diff --git a/Examples/DataRepresentation/Image/Image2.cxx b/Examples/DataRepresentation/Image/Image2.cxx index ea64432a95d..05ea94fadd6 100644 --- a/Examples/DataRepresentation/Image/Image2.cxx +++ b/Examples/DataRepresentation/Image/Image2.cxx @@ -137,7 +137,7 @@ main(int, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - ImageType::Pointer image = reader->GetOutput(); + const ImageType::Pointer image = reader->GetOutput(); // Software Guide : EndCodeSnippet // Software Guide : BeginLatex diff --git a/Examples/DataRepresentation/Image/Image3.cxx b/Examples/DataRepresentation/Image/Image3.cxx index c79828d138e..0002dfe20e1 100644 --- a/Examples/DataRepresentation/Image/Image3.cxx +++ b/Examples/DataRepresentation/Image/Image3.cxx @@ -99,7 +99,7 @@ main(int, char *[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - ImageType::PixelType pixelValue = image->GetPixel(pixelIndex); + const ImageType::PixelType pixelValue = image->GetPixel(pixelIndex); // Software Guide : EndCodeSnippet // Software Guide : BeginLatex diff --git a/Examples/DataRepresentation/Image/Image4.cxx b/Examples/DataRepresentation/Image/Image4.cxx index 87e97f22b32..408a5521fcd 100644 --- a/Examples/DataRepresentation/Image/Image4.cxx +++ b/Examples/DataRepresentation/Image/Image4.cxx @@ -459,7 +459,7 @@ main(int, char *[]) LeftEyeIndexVector[1] = LeftEyeIndex[1]; LeftEyeIndexVector[2] = LeftEyeIndex[2]; - ImageType::PointType LeftEyePointByHand = + const ImageType::PointType LeftEyePointByHand = ImageOrigin + ImageDirectionCosines * SpacingMatrix * LeftEyeIndexVector; // Software Guide : EndCodeSnippet diff --git a/Examples/DataRepresentation/Image/ImageAdaptor1.cxx b/Examples/DataRepresentation/Image/ImageAdaptor1.cxx index e282fde854b..a1f6bd76ad5 100644 --- a/Examples/DataRepresentation/Image/ImageAdaptor1.cxx +++ b/Examples/DataRepresentation/Image/ImageAdaptor1.cxx @@ -162,7 +162,7 @@ main(int argc, char * argv[]) it.GoToBegin(); while (!it.IsAtEnd()) { - float value = it.Get(); + const float value = it.Get(); sum += value; ++it; } diff --git a/Examples/DataRepresentation/Image/RGBImage.cxx b/Examples/DataRepresentation/Image/RGBImage.cxx index 8950eec44fb..2b827e537e0 100644 --- a/Examples/DataRepresentation/Image/RGBImage.cxx +++ b/Examples/DataRepresentation/Image/RGBImage.cxx @@ -88,7 +88,7 @@ main(int, char * argv[]) reader->SetFileName(filename); reader->Update(); - ImageType::Pointer image = reader->GetOutput(); + const ImageType::Pointer image = reader->GetOutput(); const ImageType::IndexType pixelIndex = { { 25, 35, 0 } }; // Software Guide : BeginLatex diff --git a/Examples/DataRepresentation/Image/VectorImage.cxx b/Examples/DataRepresentation/Image/VectorImage.cxx index d4fc1965f25..8c8e0ea4ecb 100644 --- a/Examples/DataRepresentation/Image/VectorImage.cxx +++ b/Examples/DataRepresentation/Image/VectorImage.cxx @@ -127,7 +127,7 @@ main(int, char *[]) // The GetPixel method can also be used to read Vectors // pixels from the image - ImageType::PixelType value = image->GetPixel(pixelIndex); + const ImageType::PixelType value = image->GetPixel(pixelIndex); std::cout << value << std::endl; diff --git a/Examples/DataRepresentation/Mesh/AutomaticMesh.cxx b/Examples/DataRepresentation/Mesh/AutomaticMesh.cxx index de6e13762ed..a2a5db34364 100644 --- a/Examples/DataRepresentation/Mesh/AutomaticMesh.cxx +++ b/Examples/DataRepresentation/Mesh/AutomaticMesh.cxx @@ -200,7 +200,7 @@ main(int, char *[]) // // Software Guide : EndLatex - MeshType::Pointer mesh = meshSource->GetOutput(); + const MeshType::Pointer mesh = meshSource->GetOutput(); std::cout << mesh << std::endl; // Software Guide : BeginLatex diff --git a/Examples/DataRepresentation/Mesh/Mesh1.cxx b/Examples/DataRepresentation/Mesh/Mesh1.cxx index a5243ee040a..d08211f6f90 100644 --- a/Examples/DataRepresentation/Mesh/Mesh1.cxx +++ b/Examples/DataRepresentation/Mesh/Mesh1.cxx @@ -218,12 +218,12 @@ main(int, char *[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - PointsIterator end = mesh->GetPoints()->End(); + const PointsIterator end = mesh->GetPoints()->End(); while (pointIterator != end) { - MeshType::PointType p = pointIterator.Value(); // access the point - std::cout << p << std::endl; // print the point - ++pointIterator; // advance to next point + const MeshType::PointType p = pointIterator.Value(); // access the point + std::cout << p << std::endl; // print the point + ++pointIterator; // advance to next point } // Software Guide : EndCodeSnippet diff --git a/Examples/DataRepresentation/Mesh/Mesh2.cxx b/Examples/DataRepresentation/Mesh/Mesh2.cxx index 80f041b67f4..d12ea68f75d 100644 --- a/Examples/DataRepresentation/Mesh/Mesh2.cxx +++ b/Examples/DataRepresentation/Mesh/Mesh2.cxx @@ -294,8 +294,8 @@ main(int, char *[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - CellIterator cellIterator = mesh->GetCells()->Begin(); - CellIterator end = mesh->GetCells()->End(); + CellIterator cellIterator = mesh->GetCells()->Begin(); + const CellIterator end = mesh->GetCells()->End(); // Software Guide : EndCodeSnippet diff --git a/Examples/DataRepresentation/Mesh/Mesh3.cxx b/Examples/DataRepresentation/Mesh/Mesh3.cxx index 6243a128e09..1e8b248130c 100644 --- a/Examples/DataRepresentation/Mesh/Mesh3.cxx +++ b/Examples/DataRepresentation/Mesh/Mesh3.cxx @@ -218,8 +218,8 @@ main(int, char *[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - CellDataIterator cellDataIterator = mesh->GetCellData()->Begin(); - CellDataIterator end = mesh->GetCellData()->End(); + CellDataIterator cellDataIterator = mesh->GetCellData()->Begin(); + const CellDataIterator end = mesh->GetCellData()->End(); // Software Guide : EndCodeSnippet @@ -238,7 +238,7 @@ main(int, char *[]) // Software Guide : BeginCodeSnippet while (cellDataIterator != end) { - PixelType cellValue = cellDataIterator.Value(); + const PixelType cellValue = cellDataIterator.Value(); std::cout << cellValue << std::endl; ++cellDataIterator; } diff --git a/Examples/DataRepresentation/Mesh/MeshKComplex.cxx b/Examples/DataRepresentation/Mesh/MeshKComplex.cxx index 797c7f73b4b..11cd1a8f8fe 100644 --- a/Examples/DataRepresentation/Mesh/MeshKComplex.cxx +++ b/Examples/DataRepresentation/Mesh/MeshKComplex.cxx @@ -331,8 +331,8 @@ main(int, char *[]) // Software Guide : BeginCodeSnippet using PointIterator = MeshType::PointsContainer::ConstIterator; - PointIterator pointIterator = mesh->GetPoints()->Begin(); - PointIterator pointEnd = mesh->GetPoints()->End(); + PointIterator pointIterator = mesh->GetPoints()->Begin(); + const PointIterator pointEnd = mesh->GetPoints()->End(); while (pointIterator != pointEnd) { @@ -602,7 +602,8 @@ main(int, char *[]) for (unsigned int b0 = 0; b0 < n0; ++b0) { MeshType::CellIdentifier id; - bool found = mesh->GetBoundaryAssignment(dimension, cellId, b0, &id); + const bool found = + mesh->GetBoundaryAssignment(dimension, cellId, b0, &id); if (found) std::cout << id << std::endl; } @@ -613,7 +614,8 @@ main(int, char *[]) for (unsigned int b1 = 0; b1 < n1; ++b1) { MeshType::CellIdentifier id; - bool found = mesh->GetBoundaryAssignment(dimension, cellId, b1, &id); + const bool found = + mesh->GetBoundaryAssignment(dimension, cellId, b1, &id); if (found) { std::cout << id << std::endl; @@ -625,7 +627,8 @@ main(int, char *[]) for (unsigned int b2 = 0; b2 < n2; ++b2) { MeshType::CellIdentifier id; - bool found = mesh->GetBoundaryAssignment(dimension, cellId, b2, &id); + const bool found = + mesh->GetBoundaryAssignment(dimension, cellId, b2, &id); if (found) { std::cout << id << std::endl; @@ -657,7 +660,8 @@ main(int, char *[]) for (unsigned int b1 = 0; b1 < n1; ++b1) { MeshType::CellIdentifier id; - bool found = mesh->GetBoundaryAssignment(dimension, cellId, b1, &id); + const bool found = + mesh->GetBoundaryAssignment(dimension, cellId, b1, &id); if (found) { std::cout << id << std::endl; diff --git a/Examples/DataRepresentation/Mesh/MeshPolyLine.cxx b/Examples/DataRepresentation/Mesh/MeshPolyLine.cxx index 39251baf36d..385e93c9491 100644 --- a/Examples/DataRepresentation/Mesh/MeshPolyLine.cxx +++ b/Examples/DataRepresentation/Mesh/MeshPolyLine.cxx @@ -207,8 +207,8 @@ main(int, char *[]) // Software Guide : BeginCodeSnippet using PointIterator = MeshType::PointsContainer::ConstIterator; - PointIterator pointIterator = mesh->GetPoints()->Begin(); - PointIterator pointEnd = mesh->GetPoints()->End(); + PointIterator pointIterator = mesh->GetPoints()->Begin(); + const PointIterator pointEnd = mesh->GetPoints()->End(); while (pointIterator != pointEnd) { diff --git a/Examples/DataRepresentation/Mesh/MeshTraits.cxx b/Examples/DataRepresentation/Mesh/MeshTraits.cxx index 4f917173b56..80cc27e5fb6 100644 --- a/Examples/DataRepresentation/Mesh/MeshTraits.cxx +++ b/Examples/DataRepresentation/Mesh/MeshTraits.cxx @@ -216,7 +216,7 @@ main(int, char *[]) // Software Guide : BeginCodeSnippet for (unsigned int cellId = 0; cellId < numberOfCells; ++cellId) { - CellDataType value; + const CellDataType value; mesh->SetCellData(cellId, value); } @@ -278,8 +278,8 @@ main(int, char *[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - CellDataIterator cellDataIterator = mesh->GetCellData()->Begin(); - CellDataIterator end = mesh->GetCellData()->End(); + CellDataIterator cellDataIterator = mesh->GetCellData()->Begin(); + const CellDataIterator end = mesh->GetCellData()->End(); // Software Guide : EndCodeSnippet @@ -299,7 +299,7 @@ main(int, char *[]) // Software Guide : BeginCodeSnippet while (cellDataIterator != end) { - CellDataType cellValue = cellDataIterator.Value(); + const CellDataType cellValue = cellDataIterator.Value(); std::cout << cellValue << std::endl; ++cellDataIterator; } diff --git a/Examples/DataRepresentation/Mesh/PointSet1.cxx b/Examples/DataRepresentation/Mesh/PointSet1.cxx index 9e934e2e668..b5cb0b51616 100644 --- a/Examples/DataRepresentation/Mesh/PointSet1.cxx +++ b/Examples/DataRepresentation/Mesh/PointSet1.cxx @@ -195,8 +195,8 @@ main(int, char *[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - PointType pp; - bool pointExists = pointsSet->GetPoint(1, &pp); + PointType pp; + const bool pointExists = pointsSet->GetPoint(1, &pp); if (pointExists) { diff --git a/Examples/DataRepresentation/Mesh/PointSet2.cxx b/Examples/DataRepresentation/Mesh/PointSet2.cxx index a31998be04b..77beb867d9a 100644 --- a/Examples/DataRepresentation/Mesh/PointSet2.cxx +++ b/Examples/DataRepresentation/Mesh/PointSet2.cxx @@ -149,7 +149,7 @@ main(int, char *[]) // Software Guide : BeginCodeSnippet - PointsContainer::Pointer points2 = pointSet->GetPoints(); + const PointsContainer::Pointer points2 = pointSet->GetPoints(); // Software Guide : EndCodeSnippet @@ -204,12 +204,12 @@ main(int, char *[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - PointsIterator end = points->End(); + const PointsIterator end = points->End(); while (pointIterator != end) { - PointType p = pointIterator.Value(); // access the point - std::cout << p << std::endl; // print the point - ++pointIterator; // advance to next point + const PointType p = pointIterator.Value(); // access the point + std::cout << p << std::endl; // print the point + ++pointIterator; // advance to next point } // Software Guide : EndCodeSnippet diff --git a/Examples/DataRepresentation/Mesh/PointSet3.cxx b/Examples/DataRepresentation/Mesh/PointSet3.cxx index c47f02d1737..11e862cbab4 100644 --- a/Examples/DataRepresentation/Mesh/PointSet3.cxx +++ b/Examples/DataRepresentation/Mesh/PointSet3.cxx @@ -156,8 +156,8 @@ main(int, char *[]) // Software Guide : BeginCodeSnippet unsigned int pointId = 0; - PixelType value0 = 34; - PixelType value1 = 67; + const PixelType value0 = 34; + const PixelType value1 = 67; pointData->InsertElement(pointId++, value0); pointData->InsertElement(pointId++, value1); @@ -190,7 +190,7 @@ main(int, char *[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - PointDataContainer::Pointer pointData2 = pointSet->GetPointData(); + const PointDataContainer::Pointer pointData2 = pointSet->GetPointData(); // Software Guide : EndCodeSnippet @@ -243,12 +243,12 @@ main(int, char *[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - PointDataIterator end = pointData2->End(); + const PointDataIterator end = pointData2->End(); while (pointDataIterator != end) { - PixelType p = pointDataIterator.Value(); // access the pixel data - std::cout << p << std::endl; // print the pixel data - ++pointDataIterator; // advance to next pixel/point + const PixelType p = pointDataIterator.Value(); // access the pixel data + std::cout << p << std::endl; // print the pixel data + ++pointDataIterator; // advance to next pixel/point } // Software Guide : EndCodeSnippet diff --git a/Examples/DataRepresentation/Mesh/PointSetWithCovariantVectors.cxx b/Examples/DataRepresentation/Mesh/PointSetWithCovariantVectors.cxx index df2a592e02f..a25e60b8f88 100644 --- a/Examples/DataRepresentation/Mesh/PointSetWithCovariantVectors.cxx +++ b/Examples/DataRepresentation/Mesh/PointSetWithCovariantVectors.cxx @@ -139,8 +139,8 @@ main(int, char *[]) // Software Guide : BeginCodeSnippet using PointDataIterator = PointSetType::PointDataContainer::ConstIterator; - PointDataIterator pixelIterator = pointSet->GetPointData()->Begin(); - PointDataIterator pixelEnd = pointSet->GetPointData()->End(); + PointDataIterator pixelIterator = pointSet->GetPointData()->Begin(); + const PointDataIterator pixelEnd = pointSet->GetPointData()->End(); using PointIterator = PointSetType::PointsContainer::Iterator; PointIterator pointIterator = pointSet->GetPoints()->Begin(); diff --git a/Examples/DataRepresentation/Mesh/PointSetWithVectors.cxx b/Examples/DataRepresentation/Mesh/PointSetWithVectors.cxx index f6f94858c34..1556c4ca9b3 100644 --- a/Examples/DataRepresentation/Mesh/PointSetWithVectors.cxx +++ b/Examples/DataRepresentation/Mesh/PointSetWithVectors.cxx @@ -133,8 +133,8 @@ main(int, char *[]) // Software Guide : BeginCodeSnippet using PointDataIterator = PointSetType::PointDataContainer::ConstIterator; - PointDataIterator pixelIterator = pointSet->GetPointData()->Begin(); - PointDataIterator pixelEnd = pointSet->GetPointData()->End(); + PointDataIterator pixelIterator = pointSet->GetPointData()->Begin(); + const PointDataIterator pixelEnd = pointSet->GetPointData()->End(); using PointIterator = PointSetType::PointsContainer::Iterator; PointIterator pointIterator = pointSet->GetPoints()->Begin(); diff --git a/Examples/DataRepresentation/Mesh/RGBPointSet.cxx b/Examples/DataRepresentation/Mesh/RGBPointSet.cxx index a4bb67ec51d..90d012e4bbb 100644 --- a/Examples/DataRepresentation/Mesh/RGBPointSet.cxx +++ b/Examples/DataRepresentation/Mesh/RGBPointSet.cxx @@ -108,8 +108,8 @@ main(int, char *[]) // Software Guide : BeginCodeSnippet using PointIterator = PointSetType::PointsContainer::ConstIterator; - PointIterator pointIterator = pointSet->GetPoints()->Begin(); - PointIterator pointEnd = pointSet->GetPoints()->End(); + PointIterator pointIterator = pointSet->GetPoints()->Begin(); + const PointIterator pointEnd = pointSet->GetPoints()->End(); while (pointIterator != pointEnd) { point = pointIterator.Value(); @@ -142,8 +142,8 @@ main(int, char *[]) // Software Guide : BeginCodeSnippet using PointDataIterator = PointSetType::PointDataContainer::ConstIterator; - PointDataIterator pixelIterator = pointSet->GetPointData()->Begin(); - PointDataIterator pixelEnd = pointSet->GetPointData()->End(); + PointDataIterator pixelIterator = pointSet->GetPointData()->Begin(); + const PointDataIterator pixelEnd = pointSet->GetPointData()->End(); while (pixelIterator != pixelEnd) { pixel = pixelIterator.Value(); diff --git a/Examples/DataRepresentation/Path/PolyLineParametricPath1.cxx b/Examples/DataRepresentation/Path/PolyLineParametricPath1.cxx index 47cda0ae542..64b58f10eff 100644 --- a/Examples/DataRepresentation/Path/PolyLineParametricPath1.cxx +++ b/Examples/DataRepresentation/Path/PolyLineParametricPath1.cxx @@ -84,8 +84,8 @@ main(int argc, char * argv[]) } // Software Guide : BeginCodeSnippet - ImageType::ConstPointer image = reader->GetOutput(); - auto path = PathType::New(); + const ImageType::ConstPointer image = reader->GetOutput(); + auto path = PathType::New(); using ContinuousIndexType = PathType::ContinuousIndexType; ContinuousIndexType cindex; diff --git a/Examples/Filtering/DiffusionTensor3DReconstructionImageFilter.cxx b/Examples/Filtering/DiffusionTensor3DReconstructionImageFilter.cxx index e59a0967de1..e6794b9428b 100644 --- a/Examples/Filtering/DiffusionTensor3DReconstructionImageFilter.cxx +++ b/Examples/Filtering/DiffusionTensor3DReconstructionImageFilter.cxx @@ -134,14 +134,15 @@ main(int argc, char * argv[]) // DWMRI_gradient_0003:=0.110000 0.664000 0.740000 // ... // - itk::MetaDataDictionary imgMetaDictionary = img->GetMetaDataDictionary(); + const itk::MetaDataDictionary imgMetaDictionary = + img->GetMetaDataDictionary(); std::vector imgMetaKeys = imgMetaDictionary.GetKeys(); std::vector::const_iterator itKey = imgMetaKeys.begin(); std::string metaString; TensorReconstructionImageFilterType::GradientDirectionType vect3d; - TensorReconstructionImageFilterType::GradientDirectionContainerType::Pointer - DiffusionVectors = TensorReconstructionImageFilterType:: + const TensorReconstructionImageFilterType::GradientDirectionContainerType:: + Pointer DiffusionVectors = TensorReconstructionImageFilterType:: GradientDirectionContainerType::New(); diff --git a/Examples/Filtering/DigitallyReconstructedRadiograph1.cxx b/Examples/Filtering/DigitallyReconstructedRadiograph1.cxx index 0b000a98287..559afad1dd0 100644 --- a/Examples/Filtering/DigitallyReconstructedRadiograph1.cxx +++ b/Examples/Filtering/DigitallyReconstructedRadiograph1.cxx @@ -465,7 +465,7 @@ main(int argc, char * argv[]) const InputImageType::SpacingType spacing = image->GetSpacing(); std::cout << std::endl << "Input "; - InputImageType::RegionType region = image->GetBufferedRegion(); + const InputImageType::RegionType region = image->GetBufferedRegion(); region.Print(std::cout); std::cout << " Resolution: ["; @@ -540,8 +540,8 @@ main(int argc, char * argv[]) using InputImageRegionType = InputImageType::RegionType; using InputImageSizeType = InputImageRegionType::SizeType; - InputImageRegionType imRegion = image->GetBufferedRegion(); - InputImageSizeType imSize = imRegion.GetSize(); + const InputImageRegionType imRegion = image->GetBufferedRegion(); + InputImageSizeType imSize = imRegion.GetSize(); imOrigin[0] += imRes[0] * static_cast(imSize[0]) / 2.0; imOrigin[1] += imRes[1] * static_cast(imSize[1]) / 2.0; diff --git a/Examples/Filtering/GaussianBlurImageFunction.cxx b/Examples/Filtering/GaussianBlurImageFunction.cxx index 633cf0dbdb5..d9edf099e4d 100644 --- a/Examples/Filtering/GaussianBlurImageFunction.cxx +++ b/Examples/Filtering/GaussianBlurImageFunction.cxx @@ -45,7 +45,7 @@ main(int argc, char * argv[]) const ImageType * inputImage = reader->GetOutput(); - ImageType::RegionType region = inputImage->GetBufferedRegion(); + const ImageType::RegionType region = inputImage->GetBufferedRegion(); ConstIteratorType it(inputImage, region); diff --git a/Examples/Filtering/MathematicalMorphologyBinaryFilters.cxx b/Examples/Filtering/MathematicalMorphologyBinaryFilters.cxx index 3b43e8e3cd7..5d5eb63f5be 100644 --- a/Examples/Filtering/MathematicalMorphologyBinaryFilters.cxx +++ b/Examples/Filtering/MathematicalMorphologyBinaryFilters.cxx @@ -211,8 +211,8 @@ main(int argc, char * argv[]) // Software Guide : BeginCodeSnippet thresholder->SetInput(reader->GetOutput()); - InputPixelType background = 0; - InputPixelType foreground = 255; + const InputPixelType background = 0; + const InputPixelType foreground = 255; thresholder->SetOutsideValue(background); thresholder->SetInsideValue(foreground); diff --git a/Examples/Filtering/OrientImageFilter.cxx b/Examples/Filtering/OrientImageFilter.cxx index 57645ed786c..5fabb7e54bd 100644 --- a/Examples/Filtering/OrientImageFilter.cxx +++ b/Examples/Filtering/OrientImageFilter.cxx @@ -36,10 +36,10 @@ main(int argc, char * argv[]) } // Get the inputs from the command line in C++ style - std::string inputImageFile = argv[1]; - std::string outputImageFile = argv[2]; + const std::string inputImageFile = argv[1]; + const std::string outputImageFile = argv[2]; - itk::AnatomicalOrientation desiredCoordinateOrientation{ + const itk::AnatomicalOrientation desiredCoordinateOrientation{ itk::AnatomicalOrientation::CreateFromPositiveStringEncoding(argv[3]) }; diff --git a/Examples/Filtering/OtsuMultipleThresholdImageFilter.cxx b/Examples/Filtering/OtsuMultipleThresholdImageFilter.cxx index 859892084f2..8b696fbd921 100644 --- a/Examples/Filtering/OtsuMultipleThresholdImageFilter.cxx +++ b/Examples/Filtering/OtsuMultipleThresholdImageFilter.cxx @@ -103,7 +103,7 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - ScalarImageToHistogramGeneratorType::Pointer + const ScalarImageToHistogramGeneratorType::Pointer scalarImageToHistogramGenerator = ScalarImageToHistogramGeneratorType::New(); @@ -196,7 +196,7 @@ main(int argc, char * argv[]) // // Software Guide : EndLatex - std::string outputFileBase = argv[2]; + const std::string outputFileBase = argv[2]; InputPixelType lowerThreshold = itk::NumericTraits::min(); InputPixelType upperThreshold; diff --git a/Examples/Filtering/OtsuThresholdImageFilter.cxx b/Examples/Filtering/OtsuThresholdImageFilter.cxx index 1b6f59f7cff..03cfc6ed30d 100644 --- a/Examples/Filtering/OtsuThresholdImageFilter.cxx +++ b/Examples/Filtering/OtsuThresholdImageFilter.cxx @@ -201,7 +201,7 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - int threshold = filter->GetThreshold(); + const int threshold = filter->GetThreshold(); std::cout << "Threshold = " << threshold << std::endl; // Software Guide : EndCodeSnippet diff --git a/Examples/Filtering/ResampleVolumesToBeIsotropic.cxx b/Examples/Filtering/ResampleVolumesToBeIsotropic.cxx index 2ddd995df77..77341b0cc2c 100644 --- a/Examples/Filtering/ResampleVolumesToBeIsotropic.cxx +++ b/Examples/Filtering/ResampleVolumesToBeIsotropic.cxx @@ -275,7 +275,7 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - InputImageType::ConstPointer inputImage = reader->GetOutput(); + const InputImageType::ConstPointer inputImage = reader->GetOutput(); const InputImageType::SpacingType & inputSpacing = inputImage->GetSpacing(); // Software Guide : EndCodeSnippet diff --git a/Examples/Filtering/ScaleSpaceGenerator2D.cxx b/Examples/Filtering/ScaleSpaceGenerator2D.cxx index c751bc34b19..9603f40fe6b 100644 --- a/Examples/Filtering/ScaleSpaceGenerator2D.cxx +++ b/Examples/Filtering/ScaleSpaceGenerator2D.cxx @@ -85,7 +85,7 @@ main(int argc, char * argv[]) // Software Guide : BeginCodeSnippet - int numberOfSlices = std::stoi(argv[3]); + const int numberOfSlices = std::stoi(argv[3]); for (int slice = 0; slice < numberOfSlices; ++slice) { std::ostringstream filename; diff --git a/Examples/Filtering/SecondDerivativeRecursiveGaussianImageFilter.cxx b/Examples/Filtering/SecondDerivativeRecursiveGaussianImageFilter.cxx index 7d67616ce16..7eae5aa5de5 100644 --- a/Examples/Filtering/SecondDerivativeRecursiveGaussianImageFilter.cxx +++ b/Examples/Filtering/SecondDerivativeRecursiveGaussianImageFilter.cxx @@ -104,8 +104,8 @@ main(int argc, char * argv[]) reader->SetFileName(argv[1]); - std::string outputPrefix = argv[2]; - std::string outputFileName; + const std::string outputPrefix = argv[2]; + std::string outputFileName; try { @@ -162,7 +162,7 @@ main(int argc, char * argv[]) gb->SetZeroOrder(); gc->SetSecondOrder(); - ImageType::Pointer inputImage = reader->GetOutput(); + const ImageType::Pointer inputImage = reader->GetOutput(); ga->SetInput(inputImage); gb->SetInput(ga->GetOutput()); @@ -173,7 +173,7 @@ main(int argc, char * argv[]) gc->Update(); duplicator->Update(); - ImageType::Pointer Izz = duplicator->GetOutput(); + const ImageType::Pointer Izz = duplicator->GetOutput(); // Software Guide: EndCodeSnippet writer->SetInput(Izz); @@ -200,7 +200,7 @@ main(int argc, char * argv[]) gc->Update(); duplicator->Update(); - ImageType::Pointer Iyy = duplicator->GetOutput(); + const ImageType::Pointer Iyy = duplicator->GetOutput(); // Software Guide : EndCodeSnippet writer->SetInput(Iyy); @@ -223,7 +223,7 @@ main(int argc, char * argv[]) gc->Update(); duplicator->Update(); - ImageType::Pointer Ixx = duplicator->GetOutput(); + const ImageType::Pointer Ixx = duplicator->GetOutput(); // Software Guide : EndCodeSnippet writer->SetInput(Ixx); @@ -252,7 +252,7 @@ main(int argc, char * argv[]) gc->Update(); duplicator->Update(); - ImageType::Pointer Iyz = duplicator->GetOutput(); + const ImageType::Pointer Iyz = duplicator->GetOutput(); // Software Guide : EndCodeSnippet writer->SetInput(Iyz); @@ -278,7 +278,7 @@ main(int argc, char * argv[]) gc->Update(); duplicator->Update(); - ImageType::Pointer Ixz = duplicator->GetOutput(); + const ImageType::Pointer Ixz = duplicator->GetOutput(); // Software Guide : EndCodeSnippet // Software Guide : BeginLatex @@ -305,7 +305,7 @@ main(int argc, char * argv[]) gc->Update(); duplicator->Update(); - ImageType::Pointer Ixy = duplicator->GetOutput(); + const ImageType::Pointer Ixy = duplicator->GetOutput(); writer->SetInput(Ixy); outputFileName = outputPrefix + "-Ixy.mhd"; diff --git a/Examples/Filtering/SubsampleVolume.cxx b/Examples/Filtering/SubsampleVolume.cxx index fa5541f54fc..860b2bfb30f 100644 --- a/Examples/Filtering/SubsampleVolume.cxx +++ b/Examples/Filtering/SubsampleVolume.cxx @@ -119,7 +119,7 @@ main(int argc, char * argv[]) } - InputImageType::ConstPointer inputImage = reader->GetOutput(); + const InputImageType::ConstPointer inputImage = reader->GetOutput(); // Software Guide : BeginLatex diff --git a/Examples/Filtering/WarpImageFilter1.cxx b/Examples/Filtering/WarpImageFilter1.cxx index f21c77d4cf3..fa18eb06126 100644 --- a/Examples/Filtering/WarpImageFilter1.cxx +++ b/Examples/Filtering/WarpImageFilter1.cxx @@ -97,7 +97,7 @@ main(int argc, char * argv[]) fieldReader->SetFileName(argv[2]); fieldReader->Update(); - DisplacementFieldType::ConstPointer deformationField = + const DisplacementFieldType::ConstPointer deformationField = fieldReader->GetOutput(); // Software Guide : EndCodeSnippet diff --git a/Examples/IO/DicomImageReadChangeHeaderWrite.cxx b/Examples/IO/DicomImageReadChangeHeaderWrite.cxx index c9bcfa2ee18..207dc94a3b5 100644 --- a/Examples/IO/DicomImageReadChangeHeaderWrite.cxx +++ b/Examples/IO/DicomImageReadChangeHeaderWrite.cxx @@ -141,7 +141,7 @@ main(int argc, char * argv[]) // Software Guide : BeginCodeSnippet - InputImageType::Pointer inputImage = reader->GetOutput(); + const InputImageType::Pointer inputImage = reader->GetOutput(); using DictionaryType = itk::MetaDataDictionary; DictionaryType & dictionary = inputImage->GetMetaDataDictionary(); // Software Guide : EndCodeSnippet @@ -162,8 +162,8 @@ main(int argc, char * argv[]) // Software Guide : BeginCodeSnippet for (int i = 3; i < argc; i += 2) { - std::string entryId(argv[i]); - std::string value(argv[i + 1]); + const std::string entryId(argv[i]); + const std::string value(argv[i + 1]); itk::EncapsulateMetaData(dictionary, entryId, value); } // Software Guide : EndCodeSnippet diff --git a/Examples/IO/DicomImageReadPrintTags.cxx b/Examples/IO/DicomImageReadPrintTags.cxx index 8a9ef18af2f..f9095e528ab 100644 --- a/Examples/IO/DicomImageReadPrintTags.cxx +++ b/Examples/IO/DicomImageReadPrintTags.cxx @@ -198,9 +198,9 @@ main(int argc, char * argv[]) // Software Guide : BeginCodeSnippet while (itr != end) { - itk::MetaDataObjectBase::Pointer entry = itr->second; + const itk::MetaDataObjectBase::Pointer entry = itr->second; - MetaDataStringType::Pointer entryvalue = + const MetaDataStringType::Pointer entryvalue = dynamic_cast(entry.GetPointer()); // Software Guide : EndCodeSnippet @@ -221,9 +221,9 @@ main(int argc, char * argv[]) // Software Guide : BeginCodeSnippet if (entryvalue) { - std::string tagkey = itr->first; - std::string labelId; - bool found = itk::GDCMImageIO::GetLabelFromTag(tagkey, labelId); + const std::string tagkey = itr->first; + std::string labelId; + const bool found = itk::GDCMImageIO::GetLabelFromTag(tagkey, labelId); // Software Guide : EndCodeSnippet // Software Guide : BeginLatex @@ -236,7 +236,7 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - std::string tagvalue = entryvalue->GetMetaDataObjectValue(); + const std::string tagvalue = entryvalue->GetMetaDataObjectValue(); // Software Guide : EndCodeSnippet // Software Guide : BeginLatex @@ -281,8 +281,8 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - std::string entryId = "0010|0010"; - auto tagItr = dictionary.Find(entryId); + const std::string entryId = "0010|0010"; + auto tagItr = dictionary.Find(entryId); // Software Guide : EndCodeSnippet // Software Guide : BeginLatex // @@ -294,7 +294,7 @@ main(int argc, char * argv[]) // Software Guide : BeginCodeSnippet if (tagItr != end) { - MetaDataStringType::ConstPointer entryvalue = + const MetaDataStringType::ConstPointer entryvalue = dynamic_cast(tagItr->second.GetPointer()); // Software Guide : EndCodeSnippet @@ -309,7 +309,7 @@ main(int argc, char * argv[]) // Software Guide : BeginCodeSnippet if (entryvalue) { - std::string tagvalue = entryvalue->GetMetaDataObjectValue(); + const std::string tagvalue = entryvalue->GetMetaDataObjectValue(); std::cout << "Patient's Name (" << entryId << ") "; std::cout << " is: " << tagvalue.c_str() << std::endl; } @@ -325,8 +325,8 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - std::string tagkey = "0008|1050"; - std::string labelId; + const std::string tagkey = "0008|1050"; + std::string labelId; if (itk::GDCMImageIO::GetLabelFromTag(tagkey, labelId)) { std::string value; @@ -365,8 +365,8 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - itk::IOPixelEnum pixelType = reader->GetImageIO()->GetPixelType(); - itk::IOComponentEnum componentType = + const itk::IOPixelEnum pixelType = reader->GetImageIO()->GetPixelType(); + const itk::IOComponentEnum componentType = reader->GetImageIO()->GetComponentType(); std::cout << "PixelType: " << reader->GetImageIO()->GetPixelTypeAsString(pixelType) diff --git a/Examples/IO/DicomPrintPatientInformation.cxx b/Examples/IO/DicomPrintPatientInformation.cxx index a989d2470f5..430ba09d7ee 100644 --- a/Examples/IO/DicomPrintPatientInformation.cxx +++ b/Examples/IO/DicomPrintPatientInformation.cxx @@ -32,7 +32,7 @@ FindDicomTag(const std::string & entryId, const itk::GDCMImageIO::Pointer dicomIO) { std::string tagvalue; - bool found = dicomIO->GetValueFromTag(entryId, tagvalue); + const bool found = dicomIO->GetValueFromTag(entryId, tagvalue); if (!found) { tagvalue = "NOT FOUND"; @@ -74,15 +74,15 @@ main(int argc, char * argv[]) } - std::string patientName = FindDicomTag("0010|0010", dicomIO); - std::string patientID = FindDicomTag("0010|0020", dicomIO); - std::string patientSex = FindDicomTag("0010|0040", dicomIO); - std::string patientAge = FindDicomTag("0010|1010", dicomIO); - std::string studyDate = FindDicomTag("0008|0020", dicomIO); - std::string modality = FindDicomTag("0008|0060", dicomIO); - std::string manufacturer = FindDicomTag("0008|0070", dicomIO); - std::string institution = FindDicomTag("0008|0080", dicomIO); - std::string model = FindDicomTag("0008|1090", dicomIO); + const std::string patientName = FindDicomTag("0010|0010", dicomIO); + const std::string patientID = FindDicomTag("0010|0020", dicomIO); + const std::string patientSex = FindDicomTag("0010|0040", dicomIO); + const std::string patientAge = FindDicomTag("0010|1010", dicomIO); + const std::string studyDate = FindDicomTag("0008|0020", dicomIO); + const std::string modality = FindDicomTag("0008|0060", dicomIO); + const std::string manufacturer = FindDicomTag("0008|0070", dicomIO); + const std::string institution = FindDicomTag("0008|0080", dicomIO); + const std::string model = FindDicomTag("0008|1090", dicomIO); std::cout << "Patient Name : " << patientName << std::endl; diff --git a/Examples/IO/DicomSeriesReadPrintTags.cxx b/Examples/IO/DicomSeriesReadPrintTags.cxx index 9f496f1be9e..88c32387440 100644 --- a/Examples/IO/DicomSeriesReadPrintTags.cxx +++ b/Examples/IO/DicomSeriesReadPrintTags.cxx @@ -119,7 +119,7 @@ main(int argc, char * argv[]) // Software Guide : BeginCodeSnippet using FileNamesContainer = std::vector; - FileNamesContainer fileNames = nameGenerator->GetInputFileNames(); + const FileNamesContainer fileNames = nameGenerator->GetInputFileNames(); reader->SetFileNames(fileNames); // Software Guide : EndCodeSnippet @@ -212,15 +212,15 @@ main(int argc, char * argv[]) // Software Guide : BeginCodeSnippet while (itr != end) { - itk::MetaDataObjectBase::Pointer entry = itr->second; + const itk::MetaDataObjectBase::Pointer entry = itr->second; - MetaDataStringType::Pointer entryvalue = + const MetaDataStringType::Pointer entryvalue = dynamic_cast(entry.GetPointer()); if (entryvalue) { - std::string tagkey = itr->first; - std::string tagvalue = entryvalue->GetMetaDataObjectValue(); + const std::string tagkey = itr->first; + const std::string tagvalue = entryvalue->GetMetaDataObjectValue(); std::cout << tagkey << " = " << tagvalue << std::endl; } @@ -238,7 +238,7 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - std::string entryId = "0010|0010"; + const std::string entryId = "0010|0010"; auto tagItr = dictionary.Find(entryId); @@ -260,12 +260,12 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - MetaDataStringType::ConstPointer entryvalue = + const MetaDataStringType::ConstPointer entryvalue = dynamic_cast(tagItr->second.GetPointer()); if (entryvalue) { - std::string tagvalue = entryvalue->GetMetaDataObjectValue(); + const std::string tagvalue = entryvalue->GetMetaDataObjectValue(); std::cout << "Patient's Name (" << entryId << ") "; std::cout << " is: " << tagvalue << std::endl; } diff --git a/Examples/IO/DicomSeriesReadSeriesWrite.cxx b/Examples/IO/DicomSeriesReadSeriesWrite.cxx index e8f983a020f..900e76bf98d 100644 --- a/Examples/IO/DicomSeriesReadSeriesWrite.cxx +++ b/Examples/IO/DicomSeriesReadSeriesWrite.cxx @@ -143,7 +143,7 @@ main(int argc, char * argv[]) namesGenerator->GetInputFileNames(); // Software Guide : EndCodeSnippet - size_t numberOfFileNames = filenames.size(); + const size_t numberOfFileNames = filenames.size(); std::cout << numberOfFileNames << std::endl; for (unsigned int fni = 0; fni < numberOfFileNames; ++fni) { diff --git a/Examples/IO/ImageReadDicomSeriesWrite.cxx b/Examples/IO/ImageReadDicomSeriesWrite.cxx index 47010c5eb25..cc91e531d5f 100644 --- a/Examples/IO/ImageReadDicomSeriesWrite.cxx +++ b/Examples/IO/ImageReadDicomSeriesWrite.cxx @@ -115,7 +115,7 @@ main(int argc, char * argv[]) seriesWriter->SetImageIO(gdcmIO); - ImageType::RegionType region = + const ImageType::RegionType region = reader->GetOutput()->GetLargestPossibleRegion(); ImageType::IndexType start = region.GetIndex(); diff --git a/Examples/IO/ImageReadExtractFilterInsertWrite.cxx b/Examples/IO/ImageReadExtractFilterInsertWrite.cxx index 077225a39ab..540b76c6623 100644 --- a/Examples/IO/ImageReadExtractFilterInsertWrite.cxx +++ b/Examples/IO/ImageReadExtractFilterInsertWrite.cxx @@ -165,8 +165,9 @@ main(int argc, char ** argv) // Software Guide : BeginCodeSnippet reader->Update(); - const InputImageType * inputImage = reader->GetOutput(); - InputImageType::RegionType inputRegion = inputImage->GetBufferedRegion(); + const InputImageType * inputImage = reader->GetOutput(); + const InputImageType::RegionType inputRegion = + inputImage->GetBufferedRegion(); // Software Guide : EndCodeSnippet // Software Guide : BeginLatex diff --git a/Examples/IO/ImageReadExtractWrite.cxx b/Examples/IO/ImageReadExtractWrite.cxx index d89e87bb8e6..edae8cd341e 100644 --- a/Examples/IO/ImageReadExtractWrite.cxx +++ b/Examples/IO/ImageReadExtractWrite.cxx @@ -175,7 +175,7 @@ main(int argc, char ** argv) // Software Guide : BeginCodeSnippet reader->UpdateOutputInformation(); - InputImageType::RegionType inputRegion = + const InputImageType::RegionType inputRegion = reader->GetOutput()->GetLargestPossibleRegion(); // Software Guide : EndCodeSnippet diff --git a/Examples/IO/ImageReadImageSeriesWrite.cxx b/Examples/IO/ImageReadImageSeriesWrite.cxx index 3067f9d4439..e8d36a4dcd1 100644 --- a/Examples/IO/ImageReadImageSeriesWrite.cxx +++ b/Examples/IO/ImageReadImageSeriesWrite.cxx @@ -153,10 +153,10 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - ImageType::ConstPointer inputImage = reader->GetOutput(); - ImageType::RegionType region = inputImage->GetLargestPossibleRegion(); - ImageType::IndexType start = region.GetIndex(); - ImageType::SizeType size = region.GetSize(); + const ImageType::ConstPointer inputImage = reader->GetOutput(); + const ImageType::RegionType region = inputImage->GetLargestPossibleRegion(); + ImageType::IndexType start = region.GetIndex(); + ImageType::SizeType size = region.GetSize(); // Software Guide : EndCodeSnippet // Software Guide : BeginLatex diff --git a/Examples/IO/ImageSeriesReadWrite2.cxx b/Examples/IO/ImageSeriesReadWrite2.cxx index 214a69f3fe5..cc1331342ea 100644 --- a/Examples/IO/ImageSeriesReadWrite2.cxx +++ b/Examples/IO/ImageSeriesReadWrite2.cxx @@ -124,12 +124,12 @@ main(int argc, char ** argv) // Software Guide : EndCodeSnippet - std::string directory = argv[1]; - std::string regularExpression = argv[2]; + const std::string directory = argv[1]; + const std::string regularExpression = argv[2]; const unsigned int subMatch = std::stoi(argv[3]); - std::string outputFilename = argv[4]; + const std::string outputFilename = argv[4]; // Software Guide : BeginLatex diff --git a/Examples/IO/RGBImageReadWrite.cxx b/Examples/IO/RGBImageReadWrite.cxx index 40426cb5c8f..5d27670ff0c 100644 --- a/Examples/IO/RGBImageReadWrite.cxx +++ b/Examples/IO/RGBImageReadWrite.cxx @@ -102,7 +102,7 @@ main(int argc, char ** argv) // Software Guide : EndCodeSnippet - ImageType::Pointer image = reader->GetOutput(); + const ImageType::Pointer image = reader->GetOutput(); writer->SetInput(image); diff --git a/Examples/IO/TransformReadWrite.cxx b/Examples/IO/TransformReadWrite.cxx index 1ad2c86edd7..0550398448a 100644 --- a/Examples/IO/TransformReadWrite.cxx +++ b/Examples/IO/TransformReadWrite.cxx @@ -82,7 +82,7 @@ main(int argc, char * argv[]) bspline->SetTransformDomainOrigin(origin); bspline->SetTransformDomainPhysicalDimensions(dimensions); - BSplineTransformType::ParametersType parameters( + const BSplineTransformType::ParametersType parameters( bspline->GetNumberOfParameters()); bspline->SetParameters(parameters); bspline->SetIdentity(); @@ -203,7 +203,7 @@ main(int argc, char * argv[]) auto it = transforms->begin(); if (!strcmp((*it)->GetNameOfClass(), "CompositeTransform")) { - ReadCompositeTransformType::Pointer compositeRead = + const ReadCompositeTransformType::Pointer compositeRead = static_cast((*it).GetPointer()); compositeRead->Print(std::cout); } diff --git a/Examples/IO/VisibleHumanPasteWrite.cxx b/Examples/IO/VisibleHumanPasteWrite.cxx index fc7b13abadf..1bcffc71413 100644 --- a/Examples/IO/VisibleHumanPasteWrite.cxx +++ b/Examples/IO/VisibleHumanPasteWrite.cxx @@ -47,8 +47,8 @@ main(int argc, char * argv[]) } - std::string inputImageFile = argv[1]; - std::string outputImageFile = argv[2]; + const std::string inputImageFile = argv[1]; + const std::string outputImageFile = argv[2]; using RGBPixelType = itk::RGBPixel; using RGB2DImageType = itk::Image; @@ -87,7 +87,7 @@ main(int argc, char * argv[]) // except that it is not templated over the image dimension, because // of the runtime nature of IO. composeRGB->UpdateOutputInformation(); - RGB2DImageType::RegionType largest = + const RGB2DImageType::RegionType largest = composeRGB->GetOutput()->GetLargestPossibleRegion(); itk::ImageIORegion halfIO(2); halfIO.SetIndex(0, @@ -118,9 +118,9 @@ main(int argc, char * argv[]) writer->SetIORegion(halfIO); writer->SetInput(adaptor); - itk::SimpleFilterWatcher watcher1(writer, "stream pasting writing"); + const itk::SimpleFilterWatcher watcher1(writer, "stream pasting writing"); - itk::SimpleFilterWatcher watcher(grad, "stream gradient magnitude"); + const itk::SimpleFilterWatcher watcher(grad, "stream gradient magnitude"); try diff --git a/Examples/IO/VisibleHumanStreamReadWrite.cxx b/Examples/IO/VisibleHumanStreamReadWrite.cxx index 353aa979bcb..a46c79fe572 100644 --- a/Examples/IO/VisibleHumanStreamReadWrite.cxx +++ b/Examples/IO/VisibleHumanStreamReadWrite.cxx @@ -55,8 +55,8 @@ main(int argc, char * argv[]) return EXIT_FAILURE; } - std::string visibleHumanPath = argv[1]; - std::string outputImageFile = argv[2]; + const std::string visibleHumanPath = argv[1]; + const std::string outputImageFile = argv[2]; using RGBPixelType = itk::RGBPixel; using PixelType = unsigned char; @@ -162,7 +162,7 @@ main(int argc, char * argv[]) writer->SetNumberOfStreamDivisions(200); writer->SetInput(extract->GetOutput()); - itk::SimpleFilterWatcher watcher1(writer, "stream writing"); + const itk::SimpleFilterWatcher watcher1(writer, "stream writing"); try diff --git a/Examples/IO/XML/DOMFindDemo.cxx b/Examples/IO/XML/DOMFindDemo.cxx index 15ce8d11a79..49982407864 100644 --- a/Examples/IO/XML/DOMFindDemo.cxx +++ b/Examples/IO/XML/DOMFindDemo.cxx @@ -63,7 +63,7 @@ main(int argc, char * argv[]) auto reader = itk::DOMNodeXMLReader::New(); reader->SetFileName(argv[1]); reader->Update(); - itk::DOMNode::Pointer dom = reader->GetOutput(); + const itk::DOMNode::Pointer dom = reader->GetOutput(); // the following code demonstrates the DOM function Find("QueryString"); // it navigates through the loaded XML document by typing a query string @@ -73,7 +73,7 @@ main(int argc, char * argv[]) do { std::cout << "query = \"" << query << "\"" << std::endl; - itk::DOMNode::Pointer dom2 = dom1->Find(query); + const itk::DOMNode::Pointer dom2 = dom1->Find(query); if ((itk::DOMNode *)dom2 == nullptr) { std::cout << "invalid query!" << std::endl; diff --git a/Examples/IO/XML/itkParticleSwarmOptimizerSAXReader.cxx b/Examples/IO/XML/itkParticleSwarmOptimizerSAXReader.cxx index 3e007a841ca..628c0d4989c 100644 --- a/Examples/IO/XML/itkParticleSwarmOptimizerSAXReader.cxx +++ b/Examples/IO/XML/itkParticleSwarmOptimizerSAXReader.cxx @@ -31,7 +31,7 @@ int ParticleSwarmOptimizerSAXReader::CanReadFile(const char * name) { std::ifstream ifs(name); - int yes = ifs.is_open(); + const int yes = ifs.is_open(); if (yes) { ifs.close(); @@ -135,7 +135,7 @@ ParticleSwarmOptimizerSAXReader::CharacterDataHandler(const char * inData, { std::vector data; - std::string s(inData, inLength); + const std::string s(inData, inLength); std::istringstream iss(s); while (iss.good()) { diff --git a/Examples/IO/XML/itkParticleSwarmOptimizerSAXWriter.cxx b/Examples/IO/XML/itkParticleSwarmOptimizerSAXWriter.cxx index 39dd7f5bc25..53da4ee2f60 100644 --- a/Examples/IO/XML/itkParticleSwarmOptimizerSAXWriter.cxx +++ b/Examples/IO/XML/itkParticleSwarmOptimizerSAXWriter.cxx @@ -30,7 +30,7 @@ int ParticleSwarmOptimizerSAXWriter::CanWriteFile(const char * name) { std::ofstream ofs(name); - int yes = ofs.is_open(); + const int yes = ofs.is_open(); if (yes) { ofs.close(); diff --git a/Examples/Iterators/ImageLinearIteratorWithIndex2.cxx b/Examples/Iterators/ImageLinearIteratorWithIndex2.cxx index b31c2d44e05..519e77f6651 100644 --- a/Examples/Iterators/ImageLinearIteratorWithIndex2.cxx +++ b/Examples/Iterators/ImageLinearIteratorWithIndex2.cxx @@ -79,7 +79,7 @@ main(int argc, char * argv[]) return EXIT_FAILURE; } - Image4DType::ConstPointer image4D = reader4D->GetOutput(); + const Image4DType::ConstPointer image4D = reader4D->GetOutput(); // Software Guide : BeginLatex // @@ -106,7 +106,7 @@ main(int argc, char * argv[]) Spacing3DType spacing3D; Origin3DType origin3D; - Image4DType::RegionType region4D = image4D->GetBufferedRegion(); + const Image4DType::RegionType region4D = image4D->GetBufferedRegion(); Index4DType index4D = region4D.GetIndex(); Size4DType size4D = region4D.GetSize(); @@ -168,7 +168,7 @@ main(int argc, char * argv[]) sum += it.Get(); ++it; } - MeanType mean = + const MeanType mean = static_cast(sum) / static_cast(timeLength); index3D[0] = index4D[0]; diff --git a/Examples/Iterators/ImageSliceIteratorWithIndex.cxx b/Examples/Iterators/ImageSliceIteratorWithIndex.cxx index 43e6a661aff..8541b70bfa7 100644 --- a/Examples/Iterators/ImageSliceIteratorWithIndex.cxx +++ b/Examples/Iterators/ImageSliceIteratorWithIndex.cxx @@ -197,7 +197,8 @@ main(int argc, char * argv[]) ImageType2D::RegionType::SizeType size; ImageType2D::RegionType::IndexType index; - ImageType3D::RegionType requestedRegion = inputImage->GetRequestedRegion(); + const ImageType3D::RegionType requestedRegion = + inputImage->GetRequestedRegion(); index[direction[0]] = requestedRegion.GetIndex()[direction[0]]; index[1 - direction[0]] = requestedRegion.GetIndex()[direction[1]]; diff --git a/Examples/Iterators/NeighborhoodIterators1.cxx b/Examples/Iterators/NeighborhoodIterators1.cxx index 4aa6e2e50d8..a0806e2ef3f 100644 --- a/Examples/Iterators/NeighborhoodIterators1.cxx +++ b/Examples/Iterators/NeighborhoodIterators1.cxx @@ -159,12 +159,12 @@ main(int argc, char ** argv) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - NeighborhoodIteratorType::OffsetType offset1 = { { -1, -1 } }; - NeighborhoodIteratorType::OffsetType offset2 = { { 1, -1 } }; - NeighborhoodIteratorType::OffsetType offset3 = { { -1, 0 } }; - NeighborhoodIteratorType::OffsetType offset4 = { { 1, 0 } }; - NeighborhoodIteratorType::OffsetType offset5 = { { -1, 1 } }; - NeighborhoodIteratorType::OffsetType offset6 = { { 1, 1 } }; + const NeighborhoodIteratorType::OffsetType offset1 = { { -1, -1 } }; + const NeighborhoodIteratorType::OffsetType offset2 = { { 1, -1 } }; + const NeighborhoodIteratorType::OffsetType offset3 = { { -1, 0 } }; + const NeighborhoodIteratorType::OffsetType offset4 = { { 1, 0 } }; + const NeighborhoodIteratorType::OffsetType offset5 = { { -1, 1 } }; + const NeighborhoodIteratorType::OffsetType offset6 = { { 1, 1 } }; // Software Guide : EndCodeSnippet // Software Guide : BeginLatex diff --git a/Examples/Iterators/NeighborhoodIterators2.cxx b/Examples/Iterators/NeighborhoodIterators2.cxx index de5d989de0b..fb0acea4eb6 100644 --- a/Examples/Iterators/NeighborhoodIterators2.cxx +++ b/Examples/Iterators/NeighborhoodIterators2.cxx @@ -124,11 +124,12 @@ main(int argc, char ** argv) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - NeighborhoodIteratorType::RadiusType radius = sobelOperator.GetRadius(); - NeighborhoodIteratorType it( + const NeighborhoodIteratorType::RadiusType radius = + sobelOperator.GetRadius(); + NeighborhoodIteratorType it( radius, reader->GetOutput(), reader->GetOutput()->GetRequestedRegion()); - itk::NeighborhoodInnerProduct innerProduct; + const itk::NeighborhoodInnerProduct innerProduct; // Software Guide : EndCodeSnippet // Software Guide : BeginLatex diff --git a/Examples/Iterators/NeighborhoodIterators3.cxx b/Examples/Iterators/NeighborhoodIterators3.cxx index b960ac1d5ac..241dc332d8d 100644 --- a/Examples/Iterators/NeighborhoodIterators3.cxx +++ b/Examples/Iterators/NeighborhoodIterators3.cxx @@ -98,7 +98,7 @@ main(int argc, char ** argv) sobelOperator.SetDirection(std::stoi(argv[3])); sobelOperator.CreateDirectional(); - itk::NeighborhoodInnerProduct innerProduct; + const itk::NeighborhoodInnerProduct innerProduct; // Software Guide : BeginLatex // diff --git a/Examples/Iterators/NeighborhoodIterators4.cxx b/Examples/Iterators/NeighborhoodIterators4.cxx index d6fefe4dd88..1d178f15299 100644 --- a/Examples/Iterators/NeighborhoodIterators4.cxx +++ b/Examples/Iterators/NeighborhoodIterators4.cxx @@ -100,7 +100,7 @@ main(int argc, char ** argv) output->SetRegions(reader->GetOutput()->GetRequestedRegion()); output->Allocate(); - itk::NeighborhoodInnerProduct innerProduct; + const itk::NeighborhoodInnerProduct innerProduct; using FaceCalculatorType = itk::NeighborhoodAlgorithm::ImageBoundaryFacesCalculator; @@ -170,7 +170,7 @@ main(int argc, char ** argv) // Swap the input and output buffers if (i != ImageType::ImageDimension - 1) { - ImageType::Pointer tmp = input; + const ImageType::Pointer tmp = input; input = output; output = tmp; } diff --git a/Examples/Iterators/NeighborhoodIterators5.cxx b/Examples/Iterators/NeighborhoodIterators5.cxx index 283dacead7a..df0af750479 100644 --- a/Examples/Iterators/NeighborhoodIterators5.cxx +++ b/Examples/Iterators/NeighborhoodIterators5.cxx @@ -92,7 +92,7 @@ main(int argc, char ** argv) output->SetRegions(reader->GetOutput()->GetRequestedRegion()); output->Allocate(); - itk::NeighborhoodInnerProduct innerProduct; + const itk::NeighborhoodInnerProduct innerProduct; using FaceCalculatorType = itk::NeighborhoodAlgorithm::ImageBoundaryFacesCalculator; @@ -164,7 +164,7 @@ main(int argc, char ** argv) // Swap the input and output buffers if (i != ImageType::ImageDimension - 1) { - ImageType::Pointer tmp = input; + const ImageType::Pointer tmp = input; input = output; output = tmp; } diff --git a/Examples/Iterators/NeighborhoodIterators6.cxx b/Examples/Iterators/NeighborhoodIterators6.cxx index a3c1d5054e6..f8cad8178c7 100644 --- a/Examples/Iterators/NeighborhoodIterators6.cxx +++ b/Examples/Iterators/NeighborhoodIterators6.cxx @@ -117,7 +117,7 @@ main(int argc, char ** argv) return EXIT_FAILURE; } - ImageType::Pointer input = adder->GetOutput(); + const ImageType::Pointer input = adder->GetOutput(); // Software Guide : BeginLatex // diff --git a/Examples/Iterators/ShapedNeighborhoodIterators1.cxx b/Examples/Iterators/ShapedNeighborhoodIterators1.cxx index 167a8798fab..6fa85350060 100644 --- a/Examples/Iterators/ShapedNeighborhoodIterators1.cxx +++ b/Examples/Iterators/ShapedNeighborhoodIterators1.cxx @@ -110,7 +110,7 @@ main(int argc, char ** argv) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - unsigned int element_radius = std::stoi(argv[3]); + const unsigned int element_radius = std::stoi(argv[3]); auto radius = itk::MakeFilled( element_radius); // Software Guide : EndCodeSnippet @@ -180,7 +180,7 @@ main(int argc, char ** argv) { ShapedNeighborhoodIteratorType::OffsetType off; - float dis = std::sqrt(x * x + y * y); + const float dis = std::sqrt(x * x + y * y); if (dis <= rad) { off[0] = static_cast(x); diff --git a/Examples/Iterators/ShapedNeighborhoodIterators2.cxx b/Examples/Iterators/ShapedNeighborhoodIterators2.cxx index 3f163eea81f..2c8a00086be 100644 --- a/Examples/Iterators/ShapedNeighborhoodIterators2.cxx +++ b/Examples/Iterators/ShapedNeighborhoodIterators2.cxx @@ -52,7 +52,7 @@ main(int argc, char ** argv) auto reader = ReaderType::New(); reader->SetFileName(argv[1]); - unsigned int element_radius = std::stoi(argv[3]); + const unsigned int element_radius = std::stoi(argv[3]); try { @@ -101,7 +101,7 @@ main(int argc, char ** argv) { ShapedNeighborhoodIteratorType::OffsetType off; - float dis = std::sqrt(x * x + y * y); + const float dis = std::sqrt(x * x + y * y); if (dis <= rad) { off[0] = static_cast(x); diff --git a/Examples/RegistrationITKv4/BSplineWarping1.cxx b/Examples/RegistrationITKv4/BSplineWarping1.cxx index 3502fe55a3b..b1198aa62c2 100644 --- a/Examples/RegistrationITKv4/BSplineWarping1.cxx +++ b/Examples/RegistrationITKv4/BSplineWarping1.cxx @@ -130,7 +130,7 @@ main(int argc, char * argv[]) movingWriter->SetFileName(argv[4]); - FixedImageType::ConstPointer fixedImage = fixedReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = fixedReader->GetOutput(); using FilterType = @@ -153,17 +153,19 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - FixedImageType::SpacingType fixedSpacing = fixedImage->GetSpacing(); - FixedImageType::PointType fixedOrigin = fixedImage->GetOrigin(); - FixedImageType::DirectionType fixedDirection = fixedImage->GetDirection(); + FixedImageType::SpacingType fixedSpacing = fixedImage->GetSpacing(); + const FixedImageType::PointType fixedOrigin = fixedImage->GetOrigin(); + const FixedImageType::DirectionType fixedDirection = + fixedImage->GetDirection(); resampler->SetOutputSpacing(fixedSpacing); resampler->SetOutputOrigin(fixedOrigin); resampler->SetOutputDirection(fixedDirection); - FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); - FixedImageType::SizeType fixedSize = fixedRegion.GetSize(); + const FixedImageType::RegionType fixedRegion = + fixedImage->GetBufferedRegion(); + FixedImageType::SizeType fixedSize = fixedRegion.GetSize(); resampler->SetSize(fixedSize); resampler->SetOutputStartIndex(fixedRegion.GetIndex()); diff --git a/Examples/RegistrationITKv4/BSplineWarping2.cxx b/Examples/RegistrationITKv4/BSplineWarping2.cxx index f7f49df58e0..04d4b04e365 100644 --- a/Examples/RegistrationITKv4/BSplineWarping2.cxx +++ b/Examples/RegistrationITKv4/BSplineWarping2.cxx @@ -135,7 +135,7 @@ main(int argc, char * argv[]) movingWriter->SetFileName(argv[4]); // Software Guide : EndCodeSnippet - FixedImageType::ConstPointer fixedImage = fixedReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = fixedReader->GetOutput(); using FilterType = @@ -150,9 +150,10 @@ main(int argc, char * argv[]) resampler->SetInterpolator(interpolator); - FixedImageType::SpacingType fixedSpacing = fixedImage->GetSpacing(); - FixedImageType::PointType fixedOrigin = fixedImage->GetOrigin(); - FixedImageType::DirectionType fixedDirection = fixedImage->GetDirection(); + FixedImageType::SpacingType fixedSpacing = fixedImage->GetSpacing(); + const FixedImageType::PointType fixedOrigin = fixedImage->GetOrigin(); + const FixedImageType::DirectionType fixedDirection = + fixedImage->GetDirection(); // Software Guide : BeginLatex // @@ -166,8 +167,9 @@ main(int argc, char * argv[]) resampler->SetOutputOrigin(fixedOrigin); resampler->SetOutputDirection(fixedDirection); - FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); - FixedImageType::SizeType fixedSize = fixedRegion.GetSize(); + const FixedImageType::RegionType fixedRegion = + fixedImage->GetBufferedRegion(); + FixedImageType::SizeType fixedSize = fixedRegion.GetSize(); resampler->SetSize(fixedSize); resampler->SetOutputStartIndex(fixedRegion.GetIndex()); // Software Guide : EndCodeSnippet diff --git a/Examples/RegistrationITKv4/ChangeInformationImageFilter.cxx b/Examples/RegistrationITKv4/ChangeInformationImageFilter.cxx index cf7189942f0..b8c750b8cf6 100644 --- a/Examples/RegistrationITKv4/ChangeInformationImageFilter.cxx +++ b/Examples/RegistrationITKv4/ChangeInformationImageFilter.cxx @@ -117,15 +117,15 @@ main(int argc, char * argv[]) return EXIT_FAILURE; } - ImageType::ConstPointer inputImage = reader->GetOutput(); + const ImageType::ConstPointer inputImage = reader->GetOutput(); - ImageType::PointType origin = inputImage->GetOrigin(); - ImageType::SpacingType spacing = inputImage->GetSpacing(); - ImageType::DirectionType direction = inputImage->GetDirection(); + ImageType::PointType origin = inputImage->GetOrigin(); + ImageType::SpacingType spacing = inputImage->GetSpacing(); + const ImageType::DirectionType direction = inputImage->GetDirection(); if (argc > 3) { - double scale = std::stod(argv[3]); + const double scale = std::stod(argv[3]); for (unsigned int i = 0; i < Dimension; ++i) { spacing[i] *= scale; @@ -151,13 +151,14 @@ main(int argc, char * argv[]) if (argc > 7) { - double additionalAngle = std::stod(argv[7]); + const double additionalAngle = std::stod(argv[7]); itk::Versor rotation; - double angleInRadians = additionalAngle * itk::Math::pi / 180.0; + const double angleInRadians = additionalAngle * itk::Math::pi / 180.0; rotation.SetRotationAroundZ(angleInRadians); - ImageType::DirectionType newDirection = direction * rotation.GetMatrix(); + const ImageType::DirectionType newDirection = + direction * rotation.GetMatrix(); filter->SetOutputDirection(newDirection); filter->ChangeDirectionOn(); diff --git a/Examples/RegistrationITKv4/DeformableRegistration10.cxx b/Examples/RegistrationITKv4/DeformableRegistration10.cxx index 04ee58a8c62..8a95ba5cb5e 100644 --- a/Examples/RegistrationITKv4/DeformableRegistration10.cxx +++ b/Examples/RegistrationITKv4/DeformableRegistration10.cxx @@ -175,9 +175,9 @@ main(int argc, char * argv[]) InternalPixelType>; using InterpolatorType = itk::LinearInterpolateImageFunction; - auto warper = WarperType::New(); - auto interpolator = InterpolatorType::New(); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + auto warper = WarperType::New(); + auto interpolator = InterpolatorType::New(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); warper->SetInput(movingImageReader->GetOutput()); warper->SetInterpolator(interpolator); diff --git a/Examples/RegistrationITKv4/DeformableRegistration12.cxx b/Examples/RegistrationITKv4/DeformableRegistration12.cxx index fb5401b3946..9af75a0cf2d 100644 --- a/Examples/RegistrationITKv4/DeformableRegistration12.cxx +++ b/Examples/RegistrationITKv4/DeformableRegistration12.cxx @@ -149,14 +149,17 @@ main(int argc, char * argv[]) auto fixedImageReader = FixedImageReaderType::New(); fixedImageReader->SetFileName(argv[1]); fixedImageReader->Update(); - FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); - FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); + const FixedImageType::ConstPointer fixedImage = + fixedImageReader->GetOutput(); + const FixedImageType::RegionType fixedRegion = + fixedImage->GetBufferedRegion(); using MovingImageReaderType = itk::ImageFileReader; auto movingImageReader = MovingImageReaderType::New(); movingImageReader->SetFileName(argv[2]); movingImageReader->Update(); - MovingImageType::ConstPointer movingImage = movingImageReader->GetOutput(); + const MovingImageType::ConstPointer movingImage = + movingImageReader->GetOutput(); // Software Guide : BeginCodeSnippet const unsigned int SpaceDimension = ImageDimension; @@ -321,7 +324,8 @@ main(int argc, char * argv[]) // While the registration filter is run, it updates the output transform // parameters with the final registration parameters - OptimizerType::ParametersType finalParameters = transform->GetParameters(); + const OptimizerType::ParametersType finalParameters = + transform->GetParameters(); // Report the time and memory taken by the registration chronometer.Report(std::cout); diff --git a/Examples/RegistrationITKv4/DeformableRegistration13.cxx b/Examples/RegistrationITKv4/DeformableRegistration13.cxx index e6a56dfee00..c4927ffe0da 100644 --- a/Examples/RegistrationITKv4/DeformableRegistration13.cxx +++ b/Examples/RegistrationITKv4/DeformableRegistration13.cxx @@ -186,18 +186,20 @@ main(int argc, char * argv[]) fixedImageReader->SetFileName(argv[1]); movingImageReader->SetFileName(argv[2]); - FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = + fixedImageReader->GetOutput(); registration->SetFixedImage(fixedImage); registration->SetMovingImage(movingImageReader->GetOutput()); fixedImageReader->Update(); - FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); + const FixedImageType::RegionType fixedRegion = + fixedImage->GetBufferedRegion(); registration->SetFixedImageRegion(fixedRegion); - unsigned int numberOfGridNodesInOneDimension = 7; + const unsigned int numberOfGridNodesInOneDimension = 7; // Software Guide : BeginCodeSnippet @@ -307,7 +309,7 @@ main(int argc, char * argv[]) return EXIT_FAILURE; } - OptimizerType::ParametersType finalParameters = + const OptimizerType::ParametersType finalParameters = registration->GetLastTransformParameters(); diff --git a/Examples/RegistrationITKv4/DeformableRegistration14.cxx b/Examples/RegistrationITKv4/DeformableRegistration14.cxx index da7afc1177b..4f70ab2de9d 100644 --- a/Examples/RegistrationITKv4/DeformableRegistration14.cxx +++ b/Examples/RegistrationITKv4/DeformableRegistration14.cxx @@ -161,18 +161,20 @@ main(int argc, char * argv[]) fixedImageReader->SetFileName(argv[1]); movingImageReader->SetFileName(argv[2]); - FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = + fixedImageReader->GetOutput(); registration->SetFixedImage(fixedImage); registration->SetMovingImage(movingImageReader->GetOutput()); fixedImageReader->Update(); - FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); + const FixedImageType::RegionType fixedRegion = + fixedImage->GetBufferedRegion(); registration->SetFixedImageRegion(fixedRegion); - unsigned int numberOfGridNodesInOneDimension = 5; + const unsigned int numberOfGridNodesInOneDimension = 5; // Software Guide : BeginCodeSnippet @@ -301,7 +303,7 @@ main(int argc, char * argv[]) return EXIT_FAILURE; } - OptimizerType::ParametersType finalParameters = + const OptimizerType::ParametersType finalParameters = registration->GetLastTransformParameters(); // Report the time and memory taken by the registration diff --git a/Examples/RegistrationITKv4/DeformableRegistration15.cxx b/Examples/RegistrationITKv4/DeformableRegistration15.cxx index 8ca1f7bca74..cde4ab28ff6 100644 --- a/Examples/RegistrationITKv4/DeformableRegistration15.cxx +++ b/Examples/RegistrationITKv4/DeformableRegistration15.cxx @@ -202,7 +202,8 @@ main(int argc, char * argv[]) return EXIT_FAILURE; } - FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = + fixedImageReader->GetOutput(); registration->SetFixedImage(fixedImage); registration->SetMovingImage(movingImageReader->GetOutput()); @@ -216,7 +217,8 @@ main(int argc, char * argv[]) // Setup the metric parameters metric->SetNumberOfHistogramBins(50); - FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); + const FixedImageType::RegionType fixedRegion = + fixedImage->GetBufferedRegion(); const unsigned int numberOfPixels = fixedRegion.GetNumberOfPixels(); @@ -409,7 +411,7 @@ main(int argc, char * argv[]) // Perform Deformable Registration auto bsplineTransformCoarse = DeformableTransformType::New(); - unsigned int numberOfGridNodesInOneDimensionCoarse = 5; + const unsigned int numberOfGridNodesInOneDimensionCoarse = 5; DeformableTransformType::PhysicalDimensionsType fixedPhysicalDimensions; DeformableTransformType::MeshSizeType meshSize; @@ -540,7 +542,7 @@ main(int argc, char * argv[]) auto bsplineTransformFine = DeformableTransformType::New(); - unsigned int numberOfGridNodesInOneDimensionFine = 20; + const unsigned int numberOfGridNodesInOneDimensionFine = 20; meshSize.Fill(numberOfGridNodesInOneDimensionFine - SplineOrder); @@ -599,7 +601,8 @@ main(int argc, char * argv[]) decomposition->SetInput(upsampler->GetOutput()); decomposition->Update(); - ParametersImageType::Pointer newCoefficients = decomposition->GetOutput(); + const ParametersImageType::Pointer newCoefficients = + decomposition->GetOutput(); // copy the coefficients into the parameter array using Iterator = itk::ImageRegionIterator; diff --git a/Examples/RegistrationITKv4/DeformableRegistration16.cxx b/Examples/RegistrationITKv4/DeformableRegistration16.cxx index e8fa558f00e..3a4fe7d7923 100644 --- a/Examples/RegistrationITKv4/DeformableRegistration16.cxx +++ b/Examples/RegistrationITKv4/DeformableRegistration16.cxx @@ -316,7 +316,7 @@ main(int argc, char * argv[]) auto interpolator = InterpolatorType::New(); - ImageType::Pointer targetImage = targetReader->GetOutput(); + const ImageType::Pointer targetImage = targetReader->GetOutput(); warper->SetInput(sourceReader->GetOutput()); warper->SetInterpolator(interpolator); warper->SetOutputSpacing(targetImage->GetSpacing()); diff --git a/Examples/RegistrationITKv4/DeformableRegistration17.cxx b/Examples/RegistrationITKv4/DeformableRegistration17.cxx index 3bf9eb1ad52..dd07d2b68d9 100644 --- a/Examples/RegistrationITKv4/DeformableRegistration17.cxx +++ b/Examples/RegistrationITKv4/DeformableRegistration17.cxx @@ -319,7 +319,7 @@ main(int argc, char * argv[]) auto interpolator = InterpolatorType::New(); - ImageType::Pointer targetImage = targetReader->GetOutput(); + const ImageType::Pointer targetImage = targetReader->GetOutput(); warper->SetInput(sourceReader->GetOutput()); warper->SetInterpolator(interpolator); warper->SetOutputSpacing(targetImage->GetSpacing()); diff --git a/Examples/RegistrationITKv4/DeformableRegistration2.cxx b/Examples/RegistrationITKv4/DeformableRegistration2.cxx index 414ba7cc2eb..35a1235554f 100644 --- a/Examples/RegistrationITKv4/DeformableRegistration2.cxx +++ b/Examples/RegistrationITKv4/DeformableRegistration2.cxx @@ -420,9 +420,9 @@ main(int argc, char * argv[]) using VectorImage2DType = DisplacementFieldType; using Vector2DType = DisplacementFieldType::PixelType; - VectorImage2DType::ConstPointer vectorImage2D = filter->GetOutput(); + const VectorImage2DType::ConstPointer vectorImage2D = filter->GetOutput(); - VectorImage2DType::RegionType region2D = + const VectorImage2DType::RegionType region2D = vectorImage2D->GetBufferedRegion(); VectorImage2DType::IndexType index2D = region2D.GetIndex(); VectorImage2DType::SizeType size2D = region2D.GetSize(); diff --git a/Examples/RegistrationITKv4/DeformableRegistration3.cxx b/Examples/RegistrationITKv4/DeformableRegistration3.cxx index 240a0505eec..dd38638c7da 100644 --- a/Examples/RegistrationITKv4/DeformableRegistration3.cxx +++ b/Examples/RegistrationITKv4/DeformableRegistration3.cxx @@ -316,9 +316,9 @@ main(int argc, char * argv[]) using InterpolatorType = itk::LinearInterpolateImageFunction; - auto warper = WarperType::New(); - auto interpolator = InterpolatorType::New(); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + auto warper = WarperType::New(); + auto interpolator = InterpolatorType::New(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); warper->SetInput(movingImageReader->GetOutput()); warper->SetInterpolator(interpolator); diff --git a/Examples/RegistrationITKv4/DeformableRegistration4.cxx b/Examples/RegistrationITKv4/DeformableRegistration4.cxx index 9512df72e81..2e852ec25da 100644 --- a/Examples/RegistrationITKv4/DeformableRegistration4.cxx +++ b/Examples/RegistrationITKv4/DeformableRegistration4.cxx @@ -145,7 +145,8 @@ main(int argc, char * argv[]) movingImageReader->SetFileName(argv[2]); fixedImageReader->Update(); - FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = + fixedImageReader->GetOutput(); // Software Guide : BeginLatex @@ -175,7 +176,7 @@ main(int argc, char * argv[]) auto transformInitializer = InitializerType::New(); - unsigned int numberOfGridNodesInOneDimension = 8; + const unsigned int numberOfGridNodesInOneDimension = 8; auto meshSize = itk::MakeFilled( numberOfGridNodesInOneDimension - SplineOrder); @@ -322,7 +323,8 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - OptimizerType::ParametersType finalParameters = transform->GetParameters(); + const OptimizerType::ParametersType finalParameters = + transform->GetParameters(); // Software Guide : EndCodeSnippet std::cout << "Last Transform Parameters" << std::endl; diff --git a/Examples/RegistrationITKv4/DeformableRegistration5.cxx b/Examples/RegistrationITKv4/DeformableRegistration5.cxx index 039b7707ca8..0474001be8f 100644 --- a/Examples/RegistrationITKv4/DeformableRegistration5.cxx +++ b/Examples/RegistrationITKv4/DeformableRegistration5.cxx @@ -314,9 +314,9 @@ main(int argc, char * argv[]) using InterpolatorType = itk::LinearInterpolateImageFunction; - auto warper = WarperType::New(); - auto interpolator = InterpolatorType::New(); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + auto warper = WarperType::New(); + auto interpolator = InterpolatorType::New(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); warper->SetInput(movingImageReader->GetOutput()); warper->SetInterpolator(interpolator); @@ -422,9 +422,9 @@ main(int argc, char * argv[]) using VectorImage2DType = DisplacementFieldType; using Vector2DType = DisplacementFieldType::PixelType; - VectorImage2DType::ConstPointer vectorImage2D = filter->GetOutput(); + const VectorImage2DType::ConstPointer vectorImage2D = filter->GetOutput(); - VectorImage2DType::RegionType region2D = + const VectorImage2DType::RegionType region2D = vectorImage2D->GetBufferedRegion(); VectorImage2DType::IndexType index2D = region2D.GetIndex(); VectorImage2DType::SizeType size2D = region2D.GetSize(); diff --git a/Examples/RegistrationITKv4/DeformableRegistration6.cxx b/Examples/RegistrationITKv4/DeformableRegistration6.cxx index adf78dc3d95..62a9fdf35a5 100644 --- a/Examples/RegistrationITKv4/DeformableRegistration6.cxx +++ b/Examples/RegistrationITKv4/DeformableRegistration6.cxx @@ -195,7 +195,8 @@ main(int argc, char * argv[]) fixedImageReader->SetFileName(argv[1]); movingImageReader->SetFileName(argv[2]); - FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = + fixedImageReader->GetOutput(); registration->SetFixedImage(fixedImage); registration->SetMovingImage(movingImageReader->GetOutput()); @@ -221,7 +222,7 @@ main(int argc, char * argv[]) auto transformInitializer = InitializerType::New(); - unsigned int numberOfGridNodesInOneDimension = 8; + const unsigned int numberOfGridNodesInOneDimension = 8; auto meshSize = itk::MakeFilled( numberOfGridNodesInOneDimension - SplineOrder); diff --git a/Examples/RegistrationITKv4/DeformableRegistration7.cxx b/Examples/RegistrationITKv4/DeformableRegistration7.cxx index e0d4b51aab5..e68a68e2510 100644 --- a/Examples/RegistrationITKv4/DeformableRegistration7.cxx +++ b/Examples/RegistrationITKv4/DeformableRegistration7.cxx @@ -185,7 +185,8 @@ main(int argc, char * argv[]) fixedImageReader->SetFileName(argv[1]); movingImageReader->SetFileName(argv[2]); - FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = + fixedImageReader->GetOutput(); registration->SetFixedImage(fixedImage); registration->SetMovingImage(movingImageReader->GetOutput()); @@ -212,7 +213,7 @@ main(int argc, char * argv[]) auto transformInitializer = InitializerType::New(); - unsigned int numberOfGridNodesInOneDimension = 8; + const unsigned int numberOfGridNodesInOneDimension = 8; auto meshSize = itk::MakeFilled( numberOfGridNodesInOneDimension - SplineOrder); @@ -306,7 +307,7 @@ main(int argc, char * argv[]) return EXIT_FAILURE; } - OptimizerType::ParametersType finalParameters = + const OptimizerType::ParametersType finalParameters = outputBSplineTransform->GetParameters(); std::cout << "Last Transform Parameters" << std::endl; diff --git a/Examples/RegistrationITKv4/DeformableRegistration8.cxx b/Examples/RegistrationITKv4/DeformableRegistration8.cxx index 5bfa1e2dd88..31aa80a779c 100644 --- a/Examples/RegistrationITKv4/DeformableRegistration8.cxx +++ b/Examples/RegistrationITKv4/DeformableRegistration8.cxx @@ -173,7 +173,8 @@ main(int argc, char * argv[]) fixedImageReader->SetFileName(argv[1]); movingImageReader->SetFileName(argv[2]); - FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = + fixedImageReader->GetOutput(); registration->SetFixedImage(fixedImage); registration->SetMovingImage(movingImageReader->GetOutput()); @@ -314,7 +315,8 @@ main(int argc, char * argv[]) chronometer.Report(std::cout); memorymeter.Report(std::cout); - OptimizerType::ParametersType finalParameters = transform->GetParameters(); + const OptimizerType::ParametersType finalParameters = + transform->GetParameters(); std::cout << "Last Transform Parameters" << std::endl; std::cout << finalParameters << std::endl; diff --git a/Examples/RegistrationITKv4/DeformableRegistration9.cxx b/Examples/RegistrationITKv4/DeformableRegistration9.cxx index 45216847406..b906cc6c8f6 100644 --- a/Examples/RegistrationITKv4/DeformableRegistration9.cxx +++ b/Examples/RegistrationITKv4/DeformableRegistration9.cxx @@ -166,9 +166,9 @@ main(int argc, char * argv[]) using InterpolatorType = itk::LinearInterpolateImageFunction; - auto warper = WarperType::New(); - auto interpolator = InterpolatorType::New(); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + auto warper = WarperType::New(); + auto interpolator = InterpolatorType::New(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); warper->SetInput(movingImageReader->GetOutput()); warper->SetInterpolator(interpolator); diff --git a/Examples/RegistrationITKv4/DisplacementFieldInitialization.cxx b/Examples/RegistrationITKv4/DisplacementFieldInitialization.cxx index 1b89d0c64df..e3827cfe0b9 100644 --- a/Examples/RegistrationITKv4/DisplacementFieldInitialization.cxx +++ b/Examples/RegistrationITKv4/DisplacementFieldInitialization.cxx @@ -88,7 +88,7 @@ main(int argc, char * argv[]) } - FixedImageType::ConstPointer fixedImage = fixedReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = fixedReader->GetOutput(); using FilterType = itk::LandmarkDisplacementFieldSource; diff --git a/Examples/RegistrationITKv4/ImageRegistration1.cxx b/Examples/RegistrationITKv4/ImageRegistration1.cxx index 1fe4770f8bf..0184edc2e93 100644 --- a/Examples/RegistrationITKv4/ImageRegistration1.cxx +++ b/Examples/RegistrationITKv4/ImageRegistration1.cxx @@ -550,7 +550,7 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - TransformType::ConstPointer transform = registration->GetTransform(); + const TransformType::ConstPointer transform = registration->GetTransform(); // Software Guide : EndCodeSnippet @@ -728,7 +728,7 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resampler->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resampler->SetOutputOrigin(fixedImage->GetOrigin()); resampler->SetOutputSpacing(fixedImage->GetSpacing()); diff --git a/Examples/RegistrationITKv4/ImageRegistration10.cxx b/Examples/RegistrationITKv4/ImageRegistration10.cxx index 68c81520e23..18234d4aa52 100644 --- a/Examples/RegistrationITKv4/ImageRegistration10.cxx +++ b/Examples/RegistrationITKv4/ImageRegistration10.cxx @@ -511,7 +511,7 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resample->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resample->SetOutputOrigin(fixedImage->GetOrigin()); resample->SetOutputSpacing(fixedImage->GetSpacing()); diff --git a/Examples/RegistrationITKv4/ImageRegistration11.cxx b/Examples/RegistrationITKv4/ImageRegistration11.cxx index 13084d5b0f5..b55ac615814 100644 --- a/Examples/RegistrationITKv4/ImageRegistration11.cxx +++ b/Examples/RegistrationITKv4/ImageRegistration11.cxx @@ -83,7 +83,7 @@ class CommandIterationUpdate : public itk::Command { return; } - double currentValue = optimizer->GetValue(); + const double currentValue = optimizer->GetValue(); // Only print out when the Metric value changes if (itk::Math::abs(m_LastMetricValue - currentValue) > 1e-7) { @@ -179,7 +179,7 @@ main(int argc, char * argv[]) // Software Guide : BeginCodeSnippet registration->SetMetricSamplingPercentage(samplingPercentage); - RegistrationType::MetricSamplingStrategyEnum samplingStrategy = + const RegistrationType::MetricSamplingStrategyEnum samplingStrategy = RegistrationType::MetricSamplingStrategyEnum::RANDOM; registration->SetMetricSamplingStrategy(samplingStrategy); // Software Guide : EndCodeSnippet @@ -295,12 +295,12 @@ main(int argc, char * argv[]) ParametersType finalParameters = transform->GetParameters(); - double TranslationAlongX = finalParameters[0]; - double TranslationAlongY = finalParameters[1]; + const double TranslationAlongX = finalParameters[0]; + const double TranslationAlongY = finalParameters[1]; - unsigned int numberOfIterations = optimizer->GetCurrentIteration(); + const unsigned int numberOfIterations = optimizer->GetCurrentIteration(); - double bestValue = optimizer->GetValue(); + const double bestValue = optimizer->GetValue(); // Print out results @@ -336,7 +336,7 @@ main(int argc, char * argv[]) resample->SetTransform(transform); resample->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resample->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resample->SetOutputOrigin(fixedImage->GetOrigin()); diff --git a/Examples/RegistrationITKv4/ImageRegistration12.cxx b/Examples/RegistrationITKv4/ImageRegistration12.cxx index 9f2043f8474..9b1e0ff918f 100644 --- a/Examples/RegistrationITKv4/ImageRegistration12.cxx +++ b/Examples/RegistrationITKv4/ImageRegistration12.cxx @@ -375,8 +375,8 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - TransformType::MatrixType matrix = transform->GetMatrix(); - TransformType::OffsetType offset = transform->GetOffset(); + const TransformType::MatrixType matrix = transform->GetMatrix(); + const TransformType::OffsetType offset = transform->GetOffset(); std::cout << "Matrix = " << std::endl << matrix << std::endl; std::cout << "Offset = " << std::endl << offset << std::endl; @@ -394,7 +394,7 @@ main(int argc, char * argv[]) resample->SetTransform(finalTransform); resample->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resample->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resample->SetOutputOrigin(fixedImage->GetOrigin()); diff --git a/Examples/RegistrationITKv4/ImageRegistration13.cxx b/Examples/RegistrationITKv4/ImageRegistration13.cxx index d7a11674a82..97de9c8d588 100644 --- a/Examples/RegistrationITKv4/ImageRegistration13.cxx +++ b/Examples/RegistrationITKv4/ImageRegistration13.cxx @@ -139,10 +139,10 @@ main(int argc, char * argv[]) metric->SetNumberOfHistogramBins(20); - double samplingPercentage = 0.20; + const double samplingPercentage = 0.20; registration->SetMetricSamplingPercentage(samplingPercentage); - RegistrationType::MetricSamplingStrategyEnum samplingStrategy = + const RegistrationType::MetricSamplingStrategyEnum samplingStrategy = RegistrationType::MetricSamplingStrategyEnum::RANDOM; registration->SetMetricSamplingStrategy(samplingStrategy); // Software Guide : EndCodeSnippet @@ -275,9 +275,9 @@ main(int argc, char * argv[]) const double rotationCenterY = registration->GetOutput()->Get()->GetFixedParameters()[1]; - unsigned int numberOfIterations = optimizer->GetCurrentIteration(); + const unsigned int numberOfIterations = optimizer->GetCurrentIteration(); - double bestValue = optimizer->GetValue(); + const double bestValue = optimizer->GetValue(); // Print out results // @@ -303,7 +303,7 @@ main(int argc, char * argv[]) resample->SetTransform(transform); resample->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resample->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resample->SetOutputOrigin(fixedImage->GetOrigin()); diff --git a/Examples/RegistrationITKv4/ImageRegistration14.cxx b/Examples/RegistrationITKv4/ImageRegistration14.cxx index 241e85f797e..fef1f1e42ca 100644 --- a/Examples/RegistrationITKv4/ImageRegistration14.cxx +++ b/Examples/RegistrationITKv4/ImageRegistration14.cxx @@ -74,7 +74,7 @@ class CommandIterationUpdate : public itk::Command { return; } - double currentValue = optimizer->GetValue(); + const double currentValue = optimizer->GetValue(); // Only print out when the Metric value changes if (itk::Math::abs(m_LastMetricValue - currentValue) > 1e-7) { @@ -178,7 +178,8 @@ main(int argc, char * argv[]) fixedImageReader->Update(); movingImageReader->Update(); - FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = + fixedImageReader->GetOutput(); registration->SetFixedImageRegion(fixedImage->GetBufferedRegion()); using TransformInitializerType = @@ -208,7 +209,7 @@ main(int argc, char * argv[]) transform->SetTranslation(initialTranslation); using ParametersType = RegistrationType::ParametersType; - ParametersType initialParameters = transform->GetParameters(); + const ParametersType initialParameters = transform->GetParameters(); registration->SetInitialTransformParameters(initialParameters); std::cout << "Initial transform parameters = "; std::cout << initialParameters << std::endl; @@ -216,7 +217,8 @@ main(int argc, char * argv[]) using OptimizerScalesType = OptimizerType::ScalesType; OptimizerScalesType optimizerScales(transform->GetNumberOfParameters()); - FixedImageType::RegionType region = fixedImage->GetLargestPossibleRegion(); + const FixedImageType::RegionType region = + fixedImage->GetLargestPossibleRegion(); FixedImageType::SizeType size = region.GetSize(); FixedImageType::SpacingType spacing = fixedImage->GetSpacing(); diff --git a/Examples/RegistrationITKv4/ImageRegistration15.cxx b/Examples/RegistrationITKv4/ImageRegistration15.cxx index 0e14741cc02..37d063ca145 100644 --- a/Examples/RegistrationITKv4/ImageRegistration15.cxx +++ b/Examples/RegistrationITKv4/ImageRegistration15.cxx @@ -73,7 +73,7 @@ class CommandIterationUpdate : public itk::Command { return; } - double currentValue = optimizer->GetValue(); + const double currentValue = optimizer->GetValue(); // Only print out when the Metric value changes if (itk::Math::abs(m_LastMetricValue - currentValue) > 1e-7) { @@ -176,7 +176,8 @@ main(int argc, char * argv[]) fixedImageReader->Update(); movingImageReader->Update(); - FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = + fixedImageReader->GetOutput(); registration->SetFixedImageRegion(fixedImage->GetBufferedRegion()); transform->SetIdentity(); @@ -198,7 +199,8 @@ main(int argc, char * argv[]) using OptimizerScalesType = OptimizerType::ScalesType; OptimizerScalesType optimizerScales(transform->GetNumberOfParameters()); - FixedImageType::RegionType region = fixedImage->GetLargestPossibleRegion(); + const FixedImageType::RegionType region = + fixedImage->GetLargestPossibleRegion(); FixedImageType::SizeType size = region.GetSize(); FixedImageType::SpacingType spacing = fixedImage->GetSpacing(); @@ -249,8 +251,8 @@ main(int argc, char * argv[]) ParametersType finalParameters = registration->GetLastTransformParameters(); const double finalTranslationX = finalParameters[0]; const double finalTranslationY = finalParameters[1]; - unsigned int numberOfIterations = optimizer->GetCurrentIteration(); - const double bestValue = optimizer->GetValue(); + const unsigned int numberOfIterations = optimizer->GetCurrentIteration(); + const double bestValue = optimizer->GetValue(); // Print out results std::cout << "Result = " << std::endl; diff --git a/Examples/RegistrationITKv4/ImageRegistration16.cxx b/Examples/RegistrationITKv4/ImageRegistration16.cxx index 6f3dc8e0d32..3c20872365b 100644 --- a/Examples/RegistrationITKv4/ImageRegistration16.cxx +++ b/Examples/RegistrationITKv4/ImageRegistration16.cxx @@ -184,7 +184,8 @@ main(int argc, char * argv[]) fixedImageReader->Update(); movingImageReader->Update(); - FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = + fixedImageReader->GetOutput(); registration->SetFixedImageRegion(fixedImage->GetBufferedRegion()); @@ -286,7 +287,7 @@ main(int argc, char * argv[]) const double finalTranslationX = finalParameters[0]; const double finalTranslationY = finalParameters[1]; - double bestValue = optimizer->GetValue(); + const double bestValue = optimizer->GetValue(); // Print out results diff --git a/Examples/RegistrationITKv4/ImageRegistration17.cxx b/Examples/RegistrationITKv4/ImageRegistration17.cxx index 2f0a0512db6..83f5ba795d3 100644 --- a/Examples/RegistrationITKv4/ImageRegistration17.cxx +++ b/Examples/RegistrationITKv4/ImageRegistration17.cxx @@ -164,7 +164,8 @@ main(int argc, char * argv[]) fixedImageReader->Update(); movingImageReader->Update(); - FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = + fixedImageReader->GetOutput(); registration->SetFixedImageRegion(fixedImage->GetBufferedRegion()); @@ -279,7 +280,7 @@ main(int argc, char * argv[]) const double finalTranslationX = finalParameters[0]; const double finalTranslationY = finalParameters[1]; - double bestValue = optimizer->GetValue(); + const double bestValue = optimizer->GetValue(); // Print out results diff --git a/Examples/RegistrationITKv4/ImageRegistration18.cxx b/Examples/RegistrationITKv4/ImageRegistration18.cxx index 75491488a66..b5054e282c1 100644 --- a/Examples/RegistrationITKv4/ImageRegistration18.cxx +++ b/Examples/RegistrationITKv4/ImageRegistration18.cxx @@ -223,7 +223,7 @@ main(int argc, char * argv[]) resample->SetTransform(finalTransform); resample->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resample->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resample->SetOutputOrigin(fixedImage->GetOrigin()); diff --git a/Examples/RegistrationITKv4/ImageRegistration19.cxx b/Examples/RegistrationITKv4/ImageRegistration19.cxx index f7b52428c5b..fa1721f05b7 100644 --- a/Examples/RegistrationITKv4/ImageRegistration19.cxx +++ b/Examples/RegistrationITKv4/ImageRegistration19.cxx @@ -261,7 +261,7 @@ main(int argc, char * argv[]) // This parameter is tightly coupled to the stepInParametricSpace above. - double translationScale = 1.0 / 1000.0; + const double translationScale = 1.0 / 1000.0; using OptimizerScalesType = OptimizerType::ScalesType; OptimizerScalesType optimizerScales(numberOfParameters); @@ -393,7 +393,7 @@ main(int argc, char * argv[]) // interpolator to be the same type of interpolator as the // registration method used (nearest neighbor). // - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resample->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resample->SetOutputOrigin(fixedImage->GetOrigin()); resample->SetOutputSpacing(fixedImage->GetSpacing()); diff --git a/Examples/RegistrationITKv4/ImageRegistration2.cxx b/Examples/RegistrationITKv4/ImageRegistration2.cxx index 76b0c7df097..4667d099492 100644 --- a/Examples/RegistrationITKv4/ImageRegistration2.cxx +++ b/Examples/RegistrationITKv4/ImageRegistration2.cxx @@ -319,7 +319,7 @@ main(int argc, char * argv[]) fixedNormalizer->Update(); - FixedImageType::RegionType fixedImageRegion = + const FixedImageType::RegionType fixedImageRegion = fixedNormalizer->GetOutput()->GetBufferedRegion(); registration->SetFixedImageRegion(fixedImageRegion); @@ -444,12 +444,12 @@ main(int argc, char * argv[]) ParametersType finalParameters = registration->GetLastTransformParameters(); - double TranslationAlongX = finalParameters[0]; - double TranslationAlongY = finalParameters[1]; + const double TranslationAlongX = finalParameters[0]; + const double TranslationAlongY = finalParameters[1]; - unsigned int numberOfIterations = optimizer->GetCurrentIteration(); + const unsigned int numberOfIterations = optimizer->GetCurrentIteration(); - double bestValue = optimizer->GetValue(); + const double bestValue = optimizer->GetValue(); // Print out results @@ -510,7 +510,7 @@ main(int argc, char * argv[]) resample->SetTransform(finalTransform); resample->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resample->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resample->SetOutputOrigin(fixedImage->GetOrigin()); diff --git a/Examples/RegistrationITKv4/ImageRegistration20.cxx b/Examples/RegistrationITKv4/ImageRegistration20.cxx index ba8ff831c7b..fbfb367d009 100644 --- a/Examples/RegistrationITKv4/ImageRegistration20.cxx +++ b/Examples/RegistrationITKv4/ImageRegistration20.cxx @@ -351,7 +351,7 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - OptimizerType::ParametersType finalParameters = + const OptimizerType::ParametersType finalParameters = registration->GetLastTransformParameters(); const unsigned int numberOfIterations = optimizer->GetCurrentIteration(); @@ -384,7 +384,7 @@ main(int argc, char * argv[]) resampler->SetTransform(finalTransform); resampler->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resampler->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resampler->SetOutputOrigin(fixedImage->GetOrigin()); diff --git a/Examples/RegistrationITKv4/ImageRegistration3.cxx b/Examples/RegistrationITKv4/ImageRegistration3.cxx index 619aef2114a..4f312f91419 100644 --- a/Examples/RegistrationITKv4/ImageRegistration3.cxx +++ b/Examples/RegistrationITKv4/ImageRegistration3.cxx @@ -488,7 +488,7 @@ main(int argc, char * argv[]) resample->SetTransform(registration->GetTransform()); resample->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resample->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resample->SetOutputOrigin(fixedImage->GetOrigin()); diff --git a/Examples/RegistrationITKv4/ImageRegistration4.cxx b/Examples/RegistrationITKv4/ImageRegistration4.cxx index c70dd6c1b8a..5c1b20f2457 100644 --- a/Examples/RegistrationITKv4/ImageRegistration4.cxx +++ b/Examples/RegistrationITKv4/ImageRegistration4.cxx @@ -306,7 +306,7 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - RegistrationType::MetricSamplingStrategyEnum samplingStrategy = + const RegistrationType::MetricSamplingStrategyEnum samplingStrategy = RegistrationType::MetricSamplingStrategyEnum::RANDOM; // Software Guide : EndCodeSnippet @@ -349,7 +349,7 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - double samplingPercentage = 0.20; + const double samplingPercentage = 0.20; // Software Guide : EndCodeSnippet // Software Guide : BeginLatex @@ -388,15 +388,15 @@ main(int argc, char * argv[]) TransformType::ParametersType finalParameters = registration->GetOutput()->Get()->GetParameters(); - double TranslationAlongX = finalParameters[0]; - double TranslationAlongY = finalParameters[1]; + const double TranslationAlongX = finalParameters[0]; + const double TranslationAlongY = finalParameters[1]; // For stability reasons it may be desirable to round up the values of // translation // - unsigned int numberOfIterations = optimizer->GetCurrentIteration(); + const unsigned int numberOfIterations = optimizer->GetCurrentIteration(); - double bestValue = optimizer->GetValue(); + const double bestValue = optimizer->GetValue(); // Print out results @@ -453,7 +453,7 @@ main(int argc, char * argv[]) resample->SetTransform(registration->GetTransform()); resample->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); PixelType defaultPixelValue = 100; diff --git a/Examples/RegistrationITKv4/ImageRegistration5.cxx b/Examples/RegistrationITKv4/ImageRegistration5.cxx index bdaae1b4e38..addd24e5618 100644 --- a/Examples/RegistrationITKv4/ImageRegistration5.cxx +++ b/Examples/RegistrationITKv4/ImageRegistration5.cxx @@ -293,7 +293,7 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); const SpacingType fixedSpacing = fixedImage->GetSpacing(); const OriginType fixedOrigin = fixedImage->GetOrigin(); @@ -314,7 +314,7 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); + const MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); const SpacingType movingSpacing = movingImage->GetSpacing(); const OriginType movingOrigin = movingImage->GetOrigin(); diff --git a/Examples/RegistrationITKv4/ImageRegistration6.cxx b/Examples/RegistrationITKv4/ImageRegistration6.cxx index 24d81f620f8..1aa8c8f3836 100644 --- a/Examples/RegistrationITKv4/ImageRegistration6.cxx +++ b/Examples/RegistrationITKv4/ImageRegistration6.cxx @@ -443,8 +443,8 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - TransformType::MatrixType matrix = transform->GetMatrix(); - TransformType::OffsetType offset = transform->GetOffset(); + const TransformType::MatrixType matrix = transform->GetMatrix(); + const TransformType::OffsetType offset = transform->GetOffset(); std::cout << "Matrix = " << std::endl << matrix << std::endl; std::cout << "Offset = " << std::endl << offset << std::endl; @@ -577,7 +577,7 @@ main(int argc, char * argv[]) resample->SetTransform(transform); resample->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resample->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resample->SetOutputOrigin(fixedImage->GetOrigin()); diff --git a/Examples/RegistrationITKv4/ImageRegistration7.cxx b/Examples/RegistrationITKv4/ImageRegistration7.cxx index e1c3c70a633..1918ea83d05 100644 --- a/Examples/RegistrationITKv4/ImageRegistration7.cxx +++ b/Examples/RegistrationITKv4/ImageRegistration7.cxx @@ -490,7 +490,7 @@ main(int argc, char * argv[]) resampler->SetTransform(transform); resampler->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resampler->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resampler->SetOutputOrigin(fixedImage->GetOrigin()); diff --git a/Examples/RegistrationITKv4/ImageRegistration8.cxx b/Examples/RegistrationITKv4/ImageRegistration8.cxx index 00f7d959972..6adb58f488b 100644 --- a/Examples/RegistrationITKv4/ImageRegistration8.cxx +++ b/Examples/RegistrationITKv4/ImageRegistration8.cxx @@ -451,8 +451,8 @@ main(int argc, char * argv[]) finalTransform->SetParameters(finalParameters); // Software Guide : BeginCodeSnippet - TransformType::MatrixType matrix = finalTransform->GetMatrix(); - TransformType::OffsetType offset = finalTransform->GetOffset(); + const TransformType::MatrixType matrix = finalTransform->GetMatrix(); + const TransformType::OffsetType offset = finalTransform->GetOffset(); std::cout << "Matrix = " << std::endl << matrix << std::endl; std::cout << "Offset = " << std::endl << offset << std::endl; // Software Guide : EndCodeSnippet @@ -562,7 +562,7 @@ main(int argc, char * argv[]) resampler->SetTransform(finalTransform); resampler->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resampler->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resampler->SetOutputOrigin(fixedImage->GetOrigin()); @@ -636,7 +636,7 @@ main(int argc, char * argv[]) extractor->SetDirectionCollapseToSubmatrix(); extractor->InPlaceOn(); - FixedImageType::RegionType inputRegion = + const FixedImageType::RegionType inputRegion = fixedImage->GetLargestPossibleRegion(); FixedImageType::SizeType size = inputRegion.GetSize(); FixedImageType::IndexType start = inputRegion.GetIndex(); diff --git a/Examples/RegistrationITKv4/ImageRegistration9.cxx b/Examples/RegistrationITKv4/ImageRegistration9.cxx index 67b2bd072c3..703229d0c4b 100644 --- a/Examples/RegistrationITKv4/ImageRegistration9.cxx +++ b/Examples/RegistrationITKv4/ImageRegistration9.cxx @@ -115,7 +115,7 @@ class CommandIterationUpdate : public itk::Command vnl_svd svd(p); vnl_matrix r(2, 2); r = svd.U() * vnl_transpose(svd.V()); - double angle = std::asin(r[1][0]); + const double angle = std::asin(r[1][0]); std::cout << " AffineAngle: " << angle * 180.0 / itk::Math::pi << std::endl; } @@ -414,7 +414,7 @@ main(int argc, char * argv[]) vnl_svd svd(p); vnl_matrix r(2, 2); r = svd.U() * vnl_transpose(svd.V()); - double angle = std::asin(r[1][0]); + const double angle = std::asin(r[1][0]); const double angleInDegrees = angle * 180.0 / itk::Math::pi; @@ -523,7 +523,7 @@ main(int argc, char * argv[]) resampler->SetTransform(transform); resampler->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resampler->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resampler->SetOutputOrigin(fixedImage->GetOrigin()); diff --git a/Examples/RegistrationITKv4/ImageRegistrationHistogramPlotter.cxx b/Examples/RegistrationITKv4/ImageRegistrationHistogramPlotter.cxx index b1bd826c4d3..2ee2a074c0d 100644 --- a/Examples/RegistrationITKv4/ImageRegistrationHistogramPlotter.cxx +++ b/Examples/RegistrationITKv4/ImageRegistrationHistogramPlotter.cxx @@ -249,7 +249,7 @@ class HistogramWriter void WriteHistogramFile(unsigned int iterationNumber) { - std::string outputFileBase = "JointHistogram"; + const std::string outputFileBase = "JointHistogram"; std::ostringstream outputFilename; outputFilename << outputFileBase << "." << std::setfill('0') << std::setw(3) << iterationNumber << "." @@ -535,7 +535,7 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - unsigned int numberOfHistogramBins = std::stoi(argv[7]); + const unsigned int numberOfHistogramBins = std::stoi(argv[7]); MetricType::HistogramType::SizeType histogramSize; histogramSize.SetSize(2); histogramSize[0] = numberOfHistogramBins; @@ -649,12 +649,12 @@ main(int argc, char * argv[]) ParametersType finalParameters = registration->GetLastTransformParameters(); - double TranslationAlongX = finalParameters[0]; - double TranslationAlongY = finalParameters[1]; + const double TranslationAlongX = finalParameters[0]; + const double TranslationAlongY = finalParameters[1]; - unsigned int numberOfIterations = optimizer->GetCurrentIteration(); + const unsigned int numberOfIterations = optimizer->GetCurrentIteration(); - double bestValue = optimizer->GetValue(); + const double bestValue = optimizer->GetValue(); std::cout << "Result = " << std::endl; @@ -689,7 +689,7 @@ main(int argc, char * argv[]) resample->SetTransform(finalTransform); resample->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resample->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resample->SetOutputOrigin(fixedImage->GetOrigin()); diff --git a/Examples/RegistrationITKv4/IterativeClosestPoint1.cxx b/Examples/RegistrationITKv4/IterativeClosestPoint1.cxx index f71c1cbeeaa..b819ae4f2c2 100644 --- a/Examples/RegistrationITKv4/IterativeClosestPoint1.cxx +++ b/Examples/RegistrationITKv4/IterativeClosestPoint1.cxx @@ -216,10 +216,10 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - unsigned long numberOfIterations = 100; - double gradientTolerance = 1e-5; // convergence criterion - double valueTolerance = 1e-5; // convergence criterion - double epsilonFunction = 1e-6; // convergence criterion + const unsigned long numberOfIterations = 100; + const double gradientTolerance = 1e-5; // convergence criterion + const double valueTolerance = 1e-5; // convergence criterion + const double epsilonFunction = 1e-6; // convergence criterion optimizer->SetScales(scales); diff --git a/Examples/RegistrationITKv4/IterativeClosestPoint2.cxx b/Examples/RegistrationITKv4/IterativeClosestPoint2.cxx index b4c979b29e2..c40edbbca2d 100644 --- a/Examples/RegistrationITKv4/IterativeClosestPoint2.cxx +++ b/Examples/RegistrationITKv4/IterativeClosestPoint2.cxx @@ -232,10 +232,10 @@ main(int argc, char * argv[]) scales[4] = 1.0 / translationScale; scales[5] = 1.0 / translationScale; - unsigned long numberOfIterations = 2000; - double gradientTolerance = 1e-4; // convergence criterion - double valueTolerance = 1e-4; // convergence criterion - double epsilonFunction = 1e-5; // convergence criterion + const unsigned long numberOfIterations = 2000; + const double gradientTolerance = 1e-4; // convergence criterion + const double valueTolerance = 1e-4; // convergence criterion + const double epsilonFunction = 1e-5; // convergence criterion optimizer->SetScales(scales); diff --git a/Examples/RegistrationITKv4/IterativeClosestPoint3.cxx b/Examples/RegistrationITKv4/IterativeClosestPoint3.cxx index 2de045217ec..96e80497e46 100644 --- a/Examples/RegistrationITKv4/IterativeClosestPoint3.cxx +++ b/Examples/RegistrationITKv4/IterativeClosestPoint3.cxx @@ -233,7 +233,8 @@ main(int argc, char * argv[]) pointsToImageFilter->SetSpacing(spacing); pointsToImageFilter->SetOrigin(origin); pointsToImageFilter->Update(); - BinaryImageType::Pointer binaryImage = pointsToImageFilter->GetOutput(); + const BinaryImageType::Pointer binaryImage = + pointsToImageFilter->GetOutput(); using DistanceImageType = itk::Image; using DistanceFilterType = diff --git a/Examples/RegistrationITKv4/LandmarkWarping2.cxx b/Examples/RegistrationITKv4/LandmarkWarping2.cxx index ca816857067..9a1261b40f3 100644 --- a/Examples/RegistrationITKv4/LandmarkWarping2.cxx +++ b/Examples/RegistrationITKv4/LandmarkWarping2.cxx @@ -92,7 +92,7 @@ main(int argc, char * argv[]) movingWriter->SetFileName(argv[4]); - FixedImageType::ConstPointer fixedImage = fixedReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = fixedReader->GetOutput(); // Software Guide : BeginLatex // @@ -189,7 +189,8 @@ main(int argc, char * argv[]) return EXIT_FAILURE; } - DisplacementFieldType::Pointer displacementField = deformer->GetOutput(); + const DisplacementFieldType::Pointer displacementField = + deformer->GetOutput(); using InterpolatorPrecisionType = double; using TransformPrecisionType = float; diff --git a/Examples/RegistrationITKv4/MeanSquaresImageMetric1.cxx b/Examples/RegistrationITKv4/MeanSquaresImageMetric1.cxx index 1bb1c8dab9b..1158b7f6aa1 100644 --- a/Examples/RegistrationITKv4/MeanSquaresImageMetric1.cxx +++ b/Examples/RegistrationITKv4/MeanSquaresImageMetric1.cxx @@ -132,8 +132,8 @@ main(int argc, char * argv[]) transform->SetIdentity(); - ImageType::ConstPointer fixedImage = fixedReader->GetOutput(); - ImageType::ConstPointer movingImage = movingReader->GetOutput(); + const ImageType::ConstPointer fixedImage = fixedReader->GetOutput(); + const ImageType::ConstPointer movingImage = movingReader->GetOutput(); // Software Guide : BeginLatex diff --git a/Examples/RegistrationITKv4/ModelToImageRegistration1.cxx b/Examples/RegistrationITKv4/ModelToImageRegistration1.cxx index 6a0cd9c8bf9..7d2492ea53e 100644 --- a/Examples/RegistrationITKv4/ModelToImageRegistration1.cxx +++ b/Examples/RegistrationITKv4/ModelToImageRegistration1.cxx @@ -339,7 +339,8 @@ class SimpleImageToSpatialObjectMetric value = 0; for (auto it : m_PointList) { - PointType transformedPoint = this->m_Transform->TransformPoint(it); + const PointType transformedPoint = + this->m_Transform->TransformPoint(it); if (this->m_Interpolator->IsInsideBuffer(transformedPoint)) { value += this->m_Interpolator->Evaluate(transformedPoint); @@ -917,7 +918,7 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - RegistrationType::ParametersType finalParameters = + const RegistrationType::ParametersType finalParameters = registration->GetLastTransformParameters(); std::cout << "Final Solution is : " << finalParameters << std::endl; diff --git a/Examples/RegistrationITKv4/ModelToImageRegistration2.cxx b/Examples/RegistrationITKv4/ModelToImageRegistration2.cxx index efee258fd17..6a6bcf5ba40 100644 --- a/Examples/RegistrationITKv4/ModelToImageRegistration2.cxx +++ b/Examples/RegistrationITKv4/ModelToImageRegistration2.cxx @@ -261,7 +261,8 @@ main(int argc, char * argv[]) // spatialObject->SetSizeInObjectSpace(boxSize); - ImageType::RegionType region = movingImage->GetLargestPossibleRegion(); + const ImageType::RegionType region = + movingImage->GetLargestPossibleRegion(); ImageType::SizeType imageSize = region.GetSize(); @@ -360,11 +361,11 @@ main(int argc, char * argv[]) return EXIT_FAILURE; } - ParametersType transformParameters = + const ParametersType transformParameters = registrationMethod->GetLastTransformParameters(); - TransformType::OutputPointType center = transform->GetCenter(); + const TransformType::OutputPointType center = transform->GetCenter(); std::cout << "Registration parameter = " << std::endl; std::cout << "Rotation center = " << center << std::endl; diff --git a/Examples/RegistrationITKv4/MultiResImageRegistration1.cxx b/Examples/RegistrationITKv4/MultiResImageRegistration1.cxx index a777749be00..8d4fd87b165 100644 --- a/Examples/RegistrationITKv4/MultiResImageRegistration1.cxx +++ b/Examples/RegistrationITKv4/MultiResImageRegistration1.cxx @@ -209,8 +209,8 @@ class RegistrationInterfaceCommand : public itk::Command static_cast(registration->GetModifiableOptimizer()); // Software Guide : EndCodeSnippet - unsigned int currentLevel = registration->GetCurrentLevel(); - typename RegistrationType::ShrinkFactorsPerDimensionContainerType + const unsigned int currentLevel = registration->GetCurrentLevel(); + const typename RegistrationType::ShrinkFactorsPerDimensionContainerType shrinkFactors = registration->GetShrinkFactorsPerDimension(currentLevel); typename RegistrationType::SmoothingSigmasArrayType smoothingSigmas = @@ -503,12 +503,12 @@ main(int argc, const char * argv[]) ParametersType finalParameters = transform->GetParameters(); - double TranslationAlongX = finalParameters[0]; - double TranslationAlongY = finalParameters[1]; + const double TranslationAlongX = finalParameters[0]; + const double TranslationAlongY = finalParameters[1]; - unsigned int numberOfIterations = optimizer->GetCurrentIteration(); + const unsigned int numberOfIterations = optimizer->GetCurrentIteration(); - double bestValue = optimizer->GetValue(); + const double bestValue = optimizer->GetValue(); // Print out results @@ -570,7 +570,7 @@ main(int argc, const char * argv[]) resample->SetTransform(transform); resample->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resample->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); diff --git a/Examples/RegistrationITKv4/MultiResImageRegistration2.cxx b/Examples/RegistrationITKv4/MultiResImageRegistration2.cxx index 84373205fdd..b5d9db1ed28 100644 --- a/Examples/RegistrationITKv4/MultiResImageRegistration2.cxx +++ b/Examples/RegistrationITKv4/MultiResImageRegistration2.cxx @@ -464,12 +464,12 @@ main(int argc, char * argv[]) using ParametersType = RegistrationType::ParametersType; ParametersType finalParameters = registration->GetLastTransformParameters(); - double TranslationAlongX = finalParameters[4]; - double TranslationAlongY = finalParameters[5]; + const double TranslationAlongX = finalParameters[4]; + const double TranslationAlongY = finalParameters[5]; - unsigned int numberOfIterations = optimizer->GetCurrentIteration(); + const unsigned int numberOfIterations = optimizer->GetCurrentIteration(); - double bestValue = optimizer->GetValue(); + const double bestValue = optimizer->GetValue(); // Print out results // @@ -535,7 +535,7 @@ main(int argc, char * argv[]) resample->SetTransform(finalTransform); resample->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); PixelType backgroundGrayLevel = 100; if (argc > 4) diff --git a/Examples/RegistrationITKv4/MultiResImageRegistration3.cxx b/Examples/RegistrationITKv4/MultiResImageRegistration3.cxx index 7a00431fee8..531c94d9a16 100644 --- a/Examples/RegistrationITKv4/MultiResImageRegistration3.cxx +++ b/Examples/RegistrationITKv4/MultiResImageRegistration3.cxx @@ -300,13 +300,13 @@ main(int argc, char * argv[]) ParametersType finalParameters = registration->GetLastTransformParameters(); - double TranslationAlongX = finalParameters[0]; - double TranslationAlongY = finalParameters[1]; - double TranslationAlongZ = finalParameters[2]; + const double TranslationAlongX = finalParameters[0]; + const double TranslationAlongY = finalParameters[1]; + const double TranslationAlongZ = finalParameters[2]; - unsigned int numberOfIterations = optimizer->GetCurrentIteration(); + const unsigned int numberOfIterations = optimizer->GetCurrentIteration(); - double bestValue = optimizer->GetValue(); + const double bestValue = optimizer->GetValue(); // Print out results @@ -331,7 +331,7 @@ main(int argc, char * argv[]) resample->SetTransform(finalTransform); resample->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); PixelType backgroundGrayLevel = 100; if (argc > 4) diff --git a/Examples/RegistrationITKv4/MultiStageImageRegistration1.cxx b/Examples/RegistrationITKv4/MultiStageImageRegistration1.cxx index a197a5b1d9e..2b9db9b7f2c 100644 --- a/Examples/RegistrationITKv4/MultiStageImageRegistration1.cxx +++ b/Examples/RegistrationITKv4/MultiStageImageRegistration1.cxx @@ -113,8 +113,8 @@ class RegistrationInterfaceCommand : public itk::Command const auto * registration = static_cast(object); - unsigned int currentLevel = registration->GetCurrentLevel(); - typename RegistrationType::ShrinkFactorsPerDimensionContainerType + const unsigned int currentLevel = registration->GetCurrentLevel(); + const typename RegistrationType::ShrinkFactorsPerDimensionContainerType shrinkFactors = registration->GetShrinkFactorsPerDimension(currentLevel); typename RegistrationType::SmoothingSigmasArrayType smoothingSigmas = @@ -533,7 +533,7 @@ main(int argc, char * argv[]) using RegionType = FixedImageType::RegionType; using SizeType = FixedImageType::SizeType; - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); const SpacingType fixedSpacing = fixedImage->GetSpacing(); const OriginType fixedOrigin = fixedImage->GetOrigin(); diff --git a/Examples/RegistrationITKv4/MultiStageImageRegistration2.cxx b/Examples/RegistrationITKv4/MultiStageImageRegistration2.cxx index 97087a11623..ceb64cef166 100644 --- a/Examples/RegistrationITKv4/MultiStageImageRegistration2.cxx +++ b/Examples/RegistrationITKv4/MultiStageImageRegistration2.cxx @@ -111,8 +111,8 @@ class RegistrationInterfaceCommand : public itk::Command << object->GetNameOfClass()); } - unsigned int currentLevel = registration->GetCurrentLevel(); - typename RegistrationType::ShrinkFactorsPerDimensionContainerType + const unsigned int currentLevel = registration->GetCurrentLevel(); + const typename RegistrationType::ShrinkFactorsPerDimensionContainerType shrinkFactors = registration->GetShrinkFactorsPerDimension(currentLevel); typename RegistrationType::SmoothingSigmasArrayType smoothingSigmas = @@ -369,7 +369,7 @@ main(int argc, char * argv[]) } fixedImageReader->Update(); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); // Software Guide : BeginCodeSnippet using FixedImageCalculatorType = diff --git a/Examples/RegistrationITKv4/ThinPlateSplineWarp.cxx b/Examples/RegistrationITKv4/ThinPlateSplineWarp.cxx index 20f555e9a8c..a2a5db56482 100644 --- a/Examples/RegistrationITKv4/ThinPlateSplineWarp.cxx +++ b/Examples/RegistrationITKv4/ThinPlateSplineWarp.cxx @@ -104,9 +104,9 @@ main(int argc, char * argv[]) auto targetLandMarks = PointSetType::New(); PointType p1; PointType p2; - PointSetType::PointsContainer::Pointer sourceLandMarkContainer = + const PointSetType::PointsContainer::Pointer sourceLandMarkContainer = sourceLandMarks->GetPoints(); - PointSetType::PointsContainer::Pointer targetLandMarkContainer = + const PointSetType::PointsContainer::Pointer targetLandMarkContainer = targetLandMarks->GetPoints(); // Software Guide : EndCodeSnippet @@ -141,15 +141,15 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Set the resampler params - InputImageType::ConstPointer inputImage = reader->GetOutput(); - auto resampler = ResamplerType::New(); - auto interpolator = InterpolatorType::New(); + const InputImageType::ConstPointer inputImage = reader->GetOutput(); + auto resampler = ResamplerType::New(); + auto interpolator = InterpolatorType::New(); resampler->SetInterpolator(interpolator); - InputImageType::SpacingType spacing = inputImage->GetSpacing(); - InputImageType::PointType origin = inputImage->GetOrigin(); - InputImageType::DirectionType direction = inputImage->GetDirection(); - InputImageType::RegionType region = inputImage->GetBufferedRegion(); - InputImageType::SizeType size = region.GetSize(); + const InputImageType::SpacingType spacing = inputImage->GetSpacing(); + const InputImageType::PointType origin = inputImage->GetOrigin(); + const InputImageType::DirectionType direction = inputImage->GetDirection(); + const InputImageType::RegionType region = inputImage->GetBufferedRegion(); + const InputImageType::SizeType size = region.GetSize(); // Software Guide : BeginCodeSnippet resampler->SetOutputSpacing(spacing); diff --git a/Examples/Segmentation/GeodesicActiveContourShapePriorLevelSetImageFilter.cxx b/Examples/Segmentation/GeodesicActiveContourShapePriorLevelSetImageFilter.cxx index 841e97b3f91..25fb99ae6bb 100644 --- a/Examples/Segmentation/GeodesicActiveContourShapePriorLevelSetImageFilter.cxx +++ b/Examples/Segmentation/GeodesicActiveContourShapePriorLevelSetImageFilter.cxx @@ -847,9 +847,9 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - double initRadius = 1.05; - double grow = 1.1; - double shrink = pow(grow, -0.25); + const double initRadius = 1.05; + const double grow = 1.1; + const double shrink = pow(grow, -0.25); optimizer->Initialize(initRadius, grow, shrink); optimizer->SetEpsilon(1.0e-6); // minimal search radius diff --git a/Examples/Segmentation/GibbsPriorImageFilter1.cxx b/Examples/Segmentation/GibbsPriorImageFilter1.cxx index ed29a28ec9d..c7d7b2a776e 100644 --- a/Examples/Segmentation/GibbsPriorImageFilter1.cxx +++ b/Examples/Segmentation/GibbsPriorImageFilter1.cxx @@ -111,7 +111,7 @@ main(int argc, char * argv[]) // auto vecImage = VecImageType::New(); using VecImagePixelType = VecImageType::PixelType; - VecImageType::SizeType vecImgSize = { { 181, 217, 1 } }; + const VecImageType::SizeType vecImgSize = { { 181, 217, 1 } }; VecImageType::IndexType index{}; @@ -224,7 +224,7 @@ main(int argc, char * argv[]) using ClassifierType = itk::ImageClassifierBase; using ClassifierPointer = ClassifierType::Pointer; - ClassifierPointer myClassifier = ClassifierType::New(); + const ClassifierPointer myClassifier = ClassifierType::New(); // Software Guide : EndCodeSnippet // Set the Classifier parameters diff --git a/Examples/Segmentation/HoughTransform2DCirclesImageFilter.cxx b/Examples/Segmentation/HoughTransform2DCirclesImageFilter.cxx index e8049817c1e..25b14319bad 100644 --- a/Examples/Segmentation/HoughTransform2DCirclesImageFilter.cxx +++ b/Examples/Segmentation/HoughTransform2DCirclesImageFilter.cxx @@ -101,7 +101,7 @@ main(int argc, char * argv[]) std::cerr << excep << std::endl; return EXIT_FAILURE; } - ImageType::Pointer localImage = reader->GetOutput(); + const ImageType::Pointer localImage = reader->GetOutput(); // Software Guide : EndCodeSnippet @@ -170,7 +170,8 @@ main(int argc, char * argv[]) } houghFilter->Update(); - AccumulatorImageType::Pointer localAccumulator = houghFilter->GetOutput(); + const AccumulatorImageType::Pointer localAccumulator = + houghFilter->GetOutput(); // Software Guide : EndCodeSnippet // Software Guide : BeginLatex @@ -245,7 +246,7 @@ main(int argc, char * argv[]) localIndex[1] = itk::Math::Round( centerPoint[1] + (*itCircles)->GetRadiusInObjectSpace()[0] * std::sin(angle)); - OutputImageType::RegionType outputRegion = + const OutputImageType::RegionType outputRegion = localOutputImage->GetLargestPossibleRegion(); if (outputRegion.IsInside(localIndex)) diff --git a/Examples/Segmentation/HoughTransform2DLinesImageFilter.cxx b/Examples/Segmentation/HoughTransform2DLinesImageFilter.cxx index 60b79086059..a9117cb2021 100644 --- a/Examples/Segmentation/HoughTransform2DLinesImageFilter.cxx +++ b/Examples/Segmentation/HoughTransform2DLinesImageFilter.cxx @@ -96,7 +96,7 @@ main(int argc, char * argv[]) std::cerr << excep << std::endl; return EXIT_FAILURE; } - ImageType::Pointer localImage = reader->GetOutput(); + const ImageType::Pointer localImage = reader->GetOutput(); // Software Guide : EndCodeSnippet @@ -141,8 +141,8 @@ main(int argc, char * argv[]) threshFilter->SetInput(gradFilter->GetOutput()); threshFilter->SetOutsideValue(0); - unsigned char threshBelow = 0; - unsigned char threshAbove = 255; + const unsigned char threshBelow = 0; + const unsigned char threshAbove = 255; threshFilter->ThresholdOutside(threshBelow, threshAbove); threshFilter->Update(); // Software Guide : EndCodeSnippet @@ -189,7 +189,8 @@ main(int argc, char * argv[]) houghFilter->SetDiscRadius(std::stod(argv[5])); } houghFilter->Update(); - AccumulatorImageType::Pointer localAccumulator = houghFilter->GetOutput(); + const AccumulatorImageType::Pointer localAccumulator = + houghFilter->GetOutput(); // Software Guide : EndCodeSnippet // Software Guide : BeginLatex @@ -218,7 +219,8 @@ main(int argc, char * argv[]) auto localOutputImage = OutputImageType::New(); - OutputImageType::RegionType region(localImage->GetLargestPossibleRegion()); + const OutputImageType::RegionType region( + localImage->GetLargestPossibleRegion()); localOutputImage->SetRegions(region); localOutputImage->CopyInformation(localImage); localOutputImage->Allocate(true); // initialize buffer to zero @@ -262,7 +264,7 @@ main(int argc, char * argv[]) v[0] = u[0] - (*itPoints).GetPositionInObjectSpace()[0]; v[1] = u[1] - (*itPoints).GetPositionInObjectSpace()[1]; - double norm = std::sqrt(v[0] * v[0] + v[1] * v[1]); + const double norm = std::sqrt(v[0] * v[0] + v[1] * v[1]); v[0] /= norm; v[1] /= norm; // Software Guide : EndCodeSnippet @@ -277,7 +279,7 @@ main(int argc, char * argv[]) ImageType::IndexType localIndex; itk::Size<2> size = localOutputImage->GetLargestPossibleRegion().GetSize(); - float diag = + const float diag = std::sqrt(static_cast(size[0] * size[0] + size[1] * size[1])); for (auto i = static_cast(-diag); i < static_cast(diag); ++i) @@ -285,7 +287,7 @@ main(int argc, char * argv[]) localIndex[0] = static_cast(u[0] + i * v[0]); localIndex[1] = static_cast(u[1] + i * v[1]); - OutputImageType::RegionType outputRegion = + const OutputImageType::RegionType outputRegion = localOutputImage->GetLargestPossibleRegion(); if (outputRegion.IsInside(localIndex)) diff --git a/Examples/Segmentation/LaplacianSegmentationLevelSetImageFilter.cxx b/Examples/Segmentation/LaplacianSegmentationLevelSetImageFilter.cxx index c5a9726f947..0836af1a177 100644 --- a/Examples/Segmentation/LaplacianSegmentationLevelSetImageFilter.cxx +++ b/Examples/Segmentation/LaplacianSegmentationLevelSetImageFilter.cxx @@ -166,7 +166,7 @@ main(int argc, char * argv[]) using LaplacianSegmentationLevelSetImageFilterType = itk::LaplacianSegmentationLevelSetImageFilter; - LaplacianSegmentationLevelSetImageFilterType::Pointer + const LaplacianSegmentationLevelSetImageFilterType::Pointer laplacianSegmentation = LaplacianSegmentationLevelSetImageFilterType::New(); // Software Guide : EndCodeSnippet diff --git a/Examples/Segmentation/ThresholdSegmentationLevelSetImageFilter.cxx b/Examples/Segmentation/ThresholdSegmentationLevelSetImageFilter.cxx index 132e5287047..015f47005d7 100644 --- a/Examples/Segmentation/ThresholdSegmentationLevelSetImageFilter.cxx +++ b/Examples/Segmentation/ThresholdSegmentationLevelSetImageFilter.cxx @@ -176,7 +176,7 @@ main(int argc, char * argv[]) using ThresholdSegmentationLevelSetImageFilterType = itk::ThresholdSegmentationLevelSetImageFilter; - ThresholdSegmentationLevelSetImageFilterType::Pointer + const ThresholdSegmentationLevelSetImageFilterType::Pointer thresholdSegmentation = ThresholdSegmentationLevelSetImageFilterType::New(); // Software Guide : EndCodeSnippet diff --git a/Examples/SpatialObjects/BlobSpatialObject.cxx b/Examples/SpatialObjects/BlobSpatialObject.cxx index b0de29ebc88..2e5ba9ffec7 100644 --- a/Examples/SpatialObjects/BlobSpatialObject.cxx +++ b/Examples/SpatialObjects/BlobSpatialObject.cxx @@ -106,7 +106,7 @@ main(int, char *[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - BlobPointer blob = BlobType::New(); + const BlobPointer blob = BlobType::New(); blob->GetProperty().SetName("My Blob"); blob->SetId(1); blob->SetPoints(list); @@ -121,7 +121,7 @@ main(int, char *[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - BlobType::BlobPointListType pointList = blob->GetPoints(); + const BlobType::BlobPointListType pointList = blob->GetPoints(); std::cout << "The blob contains " << pointList.size(); std::cout << " points" << std::endl; // Software Guide : EndCodeSnippet diff --git a/Examples/SpatialObjects/DTITubeSpatialObject.cxx b/Examples/SpatialObjects/DTITubeSpatialObject.cxx index fb4d923099f..8eb559f349d 100644 --- a/Examples/SpatialObjects/DTITubeSpatialObject.cxx +++ b/Examples/SpatialObjects/DTITubeSpatialObject.cxx @@ -133,7 +133,7 @@ main(int, char *[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - DTITubeType::DTITubePointListType pointList = dtiTube->GetPoints(); + const DTITubeType::DTITubePointListType pointList = dtiTube->GetPoints(); std::cout << "Number of points representing the fiber tract: "; std::cout << pointList.size() << std::endl; // Software Guide : EndCodeSnippet diff --git a/Examples/SpatialObjects/EllipseSpatialObject.cxx b/Examples/SpatialObjects/EllipseSpatialObject.cxx index cb530b16daf..999db901d40 100644 --- a/Examples/SpatialObjects/EllipseSpatialObject.cxx +++ b/Examples/SpatialObjects/EllipseSpatialObject.cxx @@ -83,7 +83,7 @@ main(int, char *[]) // // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - EllipseType::ArrayType myCurrentRadius = + const EllipseType::ArrayType myCurrentRadius = myEllipse->GetRadiusInObjectSpace(); std::cout << "Current radius is " << myCurrentRadius << std::endl; // Software Guide : EndCodeSnippet diff --git a/Examples/SpatialObjects/ImageMaskSpatialObject.cxx b/Examples/SpatialObjects/ImageMaskSpatialObject.cxx index 895d4821a37..7fd19af1add 100644 --- a/Examples/SpatialObjects/ImageMaskSpatialObject.cxx +++ b/Examples/SpatialObjects/ImageMaskSpatialObject.cxx @@ -67,10 +67,10 @@ main(int, char *[]) using ImageType = ImageMaskSpatialObject::ImageType; using Iterator = itk::ImageRegionIterator; - auto image = ImageType::New(); - ImageType::SizeType size = { { 50, 50, 50 } }; - ImageType::IndexType index = { { 0, 0, 0 } }; - ImageType::RegionType region; + auto image = ImageType::New(); + const ImageType::SizeType size = { { 50, 50, 50 } }; + const ImageType::IndexType index = { { 0, 0, 0 } }; + ImageType::RegionType region; region.SetSize(size); region.SetIndex(index); @@ -78,9 +78,9 @@ main(int, char *[]) image->SetRegions(region); image->Allocate(true); // initialize buffer to zero - ImageType::RegionType insideRegion; - ImageType::SizeType insideSize = { { 30, 30, 30 } }; - ImageType::IndexType insideIndex = { { 10, 10, 10 } }; + ImageType::RegionType insideRegion; + const ImageType::SizeType insideSize = { { 30, 30, 30 } }; + const ImageType::IndexType insideIndex = { { 10, 10, 10 } }; insideRegion.SetSize(insideSize); insideRegion.SetIndex(insideIndex); diff --git a/Examples/SpatialObjects/ImageSpatialObject.cxx b/Examples/SpatialObjects/ImageSpatialObject.cxx index 448e1a106bd..e83ef7d0369 100644 --- a/Examples/SpatialObjects/ImageSpatialObject.cxx +++ b/Examples/SpatialObjects/ImageSpatialObject.cxx @@ -43,9 +43,9 @@ main(int, char *[]) // Software Guide : BeginCodeSnippet using Image = itk::Image; - auto image = Image::New(); - Image::SizeType size = { { 10, 10 } }; - Image::RegionType region; + auto image = Image::New(); + const Image::SizeType size = { { 10, 10 } }; + Image::RegionType region; region.SetSize(size); image->SetRegions(region); image->Allocate(); diff --git a/Examples/SpatialObjects/LandmarkSpatialObject.cxx b/Examples/SpatialObjects/LandmarkSpatialObject.cxx index 7d83cedd76d..243e86409f0 100644 --- a/Examples/SpatialObjects/LandmarkSpatialObject.cxx +++ b/Examples/SpatialObjects/LandmarkSpatialObject.cxx @@ -47,7 +47,7 @@ main(int, char *[]) using LandmarkPointType = LandmarkType::LandmarkPointType; using PointType = LandmarkType::PointType; - LandmarkPointer landmark = LandmarkType::New(); + const LandmarkPointer landmark = LandmarkType::New(); // Software Guide : EndCodeSnippet // Software Guide : BeginLatex // @@ -104,7 +104,7 @@ main(int, char *[]) // // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - size_t nPoints = landmark->GetPoints().size(); + const size_t nPoints = landmark->GetPoints().size(); std::cout << "Number of Points in the landmark: " << nPoints << std::endl; LandmarkType::LandmarkPointListType::const_iterator it = diff --git a/Examples/SpatialObjects/LineSpatialObject.cxx b/Examples/SpatialObjects/LineSpatialObject.cxx index 1b877d3a9f9..d2a07363569 100644 --- a/Examples/SpatialObjects/LineSpatialObject.cxx +++ b/Examples/SpatialObjects/LineSpatialObject.cxx @@ -53,7 +53,7 @@ main(int, char *[]) using PointType = LineType::PointType; using CovariantVectorType = LineType::CovariantVectorType; - LinePointer Line = LineType::New(); + const LinePointer Line = LineType::New(); // Software Guide : EndCodeSnippet // Software Guide : BeginLatex @@ -119,7 +119,7 @@ main(int, char *[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - LineType::LinePointListType pointList = Line->GetPoints(); + const LineType::LinePointListType pointList = Line->GetPoints(); std::cout << "Number of points representing the line: "; std::cout << pointList.size() << std::endl; // Software Guide : EndCodeSnippet diff --git a/Examples/SpatialObjects/MeshSpatialObject.cxx b/Examples/SpatialObjects/MeshSpatialObject.cxx index 66093afd0a7..680dd9ffc65 100644 --- a/Examples/SpatialObjects/MeshSpatialObject.cxx +++ b/Examples/SpatialObjects/MeshSpatialObject.cxx @@ -63,7 +63,7 @@ main(int, char *[]) // Software Guide : BeginCodeSnippet auto myMesh = MeshType::New(); - MeshType::CoordinateType testPointCoords[4][3] = { + const MeshType::CoordinateType testPointCoords[4][3] = { { 0, 0, 0 }, { 9, 0, 0 }, { 9, 9, 0 }, { 0, 0, 9 } }; @@ -238,7 +238,7 @@ main(int, char *[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - ImageType::Pointer myBinaryMeshImage = imageFilter->GetOutput(); + const ImageType::Pointer myBinaryMeshImage = imageFilter->GetOutput(); // Software Guide : EndCodeSnippet return EXIT_SUCCESS; diff --git a/Examples/SpatialObjects/SpatialObjectToImageStatisticsCalculator.cxx b/Examples/SpatialObjects/SpatialObjectToImageStatisticsCalculator.cxx index 168967dfd35..2eace034dd2 100644 --- a/Examples/SpatialObjects/SpatialObjectToImageStatisticsCalculator.cxx +++ b/Examples/SpatialObjects/SpatialObjectToImageStatisticsCalculator.cxx @@ -52,7 +52,7 @@ main(int, char *[]) size[1] = 10; randomImageSource->SetSize(size); randomImageSource->Update(); - ImageType::Pointer image = randomImageSource->GetOutput(); + const ImageType::Pointer image = randomImageSource->GetOutput(); // Software Guide : EndCodeSnippet // Software Guide : BeginLatex diff --git a/Examples/SpatialObjects/SurfaceSpatialObject.cxx b/Examples/SpatialObjects/SurfaceSpatialObject.cxx index 0f7c11af822..3ba5df21a37 100644 --- a/Examples/SpatialObjects/SurfaceSpatialObject.cxx +++ b/Examples/SpatialObjects/SurfaceSpatialObject.cxx @@ -53,7 +53,7 @@ main(int, char *[]) using CovariantVectorType = SurfaceType::CovariantVectorType; using PointType = SurfaceType::PointType; - SurfacePointer surface = SurfaceType::New(); + const SurfacePointer surface = SurfaceType::New(); // Software Guide : EndCodeSnippet // Software Guide : BeginLatex @@ -109,7 +109,7 @@ main(int, char *[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - SurfaceType::SurfacePointListType pointList = surface->GetPoints(); + const SurfaceType::SurfacePointListType pointList = surface->GetPoints(); std::cout << "Number of points representing the surface: "; std::cout << pointList.size() << std::endl; // Software Guide : EndCodeSnippet diff --git a/Examples/SpatialObjects/TubeSpatialObject.cxx b/Examples/SpatialObjects/TubeSpatialObject.cxx index d0d45277680..08a50057b4e 100644 --- a/Examples/SpatialObjects/TubeSpatialObject.cxx +++ b/Examples/SpatialObjects/TubeSpatialObject.cxx @@ -54,7 +54,7 @@ main(int, char *[]) using PointType = TubeType::PointType; using CovariantVectorType = TubePointType::CovariantVectorType; - TubePointer tube = TubeType::New(); + const TubePointer tube = TubeType::New(); // Software Guide : EndCodeSnippet // Software Guide : BeginLatex @@ -123,7 +123,7 @@ main(int, char *[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - TubeType::TubePointListType pointList = tube->GetPoints(); + const TubeType::TubePointListType pointList = tube->GetPoints(); std::cout << "Number of points representing the tube: "; std::cout << pointList.size() << std::endl; // Software Guide : EndCodeSnippet diff --git a/Examples/SpatialObjects/VesselTubeSpatialObject.cxx b/Examples/SpatialObjects/VesselTubeSpatialObject.cxx index 720e02b9517..fb2bfb187f2 100644 --- a/Examples/SpatialObjects/VesselTubeSpatialObject.cxx +++ b/Examples/SpatialObjects/VesselTubeSpatialObject.cxx @@ -123,7 +123,7 @@ main(int, char *[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - VesselTubeType::TubePointListType pointList = vesselTube->GetPoints(); + const VesselTubeType::TubePointListType pointList = vesselTube->GetPoints(); std::cout << "Number of points representing the blood vessel: "; std::cout << pointList.size() << std::endl; // Software Guide : EndCodeSnippet diff --git a/Examples/Statistics/BayesianPluginClassifier.cxx b/Examples/Statistics/BayesianPluginClassifier.cxx index 0efab9deb5a..f214695a5f4 100644 --- a/Examples/Statistics/BayesianPluginClassifier.cxx +++ b/Examples/Statistics/BayesianPluginClassifier.cxx @@ -278,9 +278,9 @@ main(int, char *[]) auto classLabelVectorObject = ClassLabelVectorObjectType::New(); ClassLabelVectorType classLabelVector = classLabelVectorObject->Get(); - ClassifierType::ClassLabelType class1 = 100; + const ClassifierType::ClassLabelType class1 = 100; classLabelVector.push_back(class1); - ClassifierType::ClassLabelType class2 = 200; + const ClassifierType::ClassLabelType class2 = 200; classLabelVector.push_back(class2); classLabelVectorObject->Set(classLabelVector); diff --git a/Examples/Statistics/ExpectationMaximizationMixtureModelEstimator.cxx b/Examples/Statistics/ExpectationMaximizationMixtureModelEstimator.cxx index bde5b6344a5..4c675ee311b 100644 --- a/Examples/Statistics/ExpectationMaximizationMixtureModelEstimator.cxx +++ b/Examples/Statistics/ExpectationMaximizationMixtureModelEstimator.cxx @@ -122,7 +122,7 @@ main() // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - unsigned int numberOfClasses = 2; + const unsigned int numberOfClasses = 2; using MeasurementVectorType = itk::Vector; using SampleType = itk::Statistics::ListSample; auto sample = SampleType::New(); diff --git a/Examples/Statistics/ImageEntropy1.cxx b/Examples/Statistics/ImageEntropy1.cxx index de718b28cd3..4ac41ea6556 100644 --- a/Examples/Statistics/ImageEntropy1.cxx +++ b/Examples/Statistics/ImageEntropy1.cxx @@ -194,10 +194,10 @@ main(int argc, char * argv[]) // Software Guide : BeginCodeSnippet - HistogramType::ConstIterator itr = histogram->Begin(); - HistogramType::ConstIterator end = histogram->End(); + HistogramType::ConstIterator itr = histogram->Begin(); + const HistogramType::ConstIterator end = histogram->End(); - double Sum = histogram->GetTotalFrequency(); + const double Sum = histogram->GetTotalFrequency(); double Entropy = 0.0; // Software Guide : EndCodeSnippet diff --git a/Examples/Statistics/ImageHistogram1.cxx b/Examples/Statistics/ImageHistogram1.cxx index f82f705dfee..88360357a56 100644 --- a/Examples/Statistics/ImageHistogram1.cxx +++ b/Examples/Statistics/ImageHistogram1.cxx @@ -206,7 +206,7 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - HistogramType::ConstPointer histogram = filter->GetOutput(); + const HistogramType::ConstPointer histogram = filter->GetOutput(); // Software Guide : EndCodeSnippet // Software Guide : BeginLatex diff --git a/Examples/Statistics/ImageHistogram2.cxx b/Examples/Statistics/ImageHistogram2.cxx index 3779056ebb2..5cede9e4611 100644 --- a/Examples/Statistics/ImageHistogram2.cxx +++ b/Examples/Statistics/ImageHistogram2.cxx @@ -193,8 +193,8 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - HistogramType::ConstIterator itr = histogram->Begin(); - HistogramType::ConstIterator end = histogram->End(); + HistogramType::ConstIterator itr = histogram->Begin(); + const HistogramType::ConstIterator end = histogram->End(); unsigned int binNumber = 0; while (itr != end) diff --git a/Examples/Statistics/ImageHistogram4.cxx b/Examples/Statistics/ImageHistogram4.cxx index e506363303a..08391a5a18b 100644 --- a/Examples/Statistics/ImageHistogram4.cxx +++ b/Examples/Statistics/ImageHistogram4.cxx @@ -257,8 +257,8 @@ main(int argc, char * argv[]) std::ofstream histogramFile; histogramFile.open(argv[2]); - HistogramType::ConstIterator itr = histogram->Begin(); - HistogramType::ConstIterator end = histogram->End(); + HistogramType::ConstIterator itr = histogram->Begin(); + const HistogramType::ConstIterator end = histogram->End(); using AbsoluteFrequencyType = HistogramType::AbsoluteFrequencyType; diff --git a/Examples/Statistics/ImageMutualInformation1.cxx b/Examples/Statistics/ImageMutualInformation1.cxx index 2cc8091db8b..55518fdc3b1 100644 --- a/Examples/Statistics/ImageMutualInformation1.cxx +++ b/Examples/Statistics/ImageMutualInformation1.cxx @@ -419,7 +419,7 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - double MutualInformation = Entropy1 + Entropy2 - JointEntropy; + const double MutualInformation = Entropy1 + Entropy2 - JointEntropy; // Software Guide : EndCodeSnippet std::cout << "Mutual Information = " << MutualInformation << " bits " @@ -434,7 +434,7 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - double NormalizedMutualInformation1 = + const double NormalizedMutualInformation1 = 2.0 * MutualInformation / (Entropy1 + Entropy2); // Software Guide : EndCodeSnippet @@ -450,7 +450,8 @@ main(int argc, char * argv[]) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - double NormalizedMutualInformation2 = (Entropy1 + Entropy2) / JointEntropy; + const double NormalizedMutualInformation2 = + (Entropy1 + Entropy2) / JointEntropy; // Software Guide : EndCodeSnippet diff --git a/Examples/Statistics/KdTree.cxx b/Examples/Statistics/KdTree.cxx index e335ec5b80c..7540ba69a11 100644 --- a/Examples/Statistics/KdTree.cxx +++ b/Examples/Statistics/KdTree.cxx @@ -124,8 +124,8 @@ main() using TreeType = TreeGeneratorType::KdTreeType; using NodeType = TreeType::KdTreeNodeType; - TreeType::Pointer tree = treeGenerator->GetOutput(); - TreeType::Pointer centroidTree = centroidTreeGenerator->GetOutput(); + const TreeType::Pointer tree = treeGenerator->GetOutput(); + const TreeType::Pointer centroidTree = centroidTreeGenerator->GetOutput(); NodeType * root = tree->GetRoot(); @@ -212,7 +212,7 @@ main() // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - unsigned int numberOfNeighbors = 3; + const unsigned int numberOfNeighbors = 3; TreeType::InstanceIdentifierVectorType neighbors; tree->Search(queryPoint, numberOfNeighbors, neighbors); @@ -308,7 +308,7 @@ main() // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - double radius = 437.0; + const double radius = 437.0; tree->Search(queryPoint, radius, neighbors); diff --git a/Examples/Statistics/KdTreeBasedKMeansClustering.cxx b/Examples/Statistics/KdTreeBasedKMeansClustering.cxx index 1f4a49faddc..c3debf8ff25 100644 --- a/Examples/Statistics/KdTreeBasedKMeansClustering.cxx +++ b/Examples/Statistics/KdTreeBasedKMeansClustering.cxx @@ -323,9 +323,9 @@ main() auto classLabelsObject = ClassLabelVectorObjectType::New(); ClassLabelVectorType & classLabelsVector = classLabelsObject->Get(); - ClassLabelType class1 = 200; + const ClassLabelType class1 = 200; classLabelsVector.push_back(class1); - ClassLabelType class2 = 100; + const ClassLabelType class2 = 100; classLabelsVector.push_back(class2); classifier->SetClassLabels(classLabelsObject); diff --git a/Examples/Statistics/MembershipSample.cxx b/Examples/Statistics/MembershipSample.cxx index a1cc94c0edd..3850f4aa830 100644 --- a/Examples/Statistics/MembershipSample.cxx +++ b/Examples/Statistics/MembershipSample.cxx @@ -175,7 +175,7 @@ main() // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - MembershipSampleType::ClassSampleType::ConstPointer classSample = + const MembershipSampleType::ClassSampleType::ConstPointer classSample = membershipSample->GetClassSample(0); MembershipSampleType::ClassSampleType::ConstIterator c_iter = diff --git a/Examples/Statistics/SampleSorting.cxx b/Examples/Statistics/SampleSorting.cxx index c06047e3466..9520bd31ffc 100644 --- a/Examples/Statistics/SampleSorting.cxx +++ b/Examples/Statistics/SampleSorting.cxx @@ -190,7 +190,7 @@ main() // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - int activeDimension = 0; + const int activeDimension = 0; itk::Statistics::Algorithm::InsertSort( subsample, activeDimension, 0, subsample->Size()); printSubsample(subsample, "InsertSort"); @@ -243,7 +243,7 @@ main() // Software Guide : BeginCodeSnippet initializeSubsample(subsample, sample); - SubsampleType::MeasurementType median = + const SubsampleType::MeasurementType median = itk::Statistics::Algorithm::QuickSelect(subsample, activeDimension, 0, diff --git a/Examples/Statistics/ScalarImageMarkovRandomField1.cxx b/Examples/Statistics/ScalarImageMarkovRandomField1.cxx index aef51ff3fa5..3e529767a0e 100644 --- a/Examples/Statistics/ScalarImageMarkovRandomField1.cxx +++ b/Examples/Statistics/ScalarImageMarkovRandomField1.cxx @@ -279,7 +279,7 @@ main(int argc, char * argv[]) MembershipFunctionType::CentroidType centroid(1); for (unsigned int i = 0; i < numberOfClasses; ++i) { - MembershipFunctionPointer membershipFunction = + const MembershipFunctionPointer membershipFunction = MembershipFunctionType::New(); centroid[0] = std::stod(argv[i + numberOfArgumentsBeforeMeans]); @@ -373,7 +373,7 @@ main(int argc, char * argv[]) // Software Guide : BeginCodeSnippet double totalWeight = 0; - for (double weight : weights) + for (const double weight : weights) { totalWeight += weight; } diff --git a/Modules/Bridge/VTK/src/itkVTKImageExportBase.cxx b/Modules/Bridge/VTK/src/itkVTKImageExportBase.cxx index 855ba87b4b9..5e438ccadff 100644 --- a/Modules/Bridge/VTK/src/itkVTKImageExportBase.cxx +++ b/Modules/Bridge/VTK/src/itkVTKImageExportBase.cxx @@ -133,7 +133,7 @@ VTKImageExportBase::UpdateInformationCallback() int VTKImageExportBase::PipelineModifiedCallback() { - DataObjectPointer input = this->GetInput(0); + const DataObjectPointer input = this->GetInput(0); if (!input) { @@ -173,7 +173,7 @@ void VTKImageExportBase::UpdateDataCallback() { // Get the input. - DataObjectPointer input = this->GetInput(0); + const DataObjectPointer input = this->GetInput(0); if (!input) { diff --git a/Modules/Core/Common/include/VNLIterativeSparseSolverTraits.h b/Modules/Core/Common/include/VNLIterativeSparseSolverTraits.h index b743c2ea95a..3f5d3ee5037 100644 --- a/Modules/Core/Common/include/VNLIterativeSparseSolverTraits.h +++ b/Modules/Core/Common/include/VNLIterativeSparseSolverTraits.h @@ -123,8 +123,8 @@ class VNLIterativeSparseSolverTraits static bool Solve(const MatrixType & iA, const VectorType & iBx, const VectorType & iBy, VectorType & oX, VectorType & oY) { - bool result1 = Solve(iA, iBx, oX); - bool result2 = Solve(iA, iBy, oY); + const bool result1 = Solve(iA, iBx, oX); + const bool result2 = Solve(iA, iBy, oY); return (result1 && result2); } diff --git a/Modules/Core/Common/include/itkAnnulusOperator.hxx b/Modules/Core/Common/include/itkAnnulusOperator.hxx index 2461fe041c7..20ec162fb59 100644 --- a/Modules/Core/Common/include/itkAnnulusOperator.hxx +++ b/Modules/Core/Common/include/itkAnnulusOperator.hxx @@ -30,7 +30,7 @@ template void AnnulusOperator::CreateOperator() { - CoefficientVector coefficients = this->GenerateCoefficients(); + const CoefficientVector coefficients = this->GenerateCoefficients(); this->Fill(coefficients); } @@ -84,7 +84,7 @@ AnnulusOperator::GenerateCoefficients() -> Coeff { SizeType r; - double outerRadius = m_InnerRadius + m_Thickness; + const double outerRadius = m_InnerRadius + m_Thickness; for (unsigned int i = 0; i < TDimension; ++i) { r[i] = Math::Ceil(outerRadius / m_Spacing[i]); @@ -160,16 +160,16 @@ AnnulusOperator::GenerateCoefficients() -> Coeff { // Calculate the mean and standard deviation of kernel values NOT // the exterior - auto num = static_cast(countNotExterior); - double mean = sumNotExterior / num; - double var = (sumNotExteriorSq - (sumNotExterior * sumNotExterior / num)) / (num - 1.0); - double std = std::sqrt(var); + auto num = static_cast(countNotExterior); + const double mean = sumNotExterior / num; + const double var = (sumNotExteriorSq - (sumNotExterior * sumNotExterior / num)) / (num - 1.0); + const double std = std::sqrt(var); // convert std to a scaling factor k such that // // || (coeffP - mean) / k || = 1.0 // - double k = std * std::sqrt(num - 1.0); + const double k = std * std::sqrt(num - 1.0); // Run through the kernel again, shifting and normalizing the // elements that are not exterior to the annulus. This forces the diff --git a/Modules/Core/Common/include/itkBinaryThresholdSpatialFunction.hxx b/Modules/Core/Common/include/itkBinaryThresholdSpatialFunction.hxx index 5eef8a3a850..cdae77134ed 100644 --- a/Modules/Core/Common/include/itkBinaryThresholdSpatialFunction.hxx +++ b/Modules/Core/Common/include/itkBinaryThresholdSpatialFunction.hxx @@ -42,7 +42,7 @@ template auto BinaryThresholdSpatialFunction::Evaluate(const InputType & point) const -> OutputType { - FunctionOutputType value = m_Function->Evaluate(point); + const FunctionOutputType value = m_Function->Evaluate(point); if (m_LowerThreshold <= value && value <= m_UpperThreshold) { diff --git a/Modules/Core/Common/include/itkBoundingBox.hxx b/Modules/Core/Common/include/itkBoundingBox.hxx index e4c05e6ec94..4b3f8e68dd5 100644 --- a/Modules/Core/Common/include/itkBoundingBox.hxx +++ b/Modules/Core/Common/include/itkBoundingBox.hxx @@ -348,11 +348,11 @@ BoundingBox::D // Copy the corners into the clone. clone->m_CornersContainer->clear(); - PointsContainerConstIterator itr = this->m_CornersContainer->Begin(); - PointsContainerConstIterator end = this->m_CornersContainer->End(); + PointsContainerConstIterator itr = this->m_CornersContainer->Begin(); + const PointsContainerConstIterator end = this->m_CornersContainer->End(); clone->m_CornersContainer->Reserve(this->m_CornersContainer->Size()); - PointsContainerIterator dest = clone->m_CornersContainer->Begin(); + const PointsContainerIterator dest = clone->m_CornersContainer->Begin(); while (itr != end) { diff --git a/Modules/Core/Common/include/itkBresenhamLine.hxx b/Modules/Core/Common/include/itkBresenhamLine.hxx index f6d9782eeb9..8fb216d84f2 100644 --- a/Modules/Core/Common/include/itkBresenhamLine.hxx +++ b/Modules/Core/Common/include/itkBresenhamLine.hxx @@ -60,7 +60,7 @@ BresenhamLine::BuildLine(LType Direction, IdentifierType length) -> } // The dimension with the largest difference between start and end - unsigned int m_MainDirection = maxDistanceDimension; + const unsigned int m_MainDirection = maxDistanceDimension; // If enough is accumulated for a dimension, the index has to be // incremented. Will be the number of pixels in the line auto m_MaximalError = MakeFilled(maxDistance); @@ -113,7 +113,7 @@ BresenhamLine::BuildLine(IndexType p0, IndexType p1) -> IndexArray { point0[i] = p0[i]; point1[i] = p1[i]; - IdentifierType distance = itk::Math::abs(p0[i] - p1[i]) + 1; + const IdentifierType distance = itk::Math::abs(p0[i] - p1[i]) + 1; if (distance > maxDistance) { maxDistance = distance; diff --git a/Modules/Core/Common/include/itkCellInterface.h b/Modules/Core/Common/include/itkCellInterface.h index a286bf6ac9b..583253b99ef 100644 --- a/Modules/Core/Common/include/itkCellInterface.h +++ b/Modules/Core/Common/include/itkCellInterface.h @@ -207,7 +207,7 @@ class ITK_TEMPLATE_EXPORT CellInterface void AddVisitor(VisitorType * v) { - CellGeometryEnum id = v->GetCellTopologyId(); + const CellGeometryEnum id = v->GetCellTopologyId(); if (id < CellGeometryEnum::LAST_ITK_CELL) { diff --git a/Modules/Core/Common/include/itkColorTable.hxx b/Modules/Core/Common/include/itkColorTable.hxx index 9cf38937f89..b9a7a02686a 100644 --- a/Modules/Core/Common/include/itkColorTable.hxx +++ b/Modules/Core/Common/include/itkColorTable.hxx @@ -87,8 +87,8 @@ ColorTable::UseDiscreteColors() // max for TComponent. Exceptions were happening // on this assignment, even if realMax was // set to NumericTraits::max(). - typename NumericTraits::RealType realMax(1.0 * scale + shift); - TComponent pixelMax(NumericTraits::max()); + const typename NumericTraits::RealType realMax(1.0 * scale + shift); + TComponent pixelMax(NumericTraits::max()); // Converting from TComponent to RealType may introduce a rounding error, so do static_cast constexpr auto max_value_converted = static_cast::RealType>(NumericTraits::max()); @@ -140,7 +140,7 @@ ColorTable::UseGrayColors(unsigned int n) static_cast::RealType>(NumericTraits::max()); for (i = 0; i < m_NumberOfColors; ++i) { - typename NumericTraits::RealType realGray(minimum + i * delta); + const typename NumericTraits::RealType realGray(minimum + i * delta); TComponent gray = NumericTraits::max(); if (realGray < max_value_converted) @@ -187,8 +187,8 @@ ColorTable::UseHeatColors(unsigned int n) { // // avoid overflow - typename NumericTraits::RealType realR(((i + 1) / (n / 2.0 + 1)) * scale + shift); - TComponent r(NumericTraits::max()); + const typename NumericTraits::RealType realR(((i + 1) / (n / 2.0 + 1)) * scale + shift); + TComponent r(NumericTraits::max()); if (realR < max_value_converted) { r = static_cast(realR); @@ -203,8 +203,8 @@ ColorTable::UseHeatColors(unsigned int n) for (i = 0; i < n / 2; ++i) { - typename NumericTraits::RealType rdouble(1.0 * scale + shift); - TComponent r(NumericTraits::max()); + const typename NumericTraits::RealType rdouble(1.0 * scale + shift); + TComponent r(NumericTraits::max()); if (rdouble < max_value_converted) { r = static_cast(rdouble); diff --git a/Modules/Core/Common/include/itkConceptChecking.h b/Modules/Core/Common/include/itkConceptChecking.h index 0480fc6aa2d..ba5b8f06f16 100644 --- a/Modules/Core/Common/include/itkConceptChecking.h +++ b/Modules/Core/Common/include/itkConceptChecking.h @@ -153,7 +153,7 @@ template void RequireBooleanExpression(const T & t) { - bool x = t; + const bool x = t; IgnoreUnusedVariable(x); } @@ -649,7 +649,7 @@ struct Signed void constraints() { - SignedT a = TrueT(); + const SignedT a = TrueT(); Detail::IgnoreUnusedVariable(a); } @@ -667,7 +667,7 @@ struct SameType void constraints() { - Detail::UniqueType a = Detail::UniqueType(); + const Detail::UniqueType a = Detail::UniqueType(); Detail::IgnoreUnusedVariable(a); } }; @@ -685,7 +685,7 @@ struct SameDimension void constraints() { - DT1 a = DT2(); + DT1 const a = DT2(); Detail::IgnoreUnusedVariable(a); } @@ -739,7 +739,7 @@ struct HasPixelTraits constraints() { Detail::UniqueType::ValueType>(); - unsigned int a = PixelTraits::Dimension; + const unsigned int a = PixelTraits::Dimension; Detail::IgnoreUnusedVariable(a); } }; @@ -817,7 +817,7 @@ struct SameDimensionOrMinusOne void constraints() { - Detail::UniqueType_unsigned_int tt; + const Detail::UniqueType_unsigned_int tt; this->f(tt); } }; @@ -867,7 +867,7 @@ struct IsInteger void constraints() { - IntegralT a = TrueT(); + const IntegralT a = TrueT(); Detail::IgnoreUnusedVariable(a); } @@ -890,7 +890,7 @@ struct IsUnsignedInteger void constraints() { - UnsignedT a = TrueT(); + const UnsignedT a = TrueT(); Detail::IgnoreUnusedVariable(a); } @@ -937,8 +937,8 @@ struct IsFloatingPoint void constraints() { - IntegralT a = FalseT(); - ExactT b = FalseT(); + const IntegralT a = FalseT(); + const ExactT b = FalseT(); Detail::IgnoreUnusedVariable(a); Detail::IgnoreUnusedVariable(b); diff --git a/Modules/Core/Common/include/itkConicShellInteriorExteriorSpatialFunction.hxx b/Modules/Core/Common/include/itkConicShellInteriorExteriorSpatialFunction.hxx index 0c20f0bd445..667b91e1909 100644 --- a/Modules/Core/Common/include/itkConicShellInteriorExteriorSpatialFunction.hxx +++ b/Modules/Core/Common/include/itkConicShellInteriorExteriorSpatialFunction.hxx @@ -41,7 +41,7 @@ ConicShellInteriorExteriorSpatialFunction::Evaluate(const In VectorType vecOriginToTest = position - m_Origin; // Compute the length of this vector - double vecDistance = vecOriginToTest.GetNorm(); + const double vecDistance = vecOriginToTest.GetNorm(); // Check to see if this an allowed distance if (!((vecDistance > m_DistanceMin) && (vecDistance < m_DistanceMax))) @@ -53,7 +53,7 @@ ConicShellInteriorExteriorSpatialFunction::Evaluate(const In vecOriginToTest.Normalize(); // Create a temp vector to get around const problems - GradientType originGradient = m_OriginGradient; + const GradientType originGradient = m_OriginGradient; // Now compute the dot product double dotprod = originGradient * vecOriginToTest; diff --git a/Modules/Core/Common/include/itkConnectedComponentAlgorithm.h b/Modules/Core/Common/include/itkConnectedComponentAlgorithm.h index e4be81588fe..165787eef5c 100644 --- a/Modules/Core/Common/include/itkConnectedComponentAlgorithm.h +++ b/Modules/Core/Common/include/itkConnectedComponentAlgorithm.h @@ -47,13 +47,13 @@ setConnectivity(TIterator * it, bool fullyConnected = false) { // activate all neighbors that are face+edge+vertex // connected to the current pixel. do not include the center pixel - unsigned int centerIndex = it->GetCenterNeighborhoodIndex(); + const unsigned int centerIndex = it->GetCenterNeighborhoodIndex(); for (unsigned int d = 0; d < centerIndex * 2 + 1; ++d) { - typename TIterator::OffsetType offset = it->GetOffset(d); + const typename TIterator::OffsetType offset = it->GetOffset(d); it->ActivateOffset(offset); } - typename TIterator::OffsetType offset_zeros{}; + const typename TIterator::OffsetType offset_zeros{}; it->DeactivateOffset(offset_zeros); } return it; @@ -64,7 +64,6 @@ TIterator * setConnectivityPrevious(TIterator * it, bool fullyConnected = false) { // activate the "previous" neighbours - it->ClearActiveList(); if (!fullyConnected) { @@ -82,13 +81,13 @@ setConnectivityPrevious(TIterator * it, bool fullyConnected = false) { // activate all neighbors that are face+edge+vertex // connected to the current pixel. do not include the center pixel - unsigned int centerIndex = it->GetCenterNeighborhoodIndex(); + const unsigned int centerIndex = it->GetCenterNeighborhoodIndex(); for (unsigned int d = 0; d < centerIndex; ++d) { - typename TIterator::OffsetType offset = it->GetOffset(d); + const typename TIterator::OffsetType offset = it->GetOffset(d); it->ActivateOffset(offset); } - typename TIterator::OffsetType offset_zeros{}; + const typename TIterator::OffsetType offset_zeros{}; it->DeactivateOffset(offset_zeros); } return it; @@ -117,13 +116,13 @@ setConnectivityLater(TIterator * it, bool fullyConnected = false) { // activate all neighbors that are face+edge+vertex // connected to the current pixel. do not include the center pixel - unsigned int centerIndex = it->GetCenterNeighborhoodIndex(); + const unsigned int centerIndex = it->GetCenterNeighborhoodIndex(); for (unsigned int d = centerIndex + 1; d < 2 * centerIndex + 1; ++d) { - typename TIterator::OffsetType offset = it->GetOffset(d); + const typename TIterator::OffsetType offset = it->GetOffset(d); it->ActivateOffset(offset); } - typename TIterator::OffsetType offset_zeros{}; + const typename TIterator::OffsetType offset_zeros{}; it->DeactivateOffset(offset_zeros); } return it; diff --git a/Modules/Core/Common/include/itkConstNeighborhoodIterator.hxx b/Modules/Core/Common/include/itkConstNeighborhoodIterator.hxx index 7a012b0fc56..d3326fb982f 100644 --- a/Modules/Core/Common/include/itkConstNeighborhoodIterator.hxx +++ b/Modules/Core/Common/include/itkConstNeighborhoodIterator.hxx @@ -166,7 +166,7 @@ ConstNeighborhoodIterator::GetPixel(NeighborIndexTyp { OffsetType offset; OffsetType internalIndex; - bool flag = this->IndexInBounds(n, internalIndex, offset); + const bool flag = this->IndexInBounds(n, internalIndex, offset); if (flag) { IsInBounds = true; diff --git a/Modules/Core/Common/include/itkConstantBoundaryCondition.hxx b/Modules/Core/Common/include/itkConstantBoundaryCondition.hxx index 1a7ab87a75a..fdbc90f4b5b 100644 --- a/Modules/Core/Common/include/itkConstantBoundaryCondition.hxx +++ b/Modules/Core/Common/include/itkConstantBoundaryCondition.hxx @@ -63,7 +63,7 @@ ConstantBoundaryCondition::GetInputRequestedRegion( const RegionType & outputRequestedRegion) const -> RegionType { RegionType inputRequestedRegion(inputLargestPossibleRegion); - bool cropped = inputRequestedRegion.Crop(outputRequestedRegion); + const bool cropped = inputRequestedRegion.Crop(outputRequestedRegion); if (!cropped) { @@ -79,7 +79,7 @@ auto ConstantBoundaryCondition::GetPixel(const IndexType & index, const TInputImage * image) const -> OutputPixelType { - RegionType imageRegion = image->GetLargestPossibleRegion(); + const RegionType imageRegion = image->GetLargestPossibleRegion(); if (imageRegion.IsInside(index)) { return static_cast(image->GetPixel(index)); diff --git a/Modules/Core/Common/include/itkDataObjectConstIterator.h b/Modules/Core/Common/include/itkDataObjectConstIterator.h index 8ee96619099..0988926a8b1 100644 --- a/Modules/Core/Common/include/itkDataObjectConstIterator.h +++ b/Modules/Core/Common/include/itkDataObjectConstIterator.h @@ -68,7 +68,7 @@ class DataObjectConstIterator DataObjectConstIterator operator++(int) { - DataObjectConstIterator tmp = *this; + const DataObjectConstIterator tmp = *this; ++(*this); return tmp; } diff --git a/Modules/Core/Common/include/itkDataObjectIterator.h b/Modules/Core/Common/include/itkDataObjectIterator.h index e93d6225ed8..e70203cc73d 100644 --- a/Modules/Core/Common/include/itkDataObjectIterator.h +++ b/Modules/Core/Common/include/itkDataObjectIterator.h @@ -68,7 +68,7 @@ class DataObjectIterator DataObjectIterator operator++(int) { - DataObjectIterator tmp = *this; + const DataObjectIterator tmp = *this; ++(*this); return tmp; } diff --git a/Modules/Core/Common/include/itkDomainThreader.hxx b/Modules/Core/Common/include/itkDomainThreader.hxx index 7b68c4f1d8d..cfd3e01fe50 100644 --- a/Modules/Core/Common/include/itkDomainThreader.hxx +++ b/Modules/Core/Common/include/itkDomainThreader.hxx @@ -71,7 +71,7 @@ template void DomainThreader::DetermineNumberOfWorkUnitsUsed() { - ThreadIdType numberOfWorkUnits = this->GetNumberOfWorkUnits(); + const ThreadIdType numberOfWorkUnits = this->GetNumberOfWorkUnits(); // Attempt a single dummy partition, just to get the number of subdomains actually created DomainType subdomain; diff --git a/Modules/Core/Common/include/itkExtractImageFilter.hxx b/Modules/Core/Common/include/itkExtractImageFilter.hxx index 110c4fa0677..6e7cd5c472b 100644 --- a/Modules/Core/Common/include/itkExtractImageFilter.hxx +++ b/Modules/Core/Common/include/itkExtractImageFilter.hxx @@ -49,7 +49,7 @@ ExtractImageFilter::CallCopyOutputRegionToInputRegion InputImageRegionType & destRegion, const OutputImageRegionType & srcRegion) { - ExtractImageFilterRegionCopierType extractImageRegionCopier; + const ExtractImageFilterRegionCopierType extractImageRegionCopier; extractImageRegionCopier(destRegion, srcRegion, m_ExtractionRegion); } @@ -105,8 +105,8 @@ ExtractImageFilter::GenerateOutputInformation() // this filter allows the input and the output to be of different dimensions // get pointers to the input and output - typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); - typename Superclass::InputImageConstPointer inputPtr = this->GetInput(); + const typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); + const typename Superclass::InputImageConstPointer inputPtr = this->GetInput(); if (!outputPtr || !inputPtr) { diff --git a/Modules/Core/Common/include/itkFloodFilledFunctionConditionalConstIterator.hxx b/Modules/Core/Common/include/itkFloodFilledFunctionConditionalConstIterator.hxx index dabf262c0c5..d64a316af3b 100644 --- a/Modules/Core/Common/include/itkFloodFilledFunctionConditionalConstIterator.hxx +++ b/Modules/Core/Common/include/itkFloodFilledFunctionConditionalConstIterator.hxx @@ -80,7 +80,7 @@ FloodFilledFunctionConditionalConstIterator::InitializeIterat // Build a temporary image of chars for use in the flood algorithm m_TemporaryPointer = TTempImage::New(); - typename TTempImage::RegionType tempRegion = this->m_Image->GetBufferedRegion(); + const typename TTempImage::RegionType tempRegion = this->m_Image->GetBufferedRegion(); m_TemporaryPointer->SetRegions(tempRegion); m_TemporaryPointer->AllocateInitialized(); diff --git a/Modules/Core/Common/include/itkFloodFilledSpatialFunctionConditionalConstIterator.hxx b/Modules/Core/Common/include/itkFloodFilledSpatialFunctionConditionalConstIterator.hxx index a6e0abbfdb2..f92b4b9a143 100644 --- a/Modules/Core/Common/include/itkFloodFilledSpatialFunctionConditionalConstIterator.hxx +++ b/Modules/Core/Common/include/itkFloodFilledSpatialFunctionConditionalConstIterator.hxx @@ -109,10 +109,10 @@ FloodFilledSpatialFunctionConditionalConstIterator::IsPixelIn // means of determining index inclusion. // To reiterate... DO NOT use this on images higher than 16D - unsigned int counter; - unsigned int counterCopy; - unsigned int dim = TImage::ImageDimension; - auto numReps = static_cast(std::pow(2.0, static_cast(dim))); + unsigned int counter; + unsigned int counterCopy; + const unsigned int dim = TImage::ImageDimension; + auto numReps = static_cast(std::pow(2.0, static_cast(dim))); IndexType tempIndex; @@ -154,11 +154,11 @@ FloodFilledSpatialFunctionConditionalConstIterator::IsPixelIn // generated indices are true // To reiterate... DO NOT use this on images higher than 16D - unsigned int counter; - unsigned int counterCopy; - unsigned int dim = TImage::ImageDimension; - auto numReps = static_cast(std::pow(2.0, static_cast(dim))); - IndexType tempIndex; + unsigned int counter; + unsigned int counterCopy; + const unsigned int dim = TImage::ImageDimension; + auto numReps = static_cast(std::pow(2.0, static_cast(dim))); + IndexType tempIndex; // First we loop over the binary counter for (counter = 0; counter < numReps; ++counter) diff --git a/Modules/Core/Common/include/itkGaussianDerivativeOperator.hxx b/Modules/Core/Common/include/itkGaussianDerivativeOperator.hxx index 0f6f3a0bcb3..4e9710bdf53 100644 --- a/Modules/Core/Common/include/itkGaussianDerivativeOperator.hxx +++ b/Modules/Core/Common/include/itkGaussianDerivativeOperator.hxx @@ -64,7 +64,7 @@ GaussianDerivativeOperator::GenerateCoefficients // operator, then the output kernel needs to be padded by N-1. For // these values to be computed the input kernel needs to be padded // by 2N-1 on both sides. - unsigned int N = (derivOp.Size() - 1) / 2; + const unsigned int N = (derivOp.Size() - 1) / 2; // copy the gaussian operator adding clamped boundary condition CoefficientVector paddedCoeff(coeff.size() + 4 * N - 2); @@ -88,7 +88,7 @@ GaussianDerivativeOperator::GenerateCoefficients // current index in derivative op for (unsigned int j = 0; j < derivOp.Size(); ++j) { - unsigned int k = i + j - derivOp.Size() / 2; + const unsigned int k = i + j - derivOp.Size() / 2; conv += paddedCoeff[k] * derivOp[derivOp.Size() - 1 - j]; } @@ -155,7 +155,7 @@ GaussianDerivativeOperator::GenerateGaussianCoef } // Make symmetric - size_t s = coeff.size() - 1; + const size_t s = coeff.size() - 1; coeff.insert(coeff.begin(), s, 0); std::copy_n(coeff.rbegin(), s, coeff.begin()); @@ -168,7 +168,7 @@ GaussianDerivativeOperator::ModifiedBesselI0(dou { double accumulator; - double d = itk::Math::abs(y); + const double d = itk::Math::abs(y); if (d < 3.75) { double m = y / 3.75; @@ -178,7 +178,7 @@ GaussianDerivativeOperator::ModifiedBesselI0(dou } else { - double m = 3.75 / d; + const double m = 3.75 / d; accumulator = (std::exp(d) / std::sqrt(d)) * (0.39894228 + @@ -195,8 +195,8 @@ template double GaussianDerivativeOperator::ModifiedBesselI1(double y) { - double accumulator; - double d = itk::Math::abs(y); + double accumulator; + const double d = itk::Math::abs(y); if (d < 3.75) { double m = y / 3.75; @@ -207,7 +207,7 @@ GaussianDerivativeOperator::ModifiedBesselI1(dou } else { - double m = 3.75 / d; + const double m = 3.75 / d; accumulator = 0.2282967e-1 + m * (-0.2895312e-1 + m * (0.1787654e-1 - m * 0.420059e-2)); accumulator = 0.39894228 + m * (-0.3988024e-1 + m * (-0.362018e-2 + m * (0.163801e-2 + m * (-0.1031555e-1 + m * accumulator)))); @@ -244,12 +244,12 @@ GaussianDerivativeOperator::ModifiedBesselI(int } else { - double toy = 2.0 / itk::Math::abs(y); - double qip = accumulator = 0.0; - double qi = 1.0; + const double toy = 2.0 / itk::Math::abs(y); + double qip = accumulator = 0.0; + double qi = 1.0; for (int j = 2 * (n + static_cast(DIGITS * std::sqrt(static_cast(n)))); j > 0; j--) { - double qim = qip + j * toy * qi; + const double qim = qip + j * toy * qi; qip = qi; qi = qim; if (itk::Math::abs(qi) > 1.0e10) diff --git a/Modules/Core/Common/include/itkGaussianDerivativeSpatialFunction.hxx b/Modules/Core/Common/include/itkGaussianDerivativeSpatialFunction.hxx index 08d23b47299..c1288db779f 100644 --- a/Modules/Core/Common/include/itkGaussianDerivativeSpatialFunction.hxx +++ b/Modules/Core/Common/include/itkGaussianDerivativeSpatialFunction.hxx @@ -57,7 +57,7 @@ GaussianDerivativeSpatialFunction::Evaluate(co (2 * m_Sigma[m_Direction] * m_Sigma[m_Direction]); } - double value = + const double value = -2 * (position[m_Direction] - m_Mean[m_Direction]) * m_Scale * (1 / prefixDenom) * std::exp(-1 * suffixExp); return static_cast(value); diff --git a/Modules/Core/Common/include/itkGaussianOperator.hxx b/Modules/Core/Common/include/itkGaussianOperator.hxx index 51c57c5f60c..5e4d05ff4ee 100644 --- a/Modules/Core/Common/include/itkGaussianOperator.hxx +++ b/Modules/Core/Common/include/itkGaussianOperator.hxx @@ -59,7 +59,7 @@ GaussianOperator::GenerateCoefficients() -> Coef } // Make symmetric - int j = static_cast(coeff.size()) - 1; + const int j = static_cast(coeff.size()) - 1; coeff.insert(coeff.begin(), j, 0); { int i = 0; @@ -154,14 +154,14 @@ GaussianOperator::ModifiedBesselI(int n, double } else { - double toy = 2.0 / itk::Math::abs(y); - double qip = 0.0; - double accumulator = 0.0; - double qi = 1.0; + const double toy = 2.0 / itk::Math::abs(y); + double qip = 0.0; + double accumulator = 0.0; + double qi = 1.0; for (int j = 2 * (n + static_cast(std::sqrt(ACCURACY * n))); j > 0; j--) { - double qim = qip + j * toy * qi; + const double qim = qip + j * toy * qi; qip = qi; qi = qim; if (itk::Math::abs(qi) > 1.0e10) diff --git a/Modules/Core/Common/include/itkHexahedronCell.hxx b/Modules/Core/Common/include/itkHexahedronCell.hxx index 185369c218f..093fc1f96f5 100644 --- a/Modules/Core/Common/include/itkHexahedronCell.hxx +++ b/Modules/Core/Common/include/itkHexahedronCell.hxx @@ -398,7 +398,7 @@ HexahedronCell::EvaluatePosition(CoordinateType * x, } // ONLY 3x3 determinants are supported. - double d = vnl_determinant(mat); + const double d = vnl_determinant(mat); // d=vtkMath::Determinant3x3(rcol,scol,tcol); if (itk::Math::abs(d) < 1.e-20) { diff --git a/Modules/Core/Common/include/itkImage.h b/Modules/Core/Common/include/itkImage.h index e756a207c37..d03b40f8275 100644 --- a/Modules/Core/Common/include/itkImage.h +++ b/Modules/Core/Common/include/itkImage.h @@ -207,7 +207,7 @@ class ITK_TEMPLATE_EXPORT Image : public ImageBase void SetPixel(const IndexType & index, const TPixel & value) { - OffsetValueType offset = this->FastComputeOffset(index); + const OffsetValueType offset = this->FastComputeOffset(index); (*m_Buffer)[offset] = value; } @@ -218,7 +218,7 @@ class ITK_TEMPLATE_EXPORT Image : public ImageBase const TPixel & GetPixel(const IndexType & index) const { - OffsetValueType offset = this->FastComputeOffset(index); + const OffsetValueType offset = this->FastComputeOffset(index); return ((*m_Buffer)[offset]); } @@ -229,7 +229,7 @@ class ITK_TEMPLATE_EXPORT Image : public ImageBase TPixel & GetPixel(const IndexType & index) { - OffsetValueType offset = this->FastComputeOffset(index); + const OffsetValueType offset = this->FastComputeOffset(index); return ((*m_Buffer)[offset]); } diff --git a/Modules/Core/Common/include/itkImageConstIteratorWithIndex.hxx b/Modules/Core/Common/include/itkImageConstIteratorWithIndex.hxx index 4a0f381d81e..96835d60db7 100644 --- a/Modules/Core/Common/include/itkImageConstIteratorWithIndex.hxx +++ b/Modules/Core/Common/include/itkImageConstIteratorWithIndex.hxx @@ -70,7 +70,7 @@ ImageConstIteratorWithIndex::ImageConstIteratorWithIndex(const TImage * std::copy_n(m_Image->GetOffsetTable(), ImageDimension + 1, m_OffsetTable); // Compute the start position - OffsetValueType offs = m_Image->ComputeOffset(m_BeginIndex); + const OffsetValueType offs = m_Image->ComputeOffset(m_BeginIndex); m_Begin = buffer + offs; m_Position = m_Begin; @@ -79,7 +79,7 @@ ImageConstIteratorWithIndex::ImageConstIteratorWithIndex(const TImage * IndexType pastEnd; for (unsigned int i = 0; i < ImageDimension; ++i) { - SizeValueType size = region.GetSize()[i]; + const SizeValueType size = region.GetSize()[i]; if (size > 0) { m_Remaining = true; diff --git a/Modules/Core/Common/include/itkImageConstIteratorWithOnlyIndex.hxx b/Modules/Core/Common/include/itkImageConstIteratorWithOnlyIndex.hxx index 840be943bfa..e3399bf881e 100644 --- a/Modules/Core/Common/include/itkImageConstIteratorWithOnlyIndex.hxx +++ b/Modules/Core/Common/include/itkImageConstIteratorWithOnlyIndex.hxx @@ -39,7 +39,7 @@ ImageConstIteratorWithOnlyIndex::ImageConstIteratorWithOnlyIndex(const T m_Remaining = false; for (unsigned int i = 0; i < ImageDimension; ++i) { - SizeValueType size = region.GetSize()[i]; + const SizeValueType size = region.GetSize()[i]; if (size > 0) { m_Remaining = true; diff --git a/Modules/Core/Common/include/itkImageDuplicator.hxx b/Modules/Core/Common/include/itkImageDuplicator.hxx index d342a82ca65..a4a031cb9ef 100644 --- a/Modules/Core/Common/include/itkImageDuplicator.hxx +++ b/Modules/Core/Common/include/itkImageDuplicator.hxx @@ -51,7 +51,7 @@ ImageDuplicator::Update() m_DuplicateImage->SetRequestedRegion(m_InputImage->GetRequestedRegion()); m_DuplicateImage->SetBufferedRegion(m_InputImage->GetBufferedRegion()); m_DuplicateImage->Allocate(); - typename ImageType::RegionType region = m_InputImage->GetBufferedRegion(); + const typename ImageType::RegionType region = m_InputImage->GetBufferedRegion(); ImageAlgorithm::Copy(m_InputImage.GetPointer(), m_DuplicateImage.GetPointer(), region, region); } diff --git a/Modules/Core/Common/include/itkImageLinearConstIteratorWithIndex.hxx b/Modules/Core/Common/include/itkImageLinearConstIteratorWithIndex.hxx index 663c7eced1c..0a3a95f5a8c 100644 --- a/Modules/Core/Common/include/itkImageLinearConstIteratorWithIndex.hxx +++ b/Modules/Core/Common/include/itkImageLinearConstIteratorWithIndex.hxx @@ -39,7 +39,7 @@ template void ImageLinearConstIteratorWithIndex::GoToReverseBeginOfLine() { - OffsetValueType distanceToEnd = this->m_EndIndex[m_Direction] - this->m_PositionIndex[m_Direction] - 1; + const OffsetValueType distanceToEnd = this->m_EndIndex[m_Direction] - this->m_PositionIndex[m_Direction] - 1; this->m_Position += m_Jump * distanceToEnd; this->m_PositionIndex[m_Direction] = this->m_EndIndex[m_Direction] - 1; @@ -52,7 +52,7 @@ template void ImageLinearConstIteratorWithIndex::GoToBeginOfLine() { - OffsetValueType distanceToBegin = this->m_PositionIndex[m_Direction] - this->m_BeginIndex[m_Direction]; + const OffsetValueType distanceToBegin = this->m_PositionIndex[m_Direction] - this->m_BeginIndex[m_Direction]; this->m_Position -= m_Jump * distanceToBegin; @@ -66,7 +66,7 @@ template void ImageLinearConstIteratorWithIndex::GoToEndOfLine() { - OffsetValueType distanceToEnd = this->m_EndIndex[m_Direction] - this->m_PositionIndex[m_Direction]; + const OffsetValueType distanceToEnd = this->m_EndIndex[m_Direction] - this->m_PositionIndex[m_Direction]; this->m_Position += m_Jump * distanceToEnd; diff --git a/Modules/Core/Common/include/itkImageReverseConstIterator.h b/Modules/Core/Common/include/itkImageReverseConstIterator.h index 18fb279b813..386e0a66292 100644 --- a/Modules/Core/Common/include/itkImageReverseConstIterator.h +++ b/Modules/Core/Common/include/itkImageReverseConstIterator.h @@ -208,7 +208,7 @@ class ITK_TEMPLATE_EXPORT ImageReverseConstIterator m_Region = it.GetRegion(); m_Buffer = m_Image->GetBufferPointer(); - IndexType ind = it.GetIndex(); + const IndexType ind = it.GetIndex(); m_Offset = m_Image->ComputeOffset(ind); diff --git a/Modules/Core/Common/include/itkImageSink.hxx b/Modules/Core/Common/include/itkImageSink.hxx index db3a90ac1f8..0e062454195 100644 --- a/Modules/Core/Common/include/itkImageSink.hxx +++ b/Modules/Core/Common/include/itkImageSink.hxx @@ -116,8 +116,8 @@ template unsigned int ImageSink::GetNumberOfInputRequestedRegions() { - const InputImageType * inputPtr = const_cast(this->GetInput()); - InputImageRegionType inputImageRegion = inputPtr->GetLargestPossibleRegion(); + const InputImageType * inputPtr = const_cast(this->GetInput()); + const InputImageRegionType inputImageRegion = inputPtr->GetLargestPossibleRegion(); return this->GetRegionSplitter()->GetNumberOfSplits(inputImageRegion, this->m_NumberOfStreamDivisions); } diff --git a/Modules/Core/Common/include/itkImageSource.hxx b/Modules/Core/Common/include/itkImageSource.hxx index 6142c980a8c..e0adfa55f8a 100644 --- a/Modules/Core/Common/include/itkImageSource.hxx +++ b/Modules/Core/Common/include/itkImageSource.hxx @@ -41,7 +41,7 @@ ImageSource::ImageSource() { // Create the output. We use static_cast<> here because we know the default // output must be of type TOutputImage - typename TOutputImage::Pointer output = static_cast(this->MakeOutput(0).GetPointer()); + const typename TOutputImage::Pointer output = static_cast(this->MakeOutput(0).GetPointer()); this->ProcessObject::SetNumberOfRequiredOutputs(1); this->ProcessObject::SetNthOutput(0, output.GetPointer()); @@ -269,15 +269,15 @@ ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION ImageSource::ThreaderCallback(void * arg) { using WorkUnitInfo = MultiThreaderBase::WorkUnitInfo; - auto * workUnitInfo = static_cast(arg); - ThreadIdType workUnitID = workUnitInfo->WorkUnitID; - ThreadIdType workUnitCount = workUnitInfo->NumberOfWorkUnits; - auto * str = (ThreadStruct *)(workUnitInfo->UserData); + auto * workUnitInfo = static_cast(arg); + const ThreadIdType workUnitID = workUnitInfo->WorkUnitID; + const ThreadIdType workUnitCount = workUnitInfo->NumberOfWorkUnits; + auto * str = (ThreadStruct *)(workUnitInfo->UserData); // execute the actual method with appropriate output region // first find out how many pieces extent can be split into. typename TOutputImage::RegionType splitRegion; - ThreadIdType total = str->Filter->SplitRequestedRegion(workUnitID, workUnitCount, splitRegion); + const ThreadIdType total = str->Filter->SplitRequestedRegion(workUnitID, workUnitCount, splitRegion); if (workUnitID < total) { diff --git a/Modules/Core/Common/include/itkImageToImageFilter.hxx b/Modules/Core/Common/include/itkImageToImageFilter.hxx index 477f7ed1fc7..e6c6d6aeb4c 100644 --- a/Modules/Core/Common/include/itkImageToImageFilter.hxx +++ b/Modules/Core/Common/include/itkImageToImageFilter.hxx @@ -116,7 +116,7 @@ ImageToImageFilter::CallCopyOutputRegionToInputRegion InputImageRegionType & destRegion, const OutputImageRegionType & srcRegion) { - OutputToInputRegionCopierType regionCopier; + const OutputToInputRegionCopierType regionCopier; regionCopier(destRegion, srcRegion); } @@ -127,7 +127,7 @@ void ImageToImageFilter::CallCopyInputRegionToOutputRegion(OutputImageRegionType & destRegion, const InputImageRegionType & srcRegion) { - InputToOutputRegionCopierType regionCopier; + const InputToOutputRegionCopierType regionCopier; regionCopier(destRegion, srcRegion); } diff --git a/Modules/Core/Common/include/itkImageVectorOptimizerParametersHelper.hxx b/Modules/Core/Common/include/itkImageVectorOptimizerParametersHelper.hxx index 8fa6baa20e7..c9a55dd206e 100644 --- a/Modules/Core/Common/include/itkImageVectorOptimizerParametersHelper.hxx +++ b/Modules/Core/Common/include/itkImageVectorOptimizerParametersHelper.hxx @@ -39,7 +39,7 @@ ImageVectorOptimizerParametersHelper: using vectorElement = typename ParameterImageType::PixelContainer::Element; auto * vectorPointer = reinterpret_cast(pointer); // We're expecting the new memory buffer t be of same size. - unsigned int sizeInVectors = m_ParameterImage->GetPixelContainer()->Size(); + const unsigned int sizeInVectors = m_ParameterImage->GetPixelContainer()->Size(); // After this call, PixelContainer will *not* manage its memory. this->m_ParameterImage->GetPixelContainer()->SetImportPointer(vectorPointer, sizeInVectors); Superclass::MoveDataPointer(container, pointer); @@ -70,7 +70,7 @@ ImageVectorOptimizerParametersHelper: // The PixelContainer for Image points to type Vector, so we have // to determine the number of raw elements of type TValue in the buffer // and cast a pointer to it for assignment to the Array data pointer. - typename CommonContainerType::SizeValueType sz = image->GetPixelContainer()->Size() * VVectorDimension; + const typename CommonContainerType::SizeValueType sz = image->GetPixelContainer()->Size() * VVectorDimension; auto * valuePointer = reinterpret_cast(image->GetPixelContainer()->GetBufferPointer()); // Set the Array's pointer to the image data buffer. By default it will // not manage the memory. diff --git a/Modules/Core/Common/include/itkImportImageFilter.hxx b/Modules/Core/Common/include/itkImportImageFilter.hxx index 7c3fdf35ced..8380bf14620 100644 --- a/Modules/Core/Common/include/itkImportImageFilter.hxx +++ b/Modules/Core/Common/include/itkImportImageFilter.hxx @@ -92,7 +92,7 @@ ImportImageFilter::EnlargeOutputRequestedRegion(DataObj Superclass::EnlargeOutputRequestedRegion(output); // get pointer to the output - OutputImagePointer outputPtr = this->GetOutput(); + const OutputImagePointer outputPtr = this->GetOutput(); // set the requested region to the largest possible region (in this case // the amount of data that we have) @@ -110,7 +110,7 @@ ImportImageFilter::GenerateOutputInformation() Superclass::GenerateOutputInformation(); // get pointer to the output - OutputImagePointer outputPtr = this->GetOutput(); + const OutputImagePointer outputPtr = this->GetOutput(); // we need to compute the output spacing, the output origin, the // output image size, and the output image start index @@ -132,7 +132,7 @@ ImportImageFilter::GenerateData() // Therefore, this filter does not call outputPtr->Allocate(). // get pointer to the output - OutputImagePointer outputPtr = this->GetOutput(); + const OutputImagePointer outputPtr = this->GetOutput(); // the output buffer size is set to the size specified by the user via the // SetRegion() method. diff --git a/Modules/Core/Common/include/itkInPlaceImageFilter.hxx b/Modules/Core/Common/include/itkInPlaceImageFilter.hxx index 4c3cf6881dd..b49ce73c2f1 100644 --- a/Modules/Core/Common/include/itkInPlaceImageFilter.hxx +++ b/Modules/Core/Common/include/itkInPlaceImageFilter.hxx @@ -98,7 +98,8 @@ InPlaceImageFilter::InternalAllocateOutputs() // 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). - typename ImageBaseType::Pointer nthOutputPtr = dynamic_cast(this->ProcessObject::GetOutput(i)); + const typename ImageBaseType::Pointer nthOutputPtr = + dynamic_cast(this->ProcessObject::GetOutput(i)); if (nthOutputPtr) { diff --git a/Modules/Core/Common/include/itkLaplacianOperator.hxx b/Modules/Core/Common/include/itkLaplacianOperator.hxx index 544878e0c02..fee8be394cf 100644 --- a/Modules/Core/Common/include/itkLaplacianOperator.hxx +++ b/Modules/Core/Common/include/itkLaplacianOperator.hxx @@ -35,7 +35,7 @@ template void LaplacianOperator::CreateOperator() { - CoefficientVector coefficients = this->GenerateCoefficients(); + const CoefficientVector coefficients = this->GenerateCoefficients(); this->Fill(coefficients); } @@ -70,14 +70,14 @@ LaplacianOperator::GenerateCoefficients() -> Coe this->SetRadius(r); // Create a vector of the correct size to hold the coefficients. - unsigned int w = this->Size(); - CoefficientVector coeffP(w); + const unsigned int w = this->Size(); + CoefficientVector coeffP(w); // Set the coefficients double sum = 0.0; for (unsigned int i = 0; i < 2 * VDimension; i += 2) { - OffsetValueType stride = this->GetStride(i / 2); + const OffsetValueType stride = this->GetStride(i / 2); const double hsq = m_DerivativeScalings[i / 2] * m_DerivativeScalings[i / 2]; coeffP[w / 2 - stride] = coeffP[w / 2 + stride] = hsq; diff --git a/Modules/Core/Common/include/itkLineConstIterator.hxx b/Modules/Core/Common/include/itkLineConstIterator.hxx index fbb72d89749..29e878d8660 100644 --- a/Modules/Core/Common/include/itkLineConstIterator.hxx +++ b/Modules/Core/Common/include/itkLineConstIterator.hxx @@ -42,7 +42,7 @@ LineConstIterator::LineConstIterator(const ImageType * imagePtr, unsigned int maxDistanceDimension = 0; for (unsigned int i = 0; i < TImage::ImageDimension; ++i) { - IndexValueType distance = itk::Math::abs(difference[i]); + const IndexValueType distance = itk::Math::abs(difference[i]); if (distance > maxDistance) { maxDistance = distance; diff --git a/Modules/Core/Common/include/itkLoggerThreadWrapper.hxx b/Modules/Core/Common/include/itkLoggerThreadWrapper.hxx index b5e0958064f..c534de7ec96 100644 --- a/Modules/Core/Common/include/itkLoggerThreadWrapper.hxx +++ b/Modules/Core/Common/include/itkLoggerThreadWrapper.hxx @@ -43,7 +43,7 @@ typename SimpleLoggerType::PriorityLevelEnum LoggerThreadWrapper::GetPriorityLevel() const { const std::lock_guard lockGuard(m_Mutex); - PriorityLevelEnum level = this->m_PriorityLevel; + const PriorityLevelEnum level = this->m_PriorityLevel; return level; } @@ -62,7 +62,7 @@ typename SimpleLoggerType::PriorityLevelEnum LoggerThreadWrapper::GetLevelForFlushing() const { const std::lock_guard lockGuard(m_Mutex); - PriorityLevelEnum level = this->m_LevelForFlushing; + const PriorityLevelEnum level = this->m_LevelForFlushing; return level; } @@ -79,7 +79,7 @@ auto LoggerThreadWrapper::GetDelay() const -> DelayType { const std::lock_guard lockGuard(m_Mutex); - DelayType delay = this->m_Delay; + const DelayType delay = this->m_Delay; return delay; } diff --git a/Modules/Core/Common/include/itkMath.h b/Modules/Core/Common/include/itkMath.h index ebeb0c1a404..a4b837206d7 100644 --- a/Modules/Core/Common/include/itkMath.h +++ b/Modules/Core/Common/include/itkMath.h @@ -253,8 +253,8 @@ template inline typename Detail::FloatIEEE::IntType FloatDifferenceULP(T x1, T x2) { - Detail::FloatIEEE x1f(x1); - Detail::FloatIEEE x2f(x2); + const Detail::FloatIEEE x1f(x1); + const Detail::FloatIEEE x2f(x2); return x1f.AsULP() - x2f.AsULP(); } @@ -269,8 +269,8 @@ template inline T FloatAddULP(T x, typename Detail::FloatIEEE::IntType ulps) { - Detail::FloatIEEE representInput(x); - Detail::FloatIEEE representOutput(representInput.asInt + ulps); + const Detail::FloatIEEE representInput(x); + const Detail::FloatIEEE representOutput(representInput.asInt + ulps); return representOutput.asFloat; } @@ -329,7 +329,7 @@ FloatAlmostEqual(T x1, return false; } - typename Detail::FloatIEEE::IntType ulps = std::abs(FloatDifferenceULP(x1, x2)); + const typename Detail::FloatIEEE::IntType ulps = std::abs(FloatDifferenceULP(x1, x2)); return ulps <= maxUlps; } diff --git a/Modules/Core/Common/include/itkMatrix.h b/Modules/Core/Common/include/itkMatrix.h index 59203d1f4a5..8fbadb34c59 100644 --- a/Modules/Core/Common/include/itkMatrix.h +++ b/Modules/Core/Common/include/itkMatrix.h @@ -315,7 +315,7 @@ class ITK_TEMPLATE_EXPORT Matrix { itkGenericExceptionMacro("Singular matrix. Determinant is 0."); } - vnl_matrix_inverse inverse(m_Matrix.as_ref()); + const vnl_matrix_inverse inverse(m_Matrix.as_ref()); return vnl_matrix_fixed{ inverse.as_matrix() }; } diff --git a/Modules/Core/Common/include/itkMersenneTwisterRandomVariateGenerator.h b/Modules/Core/Common/include/itkMersenneTwisterRandomVariateGenerator.h index e907090bb06..dccb891be87 100644 --- a/Modules/Core/Common/include/itkMersenneTwisterRandomVariateGenerator.h +++ b/Modules/Core/Common/include/itkMersenneTwisterRandomVariateGenerator.h @@ -499,8 +499,8 @@ MersenneTwisterRandomVariateGenerator::GetIntegerVariate(const IntegerType & n) inline double MersenneTwisterRandomVariateGenerator::Get53BitVariate() { - IntegerType a = GetIntegerVariate() >> 5; - IntegerType b = GetIntegerVariate() >> 6; + const IntegerType a = GetIntegerVariate() >> 5; + const IntegerType b = GetIntegerVariate() >> 6; return (a * 67108864.0 + b) * (1.0 / 9007199254740992.0); // by Isaku // Wada @@ -513,8 +513,8 @@ MersenneTwisterRandomVariateGenerator::GetNormalVariate(const double mean, const { // Return a real number from a normal (Gaussian) distribution with given // mean and variance by Box-Muller method - double r = std::sqrt(-2.0 * std::log(1.0 - GetVariateWithOpenRange()) * variance); - double phi = 2.0 * itk::Math::pi * GetVariateWithOpenUpperRange(); + const double r = std::sqrt(-2.0 * std::log(1.0 - GetVariateWithOpenRange()) * variance); + const double phi = 2.0 * itk::Math::pi * GetVariateWithOpenUpperRange(); return mean + r * std::cos(phi); } @@ -524,7 +524,7 @@ MersenneTwisterRandomVariateGenerator::GetNormalVariate(const double mean, const inline double MersenneTwisterRandomVariateGenerator::GetUniformVariate(const double a, const double b) { - double u = GetVariateWithOpenUpperRange(); + const double u = GetVariateWithOpenUpperRange(); return ((1.0 - u) * a + u * b); } diff --git a/Modules/Core/Common/include/itkMultiThreaderBase.h b/Modules/Core/Common/include/itkMultiThreaderBase.h index 8b0467bb3ac..4af5bf37ceb 100644 --- a/Modules/Core/Common/include/itkMultiThreaderBase.h +++ b/Modules/Core/Common/include/itkMultiThreaderBase.h @@ -371,7 +371,7 @@ ITK_GCC_PRAGMA_DIAG_POP() if constexpr (VDimension <= 1) // Cannot split, no parallelization { - ProgressReporter progress(filter, 0, requestedRegion.GetNumberOfPixels()); + const ProgressReporter progress(filter, 0, requestedRegion.GetNumberOfPixels()); funcP(requestedRegion); } else // Can split, parallelize! diff --git a/Modules/Core/Common/include/itkNeighborhoodIterator.hxx b/Modules/Core/Common/include/itkNeighborhoodIterator.hxx index 66e51bcf828..7aac6053311 100644 --- a/Modules/Core/Common/include/itkNeighborhoodIterator.hxx +++ b/Modules/Core/Common/include/itkNeighborhoodIterator.hxx @@ -124,8 +124,8 @@ NeighborhoodIterator::SetPixel(const unsigned int n, { if (!this->m_InBounds[i]) // Part of dimension spills out of bounds { - typename OffsetType::OffsetValueType OverlapLow = this->m_InnerBoundsLow[i] - this->m_Loop[i]; - typename OffsetType::OffsetValueType OverlapHigh = + const typename OffsetType::OffsetValueType OverlapLow = this->m_InnerBoundsLow[i] - this->m_Loop[i]; + const typename OffsetType::OffsetValueType OverlapHigh = static_cast(this->GetSize(i) - ((this->m_Loop[i] + 2) - this->m_InnerBoundsHigh[i])); if (temp[i] < OverlapLow || OverlapHigh < temp[i]) { diff --git a/Modules/Core/Common/include/itkObjectFactory.h b/Modules/Core/Common/include/itkObjectFactory.h index 4cc86e928eb..12241cb1bee 100644 --- a/Modules/Core/Common/include/itkObjectFactory.h +++ b/Modules/Core/Common/include/itkObjectFactory.h @@ -58,7 +58,7 @@ class ObjectFactory : public ObjectFactoryBase static typename T::Pointer Create() { - LightObject::Pointer ret = CreateInstance(typeid(T).name()); + const LightObject::Pointer ret = CreateInstance(typeid(T).name()); return dynamic_cast(ret.GetPointer()); } diff --git a/Modules/Core/Common/include/itkObjectStore.hxx b/Modules/Core/Common/include/itkObjectStore.hxx index 74e098f5a07..23481ca8bf2 100644 --- a/Modules/Core/Common/include/itkObjectStore.hxx +++ b/Modules/Core/Common/include/itkObjectStore.hxx @@ -42,7 +42,7 @@ ObjectStore::Reserve(SizeValueType n) // Need to grow. Allocate a new block of memory and copy that block's // pointers into the m_FreeList. Updates m_Size appropriately. - MemoryBlock new_block(n - m_Size); + const MemoryBlock new_block(n - m_Size); m_Store.push_back(new_block); m_FreeList.reserve(n); diff --git a/Modules/Core/Common/include/itkOctree.hxx b/Modules/Core/Common/include/itkOctree.hxx index cf2c3c201f4..3e9d5fc03f3 100644 --- a/Modules/Core/Common/include/itkOctree.hxx +++ b/Modules/Core/Common/include/itkOctree.hxx @@ -227,9 +227,9 @@ Octree::BuildFromBuffer(const void const unsigned int ysize, const unsigned int zsize) { - unsigned int maxSize = xsize >= ysize ? (xsize >= zsize ? xsize : zsize) : (ysize >= zsize ? ysize : zsize); - unsigned int width = 1; - unsigned int depth = 0; + const unsigned int maxSize = xsize >= ysize ? (xsize >= zsize ? xsize : zsize) : (ysize >= zsize ? ysize : zsize); + unsigned int width = 1; + unsigned int depth = 0; while (width < maxSize) { diff --git a/Modules/Core/Common/include/itkOffset.h b/Modules/Core/Common/include/itkOffset.h index 76edab28cd2..d09a8157cad 100644 --- a/Modules/Core/Common/include/itkOffset.h +++ b/Modules/Core/Common/include/itkOffset.h @@ -465,7 +465,7 @@ std::ostream & operator<<(std::ostream & os, const Offset & ind) { os << '['; - unsigned int dimlim = VDimension - 1; + const unsigned int dimlim = VDimension - 1; for (unsigned int i = 0; i < dimlim; ++i) { os << ind[i] << ", "; diff --git a/Modules/Core/Common/include/itkPeriodicBoundaryCondition.hxx b/Modules/Core/Common/include/itkPeriodicBoundaryCondition.hxx index caba00b5658..67370d287c9 100644 --- a/Modules/Core/Common/include/itkPeriodicBoundaryCondition.hxx +++ b/Modules/Core/Common/include/itkPeriodicBoundaryCondition.hxx @@ -155,9 +155,9 @@ PeriodicBoundaryCondition::GetInputRequestedRegion( { lowIndex += static_cast(imageSize[i]); } - IndexValueType highIndex = lowIndex + static_cast(outputSize[i]); + const IndexValueType highIndex = lowIndex + static_cast(outputSize[i]); - bool overlap = (highIndex >= static_cast(imageSize[i])); + const bool overlap = (highIndex >= static_cast(imageSize[i])); if (overlap) { @@ -172,7 +172,7 @@ PeriodicBoundaryCondition::GetInputRequestedRegion( inputRequestedSize[i] = outputSize[i]; } } - RegionType inputRequestedRegion(inputRequestedIndex, inputRequestedSize); + const RegionType inputRequestedRegion(inputRequestedIndex, inputRequestedSize); return inputRequestedRegion; } @@ -183,9 +183,9 @@ auto PeriodicBoundaryCondition::GetPixel(const IndexType & index, const TInputImage * image) const -> OutputPixelType { - RegionType imageRegion = image->GetLargestPossibleRegion(); - IndexType imageIndex = imageRegion.GetIndex(); - SizeType imageSize = imageRegion.GetSize(); + const RegionType imageRegion = image->GetLargestPossibleRegion(); + IndexType imageIndex = imageRegion.GetIndex(); + SizeType imageSize = imageRegion.GetSize(); IndexType lookupIndex; diff --git a/Modules/Core/Common/include/itkPoint.hxx b/Modules/Core/Common/include/itkPoint.hxx index ad05327b46f..339d907ef3f 100644 --- a/Modules/Core/Common/include/itkPoint.hxx +++ b/Modules/Core/Common/include/itkPoint.hxx @@ -221,9 +221,9 @@ BarycentricCombination::Evaluate(const PointC { PointType barycentre{}; // set to null - typename TPointContainer::Iterator point = points->Begin(); - typename TPointContainer::Iterator final = points->End(); - typename TPointContainer::Iterator last = final; + typename TPointContainer::Iterator point = points->Begin(); + const typename TPointContainer::Iterator final = points->End(); + typename TPointContainer::Iterator last = final; --last; // move to the (N)th point double weightSum = 0.0; diff --git a/Modules/Core/Common/include/itkPointSetBase.hxx b/Modules/Core/Common/include/itkPointSetBase.hxx index 685fcb3912a..43139311bc7 100644 --- a/Modules/Core/Common/include/itkPointSetBase.hxx +++ b/Modules/Core/Common/include/itkPointSetBase.hxx @@ -198,8 +198,8 @@ PointSetBase::GetPoint(PointIdentifier ptId) const -> PointTyp /** * Ask the container if the point identifier exists. */ - PointType point; - bool exist = m_PointsContainer->GetElementIfIndexExists(ptId, &point); + PointType point; + const bool exist = m_PointsContainer->GetElementIfIndexExists(ptId, &point); if (!exist) { itkExceptionMacro("Point id doesn't exist: " << ptId); @@ -332,7 +332,7 @@ template bool PointSetBase::VerifyRequestedRegion() { - bool retval = true; + const bool retval = true; // Are we asking for more regions than we can get? if (m_RequestedNumberOfRegions > m_MaximumNumberOfRegions) diff --git a/Modules/Core/Common/include/itkPointSetToImageFilter.hxx b/Modules/Core/Common/include/itkPointSetToImageFilter.hxx index dd913ec2369..1518f6726d0 100644 --- a/Modules/Core/Common/include/itkPointSetToImageFilter.hxx +++ b/Modules/Core/Common/include/itkPointSetToImageFilter.hxx @@ -113,7 +113,7 @@ PointSetToImageFilter::GenerateData() // Get the input and output pointers const InputPointSetType * InputPointSet = this->GetInput(); - OutputImagePointer OutputImage = this->GetOutput(); + const OutputImagePointer OutputImage = this->GetOutput(); // Generate the image double origin[InputPointSetDimension]; @@ -205,8 +205,8 @@ PointSetToImageFilter::GenerateData() OutputImage->FillBuffer(m_OutsideValue); using PointIterator = typename InputPointSetType::PointsContainer::ConstIterator; - PointIterator pointItr = InputPointSet->GetPoints()->Begin(); - PointIterator pointEnd = InputPointSet->GetPoints()->End(); + PointIterator pointItr = InputPointSet->GetPoints()->Begin(); + const PointIterator pointEnd = InputPointSet->GetPoints()->End(); typename OutputImageType::IndexType index; diff --git a/Modules/Core/Common/include/itkPolygonCell.hxx b/Modules/Core/Common/include/itkPolygonCell.hxx index d48fb8ef5c6..feb169d3f35 100644 --- a/Modules/Core/Common/include/itkPolygonCell.hxx +++ b/Modules/Core/Common/include/itkPolygonCell.hxx @@ -387,8 +387,8 @@ template bool PolygonCell::GetEdge(CellFeatureIdentifier edgeId, EdgeAutoPointer & edgePointer) { - auto * edge = new EdgeType; - unsigned int max_pointId = this->GetNumberOfPoints() - 1; + auto * edge = new EdgeType; + const unsigned int max_pointId = this->GetNumberOfPoints() - 1; if (edgeId < max_pointId) { diff --git a/Modules/Core/Common/include/itkPriorityQueueContainer.hxx b/Modules/Core/Common/include/itkPriorityQueueContainer.hxx index 8fbda303a43..fadc47e77dd 100644 --- a/Modules/Core/Common/include/itkPriorityQueueContainer.hxx +++ b/Modules/Core/Common/include/itkPriorityQueueContainer.hxx @@ -337,7 +337,7 @@ bool PriorityQueueContainer::Update( const ElementWrapperType & element) { - ElementIdentifierType location = m_Interface.GetLocation(element); + const ElementIdentifierType location = m_Interface.GetLocation(element); if (location != m_ElementNotFound) { @@ -363,13 +363,13 @@ bool PriorityQueueContainer::DeleteElement( const ElementWrapperType & element) { - ElementIdentifierType location = m_Interface.GetLocation(element); + const ElementIdentifierType location = m_Interface.GetLocation(element); if (location != m_ElementNotFound) { // m_Interface.SetLocation(element, m_ElementNotFound); - ElementIdentifierType tsize = this->Size(); + const ElementIdentifierType tsize = this->Size(); if (location >= tsize) { @@ -438,7 +438,7 @@ PriorityQueueContainerSize(); + const ElementIdentifierType queueSize = this->Size(); while (id < queueSize) { diff --git a/Modules/Core/Common/include/itkProcessObject.h b/Modules/Core/Common/include/itkProcessObject.h index 42305dea983..83a0d1564d2 100644 --- a/Modules/Core/Common/include/itkProcessObject.h +++ b/Modules/Core/Common/include/itkProcessObject.h @@ -916,7 +916,7 @@ class ITKCommon_EXPORT ProcessObject : public Object { return std::numeric_limits::max(); } - double temp = static_cast(f) * std::numeric_limits::max(); + const double temp = static_cast(f) * std::numeric_limits::max(); return static_cast(temp); } diff --git a/Modules/Core/Common/include/itkQuadraticEdgeCell.hxx b/Modules/Core/Common/include/itkQuadraticEdgeCell.hxx index 77ec4e30bd8..39247255917 100644 --- a/Modules/Core/Common/include/itkQuadraticEdgeCell.hxx +++ b/Modules/Core/Common/include/itkQuadraticEdgeCell.hxx @@ -225,7 +225,7 @@ void QuadraticEdgeCell::EvaluateShapeFunctions(const ParametricCoordArrayType & parametricCoordinates, ShapeFunctionsArrayType & weights) const { - CoordinateType x = parametricCoordinates[0]; // one-dimensional cell + const CoordinateType x = parametricCoordinates[0]; // one-dimensional cell if (weights.Size() != this->GetNumberOfPoints()) { diff --git a/Modules/Core/Common/include/itkQuadrilateralCell.hxx b/Modules/Core/Common/include/itkQuadrilateralCell.hxx index 737f3630de1..a680d9f27f9 100644 --- a/Modules/Core/Common/include/itkQuadrilateralCell.hxx +++ b/Modules/Core/Common/include/itkQuadrilateralCell.hxx @@ -333,7 +333,7 @@ QuadrilateralCell::EvaluatePosition(CoordinateType * x, mat.put(1, i, scol[i]); } - double d = vnl_determinant(mat); + const double d = vnl_determinant(mat); // d=vtkMath::Determinant2x2(rcol,scol); if (itk::Math::abs(d) < 1.e-20) { diff --git a/Modules/Core/Common/include/itkResourceProbe.hxx b/Modules/Core/Common/include/itkResourceProbe.hxx index 9af6cff8aff..8ce6112e5ef 100644 --- a/Modules/Core/Common/include/itkResourceProbe.hxx +++ b/Modules/Core/Common/include/itkResourceProbe.hxx @@ -402,7 +402,7 @@ ResourceProbe::PrintJSONvar(std::ostream & os, unsigned int indent, bool comma) { - bool varIsNumber = mpl::IsNumber::Value; + const bool varIsNumber = mpl::IsNumber::Value; while (indent > 0) { os << ' '; @@ -427,7 +427,7 @@ template void ResourceProbe::JSONReport(std::ostream & os) { - std::stringstream ss; + const std::stringstream ss; ValueType ratioOfMeanToMinimum; if (Math::ExactlyEquals(this->GetMinimum(), 0.0)) diff --git a/Modules/Core/Common/include/itkResourceProbesCollectorBase.hxx b/Modules/Core/Common/include/itkResourceProbesCollectorBase.hxx index d3c150d79f6..398838a3c19 100644 --- a/Modules/Core/Common/include/itkResourceProbesCollectorBase.hxx +++ b/Modules/Core/Common/include/itkResourceProbesCollectorBase.hxx @@ -37,7 +37,7 @@ template void ResourceProbesCollectorBase::Stop(const char * id) { - IdType tid = id; + const IdType tid = id; auto pos = this->m_Probes.find(tid); if (pos == this->m_Probes.end()) @@ -52,7 +52,7 @@ template const TProbe & ResourceProbesCollectorBase::GetProbe(const char * id) const { - IdType tid = id; + const IdType tid = id; auto pos = this->m_Probes.find(tid); if (pos == this->m_Probes.end()) @@ -67,8 +67,8 @@ template void ResourceProbesCollectorBase::Report(std::ostream & os, bool printSystemInfo, bool printReportHead, bool useTabs) { - auto probe = this->m_Probes.begin(); - typename MapType::const_iterator end = this->m_Probes.end(); + auto probe = this->m_Probes.begin(); + const typename MapType::const_iterator end = this->m_Probes.end(); if (probe == end) { @@ -122,8 +122,8 @@ ResourceProbesCollectorBase::ExpandedReport(std::ostream & os, bool printReportHead, bool useTabs) { - auto probe = this->m_Probes.begin(); - typename MapType::const_iterator end = this->m_Probes.end(); + auto probe = this->m_Probes.begin(); + const typename MapType::const_iterator end = this->m_Probes.end(); if (probe == end) { @@ -174,8 +174,8 @@ template void ResourceProbesCollectorBase::JSONReport(std::ostream & os, bool printSystemInfo) { - auto probe = this->m_Probes.begin(); - typename MapType::const_iterator end = this->m_Probes.end(); + auto probe = this->m_Probes.begin(); + const typename MapType::const_iterator end = this->m_Probes.end(); if (probe == end) { diff --git a/Modules/Core/Common/include/itkShapedFloodFilledFunctionConditionalConstIterator.hxx b/Modules/Core/Common/include/itkShapedFloodFilledFunctionConditionalConstIterator.hxx index 44dffa0d0e3..19ee070b557 100644 --- a/Modules/Core/Common/include/itkShapedFloodFilledFunctionConditionalConstIterator.hxx +++ b/Modules/Core/Common/include/itkShapedFloodFilledFunctionConditionalConstIterator.hxx @@ -82,14 +82,14 @@ ShapedFloodFilledFunctionConditionalConstIterator::Initialize // Build and setup the neighborhood iterator constexpr auto radius = MakeFilled(1); - NeighborhoodIteratorType tmp_iter(radius, this->m_Image, m_ImageRegion); + const NeighborhoodIteratorType tmp_iter(radius, this->m_Image, m_ImageRegion); m_NeighborhoodIterator = tmp_iter; setConnectivity(&m_NeighborhoodIterator, m_FullyConnected); // Build a temporary image of chars for use in the flood algorithm m_TempPtr = TTempImage::New(); - typename TTempImage::RegionType tempRegion = this->m_Image->GetBufferedRegion(); + const typename TTempImage::RegionType tempRegion = this->m_Image->GetBufferedRegion(); m_TempPtr->SetRegions(tempRegion); m_TempPtr->AllocateInitialized(); diff --git a/Modules/Core/Common/include/itkSmapsFileParser.hxx b/Modules/Core/Common/include/itkSmapsFileParser.hxx index 7b61eb32050..cbf9d367046 100644 --- a/Modules/Core/Common/include/itkSmapsFileParser.hxx +++ b/Modules/Core/Common/include/itkSmapsFileParser.hxx @@ -104,7 +104,7 @@ SmapsFileParser::ReadFile(const std::string & mapFileLocation) #if defined(WIN32) || defined(_WIN32) itkGenericExceptionMacro("smaps files don't exist on Windows"); #else - int pid = getpid(); + int const pid = getpid(); filename << "/proc/" << pid << "/smaps"; #endif } diff --git a/Modules/Core/Common/include/itkSparseFieldLayer.hxx b/Modules/Core/Common/include/itkSparseFieldLayer.hxx index 2a0f6e47e17..6790fedeabc 100644 --- a/Modules/Core/Common/include/itkSparseFieldLayer.hxx +++ b/Modules/Core/Common/include/itkSparseFieldLayer.hxx @@ -50,10 +50,11 @@ template auto SparseFieldLayer::SplitRegions(int num) const -> RegionListType { - unsigned int size = Size(); - unsigned int regionsize = static_cast(std::ceil(static_cast(size) / static_cast(num))); - ConstIterator position = Begin(); - ConstIterator last = End(); + const unsigned int size = Size(); + const unsigned int regionsize = + static_cast(std::ceil(static_cast(size) / static_cast(num))); + ConstIterator position = Begin(); + const ConstIterator last = End(); std::vector regionlist; regionlist.reserve(num); diff --git a/Modules/Core/Common/include/itkSpatialOrientationAdapter.h b/Modules/Core/Common/include/itkSpatialOrientationAdapter.h index 2800ed37422..617e1407462 100644 --- a/Modules/Core/Common/include/itkSpatialOrientationAdapter.h +++ b/Modules/Core/Common/include/itkSpatialOrientationAdapter.h @@ -43,9 +43,9 @@ Max3(double x, double y, double z) { constexpr double obliquityThresholdCosineValue = 0.001; - double absX = itk::Math::abs(x); - double absY = itk::Math::abs(y); - double absZ = itk::Math::abs(z); + const double absX = itk::Math::abs(x); + const double absY = itk::Math::abs(y); + const double absZ = itk::Math::abs(z); if ((absX > obliquityThresholdCosineValue) && (absX > absY) && (absX > absZ)) { diff --git a/Modules/Core/Common/include/itkSpecialCoordinatesImage.h b/Modules/Core/Common/include/itkSpecialCoordinatesImage.h index aa3bb0d306d..8bb9b76fcc5 100644 --- a/Modules/Core/Common/include/itkSpecialCoordinatesImage.h +++ b/Modules/Core/Common/include/itkSpecialCoordinatesImage.h @@ -204,7 +204,7 @@ class ITK_TEMPLATE_EXPORT SpecialCoordinatesImage : public ImageBaseFastComputeOffset(index); + const OffsetValueType offset = this->FastComputeOffset(index); return ((*m_Buffer)[offset]); } diff --git a/Modules/Core/Common/include/itkStreamingImageFilter.hxx b/Modules/Core/Common/include/itkStreamingImageFilter.hxx index cc510cc88b4..c32b0e78182 100644 --- a/Modules/Core/Common/include/itkStreamingImageFilter.hxx +++ b/Modules/Core/Common/include/itkStreamingImageFilter.hxx @@ -151,8 +151,9 @@ StreamingImageFilter::UpdateOutputData(DataObject * i * minimum of what the user specified via SetNumberOfStreamDivisions() * and what the Splitter thinks is a reasonable value. */ - unsigned int numDivisions = m_NumberOfStreamDivisions; - unsigned int numDivisionsFromSplitter = m_RegionSplitter->GetNumberOfSplits(outputRegion, m_NumberOfStreamDivisions); + unsigned int numDivisions = m_NumberOfStreamDivisions; + const unsigned int numDivisionsFromSplitter = + m_RegionSplitter->GetNumberOfSplits(outputRegion, m_NumberOfStreamDivisions); if (numDivisionsFromSplitter < numDivisions) { numDivisions = numDivisionsFromSplitter; diff --git a/Modules/Core/Common/include/itkSymmetricEigenAnalysis.h b/Modules/Core/Common/include/itkSymmetricEigenAnalysis.h index 52653712f3b..e2e6a4a5a8f 100644 --- a/Modules/Core/Common/include/itkSymmetricEigenAnalysis.h +++ b/Modules/Core/Common/include/itkSymmetricEigenAnalysis.h @@ -556,8 +556,8 @@ class ITK_TEMPLATE_EXPORT SymmetricEigenAnalysis } } using EigenSolverType = Eigen::SelfAdjointEigenSolver; - EigenSolverType solver(inputMatrix); // Computes EigenValues and EigenVectors - const auto & eigenValues = solver.eigenvalues(); + const EigenSolverType solver(inputMatrix); // Computes EigenValues and EigenVectors + const auto & eigenValues = solver.eigenvalues(); /* Column k of the returned matrix is an eigenvector corresponding to * eigenvalue number $ k $ as returned by eigenvalues(). * The eigenvectors are normalized to have (Euclidean) norm equal to one. */ @@ -683,8 +683,8 @@ class ITK_TEMPLATE_EXPORT SymmetricEigenAnalysis } } using EigenSolverType = Eigen::SelfAdjointEigenSolver; - EigenSolverType solver(inputMatrix, Eigen::EigenvaluesOnly); - auto eigenValues = solver.eigenvalues(); + const EigenSolverType solver(inputMatrix, Eigen::EigenvaluesOnly); + auto eigenValues = solver.eigenvalues(); if (m_OrderEigenValues == EigenValueOrderEnum::OrderByMagnitude) { detail::sortEigenValuesByMagnitude(eigenValues, m_Dimension); @@ -971,8 +971,8 @@ class ITK_TEMPLATE_EXPORT SymmetricEigenAnalysisFixedDimension } } using EigenSolverType = Eigen::SelfAdjointEigenSolver; - EigenSolverType solver(inputMatrix); // Computes EigenValues and EigenVectors - const auto & eigenValues = solver.eigenvalues(); + const EigenSolverType solver(inputMatrix); // Computes EigenValues and EigenVectors + const auto & eigenValues = solver.eigenvalues(); /* Column k of the returned matrix is an eigenvector corresponding to * eigenvalue number $ k $ as returned by eigenvalues(). * The eigenvectors are normalized to have (Euclidean) norm equal to one. */ @@ -1030,8 +1030,8 @@ class ITK_TEMPLATE_EXPORT SymmetricEigenAnalysisFixedDimension } } using EigenSolverType = Eigen::SelfAdjointEigenSolver; - EigenSolverType solver(inputMatrix, Eigen::EigenvaluesOnly); - auto eigenValues = solver.eigenvalues(); + const EigenSolverType solver(inputMatrix, Eigen::EigenvaluesOnly); + auto eigenValues = solver.eigenvalues(); if (m_OrderEigenValues == EigenValueOrderEnum::OrderByMagnitude) { detail::sortEigenValuesByMagnitude(eigenValues, VDimension); diff --git a/Modules/Core/Common/include/itkSymmetricEigenAnalysis.hxx b/Modules/Core/Common/include/itkSymmetricEigenAnalysis.hxx index 6f4b0a2a264..ebba8aa3b04 100644 --- a/Modules/Core/Common/include/itkSymmetricEigenAnalysis.hxx +++ b/Modules/Core/Common/include/itkSymmetricEigenAnalysis.hxx @@ -148,9 +148,9 @@ SymmetricEigenAnalysis::ReduceToTridiagonalMatri for (int i = m_Order - 1; i >= 0; --i) { - int l = i - 1; - double h = 0.; - double scale = 0.; + const int l = i - 1; + double h = 0.; + double scale = 0.; // Scale row (algol tol then not needed) for (int k = 0; k <= l; ++k) @@ -177,9 +177,9 @@ SymmetricEigenAnalysis::ReduceToTridiagonalMatri } e2[i] = scale * scale * h; - double f = d[l]; - double d__1 = std::sqrt(h); - double g = (-1.0) * itk::Math::sgn0(f) * itk::Math::abs(d__1); + double f = d[l]; + const double d__1 = std::sqrt(h); + double g = (-1.0) * itk::Math::sgn0(f) * itk::Math::abs(d__1); e[i] = scale * g; h -= f * g; d[l] = f - g; @@ -262,9 +262,9 @@ SymmetricEigenAnalysis::ReduceToTridiagonalMatri for (unsigned int i = m_Order - 1; i > 0; --i) { - unsigned int l = i - 1; - double h = 0.0; - double scale = 0.0; + const unsigned int l = i - 1; + double h = 0.0; + double scale = 0.0; // Scale row (algol tol then not needed) for (unsigned int k = 0; k <= l; ++k) @@ -291,9 +291,9 @@ SymmetricEigenAnalysis::ReduceToTridiagonalMatri h += d[k] * d[k]; } - double f = d[l]; - double d__1 = std::sqrt(h); - double g = (-1.0) * itk::Math::sgn0(f) * itk::Math::abs(d__1); + double f = d[l]; + const double d__1 = std::sqrt(h); + double g = (-1.0) * itk::Math::sgn0(f) * itk::Math::abs(d__1); e[i] = scale * g; h -= f * g; d[l] = f - g; @@ -328,7 +328,7 @@ SymmetricEigenAnalysis::ReduceToTridiagonalMatri f += e[j] * d[j]; } - double hh = f / (h + h); + const double hh = f / (h + h); // Form q for (unsigned int j = 0; j <= l; ++j) @@ -358,10 +358,10 @@ SymmetricEigenAnalysis::ReduceToTridiagonalMatri // Accumulation of transformation matrices for (unsigned int i = 1; i < m_Order; ++i) { - unsigned int l = i - 1; + const unsigned int l = i - 1; z[m_Order - 1 + l * m_Dimension] = z[l + l * m_Dimension]; z[l + l * m_Dimension] = 1.0; - double h = d[i]; + const double h = d[i]; if (h != 0.0) { for (unsigned int k = 0; k <= l; ++k) @@ -435,7 +435,7 @@ SymmetricEigenAnalysis::ComputeEigenValuesUsingQ // Look for small sub-diagonal element for (m = l; m < m_Order - 1; ++m) { - double tst2 = tst1 + itk::Math::abs(e[m]); + const double tst2 = tst1 + itk::Math::abs(e[m]); if (tst2 == tst1) { break; @@ -461,7 +461,7 @@ SymmetricEigenAnalysis::ComputeEigenValuesUsingQ double r = itk::Math::hypot(p, c_b10); d[l] = e[l] / (p + itk::Math::sgn0(p) * itk::Math::abs(r)); d[l + 1] = e[l] * (p + itk::Math::sgn0(p) * itk::Math::abs(r)); - double dl1 = d[l + 1]; + const double dl1 = d[l + 1]; h = g - d[l]; for (unsigned int i = l + 2; i < m_Order; ++i) @@ -504,7 +504,7 @@ SymmetricEigenAnalysis::ComputeEigenValuesUsingQ } while (tst2 > tst1); } - double p = d[l] + f; + const double p = d[l] + f; if (m_OrderEigenValues == EigenValueOrderEnum::OrderByValue) { @@ -608,7 +608,7 @@ SymmetricEigenAnalysis::ComputeEigenValuesAndVec double r = itk::Math::hypot(p, c_b10); d[l] = e[l] / (p + itk::Math::sgn0(p) * itk::Math::abs(r)); d[l + 1] = e[l] * (p + itk::Math::sgn0(p) * itk::Math::abs(r)); - double dl1 = d[l + 1]; + const double dl1 = d[l + 1]; h = g - d[l]; for (unsigned int i = l + 2; i < m_Order; ++i) @@ -619,10 +619,10 @@ SymmetricEigenAnalysis::ComputeEigenValuesAndVec f += h; // ql transformation p = d[m]; - double c = 1.0; - double c2 = c; - double el1 = e[l + 1]; - double s = 0.; + double c = 1.0; + double c2 = c; + const double el1 = e[l + 1]; + double s = 0.; for (unsigned int i = m - 1; i >= l; --i) { diff --git a/Modules/Core/Common/include/itkSymmetricSecondRankTensor.hxx b/Modules/Core/Common/include/itkSymmetricSecondRankTensor.hxx index ff48d8c7a6f..c89cbd373d0 100644 --- a/Modules/Core/Common/include/itkSymmetricSecondRankTensor.hxx +++ b/Modules/Core/Common/include/itkSymmetricSecondRankTensor.hxx @@ -256,7 +256,7 @@ template void SymmetricSecondRankTensor::ComputeEigenValues(EigenValuesArrayType & eigenValues) const { - SymmetricEigenAnalysisType symmetricEigenSystem; + const SymmetricEigenAnalysisType symmetricEigenSystem; MatrixType tensorMatrix; @@ -280,7 +280,7 @@ void SymmetricSecondRankTensor::ComputeEigenAnalysis(EigenValuesArrayType & eigenValues, EigenVectorsMatrixType & eigenVectors) const { - SymmetricEigenAnalysisType symmetricEigenSystem; + const SymmetricEigenAnalysisType symmetricEigenSystem; MatrixType tensorMatrix; diff --git a/Modules/Core/Common/include/itkThreadedIteratorRangePartitioner.hxx b/Modules/Core/Common/include/itkThreadedIteratorRangePartitioner.hxx index 5f9478e6d87..785b0c4fa48 100644 --- a/Modules/Core/Common/include/itkThreadedIteratorRangePartitioner.hxx +++ b/Modules/Core/Common/include/itkThreadedIteratorRangePartitioner.hxx @@ -36,10 +36,10 @@ ThreadedIteratorRangePartitioner::PartitionDomain(const ThreadIdType // overallIndexRange is expected to be inclusive // determine the actual number of pieces that will be generated - ThreadIdType count = std::distance(completeDomain.Begin(), completeDomain.End()); + const ThreadIdType count = std::distance(completeDomain.Begin(), completeDomain.End()); auto valuesPerThread = Math::Ceil(static_cast(count) / static_cast(requestedTotal)); - ThreadIdType maxThreadIdUsed = + const ThreadIdType maxThreadIdUsed = Math::Ceil(static_cast(count) / static_cast(valuesPerThread)) - 1; if (threadId > maxThreadIdUsed) diff --git a/Modules/Core/Common/include/itkTorusInteriorExteriorSpatialFunction.hxx b/Modules/Core/Common/include/itkTorusInteriorExteriorSpatialFunction.hxx index 0aac93f944c..34a4a8d5c4e 100644 --- a/Modules/Core/Common/include/itkTorusInteriorExteriorSpatialFunction.hxx +++ b/Modules/Core/Common/include/itkTorusInteriorExteriorSpatialFunction.hxx @@ -25,11 +25,11 @@ template auto TorusInteriorExteriorSpatialFunction::Evaluate(const InputType & position) const -> OutputType { - double x = position[0] - m_Origin[0]; - double y = position[1] - m_Origin[1]; - double z = position[2] - m_Origin[2]; + const double x = position[0] - m_Origin[0]; + const double y = position[1] - m_Origin[1]; + const double z = position[2] - m_Origin[2]; - double k = std::pow(m_MajorRadius - std::sqrt(x * x + y * y), 2.0) + z * z; + const double k = std::pow(m_MajorRadius - std::sqrt(x * x + y * y), 2.0) + z * z; if (k <= (m_MinorRadius * m_MinorRadius)) { diff --git a/Modules/Core/Common/include/itkTotalProgressReporter.h b/Modules/Core/Common/include/itkTotalProgressReporter.h index bf46c6588f0..599f31ffe91 100644 --- a/Modules/Core/Common/include/itkTotalProgressReporter.h +++ b/Modules/Core/Common/include/itkTotalProgressReporter.h @@ -102,8 +102,8 @@ class ITKCommon_EXPORT TotalProgressReporter if (count >= m_PixelsBeforeUpdate) { - SizeValueType total = static_cast(m_PixelsPerUpdate - m_PixelsBeforeUpdate) + count; - SizeValueType numberOfUpdates = total / m_PixelsPerUpdate; + const SizeValueType total = static_cast(m_PixelsPerUpdate - m_PixelsBeforeUpdate) + count; + const SizeValueType numberOfUpdates = total / m_PixelsPerUpdate; m_PixelsBeforeUpdate = m_PixelsPerUpdate - total % m_PixelsPerUpdate; m_CurrentPixel += numberOfUpdates * m_PixelsPerUpdate; diff --git a/Modules/Core/Common/include/itkTriangleCell.hxx b/Modules/Core/Common/include/itkTriangleCell.hxx index e8bd7fbdc2f..47c4948d926 100644 --- a/Modules/Core/Common/include/itkTriangleCell.hxx +++ b/Modules/Core/Common/include/itkTriangleCell.hxx @@ -238,7 +238,7 @@ TriangleCell::DistanceToLine(PointType x, denom += static_cast(v21[i] * v21[i]); } - double tolerance = std::abs(1.e-05 * num); + const double tolerance = std::abs(1.e-05 * num); if ((-tolerance < denom) && (denom < tolerance)) // numerically bad! { closestPoint = p1; // arbitrary, point is (numerically) far away @@ -369,14 +369,14 @@ TriangleCell::EvaluatePosition(CoordinateType * x, double * minDist2, InterpolationWeightType * weights) { - unsigned int i; - double dist2Point; - double dist2Line1; - double dist2Line2; - PointType closest; - PointType closestPoint1; - PointType closestPoint2; - PointType X(x); + unsigned int i; + double dist2Point; + double dist2Line1; + double dist2Line2; + PointType closest; + PointType closestPoint1; + PointType closestPoint2; + const PointType X(x); if (!points) { @@ -390,8 +390,8 @@ TriangleCell::EvaluatePosition(CoordinateType * x, // Compute Vectors along the edges. // These two vectors form a vector base for the 2D space of the triangle cell. - VectorType v12 = pt1 - pt2; - VectorType v32 = pt3 - pt2; + const VectorType v12 = pt1 - pt2; + const VectorType v32 = pt3 - pt2; // Compute Vectors in the dual vector base inside the 2D space of the triangle // cell. @@ -410,13 +410,13 @@ TriangleCell::EvaluatePosition(CoordinateType * x, // Compute components of the input point in the 2D // space defined by v12 and v32 - VectorType xo = X - pt2; + const VectorType xo = X - pt2; const double u12p = xo * u12; const double u32p = xo * u32; - VectorType x12 = v12 * u12p; - VectorType x32 = v32 * u32p; + const VectorType x12 = v12 * u12p; + const VectorType x32 = v32 * u32p; // The projection of point X in the plane is cp PointType cp = pt2 + x12 + x32; diff --git a/Modules/Core/Common/include/itkTriangleHelper.hxx b/Modules/Core/Common/include/itkTriangleHelper.hxx index 8c124a04181..82659a5a0f6 100644 --- a/Modules/Core/Common/include/itkTriangleHelper.hxx +++ b/Modules/Core/Common/include/itkTriangleHelper.hxx @@ -26,9 +26,9 @@ template bool TriangleHelper::IsObtuse(const PointType & iA, const PointType & iB, const PointType & iC) { - VectorType v01 = iB - iA; - VectorType v02 = iC - iA; - VectorType v12 = iC - iB; + const VectorType v01 = iB - iA; + const VectorType v02 = iC - iA; + const VectorType v12 = iC - iB; if (v01 * v02 < 0.0) { @@ -58,9 +58,9 @@ template auto TriangleHelper::ComputeNormal(const PointType & iA, const PointType & iB, const PointType & iC) -> VectorType { - CrossVectorType cross; - VectorType w = cross(iB - iA, iC - iA); - CoordinateType l2 = w.GetSquaredNorm(); + const CrossVectorType cross; + VectorType w = cross(iB - iA, iC - iA); + const CoordinateType l2 = w.GetSquaredNorm(); if (l2 != 0.0) { @@ -76,23 +76,23 @@ TriangleHelper::Cotangent(const PointType & iA, const PointType & iB, co { VectorType v21 = iA - iB; - CoordinateType v21_l2 = v21.GetSquaredNorm(); + const CoordinateType v21_l2 = v21.GetSquaredNorm(); if (Math::NotAlmostEquals(v21_l2, CoordinateType{})) { v21 /= std::sqrt(v21_l2); } - VectorType v23 = iC - iB; - CoordinateType v23_l2 = v23.GetSquaredNorm(); + VectorType v23 = iC - iB; + const CoordinateType v23_l2 = v23.GetSquaredNorm(); if (Math::NotAlmostEquals(v23_l2, CoordinateType{})) { v23 /= std::sqrt(v23_l2); } - CoordinateType bound(0.999999); + const CoordinateType bound(0.999999); - CoordinateType cos_theta = std::clamp(v21 * v23, -bound, bound); + const CoordinateType cos_theta = std::clamp(v21 * v23, -bound, bound); return 1.0 / std::tan(std::acos(cos_theta)); } @@ -135,8 +135,8 @@ TriangleHelper::ComputeAngle(const PointType & iP1, const PointType & iP VectorType v21 = iP1 - iP2; VectorType v23 = iP3 - iP2; - CoordinateType v21_l2 = v21.GetSquaredNorm(); - CoordinateType v23_l2 = v23.GetSquaredNorm(); + const CoordinateType v21_l2 = v21.GetSquaredNorm(); + const CoordinateType v23_l2 = v23.GetSquaredNorm(); if (v21_l2 != 0.0) { @@ -147,9 +147,9 @@ TriangleHelper::ComputeAngle(const PointType & iP1, const PointType & iP v23 /= std::sqrt(v23_l2); } - CoordinateType bound(0.999999); + const CoordinateType bound(0.999999); - CoordinateType cos_theta = std::clamp(v21 * v23, -bound, bound); + const CoordinateType cos_theta = std::clamp(v21 * v23, -bound, bound); return std::acos(cos_theta); } @@ -209,11 +209,11 @@ auto TriangleHelper::ComputeArea(const PointType & iP1, const PointType & iP2, const PointType & iP3) -> CoordinateType { - CoordinateType a = iP2.EuclideanDistanceTo(iP3); - CoordinateType b = iP1.EuclideanDistanceTo(iP3); - CoordinateType c = iP2.EuclideanDistanceTo(iP1); + const CoordinateType a = iP2.EuclideanDistanceTo(iP3); + const CoordinateType b = iP1.EuclideanDistanceTo(iP3); + const CoordinateType c = iP2.EuclideanDistanceTo(iP1); - CoordinateType s = 0.5 * (a + b + c); + const CoordinateType s = 0.5 * (a + b + c); return static_cast(std::sqrt(s * (s - a) * (s - b) * (s - c))); } @@ -230,8 +230,8 @@ TriangleHelper::ComputeMixedArea(const PointType & iP1, const PointType auto sq_d01 = static_cast(iP1.SquaredEuclideanDistanceTo(iP2)); auto sq_d02 = static_cast(iP1.SquaredEuclideanDistanceTo(iP3)); - CoordinateType cot_theta_210 = TriangleType::Cotangent(iP3, iP2, iP1); - CoordinateType cot_theta_021 = TriangleType::Cotangent(iP1, iP3, iP2); + const CoordinateType cot_theta_210 = TriangleType::Cotangent(iP3, iP2, iP1); + const CoordinateType cot_theta_021 = TriangleType::Cotangent(iP1, iP3, iP2); return 0.125 * (sq_d02 * cot_theta_210 + sq_d01 * cot_theta_021); } diff --git a/Modules/Core/Common/include/itkUnaryFunctorImageFilter.hxx b/Modules/Core/Common/include/itkUnaryFunctorImageFilter.hxx index 39d8b4c4d1b..e0ce10e85b8 100644 --- a/Modules/Core/Common/include/itkUnaryFunctorImageFilter.hxx +++ b/Modules/Core/Common/include/itkUnaryFunctorImageFilter.hxx @@ -62,7 +62,8 @@ UnaryFunctorImageFilter::GenerateOutputInf this->CallCopyInputRegionToOutputRegion(outputLargestPossibleRegion, inputPtr->GetLargestPossibleRegion()); outputPtr->SetLargestPossibleRegion(outputLargestPossibleRegion); - ImageToImageFilterDetail::ImageInformationCopier + const ImageToImageFilterDetail::ImageInformationCopier informationCopier; informationCopier(outputPtr, inputPtr); } diff --git a/Modules/Core/Common/include/itkVariableSizeMatrix.hxx b/Modules/Core/Common/include/itkVariableSizeMatrix.hxx index e8f6671f4af..99b28503a9b 100644 --- a/Modules/Core/Common/include/itkVariableSizeMatrix.hxx +++ b/Modules/Core/Common/include/itkVariableSizeMatrix.hxx @@ -34,8 +34,8 @@ template Array VariableSizeMatrix::operator*(const Array & vect) const { - unsigned int rows = this->Rows(); - unsigned int cols = this->Cols(); + const unsigned int rows = this->Rows(); + const unsigned int cols = this->Cols(); if (vect.Size() != cols) { diff --git a/Modules/Core/Common/include/itkVectorImage.h b/Modules/Core/Common/include/itkVectorImage.h index 0b1d468d968..1a40b5e4fce 100644 --- a/Modules/Core/Common/include/itkVectorImage.h +++ b/Modules/Core/Common/include/itkVectorImage.h @@ -223,7 +223,7 @@ class ITK_TEMPLATE_EXPORT VectorImage : public ImageBase void SetPixel(const IndexType & index, const PixelType & value) { - OffsetValueType offset = m_VectorLength * this->FastComputeOffset(index); + const OffsetValueType offset = m_VectorLength * this->FastComputeOffset(index); for (VectorLengthType i = 0; i < m_VectorLength; ++i) { @@ -239,7 +239,7 @@ class ITK_TEMPLATE_EXPORT VectorImage : public ImageBase const PixelType GetPixel(const IndexType & index) const { - OffsetValueType offset = m_VectorLength * this->FastComputeOffset(index); + const OffsetValueType offset = m_VectorLength * this->FastComputeOffset(index); // Do not create a local for this method, to use return value // optimization. @@ -258,7 +258,7 @@ class ITK_TEMPLATE_EXPORT VectorImage : public ImageBase PixelType GetPixel(const IndexType & index) { - OffsetValueType offset = m_VectorLength * this->FastComputeOffset(index); + const OffsetValueType offset = m_VectorLength * this->FastComputeOffset(index); // Correctness of this method relies of return value optimization, do // not create a local for the value. diff --git a/Modules/Core/Common/include/itkVersor.hxx b/Modules/Core/Common/include/itkVersor.hxx index f75c1c9040b..1527f10ba8f 100644 --- a/Modules/Core/Common/include/itkVersor.hxx +++ b/Modules/Core/Common/include/itkVersor.hxx @@ -108,7 +108,7 @@ bool Versor::operator==(const Self & v) const { // Evaluate the quaternion ratio between them - Self ratio = *this * v.GetReciprocal(); + const Self ratio = *this * v.GetReciprocal(); const typename itk::NumericTraits::AccumulateType square = ratio.m_W * ratio.m_W; diff --git a/Modules/Core/Common/include/itkZeroFluxNeumannBoundaryCondition.hxx b/Modules/Core/Common/include/itkZeroFluxNeumannBoundaryCondition.hxx index b2f07b1ed1d..d5f7e7f5cc3 100644 --- a/Modules/Core/Common/include/itkZeroFluxNeumannBoundaryCondition.hxx +++ b/Modules/Core/Common/include/itkZeroFluxNeumannBoundaryCondition.hxx @@ -123,7 +123,7 @@ ZeroFluxNeumannBoundaryCondition::GetInputRequestedRe if (requestIndex[i] < outputIndex[i]) { // How much do we need to adjust - OffsetValueType crop = outputIndex[i] - requestIndex[i]; + const OffsetValueType crop = outputIndex[i] - requestIndex[i]; // Adjust the start index and the size of the current region requestIndex[i] += crop; @@ -134,8 +134,8 @@ ZeroFluxNeumannBoundaryCondition::GetInputRequestedRe outputIndex[i] + static_cast(outputSize[i])) { // How much do we need to adjust - OffsetValueType crop = requestIndex[i] + static_cast(requestSize[i]) - outputIndex[i] - - static_cast(outputSize[i]); + const OffsetValueType crop = requestIndex[i] + static_cast(requestSize[i]) - outputIndex[i] - + static_cast(outputSize[i]); // Adjust the size requestSize[i] -= static_cast(crop); @@ -143,7 +143,7 @@ ZeroFluxNeumannBoundaryCondition::GetInputRequestedRe } } - RegionType inputRequestedRegion(requestIndex, requestSize); + const RegionType inputRequestedRegion(requestIndex, requestSize); return inputRequestedRegion; } @@ -155,16 +155,16 @@ ZeroFluxNeumannBoundaryCondition::GetPixel(const Inde const TInputImage * image) const -> OutputPixelType { - RegionType imageRegion = image->GetLargestPossibleRegion(); - IndexType imageIndex = imageRegion.GetIndex(); - SizeType imageSize = imageRegion.GetSize(); + const RegionType imageRegion = image->GetLargestPossibleRegion(); + IndexType imageIndex = imageRegion.GetIndex(); + SizeType imageSize = imageRegion.GetSize(); IndexType lookupIndex; for (unsigned int i = 0; i < ImageDimension; ++i) { - IndexValueType lowerIndex = imageIndex[i]; - IndexValueType upperIndex = imageIndex[i] + static_cast(imageSize[i]) - 1; + const IndexValueType lowerIndex = imageIndex[i]; + const IndexValueType upperIndex = imageIndex[i] + static_cast(imageSize[i]) - 1; if (index[i] < lowerIndex) { lookupIndex[i] = lowerIndex; diff --git a/Modules/Core/Common/src/itkAnatomicalOrientation.cxx b/Modules/Core/Common/src/itkAnatomicalOrientation.cxx index 23c31135f95..79ae7d50cbc 100644 --- a/Modules/Core/Common/src/itkAnatomicalOrientation.cxx +++ b/Modules/Core/Common/src/itkAnatomicalOrientation.cxx @@ -252,8 +252,8 @@ AnatomicalOrientation::ConvertPositiveEnumToDirection(PositiveEnum orientationEn { const AnatomicalOrientation o(orientationEnum); - CoordinateEnum terms[Dimension] = { o.GetPrimaryTerm(), o.GetSecondaryTerm(), o.GetTertiaryTerm() }; - DirectionType direction{}; + const CoordinateEnum terms[Dimension] = { o.GetPrimaryTerm(), o.GetSecondaryTerm(), o.GetTertiaryTerm() }; + DirectionType direction{}; for (unsigned int i = 0; i < Dimension; ++i) { diff --git a/Modules/Core/Common/src/itkDirectory.cxx b/Modules/Core/Common/src/itkDirectory.cxx index 81d528ead5b..59e32085b85 100644 --- a/Modules/Core/Common/src/itkDirectory.cxx +++ b/Modules/Core/Common/src/itkDirectory.cxx @@ -39,7 +39,7 @@ Directory::PrintSelf(std::ostream & os, Indent indent) const os << indent << "Directory for: " << m_Internal.GetPath() << '\n'; os << indent << "Contains the following files:\n"; indent = indent.GetNextIndent(); - unsigned long numFiles = m_Internal.GetNumberOfFiles(); + const unsigned long numFiles = m_Internal.GetNumberOfFiles(); for (unsigned long i = 0; i < numFiles; ++i) { os << indent << m_Internal.GetFile(i) << '\n'; diff --git a/Modules/Core/Common/src/itkEquivalencyTable.cxx b/Modules/Core/Common/src/itkEquivalencyTable.cxx index 0371a7312f6..b3f34a3338f 100644 --- a/Modules/Core/Common/src/itkEquivalencyTable.cxx +++ b/Modules/Core/Common/src/itkEquivalencyTable.cxx @@ -29,7 +29,7 @@ EquivalencyTable::Add(unsigned long a, unsigned long b) } else if (a < b) { // swap a, b - unsigned long temp = a; + const unsigned long temp = a; a = b; b = temp; } @@ -62,12 +62,12 @@ EquivalencyTable::AddAndFlatten(unsigned long a, unsigned long b) } else if (a < b) { // swap a, b - unsigned long temp = a; + const unsigned long temp = a; a = b; b = temp; } - unsigned long bFlattened = this->RecursiveLookup(b); + const unsigned long bFlattened = this->RecursiveLookup(b); result = m_HashMap.insert(ValueType(a, bFlattened)); if (result.second == false) diff --git a/Modules/Core/Common/src/itkEventObject.cxx b/Modules/Core/Common/src/itkEventObject.cxx index 7c58cd93196..dee96f2236d 100644 --- a/Modules/Core/Common/src/itkEventObject.cxx +++ b/Modules/Core/Common/src/itkEventObject.cxx @@ -22,7 +22,7 @@ namespace itk void EventObject::Print(std::ostream & os) const { - Indent indent; + const Indent indent; this->PrintHeader(os, 0); this->PrintSelf(os, indent.GetNextIndent()); diff --git a/Modules/Core/Common/src/itkExceptionObject.cxx b/Modules/Core/Common/src/itkExceptionObject.cxx index c4e7374014d..ac7b1f4c438 100644 --- a/Modules/Core/Common/src/itkExceptionObject.cxx +++ b/Modules/Core/Common/src/itkExceptionObject.cxx @@ -178,7 +178,7 @@ ExceptionObject::what() const noexcept void ExceptionObject::Print(std::ostream & os) const { - Indent indent; + const Indent indent; // Print header os << std::endl; diff --git a/Modules/Core/Common/src/itkImageRegionSplitterMultidimensional.cxx b/Modules/Core/Common/src/itkImageRegionSplitterMultidimensional.cxx index a6977240e62..683f0363eea 100644 --- a/Modules/Core/Common/src/itkImageRegionSplitterMultidimensional.cxx +++ b/Modules/Core/Common/src/itkImageRegionSplitterMultidimensional.cxx @@ -41,7 +41,7 @@ ImageRegionSplitterMultidimensional::GetNumberOfSplitsInternal(unsigned int // number of splits in each dimension std::vector splits(dim); // Note: stack allocation preferred - unsigned int numberOfPieces = this->ComputeSplits(dim, requestedNumber, regionIndex, regionSize, &splits[0]); + const unsigned int numberOfPieces = this->ComputeSplits(dim, requestedNumber, regionIndex, regionSize, &splits[0]); return numberOfPieces; } diff --git a/Modules/Core/Common/src/itkLightObject.cxx b/Modules/Core/Common/src/itkLightObject.cxx index 507403767e5..f74b1de297a 100644 --- a/Modules/Core/Common/src/itkLightObject.cxx +++ b/Modules/Core/Common/src/itkLightObject.cxx @@ -191,7 +191,7 @@ void LightObject::PrintSelf(std::ostream & os, Indent indent) const { #ifdef GCC_USEDEMANGLE - char const * mangledName = typeid(*this).name(); + const char * mangledName = typeid(*this).name(); int status; char * unmangled = abi::__cxa_demangle(mangledName, nullptr, nullptr, &status); diff --git a/Modules/Core/Common/src/itkLoggerBase.cxx b/Modules/Core/Common/src/itkLoggerBase.cxx index 2b334990256..e9b1508eb61 100644 --- a/Modules/Core/Common/src/itkLoggerBase.cxx +++ b/Modules/Core/Common/src/itkLoggerBase.cxx @@ -71,9 +71,9 @@ LoggerBase::PrivateFlush() std::string LoggerBase::BuildFormattedEntry(PriorityLevelEnum level, const std::string & content) { - static std::string m_LevelString[] = { "(MUSTFLUSH) ", "(FATAL) ", "(CRITICAL) ", "(WARNING) ", - "(INFO) ", "(DEBUG) ", "(NOTSET) " }; - std::ostringstream s; + static const std::string m_LevelString[] = { "(MUSTFLUSH) ", "(FATAL) ", "(CRITICAL) ", "(WARNING) ", + "(INFO) ", "(DEBUG) ", "(NOTSET) " }; + std::ostringstream s; switch (this->m_TimeStampFormat) { diff --git a/Modules/Core/Common/src/itkMemoryUsageObserver.cxx b/Modules/Core/Common/src/itkMemoryUsageObserver.cxx index fea46c98e00..84fdf86d9a8 100644 --- a/Modules/Core/Common/src/itkMemoryUsageObserver.cxx +++ b/Modules/Core/Common/src/itkMemoryUsageObserver.cxx @@ -315,10 +315,10 @@ MacOSXMemoryUsageObserver::GetMemoryUsage() // // this method comes from // https://stackoverflow.com/questions/5839626/how-is-top-able-to-see-memory-usage - task_t targetTask = mach_task_self(); + const task_t targetTask = mach_task_self(); struct task_basic_info ti; mach_msg_type_number_t count = TASK_BASIC_INFO_64_COUNT; - kern_return_t kr = task_info(targetTask, TASK_BASIC_INFO_64, (task_info_t)&ti, &count); + const kern_return_t kr = task_info(targetTask, TASK_BASIC_INFO_64, (task_info_t)&ti, &count); if (kr != KERN_SUCCESS) { return 0; diff --git a/Modules/Core/Common/src/itkMetaDataDictionary.cxx b/Modules/Core/Common/src/itkMetaDataDictionary.cxx index 04113be49de..6cb5e992725 100644 --- a/Modules/Core/Common/src/itkMetaDataDictionary.cxx +++ b/Modules/Core/Common/src/itkMetaDataDictionary.cxx @@ -78,8 +78,8 @@ MetaDataDictionary::Get(const std::string & key) const { itkGenericExceptionMacro("Key '" << key << "' does not exist "); } - MetaDataObjectBase::Pointer entry = (*m_Dictionary)[key]; - const MetaDataObjectBase * constentry = entry.GetPointer(); + const MetaDataObjectBase::Pointer entry = (*m_Dictionary)[key]; + const MetaDataObjectBase * constentry = entry.GetPointer(); return constentry; } diff --git a/Modules/Core/Common/src/itkMultiThreaderBase.cxx b/Modules/Core/Common/src/itkMultiThreaderBase.cxx index f2338b20d72..0c960403b7d 100644 --- a/Modules/Core/Common/src/itkMultiThreaderBase.cxx +++ b/Modules/Core/Common/src/itkMultiThreaderBase.cxx @@ -147,7 +147,7 @@ MultiThreaderBase::GetGlobalDefaultThreaderPrivate() if (itksys::SystemTools::GetEnv("ITK_GLOBAL_DEFAULT_THREADER", envVar)) { envVar = itksys::SystemTools::UpperCase(envVar); - ThreaderEnum threaderT = ThreaderTypeFromString(envVar); + const ThreaderEnum threaderT = ThreaderTypeFromString(envVar); if (threaderT != ThreaderEnum::Unknown) { MultiThreaderBase::SetGlobalDefaultThreaderPrivate(threaderT); @@ -365,7 +365,7 @@ MultiThreaderBase::GetGlobalDefaultNumberOfThreadsByPlatform() itksys::SystemInformation mySys; mySys.RunCPUCheck(); - int result = mySys.GetNumberOfPhysicalCPU(); // Avoid using hyperthreading cores. + const int result = mySys.GetNumberOfPhysicalCPU(); // Avoid using hyperthreading cores. if (result == -1) { num = 1; @@ -388,7 +388,7 @@ MultiThreaderBase::New() Pointer smartPtr = itk::ObjectFactory::Create(); if (smartPtr == nullptr) { - ThreaderEnum threaderType = GetGlobalDefaultThreader(); + const ThreaderEnum threaderType = GetGlobalDefaultThreader(); switch (threaderType) { case ThreaderEnum::Platform: @@ -477,7 +477,7 @@ MultiThreaderBase::ParallelizeArray(SizeValueType firstIndex, filter = nullptr; } // Upon destruction, progress will be set to 1.0 - ProgressReporter progress(filter, 0, 1); + const ProgressReporter progress(filter, 0, 1); if (firstIndex + 1 < lastIndexPlus1) { @@ -494,15 +494,15 @@ MultiThreaderBase::ParallelizeArray(SizeValueType firstIndex, ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION MultiThreaderBase::ParallelizeArrayHelper(void * arg) { - auto * workUnitInfo = static_cast(arg); - ThreadIdType workUnitID = workUnitInfo->WorkUnitID; - ThreadIdType workUnitCount = workUnitInfo->NumberOfWorkUnits; - auto * acParams = static_cast(workUnitInfo->UserData); - - SizeValueType range = acParams->lastIndexPlus1 - acParams->firstIndex; - double fraction = static_cast(range) / workUnitCount; - SizeValueType first = acParams->firstIndex + fraction * workUnitID; - SizeValueType afterLast = acParams->firstIndex + fraction * (workUnitID + 1); + auto * workUnitInfo = static_cast(arg); + const ThreadIdType workUnitID = workUnitInfo->WorkUnitID; + const ThreadIdType workUnitCount = workUnitInfo->NumberOfWorkUnits; + auto * acParams = static_cast(workUnitInfo->UserData); + + const SizeValueType range = acParams->lastIndexPlus1 - acParams->firstIndex; + const double fraction = static_cast(range) / workUnitCount; + const SizeValueType first = acParams->firstIndex + fraction * workUnitID; + SizeValueType afterLast = acParams->firstIndex + fraction * (workUnitID + 1); if (workUnitID == workUnitCount - 1) // last thread { // Avoid possible problems due to floating point arithmetic @@ -535,7 +535,7 @@ MultiThreaderBase::ParallelizeImageRegion(unsigned int { filter = nullptr; } - ProgressReporter progress(filter, 0, 1); + const ProgressReporter progress(filter, 0, 1); struct RegionAndCallback rnc{ funcP, dimension, index, size, filter }; this->SetSingleMethodAndExecute(&MultiThreaderBase::ParallelizeImageRegionHelper, &rnc); @@ -544,10 +544,10 @@ MultiThreaderBase::ParallelizeImageRegion(unsigned int ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION MultiThreaderBase::ParallelizeImageRegionHelper(void * arg) { - auto * workUnitInfo = static_cast(arg); - ThreadIdType workUnitID = workUnitInfo->WorkUnitID; - ThreadIdType workUnitCount = workUnitInfo->NumberOfWorkUnits; - auto * rnc = static_cast(workUnitInfo->UserData); + auto * workUnitInfo = static_cast(arg); + const ThreadIdType workUnitID = workUnitInfo->WorkUnitID; + const ThreadIdType workUnitCount = workUnitInfo->NumberOfWorkUnits; + auto * rnc = static_cast(workUnitInfo->UserData); const ImageRegionSplitterBase * splitter = ImageSourceCommon::GetGlobalDefaultSplitter(); ImageIORegion region(rnc->dimension); @@ -556,7 +556,7 @@ MultiThreaderBase::ParallelizeImageRegionHelper(void * arg) region.SetIndex(d, rnc->index[d]); region.SetSize(d, rnc->size[d]); } - ThreadIdType total = splitter->GetSplit(workUnitID, workUnitCount, region); + const ThreadIdType total = splitter->GetSplit(workUnitID, workUnitCount, region); TotalProgressReporter reporter(rnc->filter, 0); diff --git a/Modules/Core/Common/src/itkObject.cxx b/Modules/Core/Common/src/itkObject.cxx index e8d219fcb82..8d5ae04818f 100644 --- a/Modules/Core/Common/src/itkObject.cxx +++ b/Modules/Core/Common/src/itkObject.cxx @@ -154,7 +154,7 @@ Object::SubjectImplementation::InvokeEvent(const EventObject & event, Object * s // m_ListModified flag. The modified flag is save to the stack and // marked false before recursively saving the current list. - SaveRestoreListModified save(this); + const SaveRestoreListModified save(this); auto i = m_Observers.crbegin(); InvokeEventRecursion(event, self, i); @@ -163,7 +163,7 @@ Object::SubjectImplementation::InvokeEvent(const EventObject & event, Object * s void Object::SubjectImplementation::InvokeEvent(const EventObject & event, const Object * self) { - SaveRestoreListModified save(this); + const SaveRestoreListModified save(this); auto i = m_Observers.crbegin(); InvokeEventRecursion(event, self, i); diff --git a/Modules/Core/Common/src/itkObjectFactoryBase.cxx b/Modules/Core/Common/src/itkObjectFactoryBase.cxx index 5fa492f3c24..9afaa18954a 100644 --- a/Modules/Core/Common/src/itkObjectFactoryBase.cxx +++ b/Modules/Core/Common/src/itkObjectFactoryBase.cxx @@ -256,7 +256,7 @@ ObjectFactoryBase::LoadDynamicFactories() # ifdef _WIN32 char PathSeparator = ';'; # else - char PathSeparator = ':'; + const char PathSeparator = ':'; # endif const std::string itk_autoload_env{ "ITK_AUTOLOAD_PATH" }; @@ -286,7 +286,8 @@ ObjectFactoryBase::LoadDynamicFactories() EndSeparatorPosition = LoadPath.size() + 1; // Add 1 to simulate // having a separator } - std::string CurrentPath = LoadPath.substr(StartSeparatorPosition, EndSeparatorPosition - StartSeparatorPosition); + const std::string CurrentPath = + LoadPath.substr(StartSeparatorPosition, EndSeparatorPosition - StartSeparatorPosition); ObjectFactoryBase::LoadLibrariesInPath(CurrentPath.c_str()); @@ -353,7 +354,7 @@ NameIsSharedLibrary([[maybe_unused]] const char * name) #ifdef ITK_DYNAMIC_LOADING std::string extension = itksys::DynamicLoader::LibExtension(); - std::string sname = name; + const std::string sname = name; if (sname.rfind(extension) == sname.size() - extension.size()) { return true; @@ -399,8 +400,8 @@ ObjectFactoryBase::LoadLibrariesInPath(const char * path) */ if (NameIsSharedLibrary(file)) { - std::string fullpath = CreateFullPath(path, file); - LibHandle lib = DynamicLoader::OpenLibrary(fullpath.c_str()); + const std::string fullpath = CreateFullPath(path, file); + LibHandle lib = DynamicLoader::OpenLibrary(fullpath.c_str()); if (lib) { /** diff --git a/Modules/Core/Common/src/itkPlatformMultiThreaderPosix.cxx b/Modules/Core/Common/src/itkPlatformMultiThreaderPosix.cxx index e5e9046553c..eaf67615787 100644 --- a/Modules/Core/Common/src/itkPlatformMultiThreaderPosix.cxx +++ b/Modules/Core/Common/src/itkPlatformMultiThreaderPosix.cxx @@ -71,10 +71,10 @@ PlatformMultiThreader::MultipleMethodExecute() { m_ThreadInfoArray[thread_loop].UserData = m_MultipleData[thread_loop]; m_ThreadInfoArray[thread_loop].NumberOfWorkUnits = m_NumberOfWorkUnits; - int threadError = pthread_create(&(process_id[thread_loop]), - nullptr, - reinterpret_cast(m_MultipleMethod[thread_loop]), - ((void *)(&m_ThreadInfoArray[thread_loop]))); + const int threadError = pthread_create(&(process_id[thread_loop]), + nullptr, + reinterpret_cast(m_MultipleMethod[thread_loop]), + ((void *)(&m_ThreadInfoArray[thread_loop]))); if (threadError != 0) { itkExceptionMacro("Unable to create a thread. pthread_create() returned " << threadError); @@ -124,10 +124,10 @@ PlatformMultiThreader::SpawnThread(ThreadFunctionType f, void * UserData) m_SpawnedThreadInfoArray[id].ActiveFlag = &m_SpawnedThreadActiveFlag[id]; m_SpawnedThreadInfoArray[id].ActiveFlagLock = m_SpawnedThreadActiveFlagMutex[id]; - int threadError = pthread_create(&(m_SpawnedThreadProcessID[id]), - nullptr, - reinterpret_cast(f), - ((void *)(&m_SpawnedThreadInfoArray[id]))); + const int threadError = pthread_create(&(m_SpawnedThreadProcessID[id]), + nullptr, + reinterpret_cast(f), + ((void *)(&m_SpawnedThreadInfoArray[id]))); if (threadError != 0) { itkExceptionMacro("Unable to create a thread. pthread_create() returned " << threadError); @@ -170,10 +170,10 @@ PlatformMultiThreader::SpawnDispatchSingleMethodThread(PlatformMultiThreader::Wo { // Using POSIX threads pthread_t threadHandle; - int threadError = pthread_create(&threadHandle, - nullptr, - reinterpret_cast(this->SingleMethodProxy), - reinterpret_cast(threadInfo)); + const int threadError = pthread_create(&threadHandle, + nullptr, + reinterpret_cast(this->SingleMethodProxy), + reinterpret_cast(threadInfo)); if (threadError != 0) { itkExceptionMacro("Unable to create a thread. pthread_create() returned " << threadError); diff --git a/Modules/Core/Common/src/itkPoolMultiThreader.cxx b/Modules/Core/Common/src/itkPoolMultiThreader.cxx index 8201d82fc97..27bd8277163 100644 --- a/Modules/Core/Common/src/itkPoolMultiThreader.cxx +++ b/Modules/Core/Common/src/itkPoolMultiThreader.cxx @@ -107,7 +107,7 @@ void PoolMultiThreader::SetMaximumNumberOfThreads(ThreadIdType numberOfThreads) { Superclass::SetMaximumNumberOfThreads(numberOfThreads); - ThreadIdType threadCount = m_ThreadPool->GetMaximumNumberOfThreads(); + const ThreadIdType threadCount = m_ThreadPool->GetMaximumNumberOfThreads(); if (threadCount < m_MaximumNumberOfThreads) { m_ThreadPool->AddThreads(m_MaximumNumberOfThreads - threadCount); @@ -254,7 +254,7 @@ PoolMultiThreader::ParallelizeImageRegion(unsigned int dimension, else { const ImageRegionSplitterBase * splitter = ImageSourceCommon::GetGlobalDefaultSplitter(); - ThreadIdType splitCount = splitter->GetNumberOfSplits(region, m_NumberOfWorkUnits); + const ThreadIdType splitCount = splitter->GetNumberOfSplits(region, m_NumberOfWorkUnits); ProgressReporter reporter(filter, 0, splitCount); itkAssertOrThrowMacro(splitCount <= m_NumberOfWorkUnits, "Split count is greater than number of work units!"); ImageIORegion iRegion; diff --git a/Modules/Core/Common/src/itkProcessObject.cxx b/Modules/Core/Common/src/itkProcessObject.cxx index 4a8e6036c03..fd51e2c97cb 100644 --- a/Modules/Core/Common/src/itkProcessObject.cxx +++ b/Modules/Core/Common/src/itkProcessObject.cxx @@ -345,7 +345,7 @@ ProcessObject::PushFrontInput(const DataObject * input) void ProcessObject::PopFrontInput() { - DataObjectPointerArraySizeType nb = this->GetNumberOfIndexedInputs(); + const DataObjectPointerArraySizeType nb = this->GetNumberOfIndexedInputs(); if (nb > 0) { for (DataObjectPointerArraySizeType i = 1; i < nb; ++i) @@ -426,7 +426,7 @@ ProcessObject::SetOutput(const DataObjectIdentifierType & name, DataObject * out // copy the key, because it might be destroyed in that method, so a reference // is not enough. - DataObjectIdentifierType key = name; + const DataObjectIdentifierType key = name; if (key.empty()) { @@ -434,7 +434,7 @@ ProcessObject::SetOutput(const DataObjectIdentifierType & name, DataObject * out } // does this change anything? - DataObjectPointerMap::const_iterator it = m_Outputs.find(key); + const DataObjectPointerMap::const_iterator it = m_Outputs.find(key); if (it != m_Outputs.end() && it->second.GetPointer() == output) { return; @@ -462,7 +462,7 @@ ProcessObject::SetOutput(const DataObjectIdentifierType & name, DataObject * out if (!m_Outputs[key]) { itkDebugMacro(" creating new output object."); - DataObjectPointer newOutput = this->MakeOutput(key); + const DataObjectPointer newOutput = this->MakeOutput(key); this->SetOutput(key, newOutput); // If we had an output object before, copy the requested region @@ -1087,14 +1087,14 @@ ProcessObject::MakeIndexFromOutputName(const DataObjectIdentifierType & name) co ProcessObject::DataObjectPointerArraySizeType ProcessObject::MakeIndexFromName(const DataObjectIdentifierType & name) const { - DataObjectIdentifierType baseName = "_"; - DataObjectPointerArraySizeType baseSize = baseName.size(); + const DataObjectIdentifierType baseName = "_"; + const DataObjectPointerArraySizeType baseSize = baseName.size(); if (name.size() <= baseSize || name.substr(0, baseSize) != baseName) { itkDebugMacro("MakeIndexFromName(" << name << ") -> exception bad base name"); itkExceptionMacro("Not an indexed data object: " << name); } - DataObjectIdentifierType idxStr = name.substr(baseSize); + const DataObjectIdentifierType idxStr = name.substr(baseSize); DataObjectPointerArraySizeType idx; if (!(std::istringstream(idxStr) >> idx)) { @@ -1156,11 +1156,11 @@ void ProcessObject::IncrementProgress(float increment) { // Clamp the value to be between 0 and 1. - uint32_t integerIncrement = progressFloatToFixed(increment); + const uint32_t integerIncrement = progressFloatToFixed(increment); - uint32_t oldProgress = m_Progress.fetch_add(integerIncrement); + const uint32_t oldProgress = m_Progress.fetch_add(integerIncrement); - uint32_t updatedProgress = m_Progress; + const uint32_t updatedProgress = m_Progress; // check if progress overflowed if (oldProgress > updatedProgress) @@ -1204,7 +1204,7 @@ ProcessObject::PrintSelf(std::ostream & os, Indent indent) const { Superclass::PrintSelf(os, indent); - Indent indent2 = indent.GetNextIndent(); + const Indent indent2 = indent.GetNextIndent(); if (!m_Inputs.empty()) { os << indent << "Inputs: " << std::endl; @@ -1573,9 +1573,9 @@ ProcessObject::SetMultiThreader(MultiThreaderType * threader) } else { - ThreadIdType oldDefaultNumber = m_MultiThreader->GetNumberOfWorkUnits(); + const ThreadIdType oldDefaultNumber = m_MultiThreader->GetNumberOfWorkUnits(); this->m_MultiThreader = threader; - ThreadIdType newDefaultNumber = m_MultiThreader->GetNumberOfWorkUnits(); + const ThreadIdType newDefaultNumber = m_MultiThreader->GetNumberOfWorkUnits(); if (m_NumberOfWorkUnits == oldDefaultNumber) { m_NumberOfWorkUnits = newDefaultNumber; diff --git a/Modules/Core/Common/src/itkProgressAccumulator.cxx b/Modules/Core/Common/src/itkProgressAccumulator.cxx index 41205a91675..2d7f21cc9ba 100644 --- a/Modules/Core/Common/src/itkProgressAccumulator.cxx +++ b/Modules/Core/Common/src/itkProgressAccumulator.cxx @@ -38,8 +38,8 @@ void ProgressAccumulator::RegisterInternalFilter(GenericFilterType * filter, float weight) { // Observe the filter - unsigned long progressTag = filter->AddObserver(ProgressEvent(), m_CallbackCommand); - unsigned long startTag = filter->AddObserver(StartEvent(), m_CallbackCommand); + const unsigned long progressTag = filter->AddObserver(ProgressEvent(), m_CallbackCommand); + const unsigned long startTag = filter->AddObserver(StartEvent(), m_CallbackCommand); // Create a record for the filter struct FilterRecord record; @@ -101,8 +101,8 @@ ProgressAccumulator::ResetFilterProgressAndKeepAccumulatedProgress() void ProgressAccumulator::ReportProgress(Object * who, const EventObject & event) { - ProgressEvent pe; - StartEvent se; + const ProgressEvent pe; + const StartEvent se; if (typeid(event) == typeid(pe)) { @@ -113,7 +113,7 @@ ProgressAccumulator::ReportProgress(Object * who, const EventObject & event) FilterRecordVector::iterator it; for (it = m_FilterRecord.begin(); it != m_FilterRecord.end(); ++it) { - float progress = it->Filter->GetProgress(); + const float progress = it->Filter->GetProgress(); if (progress != it->AccumulatedProgress) { m_AccumulatedProgress += progress * it->Weight; diff --git a/Modules/Core/Common/src/itkProgressReporter.cxx b/Modules/Core/Common/src/itkProgressReporter.cxx index e16be9d8934..64e909e390b 100644 --- a/Modules/Core/Common/src/itkProgressReporter.cxx +++ b/Modules/Core/Common/src/itkProgressReporter.cxx @@ -65,8 +65,8 @@ ProgressReporter::~ProgressReporter() // Set the progress to the end of its current range. // Make sure it increases the progress, in case multiple reporters // were used inside filter's GenerateData(). - float newProgress = m_InitialProgress + m_ProgressWeight; - float oldProgress = m_Filter->GetProgress(); + const float newProgress = m_InitialProgress + m_ProgressWeight; + const float oldProgress = m_Filter->GetProgress(); if (newProgress > oldProgress) { m_Filter->UpdateProgress(m_InitialProgress + m_ProgressWeight); diff --git a/Modules/Core/Common/src/itkRealTimeClock.cxx b/Modules/Core/Common/src/itkRealTimeClock.cxx index 81b4793d43f..90a1fd03b22 100644 --- a/Modules/Core/Common/src/itkRealTimeClock.cxx +++ b/Modules/Core/Common/src/itkRealTimeClock.cxx @@ -85,7 +85,7 @@ RealTimeClock::GetTimeInSeconds() const struct timeval tval; ::gettimeofday(&tval, nullptr); - TimeStampType value = + const TimeStampType value = static_cast(tval.tv_sec) + static_cast(tval.tv_usec) / m_Frequency; return value; #endif // defined(WIN32) || defined(_WIN32) diff --git a/Modules/Core/Common/src/itkStreamingProcessObject.cxx b/Modules/Core/Common/src/itkStreamingProcessObject.cxx index c70ab967ae8..141dadf2632 100644 --- a/Modules/Core/Common/src/itkStreamingProcessObject.cxx +++ b/Modules/Core/Common/src/itkStreamingProcessObject.cxx @@ -36,7 +36,7 @@ StreamingProcessObject::GenerateData() // minimum of what the user specified via SetNumberOfStreamDivisions() // and what the Splitter thinks is a reasonable value. // - unsigned int numberOfInputRequestRegion = this->GetNumberOfInputRequestedRegions(); + const unsigned int numberOfInputRequestRegion = this->GetNumberOfInputRequestedRegions(); // // Loop over the number of pieces, execute the upstream pipeline on each diff --git a/Modules/Core/Common/src/itkTBBMultiThreader.cxx b/Modules/Core/Common/src/itkTBBMultiThreader.cxx index 7c49cac55e4..03b844ea342 100644 --- a/Modules/Core/Common/src/itkTBBMultiThreader.cxx +++ b/Modules/Core/Common/src/itkTBBMultiThreader.cxx @@ -35,7 +35,7 @@ get_default_num_threads() #if __TBB_MIC_OFFLOAD # pragma offload target(mic) out(default_num_threads) #endif // __TBB_MIC_OFFLOAD - static const size_t default_num_threads = + const static size_t default_num_threads = tbb::global_control::active_value(tbb::global_control::max_allowed_parallelism); return static_cast(default_num_threads); } diff --git a/Modules/Core/Common/src/itkThreadLogger.cxx b/Modules/Core/Common/src/itkThreadLogger.cxx index 9bd3b94c490..1bb0dde22fb 100644 --- a/Modules/Core/Common/src/itkThreadLogger.cxx +++ b/Modules/Core/Common/src/itkThreadLogger.cxx @@ -50,7 +50,7 @@ Logger::PriorityLevelEnum ThreadLogger::GetPriorityLevel() const { const std::lock_guard lockGuard(m_Mutex); - PriorityLevelEnum level = this->m_PriorityLevel; + const PriorityLevelEnum level = this->m_PriorityLevel; return level; } @@ -67,7 +67,7 @@ Logger::PriorityLevelEnum ThreadLogger::GetLevelForFlushing() const { const std::lock_guard lockGuard(m_Mutex); - PriorityLevelEnum level = this->m_LevelForFlushing; + const PriorityLevelEnum level = this->m_LevelForFlushing; return level; } @@ -82,7 +82,7 @@ ThreadLogger::DelayType ThreadLogger::GetDelay() const { const std::lock_guard lockGuard(m_Mutex); - DelayType delay = this->m_Delay; + const DelayType delay = this->m_Delay; return delay; } diff --git a/Modules/Core/Common/src/itkThreadPool.cxx b/Modules/Core/Common/src/itkThreadPool.cxx index 57065659fa3..1b4dd517eb7 100644 --- a/Modules/Core/Common/src/itkThreadPool.cxx +++ b/Modules/Core/Common/src/itkThreadPool.cxx @@ -111,7 +111,7 @@ ThreadPool::ThreadPool() m_PimplGlobals->m_ThreadPoolInstance = this; // threads need this m_PimplGlobals->m_ThreadPoolInstance->UnRegister(); // Remove extra reference - ThreadIdType threadCount = MultiThreaderBase::GetGlobalDefaultNumberOfThreads(); + const ThreadIdType threadCount = MultiThreaderBase::GetGlobalDefaultNumberOfThreads(); m_Threads.reserve(threadCount); for (ThreadIdType i = 0; i < threadCount; ++i) { @@ -179,8 +179,8 @@ ThreadPool::PrepareForFork() void ThreadPool::ResumeFromFork() { - ThreadPool * instance = m_PimplGlobals->m_ThreadPoolInstance.GetPointer(); - ThreadIdType threadCount = instance->m_Threads.size(); + ThreadPool * instance = m_PimplGlobals->m_ThreadPoolInstance.GetPointer(); + const ThreadIdType threadCount = instance->m_Threads.size(); instance->m_Threads.clear(); instance->m_Stopping = false; instance->AddThreads(threadCount); diff --git a/Modules/Core/Common/src/itkThreadedIndexedContainerPartitioner.cxx b/Modules/Core/Common/src/itkThreadedIndexedContainerPartitioner.cxx index 679bf275436..b50e4f558ed 100644 --- a/Modules/Core/Common/src/itkThreadedIndexedContainerPartitioner.cxx +++ b/Modules/Core/Common/src/itkThreadedIndexedContainerPartitioner.cxx @@ -34,9 +34,9 @@ ThreadedIndexedContainerPartitioner::PartitionDomain(const ThreadIdType threadId // completeIndexRange and subIndexRange are inclusive // determine the actual number of pieces that will be generated - const auto count = static_cast(completeIndexRange[1] - completeIndexRange[0] + 1); - auto valuesPerThread = Math::Ceil(count / static_cast(requestedTotal)); - ThreadIdType maxThreadIdUsed = Math::Ceil(count / static_cast(valuesPerThread)) - 1; + const auto count = static_cast(completeIndexRange[1] - completeIndexRange[0] + 1); + auto valuesPerThread = Math::Ceil(count / static_cast(requestedTotal)); + const ThreadIdType maxThreadIdUsed = Math::Ceil(count / static_cast(valuesPerThread)) - 1; // Split the index range if (threadId < maxThreadIdUsed) diff --git a/Modules/Core/Common/src/itkTotalProgressReporter.cxx b/Modules/Core/Common/src/itkTotalProgressReporter.cxx index 4d318abd092..450b36ca5db 100644 --- a/Modules/Core/Common/src/itkTotalProgressReporter.cxx +++ b/Modules/Core/Common/src/itkTotalProgressReporter.cxx @@ -51,7 +51,7 @@ TotalProgressReporter::TotalProgressReporter(ProcessObject * filter, //---------------------------------------------------------------------------- TotalProgressReporter::~TotalProgressReporter() { - SizeValueType pixelRemnants = m_PixelsPerUpdate - m_PixelsBeforeUpdate; + const SizeValueType pixelRemnants = m_PixelsPerUpdate - m_PixelsBeforeUpdate; if (pixelRemnants != 0 && m_Filter) { diff --git a/Modules/Core/Common/test/SharedTestLibraryA.cxx b/Modules/Core/Common/test/SharedTestLibraryA.cxx index 81da43b5373..ae45ad0db1d 100644 --- a/Modules/Core/Common/test/SharedTestLibraryA.cxx +++ b/Modules/Core/Common/test/SharedTestLibraryA.cxx @@ -21,5 +21,5 @@ void bar() { using ImageType = itk::Image; - ImageType::Pointer image = ImageType::New(); + const ImageType::Pointer image = ImageType::New(); } diff --git a/Modules/Core/Common/test/SharedTestLibraryB.cxx b/Modules/Core/Common/test/SharedTestLibraryB.cxx index b939073cd99..b98bf044447 100644 --- a/Modules/Core/Common/test/SharedTestLibraryB.cxx +++ b/Modules/Core/Common/test/SharedTestLibraryB.cxx @@ -21,5 +21,5 @@ void foo() { using ImageType = itk::Image; - ImageType::Pointer image = ImageType::New(); + const ImageType::Pointer image = ImageType::New(); } diff --git a/Modules/Core/Common/test/VNLSparseLUSolverTraitsTest.cxx b/Modules/Core/Common/test/VNLSparseLUSolverTraitsTest.cxx index 17b975b59b2..b19b207337c 100644 --- a/Modules/Core/Common/test/VNLSparseLUSolverTraitsTest.cxx +++ b/Modules/Core/Common/test/VNLSparseLUSolverTraitsTest.cxx @@ -59,8 +59,8 @@ VNLSparseLUSolverTraitsTest(int, char *[]) /** * Build the linear system to solve */ - unsigned int N = 3; - VectorType Bx = SolverTraits::InitializeVector(N); + const unsigned int N = 3; + VectorType Bx = SolverTraits::InitializeVector(N); Bx.fill(0.); Bx[0] = 2.1; @@ -86,7 +86,7 @@ VNLSparseLUSolverTraitsTest(int, char *[]) /** * Define the tolerance and expected results */ - CoordinateType tolerance = 1e-9; + const CoordinateType tolerance = 1e-9; VectorType Xexpected(N); Xexpected(0) = 1.575; diff --git a/Modules/Core/Common/test/itkAbortProcessObjectTest.cxx b/Modules/Core/Common/test/itkAbortProcessObjectTest.cxx index d0556dc8437..1a30812ecd9 100644 --- a/Modules/Core/Common/test/itkAbortProcessObjectTest.cxx +++ b/Modules/Core/Common/test/itkAbortProcessObjectTest.cxx @@ -35,7 +35,7 @@ bool onAbortCalled = false; void onProgress(itk::Object * obj, const itk::EventObject &, void *) { - itk::ProcessObject::Pointer p(dynamic_cast(obj)); + const itk::ProcessObject::Pointer p(dynamic_cast(obj)); if (p.IsNull()) { return; @@ -64,9 +64,9 @@ itkAbortProcessObjectTest(int, char *[]) auto img = ShortImage::New(); // fill in an image - const ShortImage::IndexType index = { { 0, 0 } }; - const ShortImage::SizeType size = { { 100, 100 } }; - ShortImage::RegionType region{ index, size }; + const ShortImage::IndexType index = { { 0, 0 } }; + const ShortImage::SizeType size = { { 100, 100 } }; + const ShortImage::RegionType region{ index, size }; img->SetRegions(region); img->Allocate(); @@ -85,17 +85,17 @@ itkAbortProcessObjectTest(int, char *[]) extract->SetInput(img); // fill in an image - ShortImage::IndexType extractIndex = { { 0, 0 } }; - ShortImage::SizeType extractSize = { { 99, 99 } }; - ShortImage::RegionType extractRegion{ extractIndex, extractSize }; + const ShortImage::IndexType extractIndex = { { 0, 0 } }; + const ShortImage::SizeType extractSize = { { 99, 99 } }; + const ShortImage::RegionType extractRegion{ extractIndex, extractSize }; extract->SetExtractionRegion(extractRegion); - itk::CStyleCommand::Pointer progressCmd = itk::CStyleCommand::New(); + const itk::CStyleCommand::Pointer progressCmd = itk::CStyleCommand::New(); progressCmd->SetCallback(onProgress); progressCmd->SetObjectName("Progress Event"); extract->AddObserver(itk::ProgressEvent(), progressCmd); - itk::CStyleCommand::Pointer abortCmd = itk::CStyleCommand::New(); + const itk::CStyleCommand::Pointer abortCmd = itk::CStyleCommand::New(); abortCmd->SetCallback(onAbort); abortCmd->SetObjectName("Abort Event"); extract->AddObserver(itk::AbortEvent(), abortCmd); diff --git a/Modules/Core/Common/test/itkAggregateTypesGTest.cxx b/Modules/Core/Common/test/itkAggregateTypesGTest.cxx index 2fcd8027019..6c162e325b4 100644 --- a/Modules/Core/Common/test/itkAggregateTypesGTest.cxx +++ b/Modules/Core/Common/test/itkAggregateTypesGTest.cxx @@ -338,7 +338,7 @@ TEST(Specialized, Index) ITK_EXPECT_VECTOR_NEAR(IndexType::GetBasisIndex(2), twoBasis, 0); ITK_EXPECT_VECTOR_NEAR(IndexType::GetBasisIndex(3), threeBasis, 0); - IndexType known3s{ { 3, 3, 3, 3 } }; + const IndexType known3s{ { 3, 3, 3, 3 } }; IndexType threes; IndexType::IndexValueType raw3s[4] = { 3, 3, 3, 3 }; threes.SetIndex(raw3s); @@ -362,7 +362,7 @@ TEST(Specialized, Offset) ITK_EXPECT_VECTOR_NEAR(OffsetType::GetBasisOffset(2), twoBasis, 0); ITK_EXPECT_VECTOR_NEAR(OffsetType::GetBasisOffset(3), threeBasis, 0); - OffsetType known3s{ { 3, 3, 3, 3 } }; + const OffsetType known3s{ { 3, 3, 3, 3 } }; OffsetType threes; OffsetType::OffsetValueType raw3s[4] = { 3, 3, 3, 3 }; threes.SetOffset(raw3s); @@ -375,7 +375,7 @@ TEST(Specialized, Size) EXPECT_EQ(itk::Size<7>::GetSizeDimension(), 7); using SizeType = itk::Size<4>; - SizeType known3s{ { 3, 3, 3, 3 } }; + const SizeType known3s{ { 3, 3, 3, 3 } }; SizeType threes; SizeType::SizeValueType raw3s[4] = { 3, 3, 3, 3 }; threes.SetSize(raw3s); diff --git a/Modules/Core/Common/test/itkAnatomicalOrientationGTest.cxx b/Modules/Core/Common/test/itkAnatomicalOrientationGTest.cxx index 4be819bfd80..0ab25663ee5 100644 --- a/Modules/Core/Common/test/itkAnatomicalOrientationGTest.cxx +++ b/Modules/Core/Common/test/itkAnatomicalOrientationGTest.cxx @@ -101,7 +101,7 @@ TEST(AnatomicalOrientation, ConstructionAndValues) d(0, 2) = -1.0; EXPECT_EQ(d, do1.GetAsDirection()); - AnatomicalOrientation do2(d); + const AnatomicalOrientation do2(d); EXPECT_EQ("PIR", do2.GetAsPositiveStringEncoding()); EXPECT_EQ(CE::AnteriorToPosterior, do2.GetPrimaryTerm()); @@ -112,7 +112,7 @@ TEST(AnatomicalOrientation, ConstructionAndValues) EXPECT_EQ(d, do2.GetAsDirection()); - AnatomicalOrientation do3 = AnatomicalOrientation::CreateFromPositiveStringEncoding("something invalid"); + const AnatomicalOrientation do3 = AnatomicalOrientation::CreateFromPositiveStringEncoding("something invalid"); EXPECT_EQ("INVALID", do3.GetAsPositiveStringEncoding()); EXPECT_EQ(CE::UNKNOWN, do3.GetPrimaryTerm()); EXPECT_EQ(CE::UNKNOWN, do3.GetSecondaryTerm()); @@ -168,10 +168,10 @@ TEST(AnatomicalOrientation, ConvertDirectionToPositiveEnum) d(0, 2) = 1; EXPECT_EQ(OE::SPL, AnatomicalOrientation(d)); - const itk::SpacePrecisionType data[] = { 0.5986634407395047, 0.22716302314740483, -0.768113953548866, - 0.5627936241740271, 0.563067040943212, 0.6051601804419384, - 0.5699696670095713, -0.794576911518317, 0.20924175102261847 }; - ImageType::DirectionType::InternalMatrixType m{ data }; + const itk::SpacePrecisionType data[] = { 0.5986634407395047, 0.22716302314740483, -0.768113953548866, + 0.5627936241740271, 0.563067040943212, 0.6051601804419384, + 0.5699696670095713, -0.794576911518317, 0.20924175102261847 }; + const ImageType::DirectionType::InternalMatrixType m{ data }; d.GetVnlMatrix() = m; EXPECT_EQ(OE::PIR, AnatomicalOrientation(d)); } @@ -238,7 +238,7 @@ TEST(AntomicalOrientation, ToFromEnumInteroperability) static_assert(int(OE::PIR) == int(FromOE::ASL)); static_assert(int(OE::ASL) == int(FromOE::PIR)); - itk::AnatomicalOrientation itk_rai(FromOE::RAI); + const itk::AnatomicalOrientation itk_rai(FromOE::RAI); EXPECT_EQ(itk_rai, itk::AnatomicalOrientation(OE::LPS)); EXPECT_EQ(itk_rai.GetAsPositiveOrientation(), OE::LPS); @@ -261,7 +261,7 @@ TEST(AnatomicalOrientation, LegacyInteroperability) static_assert(int(SOE::ITK_COORDINATE_ORIENTATION_RSA) == int(OE::LIP)); static_assert(int(SOE::ITK_COORDINATE_ORIENTATION_ASL) == int(OE::PIR)); - itk::AnatomicalOrientation itk_rai(SOE::ITK_COORDINATE_ORIENTATION_RAI); + const itk::AnatomicalOrientation itk_rai(SOE::ITK_COORDINATE_ORIENTATION_RAI); EXPECT_EQ(itk_rai, OE::LPS); EXPECT_EQ(itk_rai.GetAsPositiveOrientation(), OE::LPS); EXPECT_EQ(itk_rai.GetAsPositiveStringEncoding(), "LPS"); diff --git a/Modules/Core/Common/test/itkAnnulusOperatorTest.cxx b/Modules/Core/Common/test/itkAnnulusOperatorTest.cxx index 928f6f65d66..2aeb5c753b2 100644 --- a/Modules/Core/Common/test/itkAnnulusOperatorTest.cxx +++ b/Modules/Core/Common/test/itkAnnulusOperatorTest.cxx @@ -26,7 +26,7 @@ itkAnnulusOperatorTest(int, char *[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope // scope. - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); constexpr unsigned int Dimension = 2; using PixelType = float; diff --git a/Modules/Core/Common/test/itkArrayTest.cxx b/Modules/Core/Common/test/itkArrayTest.cxx index 706e9ede389..e903a48b2b7 100644 --- a/Modules/Core/Common/test/itkArrayTest.cxx +++ b/Modules/Core/Common/test/itkArrayTest.cxx @@ -28,8 +28,8 @@ itkArrayTest(int, char *[]) using FloatArrayType = itk::Array; using DoubleArrayType = itk::Array; - FloatArrayType fa(10); - DoubleArrayType da(10); + const FloatArrayType fa(10); + const DoubleArrayType da(10); /** * The following section tests the functionality of the Array's @@ -109,7 +109,7 @@ itkArrayTest(int, char *[]) objectToCopy.SetDataSameSize(data); // This implicitly means LetArrayManageMemory=false // Make a copy of the array which is not managing its own memory. - FloatArrayType copy(objectToCopy); + const FloatArrayType copy(objectToCopy); // DO a double // diff --git a/Modules/Core/Common/test/itkAtanRegularizedHeavisideStepFunctionTest1.cxx b/Modules/Core/Common/test/itkAtanRegularizedHeavisideStepFunctionTest1.cxx index 7c21e46b6f0..395b748dd72 100644 --- a/Modules/Core/Common/test/itkAtanRegularizedHeavisideStepFunctionTest1.cxx +++ b/Modules/Core/Common/test/itkAtanRegularizedHeavisideStepFunctionTest1.cxx @@ -55,9 +55,9 @@ itkAtanRegularizedHeavisideStepFunctionTest1(int, char *[]) for (int x = minValue; x < maxValue; ++x) { - const InputType ix = x * incValue; - OutputType f = functionBase0->Evaluate(ix); - OutputType df = functionBase0->EvaluateDerivative(ix); + const InputType ix = x * incValue; + const OutputType f = functionBase0->Evaluate(ix); + const OutputType df = functionBase0->EvaluateDerivative(ix); std::cout << ix << ' ' << f << ' ' << df << std::endl; } diff --git a/Modules/Core/Common/test/itkAutoPointerTest.cxx b/Modules/Core/Common/test/itkAutoPointerTest.cxx index ecfc906a79b..b6c0634bebe 100644 --- a/Modules/Core/Common/test/itkAutoPointerTest.cxx +++ b/Modules/Core/Common/test/itkAutoPointerTest.cxx @@ -83,7 +83,7 @@ itkAutoPointerTest(int, char *[]) cptr1.TakeOwnership(new TestObject); - TestObject::ConstAutoPointer cptr2(cptr1); + const TestObject::ConstAutoPointer cptr2(cptr1); return EXIT_SUCCESS; diff --git a/Modules/Core/Common/test/itkBSplineInterpolationWeightFunctionTest.cxx b/Modules/Core/Common/test/itkBSplineInterpolationWeightFunctionTest.cxx index 01f739df312..97c81be2bc2 100644 --- a/Modules/Core/Common/test/itkBSplineInterpolationWeightFunctionTest.cxx +++ b/Modules/Core/Common/test/itkBSplineInterpolationWeightFunctionTest.cxx @@ -249,8 +249,8 @@ itkBSplineInterpolationWeightFunctionTest(int, char *[]) auto function = FunctionType::New(); function->Print(std::cout); - SizeType size = FunctionType::SupportSize; - unsigned long numberOfWeights = FunctionType::NumberOfWeights; + const SizeType size = FunctionType::SupportSize; + const unsigned long numberOfWeights = FunctionType::NumberOfWeights; std::cout << "Number Of Weights: " << numberOfWeights << std::endl; @@ -275,8 +275,8 @@ itkBSplineInterpolationWeightFunctionTest(int, char *[]) auto kernel = KernelType::New(); using ImageType = itk::Image; - auto image = ImageType::New(); - ImageType::RegionType region{ startIndex, size }; + auto image = ImageType::New(); + const ImageType::RegionType region{ startIndex, size }; image->SetRegions(region); image->AllocateInitialized(); diff --git a/Modules/Core/Common/test/itkBSplineKernelFunctionTest.cxx b/Modules/Core/Common/test/itkBSplineKernelFunctionTest.cxx index 9022ed05ba6..ba2d55e7612 100644 --- a/Modules/Core/Common/test/itkBSplineKernelFunctionTest.cxx +++ b/Modules/Core/Common/test/itkBSplineKernelFunctionTest.cxx @@ -97,9 +97,9 @@ itkBSplineKernelFunctionTest(int, char *[]) auto derivFunction = DerivativeFunctionType::New(); derivFunction->Print(std::cout); - double xx = -0.25; - double expectedValue = 0.0; - double results = derivFunction->Evaluate(xx); + const double xx = -0.25; + const double expectedValue = 0.0; + const double results = derivFunction->Evaluate(xx); const double epsilon = 1e-6; if (itk::Math::abs(results - expectedValue) > epsilon) @@ -125,8 +125,8 @@ itkBSplineKernelFunctionTest(int, char *[]) for (double xx = -3.0; xx <= 3.0; xx += 0.1) { - double expectedValue = function->Evaluate(xx + 0.5) - function->Evaluate(xx - 0.5); - double results = derivFunction->Evaluate(xx); + const double expectedValue = function->Evaluate(xx + 0.5) - function->Evaluate(xx - 0.5); + const double results = derivFunction->Evaluate(xx); const double epsilon = 1e-6; if (itk::Math::abs(results - expectedValue) > epsilon) @@ -154,8 +154,8 @@ itkBSplineKernelFunctionTest(int, char *[]) for (double xx = -3.0; xx <= 3.0; xx += 0.1) { - double expectedValue = function->Evaluate(xx + 0.5) - function->Evaluate(xx - 0.5); - double results = derivFunction->Evaluate(xx); + const double expectedValue = function->Evaluate(xx + 0.5) - function->Evaluate(xx - 0.5); + const double results = derivFunction->Evaluate(xx); const double epsilon = 1e-6; if (itk::Math::abs(results - expectedValue) > epsilon) @@ -183,8 +183,8 @@ itkBSplineKernelFunctionTest(int, char *[]) for (double xx = -3.0; xx <= 3.0; xx += 0.1) { - double expectedValue = function->Evaluate(xx + 0.5) - function->Evaluate(xx - 0.5); - double results = derivFunction->Evaluate(xx); + const double expectedValue = function->Evaluate(xx + 0.5) - function->Evaluate(xx - 0.5); + const double results = derivFunction->Evaluate(xx); const double epsilon = 1e-6; if (itk::Math::abs(results - expectedValue) > epsilon) diff --git a/Modules/Core/Common/test/itkBoundaryConditionTest.cxx b/Modules/Core/Common/test/itkBoundaryConditionTest.cxx index d2d3059e122..b495d8868ff 100644 --- a/Modules/Core/Common/test/itkBoundaryConditionTest.cxx +++ b/Modules/Core/Common/test/itkBoundaryConditionTest.cxx @@ -129,9 +129,9 @@ itkBoundaryConditionTest(int, char *[]) image3D->Allocate(); imageND->Allocate(); - itk::ImageRegionIterator it2D(image2D, image2D->GetRequestedRegion()); - itk::ImageRegionIterator it3D(image3D, image3D->GetRequestedRegion()); - itk::ImageRegionIterator itND(imageND, imageND->GetRequestedRegion()); + const itk::ImageRegionIterator it2D(image2D, image2D->GetRequestedRegion()); + itk::ImageRegionIterator it3D(image3D, image3D->GetRequestedRegion()); + itk::ImageRegionIterator itND(imageND, imageND->GetRequestedRegion()); println("Initializing some images"); diff --git a/Modules/Core/Common/test/itkBoundingBoxTest.cxx b/Modules/Core/Common/test/itkBoundingBoxTest.cxx index f80c0b7bb1c..b6ec7d45b18 100644 --- a/Modules/Core/Common/test/itkBoundingBoxTest.cxx +++ b/Modules/Core/Common/test/itkBoundingBoxTest.cxx @@ -31,7 +31,7 @@ itkBoundingBoxTest(int, char *[]) using BB = itk::BoundingBox; auto myBox = BB::New(); - BB::PointsContainerPointer Points = BB::PointsContainer::New(); + const BB::PointsContainerPointer Points = BB::PointsContainer::New(); itk::Point P; @@ -125,7 +125,7 @@ itkBoundingBoxTest(int, char *[]) } std::cout << "GetDiagonalLength2 passed" << std::endl; - BB::PointsContainerConstPointer NewPoints = myBox->GetPoints(); + const BB::PointsContainerConstPointer NewPoints = myBox->GetPoints(); // End with a Print. myBox->Print(std::cout); @@ -137,10 +137,10 @@ itkBoundingBoxTest(int, char *[]) using CC = itk::BoundingBox; auto my3DBox = CC::New(); - CC::PointsContainerPointer Points3D = CC::PointsContainer::New(); + const CC::PointsContainerPointer Points3D = CC::PointsContainer::New(); - CC::PointType::ValueType qval1[3] = { -1.0f, -1.0f, -1.0f }; - CC::PointType Q = qval1; + const CC::PointType::ValueType qval1[3] = { -1.0f, -1.0f, -1.0f }; + CC::PointType Q = qval1; Points3D->InsertElement(0, Q); CC::PointType::ValueType qval2[3] = { 1.0f, 1.0f, 1.0f }; @@ -195,7 +195,7 @@ itkBoundingBoxTest(int, char *[]) // Testing the DeepCopy method { const double tolerance = 1e-10; - CC::Pointer clone = my3DBox->DeepCopy(); + const CC::Pointer clone = my3DBox->DeepCopy(); const CC::BoundsArrayType & originalBounds = my3DBox->GetBounds(); const CC::BoundsArrayType & clonedbounds = clone->GetBounds(); for (unsigned int i = 0; i < originalBounds.Size(); ++i) diff --git a/Modules/Core/Common/test/itkBuildInformationGTest.cxx b/Modules/Core/Common/test/itkBuildInformationGTest.cxx index 19aebcceeff..0759c7862df 100644 --- a/Modules/Core/Common/test/itkBuildInformationGTest.cxx +++ b/Modules/Core/Common/test/itkBuildInformationGTest.cxx @@ -32,7 +32,7 @@ TEST(ITKBuildInformation, InformationFeatures) { using MapType = itk::BuildInformation::MapType; - itk::BuildInformation::Pointer instance = itk::BuildInformation::GetInstance(); + const itk::BuildInformation::Pointer instance = itk::BuildInformation::GetInstance(); EXPECT_EQ(instance.IsNull(), false); diff --git a/Modules/Core/Common/test/itkByteSwapTest.cxx b/Modules/Core/Common/test/itkByteSwapTest.cxx index cfa5bf1236b..9f5067d5e9a 100644 --- a/Modules/Core/Common/test/itkByteSwapTest.cxx +++ b/Modules/Core/Common/test/itkByteSwapTest.cxx @@ -38,8 +38,8 @@ itkByteSwapTest(int, char *[]) return EXIT_FAILURE; } - unsigned char uc = 'a'; - unsigned char uc1 = 'a'; + unsigned char uc = 'a'; + const unsigned char uc1 = 'a'; if constexpr (itk::ByteSwapper::SystemIsBigEndian()) { itk::ByteSwapper::SwapFromSystemToLittleEndian(&uc); @@ -56,8 +56,8 @@ itkByteSwapTest(int, char *[]) } std::cout << "Passed unsigned char: " << uc << std::endl; - unsigned short us = 1; - unsigned short us1 = 1; + unsigned short us = 1; + const unsigned short us1 = 1; if constexpr (itk::ByteSwapper::SystemIsBE()) { itk::ByteSwapper::SwapFromSystemToLittleEndian(&us); @@ -73,8 +73,8 @@ itkByteSwapTest(int, char *[]) return EXIT_FAILURE; } std::cout << "Passed unsigned short: " << us << std::endl; - unsigned int ui = 1; - unsigned int ui1 = 1; + unsigned int ui = 1; + const unsigned int ui1 = 1; if constexpr (itk::ByteSwapper::SystemIsBigEndian()) { itk::ByteSwapper::SwapFromSystemToLittleEndian(&ui); @@ -91,8 +91,8 @@ itkByteSwapTest(int, char *[]) } std::cout << "Passed unsigned int: " << ui << std::endl; - unsigned long ul = 1; - unsigned long ul1 = 1; + unsigned long ul = 1; + const unsigned long ul1 = 1; try { if constexpr (itk::ByteSwapper::SystemIsBigEndian()) @@ -117,8 +117,8 @@ itkByteSwapTest(int, char *[]) err.Print(std::cerr); } - unsigned long long ull = 1; - unsigned long long ull1 = 1; + unsigned long long ull = 1; + const unsigned long long ull1 = 1; try { if constexpr (itk::ByteSwapper::SystemIsBigEndian()) @@ -143,8 +143,8 @@ itkByteSwapTest(int, char *[]) err.Print(std::cerr); } - float f = 1.0; - float f1 = 1.0; + float f = 1.0; + const float f1 = 1.0; try { if constexpr (itk::ByteSwapper::SystemIsBigEndian()) @@ -170,8 +170,8 @@ itkByteSwapTest(int, char *[]) return EXIT_FAILURE; } - double d = 1.0; - double d1 = 1.0; + double d = 1.0; + const double d1 = 1.0; try { if constexpr (itk::ByteSwapper::SystemIsBigEndian()) diff --git a/Modules/Core/Common/test/itkCMakeConfigurationTest.cxx b/Modules/Core/Common/test/itkCMakeConfigurationTest.cxx index e7880829d58..a88fef85758 100644 --- a/Modules/Core/Common/test/itkCMakeConfigurationTest.cxx +++ b/Modules/Core/Common/test/itkCMakeConfigurationTest.cxx @@ -54,7 +54,7 @@ itkCMakeInformationPrintFile(const char * name, std::ostream & os) os << " has " << fs.st_size << " bytes"; } - std::ifstream fin(name); + const std::ifstream fin(name); if (fin) { const char * div = "======================================================================="; @@ -86,7 +86,7 @@ main(int argc, char * argv[]) for (const char ** f = files; *f; ++f) { - std::string fname = build_dir + *f; + const std::string fname = build_dir + *f; itkCMakeInformationPrintFile(fname.c_str(), std::cout); } return EXIT_SUCCESS; diff --git a/Modules/Core/Common/test/itkColorTableTest.cxx b/Modules/Core/Common/test/itkColorTableTest.cxx index baf713abdcd..cb3d4f2fc0f 100644 --- a/Modules/Core/Common/test/itkColorTableTest.cxx +++ b/Modules/Core/Common/test/itkColorTableTest.cxx @@ -78,7 +78,7 @@ ColorTableTestSpecialConditionChecker(typename itk::ColorTable::Poin return EXIT_FAILURE; } - RGBPixelType pixel = colors->GetColor(numberOfColors); + const RGBPixelType pixel = colors->GetColor(numberOfColors); if (pixel != zeroPixel) { std::cerr << "Test failed!" << std::endl; @@ -87,7 +87,7 @@ ColorTableTestSpecialConditionChecker(typename itk::ColorTable::Poin return EXIT_FAILURE; } - bool tf = colors->SetColor(numberOfColors, 0, 0, 0, "NoMatterTheName"); + const bool tf = colors->SetColor(numberOfColors, 0, 0, 0, "NoMatterTheName"); if (tf != false) { std::cerr << "Test failed!" << std::endl; @@ -96,7 +96,7 @@ ColorTableTestSpecialConditionChecker(typename itk::ColorTable::Poin return EXIT_FAILURE; } - std::string name = colors->GetColorName(numberOfColors); + const std::string name = colors->GetColorName(numberOfColors); if (!name.empty()) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Core/Common/test/itkCommandObserverObjectTest.cxx b/Modules/Core/Common/test/itkCommandObserverObjectTest.cxx index b72bf939917..a757476d28f 100644 --- a/Modules/Core/Common/test/itkCommandObserverObjectTest.cxx +++ b/Modules/Core/Common/test/itkCommandObserverObjectTest.cxx @@ -67,23 +67,23 @@ onAnyThrow(itk::Object *, const itk::EventObject &, void *) void onUserRemove(itk::Object * o, const itk::EventObject &, void * data) { - unsigned long idToRemove = *static_cast(data); + const unsigned long idToRemove = *static_cast(data); o->RemoveObserver(idToRemove); } int testDeleteObserverDuringEvent() { - itk::Object::Pointer o = itk::Object::New(); + const itk::Object::Pointer o = itk::Object::New(); unsigned long idToRemove; - itk::CStyleCommand::Pointer removeCmd = itk::CStyleCommand::New(); + const itk::CStyleCommand::Pointer removeCmd = itk::CStyleCommand::New(); removeCmd->SetCallback(onUserRemove); removeCmd->SetObjectName("Remove Command"); - itk::CStyleCommand::Pointer cmd = itk::CStyleCommand::New(); + const itk::CStyleCommand::Pointer cmd = itk::CStyleCommand::New(); cmd->SetCallback(onAny); cmd->SetObjectName("Any Command 1"); @@ -180,14 +180,14 @@ int testCommandConstObject() { - itk::Object::Pointer o = itk::Object::New(); - itk::Object::ConstPointer co = o; + const itk::Object::Pointer o = itk::Object::New(); + const itk::Object::ConstPointer co = o; - itk::CStyleCommand::Pointer cmd = itk::CStyleCommand::New(); + const itk::CStyleCommand::Pointer cmd = itk::CStyleCommand::New(); cmd->SetConstCallback(onAnyConst); cmd->SetObjectName("Any Command 1"); - itk::CStyleCommand::Pointer removeCmd = itk::CStyleCommand::New(); + const itk::CStyleCommand::Pointer removeCmd = itk::CStyleCommand::New(); removeCmd->SetCallback(onUserRemove); removeCmd->SetObjectName("Remove Command"); @@ -215,20 +215,20 @@ testCommandRecursiveObject() // a Command. // This is a super-mean test that is not likely to really be used. - itk::Object::Pointer o = itk::Object::New(); - itk::Object::ConstPointer co = o; + const itk::Object::Pointer o = itk::Object::New(); + const itk::Object::ConstPointer co = o; unsigned long idToRemove; - itk::CStyleCommand::Pointer cmd = itk::CStyleCommand::New(); + const itk::CStyleCommand::Pointer cmd = itk::CStyleCommand::New(); cmd->SetCallback(onAny); cmd->SetObjectName("Any Command 1"); - itk::CStyleCommand::Pointer removeCmd = itk::CStyleCommand::New(); + const itk::CStyleCommand::Pointer removeCmd = itk::CStyleCommand::New(); removeCmd->SetCallback(onUserRemove); removeCmd->SetObjectName("Remove Command"); - itk::CStyleCommand::Pointer cmdInvoke = itk::CStyleCommand::New(); + const itk::CStyleCommand::Pointer cmdInvoke = itk::CStyleCommand::New(); cmdInvoke->SetCallback(onAnyInvokeUser); cmdInvoke->SetObjectName("Any Invoke User"); @@ -274,9 +274,9 @@ bool testDeleteEventThrow() { // check the case where an exception in thrown in the DeleteEvent - itk::Object::Pointer o = itk::Object::New(); + const itk::Object::Pointer o = itk::Object::New(); - itk::CStyleCommand::Pointer cmd = itk::CStyleCommand::New(); + const itk::CStyleCommand::Pointer cmd = itk::CStyleCommand::New(); cmd->SetCallback(onAnyThrow); o->AddObserver(itk::DeleteEvent(), cmd); @@ -295,7 +295,7 @@ testLambdaCommand() { // check the case where an exception in thrown in the DeleteEvent - itk::Object::Pointer o = itk::Object::New(); + const itk::Object::Pointer o = itk::Object::New(); /*----- FIRST OBSERVER LAMBDA */ o->AddObserver(itk::AnyEvent(), [&cnt](const itk::EventObject &) { ++cnt; }); diff --git a/Modules/Core/Common/test/itkCompensatedSummationTest.cxx b/Modules/Core/Common/test/itkCompensatedSummationTest.cxx index 47dc02e0ab6..195267eb95e 100644 --- a/Modules/Core/Common/test/itkCompensatedSummationTest.cxx +++ b/Modules/Core/Common/test/itkCompensatedSummationTest.cxx @@ -27,10 +27,10 @@ itkCompensatedSummationTest(int, char *[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope // scope. - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); using FloatType = float; - long seedValue = 17; + const long seedValue = 17; constexpr FloatType expectedMean = 0.5; @@ -73,7 +73,7 @@ itkCompensatedSummationTest(int, char *[]) } // exercise other methods - CompensatedSummationType floatAccumulatorCopy = floatAccumulator; + const CompensatedSummationType floatAccumulatorCopy = floatAccumulator; if (itk::Math::NotExactlyEquals(floatAccumulatorCopy.GetSum(), floatAccumulator.GetSum())) { std::cerr << "The copy constructor failed." << std::endl; diff --git a/Modules/Core/Common/test/itkCompensatedSummationTest2.cxx b/Modules/Core/Common/test/itkCompensatedSummationTest2.cxx index 9e4a4d1d359..4539570f326 100644 --- a/Modules/Core/Common/test/itkCompensatedSummationTest2.cxx +++ b/Modules/Core/Common/test/itkCompensatedSummationTest2.cxx @@ -73,7 +73,7 @@ class CompensatedSummationTest2Associate { for (DomainType::IndexValueType i = subdomain[0]; i <= subdomain[1]; ++i) { - double value = 1.0 / 7; + const double value = 1.0 / 7; this->m_PerThreadCompensatedSum[threadId].AddElement(value); } } @@ -86,7 +86,7 @@ class CompensatedSummationTest2Associate for (itk::ThreadIdType i = 0, numWorkUnitsUsed = this->GetNumberOfWorkUnitsUsed(); i < numWorkUnitsUsed; ++i) { - double sum = this->m_PerThreadCompensatedSum[i].GetSum(); + const double sum = this->m_PerThreadCompensatedSum[i].GetSum(); std::cout << i << ": " << sum << std::endl; this->m_Associate->m_CompensatedSumOfThreads.AddElement(sum); this->m_Associate->m_UncompensatedSumOfThreads += sum; @@ -139,8 +139,9 @@ class CompensatedSummationTest2Associate int itkCompensatedSummationTest2(int, char *[]) { - CompensatedSummationTest2Associate enclosingClass; - CompensatedSummationTest2Associate::TestDomainThreader::Pointer domainThreader = enclosingClass.GetDomainThreader(); + CompensatedSummationTest2Associate enclosingClass; + const CompensatedSummationTest2Associate::TestDomainThreader::Pointer domainThreader = + enclosingClass.GetDomainThreader(); /* Check # of threads */ std::cout << "GetGlobalMaximumNumberOfThreads: " @@ -151,12 +152,12 @@ itkCompensatedSummationTest2(int, char *[]) using DomainType = CompensatedSummationTest2Associate::TestDomainThreader::DomainType; DomainType domain; - itk::ThreadIdType maxNumberOfThreads = domainThreader->GetMultiThreader()->GetGlobalMaximumNumberOfThreads(); + const itk::ThreadIdType maxNumberOfThreads = domainThreader->GetMultiThreader()->GetGlobalMaximumNumberOfThreads(); domain[0] = 0; domain[1] = maxNumberOfThreads * 10000; /* Test with single thread. We should get the same result. */ - itk::ThreadIdType numberOfThreads = 1; + const itk::ThreadIdType numberOfThreads = 1; domainThreader->SetMaximumNumberOfThreads(numberOfThreads); domainThreader->SetNumberOfWorkUnits(numberOfThreads); std::cout << "Testing with " << numberOfThreads << " threads and domain " << domain << " ..." << std::endl; @@ -183,7 +184,7 @@ itkCompensatedSummationTest2(int, char *[]) } /* Store result as reference */ - double referenceSum = enclosingClass.GetCompensatedSumOfThreads(); + const double referenceSum = enclosingClass.GetCompensatedSumOfThreads(); /* Test with maximum threads. We need at least three threads to see a difference. */ if (domainThreader->GetMultiThreader()->GetGlobalMaximumNumberOfThreads() > 2) diff --git a/Modules/Core/Common/test/itkConicShellInteriorExteriorSpatialFunctionTest.cxx b/Modules/Core/Common/test/itkConicShellInteriorExteriorSpatialFunctionTest.cxx index c994cfcedf2..48cc4a86867 100644 --- a/Modules/Core/Common/test/itkConicShellInteriorExteriorSpatialFunctionTest.cxx +++ b/Modules/Core/Common/test/itkConicShellInteriorExteriorSpatialFunctionTest.cxx @@ -42,7 +42,7 @@ itkConicShellInteriorExteriorSpatialFunctionTest(int, char *[]) // Create the conic shell function - ConicShellInteriorExteriorSpatialFunctionType::Pointer conicShellInteriorExteriorSpatialFunction = + const ConicShellInteriorExteriorSpatialFunctionType::Pointer conicShellInteriorExteriorSpatialFunction = ConicShellInteriorExteriorSpatialFunctionType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(conicShellInteriorExteriorSpatialFunction, @@ -59,7 +59,7 @@ itkConicShellInteriorExteriorSpatialFunctionTest(int, char *[]) originGradient.GetVnlVector().normalize(); conicShellInteriorExteriorSpatialFunction->SetOriginGradient(originGradient); - double tolerance = 10e-6; + const double tolerance = 10e-6; std::cerr.precision(static_cast(itk::Math::abs(std::log10(tolerance)))); for (unsigned int i = 0; i < originGradient.Size(); ++i) { @@ -74,15 +74,15 @@ itkConicShellInteriorExteriorSpatialFunctionTest(int, char *[]) } } - double distanceMin = 10.0; + const double distanceMin = 10.0; conicShellInteriorExteriorSpatialFunction->SetDistanceMin(distanceMin); ITK_TEST_SET_GET_VALUE(distanceMin, conicShellInteriorExteriorSpatialFunction->GetDistanceMin()); - double distanceMax = 50.0; + const double distanceMax = 50.0; conicShellInteriorExteriorSpatialFunction->SetDistanceMax(distanceMax); ITK_TEST_SET_GET_VALUE(distanceMax, conicShellInteriorExteriorSpatialFunction->GetDistanceMax()); - double epsilon = 1e-3; + const double epsilon = 1e-3; conicShellInteriorExteriorSpatialFunction->SetEpsilon(epsilon); ITK_TEST_SET_GET_VALUE(epsilon, conicShellInteriorExteriorSpatialFunction->GetEpsilon()); diff --git a/Modules/Core/Common/test/itkConnectedImageNeighborhoodShapeGTest.cxx b/Modules/Core/Common/test/itkConnectedImageNeighborhoodShapeGTest.cxx index 5f17d8c60d5..834774d35de 100644 --- a/Modules/Core/Common/test/itkConnectedImageNeighborhoodShapeGTest.cxx +++ b/Modules/Core/Common/test/itkConnectedImageNeighborhoodShapeGTest.cxx @@ -49,7 +49,7 @@ Assert_GetNumberOfOffsets_returns_expected_number() "Checked ConnectedImageNeighborhoodShape::GetNumberOfOffsets()."); // Test GetNumberOfOffsets() on a non-const shape, at run-time: - ShapeType nonConstShape = constexprShape; + const ShapeType nonConstShape = constexprShape; ASSERT_EQ(nonConstShape.GetNumberOfOffsets(), VExpectedNumberOfOffsets); } @@ -125,7 +125,7 @@ Assert_Offsets_are_unique_and_colexicographically_ordered() for (unsigned int maximumCityblockDistance = 0; maximumCityblockDistance < VImageDimension; ++maximumCityblockDistance) { - for (bool includeCenterPixel : { false, true }) + for (const bool includeCenterPixel : { false, true }) { const ShapeType shape{ maximumCityblockDistance, includeCenterPixel }; const std::vector offsets = GenerateImageNeighborhoodOffsets(shape); diff --git a/Modules/Core/Common/test/itkConstNeighborhoodIteratorTest.cxx b/Modules/Core/Common/test/itkConstNeighborhoodIteratorTest.cxx index b2f4f9d096d..32f2b22b2cb 100644 --- a/Modules/Core/Common/test/itkConstNeighborhoodIteratorTest.cxx +++ b/Modules/Core/Common/test/itkConstNeighborhoodIteratorTest.cxx @@ -34,9 +34,9 @@ GetTestImage(int d1, int d2, int d3, int d4) sizeND[2] = d3; sizeND[3] = d4; - itk::Index<4> origND{}; + const itk::Index<4> origND{}; - itk::ImageRegion<4> RegionND{ origND, sizeND }; + const itk::ImageRegion<4> RegionND{ origND, sizeND }; auto imageND = TestImageType::New(); imageND->SetRegions(RegionND); @@ -50,7 +50,7 @@ GetTestImage(int d1, int d2, int d3, int d4) int itkConstNeighborhoodIteratorTest(int, char *[]) { - TestImageType::Pointer img = GetTestImage(10, 10, 5, 3); + const TestImageType::Pointer img = GetTestImage(10, 10, 5, 3); itk::ConstNeighborhoodIterator::IndexType loc; loc[0] = 4; loc[1] = 4; @@ -176,7 +176,7 @@ itkConstNeighborhoodIteratorTest(int, char *[]) println("Testing random access iteration"); - TestImageType::Pointer ra_img = GetTestImage(10, 10, 5, 3); + const TestImageType::Pointer ra_img = GetTestImage(10, 10, 5, 3); loc[0] = 4; loc[1] = 4; loc[2] = 2; @@ -224,8 +224,8 @@ itkConstNeighborhoodIteratorTest(int, char *[]) // Test IndexInBounds // println("Testing IndexInBounds"); - int dims[4] = { 13, 11, 9, 7 }; - TestImageType::Pointer iib_img = GetTestImage(dims[0], dims[1], dims[2], dims[3]); + const int dims[4] = { 13, 11, 9, 7 }; + const TestImageType::Pointer iib_img = GetTestImage(dims[0], dims[1], dims[2], dims[3]); radius[0] = 4; radius[1] = 3; radius[2] = 2; @@ -316,11 +316,11 @@ itkConstNeighborhoodIteratorTest(int, char *[]) { // Create an image using ChangeRegionTestImageType = itk::Image; - ChangeRegionTestImageType::IndexType imageCorner{}; + const ChangeRegionTestImageType::IndexType imageCorner{}; auto imageSize = ChangeRegionTestImageType::SizeType::Filled(4); - ChangeRegionTestImageType::RegionType imageRegion(imageCorner, imageSize); + const ChangeRegionTestImageType::RegionType imageRegion(imageCorner, imageSize); auto image = ChangeRegionTestImageType::New(); image->SetRegions(imageRegion); @@ -348,7 +348,7 @@ itkConstNeighborhoodIteratorTest(int, char *[]) auto regionSize = ChangeRegionTestImageType::SizeType::Filled(1); - ChangeRegionTestImageType::RegionType region1(region1Start, regionSize); + const ChangeRegionTestImageType::RegionType region1(region1Start, regionSize); // Create the radius (a 3x3 region) auto neighborhoodRadius = ChangeRegionTestImageType::SizeType::Filled(1); @@ -382,7 +382,7 @@ itkConstNeighborhoodIteratorTest(int, char *[]) // Change iteration region auto region2start = ChangeRegionTestImageType::IndexType::Filled(2); - ChangeRegionTestImageType::RegionType region2(region2start, regionSize); + const ChangeRegionTestImageType::RegionType region2(region2start, regionSize); neighborhoodIterator.SetRegion(region2); neighborhoodIterator.GoToBegin(); diff --git a/Modules/Core/Common/test/itkConstNeighborhoodIteratorWithOnlyIndexTest.cxx b/Modules/Core/Common/test/itkConstNeighborhoodIteratorWithOnlyIndexTest.cxx index 95e03391a38..ac90c79c85d 100644 --- a/Modules/Core/Common/test/itkConstNeighborhoodIteratorWithOnlyIndexTest.cxx +++ b/Modules/Core/Common/test/itkConstNeighborhoodIteratorWithOnlyIndexTest.cxx @@ -29,9 +29,9 @@ itkConstNeighborhoodIteratorWithOnlyIndexTestGetTestImage(int d1, int d2, int d3 sizeND[2] = d3; sizeND[3] = d4; - itk::Index<4> origND{}; + const itk::Index<4> origND{}; - itk::ImageRegion<4> RegionND{ origND, sizeND }; + const itk::ImageRegion<4> RegionND{ origND, sizeND }; auto imageND = TImage::New(); imageND->SetRegions(RegionND); @@ -43,7 +43,7 @@ template int itkConstNeighborhoodIteratorWithOnlyIndexTestRun() { - typename TImage::Pointer img = itkConstNeighborhoodIteratorWithOnlyIndexTestGetTestImage(10, 10, 5, 3); + const typename TImage::Pointer img = itkConstNeighborhoodIteratorWithOnlyIndexTestGetTestImage(10, 10, 5, 3); using ImageType = TImage; using ConstNeighborhoodIteratorType = itk::ConstNeighborhoodIteratorWithOnlyIndex; @@ -212,7 +212,8 @@ itkConstNeighborhoodIteratorWithOnlyIndexTestRun() std::cout << "Testing random access iteration" << std::endl; - typename ImageType::Pointer ra_img = itkConstNeighborhoodIteratorWithOnlyIndexTestGetTestImage(10, 10, 5, 3); + const typename ImageType::Pointer ra_img = + itkConstNeighborhoodIteratorWithOnlyIndexTestGetTestImage(10, 10, 5, 3); loc[0] = 4; loc[1] = 4; loc[2] = 2; @@ -355,8 +356,8 @@ itkConstNeighborhoodIteratorWithOnlyIndexTestRun() // Test IndexInBounds // std::cout << "Testing IndexInBounds" << std::endl; - int dims[4] = { 13, 11, 9, 7 }; - typename ImageType::Pointer iib_img = + const int dims[4] = { 13, 11, 9, 7 }; + const typename ImageType::Pointer iib_img = itkConstNeighborhoodIteratorWithOnlyIndexTestGetTestImage(dims[0], dims[1], dims[2], dims[3]); radius[0] = 4; radius[1] = 3; diff --git a/Modules/Core/Common/test/itkConstShapedNeighborhoodIteratorTest.cxx b/Modules/Core/Common/test/itkConstShapedNeighborhoodIteratorTest.cxx index dc43a0d71f3..0e7e93a6946 100644 --- a/Modules/Core/Common/test/itkConstShapedNeighborhoodIteratorTest.cxx +++ b/Modules/Core/Common/test/itkConstShapedNeighborhoodIteratorTest.cxx @@ -34,7 +34,7 @@ PrintShapedNeighborhood(const itk::ConstShapedNeighborhoodIterator::IndexType loc; loc[0] = 4; loc[1] = 4; @@ -417,11 +417,11 @@ itkConstShapedNeighborhoodIteratorTest(int, char *[]) { // Create an image using ChangeRegionTestImageType = itk::Image; - ChangeRegionTestImageType::IndexType imageCorner{}; + const ChangeRegionTestImageType::IndexType imageCorner{}; auto imageSize = ChangeRegionTestImageType::SizeType::Filled(4); - ChangeRegionTestImageType::RegionType imageRegion(imageCorner, imageSize); + const ChangeRegionTestImageType::RegionType imageRegion(imageCorner, imageSize); auto image = ChangeRegionTestImageType::New(); image->SetRegions(imageRegion); @@ -449,7 +449,7 @@ itkConstShapedNeighborhoodIteratorTest(int, char *[]) auto regionSize = ChangeRegionTestImageType::SizeType::Filled(1); - ChangeRegionTestImageType::RegionType region1(region1Start, regionSize); + const ChangeRegionTestImageType::RegionType region1(region1Start, regionSize); // Create the radius (a 3x3 region) auto neighborhoodRadius = ChangeRegionTestImageType::SizeType::Filled(1); @@ -496,7 +496,7 @@ itkConstShapedNeighborhoodIteratorTest(int, char *[]) // Change iteration region auto region2start = ChangeRegionTestImageType::IndexType::Filled(2); - ChangeRegionTestImageType::RegionType region2(region2start, regionSize); + const ChangeRegionTestImageType::RegionType region2(region2start, regionSize); shapedNeighborhoodIterator.SetRegion(region2); shapedNeighborhoodIterator.GoToBegin(); diff --git a/Modules/Core/Common/test/itkConstShapedNeighborhoodIteratorTest2.cxx b/Modules/Core/Common/test/itkConstShapedNeighborhoodIteratorTest2.cxx index bcd5c1e2f7b..12d1e209095 100644 --- a/Modules/Core/Common/test/itkConstShapedNeighborhoodIteratorTest2.cxx +++ b/Modules/Core/Common/test/itkConstShapedNeighborhoodIteratorTest2.cxx @@ -44,7 +44,7 @@ template void MyDerivedCSNI::TestNewExposedProtectedMembers() { - bool needToUseBoundaryCondition(this->GetNeedToUseBoundaryCondition()); + const bool needToUseBoundaryCondition(this->GetNeedToUseBoundaryCondition()); this->NeedToUseBoundaryConditionOn(); this->NeedToUseBoundaryConditionOff(); this->SetNeedToUseBoundaryCondition(needToUseBoundaryCondition); @@ -53,7 +53,7 @@ MyDerivedCSNI::TestNewExposedProtectedMembers() int itkConstShapedNeighborhoodIteratorTest2(int, char *[]) { - TestImageType::Pointer img = GetTestImage(10, 10, 5, 3); + const TestImageType::Pointer img = GetTestImage(10, 10, 5, 3); MyDerivedCSNI::IndexType loc; loc[0] = 4; loc[1] = 4; diff --git a/Modules/Core/Common/test/itkConstantBoundaryConditionTest.cxx b/Modules/Core/Common/test/itkConstantBoundaryConditionTest.cxx index b5e630a8fc6..4a11a3251b2 100644 --- a/Modules/Core/Common/test/itkConstantBoundaryConditionTest.cxx +++ b/Modules/Core/Common/test/itkConstantBoundaryConditionTest.cxx @@ -73,9 +73,9 @@ TestPrintNeighborhood(IteratorType & p, VectorIteratorType & v) // Access the pixel value through three different methods in the // boundary condition. - int pixel1 = p.GetBoundaryCondition()->GetPixel(index, p.GetImagePointer()); - int pixel2 = p.GetPixel(i); - int pixel3 = v.GetPixel(i)[0]; + const int pixel1 = p.GetBoundaryCondition()->GetPixel(index, p.GetImagePointer()); + const int pixel2 = p.GetPixel(i); + const int pixel3 = v.GetPixel(i)[0]; std::cout << pixel1 << ' '; @@ -121,10 +121,10 @@ int itkConstantBoundaryConditionTest(int, char *[]) { // Test an image to cover one operator() method. - auto image = ImageType::New(); - SizeType imageSize = { { 5, 5 } }; - IndexType imageIndex = { { 0, 0 } }; - RegionType imageRegion; + auto image = ImageType::New(); + const SizeType imageSize = { { 5, 5 } }; + const IndexType imageIndex = { { 0, 0 } }; + RegionType imageRegion; imageRegion.SetSize(imageSize); imageRegion.SetIndex(imageIndex); image->SetRegions(imageRegion); @@ -159,7 +159,7 @@ itkConstantBoundaryConditionTest(int, char *[]) itk::ConstantBoundaryCondition bc; itk::ConstantBoundaryCondition vbc; - ImageType::PixelType constant = 3; + const ImageType::PixelType constant = 3; bc.SetConstant(constant); if (bc.GetConstant() != constant) @@ -188,7 +188,7 @@ itkConstantBoundaryConditionTest(int, char *[]) for (it.GoToBegin(), vit.GoToBegin(); !it.IsAtEnd(); ++it, ++vit) { std::cout << "Index: " << it.GetIndex() << std::endl; - bool success = TestPrintNeighborhood(it, vit); + const bool success = TestPrintNeighborhood(it, vit); if (!success) { return EXIT_FAILURE; @@ -209,7 +209,7 @@ itkConstantBoundaryConditionTest(int, char *[]) for (it2.GoToBegin(), vit2.GoToBegin(); !it2.IsAtEnd(); ++it2, ++vit2) { std::cout << "Index: " << it2.GetIndex() << std::endl; - bool success = TestPrintNeighborhood(it2, vit2); + const bool success = TestPrintNeighborhood(it2, vit2); if (!success) { return EXIT_FAILURE; diff --git a/Modules/Core/Common/test/itkCovariantVectorGeometryTest.cxx b/Modules/Core/Common/test/itkCovariantVectorGeometryTest.cxx index ad5afb3e748..2e73363fccc 100644 --- a/Modules/Core/Common/test/itkCovariantVectorGeometryTest.cxx +++ b/Modules/Core/Common/test/itkCovariantVectorGeometryTest.cxx @@ -53,7 +53,7 @@ itkCovariantVectorGeometryTest(int, char *[]) std::cout << "vb = (1,3,5) = "; std::cout << vb << std::endl; - VectorType vc = vb - va; + const VectorType vc = vb - va; std::cout << "vc = vb - va = "; std::cout << vc << std::endl; @@ -73,7 +73,7 @@ itkCovariantVectorGeometryTest(int, char *[]) std::cout << "ve -= vb = "; std::cout << ve << std::endl; - VectorType vh = vb; + const VectorType vh = vb; std::cout << "vh = vb = "; std::cout << vh << std::endl; @@ -81,15 +81,15 @@ itkCovariantVectorGeometryTest(int, char *[]) std::cout << "vg( va ) = "; std::cout << vg << std::endl; - ValueType norm2 = vg.GetSquaredNorm(); + const ValueType norm2 = vg.GetSquaredNorm(); std::cout << "vg squared norm = "; std::cout << norm2 << std::endl; - ValueType norm = vg.GetNorm(); + const ValueType norm = vg.GetNorm(); std::cout << "vg norm = "; std::cout << norm << std::endl; - ValueType normX = vg.Normalize(); + const ValueType normX = vg.Normalize(); std::cout << "vg after normalizing: " << vg << std::endl; if (norm != normX) { diff --git a/Modules/Core/Common/test/itkCrossHelperTest.cxx b/Modules/Core/Common/test/itkCrossHelperTest.cxx index 2d1459f290f..22b5f7b3462 100644 --- a/Modules/Core/Common/test/itkCrossHelperTest.cxx +++ b/Modules/Core/Common/test/itkCrossHelperTest.cxx @@ -35,13 +35,13 @@ itkCrossHelperTest(int itkNotUsed(argc), char * itkNotUsed(argv)[]) using Vector4DType = itk::Vector; using Cross2DType = itk::CrossHelper; - Cross2DType cross2d; + const Cross2DType cross2d; using Cross3DType = itk::CrossHelper; - Cross3DType cross3d; + const Cross3DType cross3d; using Cross4DType = itk::CrossHelper; - Cross4DType cross4d; + const Cross4DType cross4d; Vector2DType u2d; u2d[0] = 1.; diff --git a/Modules/Core/Common/test/itkDataObjectAndProcessObjectTest.cxx b/Modules/Core/Common/test/itkDataObjectAndProcessObjectTest.cxx index f244dbee231..6279998bb96 100644 --- a/Modules/Core/Common/test/itkDataObjectAndProcessObjectTest.cxx +++ b/Modules/Core/Common/test/itkDataObjectAndProcessObjectTest.cxx @@ -238,14 +238,14 @@ itkDataObjectAndProcessObjectTest(int, char *[]) ITK_TEST_SET_GET_VALUE(itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads(), process->GetNumberOfWorkUnits()); // not sure what to test with that method - at least test that it exist - itk::MultiThreaderBase::Pointer multiThreader = process->GetMultiThreader(); + const itk::MultiThreaderBase::Pointer multiThreader = process->GetMultiThreader(); ITK_TEST_SET_GET_VALUE(true, multiThreader.IsNotNull()); // create some data object that will be used as input and output - itk::TestDataObject::Pointer input0 = itk::TestDataObject::New(); - itk::TestDataObject::Pointer input1 = itk::TestDataObject::New(); + const itk::TestDataObject::Pointer input0 = itk::TestDataObject::New(); + const itk::TestDataObject::Pointer input1 = itk::TestDataObject::New(); - itk::TestDataObject::Pointer output1 = itk::TestDataObject::New(); + const itk::TestDataObject::Pointer output1 = itk::TestDataObject::New(); // default input values ITK_TEST_SET_GET_NULL_VALUE(process->GetPrimaryInput()); @@ -297,7 +297,7 @@ itkDataObjectAndProcessObjectTest(int, char *[]) process->PopBackInput(); ITK_TEST_SET_GET_VALUE(1, process->GetNumberOfIndexedInputs()); - itk::TestDataObject::Pointer output = itk::TestDataObject::New(); + const itk::TestDataObject::Pointer output = itk::TestDataObject::New(); process->SetNthOutput(0, output); process->SetNumberOfRequiredInputs(1); diff --git a/Modules/Core/Common/test/itkDataObjectTest.cxx b/Modules/Core/Common/test/itkDataObjectTest.cxx index 8a51ee7d21e..877110c0acb 100644 --- a/Modules/Core/Common/test/itkDataObjectTest.cxx +++ b/Modules/Core/Common/test/itkDataObjectTest.cxx @@ -54,11 +54,11 @@ class DataObjectTestHelper : public DataObject int itkDataObjectTest(int, char *[]) { - itk::DataObjectTestHelper::Pointer dataObject = itk::DataObjectTestHelper::New(); + const itk::DataObjectTestHelper::Pointer dataObject = itk::DataObjectTestHelper::New(); - itk::RealTimeClock::Pointer clock = itk::RealTimeClock::New(); + const itk::RealTimeClock::Pointer clock = itk::RealTimeClock::New(); dataObject->SetRealTimeStamp(clock->GetRealTimeStamp()); - itk::RealTimeStamp timeStamp = dataObject->GetRealTimeStamp(); + const itk::RealTimeStamp timeStamp = dataObject->GetRealTimeStamp(); dataObject->DataHasBeenGenerated(); if (timeStamp != dataObject->GetRealTimeStamp()) { diff --git a/Modules/Core/Common/test/itkDirectoryTest.cxx b/Modules/Core/Common/test/itkDirectoryTest.cxx index 537246fa998..27e3bb6f12c 100644 --- a/Modules/Core/Common/test/itkDirectoryTest.cxx +++ b/Modules/Core/Common/test/itkDirectoryTest.cxx @@ -22,7 +22,7 @@ int itkDirectoryTest(int argc, char * argv[]) { - itk::Directory::Pointer directory = itk::Directory::New(); + const itk::Directory::Pointer directory = itk::Directory::New(); if (argc < 2) { diff --git a/Modules/Core/Common/test/itkEllipsoidInteriorExteriorSpatialFunctionTest.cxx b/Modules/Core/Common/test/itkEllipsoidInteriorExteriorSpatialFunctionTest.cxx index f8b05d38f63..20704751b04 100644 --- a/Modules/Core/Common/test/itkEllipsoidInteriorExteriorSpatialFunctionTest.cxx +++ b/Modules/Core/Common/test/itkEllipsoidInteriorExteriorSpatialFunctionTest.cxx @@ -42,9 +42,9 @@ itkEllipsoidInteriorExteriorSpatialFunctionTest(int, char *[]) spatialFunc->SetAxes(axes); // Define function doitkEllipsoidInteriorExteriorSpatialFunctionTest, which encapsulates ellipsoid. - int xExtent = 50; - int yExtent = 50; - int zExtent = 50; + const int xExtent = 50; + const int yExtent = 50; + const int zExtent = 50; // Define and set the center of the ellipsoid in the center of // the function doitkEllipsoidInteriorExteriorSpatialFunctionTest @@ -58,8 +58,8 @@ itkEllipsoidInteriorExteriorSpatialFunctionTest(int, char *[]) // (0,1,0) corresponds to the axes of length axes[0] // (1,0,0) corresponds to the axes of length axes[1] // (0,0,1) corresponds to the axes of length axes[2] - double data[] = { 0, 1, 0, 1, 0, 0, 0, 0, 1 }; - vnl_matrix orientations(data, 3, 3); + double data[] = { 0, 1, 0, 1, 0, 0, 0, 0, 1 }; + const vnl_matrix orientations(data, 3, 3); // Set the orientations of the ellipsoids spatialFunc->SetOrientations(orientations); @@ -98,10 +98,10 @@ itkEllipsoidInteriorExteriorSpatialFunctionTest(int, char *[]) functionValue = spatialFunc->Evaluate(testPosition); // Volume of ellipsoid using V=(4/3)*pi*(a/2)*(b/2)*(c/2) - double volume = 4.18879013333 * (axes[0] / 2) * (axes[1] / 2) * (axes[2] / 2); + const double volume = 4.18879013333 * (axes[0] / 2) * (axes[1] / 2) * (axes[2] / 2); // Percent difference in volume measurement and calculation - double volumeError = (itk::Math::abs(volume - interiorPixelCounter) / volume) * 100; + const double volumeError = (itk::Math::abs(volume - interiorPixelCounter) / volume) * 100; std::cout << spatialFunc; diff --git a/Modules/Core/Common/test/itkEventObjectTest.cxx b/Modules/Core/Common/test/itkEventObjectTest.cxx index b00a436e2cf..1fec0aafcb4 100644 --- a/Modules/Core/Common/test/itkEventObjectTest.cxx +++ b/Modules/Core/Common/test/itkEventObjectTest.cxx @@ -35,7 +35,7 @@ itkEventObjectTest(int, char *[]) { // test constructor - itk::TestEvent event; + const itk::TestEvent event; itk::TestDerivedEvent derivedEvent; diff --git a/Modules/Core/Common/test/itkExceptionObjectTest.cxx b/Modules/Core/Common/test/itkExceptionObjectTest.cxx index 99ea04096c0..07e69b9a8c8 100644 --- a/Modules/Core/Common/test/itkExceptionObjectTest.cxx +++ b/Modules/Core/Common/test/itkExceptionObjectTest.cxx @@ -73,7 +73,7 @@ mammal::operator==(mammal & o) int lookup(const int i) { - static int table[5] = { 23, 42, 42, 32, 12 }; + static const int table[5] = { 23, 42, 42, 32, 12 }; if (!(0 <= i && i < 5)) { itk::RangeError e(__FILE__, __LINE__); diff --git a/Modules/Core/Common/test/itkExtractImage3Dto2DTest.cxx b/Modules/Core/Common/test/itkExtractImage3Dto2DTest.cxx index a1ed39fa5c0..2df16a948d3 100644 --- a/Modules/Core/Common/test/itkExtractImage3Dto2DTest.cxx +++ b/Modules/Core/Common/test/itkExtractImage3Dto2DTest.cxx @@ -32,10 +32,10 @@ itkExtractImage3Dto2DTest(int, char *[]) auto src = RandomImageSourceType::New(); src->SetMin(0); src->SetMax(255); - Image3DType::SizeType size = { { 16, 16, 16 } }; + const Image3DType::SizeType size = { { 16, 16, 16 } }; src->SetSize(size); src->Update(); - Image3DType::Pointer im3d(src->GetOutput()); + const Image3DType::Pointer im3d(src->GetOutput()); Image3DType::DirectionType dir = im3d->GetDirection(); dir[1][1] = 0.0; dir[1][2] = 1.0; @@ -63,7 +63,7 @@ itkExtractImage3Dto2DTest(int, char *[]) extract->SetExtractionRegion(extractRegion); extract->Update(); - Image2DType::Pointer extractedImage = extract->GetOutput(); + const Image2DType::Pointer extractedImage = extract->GetOutput(); Image2DType::DirectionType identity; identity.SetIdentity(); if (extractedImage->GetDirection() != identity) diff --git a/Modules/Core/Common/test/itkExtractImageTest.cxx b/Modules/Core/Common/test/itkExtractImageTest.cxx index f32ff1c7657..483a2b9a24d 100644 --- a/Modules/Core/Common/test/itkExtractImageTest.cxx +++ b/Modules/Core/Common/test/itkExtractImageTest.cxx @@ -34,16 +34,16 @@ ExtractImageInPlaceTest() using ImageType = itk::Image; using SourceType = itk::RandomImageSource; - auto source = SourceType::New(); - ImageType::SizeType size = { { 32, 32, 32 } }; + auto source = SourceType::New(); + const ImageType::SizeType size = { { 32, 32, 32 } }; source->SetSize(size); source->UpdateLargestPossibleRegion(); - ImageType::IndexType extractIndex = { { 16, 16, 16 } }; - ImageType::SizeType extractSize = { { 8, 8, 8 } }; - ImageType::SizeType zeroSize = { { 0, 0, 0 } }; + const ImageType::IndexType extractIndex = { { 16, 16, 16 } }; + const ImageType::SizeType extractSize = { { 8, 8, 8 } }; + const ImageType::SizeType zeroSize = { { 0, 0, 0 } }; using ExtractFilterType = itk::ExtractImageFilter; auto extract = ExtractFilterType::New(); @@ -89,7 +89,7 @@ ExtractImageInPlaceTest() int itkExtractImageTest(int, char *[]) { - itk::FileOutputWindow::Pointer fow = itk::FileOutputWindow::New(); + const itk::FileOutputWindow::Pointer fow = itk::FileOutputWindow::New(); fow->SetInstance(fow); int nextVal; @@ -108,9 +108,9 @@ itkExtractImageTest(int, char *[]) auto if2 = ShortImage::New(); // fill in an image - ShortImage::IndexType index = { { 0, 0 } }; - ShortImage::SizeType size = { { 8, 12 } }; - ShortImage::RegionType region{ index, size }; + ShortImage::IndexType index = { { 0, 0 } }; + ShortImage::SizeType size = { { 8, 12 } }; + const ShortImage::RegionType region{ index, size }; if2->SetLargestPossibleRegion(region); if2->SetBufferedRegion(region); if2->Allocate(); @@ -229,7 +229,7 @@ itkExtractImageTest(int, char *[]) stream->SetInput(extract->GetOutput()); stream->SetNumberOfStreamDivisions(2); - ShortImage::RegionType setRegion = extract->GetExtractionRegion(); + const ShortImage::RegionType setRegion = extract->GetExtractionRegion(); size = setRegion.GetSize(); index = setRegion.GetIndex(); @@ -323,7 +323,7 @@ itkExtractImageTest(int, char *[]) ShortImage::IndexType testIndex; for (; !iteratorLineIn.IsAtEnd(); ++iteratorLineIn) { - LineImage::PixelType linePixelValue = iteratorLineIn.Get(); + const LineImage::PixelType linePixelValue = iteratorLineIn.Get(); testIndex[0] = extractIndex[0]; testIndex[1] = iteratorLineIn.GetIndex()[0]; if (linePixelValue != if2->GetPixel(testIndex)) diff --git a/Modules/Core/Common/test/itkFileOutputWindowTest.cxx b/Modules/Core/Common/test/itkFileOutputWindowTest.cxx index d53590bb7c3..87856e8dad3 100644 --- a/Modules/Core/Common/test/itkFileOutputWindowTest.cxx +++ b/Modules/Core/Common/test/itkFileOutputWindowTest.cxx @@ -46,9 +46,9 @@ itkFileOutputWindowTest(int, char *[]) window->SetAppend(append); // Test itkGetMacros - bool flush2 = window->GetFlush(); + const bool flush2 = window->GetFlush(); std::cout << "window->GetFlush(): " << flush2 << std::endl; - bool append2 = window->GetAppend(); + const bool append2 = window->GetAppend(); std::cout << "window->GetAppend(): " << append2 << std::endl; // Test itkBooleanMacros diff --git a/Modules/Core/Common/test/itkFiniteCylinderSpatialFunctionTest.cxx b/Modules/Core/Common/test/itkFiniteCylinderSpatialFunctionTest.cxx index 4cacc8ae0fe..75154c20811 100644 --- a/Modules/Core/Common/test/itkFiniteCylinderSpatialFunctionTest.cxx +++ b/Modules/Core/Common/test/itkFiniteCylinderSpatialFunctionTest.cxx @@ -44,14 +44,14 @@ itkFiniteCylinderSpatialFunctionTest(int, char *[]) orientation[2] = 0.0; ITK_TRY_EXPECT_EXCEPTION(spatialFunc->SetOrientation(orientation)); - double axis = 40.0; + const double axis = 40.0; spatialFunc->SetAxisLength(axis); ITK_TEST_SET_GET_VALUE(axis, spatialFunc->GetAxisLength()); // Define function, which encapsulates cylinder. - int xExtent = 50; - int yExtent = 50; - int zExtent = 50; + const int xExtent = 50; + const int yExtent = 50; + const int zExtent = 50; TCylinderFunctionVectorType center; center[0] = xExtent / 2; @@ -66,7 +66,7 @@ itkFiniteCylinderSpatialFunctionTest(int, char *[]) spatialFunc->SetOrientation(orientation); ITK_TEST_SET_GET_VALUE(orientation, spatialFunc->GetOrientation()); - double radius = 5.0; + const double radius = 5.0; spatialFunc->SetRadius(radius); ITK_TEST_SET_GET_VALUE(radius, spatialFunc->GetRadius()); @@ -103,10 +103,10 @@ itkFiniteCylinderSpatialFunctionTest(int, char *[]) functionValue = spatialFunc->Evaluate(testPosition); // Volume of cylinder using V=pi*r^2*h - double volume = 3.14159 * pow(radius, 2) * axis; + const double volume = 3.14159 * pow(radius, 2) * axis; // Percent difference in volume measurement and calculation - double volumeError = (itk::Math::abs(volume - interiorPixelCounter) / volume) * 100; + const double volumeError = (itk::Math::abs(volume - interiorPixelCounter) / volume) * 100; std::cout << spatialFunc; diff --git a/Modules/Core/Common/test/itkFixedArrayGTest.cxx b/Modules/Core/Common/test/itkFixedArrayGTest.cxx index ab8f2201411..58dd1294d4b 100644 --- a/Modules/Core/Common/test/itkFixedArrayGTest.cxx +++ b/Modules/Core/Common/test/itkFixedArrayGTest.cxx @@ -58,7 +58,7 @@ Check_FixedArray_supports_retrieving_values_by_range_based_for_loop() EXPECT_EQ(stdArrayIterator, stdArray.cend()); // Now test retrieving the values from a non-const FixedArray: - itk::FixedArray nonConstFixedArray{ stdArray }; + const itk::FixedArray nonConstFixedArray{ stdArray }; stdArrayIterator = stdArray.cbegin(); diff --git a/Modules/Core/Common/test/itkFixedArrayTest.cxx b/Modules/Core/Common/test/itkFixedArrayTest.cxx index 9e4d0379768..7387e439b0a 100644 --- a/Modules/Core/Common/test/itkFixedArrayTest.cxx +++ b/Modules/Core/Common/test/itkFixedArrayTest.cxx @@ -70,7 +70,7 @@ itkFixedArrayTest(int, char *[]) Set_c_Array(array3.GetDataPointer()); Print_Array(array3, std::cout); - itk::FixedArray array4{}; + const itk::FixedArray array4{}; Print_Array(array4, std::cout); // Test operator!= and operator== diff --git a/Modules/Core/Common/test/itkFloatingPointExceptionsTest.cxx b/Modules/Core/Common/test/itkFloatingPointExceptionsTest.cxx index 6696356597c..490980b3046 100644 --- a/Modules/Core/Common/test/itkFloatingPointExceptionsTest.cxx +++ b/Modules/Core/Common/test/itkFloatingPointExceptionsTest.cxx @@ -36,19 +36,19 @@ itkFloatingPointExceptionsTest(int argc, char * argv[]) std::cout << "No test specified" << std::endl; return 1; } - int error_return(0); - double double_zero = itkFloatingPointExceptionsTest_double_zero; - double double_max = itkFloatingPointExceptionsTest_double_max; - double test1 = itkFloatingPointExceptionsTest_double_zero; + int error_return(0); + const double double_zero = itkFloatingPointExceptionsTest_double_zero; + const double double_max = itkFloatingPointExceptionsTest_double_max; + const double test1 = itkFloatingPointExceptionsTest_double_zero; - std::string testName(argv[1]); + const std::string testName(argv[1]); if (testName == "DivByZero") { std::cout << "Testing floating point divide by zero" << std::endl; std::cout.flush(); try { - double s = 1.0 / double_zero; + const double s = 1.0 / double_zero; // // should never reach here std::cout << "Divide by Zero Exception not caught" @@ -68,7 +68,7 @@ itkFloatingPointExceptionsTest(int argc, char * argv[]) std::cout.flush(); try { - double s = test1 / double_zero; + const double s = test1 / double_zero; // // should never reach here std::cout << "Zero divide by Zero Exception not caught" diff --git a/Modules/Core/Common/test/itkFrustumSpatialFunctionTest.cxx b/Modules/Core/Common/test/itkFrustumSpatialFunctionTest.cxx index 4f6fdd1e83a..a9f94493796 100644 --- a/Modules/Core/Common/test/itkFrustumSpatialFunctionTest.cxx +++ b/Modules/Core/Common/test/itkFrustumSpatialFunctionTest.cxx @@ -56,15 +56,15 @@ itkFrustumSpatialFunctionTest(int, char *[]) frustrumSpatialFunction->SetBottomPlane(bottomPlane); ITK_TEST_SET_GET_VALUE(bottomPlane, frustrumSpatialFunction->GetBottomPlane()); - double angleZ = 36; + const double angleZ = 36; frustrumSpatialFunction->SetAngleZ(angleZ); ITK_TEST_SET_GET_VALUE(angleZ, frustrumSpatialFunction->GetAngleZ()); - double apertureAngleX = 54; + const double apertureAngleX = 54; frustrumSpatialFunction->SetApertureAngleX(apertureAngleX); ITK_TEST_SET_GET_VALUE(apertureAngleX, frustrumSpatialFunction->GetApertureAngleX()); - double apertureAngleY = 120; + const double apertureAngleY = 120; frustrumSpatialFunction->SetApertureAngleY(apertureAngleY); ITK_TEST_SET_GET_VALUE(apertureAngleY, frustrumSpatialFunction->GetApertureAngleY()); diff --git a/Modules/Core/Common/test/itkGaussianDerivativeOperatorTest.cxx b/Modules/Core/Common/test/itkGaussianDerivativeOperatorTest.cxx index d5ffdf105cc..c39cc184f21 100644 --- a/Modules/Core/Common/test/itkGaussianDerivativeOperatorTest.cxx +++ b/Modules/Core/Common/test/itkGaussianDerivativeOperatorTest.cxx @@ -54,7 +54,7 @@ TestGaussianOperator(double variance, double error, unsigned int width, unsigned op.CreateDirectional(); - double total = std::accumulate(op.Begin(), op.End(), 0.0); + const double total = std::accumulate(op.Begin(), op.End(), 0.0); std::cout << "total: " << total << std::endl; std::cout.precision(16); @@ -103,15 +103,15 @@ itkGaussianDerivativeOperatorTest(int argc, char * argv[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope. - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); if (argc == 6) { - double variance = std::stod(argv[1]); - double error = std::stod(argv[2]); - unsigned int width = std::stoi(argv[3]); - unsigned int order = std::stoi(argv[4]); - double spacing = std::stod(argv[5]); + const double variance = std::stod(argv[1]); + const double error = std::stod(argv[2]); + const unsigned int width = std::stoi(argv[3]); + const unsigned int order = std::stoi(argv[4]); + const double spacing = std::stod(argv[5]); TestGaussianOperator(variance, error, width, order, spacing); diff --git a/Modules/Core/Common/test/itkGaussianSpatialFunctionTest.cxx b/Modules/Core/Common/test/itkGaussianSpatialFunctionTest.cxx index 72f30ab7824..a8199556d10 100644 --- a/Modules/Core/Common/test/itkGaussianSpatialFunctionTest.cxx +++ b/Modules/Core/Common/test/itkGaussianSpatialFunctionTest.cxx @@ -58,7 +58,7 @@ itkGaussianSpatialFunctionTest(int argc, char * argv[]) gaussianSpatialFunction->SetSigma(sigma); ITK_TEST_SET_GET_VALUE(sigma, gaussianSpatialFunction->GetSigma()); - double scale = std::stod(argv[1]); + const double scale = std::stod(argv[1]); gaussianSpatialFunction->SetScale(scale); ITK_TEST_SET_GET_VALUE(scale, gaussianSpatialFunction->GetScale()); @@ -87,7 +87,7 @@ itkGaussianSpatialFunctionTest(int argc, char * argv[]) point[1] = mean[1]; point[2] = mean[2]; - double computedValueAtMean = gaussianSpatialFunction->Evaluate(point); + const double computedValueAtMean = gaussianSpatialFunction->Evaluate(point); double expectedValueAtMean = 1.0; if (gaussianSpatialFunction->GetNormalized()) diff --git a/Modules/Core/Common/test/itkHashTableTest.cxx b/Modules/Core/Common/test/itkHashTableTest.cxx index ddf71ca4c37..fdbd8b2ca3f 100644 --- a/Modules/Core/Common/test/itkHashTableTest.cxx +++ b/Modules/Core/Common/test/itkHashTableTest.cxx @@ -55,13 +55,13 @@ int itkHashTableTest(int, char *[]) { println("Testing std::hash"); - std::hash H; + const std::hash H; std::cout << "foo -> " << H("foo") << std::endl; std::cout << "bar -> " << H("bar") << std::endl; - std::hash H1; + const std::hash H1; std::cout << "1 -> " << H1(1) << std::endl; std::cout << "234 -> " << H1(234) << std::endl; - std::hash H2; + const std::hash H2; std::cout << "a -> " << H2('a') << std::endl; std::cout << "Z -> " << H2('Z') << std::endl; @@ -122,7 +122,7 @@ itkHashTableTest(int, char *[]) std::cout << "Set is empty." << std::endl; } months.rehash(50); - HashMapType::value_type p("psychotic break", 2); + const HashMapType::value_type p("psychotic break", 2); months.insert(p); auto map_it = months.begin(); HashMapType::const_iterator map_const_it; diff --git a/Modules/Core/Common/test/itkHeavisideStepFunctionTest1.cxx b/Modules/Core/Common/test/itkHeavisideStepFunctionTest1.cxx index 4fdda9e00f2..009e7a8a52b 100644 --- a/Modules/Core/Common/test/itkHeavisideStepFunctionTest1.cxx +++ b/Modules/Core/Common/test/itkHeavisideStepFunctionTest1.cxx @@ -38,9 +38,9 @@ itkHeavisideStepFunctionTest1(int, char *[]) for (int x = minValue; x < maxValue; ++x) { - const InputType ix = x * incValue; - OutputType f = functionBase0->Evaluate(ix); - OutputType df = functionBase0->EvaluateDerivative(ix); + const InputType ix = x * incValue; + const OutputType f = functionBase0->Evaluate(ix); + const OutputType df = functionBase0->EvaluateDerivative(ix); std::cout << ix << ' ' << f << ' ' << df << std::endl; } diff --git a/Modules/Core/Common/test/itkImageAdaptorPipeLineTest.cxx b/Modules/Core/Common/test/itkImageAdaptorPipeLineTest.cxx index 29555076a74..9d5fdfd85d6 100644 --- a/Modules/Core/Common/test/itkImageAdaptorPipeLineTest.cxx +++ b/Modules/Core/Common/test/itkImageAdaptorPipeLineTest.cxx @@ -37,7 +37,7 @@ itkImageAdaptorPipeLineTest(int, char *[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope // scope. - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); //------------------------------------------------------------- // Typedefs @@ -80,7 +80,7 @@ itkImageAdaptorPipeLineTest(int, char *[]) start[1] = 0; start[2] = 0; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; const float spacing[3] = { 1.0, 1.0, 1.0 }; @@ -143,7 +143,7 @@ itkImageAdaptorPipeLineTest(int, char *[]) myFloatIteratorType itf(myFloatImage, myFloatImage->GetRequestedRegion()); - myFloatPixelType initialFloatValue = 5.0; + const myFloatPixelType initialFloatValue = 5.0; while (!itf.IsAtEnd()) { diff --git a/Modules/Core/Common/test/itkImageAlgorithmCopyTest.cxx b/Modules/Core/Common/test/itkImageAlgorithmCopyTest.cxx index ca0c07ea6f2..dd751be7e57 100644 --- a/Modules/Core/Common/test/itkImageAlgorithmCopyTest.cxx +++ b/Modules/Core/Common/test/itkImageAlgorithmCopyTest.cxx @@ -32,7 +32,7 @@ AverageTestCopy(typename TImage::SizeType & size) typename ImageType::RegionType region; - typename ImageType::IndexType index{}; + const typename ImageType::IndexType index{}; region.SetSize(size); region.SetIndex(index); diff --git a/Modules/Core/Common/test/itkImageAlgorithmCopyTest2.cxx b/Modules/Core/Common/test/itkImageAlgorithmCopyTest2.cxx index 478175989fb..8f7a4bb0c53 100644 --- a/Modules/Core/Common/test/itkImageAlgorithmCopyTest2.cxx +++ b/Modules/Core/Common/test/itkImageAlgorithmCopyTest2.cxx @@ -64,10 +64,10 @@ itkImageAlgorithmCopyTest2(int, char *[]) using RegionType = itk::ImageRegion<3>; - RegionType::IndexType index{}; - auto size = RegionType::SizeType::Filled(64); + const RegionType::IndexType index{}; + auto size = RegionType::SizeType::Filled(64); - RegionType region{ index, size }; + const RegionType region{ index, size }; auto image1 = Short3DImageType::New(); diff --git a/Modules/Core/Common/test/itkImageBufferRangeGTest.cxx b/Modules/Core/Common/test/itkImageBufferRangeGTest.cxx index e7584b994b6..c99e14dd501 100644 --- a/Modules/Core/Common/test/itkImageBufferRangeGTest.cxx +++ b/Modules/Core/Common/test/itkImageBufferRangeGTest.cxx @@ -139,8 +139,8 @@ template typename TImage::Pointer CreateSmallImage() { - const auto image = TImage::New(); - typename TImage::SizeType imageSize{}; + const auto image = TImage::New(); + const typename TImage::SizeType imageSize{}; image->SetRegions(imageSize); SetVectorLengthIfImageIsVectorImage(*image, 1); image->AllocateInitialized(); @@ -246,7 +246,7 @@ TEST(ImageBufferRange, EquivalentBeginOrEndIteratorsCompareEqual) const auto image = CreateImage(2, 3); - ImageBufferRange range{ *image }; + const ImageBufferRange range{ *image }; const ImageBufferRange::iterator begin = range.begin(); const ImageBufferRange::iterator end = range.end(); @@ -279,7 +279,7 @@ TEST(ImageBufferRange, BeginAndEndDoNotCompareEqual) const auto image = CreateImage(2, 3); - ImageBufferRange range{ *image }; + const ImageBufferRange range{ *image }; EXPECT_FALSE(range.begin() == range.end()); EXPECT_NE(range.begin(), range.end()); @@ -293,7 +293,7 @@ TEST(ImageBufferRange, IteratorConvertsToConstIterator) const auto image = CreateImage(2, 3); - ImageBufferRange range{ *image }; + const ImageBufferRange range{ *image }; const ImageBufferRange::iterator begin = range.begin(); const ImageBufferRange::const_iterator const_begin_from_begin = begin; @@ -317,7 +317,7 @@ TEST(ImageBufferRange, IteratorsCanBePassedToStdVectorConstructor) }; const auto image = CreateImageFilledWithSequenceOfNaturalNumbers(sizeX, sizeY); - ImageBufferRange range{ *image }; + const ImageBufferRange range{ *image }; // Easily store all pixels of the ImageBufferRange in an std::vector: const std::vector stdVector(range.begin(), range.end()); @@ -339,7 +339,7 @@ TEST(ImageBufferRange, IteratorsCanBePassedToStdReverseCopy) }; const auto image = CreateImageFilledWithSequenceOfNaturalNumbers(sizeX, sizeY); - ImageBufferRange range{ *image }; + const ImageBufferRange range{ *image }; const unsigned int numberOfPixels = sizeX * sizeY; @@ -377,7 +377,7 @@ TEST(ImageBufferRange, IteratorsCanBePassedToStdInnerProduct) }; const auto image = CreateImageFilledWithSequenceOfNaturalNumbers(sizeX, sizeY); - ImageBufferRange range{ *image }; + const ImageBufferRange range{ *image }; const double innerProduct = std::inner_product(range.begin(), range.end(), range.begin(), 0.0); @@ -398,7 +398,7 @@ TEST(ImageBufferRange, IteratorsCanBePassedToStdForEach) }; const auto image = CreateImageFilledWithSequenceOfNaturalNumbers(sizeX, sizeY); - ImageBufferRange range{ *image }; + const ImageBufferRange range{ *image }; std::for_each(range.begin(), range.end(), [](const PixelType pixel) { EXPECT_TRUE(pixel > 0); }); } @@ -451,7 +451,7 @@ TEST(ImageBufferRange, DistanceBetweenIteratorsCanBeObtainedBySubtraction) }; const auto image = CreateImage(sizeX, sizeY); - ImageBufferRange range{ *image }; + const ImageBufferRange range{ *image }; ImageBufferRange::iterator it1 = range.begin(); @@ -483,7 +483,7 @@ TEST(ImageBufferRange, IteratorReferenceActsLikeARealReference) const auto image = CreateImageFilledWithSequenceOfNaturalNumbers(sizeX, sizeY); using RangeType = ImageBufferRange; - RangeType range{ *image }; + const RangeType range{ *image }; RangeType::iterator it = range.begin(); std::iterator_traits::reference reference1 = *it; @@ -541,9 +541,9 @@ TEST(ImageBufferRange, SupportsVectorImage) image->FillBuffer(fillPixelValue); using RangeType = ImageBufferRange; - RangeType range{ *image }; + const RangeType range{ *image }; - for (PixelType pixelValue : range) + for (const PixelType pixelValue : range) { EXPECT_EQ(pixelValue, fillPixelValue); } @@ -572,7 +572,7 @@ TEST(ImageBufferRange, IteratorsCanBePassedToStdSort) }; const auto image = CreateImageFilledWithSequenceOfNaturalNumbers(sizeX, sizeY); - ImageBufferRange range{ *image }; + const ImageBufferRange range{ *image }; // Initial order: (1, 2, 3, ..., 9). const std::vector initiallyOrderedPixels(range.cbegin(), range.cend()); @@ -603,7 +603,7 @@ TEST(ImageBufferRange, IteratorsCanBePassedToStdNthElement) }; const auto image = CreateImageFilledWithSequenceOfNaturalNumbers(sizeX, sizeY); - ImageBufferRange range{ *image }; + const ImageBufferRange range{ *image }; std::reverse(range.begin(), range.end()); @@ -643,7 +643,7 @@ TEST(ImageBufferRange, IteratorsSupportRandomAccess) }; const auto image = CreateImageFilledWithSequenceOfNaturalNumbers(sizeX, sizeY); - RangeType range{ *image }; + const RangeType range{ *image }; // Testing expressions from Table 111 "Random access iterator requirements // (in addition to bidirectional iterator)", C++11 Standard, section 24.2.7 @@ -664,12 +664,12 @@ TEST(ImageBufferRange, IteratorsSupportRandomAccess) { // Expression to be tested: 'r += n' - difference_type n = 3; + constexpr difference_type n = 3; r = initialIterator; - const auto expectedResult = [&r, n] { + const auto expectedResult = [&r](const difference_type nn) { // Operational semantics, as specified by the C++11 Standard: - difference_type m = n; + difference_type m = nn; if (m >= 0) while (m--) ++r; @@ -677,7 +677,7 @@ TEST(ImageBufferRange, IteratorsSupportRandomAccess) while (m++) --r; return r; - }(); + }(n); r = initialIterator; auto && actualResult = r += n; EXPECT_EQ(actualResult, expectedResult); @@ -685,29 +685,29 @@ TEST(ImageBufferRange, IteratorsSupportRandomAccess) } { // Expressions to be tested: 'a + n' and 'n + a' - difference_type n = 3; + constexpr difference_type n = 3; static_assert(std::is_same_v, "Return type tested"); static_assert(std::is_same_v, "Return type tested"); - const auto expectedResult = [a, n] { + const auto expectedResult = [a](const difference_type nn) { // Operational semantics, as specified by the C++11 Standard: X tmp = a; - return tmp += n; - }(); + return tmp += nn; + }(n); EXPECT_EQ(a + n, expectedResult); EXPECT_TRUE(a + n == n + a); } { // Expression to be tested: 'r -= n' - difference_type n = 3; + constexpr difference_type n = 3; r = initialIterator; - const auto expectedResult = [&r, n] { + const auto expectedResult = [&r](const difference_type nn) { // Operational semantics, as specified by the C++11 Standard: - return r += -n; - }(); + return r += -nn; + }(n); r = initialIterator; auto && actualResult = r -= n; EXPECT_EQ(actualResult, expectedResult); @@ -715,15 +715,15 @@ TEST(ImageBufferRange, IteratorsSupportRandomAccess) } { // Expression to be tested: 'a - n' - difference_type n = -3; + constexpr difference_type n = -3; static_assert(std::is_same_v, "Return type tested"); - const auto expectedResult = [a, n] { + const auto expectedResult = [a](const difference_type nn) { // Operational semantics, as specified by the C++11 Standard: X tmp = a; - return tmp -= n; - }(); + return tmp -= nn; + }(n); EXPECT_EQ(a - n, expectedResult); } @@ -731,13 +731,13 @@ TEST(ImageBufferRange, IteratorsSupportRandomAccess) // Expression to be tested: 'b - a' static_assert(std::is_same_v, "Return type tested"); - difference_type n = b - a; + const difference_type n = b - a; EXPECT_TRUE(a + n == b); EXPECT_TRUE(b == a + (b - a)); } { // Expression to be tested: 'a[n]' - difference_type n = 3; + constexpr difference_type n = 3; static_assert(std::is_convertible_v, "Return type tested"); EXPECT_EQ(a[n], *(a + n)); } @@ -768,7 +768,7 @@ TEST(ImageBufferRange, SupportsSubscript) }; const auto image = CreateImageFilledWithSequenceOfNaturalNumbers(sizeX, sizeY); - RangeType range{ *image }; + const RangeType range{ *image }; const size_t numberOfNeighbors = range.size(); @@ -795,7 +795,7 @@ TEST(ImageBufferRange, ProvidesReverseIterators) }; const auto image = CreateImageFilledWithSequenceOfNaturalNumbers(sizeX, sizeY); - RangeType range{ *image }; + const RangeType range{ *image }; const unsigned int numberOfPixels = sizeX * sizeY; diff --git a/Modules/Core/Common/test/itkImageDuplicatorTest.cxx b/Modules/Core/Common/test/itkImageDuplicatorTest.cxx index f8005057060..9a71866af96 100644 --- a/Modules/Core/Common/test/itkImageDuplicatorTest.cxx +++ b/Modules/Core/Common/test/itkImageDuplicatorTest.cxx @@ -33,7 +33,7 @@ itkImageDuplicatorTest(int, char *[]) size[0] = 10; size[1] = 20; size[2] = 30; - ImageType::IndexType index{}; + const ImageType::IndexType index{}; region.SetSize(size); region.SetIndex(index); @@ -191,7 +191,7 @@ itkImageDuplicatorTest(int, char *[]) RGBduplicator->SetInputImage(m_RGBImage); RGBduplicator->Update(); - RGBImageType::Pointer RGBImageCopy = RGBduplicator->GetOutput(); + const RGBImageType::Pointer RGBImageCopy = RGBduplicator->GetOutput(); itk::ImageRegionIterator it4(RGBImageCopy, RGBImageCopy->GetLargestPossibleRegion()); @@ -204,7 +204,7 @@ itkImageDuplicatorTest(int, char *[]) while (!it4.IsAtEnd()) { - itk::RGBPixel pixel = it4.Get(); + const itk::RGBPixel pixel = it4.Get(); if (pixel.GetRed() != r) { std::cout << "Error: Pixel R value mismatched: " << static_cast(pixel.GetRed()) << " vs. " @@ -269,7 +269,7 @@ itkImageDuplicatorTest(int, char *[]) Vectorduplicator->SetInputImage(vectorImage); Vectorduplicator->Update(); - VectorImageType::Pointer vectorImageCopy = Vectorduplicator->GetOutput(); + const VectorImageType::Pointer vectorImageCopy = Vectorduplicator->GetOutput(); itk::ImageRegionIterator it3(vectorImage, vectorImage->GetLargestPossibleRegion()); itk::ImageRegionIterator it4(vectorImageCopy, vectorImageCopy->GetLargestPossibleRegion()); @@ -278,8 +278,8 @@ itkImageDuplicatorTest(int, char *[]) while (!it4.IsAtEnd()) { - itk::VariableLengthVector pixel4 = it4.Get(); - itk::VariableLengthVector pixel3 = it3.Get(); + const itk::VariableLengthVector pixel4 = it4.Get(); + const itk::VariableLengthVector pixel3 = it3.Get(); if (pixel4 != pixel3) { return EXIT_FAILURE; diff --git a/Modules/Core/Common/test/itkImageDuplicatorTest2.cxx b/Modules/Core/Common/test/itkImageDuplicatorTest2.cxx index 85b5a982a4c..5217028e53e 100644 --- a/Modules/Core/Common/test/itkImageDuplicatorTest2.cxx +++ b/Modules/Core/Common/test/itkImageDuplicatorTest2.cxx @@ -47,11 +47,11 @@ itkImageDuplicatorTest2(int argc, char * argv[]) { const auto inImage = itk::ReadImage(argv[1]); - ImageType::RegionType lpr = inImage->GetLargestPossibleRegion(); - ImageType::RegionType region = lpr; + const ImageType::RegionType lpr = inImage->GetLargestPossibleRegion(); + ImageType::RegionType region = lpr; for (unsigned int d = 0; d < Dimension; ++d) { - itk::IndexValueType size = region.GetSize(d); + const itk::IndexValueType size = region.GetSize(d); region.SetIndex(d, size / 4); region.SetSize(d, size / 2); } @@ -59,11 +59,11 @@ itkImageDuplicatorTest2(int argc, char * argv[]) absF->SetInput(inImage); absF->GetOutput()->SetRequestedRegion(region); absF->Update(); - ImageType::Pointer absImage = absF->GetOutput(); // different buffered and largest regions + const ImageType::Pointer absImage = absF->GetOutput(); // different buffered and largest regions dup->SetInputImage(absF->GetOutput()); dup->Update(); - ImageType::ConstPointer dupImage = dup->GetOutput(); + const ImageType::ConstPointer dupImage = dup->GetOutput(); itk::WriteImage(dupImage, argv[2]); std::cout << "Test SUCCESS" << std::endl; diff --git a/Modules/Core/Common/test/itkImageIORegionGTest.cxx b/Modules/Core/Common/test/itkImageIORegionGTest.cxx index fc1e8297d61..9b2b9ab97ea 100644 --- a/Modules/Core/Common/test/itkImageIORegionGTest.cxx +++ b/Modules/Core/Common/test/itkImageIORegionGTest.cxx @@ -173,7 +173,7 @@ TEST(ImageIORegion, IsTwoDimensionalByDefault) EXPECT_EQ(itk::ImageIORegion(), expectedTwoDimensionalRegion); - itk::ImageIORegion defaultInitializedRegion; + const itk::ImageIORegion defaultInitializedRegion; EXPECT_EQ(defaultInitializedRegion, expectedTwoDimensionalRegion); } diff --git a/Modules/Core/Common/test/itkImageIteratorTest.cxx b/Modules/Core/Common/test/itkImageIteratorTest.cxx index 0d857e3df7f..6f17240027a 100644 --- a/Modules/Core/Common/test/itkImageIteratorTest.cxx +++ b/Modules/Core/Common/test/itkImageIteratorTest.cxx @@ -27,8 +27,8 @@ template void TestConstPixelAccess(const itk::Image & in, itk::Image & out) { - typename itk::Image::IndexType regionStartIndex3D = { { 5, 10, 15 } }; - typename itk::Image::IndexType regionEndIndex3D = { { 8, 15, 17 } }; + const typename itk::Image::IndexType regionStartIndex3D = { { 5, 10, 15 } }; + const typename itk::Image::IndexType regionEndIndex3D = { { 8, 15, 17 } }; T vec; @@ -49,20 +49,20 @@ itkImageIteratorTest(int, char *[]) constexpr unsigned int ImageDimension = 3; std::cout << "Creating an image" << std::endl; - itk::Image, ImageDimension>::Pointer o3 = + const itk::Image, ImageDimension>::Pointer o3 = itk::Image, ImageDimension>::New(); float origin3D[ImageDimension] = { 5.0f, 2.1f, 8.1f }; float spacing3D[ImageDimension] = { 1.5f, 2.1f, 1.0f }; - itk::Image, ImageDimension>::SizeType imageSize3D = { { 20, 40, 60 } }; + const itk::Image, ImageDimension>::SizeType imageSize3D = { { 20, 40, 60 } }; - itk::Image, ImageDimension>::IndexType startIndex3D = { { 5, 4, 1 } }; - itk::Image, ImageDimension>::IndexType regionStartIndex3D = { { 5, 10, 12 } }; - itk::Image, ImageDimension>::IndexType regionEndIndex3D = { { 8, 15, 17 } }; + const itk::Image, ImageDimension>::IndexType startIndex3D = { { 5, 4, 1 } }; + const itk::Image, ImageDimension>::IndexType regionStartIndex3D = { { 5, 10, 12 } }; + const itk::Image, ImageDimension>::IndexType regionEndIndex3D = { { 8, 15, 17 } }; - itk::Image, ImageDimension>::RegionType region{ startIndex3D, imageSize3D }; + const itk::Image, ImageDimension>::RegionType region{ startIndex3D, imageSize3D }; o3->SetRegions(region); o3->SetOrigin(origin3D); o3->SetSpacing(spacing3D); @@ -90,11 +90,11 @@ itkImageIteratorTest(int, char *[]) using VectorImageIterator = itk::ImageIterator; using VectorImageConstIterator = itk::ImageConstIterator; - VectorImageIterator itr1(o3, region); - VectorImageConstIterator itr2(o3, region); + VectorImageIterator itr1(o3, region); + const VectorImageConstIterator itr2(o3, region); // Exercise copy constructor - VectorImageIterator itr3(itr1); + const VectorImageIterator itr3(itr1); // Exercise assignment operator VectorImageIterator itr4; @@ -150,7 +150,7 @@ itkImageIteratorTest(int, char *[]) } // Exercise GetIndex() - VectorImageType::IndexType index1 = itr1.GetIndex(); + const VectorImageType::IndexType index1 = itr1.GetIndex(); if (index1 != startIndex3D) { std::cerr << "Error in GetIndex()" << std::endl; @@ -175,7 +175,7 @@ itkImageIteratorTest(int, char *[]) } // Exercise GetRegion() - VectorImageType::RegionType region1 = itr1.GetRegion(); + const VectorImageType::RegionType region1 = itr1.GetRegion(); if (region1 != region) { std::cerr << "Error in GetRegion()" << std::endl; diff --git a/Modules/Core/Common/test/itkImageIteratorWithIndexTest.cxx b/Modules/Core/Common/test/itkImageIteratorWithIndexTest.cxx index 7d875defc66..87011877286 100644 --- a/Modules/Core/Common/test/itkImageIteratorWithIndexTest.cxx +++ b/Modules/Core/Common/test/itkImageIteratorWithIndexTest.cxx @@ -42,9 +42,9 @@ class itkImageIteratorWithIndexTestIteratorTester auto size = ImageType::SizeType::Filled(100); - typename ImageType::IndexType start{}; + const typename ImageType::IndexType start{}; - typename ImageType::RegionType region{ start, size }; + const typename ImageType::RegionType region{ start, size }; m_Image->SetRegions(region); m_Image->Allocate(); @@ -60,8 +60,8 @@ class itkImageIteratorWithIndexTestIteratorTester it.GoToBegin(); while (!it.IsAtEnd()) { - PixelType value = it.Get(); - PixelType testValue = value * static_cast::ValueType>(2); + const PixelType value = it.Get(); + const PixelType testValue = value * static_cast::ValueType>(2); it.Set(testValue); if (itk::Math::NotExactlyEquals(it.Get(), testValue)) { @@ -87,7 +87,7 @@ class itkImageIteratorWithIndexTestIteratorTester it.GoToBegin(); while (!it.IsAtEnd()) { - PixelType value = it.Get(); + const PixelType value = it.Get(); if (itk::Math::NotExactlyEquals(value, it.Get())) // check repeatibility { std::cerr << "TestConstIterator failed!" << std::endl; @@ -112,7 +112,7 @@ class itkImageIteratorWithIndexTestIteratorTester it.GoToReverseBegin(); while (!it.IsAtReverseEnd()) { - PixelType value = it.Get(); + const PixelType value = it.Get(); if (itk::Math::NotExactlyEquals(value, it.Get())) // check repeatibility { std::cerr << "TestReverseIteration failed!" << std::endl; diff --git a/Modules/Core/Common/test/itkImageIteratorsForwardBackwardTest.cxx b/Modules/Core/Common/test/itkImageIteratorsForwardBackwardTest.cxx index 3061e070ff4..b473a0b2664 100644 --- a/Modules/Core/Common/test/itkImageIteratorsForwardBackwardTest.cxx +++ b/Modules/Core/Common/test/itkImageIteratorsForwardBackwardTest.cxx @@ -35,9 +35,9 @@ itkImageIteratorsForwardBackwardTest(int, char *[]) size[1] = 4; size[2] = 4; - ImageType::IndexType start{}; + const ImageType::IndexType start{}; - ImageType::RegionType region{ start, size }; + const ImageType::RegionType region{ start, size }; myImage->SetRegions(region); myImage->Allocate(); diff --git a/Modules/Core/Common/test/itkImageLinearIteratorTest.cxx b/Modules/Core/Common/test/itkImageLinearIteratorTest.cxx index c82c696668c..d0b3ff667d3 100644 --- a/Modules/Core/Common/test/itkImageLinearIteratorTest.cxx +++ b/Modules/Core/Common/test/itkImageLinearIteratorTest.cxx @@ -32,8 +32,8 @@ itkImageLinearIteratorTest(int, char *[]) using ImageType = itk::Image; - auto myImage = ImageType::New(); - ImageType::ConstPointer myConstImage = myImage; + auto myImage = ImageType::New(); + const ImageType::ConstPointer myConstImage = myImage; ImageType::SizeType size0; @@ -41,9 +41,9 @@ itkImageLinearIteratorTest(int, char *[]) size0[1] = 100; size0[2] = 100; - ImageType::IndexType start0{}; + const ImageType::IndexType start0{}; - ImageType::RegionType region0{ start0, size0 }; + const ImageType::RegionType region0{ start0, size0 }; myImage->SetRegions(region0); myImage->Allocate(); @@ -100,7 +100,7 @@ itkImageLinearIteratorTest(int, char *[]) ConstIteratorType cot(myConstImage, region0); // Test exceptions - int direction = ImageType::GetImageDimension() + 1; + const int direction = ImageType::GetImageDimension() + 1; ITK_TRY_EXPECT_EXCEPTION(cot.SetDirection(direction)); cot.GoToBegin(); @@ -153,7 +153,7 @@ itkImageLinearIteratorTest(int, char *[]) size[1] = 3; size[2] = 4; - ImageType::RegionType region{ start, size }; + const ImageType::RegionType region{ start, size }; std::cout << " IteratorType ior( myImage, region );" << std::endl; IteratorType ior(myImage, region); @@ -232,7 +232,7 @@ itkImageLinearIteratorTest(int, char *[]) size[1] = 12; size[2] = 13; - ImageType::RegionType region{ start, size }; + const ImageType::RegionType region{ start, size }; IteratorType bot(myImage, region); @@ -278,7 +278,7 @@ itkImageLinearIteratorTest(int, char *[]) size[1] = 12; size[2] = 13; - ImageType::RegionType region{ start, size }; + const ImageType::RegionType region{ start, size }; ConstIteratorType cbot(myImage, region); @@ -324,7 +324,7 @@ itkImageLinearIteratorTest(int, char *[]) size[1] = 12; size[2] = 13; - ImageType::RegionType region{ start, size }; + const ImageType::RegionType region{ start, size }; IteratorType cbot(myImage, region); @@ -335,8 +335,8 @@ itkImageLinearIteratorTest(int, char *[]) { while (!cbot.IsAtEndOfLine()) { - ImageType::IndexType index = cbot.GetIndex(); - ImageType::PixelType pixel = cbot.Get(); + const ImageType::IndexType index = cbot.GetIndex(); + const ImageType::PixelType pixel = cbot.Get(); if (index != pixel) { @@ -368,7 +368,7 @@ itkImageLinearIteratorTest(int, char *[]) size[1] = 12; size[2] = 13; - ImageType::RegionType region{ start, size }; + const ImageType::RegionType region{ start, size }; ConstIteratorType cbot(myImage, region); @@ -379,8 +379,8 @@ itkImageLinearIteratorTest(int, char *[]) { while (!cbot.IsAtEndOfLine()) { - ImageType::IndexType index = cbot.GetIndex(); - ImageType::PixelType pixel = cbot.Get(); + const ImageType::IndexType index = cbot.GetIndex(); + const ImageType::PixelType pixel = cbot.Get(); if (index != pixel) { @@ -412,7 +412,7 @@ itkImageLinearIteratorTest(int, char *[]) size[1] = 12; size[2] = 13; - ImageType::RegionType region{ start, size }; + const ImageType::RegionType region{ start, size }; std::cout << " IteratorType cbot( myImage, region );" << std::endl; IteratorType cbot(myImage, region); @@ -463,7 +463,7 @@ itkImageLinearIteratorTest(int, char *[]) size[1] = 12; size[2] = 13; - ImageType::RegionType region{ start, size }; + const ImageType::RegionType region{ start, size }; std::cout << " IteratorType cbot( myImage, region );" << std::endl; IteratorType cbot(myImage, region); @@ -520,7 +520,7 @@ itkImageLinearIteratorTest(int, char *[]) size[1] = 12; size[2] = 13; - ImageType::RegionType region{ start, size }; + const ImageType::RegionType region{ start, size }; ConstIteratorType cbot(myImage, region); @@ -561,7 +561,7 @@ itkImageLinearIteratorTest(int, char *[]) size[1] = 12; size[2] = 13; - ImageType::RegionType region{ start, size }; + const ImageType::RegionType region{ start, size }; ConstIteratorType cbot(myImage, region); diff --git a/Modules/Core/Common/test/itkImageRandomConstIteratorWithOnlyIndexTest.cxx b/Modules/Core/Common/test/itkImageRandomConstIteratorWithOnlyIndexTest.cxx index 6c1ec5f563e..9ce0d8e4de3 100644 --- a/Modules/Core/Common/test/itkImageRandomConstIteratorWithOnlyIndexTest.cxx +++ b/Modules/Core/Common/test/itkImageRandomConstIteratorWithOnlyIndexTest.cxx @@ -32,8 +32,8 @@ itkImageRandomConstIteratorWithOnlyIndexTest(int, char *[]) using ImageType = itk::Image; - auto myImage = ImageType::New(); - ImageType::ConstPointer myConstImage = myImage; + auto myImage = ImageType::New(); + const ImageType::ConstPointer myConstImage = myImage; ImageType::SizeType size0; @@ -41,11 +41,11 @@ itkImageRandomConstIteratorWithOnlyIndexTest(int, char *[]) size0[1] = 100; size0[2] = 100; - unsigned long numberOfSamples = 10; + const unsigned long numberOfSamples = 10; - ImageType::IndexType start0{}; + const ImageType::IndexType start0{}; - ImageType::RegionType region0{ start0, size0 }; + const ImageType::RegionType region0{ start0, size0 }; myImage->SetRegions(region0); myImage->Allocate(); @@ -167,7 +167,7 @@ itkImageRandomConstIteratorWithOnlyIndexTest(int, char *[]) size[1] = 12; size[2] = 13; - ImageType::RegionType region{ start, size }; + const ImageType::RegionType region{ start, size }; RandomConstIteratorType cbot(myImage, region); @@ -176,9 +176,9 @@ itkImageRandomConstIteratorWithOnlyIndexTest(int, char *[]) while (!cbot.IsAtEnd()) { - ImageType::IndexType index = cbot.GetIndex(); + const ImageType::IndexType index = cbot.GetIndex(); it.SetIndex(index); - ImageType::PixelType pixel = it.Get(); + const ImageType::PixelType pixel = it.Get(); if (index != pixel) { diff --git a/Modules/Core/Common/test/itkImageRandomIteratorTest.cxx b/Modules/Core/Common/test/itkImageRandomIteratorTest.cxx index 481f2fb36a1..f482b8cc67f 100644 --- a/Modules/Core/Common/test/itkImageRandomIteratorTest.cxx +++ b/Modules/Core/Common/test/itkImageRandomIteratorTest.cxx @@ -32,8 +32,8 @@ itkImageRandomIteratorTest(int, char *[]) using ImageType = itk::Image; - auto myImage = ImageType::New(); - ImageType::ConstPointer myConstImage = myImage; + auto myImage = ImageType::New(); + const ImageType::ConstPointer myConstImage = myImage; ImageType::SizeType size0; @@ -41,11 +41,11 @@ itkImageRandomIteratorTest(int, char *[]) size0[1] = 100; size0[2] = 100; - unsigned long numberOfSamples = 10; + const unsigned long numberOfSamples = 10; - ImageType::IndexType start0{}; + const ImageType::IndexType start0{}; - ImageType::RegionType region0{ start0, size0 }; + const ImageType::RegionType region0{ start0, size0 }; myImage->SetRegions(region0); myImage->Allocate(); @@ -217,7 +217,7 @@ itkImageRandomIteratorTest(int, char *[]) size[1] = 12; size[2] = 13; - ImageType::RegionType region{ start, size }; + const ImageType::RegionType region{ start, size }; RandomIteratorType cbot(myImage, region); @@ -226,8 +226,8 @@ itkImageRandomIteratorTest(int, char *[]) while (!cbot.IsAtEnd()) { - ImageType::IndexType index = cbot.GetIndex(); - ImageType::PixelType pixel = cbot.Get(); + const ImageType::IndexType index = cbot.GetIndex(); + const ImageType::PixelType pixel = cbot.Get(); if (index != pixel) { @@ -263,7 +263,7 @@ itkImageRandomIteratorTest(int, char *[]) size[1] = 12; size[2] = 13; - ImageType::RegionType region{ start, size }; + const ImageType::RegionType region{ start, size }; RandomConstIteratorType cbot(myImage, region); @@ -272,8 +272,8 @@ itkImageRandomIteratorTest(int, char *[]) while (!cbot.IsAtEnd()) { - ImageType::IndexType index = cbot.GetIndex(); - ImageType::PixelType pixel = cbot.Get(); + const ImageType::IndexType index = cbot.GetIndex(); + const ImageType::PixelType pixel = cbot.Get(); if (index != pixel) { diff --git a/Modules/Core/Common/test/itkImageRandomIteratorTest2.cxx b/Modules/Core/Common/test/itkImageRandomIteratorTest2.cxx index 8772b40b934..855bcd9f538 100644 --- a/Modules/Core/Common/test/itkImageRandomIteratorTest2.cxx +++ b/Modules/Core/Common/test/itkImageRandomIteratorTest2.cxx @@ -50,11 +50,11 @@ itkImageRandomIteratorTest2(int argc, char * argv[]) size[0] = 1000; size[1] = 1000; - unsigned long numberOfSamples = size[0] * size[1]; + const unsigned long numberOfSamples = size[0] * size[1]; - ImageType::IndexType start{}; + const ImageType::IndexType start{}; - ImageType::RegionType region{ start, size }; + const ImageType::RegionType region{ start, size }; image->SetRegions(region); image->AllocateInitialized(); diff --git a/Modules/Core/Common/test/itkImageRandomNonRepeatingIteratorWithIndexTest.cxx b/Modules/Core/Common/test/itkImageRandomNonRepeatingIteratorWithIndexTest.cxx index b94258c424f..89d74776d6e 100644 --- a/Modules/Core/Common/test/itkImageRandomNonRepeatingIteratorWithIndexTest.cxx +++ b/Modules/Core/Common/test/itkImageRandomNonRepeatingIteratorWithIndexTest.cxx @@ -40,15 +40,15 @@ itkImageRandomNonRepeatingIteratorWithIndexTest(int, char *[]) using RandomConstIteratorType = itk::ImageRandomNonRepeatingConstIteratorWithIndex; std::cout << "Creating images" << std::endl; - auto myImage = ImageType::New(); - ImageType::ConstPointer myConstImage = myImage; - ImageType::SizeType size0; + auto myImage = ImageType::New(); + const ImageType::ConstPointer myConstImage = myImage; + ImageType::SizeType size0; size0[0] = 50; size0[1] = 50; size0[2] = 50; - unsigned long numberOfSamples = 10; - ImageType::IndexType start0{}; - ImageType::RegionType region0{ start0, size0 }; + const unsigned long numberOfSamples = 10; + const ImageType::IndexType start0{}; + const ImageType::RegionType region0{ start0, size0 }; myImage->SetRegions(region0); myImage->Allocate(); // Make the priority image @@ -57,8 +57,8 @@ itkImageRandomNonRepeatingIteratorWithIndexTest(int, char *[]) prioritySize[0] = 50; prioritySize[1] = 50; prioritySize[2] = 50; - PriorityImageType::IndexType priorityStart{}; - PriorityImageType::RegionType priorityRegion{ priorityStart, prioritySize }; + const PriorityImageType::IndexType priorityStart{}; + const PriorityImageType::RegionType priorityRegion{ priorityStart, prioritySize }; priorityImage->SetRegions(priorityRegion); priorityImage->Allocate(); // we will make most of this image ones, with a small region of @@ -80,8 +80,8 @@ itkImageRandomNonRepeatingIteratorWithIndexTest(int, char *[]) subsize[0] = 3; subsize[1] = 4; subsize[2] = 5; - PriorityImageType::RegionType subregion{ substart, subsize }; - PriorityIteratorType subit(priorityImage, subregion); + const PriorityImageType::RegionType subregion{ substart, subsize }; + PriorityIteratorType subit(priorityImage, subregion); subit.GoToBegin(); while (!subit.IsAtEnd()) { @@ -233,14 +233,14 @@ itkImageRandomNonRepeatingIteratorWithIndexTest(int, char *[]) size[0] = 11; size[1] = 12; size[2] = 13; - ImageType::RegionType region{ start, size }; - RandomIteratorType cbot(myImage, region); + const ImageType::RegionType region{ start, size }; + RandomIteratorType cbot(myImage, region); cbot.SetNumberOfSamples(numberOfSamples); // 0=x, 1=y, 2=z cbot.GoToBegin(); while (!cbot.IsAtEnd()) { - ImageType::IndexType index = cbot.GetIndex(); - ImageType::PixelType pixel = cbot.Get(); + const ImageType::IndexType index = cbot.GetIndex(); + const ImageType::PixelType pixel = cbot.Get(); if (index != pixel) { std::cerr << "Iterator in region test failed" << std::endl; @@ -270,14 +270,14 @@ itkImageRandomNonRepeatingIteratorWithIndexTest(int, char *[]) size[0] = 11; size[1] = 12; size[2] = 13; - ImageType::RegionType region{ start, size }; - RandomConstIteratorType cbot(myImage, region); + const ImageType::RegionType region{ start, size }; + RandomConstIteratorType cbot(myImage, region); cbot.SetNumberOfSamples(numberOfSamples); cbot.GoToBegin(); while (!cbot.IsAtEnd()) { - ImageType::IndexType index = cbot.GetIndex(); - ImageType::PixelType pixel = cbot.Get(); + const ImageType::IndexType index = cbot.GetIndex(); + const ImageType::PixelType pixel = cbot.Get(); if (index != pixel) { std::cerr << "Iterator in region test failed" << std::endl; @@ -309,7 +309,7 @@ itkImageRandomNonRepeatingIteratorWithIndexTest(int, char *[]) unsigned int count = 0; while (!cbot.IsAtEnd() && count < (subsize[0] * subsize[1] * subsize[2])) { - ImageType::IndexType index = cbot.GetIndex(); + const ImageType::IndexType index = cbot.GetIndex(); if (!subregion.IsInside(index)) { std::cerr << "Iterator in priority region test failed" << std::endl; @@ -340,7 +340,7 @@ itkImageRandomNonRepeatingIteratorWithIndexTest(int, char *[]) unsigned int count = 0; while (!cbot.IsAtEnd() && count < (subsize[0] * subsize[1] * subsize[2])) { - ImageType::IndexType index = cbot.GetIndex(); + const ImageType::IndexType index = cbot.GetIndex(); if (!subregion.IsInside(index)) { std::cerr << "Iterator in priority region test failed" << std::endl; diff --git a/Modules/Core/Common/test/itkImageRandomNonRepeatingIteratorWithIndexTest2.cxx b/Modules/Core/Common/test/itkImageRandomNonRepeatingIteratorWithIndexTest2.cxx index ad9f8c60bc5..4358c10d8b4 100644 --- a/Modules/Core/Common/test/itkImageRandomNonRepeatingIteratorWithIndexTest2.cxx +++ b/Modules/Core/Common/test/itkImageRandomNonRepeatingIteratorWithIndexTest2.cxx @@ -34,12 +34,12 @@ itkImageRandomNonRepeatingIteratorWithIndexTest2(int, char *[]) using ImageType = itk::Image; using RandomConstIteratorType = itk::ImageRandomNonRepeatingConstIteratorWithIndex; - constexpr unsigned long N = 10; - constexpr int Seed = 42; - auto size = ImageType::SizeType::Filled(N); - ImageType::IndexType start{}; - ImageType::RegionType region{ start, size }; - auto myImage = ImageType::New(); + constexpr unsigned long N = 10; + constexpr int Seed = 42; + auto size = ImageType::SizeType::Filled(N); + const ImageType::IndexType start{}; + const ImageType::RegionType region{ start, size }; + auto myImage = ImageType::New(); myImage->SetRegions(region); myImage->Allocate(); using WalkType = std::vector; diff --git a/Modules/Core/Common/test/itkImageRegionConstIteratorWithOnlyIndexTest.cxx b/Modules/Core/Common/test/itkImageRegionConstIteratorWithOnlyIndexTest.cxx index b93f7889204..a687c39693b 100644 --- a/Modules/Core/Common/test/itkImageRegionConstIteratorWithOnlyIndexTest.cxx +++ b/Modules/Core/Common/test/itkImageRegionConstIteratorWithOnlyIndexTest.cxx @@ -81,9 +81,9 @@ class itkImageRegionConstIteratorWithOnlyIndexTestIteratorTester while (!it.IsAtEnd()) { - IndexType index = it.GetIndex(); + const IndexType index = it.GetIndex(); // Check to see if the index is within allowed bounds - bool isInside = region.IsInside(index); + const bool isInside = region.IsInside(index); if (!isInside) { std::cout << "Index is not inside region! - " << index << std::endl; diff --git a/Modules/Core/Common/test/itkImageRegionExclusionIteratorWithIndexTest.cxx b/Modules/Core/Common/test/itkImageRegionExclusionIteratorWithIndexTest.cxx index 080811110a3..0cf0d80d37c 100644 --- a/Modules/Core/Common/test/itkImageRegionExclusionIteratorWithIndexTest.cxx +++ b/Modules/Core/Common/test/itkImageRegionExclusionIteratorWithIndexTest.cxx @@ -71,7 +71,7 @@ RunTest(const TRegion & region, const TRegion & exclusionRegion) { // Exclusion region is completely outside the region. Set it to // have size 0. - typename TRegion::IndexType exclusionStart = region.GetIndex(); + const typename TRegion::IndexType exclusionStart = region.GetIndex(); croppedExclusionRegion.SetIndex(exclusionStart); typename TRegion::SizeType exclusionSize = croppedExclusionRegion.GetSize(); @@ -257,13 +257,13 @@ itkImageRegionExclusionIteratorWithIndexTest(int, char *[]) using IndexType = itk::Index; using RegionType = itk::ImageRegion; - IndexType regionStart{}; - auto regionSize = itk::MakeFilled(7); - RegionType region{ regionStart, regionSize }; + const IndexType regionStart{}; + auto regionSize = itk::MakeFilled(7); + const RegionType region{ regionStart, regionSize }; - SizeType::SizeValueType size[2] = { 4, 7 }; + const SizeType::SizeValueType size[2] = { 4, 7 }; - for (SizeType::SizeValueType s : size) + for (const SizeType::SizeValueType s : size) { for (IndexType::IndexValueType k = -2; k < 6; ++k) { @@ -278,7 +278,7 @@ itkImageRegionExclusionIteratorWithIndexTest(int, char *[]) auto exclusionSize = SizeType::Filled(s); - RegionType exclusionRegion(exclusionStart, exclusionSize); + const RegionType exclusionRegion(exclusionStart, exclusionSize); if (!RunTest(region, exclusionRegion)) { @@ -291,9 +291,9 @@ itkImageRegionExclusionIteratorWithIndexTest(int, char *[]) } // Test exclusion region completely outside the region. - auto exclusionStart = IndexType::Filled(-3); - auto exclusionSize = SizeType::Filled(2); - RegionType exclusionRegion(exclusionStart, exclusionSize); + auto exclusionStart = IndexType::Filled(-3); + auto exclusionSize = SizeType::Filled(2); + const RegionType exclusionRegion(exclusionStart, exclusionSize); if (!RunTest(region, exclusionRegion)) { diff --git a/Modules/Core/Common/test/itkImageRegionIteratorTest.cxx b/Modules/Core/Common/test/itkImageRegionIteratorTest.cxx index 4c8841f645e..0a4cbe33cfe 100644 --- a/Modules/Core/Common/test/itkImageRegionIteratorTest.cxx +++ b/Modules/Core/Common/test/itkImageRegionIteratorTest.cxx @@ -27,8 +27,8 @@ template void TestConstPixelAccess(const itk::Image & in, itk::Image & out) { - typename itk::Image::IndexType regionStartIndex3D = { { 5, 10, 15 } }; - typename itk::Image::IndexType regionEndIndex3D = { { 8, 15, 17 } }; + const typename itk::Image::IndexType regionStartIndex3D = { { 5, 10, 15 } }; + const typename itk::Image::IndexType regionEndIndex3D = { { 8, 15, 17 } }; T vec; @@ -47,21 +47,22 @@ int itkImageRegionIteratorTest(int, char *[]) { std::cout << "Creating an image" << std::endl; - itk::Image, 3>::Pointer o3 = itk::Image, 3>::New(); + const itk::Image, 3>::Pointer o3 = + itk::Image, 3>::New(); int status = 0; float origin3D[3] = { 5.0f, 2.1f, 8.1f }; float spacing3D[3] = { 1.5f, 2.1f, 1.0f }; - itk::Image, 3>::SizeType imageSize3D = { { 20, 40, 60 } }; - itk::Image, 3>::SizeType bufferSize3D = { { 8, 20, 14 } }; - itk::Image, 3>::SizeType regionSize3D = { { 4, 6, 6 } }; + const itk::Image, 3>::SizeType imageSize3D = { { 20, 40, 60 } }; + const itk::Image, 3>::SizeType bufferSize3D = { { 8, 20, 14 } }; + const itk::Image, 3>::SizeType regionSize3D = { { 4, 6, 6 } }; - itk::Image, 3>::IndexType startIndex3D = { { 5, 4, 1 } }; - itk::Image, 3>::IndexType bufferStartIndex3D = { { 2, 3, 5 } }; - itk::Image, 3>::IndexType regionStartIndex3D = { { 5, 10, 12 } }; - itk::Image, 3>::IndexType regionEndIndex3D = { { 8, 15, 17 } }; + const itk::Image, 3>::IndexType startIndex3D = { { 5, 4, 1 } }; + const itk::Image, 3>::IndexType bufferStartIndex3D = { { 2, 3, 5 } }; + const itk::Image, 3>::IndexType regionStartIndex3D = { { 5, 10, 12 } }; + const itk::Image, 3>::IndexType regionEndIndex3D = { { 8, 15, 17 } }; itk::Image, 3>::RegionType region{ startIndex3D, imageSize3D }; @@ -97,11 +98,11 @@ itkImageRegionIteratorTest(int, char *[]) std::cout << "Simple iterator loop: "; for (; !it.IsAtEnd(); ++it) { - itk::Image, 3>::IndexType index = it.GetIndex(); + const itk::Image, 3>::IndexType index = it.GetIndex(); std::cout << index << std::endl; } - itk::ImageRegionConstIterator, 3>> standardCIt(o3, region); + const itk::ImageRegionConstIterator, 3>> standardCIt(o3, region); // Iterate over a region using a simple for loop and a const iterator itk::ImageRegionConstIterator, 3>> cit(o3, region); @@ -109,7 +110,7 @@ itkImageRegionIteratorTest(int, char *[]) std::cout << "Simple const iterator loop: "; for (; !cit.IsAtEnd(); ++cit) { - itk::Image, 3>::IndexType index = cit.GetIndex(); + const itk::Image, 3>::IndexType index = cit.GetIndex(); std::cout << index << std::endl; } @@ -135,11 +136,11 @@ itkImageRegionIteratorTest(int, char *[]) { // Create an image using TestImageType = itk::Image; - TestImageType::IndexType imageCorner{}; + const TestImageType::IndexType imageCorner{}; auto imageSize = TestImageType::SizeType::Filled(3); - TestImageType::RegionType imageRegion(imageCorner, imageSize); + const TestImageType::RegionType imageRegion(imageCorner, imageSize); auto image = TestImageType::New(); image->SetRegions(imageRegion); @@ -163,11 +164,11 @@ itkImageRegionIteratorTest(int, char *[]) } // Setup and iterate over the first region - TestImageType::IndexType region1Start{}; + const TestImageType::IndexType region1Start{}; auto regionSize = TestImageType::SizeType::Filled(2); - TestImageType::RegionType region1(region1Start, regionSize); + const TestImageType::RegionType region1(region1Start, regionSize); itk::ImageRegionConstIterator imageIterator(image, region1); @@ -190,7 +191,7 @@ itkImageRegionIteratorTest(int, char *[]) // Change iteration region auto region2start = TestImageType::IndexType::Filled(1); - TestImageType::RegionType region2(region2start, regionSize); + const TestImageType::RegionType region2(region2start, regionSize); imageIterator.SetRegion(region2); imageIterator.GoToBegin(); diff --git a/Modules/Core/Common/test/itkImageRegionRangeGTest.cxx b/Modules/Core/Common/test/itkImageRegionRangeGTest.cxx index 27adbdf9c92..3237b12b4a1 100644 --- a/Modules/Core/Common/test/itkImageRegionRangeGTest.cxx +++ b/Modules/Core/Common/test/itkImageRegionRangeGTest.cxx @@ -174,7 +174,7 @@ Expect_ImageRegionRange_iterates_forward_over_same_pixels_as_ImageRegionIterator using PixelType = typename TImage::PixelType; itk::ImageRegionIterator imageRegionIterator{ &image, iterationRegion }; - ImageRegionRange range{ image, iterationRegion }; + const ImageRegionRange range{ image, iterationRegion }; ASSERT_TRUE(imageRegionIterator.IsAtBegin()); @@ -194,7 +194,7 @@ Expect_ImageRegionRange_iterates_backward_over_same_pixels_as_ImageRegionIterato const itk::ImageRegion & iterationRegion) { itk::ImageRegionIterator imageRegionIterator{ &image, iterationRegion }; - ImageRegionRange range{ image, iterationRegion }; + const ImageRegionRange range{ image, iterationRegion }; auto rangeIterator = range.cend(); imageRegionIterator.GoToEnd(); @@ -281,7 +281,7 @@ TEST(ImageRegionRange, BeginAndEndOfNonEmptyImageRegionAreNotEqual) const auto image = CreateImage(2, 3); const itk::ImageRegion region{ itk::Size::Filled(2) }; - ImageRegionRange range{ *image, region }; + const ImageRegionRange range{ *image, region }; EXPECT_FALSE(range.begin() == range.end()); EXPECT_NE(range.begin(), range.end()); @@ -298,7 +298,7 @@ TEST(ImageRegionRange, IteratorConvertsToConstIterator) const auto image = CreateImage(2, 3); const itk::ImageRegion region{ itk::Size::Filled(2) }; - RangeType range{ *image, region }; + const RangeType range{ *image, region }; const RangeType::iterator begin = range.begin(); const RangeType::const_iterator const_begin_from_begin = begin; @@ -324,7 +324,7 @@ TEST(ImageRegionRange, IteratorsCanBePassedToStdVectorConstructor) const auto image = CreateImageFilledWithSequenceOfNaturalNumbers(sizeX, sizeY); const itk::ImageRegion region{ itk::Size::Filled(2) }; - ImageRegionRange range{ *image, region }; + const ImageRegionRange range{ *image, region }; // Easily store all pixels of the ImageRegionRange in an std::vector: const std::vector stdVector(range.begin(), range.end()); @@ -348,7 +348,7 @@ TEST(ImageRegionRange, IteratorsCanBePassedToStdReverseCopy) const auto image = CreateImageFilledWithSequenceOfNaturalNumbers(sizeX, sizeY); const itk::ImageRegion region{ itk::Size::Filled(2) }; - ImageRegionRange range{ *image, region }; + const ImageRegionRange range{ *image, region }; const unsigned int numberOfPixels = sizeX * sizeY; @@ -388,7 +388,7 @@ TEST(ImageRegionRange, IteratorsCanBePassedToStdInnerProduct) const auto image = CreateImageFilledWithSequenceOfNaturalNumbers(sizeX, sizeY); const itk::ImageRegion region{ itk::Size::Filled(2) }; - ImageRegionRange range{ *image, region }; + const ImageRegionRange range{ *image, region }; const double innerProduct = std::inner_product(range.begin(), range.end(), range.begin(), 0.0); @@ -411,7 +411,7 @@ TEST(ImageRegionRange, IteratorsCanBePassedToStdForEach) const auto image = CreateImageFilledWithSequenceOfNaturalNumbers(sizeX, sizeY); const itk::ImageRegion region{ itk::Size::Filled(2) }; - ImageRegionRange range{ *image, region }; + const ImageRegionRange range{ *image, region }; std::for_each(range.begin(), range.end(), [](const PixelType pixel) { EXPECT_TRUE(pixel > 0); }); } @@ -477,9 +477,9 @@ TEST(ImageRegionRange, SupportsVectorImage) const itk::ImageRegion region{ itk::Size::Filled(2) }; using RangeType = ImageRegionRange; - RangeType range{ *image, region }; + const RangeType range{ *image, region }; - for (PixelType pixelValue : range) + for (const PixelType pixelValue : range) { EXPECT_EQ(pixelValue, fillPixelValue); } @@ -517,7 +517,7 @@ TEST(ImageRegionRange, ProvidesReverseIterators) const auto image = CreateImageFilledWithSequenceOfNaturalNumbers(sizeX, sizeY); const itk::ImageRegion region{ itk::Size::Filled(2) }; - RangeType range{ *image, region }; + const RangeType range{ *image, region }; const unsigned int numberOfPixels = sizeX * sizeY; diff --git a/Modules/Core/Common/test/itkImageRegionSplitterDirectionTest.cxx b/Modules/Core/Common/test/itkImageRegionSplitterDirectionTest.cxx index 664642ba96d..653eb2a60c1 100644 --- a/Modules/Core/Common/test/itkImageRegionSplitterDirectionTest.cxx +++ b/Modules/Core/Common/test/itkImageRegionSplitterDirectionTest.cxx @@ -25,7 +25,7 @@ int itkImageRegionSplitterDirectionTest(int, char *[]) { - itk::ImageRegionSplitterDirection::Pointer splitter = itk::ImageRegionSplitterDirection::New(); + const itk::ImageRegionSplitterDirection::Pointer splitter = itk::ImageRegionSplitterDirection::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(splitter, ImageRegionSplitterDirection, ImageRegionSplitterBase); diff --git a/Modules/Core/Common/test/itkImageRegionSplitterMultidimensionalTest.cxx b/Modules/Core/Common/test/itkImageRegionSplitterMultidimensionalTest.cxx index 52bc4fcb6af..ad43ba55d1f 100644 --- a/Modules/Core/Common/test/itkImageRegionSplitterMultidimensionalTest.cxx +++ b/Modules/Core/Common/test/itkImageRegionSplitterMultidimensionalTest.cxx @@ -25,7 +25,7 @@ int itkImageRegionSplitterMultidimensionalTest(int, char *[]) { - itk::ImageRegionSplitterMultidimensional::Pointer splitter = itk::ImageRegionSplitterMultidimensional::New(); + const itk::ImageRegionSplitterMultidimensional::Pointer splitter = itk::ImageRegionSplitterMultidimensional::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(splitter, ImageRegionSplitterMultidimensional, ImageRegionSplitterBase); diff --git a/Modules/Core/Common/test/itkImageRegionSplitterSlowDimensionTest.cxx b/Modules/Core/Common/test/itkImageRegionSplitterSlowDimensionTest.cxx index 44470c5289c..0febb5400a2 100644 --- a/Modules/Core/Common/test/itkImageRegionSplitterSlowDimensionTest.cxx +++ b/Modules/Core/Common/test/itkImageRegionSplitterSlowDimensionTest.cxx @@ -25,7 +25,7 @@ int itkImageRegionSplitterSlowDimensionTest(int, char *[]) { - itk::ImageRegionSplitterSlowDimension::Pointer splitter = itk::ImageRegionSplitterSlowDimension::New(); + const itk::ImageRegionSplitterSlowDimension::Pointer splitter = itk::ImageRegionSplitterSlowDimension::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(splitter, ImageRegionSplitterSlowDimension, ImageRegionSplitterBase); diff --git a/Modules/Core/Common/test/itkImageRegionTest.cxx b/Modules/Core/Common/test/itkImageRegionTest.cxx index 4d347aa02f2..030cd5c9035 100644 --- a/Modules/Core/Common/test/itkImageRegionTest.cxx +++ b/Modules/Core/Common/test/itkImageRegionTest.cxx @@ -38,12 +38,12 @@ itkImageRegionTest(int, char *[]) bool passed = true; - SizeType sizeA = { { 10, 20, 30 } }; - SizeType sizeB = { { 5, 10, 15 } }; + SizeType sizeA = { { 10, 20, 30 } }; + const SizeType sizeB = { { 5, 10, 15 } }; - IndexType startA = { { 12, 12, 12 } }; - IndexType startB = { { 14, 14, 14 } }; - IndexType endA = { { 21, 31, 41 } }; + IndexType startA = { { 12, 12, 12 } }; + const IndexType startB = { { 14, 14, 14 } }; + const IndexType endA = { { 21, 31, 41 } }; RegionType regionA; RegionType regionB; @@ -273,7 +273,7 @@ itkImageRegionTest(int, char *[]) std::cout << "NaN < -1 = " << (indexC[0] < -1.0) << std::endl; std::cout << "NaN > -1 = " << (indexC[0] > -1.0) << std::endl; - CoordinateType NaN = ContinuousIndexNumericTraits::quiet_NaN(); + const CoordinateType NaN = ContinuousIndexNumericTraits::quiet_NaN(); std::cout << "RoundHalfIntegerUp(NaN): " << itk::Math::RoundHalfIntegerUp(NaN) << std::endl; std::cout << "RoundHalfIntegerUp< CoordinateType >(NaN) < static_cast (0): " << (itk::Math::RoundHalfIntegerUp(NaN) < static_cast(0)) << std::endl; @@ -316,7 +316,7 @@ itkImageRegionTest(int, char *[]) shrinkRegion.SetSize(shrinkSize); RegionType padAndShrinkRegion = shrinkRegion; - itk::OffsetValueType offsetValueRadius = 4; + const itk::OffsetValueType offsetValueRadius = 4; padAndShrinkRegion.PadByRadius(offsetValueRadius); padAndShrinkRegion.ShrinkByRadius(offsetValueRadius); if (shrinkRegion != padAndShrinkRegion) diff --git a/Modules/Core/Common/test/itkImageReverseIteratorTest.cxx b/Modules/Core/Common/test/itkImageReverseIteratorTest.cxx index 3c1f42218f5..2e8136cfd5d 100644 --- a/Modules/Core/Common/test/itkImageReverseIteratorTest.cxx +++ b/Modules/Core/Common/test/itkImageReverseIteratorTest.cxx @@ -28,8 +28,8 @@ template void TestConstPixelAccess(const itk::Image & in, itk::Image & out) { - typename itk::Image::IndexType regionStartIndex3D = { { 5, 10, 15 } }; - typename itk::Image::IndexType regionEndIndex3D = { { 8, 15, 17 } }; + const typename itk::Image::IndexType regionStartIndex3D = { { 5, 10, 15 } }; + const typename itk::Image::IndexType regionEndIndex3D = { { 8, 15, 17 } }; T vec; @@ -59,14 +59,14 @@ itkImageReverseIteratorTest(int, char *[]) float origin3D[3] = { 5.0f, 2.1f, 8.1f }; float spacing3D[3] = { 1.5f, 2.1f, 1.0f }; - ImageType::SizeType imageSize3D = { { 20, 40, 60 } }; - ImageType::SizeType bufferSize3D = { { 8, 20, 14 } }; - ImageType::SizeType regionSize3D = { { 4, 6, 6 } }; + const ImageType::SizeType imageSize3D = { { 20, 40, 60 } }; + const ImageType::SizeType bufferSize3D = { { 8, 20, 14 } }; + const ImageType::SizeType regionSize3D = { { 4, 6, 6 } }; - ImageType::IndexType startIndex3D = { { 5, 4, 1 } }; - ImageType::IndexType bufferStartIndex3D = { { 2, 3, 5 } }; - ImageType::IndexType regionStartIndex3D = { { 5, 10, 12 } }; - ImageType::IndexType regionEndIndex3D = { { 8, 15, 17 } }; + const ImageType::IndexType startIndex3D = { { 5, 4, 1 } }; + const ImageType::IndexType bufferStartIndex3D = { { 2, 3, 5 } }; + const ImageType::IndexType regionStartIndex3D = { { 5, 10, 12 } }; + const ImageType::IndexType regionEndIndex3D = { { 8, 15, 17 } }; ImageType::RegionType region{ startIndex3D, imageSize3D }; diff --git a/Modules/Core/Common/test/itkImageScanlineIteratorTest1.cxx b/Modules/Core/Common/test/itkImageScanlineIteratorTest1.cxx index 53915073ed5..a1ba34d2193 100644 --- a/Modules/Core/Common/test/itkImageScanlineIteratorTest1.cxx +++ b/Modules/Core/Common/test/itkImageScanlineIteratorTest1.cxx @@ -27,8 +27,8 @@ template void TestConstPixelAccess(const itk::Image & in, itk::Image & out) { - typename itk::Image::IndexType regionStartIndex3D = { { 5, 10, 15 } }; - typename itk::Image::IndexType regionEndIndex3D = { { 8, 15, 17 } }; + const typename itk::Image::IndexType regionStartIndex3D = { { 5, 10, 15 } }; + const typename itk::Image::IndexType regionEndIndex3D = { { 8, 15, 17 } }; T vec; @@ -46,7 +46,8 @@ TestConstPixelAccess(const itk::Image & in, itk::Image, 3>::Pointer o3 = itk::Image, 3>::New(); + const itk::Image, 3>::Pointer o3 = + itk::Image, 3>::New(); int status = EXIT_SUCCESS; @@ -55,14 +56,14 @@ itkImageScanlineIteratorTest1(int, char *[]) using ImageType = itk::Image, 3>; - ImageType::SizeType imageSize3D = { { 20, 40, 60 } }; - ImageType::SizeType bufferSize3D = { { 8, 20, 14 } }; - ImageType::SizeType regionSize3D = { { 4, 6, 6 } }; + const ImageType::SizeType imageSize3D = { { 20, 40, 60 } }; + const ImageType::SizeType bufferSize3D = { { 8, 20, 14 } }; + const ImageType::SizeType regionSize3D = { { 4, 6, 6 } }; - ImageType::IndexType startIndex3D = { { 5, 4, 1 } }; - ImageType::IndexType bufferStartIndex3D = { { 2, 3, 5 } }; - ImageType::IndexType regionStartIndex3D = { { 5, 10, 12 } }; - ImageType::IndexType regionEndIndex3D = { { 8, 15, 17 } }; + const ImageType::IndexType startIndex3D = { { 5, 4, 1 } }; + const ImageType::IndexType bufferStartIndex3D = { { 2, 3, 5 } }; + const ImageType::IndexType regionStartIndex3D = { { 5, 10, 12 } }; + const ImageType::IndexType regionEndIndex3D = { { 8, 15, 17 } }; ImageType::RegionType region{ startIndex3D, imageSize3D }; @@ -93,7 +94,7 @@ itkImageScanlineIteratorTest1(int, char *[]) TestConstPixelAccess(*o3, *o3); - itk::ImageIterator standardIt(o3, region); + const itk::ImageIterator standardIt(o3, region); // Iterate over a region using a simple for loop itk::ImageScanlineIterator it(standardIt); @@ -123,7 +124,7 @@ itkImageScanlineIteratorTest1(int, char *[]) testBeginEnd.GoToBeginOfLine(); testBeginEnd.GoToEndOfLine(); - itk::ImageScanlineConstIterator standardCIt(o3, region); + const itk::ImageScanlineConstIterator standardCIt(o3, region); // Iterate over a region using a simple loop and a const iterator itk::ImageScanlineConstIterator cit(standardIt); @@ -148,11 +149,11 @@ itkImageScanlineIteratorTest1(int, char *[]) { // Create an image using TestImageType = itk::Image; - TestImageType::IndexType imageCorner{}; + const TestImageType::IndexType imageCorner{}; auto imageSize = TestImageType::SizeType::Filled(3); - TestImageType::RegionType imageRegion(imageCorner, imageSize); + const TestImageType::RegionType imageRegion(imageCorner, imageSize); auto image = TestImageType::New(); image->SetRegions(imageRegion); @@ -179,11 +180,11 @@ itkImageScanlineIteratorTest1(int, char *[]) } // Setup and iterate over the first region - TestImageType::IndexType region1Start{}; + const TestImageType::IndexType region1Start{}; auto regionSize = TestImageType::SizeType::Filled(2); - TestImageType::RegionType region1(region1Start, regionSize); + const TestImageType::RegionType region1(region1Start, regionSize); itk::ImageScanlineConstIterator imageIterator(image, region1); @@ -210,7 +211,7 @@ itkImageScanlineIteratorTest1(int, char *[]) // Change iteration region auto region2start = TestImageType::IndexType::Filled(1); - TestImageType::RegionType region2(region2start, regionSize); + const TestImageType::RegionType region2(region2start, regionSize); imageIterator.SetRegion(region2); imageIterator.GoToBegin(); diff --git a/Modules/Core/Common/test/itkImageTest.cxx b/Modules/Core/Common/test/itkImageTest.cxx index 2479c6be8c2..e0e515d47c0 100644 --- a/Modules/Core/Common/test/itkImageTest.cxx +++ b/Modules/Core/Common/test/itkImageTest.cxx @@ -47,8 +47,8 @@ int itkImageTest(int, char *[]) { using Image = itk::Image; - auto image = Image::New(); - Image::ConstPointer myconstptr = image; + auto image = Image::New(); + const Image::ConstPointer myconstptr = image; image->DebugOn(); const char * const knownStringName = "My First Image For Testing."; image->SetObjectName(knownStringName); @@ -85,7 +85,7 @@ itkImageTest(int, char *[]) // test inverse direction std::cout << "Test inverse direction." << std::endl; Image::DirectionType product = direction * image->GetInverseDirection(); - double eps = 1e-06; + const double eps = 1e-06; if (itk::Math::abs(product[0][0] - 1.0) > eps || itk::Math::abs(product[1][1] - 1.0) > eps || itk::Math::abs(product[0][1]) > eps || itk::Math::abs(product[1][0]) > eps) { @@ -118,34 +118,34 @@ itkImageTest(int, char *[]) image->SetOrigin(origin); direction.SetIdentity(); image->SetDirection(direction); - Image::RegionType region; - Image::IndexType index{}; - auto size = Image::SizeType::Filled(4); + Image::RegionType region; + const Image::IndexType index{}; + auto size = Image::SizeType::Filled(4); region.SetIndex(index); region.SetSize(size); image->SetRegions(region); - auto imageRef = Image::New(); - auto spacingRef = itk::MakeFilled(2); - Image::PointType originRef{}; - Image::DirectionType directionRef; + auto imageRef = Image::New(); + auto spacingRef = itk::MakeFilled(2); + const Image::PointType originRef{}; + Image::DirectionType directionRef; directionRef.SetIdentity(); imageRef->SetSpacing(spacingRef); imageRef->SetOrigin(originRef); imageRef->SetDirection(directionRef); - Image::IndexType indexRef{}; - auto sizeRef = itk::MakeFilled(5); - Image::RegionType regionRef{ indexRef, sizeRef }; + const Image::IndexType indexRef{}; + auto sizeRef = itk::MakeFilled(5); + const Image::RegionType regionRef{ indexRef, sizeRef }; imageRef->SetRegions(regionRef); using TransformType = itk::Transform; - Image::RegionType boxRegion = itk::ImageAlgorithm::EnlargeRegionOverBox(image->GetLargestPossibleRegion(), - image.GetPointer(), - imageRef.GetPointer(), - static_cast(nullptr)); - Image::IndexType correctIndex{}; - auto correctSize = Image::SizeType::Filled(3); + const Image::RegionType boxRegion = itk::ImageAlgorithm::EnlargeRegionOverBox(image->GetLargestPossibleRegion(), + image.GetPointer(), + imageRef.GetPointer(), + static_cast(nullptr)); + const Image::IndexType correctIndex{}; + auto correctSize = Image::SizeType::Filled(3); if (!(boxRegion.GetIndex() == correctIndex) || !(boxRegion.GetSize() == correctSize)) { std::cerr << "EnlargeRegionOverBox test failed: " @@ -154,18 +154,18 @@ itkImageTest(int, char *[]) } using Image3D = itk::Image; - auto volume = Image3D::New(); - auto spacingVol = itk::MakeFilled(1); - Image3D::PointType originVol{}; - Image3D::DirectionType directionVol; + auto volume = Image3D::New(); + auto spacingVol = itk::MakeFilled(1); + const Image3D::PointType originVol{}; + Image3D::DirectionType directionVol; directionVol.SetIdentity(); volume->SetSpacing(spacingVol); volume->SetOrigin(originVol); volume->SetDirection(directionVol); - Image3D::RegionType cuboid; - Image3D::IndexType indexCuboid{}; - Image3D::SizeType sizeCuboid; + Image3D::RegionType cuboid; + const Image3D::IndexType indexCuboid{}; + Image3D::SizeType sizeCuboid; sizeCuboid[0] = 1; sizeCuboid[1] = 2; sizeCuboid[2] = 3; @@ -176,12 +176,12 @@ itkImageTest(int, char *[]) using ProjectionTransformType = TestTransform; ProjectionTransformType * projectionTransform = new ProjectionTransformType; - Image::RegionType rectangleRegion = itk::ImageAlgorithm::EnlargeRegionOverBox( + const Image::RegionType rectangleRegion = itk::ImageAlgorithm::EnlargeRegionOverBox( volume->GetLargestPossibleRegion(), volume.GetPointer(), imageRef.GetPointer(), projectionTransform); delete projectionTransform; - Image::IndexType correctRectangleIndex{}; - Image::SizeType correctRectangleSize; + const Image::IndexType correctRectangleIndex{}; + Image::SizeType correctRectangleSize; correctRectangleSize[0] = 1; correctRectangleSize[1] = 2; if (!(rectangleRegion.GetIndex() == correctRectangleIndex) || !(rectangleRegion.GetSize() == correctRectangleSize)) @@ -194,7 +194,7 @@ itkImageTest(int, char *[]) using TestIdentityTransformType = TestTransform; TestIdentityTransformType * testIdentityTransform = new TestIdentityTransformType; - Image::RegionType tesBoxRegion = itk::ImageAlgorithm::EnlargeRegionOverBox( + const Image::RegionType tesBoxRegion = itk::ImageAlgorithm::EnlargeRegionOverBox( image->GetLargestPossibleRegion(), image.GetPointer(), imageRef.GetPointer(), testIdentityTransform); delete testIdentityTransform; diff --git a/Modules/Core/Common/test/itkImageToImageToleranceTest.cxx b/Modules/Core/Common/test/itkImageToImageToleranceTest.cxx index 7741506f68e..4a3de06d1f9 100644 --- a/Modules/Core/Common/test/itkImageToImageToleranceTest.cxx +++ b/Modules/Core/Common/test/itkImageToImageToleranceTest.cxx @@ -27,7 +27,7 @@ itkImageToImageToleranceTest(int, char *[]) auto image1 = ImageType::New(); auto image2 = ImageType::New(); - ImageType::SizeType size = { { 3, 3, 3 } }; + const ImageType::SizeType size = { { 3, 3, 3 } }; image1->SetRegions(size); image1->Allocate(); image1->FillBuffer(1); diff --git a/Modules/Core/Common/test/itkImageVectorOptimizerParametersHelperTest.cxx b/Modules/Core/Common/test/itkImageVectorOptimizerParametersHelperTest.cxx index eeb0f440f19..7a9f224a3af 100644 --- a/Modules/Core/Common/test/itkImageVectorOptimizerParametersHelperTest.cxx +++ b/Modules/Core/Common/test/itkImageVectorOptimizerParametersHelperTest.cxx @@ -53,11 +53,11 @@ testMemoryAccess(OptimizerParametersType & params, ImageVectorPointer imageOfVec // The image index returns a N-dim vector, so have to check each // element against the values returned by parameter object. - itk::OffsetValueType offset = (x + y * dimLength) * VectorDimension; - VectorPixelType vectorpixel = imageOfVectors->GetPixel(index); + const itk::OffsetValueType offset = (x + y * dimLength) * VectorDimension; + VectorPixelType vectorpixel = imageOfVectors->GetPixel(index); for (itk::SizeValueType ind = 0; ind < VectorDimension; ++ind) { - ValueType paramsValue = params[offset + ind]; + const ValueType paramsValue = params[offset + ind]; if (itk::Math::NotExactlyEquals(vectorpixel[ind], paramsValue)) { std::cout << "VectorImage pixel value does not match params value." @@ -86,20 +86,20 @@ itkImageVectorOptimizerParametersHelperTest(int, char *[]) constexpr int dimLength = 3; size.Fill(dimLength); - RegionType region{ start, size }; + const RegionType region{ start, size }; const ImageVectorPointer imageOfVectors = ImageVectorType::New(); imageOfVectors->SetRegions(region); imageOfVectors->Allocate(); - ImageVectorType::PointType origin{}; - auto spacing = itk::MakeFilled(1.0); + const ImageVectorType::PointType origin{}; + auto spacing = itk::MakeFilled(1.0); imageOfVectors->SetOrigin(origin); imageOfVectors->SetSpacing(spacing); - ValueType vectorinitvalues[VectorDimension] = { 0.0, 0.1, 0.2, 0.3 }; - VectorPixelType vectorvalues(vectorinitvalues); + ValueType vectorinitvalues[VectorDimension] = { 0.0, 0.1, 0.2, 0.3 }; + const VectorPixelType vectorvalues(vectorinitvalues); // // Fill up the image values with the function diff --git a/Modules/Core/Common/test/itkImportImageTest.cxx b/Modules/Core/Common/test/itkImportImageTest.cxx index 0ec73492f48..c70223a13b4 100644 --- a/Modules/Core/Common/test/itkImportImageTest.cxx +++ b/Modules/Core/Common/test/itkImportImageTest.cxx @@ -43,10 +43,10 @@ itkImportImageTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(basicImport, ImportImageFilter, ImageSource); - ShortImage::Pointer image; - itk::ImageRegion region; - itk::ImageRegion::IndexType index = { { 0, 0 } }; - itk::ImageRegion::SizeType size = { { 8, 12 } }; + ShortImage::Pointer image; + itk::ImageRegion region; + const itk::ImageRegion::IndexType index = { { 0, 0 } }; + const itk::ImageRegion::SizeType size = { { 8, 12 } }; region.SetIndex(index); region.SetSize(size); // local scope to make sure that imported data is not deleted with ImportImageFilter @@ -81,7 +81,7 @@ itkImportImageTest(int, char *[]) image = import->GetOutput(); } // Create another filter - itk::ShrinkImageFilter::Pointer shrink = + const itk::ShrinkImageFilter::Pointer shrink = itk::ShrinkImageFilter::New(); shrink->SetInput(image); diff --git a/Modules/Core/Common/test/itkIteratorTests.cxx b/Modules/Core/Common/test/itkIteratorTests.cxx index 63ac8f6342f..b143b04502b 100644 --- a/Modules/Core/Common/test/itkIteratorTests.cxx +++ b/Modules/Core/Common/test/itkIteratorTests.cxx @@ -34,13 +34,13 @@ itkIteratorTests(int, char *[]) double origin3D[3] = { 5, 2.1, 8.1 }; double spacing3D[3] = { 1.5, 2.1, 1 }; - ScalarImage::SizeType imageSize3D = { { 200, 200, 200 } }; - ScalarImage::SizeType bufferSize3D = { { 200, 200, 200 } }; - ScalarImage::SizeType regionSize3D = { { 190, 190, 190 } }; + const ScalarImage::SizeType imageSize3D = { { 200, 200, 200 } }; + const ScalarImage::SizeType bufferSize3D = { { 200, 200, 200 } }; + const ScalarImage::SizeType regionSize3D = { { 190, 190, 190 } }; - ScalarImage::IndexType startIndex3D = { { 0, 0, 0 } }; - ScalarImage::IndexType bufferStartIndex3D = { { 0, 0, 0 } }; - ScalarImage::IndexType regionStartIndex3D = { { 5, 5, 5 } }; + const ScalarImage::IndexType startIndex3D = { { 0, 0, 0 } }; + const ScalarImage::IndexType bufferStartIndex3D = { { 0, 0, 0 } }; + const ScalarImage::IndexType regionStartIndex3D = { { 5, 5, 5 } }; ScalarImage::RegionType region{ startIndex3D, imageSize3D }; @@ -58,7 +58,7 @@ itkIteratorTests(int, char *[]) o3->Allocate(); // extra variables - unsigned long num = 190 * 190 * 190; + const unsigned long num = 190 * 190 * 190; bool passed = true; // memset @@ -95,7 +95,7 @@ itkIteratorTests(int, char *[]) } } // 3 nested loops - unsigned long len = 190; + const unsigned long len = 190; start = clock(); { unsigned int i = 0; @@ -124,7 +124,7 @@ itkIteratorTests(int, char *[]) start = clock(); itk::ImageRegionIterator it(o3, region); - unsigned short scalar = 5; + const unsigned short scalar = 5; { unsigned int i = 0; diff --git a/Modules/Core/Common/test/itkLightObjectTest.cxx b/Modules/Core/Common/test/itkLightObjectTest.cxx index c679662a112..6dc19305dbb 100644 --- a/Modules/Core/Common/test/itkLightObjectTest.cxx +++ b/Modules/Core/Common/test/itkLightObjectTest.cxx @@ -43,8 +43,8 @@ itkLightObjectTest(int, char *[]) std::cout << counts1 << std::endl; { // initialize scope for a SmartPointer - ObjectType::Pointer secondreference = light; - const int counts2 = light->GetReferenceCount(); + const ObjectType::Pointer secondreference = light; + const int counts2 = light->GetReferenceCount(); if (counts2 != counts1 + 1) { std::cerr << "Problem in Reference counting increment" << std::endl; diff --git a/Modules/Core/Common/test/itkLineIteratorTest.cxx b/Modules/Core/Common/test/itkLineIteratorTest.cxx index 6904132b7e1..e947b883a89 100644 --- a/Modules/Core/Common/test/itkLineIteratorTest.cxx +++ b/Modules/Core/Common/test/itkLineIteratorTest.cxx @@ -42,11 +42,11 @@ itkLineIteratorTest(int argc, char * argv[]) // Set up a test image - ImageType::RegionType::IndexType index{}; + const ImageType::RegionType::IndexType index{}; auto size = ImageType::RegionType::SizeType::Filled(200); - ImageType::RegionType region{ index, size }; + const ImageType::RegionType region{ index, size }; auto output = ImageType::New(); output->SetRegions(region); diff --git a/Modules/Core/Common/test/itkLoggerManagerTest.cxx b/Modules/Core/Common/test/itkLoggerManagerTest.cxx index 8707778c72d..fd655504a0b 100644 --- a/Modules/Core/Common/test/itkLoggerManagerTest.cxx +++ b/Modules/Core/Common/test/itkLoggerManagerTest.cxx @@ -36,25 +36,26 @@ itkLoggerManagerTest(int argc, char * argv[]) } // Create an ITK StdStreamLogOutputs - itk::StdStreamLogOutput::Pointer coutput = itk::StdStreamLogOutput::New(); - itk::StdStreamLogOutput::Pointer foutput = itk::StdStreamLogOutput::New(); + const itk::StdStreamLogOutput::Pointer coutput = itk::StdStreamLogOutput::New(); + const itk::StdStreamLogOutput::Pointer foutput = itk::StdStreamLogOutput::New(); coutput->SetStream(std::cout); std::ofstream fout(argv[1]); foutput->SetStream(fout); // Create an ITK Loggers using itk::LoggerManager - itk::LoggerManager::Pointer manager = itk::LoggerManager::New(); + const itk::LoggerManager::Pointer manager = itk::LoggerManager::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(manager, LoggerManager, Object); - itk::Logger::Pointer logger = manager->CreateLogger("org.itk.logTester.logger", - itk::LoggerBase::PriorityLevelEnum::DEBUG, - itk::LoggerBase::PriorityLevelEnum::CRITICAL); + const itk::Logger::Pointer logger = manager->CreateLogger("org.itk.logTester.logger", + itk::LoggerBase::PriorityLevelEnum::DEBUG, + itk::LoggerBase::PriorityLevelEnum::CRITICAL); - itk::ThreadLogger::Pointer t_logger = manager->CreateThreadLogger("org.itk.ThreadLogger", - itk::LoggerBase::PriorityLevelEnum::WARNING, - itk::LoggerBase::PriorityLevelEnum::CRITICAL); + const itk::ThreadLogger::Pointer t_logger = + manager->CreateThreadLogger("org.itk.ThreadLogger", + itk::LoggerBase::PriorityLevelEnum::WARNING, + itk::LoggerBase::PriorityLevelEnum::CRITICAL); std::cout << "Testing itk::LoggerManager" << std::endl; diff --git a/Modules/Core/Common/test/itkLoggerOutputTest.cxx b/Modules/Core/Common/test/itkLoggerOutputTest.cxx index 0e628b02f43..f759ef58d87 100644 --- a/Modules/Core/Common/test/itkLoggerOutputTest.cxx +++ b/Modules/Core/Common/test/itkLoggerOutputTest.cxx @@ -36,14 +36,14 @@ itkLoggerOutputTest(int argc, char * argv[]) // Create an ITK StdStreamLogOutputs - itk::StdStreamLogOutput::Pointer coutput = itk::StdStreamLogOutput::New(); - itk::StdStreamLogOutput::Pointer foutput = itk::StdStreamLogOutput::New(); + const itk::StdStreamLogOutput::Pointer coutput = itk::StdStreamLogOutput::New(); + const itk::StdStreamLogOutput::Pointer foutput = itk::StdStreamLogOutput::New(); coutput->SetStream(std::cout); std::ofstream fout(argv[1]); foutput->SetStream(fout); // Create an ITK Logger - itk::Logger::Pointer logger = itk::Logger::New(); + const itk::Logger::Pointer logger = itk::Logger::New(); std::cout << "Testing itk::LoggerOutput" << std::endl; @@ -62,7 +62,7 @@ itkLoggerOutputTest(int argc, char * argv[]) std::cout << " Level For Flushing: " << logger->GetLevelForFlushing() << std::endl; // Create an ITK LoggerOutput and then test it. - itk::LoggerOutput::Pointer pOver = itk::LoggerOutput::New(); + const itk::LoggerOutput::Pointer pOver = itk::LoggerOutput::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(pOver, LoggerOutput, OutputWindow); diff --git a/Modules/Core/Common/test/itkLoggerTest.cxx b/Modules/Core/Common/test/itkLoggerTest.cxx index b0e67b95713..d3dea316379 100644 --- a/Modules/Core/Common/test/itkLoggerTest.cxx +++ b/Modules/Core/Common/test/itkLoggerTest.cxx @@ -37,14 +37,14 @@ itkLoggerTest(int argc, char * argv[]) } // Create an ITK StdStreamLogOutputs - itk::StdStreamLogOutput::Pointer coutput = itk::StdStreamLogOutput::New(); - itk::StdStreamLogOutput::Pointer foutput = itk::StdStreamLogOutput::New(); + const itk::StdStreamLogOutput::Pointer coutput = itk::StdStreamLogOutput::New(); + const itk::StdStreamLogOutput::Pointer foutput = itk::StdStreamLogOutput::New(); coutput->SetStream(std::cout); std::ofstream fout(argv[1]); foutput->SetStream(fout); // Create an ITK Logger - itk::Logger::Pointer logger = itk::Logger::New(); + const itk::Logger::Pointer logger = itk::Logger::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(logger, Logger, LoggerBase); @@ -84,7 +84,7 @@ itkLoggerTest(int argc, char * argv[]) logger->Write(itk::LoggerBase::PriorityLevelEnum::MUSTFLUSH, "This is the MUSTFLUSH message.\n"); logger->Flush(); - itk::LoggerBase::TimeStampFormatEnum timeStampFormat = itk::LoggerBase::TimeStampFormatEnum::HUMANREADABLE; + const itk::LoggerBase::TimeStampFormatEnum timeStampFormat = itk::LoggerBase::TimeStampFormatEnum::HUMANREADABLE; logger->SetTimeStampFormat(timeStampFormat); if (logger->GetTimeStampFormat() != timeStampFormat) @@ -104,7 +104,7 @@ itkLoggerTest(int argc, char * argv[]) logger->Flush(); - std::string humanReadableFormat = "%b %d, %Y, %H:%M:%S"; + const std::string humanReadableFormat = "%b %d, %Y, %H:%M:%S"; logger->SetHumanReadableFormat(humanReadableFormat); if (logger->GetHumanReadableFormat() != humanReadableFormat) diff --git a/Modules/Core/Common/test/itkLoggerThreadWrapperTest.cxx b/Modules/Core/Common/test/itkLoggerThreadWrapperTest.cxx index 3fc299b066c..cad346380b7 100644 --- a/Modules/Core/Common/test/itkLoggerThreadWrapperTest.cxx +++ b/Modules/Core/Common/test/itkLoggerThreadWrapperTest.cxx @@ -173,14 +173,14 @@ itkLoggerThreadWrapperTest(int argc, char * argv[]) } // Create an ITK StdStreamLogOutputs - itk::StdStreamLogOutput::Pointer coutput = itk::StdStreamLogOutput::New(); - itk::StdStreamLogOutput::Pointer foutput = itk::StdStreamLogOutput::New(); + const itk::StdStreamLogOutput::Pointer coutput = itk::StdStreamLogOutput::New(); + const itk::StdStreamLogOutput::Pointer foutput = itk::StdStreamLogOutput::New(); coutput->SetStream(std::cout); std::ofstream fout(argv[1]); foutput->SetStream(fout); // Create an ITK ThreadLogger - itk::LoggerThreadWrapper::Pointer logger = itk::LoggerThreadWrapper::New(); + const itk::LoggerThreadWrapper::Pointer logger = itk::LoggerThreadWrapper::New(); std::cout << "Testing itk::LoggerThreadWrapper" << std::endl; @@ -228,8 +228,8 @@ itkLoggerThreadWrapperTest(int argc, char * argv[]) std::cout << " Flushing by the ThreadLogger is synchronized." << std::endl; std::cout << "Beginning multi-threaded portion of test." << std::endl; - ThreadDataVec threadData = create_threaded_data2(numthreads, logger); - itk::MultiThreaderBase::Pointer threader = itk::MultiThreaderBase::New(); + ThreadDataVec threadData = create_threaded_data2(numthreads, logger); + const itk::MultiThreaderBase::Pointer threader = itk::MultiThreaderBase::New(); itk::MultiThreaderBase::SetGlobalMaximumNumberOfThreads(numthreads + 10); threader->SetNumberOfWorkUnits(numthreads); threader->SetSingleMethod(ThreadedGenerateLogMessages2, &threadData); @@ -246,10 +246,10 @@ itkLoggerThreadWrapperTest(int argc, char * argv[]) // // Testing the internal thread // - itk::StdStreamLogOutput::Pointer coutput2 = itk::StdStreamLogOutput::New(); + const itk::StdStreamLogOutput::Pointer coutput2 = itk::StdStreamLogOutput::New(); coutput2->SetStream(std::cout); - itk::LoggerThreadWrapper::Pointer logger2 = itk::LoggerThreadWrapper::New(); + const itk::LoggerThreadWrapper::Pointer logger2 = itk::LoggerThreadWrapper::New(); std::cout << "Testing itk::LoggerThreadWrapper" << std::endl; diff --git a/Modules/Core/Common/test/itkMapContainerTest.cxx b/Modules/Core/Common/test/itkMapContainerTest.cxx index 99d98ff0084..663f375dde0 100644 --- a/Modules/Core/Common/test/itkMapContainerTest.cxx +++ b/Modules/Core/Common/test/itkMapContainerTest.cxx @@ -38,7 +38,7 @@ itkMapContainerTest(int, char *[]) /** * Create the Container */ - ContainerPointer container = ContainerType::New(); + const ContainerPointer container = ContainerType::New(); PointType pointA; PointType pointB; @@ -63,10 +63,10 @@ itkMapContainerTest(int, char *[]) // Iterator { - ContainerType::Iterator p_null; - ContainerType::Iterator p = container->Begin(); - ContainerType::Iterator p_copy(p); - ContainerType::Iterator p_assign = p; + const ContainerType::Iterator p_null; + ContainerType::Iterator p = container->Begin(); + ContainerType::Iterator p_copy(p); + ContainerType::Iterator p_assign = p; while (p != container->End()) { @@ -81,10 +81,10 @@ itkMapContainerTest(int, char *[]) // ConstIterator { - ContainerType::ConstIterator p_null; - ContainerType::ConstIterator p = container->Begin(); - ContainerType::ConstIterator p_copy(p); - ContainerType::ConstIterator p_assign = p; + const ContainerType::ConstIterator p_null; + ContainerType::ConstIterator p = container->Begin(); + ContainerType::ConstIterator p_copy(p); + ContainerType::ConstIterator p_assign = p; while (p != container->End()) { diff --git a/Modules/Core/Common/test/itkMathCastWithRangeCheckTest.cxx b/Modules/Core/Common/test/itkMathCastWithRangeCheckTest.cxx index 7b400545701..6f02597bde9 100644 --- a/Modules/Core/Common/test/itkMathCastWithRangeCheckTest.cxx +++ b/Modules/Core/Common/test/itkMathCastWithRangeCheckTest.cxx @@ -78,7 +78,7 @@ template bool DoCastWithRangeCheckTest(const T1 * = nullptr, const T2 * = nullptr) { - int minus_one = -1; + const int minus_one = -1; // test convert T2 to T1 bool pass = true; diff --git a/Modules/Core/Common/test/itkMathRoundProfileTest1.cxx b/Modules/Core/Common/test/itkMathRoundProfileTest1.cxx index 25bdf3e2de0..926c318ded8 100644 --- a/Modules/Core/Common/test/itkMathRoundProfileTest1.cxx +++ b/Modules/Core/Common/test/itkMathRoundProfileTest1.cxx @@ -101,7 +101,7 @@ itkMathRoundProfileTest1(int, char *[]) IntArrayType::const_iterator outItr1src = output1.begin(); auto outItr2dst = output2.begin(); - IntArrayType::const_iterator outEnd1 = output1.end(); + const IntArrayType::const_iterator outEnd1 = output1.end(); chronometer.Start("std::vector"); @@ -191,8 +191,8 @@ itkMathRoundProfileTest1(int, char *[]) // // Now test the correctness of the output // - ArrayType::const_iterator inpItr = input.begin(); - ArrayType::const_iterator inputEnd = input.end(); + ArrayType::const_iterator inpItr = input.begin(); + const ArrayType::const_iterator inputEnd = input.end(); IntArrayType::const_iterator outItr1 = output1.begin(); IntArrayType::const_iterator outItr2 = output2.begin(); diff --git a/Modules/Core/Common/test/itkMathRoundTest2.cxx b/Modules/Core/Common/test/itkMathRoundTest2.cxx index cb8e64e0225..b7da4cf1069 100644 --- a/Modules/Core/Common/test/itkMathRoundTest2.cxx +++ b/Modules/Core/Common/test/itkMathRoundTest2.cxx @@ -39,13 +39,13 @@ TemplatedRoundTest() constexpr unsigned int numberOfElements = 15; // input data for rounding methods - float input[] = { -8.4999f, -8.50f, -8.5001f, 8.4999f, 8.50f, 8.5001f, -9.4999f, -9.50f, - -9.5001f, 9.4999f, 9.50f, 9.5001f, -0.4999f, -.50f, -.5001f }; + const float input[] = { -8.4999f, -8.50f, -8.5001f, 8.4999f, 8.50f, 8.5001f, -9.4999f, -9.50f, + -9.5001f, 9.4999f, 9.50f, 9.5001f, -0.4999f, -.50f, -.5001f }; T roundOutput[] = { -8, -8, -9, 8, 9, 9, -9, -9, -10, 9, 10, 10, 0, 0, -1 }; - T halftoevenOutput[] = { -8, -8, -9, 8, 8, 9, -9, -10, -10, 9, 10, 10, 0, 0, -1 }; + const T halftoevenOutput[] = { -8, -8, -9, 8, 8, 9, -9, -10, -10, 9, 10, 10, 0, 0, -1 }; T * halfupOutput = roundOutput; @@ -53,13 +53,13 @@ TemplatedRoundTest() //////// // input data for floor and ceil methods - float fcinput[] = { 8.0f, 8.9999f, 8.0001f, -8.0f, -8.9999f, -8.0001f, 9.0f, 9.9999f, - 9.0001f, -9.0f, -9.9999f, -9.0001f, -1.0f, -0.9999f, -1.0001f }; + const float fcinput[] = { 8.0f, 8.9999f, 8.0001f, -8.0f, -8.9999f, -8.0001f, 9.0f, 9.9999f, + 9.0001f, -9.0f, -9.9999f, -9.0001f, -1.0f, -0.9999f, -1.0001f }; - T floorOutput[] = { 8, 8, 8, -8, -9, -9, 9, 9, 9, -9, -10, -10, -1, -1, -2 }; + const T floorOutput[] = { 8, 8, 8, -8, -9, -9, 9, 9, 9, -9, -10, -10, -1, -1, -2 }; - T ceilOutput[] = { 8, 9, 9, -8, -8, -8, 9, 10, 10, -9, -9, -9, -1, 0, -1 }; + const T ceilOutput[] = { 8, 9, 9, -8, -8, -8, 9, 10, 10, -9, -9, -9, -1, 0, -1 }; // Round diff --git a/Modules/Core/Common/test/itkMathTest.cxx b/Modules/Core/Common/test/itkMathTest.cxx index f702752a939..bfd3869e17a 100644 --- a/Modules/Core/Common/test/itkMathTest.cxx +++ b/Modules/Core/Common/test/itkMathTest.cxx @@ -144,7 +144,7 @@ main(int, char *[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope // scope. - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); std::cout << "e: " << itk::Math::e << std::endl; std::cout << "log2e: " << itk::Math::log2e << std::endl; diff --git a/Modules/Core/Common/test/itkMatrixTest.cxx b/Modules/Core/Common/test/itkMatrixTest.cxx index 3378eac3480..8aa6eb8cb64 100644 --- a/Modules/Core/Common/test/itkMatrixTest.cxx +++ b/Modules/Core/Common/test/itkMatrixTest.cxx @@ -46,8 +46,8 @@ itkMatrixTest(int, char *[]) std::cout << resultVector[1] << ", "; std::cout << resultVector[2] << std::endl; - PointType::ValueType p1Init[3] = { 3, 4, 5 }; - PointType p1 = p1Init; + const PointType::ValueType p1Init[3] = { 3, 4, 5 }; + const PointType p1 = p1Init; PointType resultPoint = matrix * p1; std::cout << resultPoint[0] << ", "; @@ -55,7 +55,7 @@ itkMatrixTest(int, char *[]) std::cout << resultPoint[2] << std::endl; CovariantVectorType::ValueType cv1Init[3] = { 3, 4, 5 }; - CovariantVectorType cv1 = cv1Init; + const CovariantVectorType cv1 = cv1Init; CovariantVectorType resultCovariantVector = matrix * cv1; std::cout << resultCovariantVector[0] << ", "; @@ -292,7 +292,7 @@ itkMatrixTest(int, char *[]) } } - MatrixType::InternalMatrixType vnlMatrixA = matrixA.GetVnlMatrix(); + const MatrixType::InternalMatrixType vnlMatrixA = matrixA.GetVnlMatrix(); MatrixType matrixB(vnlMatrixA); // Test constructor diff --git a/Modules/Core/Common/test/itkMemoryProbesCollecterBaseTest.cxx b/Modules/Core/Common/test/itkMemoryProbesCollecterBaseTest.cxx index 78f21776047..77227e1d49c 100644 --- a/Modules/Core/Common/test/itkMemoryProbesCollecterBaseTest.cxx +++ b/Modules/Core/Common/test/itkMemoryProbesCollecterBaseTest.cxx @@ -55,7 +55,7 @@ itkMemoryProbesCollecterBaseTest(int, char *[]) Sleep(5000); mcollecter.Stop("Update"); probe.Stop(); - itk::MemoryProbe::MemoryLoadType total = probe.GetTotal(); + const itk::MemoryProbe::MemoryLoadType total = probe.GetTotal(); std::cout << " Total Value " << probe.GetTotal() << std::endl; if (total == 0) { diff --git a/Modules/Core/Common/test/itkMersenneTwisterRandomVariateGeneratorTest.cxx b/Modules/Core/Common/test/itkMersenneTwisterRandomVariateGeneratorTest.cxx index 78c70e6fb15..7b862e5ede0 100644 --- a/Modules/Core/Common/test/itkMersenneTwisterRandomVariateGeneratorTest.cxx +++ b/Modules/Core/Common/test/itkMersenneTwisterRandomVariateGeneratorTest.cxx @@ -29,7 +29,7 @@ itkMersenneTwisterRandomVariateGeneratorTest(int, char *[]) using Twister = itk::Statistics::MersenneTwisterRandomVariateGenerator; - Twister::IntegerType seed = 1234; + const Twister::IntegerType seed = 1234; // Test Get/SetSeed Twister::GetInstance()->SetSeed(seed); @@ -68,7 +68,7 @@ itkMersenneTwisterRandomVariateGeneratorTest(int, char *[]) bool sameSequence = true; for (const auto i : expected) { - Twister::IntegerType actual = twister->GetIntegerVariate(); + const Twister::IntegerType actual = twister->GetIntegerVariate(); if (actual != i) { std::cout << "GetIntegerVariate: expected " << i << " got " << actual << std::endl; @@ -82,17 +82,17 @@ itkMersenneTwisterRandomVariateGeneratorTest(int, char *[]) // Do we get roughly zero mean and unit variance? // NB: requires a large number of iterations to have variance converge... - double sum = 0.0; - double sum2 = 0.0; - int count = 500000; + double sum = 0.0; + double sum2 = 0.0; + const int count = 500000; for (int i = 0; i < count; ++i) { - double v = twister->GetNormalVariate(); + const double v = twister->GetNormalVariate(); sum += v; sum2 += v * v; } - double mean = sum / static_cast(count); - double variance = sum2 / static_cast(count) - mean * mean; + const double mean = sum / static_cast(count); + const double variance = sum2 / static_cast(count) - mean * mean; if (itk::Math::abs(mean) > 0.01) { std::cerr << "Mean was " << mean << " expected 0.0 " << std::endl; diff --git a/Modules/Core/Common/test/itkMetaDataDictionaryGTest.cxx b/Modules/Core/Common/test/itkMetaDataDictionaryGTest.cxx index 4832e8b533f..b8c20501397 100644 --- a/Modules/Core/Common/test/itkMetaDataDictionaryGTest.cxx +++ b/Modules/Core/Common/test/itkMetaDataDictionaryGTest.cxx @@ -38,7 +38,7 @@ createMetaDataDictionary() using ObjectType = itk::LightObject; using PointerType = typename ObjectType::Pointer; - PointerType obj = ObjectType::New(); + const PointerType obj = ObjectType::New(); itk::EncapsulateMetaData(metaDataDictionary, "object", obj); return metaDataDictionary; diff --git a/Modules/Core/Common/test/itkMetaDataObjectTest.cxx b/Modules/Core/Common/test/itkMetaDataObjectTest.cxx index 35527a3dfb4..6f2e2604cdc 100644 --- a/Modules/Core/Common/test/itkMetaDataObjectTest.cxx +++ b/Modules/Core/Common/test/itkMetaDataObjectTest.cxx @@ -75,7 +75,7 @@ itkMetaDataObjectTest(int, char *[]) result += testMetaData(itk::Matrix()); result += testMetaData>(itk::Matrix::GetIdentity()); using ImageType = itk::Image; - ImageType::Pointer image = nullptr; + const ImageType::Pointer image = nullptr; result += testMetaData(image); return result; diff --git a/Modules/Core/Common/test/itkMinimumMaximumImageCalculatorTest.cxx b/Modules/Core/Common/test/itkMinimumMaximumImageCalculatorTest.cxx index 3ce5e4e49fd..1f23b4f835b 100644 --- a/Modules/Core/Common/test/itkMinimumMaximumImageCalculatorTest.cxx +++ b/Modules/Core/Common/test/itkMinimumMaximumImageCalculatorTest.cxx @@ -30,9 +30,9 @@ itkMinimumMaximumImageCalculatorTest(int, char *[]) using MinMaxCalculatorType = itk::MinimumMaximumImageCalculator; /* Define the image size and physical coordinates */ - SizeType size = { { 20, 20, 20 } }; - double origin[3] = { 0.0, 0.0, 0.0 }; - double spacing[3] = { 1, 1, 1 }; + const SizeType size = { { 20, 20, 20 } }; + double origin[3] = { 0.0, 0.0, 0.0 }; + double spacing[3] = { 1, 1, 1 }; std::cout << "Testing Minimum and Maximum Image Calulator:\n"; @@ -97,9 +97,9 @@ itkMinimumMaximumImageCalculatorTest(int, char *[]) ITK_TEST_SET_GET_VALUE(maxIntensityValueIndex, calculator->GetIndexOfMaximum()); // Set the region over which perform the computations - itk::Size<3> regionSize = { { 4, 4, 4 } }; - itk::Index<3> idx = { { 0, 0, 0 } }; - MinMaxCalculatorType::RegionType computationRegion{ idx, regionSize }; + const itk::Size<3> regionSize = { { 4, 4, 4 } }; + const itk::Index<3> idx = { { 0, 0, 0 } }; + const MinMaxCalculatorType::RegionType computationRegion{ idx, regionSize }; calculator->SetRegion(computationRegion); diff --git a/Modules/Core/Common/test/itkModifiedTimeTest.cxx b/Modules/Core/Common/test/itkModifiedTimeTest.cxx index faa794fe5af..5e110917e83 100644 --- a/Modules/Core/Common/test/itkModifiedTimeTest.cxx +++ b/Modules/Core/Common/test/itkModifiedTimeTest.cxx @@ -26,10 +26,10 @@ itkModifiedTimeTest(int, char *[]) using PointsContainer = itk::VectorContainer; using BoundingBox = itk::BoundingBox; - auto pc = PointsContainer::New(); - Point p{}; + auto pc = PointsContainer::New(); + const Point p{}; pc->InsertElement(0, p); - Point q{}; + const Point q{}; pc->InsertElement(1, q); pc->Modified(); @@ -42,7 +42,7 @@ itkModifiedTimeTest(int, char *[]) std::cout << "BB time before modification: " << bbBeforeTime << std::endl; std::cout << "PC time before modification: " << pcBeforeTime << std::endl; - Point r{}; + const Point r{}; pc->InsertElement(2, r); pc->Modified(); // call the Modified function to update the modified time of the container diff --git a/Modules/Core/Common/test/itkMultiThreaderBaseTest.cxx b/Modules/Core/Common/test/itkMultiThreaderBaseTest.cxx index f0c8792636c..d63fddfadac 100644 --- a/Modules/Core/Common/test/itkMultiThreaderBaseTest.cxx +++ b/Modules/Core/Common/test/itkMultiThreaderBaseTest.cxx @@ -79,7 +79,7 @@ SetAndVerify(int number) bool result = true; result &= SetAndVerifyGlobalMaximumNumberOfThreads(number); result &= SetAndVerifyGlobalDefaultNumberOfThreads(number); - itk::MultiThreaderBase::Pointer threader = itk::MultiThreaderBase::New(); + const itk::MultiThreaderBase::Pointer threader = itk::MultiThreaderBase::New(); // PoolMultiThreader can only increase number of threads // so make sure to increase this before testing thread count itk::MultiThreaderBase::SetGlobalMaximumNumberOfThreads(itk::ITK_MAX_THREADS); diff --git a/Modules/Core/Common/test/itkMultiThreaderExceptionsTest.cxx b/Modules/Core/Common/test/itkMultiThreaderExceptionsTest.cxx index 9d34d8e163e..e01966bf376 100644 --- a/Modules/Core/Common/test/itkMultiThreaderExceptionsTest.cxx +++ b/Modules/Core/Common/test/itkMultiThreaderExceptionsTest.cxx @@ -83,7 +83,7 @@ itkMultiThreaderExceptionsTest(int, char *[]) using OutputImageType = itk::Image; - std::set threadersToTest = { ThreaderEnum::Platform, ThreaderEnum::Pool }; + const std::set threadersToTest = { ThreaderEnum::Platform, ThreaderEnum::Pool }; #ifdef ITK_USE_TBB threadersToTest.insert(ThreaderEnum::TBB); #endif // ITK_USE_TBB diff --git a/Modules/Core/Common/test/itkMultiThreaderParallelizeArrayTest.cxx b/Modules/Core/Common/test/itkMultiThreaderParallelizeArrayTest.cxx index 15db221b08c..7bbee118a73 100644 --- a/Modules/Core/Common/test/itkMultiThreaderParallelizeArrayTest.cxx +++ b/Modules/Core/Common/test/itkMultiThreaderParallelizeArrayTest.cxx @@ -51,7 +51,7 @@ class ShowProgress : public itk::Command int itkMultiThreaderParallelizeArrayTest(int argc, char * argv[]) { - itk::MultiThreaderBase::Pointer mt = itk::MultiThreaderBase::New(); + const itk::MultiThreaderBase::Pointer mt = itk::MultiThreaderBase::New(); if (mt.IsNull()) { std::cerr << "MultiThreaderBase could not be instantiated!" << std::endl; @@ -59,7 +59,7 @@ itkMultiThreaderParallelizeArrayTest(int argc, char * argv[]) } if (argc >= 2) { - unsigned int workUnitCount = static_cast(std::stoi(argv[1])); + const unsigned int workUnitCount = static_cast(std::stoi(argv[1])); mt->SetNumberOfWorkUnits(workUnitCount); } diff --git a/Modules/Core/Common/test/itkMultiThreaderTypeFromEnvironmentTest.cxx b/Modules/Core/Common/test/itkMultiThreaderTypeFromEnvironmentTest.cxx index 9905f5b148a..cdcbbe1e7c1 100644 --- a/Modules/Core/Common/test/itkMultiThreaderTypeFromEnvironmentTest.cxx +++ b/Modules/Core/Common/test/itkMultiThreaderTypeFromEnvironmentTest.cxx @@ -31,8 +31,8 @@ checkThreaderByName(ThreaderEnum expectedThreaderType) using FilterType = itk::AbsImageFilter; auto filter = FilterType::New(); - std::string realThreaderName = filter->GetMultiThreader()->GetNameOfClass(); - std::string expectedThreaderName = + const std::string realThreaderName = filter->GetMultiThreader()->GetNameOfClass(); + const std::string expectedThreaderName = itk::MultiThreaderBase::ThreaderTypeToString(expectedThreaderType) + "MultiThreader"; if (realThreaderName != expectedThreaderName) { @@ -54,8 +54,8 @@ itkMultiThreaderTypeFromEnvironmentTest(int argc, char * argv[]) bool success = true; - ThreaderEnum expectedThreaderType = itk::MultiThreaderBase::ThreaderTypeFromString(argv[1]); - ThreaderEnum realThreaderType = itk::MultiThreaderBase::GetGlobalDefaultThreader(); + const ThreaderEnum expectedThreaderType = itk::MultiThreaderBase::ThreaderTypeFromString(argv[1]); + const ThreaderEnum realThreaderType = itk::MultiThreaderBase::GetGlobalDefaultThreader(); if (realThreaderType != expectedThreaderType) { @@ -67,7 +67,7 @@ itkMultiThreaderTypeFromEnvironmentTest(int argc, char * argv[]) success &= checkThreaderByName(expectedThreaderType); // check that developer's choice for default is respected - std::set threadersToTest = { ThreaderEnum::Platform, ThreaderEnum::Pool }; + const std::set threadersToTest = { ThreaderEnum::Platform, ThreaderEnum::Pool }; #ifdef ITK_USE_TBB threadersToTest.insert(ThreaderEnum::TBB); #endif // ITK_USE_TBB diff --git a/Modules/Core/Common/test/itkMultiThreadingEnvironmentTest.cxx b/Modules/Core/Common/test/itkMultiThreadingEnvironmentTest.cxx index cee1a44e438..85eb8834206 100644 --- a/Modules/Core/Common/test/itkMultiThreadingEnvironmentTest.cxx +++ b/Modules/Core/Common/test/itkMultiThreadingEnvironmentTest.cxx @@ -29,7 +29,7 @@ itkMultiThreadingEnvironmentTest(int argc, char * argv[]) } const auto requiredValue = static_cast(std::stoi(argv[1])); - itk::MultiThreaderBase::Pointer threader = itk::MultiThreaderBase::New(); + const itk::MultiThreaderBase::Pointer threader = itk::MultiThreaderBase::New(); if (threader.IsNull()) { return EXIT_FAILURE; diff --git a/Modules/Core/Common/test/itkMultipleLogOutputTest.cxx b/Modules/Core/Common/test/itkMultipleLogOutputTest.cxx index 35dfdad7a3c..25a151e2596 100644 --- a/Modules/Core/Common/test/itkMultipleLogOutputTest.cxx +++ b/Modules/Core/Common/test/itkMultipleLogOutputTest.cxx @@ -36,9 +36,9 @@ itkMultipleLogOutputTest(int argc, char * argv[]) // Create an ITK StdStreamLogOutput - itk::StdStreamLogOutput::Pointer coutput = itk::StdStreamLogOutput::New(); - itk::StdStreamLogOutput::Pointer foutput = itk::StdStreamLogOutput::New(); - itk::MultipleLogOutput::Pointer m_output = itk::MultipleLogOutput::New(); + const itk::StdStreamLogOutput::Pointer coutput = itk::StdStreamLogOutput::New(); + const itk::StdStreamLogOutput::Pointer foutput = itk::StdStreamLogOutput::New(); + const itk::MultipleLogOutput::Pointer m_output = itk::MultipleLogOutput::New(); std::cout << "Testing itk::MultipleLogOutput" << std::endl; coutput->SetStream(std::cout); diff --git a/Modules/Core/Common/test/itkMultithreadingTest.cxx b/Modules/Core/Common/test/itkMultithreadingTest.cxx index bbcb653fb44..edfc7aaa653 100644 --- a/Modules/Core/Common/test/itkMultithreadingTest.cxx +++ b/Modules/Core/Common/test/itkMultithreadingTest.cxx @@ -42,9 +42,9 @@ execute(void * ptr) } sharedMutex->unlock(); - int n = 10; - int m = *data; - double sum = 1.0; + const int n = 10; + const int m = *data; + double sum = 1.0; for (int j = 0; j < m; ++j) { @@ -77,20 +77,20 @@ itkMultithreadingTest(int argc, char * argv[]) debugPrint = std::stoi(argv[2]); } - itk::MultiThreaderBase::Pointer threader = itk::MultiThreaderBase::New(); + const itk::MultiThreaderBase::Pointer threader = itk::MultiThreaderBase::New(); if (threader.IsNull()) { return EXIT_FAILURE; } - itk::TimeProbe timeProbe; - itk::TimeProbe::TimeStampType startTime = timeProbe.GetInstantValue(); - int data = 123; + const itk::TimeProbe timeProbe; + const itk::TimeProbe::TimeStampType startTime = timeProbe.GetInstantValue(); + int data = 123; for (int i = 0; i < count; ++i) { threader->SetSingleMethod(&execute, &data); threader->SingleMethodExecute(); } - itk::TimeProbe::TimeStampType elapsed = timeProbe.GetInstantValue() - startTime; + const itk::TimeProbe::TimeStampType elapsed = timeProbe.GetInstantValue() - startTime; std::cout << std::endl << " Thread pool test : Time elapsed : " << elapsed << std::endl; return EXIT_SUCCESS; diff --git a/Modules/Core/Common/test/itkNeighborhoodAlgorithmTest.cxx b/Modules/Core/Common/test/itkNeighborhoodAlgorithmTest.cxx index d4f5b19888f..44e7a80a9e2 100644 --- a/Modules/Core/Common/test/itkNeighborhoodAlgorithmTest.cxx +++ b/Modules/Core/Common/test/itkNeighborhoodAlgorithmTest.cxx @@ -54,7 +54,7 @@ ImageBoundaryFaceCalculatorTest(TImage * image, if (fit == faceList.begin()) { using NeighborhoodIteratorType = itk::ConstNeighborhoodIterator; - NeighborhoodIteratorType nIt(radius, image, *fit); + const NeighborhoodIteratorType nIt(radius, image, *fit); // a neighborhood iterator with radius and the first region should never overlap the boundary of the image if (!nIt.InBounds() && fit->GetNumberOfPixels() > 0) { diff --git a/Modules/Core/Common/test/itkNeighborhoodIteratorTest.cxx b/Modules/Core/Common/test/itkNeighborhoodIteratorTest.cxx index b18a2f95220..00bfeed394f 100644 --- a/Modules/Core/Common/test/itkNeighborhoodIteratorTest.cxx +++ b/Modules/Core/Common/test/itkNeighborhoodIteratorTest.cxx @@ -22,14 +22,14 @@ int itkNeighborhoodIteratorTest(int, char *[]) { - TestImageType::Pointer img = GetTestImage(10, 10, 5, 3); + const TestImageType::Pointer img = GetTestImage(10, 10, 5, 3); itk::NeighborhoodIterator::IndexType loc; loc[0] = 4; loc[1] = 4; loc[2] = 2; loc[3] = 1; - itk::NeighborhoodIterator::IndexType zeroIDX{}; + const itk::NeighborhoodIterator::IndexType zeroIDX{}; auto radius = itk::MakeFilled::RadiusType>(1); @@ -48,7 +48,7 @@ itkNeighborhoodIteratorTest(int, char *[]) it.SetPixel(6, zeroIDX); println("Using Superclass::GetNeighborhood()"); - itk::NeighborhoodIterator::NeighborhoodType n = it.GetNeighborhood(); + const itk::NeighborhoodIterator::NeighborhoodType n = it.GetNeighborhood(); println("Testing SetNeighborhood()"); it.SetNeighborhood(n); @@ -61,7 +61,7 @@ itkNeighborhoodIteratorTest(int, char *[]) it = itk::NeighborhoodIterator(radius, img, img->GetRequestedRegion()); println("Testing copy constructor"); - itk::NeighborhoodIterator it2(it); + const itk::NeighborhoodIterator it2(it); it.Print(std::cout); it2.Print(std::cout); diff --git a/Modules/Core/Common/test/itkNeighborhoodTest.cxx b/Modules/Core/Common/test/itkNeighborhoodTest.cxx index eff9931400d..00c720e2aa9 100644 --- a/Modules/Core/Common/test/itkNeighborhoodTest.cxx +++ b/Modules/Core/Common/test/itkNeighborhoodTest.cxx @@ -79,11 +79,11 @@ itkNeighborhoodTest(int, char *[]) q.Print(std::cout); println("Testing assignment operator"); - itk::Neighborhood p = q; + const itk::Neighborhood p = q; p.Print(std::cout); println("Testing copy constructor"); - itk::Neighborhood r(q); + const itk::Neighborhood r(q); r.Print(std::cout); println("Testing instantiation with itk::Vector"); diff --git a/Modules/Core/Common/test/itkNumberToStringTest.cxx b/Modules/Core/Common/test/itkNumberToStringTest.cxx index b811227c793..79b6ff1e340 100644 --- a/Modules/Core/Common/test/itkNumberToStringTest.cxx +++ b/Modules/Core/Common/test/itkNumberToStringTest.cxx @@ -25,7 +25,7 @@ template void PrintValue(const char * t, T) { - itk::NumberToString convert; + const itk::NumberToString convert; std::cout << t << "(min) " << "raw: " << itk::NumericTraits::min() << " converted: " << convert(itk::NumericTraits::min()) << std::endl; diff --git a/Modules/Core/Common/test/itkNumericTraitsTest.cxx b/Modules/Core/Common/test/itkNumericTraitsTest.cxx index 6e19952c328..38a3fc73767 100644 --- a/Modules/Core/Common/test/itkNumericTraitsTest.cxx +++ b/Modules/Core/Common/test/itkNumericTraitsTest.cxx @@ -91,7 +91,7 @@ CheckVariableLengthArrayTraits(const T & t) { std::string name; #ifdef GCC_USEDEMANGLE - char const * mangledName = typeid(t).name(); + const char * mangledName = typeid(t).name(); int status; char * unmangled = abi::__cxa_demangle(mangledName, nullptr, nullptr, &status); name = unmangled; @@ -137,7 +137,7 @@ CheckFixedArrayTraits(const T & t) std::string name; #ifdef GCC_USEDEMANGLE - char const * mangledName = typeid(t).name(); + const char * mangledName = typeid(t).name(); int status; char * unmangled = abi::__cxa_demangle(mangledName, nullptr, nullptr, &status); name = unmangled; diff --git a/Modules/Core/Common/test/itkNumericsTest.cxx b/Modules/Core/Common/test/itkNumericsTest.cxx index 36959753510..0577c4e93c7 100644 --- a/Modules/Core/Common/test/itkNumericsTest.cxx +++ b/Modules/Core/Common/test/itkNumericsTest.cxx @@ -40,7 +40,7 @@ solve_with_warning(const vnl_matrix & M, const vnl_matrix & B) { // Take svd of vnl_matrix M, setting singular values // smaller than 1e-8 to 0, and hold the result. - vnl_svd svd(M, 1e-8); + const vnl_svd svd(M, 1e-8); // Check for rank-deficiency if (svd.singularities() > 1) { @@ -53,10 +53,10 @@ solve_with_warning(const vnl_matrix & M, const vnl_matrix & B) int test_svd() { - double data[] = { 1, 1, 1, 1, 2, 3, 1, 3, 6 }; - vnl_matrix M(data, 3, 3); - vnl_matrix B(3, 1, 7.0); // column vector [7 7 7]^T - vnl_matrix result = solve_with_warning(M, B); + double data[] = { 1, 1, 1, 1, 2, 3, 1, 3, 6 }; + vnl_matrix M(data, 3, 3); + const vnl_matrix B(3, 1, 7.0); // column vector [7 7 7]^T + vnl_matrix result = solve_with_warning(M, B); std::cout << "Original svd problem solution" << std::endl; print_vnl_matrix(result); M(2, 2) = 5; diff --git a/Modules/Core/Common/test/itkObjectFactoryTest2.cxx b/Modules/Core/Common/test/itkObjectFactoryTest2.cxx index 83f796a059b..5802244ffdf 100644 --- a/Modules/Core/Common/test/itkObjectFactoryTest2.cxx +++ b/Modules/Core/Common/test/itkObjectFactoryTest2.cxx @@ -58,7 +58,7 @@ MakeImage(const int count, T pixel) size[0] = count; size[1] = count; size[2] = count; - RegionType region{ index, size }; + const RegionType region{ index, size }; testImage->SetRegions(region); testImage->Allocate(); @@ -73,12 +73,12 @@ ReallocateImage() auto testImage = ImageType::New(); - SizeType size = { { 5, 3 } }; + const SizeType size = { { 5, 3 } }; testImage->SetRegions(size); testImage->AllocateInitialized(); - SizeType size2 = { { 100, 100 } }; + const SizeType size2 = { { 100, 100 } }; testImage->SetRegions(size2); testImage->AllocateInitialized(); } @@ -102,7 +102,7 @@ itkObjectFactoryTest2(int argc, char * argv[]) #ifdef _WIN32 std::string pathSeparator = ";"; #else - std::string pathSeparator = ":"; + const std::string pathSeparator = ":"; #endif std::string path = ""; for (int ac = 1; ac < argc - 1; ++ac) @@ -164,7 +164,8 @@ itkObjectFactoryTest2(int argc, char * argv[]) return EXIT_FAILURE; } - itk::ImportImageContainer::Pointer v = itk::ImportImageContainer::New(); + const itk::ImportImageContainer::Pointer v = + itk::ImportImageContainer::New(); if (!TestNew2(v, "TestImportImageContainer")) { return EXIT_FAILURE; @@ -178,14 +179,14 @@ itkObjectFactoryTest2(int argc, char * argv[]) MakeImage(10, static_cast(0)); MakeImage(10, static_cast(0)); } - itk::RGBPixel rgbUC{}; - itk::RGBPixel rgbUS{}; + const itk::RGBPixel rgbUC{}; + const itk::RGBPixel rgbUS{}; MakeImage(10, rgbUC); MakeImage(10, rgbUS); ReallocateImage(); - int status = EXIT_SUCCESS; + const int status = EXIT_SUCCESS; return status; } diff --git a/Modules/Core/Common/test/itkObjectFactoryTest3.cxx b/Modules/Core/Common/test/itkObjectFactoryTest3.cxx index 667136d2bf3..3e16bc71008 100644 --- a/Modules/Core/Common/test/itkObjectFactoryTest3.cxx +++ b/Modules/Core/Common/test/itkObjectFactoryTest3.cxx @@ -106,7 +106,7 @@ ListRegisteredFactories(const std::string & TestName, const DescriptionListType while (registeredFactoryItr != factories.end()) { - std::string description = (*registeredFactoryItr)->GetDescription(); + const std::string description = (*registeredFactoryItr)->GetDescription(); std::cout << " Description: " << description << std::endl; if (description != *expectedItr) diff --git a/Modules/Core/Common/test/itkObjectStoreTest.cxx b/Modules/Core/Common/test/itkObjectStoreTest.cxx index 5b19a42b1f9..669db097a43 100644 --- a/Modules/Core/Common/test/itkObjectStoreTest.cxx +++ b/Modules/Core/Common/test/itkObjectStoreTest.cxx @@ -30,7 +30,7 @@ int itkObjectStoreTest(int, char *[]) { - itk::ObjectStore::Pointer store = itk::ObjectStore::New(); + const itk::ObjectStore::Pointer store = itk::ObjectStore::New(); std::list borrowed_list; store->SetGrowthStrategyToExponential(); diff --git a/Modules/Core/Common/test/itkOctreeTest.cxx b/Modules/Core/Common/test/itkOctreeTest.cxx index 7ff03900f0e..e5763148bd8 100644 --- a/Modules/Core/Common/test/itkOctreeTest.cxx +++ b/Modules/Core/Common/test/itkOctreeTest.cxx @@ -40,10 +40,10 @@ int itkOctreeTest(int, char *[]) { using ImageType = itk::Image; - const ImageType::SizeType imageSize = { { 4, 4, 4 } }; - const ImageType::IndexType imageIndex = { { 0, 0, 0 } }; - ImageType::RegionType region{ imageIndex, imageSize }; - auto img = ImageType::New(); + const ImageType::SizeType imageSize = { { 4, 4, 4 } }; + const ImageType::IndexType imageIndex = { { 0, 0, 0 } }; + const ImageType::RegionType region{ imageIndex, imageSize }; + auto img = ImageType::New(); img->SetRegions(region); img->Allocate(); srand(static_cast(time(nullptr))); @@ -53,7 +53,7 @@ itkOctreeTest(int, char *[]) unsigned int counter = 0; while (!ri.IsAtEnd()) { - unsigned int val = rand() % 16384; + const unsigned int val = rand() % 16384; if (counter && counter % 8 == 0) { std::cerr << val << std::endl; @@ -80,7 +80,7 @@ itkOctreeTest(int, char *[]) octree->BuildFromImage(img); - ImageType::Pointer output = octree->GetImage(); + const ImageType::Pointer output = octree->GetImage(); itk::ImageRegionIterator ri2(output, region); ri.GoToBegin(); IdentityMap id; @@ -88,9 +88,9 @@ itkOctreeTest(int, char *[]) { while (!ri.IsAtEnd() && !ri2.IsAtEnd()) { - unsigned int x = ri.Get(); - unsigned int y = ri2.Get(); - unsigned int mapped = id.Evaluate(&x); + const unsigned int x = ri.Get(); + const unsigned int y = ri2.Get(); + const unsigned int mapped = id.Evaluate(&x); std::cerr << "x = " << x << " mapped(x) " << mapped << " y = " << y << std::endl; if (mapped != y) { diff --git a/Modules/Core/Common/test/itkOptimizerParametersTest.cxx b/Modules/Core/Common/test/itkOptimizerParametersTest.cxx index 06d42907217..030f9eaee0a 100644 --- a/Modules/Core/Common/test/itkOptimizerParametersTest.cxx +++ b/Modules/Core/Common/test/itkOptimizerParametersTest.cxx @@ -35,8 +35,8 @@ runTestByType() /* Test different ctors */ // Construct by size - itk::SizeValueType dim = 20; - itk::OptimizerParameters paramsSize(dim); + const itk::SizeValueType dim = 20; + const itk::OptimizerParameters paramsSize(dim); if (paramsSize.GetSize() != dim) { std::cerr << "Constructor with dimension failed. Expected size of " << dim << ", but got " << paramsSize.GetSize() @@ -122,7 +122,7 @@ runTestByType() } /* Test SetParametersObject. Should throw exception with default helper. */ - typename itk::LightObject::Pointer dummyObj = itk::LightObject::New(); + const typename itk::LightObject::Pointer dummyObj = itk::LightObject::New(); ITK_TRY_EXPECT_EXCEPTION(params.SetParametersObject(dummyObj)); /* Test with null helper and expect exception */ diff --git a/Modules/Core/Common/test/itkPeriodicBoundaryConditionTest.cxx b/Modules/Core/Common/test/itkPeriodicBoundaryConditionTest.cxx index 1849ae5f662..6961b80affa 100644 --- a/Modules/Core/Common/test/itkPeriodicBoundaryConditionTest.cxx +++ b/Modules/Core/Common/test/itkPeriodicBoundaryConditionTest.cxx @@ -75,8 +75,8 @@ TestPrintNeighborhood(IteratorType & p, VectorIteratorType & v) // Access the pixel value through two different methods in the // boundary condition. - int pixel1 = p.GetBoundaryCondition()->GetPixel(index, p.GetImagePointer()); - int pixel2 = p.GetPixel(i); + const int pixel1 = p.GetBoundaryCondition()->GetPixel(index, p.GetImagePointer()); + const int pixel2 = p.GetPixel(i); std::cout << pixel1 << ' '; @@ -124,9 +124,9 @@ itkPeriodicBoundaryConditionTest(int, char *[]) // Test an image to cover one operator() method. auto image = ImageType::New(); - SizeType imageSize = { { 5, 5 } }; - IndexType imageIndex = { { 0, 0 } }; - RegionType imageRegion(imageIndex, imageSize); + const SizeType imageSize = { { 5, 5 } }; + const IndexType imageIndex = { { 0, 0 } }; + const RegionType imageRegion(imageIndex, imageSize); image->SetRegions(imageRegion); image->Allocate(); @@ -168,7 +168,7 @@ itkPeriodicBoundaryConditionTest(int, char *[]) for (it.GoToBegin(); !it.IsAtEnd(); ++it) { std::cout << "Index: " << it.GetIndex() << std::endl; - bool success = TestPrintNeighborhood(it, vit); + const bool success = TestPrintNeighborhood(it, vit); if (!success) { return EXIT_FAILURE; @@ -189,7 +189,7 @@ itkPeriodicBoundaryConditionTest(int, char *[]) for (it2.GoToBegin(); !it2.IsAtEnd(); ++it2) { std::cout << "Index: " << it2.GetIndex() << std::endl; - bool success = TestPrintNeighborhood(it2, vit2); + const bool success = TestPrintNeighborhood(it2, vit2); if (!success) { return EXIT_FAILURE; @@ -277,9 +277,9 @@ itkPeriodicBoundaryConditionTest(int, char *[]) // Check when ConstNeighborhoodIterator is templated over the // PeriodicBoundaryCondition - auto testImage = ImageType::New(); - ImageType::SizeType testSize = { { 64, 64 } }; - ImageType::RegionType testRegion(testSize); + auto testImage = ImageType::New(); + ImageType::SizeType testSize = { { 64, 64 } }; + const ImageType::RegionType testRegion(testSize); testImage->SetRegions(testRegion); testImage->Allocate(); testImage->FillBuffer(1); diff --git a/Modules/Core/Common/test/itkPixelAccessTest.cxx b/Modules/Core/Common/test/itkPixelAccessTest.cxx index ea7607938c2..fdf8122a0f7 100644 --- a/Modules/Core/Common/test/itkPixelAccessTest.cxx +++ b/Modules/Core/Common/test/itkPixelAccessTest.cxx @@ -27,8 +27,8 @@ template void TestConstPixelAccess(const itk::Image & in, itk::Image & out) { - typename itk::Image::IndexType regionStartIndex3D = { { 5, 10, 15 } }; - typename itk::Image::IndexType regionEndIndex3D = { { 8, 15, 17 } }; + const typename itk::Image::IndexType regionStartIndex3D = { { 5, 10, 15 } }; + const typename itk::Image::IndexType regionEndIndex3D = { { 8, 15, 17 } }; T vec; @@ -46,18 +46,19 @@ int itkPixelAccessTest(int, char *[]) { std::cout << "Creating an image" << std::endl; - itk::Image, 3>::Pointer o3 = itk::Image, 3>::New(); + const itk::Image, 3>::Pointer o3 = + itk::Image, 3>::New(); float origin3D[3] = { 5.0f, 2.1f, 8.1f }; float spacing3D[3] = { 1.5f, 2.1f, 1.0f }; - itk::Image, 3>::SizeType imageSize3D = { { 20, 40, 60 } }; - itk::Image, 3>::SizeType bufferSize3D = { { 8, 20, 14 } }; + const itk::Image, 3>::SizeType imageSize3D = { { 20, 40, 60 } }; + const itk::Image, 3>::SizeType bufferSize3D = { { 8, 20, 14 } }; - itk::Image, 3>::IndexType startIndex3D = { { 5, 4, 1 } }; - itk::Image, 3>::IndexType bufferStartIndex3D = { { 2, 3, 5 } }; - itk::Image, 3>::IndexType regionStartIndex3D = { { 5, 10, 12 } }; - itk::Image, 3>::IndexType regionEndIndex3D = { { 8, 15, 17 } }; + const itk::Image, 3>::IndexType startIndex3D = { { 5, 4, 1 } }; + const itk::Image, 3>::IndexType bufferStartIndex3D = { { 2, 3, 5 } }; + const itk::Image, 3>::IndexType regionStartIndex3D = { { 5, 10, 12 } }; + const itk::Image, 3>::IndexType regionEndIndex3D = { { 8, 15, 17 } }; itk::Image, 3>::RegionType region{ startIndex3D, imageSize3D }; o3->SetLargestPossibleRegion(region); diff --git a/Modules/Core/Common/test/itkPointGeometryTest.cxx b/Modules/Core/Common/test/itkPointGeometryTest.cxx index 5c173564b94..0da550e998e 100644 --- a/Modules/Core/Common/test/itkPointGeometryTest.cxx +++ b/Modules/Core/Common/test/itkPointGeometryTest.cxx @@ -70,7 +70,7 @@ itkPointGeometryTest(int, char *[]) std::cout << "copy constructor pc=pa = "; std::cout << pc << std::endl; - PointType pd = pa + va; + const PointType pd = pa + va; std::cout << "vector sum pd = pa + va = "; std::cout << pd << std::endl; @@ -78,7 +78,7 @@ itkPointGeometryTest(int, char *[]) std::cout << "vector sum pb = pd + va = "; std::cout << pb << std::endl; - VectorType diff = pa - pb; + const VectorType diff = pa - pb; std::cout << "diff = pa - pb = "; std::cout << diff << std::endl; @@ -90,11 +90,11 @@ itkPointGeometryTest(int, char *[]) std::cout << "pc += va = "; std::cout << pc << std::endl; - ValueType distance = pc.EuclideanDistanceTo(pb); + const ValueType distance = pc.EuclideanDistanceTo(pb); std::cout << "Euclidean distance between pc and pb = "; std::cout << distance << std::endl; - ValueType distance2 = pc.SquaredEuclideanDistanceTo(pb); + const ValueType distance2 = pc.SquaredEuclideanDistanceTo(pb); std::cout << "Squared Euclidean distance between pc and pb = "; std::cout << distance2 << std::endl; @@ -149,11 +149,11 @@ itkPointGeometryTest(int, char *[]) // Test the MeanPoint { - PointType midpoint; - PointType::ValueType aInit[3] = { 2.0, 4.0, 7.0 }; - PointType::ValueType bInit[3] = { 6.0, 2.0, 9.0 }; - PointType A = aInit; - PointType B = bInit; + PointType midpoint; + const PointType::ValueType aInit[3] = { 2.0, 4.0, 7.0 }; + const PointType::ValueType bInit[3] = { 6.0, 2.0, 9.0 }; + PointType A = aInit; + PointType B = bInit; midpoint.SetToMidPoint(A, B); std::cout << "Test for MidPoint " << std::endl; std::cout << "PA = " << A << std::endl; @@ -173,13 +173,13 @@ itkPointGeometryTest(int, char *[]) // Test the Barycentric combination { - const double tolerance = 1e-10; - PointType combination; - PointType::ValueType aInit[3] = { 2.0, 4.0, 7.0 }; - PointType::ValueType bInit[3] = { 6.0, 2.0, 9.0 }; - PointType A = aInit; - PointType B = bInit; - double alpha = 0.5; + const double tolerance = 1e-10; + PointType combination; + const PointType::ValueType aInit[3] = { 2.0, 4.0, 7.0 }; + const PointType::ValueType bInit[3] = { 6.0, 2.0, 9.0 }; + PointType A = aInit; + PointType B = bInit; + const double alpha = 0.5; combination.SetToBarycentricCombination(A, B, alpha); std::cout << "Test for Barycentric combination" << std::endl; std::cout << "PA = " << A << std::endl; @@ -200,16 +200,16 @@ itkPointGeometryTest(int, char *[]) // Test the Barycentric combination { - const double tolerance = 1e-10; - PointType combination; - PointType::ValueType aInit[3] = { 12.0, 0.0, 0.0 }; - PointType::ValueType bInit[3] = { 0.0, 0.0, 12.0 }; - PointType::ValueType cInit[3] = { 0.0, 12.0, 0.0 }; - PointType A = aInit; - PointType B = bInit; - PointType C = cInit; - double alpha = 1.0 / 3.0; - double beta = 1.0 / 3.0; + const double tolerance = 1e-10; + PointType combination; + const PointType::ValueType aInit[3] = { 12.0, 0.0, 0.0 }; + const PointType::ValueType bInit[3] = { 0.0, 0.0, 12.0 }; + const PointType::ValueType cInit[3] = { 0.0, 12.0, 0.0 }; + PointType A = aInit; + PointType B = bInit; + PointType C = cInit; + const double alpha = 1.0 / 3.0; + const double beta = 1.0 / 3.0; combination.SetToBarycentricCombination(A, B, C, alpha, beta); std::cout << "Test for Barycentric combination" << std::endl; std::cout << "PA = " << A << std::endl; diff --git a/Modules/Core/Common/test/itkPointSetTest.cxx b/Modules/Core/Common/test/itkPointSetTest.cxx index a57e672db3e..cc3f9fa5ea5 100644 --- a/Modules/Core/Common/test/itkPointSetTest.cxx +++ b/Modules/Core/Common/test/itkPointSetTest.cxx @@ -37,8 +37,8 @@ using PointsVectorContainerPointer = typename PointsVectorContainer::Pointer; int itkPointSetTest(int, char *[]) { - int pointDimension = 3; - int numOfPoints = 100; + const int pointDimension = 3; + const int numOfPoints = 100; /** * Define the 3d geometric positions for 8 points in a cube. @@ -48,7 +48,7 @@ itkPointSetTest(int, char *[]) /** * Create the point set through its object factory. */ - PointSet::Pointer pset(PointSet::New()); + const PointSet::Pointer pset(PointSet::New()); ITK_EXERCISE_BASIC_OBJECT_METHODS(pset, PointSet, PointSetBase); @@ -82,7 +82,7 @@ itkPointSetTest(int, char *[]) // Test non-existing point id exception ITK_TRY_EXPECT_EXCEPTION(pset->GetPoint(pId)); - PointSet::RegionType region = 0; + const PointSet::RegionType region = 0; pset->SetRequestedRegion(region); pset->SetBufferedRegion(region); @@ -100,7 +100,7 @@ itkPointSetTest(int, char *[]) } // Insert the points using SetPointArray. - PointsVectorContainerPointer pointsArray = PointsVectorContainer::New(); + const PointsVectorContainerPointer pointsArray = PointsVectorContainer::New(); // Test for in-compatible input array dimension pointsArray->InsertElement(0, 1.0); diff --git a/Modules/Core/Common/test/itkPointSetToImageFilterTest1.cxx b/Modules/Core/Common/test/itkPointSetToImageFilterTest1.cxx index 131d0e2ba94..e35d0af7065 100644 --- a/Modules/Core/Common/test/itkPointSetToImageFilterTest1.cxx +++ b/Modules/Core/Common/test/itkPointSetToImageFilterTest1.cxx @@ -49,7 +49,7 @@ itkPointSetToImageFilterTest1(int argc, char * argv[]) auto pointSet = PointSetType::New(); // Create a point set describing a circle - float radius = 100.0; + const float radius = 100.0; unsigned int count = 0; for (float theta = 0; theta < 2.0 * itk::Math::pi; theta += 0.1) { @@ -67,12 +67,12 @@ itkPointSetToImageFilterTest1(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, PointSetToImageFilter, ImageSource); - BinaryImageType::SpacingType::ValueType spacingValue = 1.0; - auto spacing = itk::MakeFilled(spacingValue); + const BinaryImageType::SpacingType::ValueType spacingValue = 1.0; + auto spacing = itk::MakeFilled(spacingValue); filter->SetSpacing(spacing); ITK_TEST_SET_GET_VALUE(spacing, filter->GetSpacing()); - BinaryImageType::PointType origin{ { { -125, -125 } } }; + const BinaryImageType::PointType origin{ { { -125, -125 } } }; filter->SetOrigin(origin); ITK_TEST_SET_GET_VALUE(origin, filter->GetOrigin()); @@ -81,28 +81,29 @@ itkPointSetToImageFilterTest1(int argc, char * argv[]) filter->SetDirection(direction); ITK_TEST_SET_GET_VALUE(direction, filter->GetDirection()); - typename BinaryImageType::ValueType insideValue = itk::NumericTraits::OneValue(); + const typename BinaryImageType::ValueType insideValue = + itk::NumericTraits::OneValue(); filter->SetInsideValue(insideValue); ITK_TEST_SET_GET_VALUE(insideValue, filter->GetInsideValue()); - typename BinaryImageType::ValueType outsideValue{}; + const typename BinaryImageType::ValueType outsideValue{}; filter->SetOutsideValue(outsideValue); ITK_TEST_SET_GET_VALUE(outsideValue, filter->GetOutsideValue()); - typename BinaryImageType::SizeType size = { { 250, 250 } }; + const typename BinaryImageType::SizeType size = { { 250, 250 } }; filter->SetSize(size); ITK_TEST_SET_GET_VALUE(size, filter->GetSize()); filter->SetInput(pointSet); ITK_TEST_SET_GET_VALUE(pointSet, filter->GetInput()); - unsigned int idx = 0; + const unsigned int idx = 0; ITK_TEST_SET_GET_VALUE(pointSet, filter->GetInput(idx)); ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); - BinaryImageType::Pointer binaryImage = filter->GetOutput(); + const BinaryImageType::Pointer binaryImage = filter->GetOutput(); itk::WriteImage(binaryImage, argv[1]); diff --git a/Modules/Core/Common/test/itkPointSetToImageFilterTest2.cxx b/Modules/Core/Common/test/itkPointSetToImageFilterTest2.cxx index 886d2423921..67a2151976f 100644 --- a/Modules/Core/Common/test/itkPointSetToImageFilterTest2.cxx +++ b/Modules/Core/Common/test/itkPointSetToImageFilterTest2.cxx @@ -81,7 +81,7 @@ itkPointSetToImageFilterTest2(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); - BinaryImageType::Pointer binaryImage = filter->GetOutput(); + const BinaryImageType::Pointer binaryImage = filter->GetOutput(); itk::WriteImage(binaryImage, argv[2]); diff --git a/Modules/Core/Common/test/itkRangeGTestUtilities.h b/Modules/Core/Common/test/itkRangeGTestUtilities.h index eba4558ac0c..66f0a13b8e8 100644 --- a/Modules/Core/Common/test/itkRangeGTestUtilities.h +++ b/Modules/Core/Common/test/itkRangeGTestUtilities.h @@ -109,7 +109,7 @@ class RangeGTestUtilities ExpectIteratorIsDefaultConstructible() { using IteratorType = typename TRange::iterator; - IteratorType defaultConstructedIterator{}; + const IteratorType defaultConstructedIterator{}; // Test that a default-constructed iterator behaves according to C++ proposal // N3644, "Null Forward Iterators" by Alan Talbot, which is accepted with diff --git a/Modules/Core/Common/test/itkRealTimeClockTest.cxx b/Modules/Core/Common/test/itkRealTimeClockTest.cxx index f27b4945e17..18d6f08e7ae 100644 --- a/Modules/Core/Common/test/itkRealTimeClockTest.cxx +++ b/Modules/Core/Common/test/itkRealTimeClockTest.cxx @@ -29,13 +29,13 @@ itkRealTimeClockTest(int, char *[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope // scope. - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); try { // Create an ITK RealTimeClock - itk::RealTimeClock::Pointer clock = itk::RealTimeClock::New(); + const itk::RealTimeClock::Pointer clock = itk::RealTimeClock::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(clock, RealTimeClock, Object); std::cout << "Testing itk::RealTimeClock" << std::endl; @@ -68,17 +68,17 @@ itkRealTimeClockTest(int, char *[]) using TimeRepresentationType = itk::RealTimeStamp::TimeRepresentationType; - TimeRepresentationType tolerance = 1e6; + const TimeRepresentationType tolerance = 1e6; for (unsigned int i = 0; i < 10; ++i) { realStamp1 = realStamp2; realStamp2 = clock->GetRealTimeStamp(); - itk::RealTimeInterval difference = realStamp2 - realStamp1; - itk::RealTimeStamp::TimeRepresentationType seconds1 = realStamp1.GetTimeInSeconds(); - itk::RealTimeStamp::TimeRepresentationType seconds2 = realStamp2.GetTimeInSeconds(); - itk::RealTimeStamp::TimeRepresentationType secondsD = difference.GetTimeInSeconds(); - itk::RealTimeStamp::TimeRepresentationType secondsE = seconds2 - seconds1; + const itk::RealTimeInterval difference = realStamp2 - realStamp1; + const itk::RealTimeStamp::TimeRepresentationType seconds1 = realStamp1.GetTimeInSeconds(); + const itk::RealTimeStamp::TimeRepresentationType seconds2 = realStamp2.GetTimeInSeconds(); + const itk::RealTimeStamp::TimeRepresentationType secondsD = difference.GetTimeInSeconds(); + const itk::RealTimeStamp::TimeRepresentationType secondsE = seconds2 - seconds1; std::cout << realStamp2 << " - " << realStamp1 << " = "; std::cout << secondsD << " = " << secondsE << std::endl; diff --git a/Modules/Core/Common/test/itkRealTimeIntervalTest.cxx b/Modules/Core/Common/test/itkRealTimeIntervalTest.cxx index a641236358c..4b8335946be 100644 --- a/Modules/Core/Common/test/itkRealTimeIntervalTest.cxx +++ b/Modules/Core/Common/test/itkRealTimeIntervalTest.cxx @@ -51,14 +51,14 @@ int itkRealTimeIntervalTest(int, char *[]) { - itk::RealTimeInterval interval0; + const itk::RealTimeInterval interval0; - double timeInMicroSeconds = interval0.GetTimeInMicroSeconds(); - double timeInMilliSeconds = interval0.GetTimeInMilliSeconds(); - double timeInSeconds = interval0.GetTimeInSeconds(); - double timeInMinutes = interval0.GetTimeInMinutes(); - double timeInHours = interval0.GetTimeInHours(); - double timeInDays = interval0.GetTimeInDays(); + const double timeInMicroSeconds = interval0.GetTimeInMicroSeconds(); + const double timeInMilliSeconds = interval0.GetTimeInMilliSeconds(); + double timeInSeconds = interval0.GetTimeInSeconds(); + const double timeInMinutes = interval0.GetTimeInMinutes(); + const double timeInHours = interval0.GetTimeInHours(); + const double timeInDays = interval0.GetTimeInDays(); CHECK_FOR_VALUE(timeInMicroSeconds, 0.0); CHECK_FOR_VALUE(timeInMilliSeconds, 0.0); @@ -67,10 +67,10 @@ itkRealTimeIntervalTest(int, char *[]) CHECK_FOR_VALUE(timeInHours, 0.0); CHECK_FOR_VALUE(timeInDays, 0.0); - itk::RealTimeInterval interval1; - itk::RealTimeInterval intervalX = interval0; + const itk::RealTimeInterval interval1; + itk::RealTimeInterval intervalX = interval0; - itk::RealTimeInterval oneSecond(1, 0); + const itk::RealTimeInterval oneSecond(1, 0); for (unsigned int i = 0; i < 1000000L; ++i) { intervalX += oneSecond; @@ -139,19 +139,19 @@ itkRealTimeIntervalTest(int, char *[]) CHECK_FOR_VALUE(timeInSeconds, 24.0); - itk::RealTimeInterval timeSpan1(19, 300000L); - itk::RealTimeInterval timeSpan2(13, 500000L); + const itk::RealTimeInterval timeSpan1(19, 300000L); + const itk::RealTimeInterval timeSpan2(13, 500000L); - itk::RealTimeInterval timeSpan3 = timeSpan1 + timeSpan2; + const itk::RealTimeInterval timeSpan3 = timeSpan1 + timeSpan2; timeInSeconds = timeSpan3.GetTimeInSeconds(); CHECK_FOR_VALUE(timeInSeconds, 32.8); // Test comparison operations - itk::RealTimeInterval dt1(15, 13); - itk::RealTimeInterval dt2(19, 11); - itk::RealTimeInterval dt3(15, 25); + const itk::RealTimeInterval dt1(15, 13); + const itk::RealTimeInterval dt2(19, 11); + const itk::RealTimeInterval dt3(15, 25); CHECK_FOR_BOOLEAN(dt1 == dt1, true); CHECK_FOR_BOOLEAN(dt1 != dt2, true); diff --git a/Modules/Core/Common/test/itkRealTimeStampTest.cxx b/Modules/Core/Common/test/itkRealTimeStampTest.cxx index fe3bf11c7e3..685fab890ef 100644 --- a/Modules/Core/Common/test/itkRealTimeStampTest.cxx +++ b/Modules/Core/Common/test/itkRealTimeStampTest.cxx @@ -50,13 +50,13 @@ int itkRealTimeStampTest(int, char *[]) { - itk::RealTimeStamp stamp0; + const itk::RealTimeStamp stamp0; - double timeInMicroSeconds = stamp0.GetTimeInMicroSeconds(); - double timeInMilliSeconds = stamp0.GetTimeInMilliSeconds(); - double timeInSeconds = stamp0.GetTimeInSeconds(); - double timeInHours = stamp0.GetTimeInHours(); - double timeInDays = stamp0.GetTimeInDays(); + const double timeInMicroSeconds = stamp0.GetTimeInMicroSeconds(); + const double timeInMilliSeconds = stamp0.GetTimeInMilliSeconds(); + double timeInSeconds = stamp0.GetTimeInSeconds(); + const double timeInHours = stamp0.GetTimeInHours(); + const double timeInDays = stamp0.GetTimeInDays(); CHECK_FOR_VALUE(timeInMicroSeconds, 0.0); CHECK_FOR_VALUE(timeInMilliSeconds, 0.0); @@ -64,13 +64,13 @@ itkRealTimeStampTest(int, char *[]) CHECK_FOR_VALUE(timeInHours, 0.0); CHECK_FOR_VALUE(timeInDays, 0.0); - itk::RealTimeStamp stamp1; - itk::RealTimeStamp stamp2 = stamp0; + const itk::RealTimeStamp stamp1; + itk::RealTimeStamp stamp2 = stamp0; - itk::RealTimeInterval minusOneSecond(-1, 0); + const itk::RealTimeInterval minusOneSecond(-1, 0); ITK_TRY_EXPECT_EXCEPTION(stamp2 += minusOneSecond); - itk::RealTimeInterval oneSecond(1, 0); + const itk::RealTimeInterval oneSecond(1, 0); for (unsigned int i = 0; i < 1000000L; ++i) { @@ -141,19 +141,19 @@ itkRealTimeStampTest(int, char *[]) CHECK_FOR_VALUE(timeInSeconds, 24.0); - itk::RealTimeInterval timeSpan1(19, 300000L); - itk::RealTimeInterval timeSpan2(13, 500000L); + const itk::RealTimeInterval timeSpan1(19, 300000L); + const itk::RealTimeInterval timeSpan2(13, 500000L); - itk::RealTimeInterval timeSpan3 = timeSpan1 + timeSpan2; + const itk::RealTimeInterval timeSpan3 = timeSpan1 + timeSpan2; timeInSeconds = timeSpan3.GetTimeInSeconds(); CHECK_FOR_VALUE(timeInSeconds, 32.8); // Test comparison operations - itk::RealTimeInterval dt1(15, 13); - itk::RealTimeInterval dt2(19, 11); - itk::RealTimeInterval dt3(15, 25); + const itk::RealTimeInterval dt1(15, 13); + const itk::RealTimeInterval dt2(19, 11); + const itk::RealTimeInterval dt3(15, 25); itk::RealTimeInterval t1; t1 += dt1; diff --git a/Modules/Core/Common/test/itkSTLThreadTest.cxx b/Modules/Core/Common/test/itkSTLThreadTest.cxx index 5c9f50ebaa6..ffed6b31092 100644 --- a/Modules/Core/Common/test/itkSTLThreadTest.cxx +++ b/Modules/Core/Common/test/itkSTLThreadTest.cxx @@ -39,7 +39,7 @@ itkSTLThreadTest(int argc, char * argv[]) size_t numWorkUnits = 10; if (argc > 1) { - int nt = std::stoi(argv[1]); + const int nt = std::stoi(argv[1]); if (nt > 1) { numWorkUnits = nt; @@ -49,7 +49,7 @@ itkSTLThreadTest(int argc, char * argv[]) // Choose a number of iterations (0 is infinite). if (argc > 2) { - int ni = std::stoi(argv[2]); + const int ni = std::stoi(argv[2]); if (ni >= 0) { itkSTLThreadTestImpl::numberOfIterations = ni; @@ -81,7 +81,7 @@ itkSTLThreadTest(int argc, char * argv[]) } // Create and execute the threads. - itk::PlatformMultiThreader::Pointer threader = itk::PlatformMultiThreader::New(); + const itk::PlatformMultiThreader::Pointer threader = itk::PlatformMultiThreader::New(); threader->SetSingleMethod(itkSTLThreadTestImpl::Runner, results); threader->SetNumberOfWorkUnits(numWorkUnits); threader->SingleMethodExecute(); @@ -108,7 +108,7 @@ itkSTLThreadTest(int argc, char * argv[]) #if !defined(ITK_LEGACY_REMOVE) // test deprecated methods too! - itk::ThreadIdType threadId = threader->SpawnThread(itkSTLThreadTestImpl::Runner, nullptr); + const itk::ThreadIdType threadId = threader->SpawnThread(itkSTLThreadTestImpl::Runner, nullptr); itkSTLThreadTestImpl::threadMutex.lock(); std::cout << "SpawnThread(itkSTLThreadTestImpl::Runner, results): " << threadId << std::endl; itkSTLThreadTestImpl::threadMutex.unlock(); @@ -128,9 +128,9 @@ static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION Runner(void * infoIn) { // Get the work unit id and result pointer and run the method for this work unit. - auto * info = static_cast(infoIn); - itk::ThreadIdType tnum = info->WorkUnitID; - auto * results = static_cast(info->UserData); + auto * info = static_cast(infoIn); + const itk::ThreadIdType tnum = info->WorkUnitID; + auto * results = static_cast(info->UserData); if (results) { results[tnum] = itkSTLThreadTestImpl::Thread(tnum); @@ -155,7 +155,7 @@ Thread(int tnum) std::list l; // Choose a size for each iteration for this thread. - int count = 10000 + 100 * tnum; + const int count = 10000 + 100 * tnum; int iteration = 0; while (!done && !(numberOfIterations && (iteration >= numberOfIterations))) diff --git a/Modules/Core/Common/test/itkShapedImageNeighborhoodRangeGTest.cxx b/Modules/Core/Common/test/itkShapedImageNeighborhoodRangeGTest.cxx index 0d48f301861..3c47d1cadf7 100644 --- a/Modules/Core/Common/test/itkShapedImageNeighborhoodRangeGTest.cxx +++ b/Modules/Core/Common/test/itkShapedImageNeighborhoodRangeGTest.cxx @@ -120,8 +120,8 @@ template typename TImage::Pointer CreateSmallImage() { - const auto image = TImage::New(); - typename TImage::SizeType imageSize{}; + const auto image = TImage::New(); + const typename TImage::SizeType imageSize{}; image->SetRegions(imageSize); SetVectorLengthIfImageIsVectorImage(*image, 1); image->AllocateInitialized(); @@ -250,7 +250,7 @@ TEST(ShapedImageNeighborhoodRange, EquivalentBeginOrEndIteratorsCompareEqual) const ImageType::IndexType location{ {} }; const std::vector> offsets = itk::GenerateRectangularImageNeighborhoodOffsets(radius); - itk::ShapedImageNeighborhoodRange range{ *image, location, offsets }; + const itk::ShapedImageNeighborhoodRange range{ *image, location, offsets }; const itk::ShapedImageNeighborhoodRange::iterator begin = range.begin(); const itk::ShapedImageNeighborhoodRange::iterator end = range.end(); @@ -288,7 +288,7 @@ TEST(ShapedImageNeighborhoodRange, BeginAndEndDoNotCompareEqual) const ImageType::IndexType location{ {} }; const std::vector> offsets = itk::GenerateRectangularImageNeighborhoodOffsets(radius); - itk::ShapedImageNeighborhoodRange range{ *image, location, offsets }; + const itk::ShapedImageNeighborhoodRange range{ *image, location, offsets }; EXPECT_FALSE(range.begin() == range.end()); EXPECT_NE(range.begin(), range.end()); @@ -306,7 +306,7 @@ TEST(ShapedImageNeighborhoodRange, IteratorConvertsToConstIterator) const ImageType::IndexType location{ {} }; const std::vector> offsets = itk::GenerateRectangularImageNeighborhoodOffsets(radius); - itk::ShapedImageNeighborhoodRange range{ *image, location, offsets }; + const itk::ShapedImageNeighborhoodRange range{ *image, location, offsets }; const itk::ShapedImageNeighborhoodRange::iterator begin = range.begin(); const itk::ShapedImageNeighborhoodRange::const_iterator const_begin_from_begin = begin; @@ -334,7 +334,7 @@ TEST(ShapedImageNeighborhoodRange, IteratorsCanBePassedToStdVectorConstructor) const itk::Size radius = { { 0, 1 } }; const std::vector> offsets = itk::GenerateRectangularImageNeighborhoodOffsets(radius); - itk::ShapedImageNeighborhoodRange range{ *image, location, offsets }; + const itk::ShapedImageNeighborhoodRange range{ *image, location, offsets }; // Easily store all pixels of the ShapedImageNeighborhoodRange in an std::vector: const std::vector stdVector(range.begin(), range.end()); @@ -360,7 +360,7 @@ TEST(ShapedImageNeighborhoodRange, IteratorsCanBePassedToStdReverseCopy) const itk::Size radius = { { 0, 1 } }; const std::vector> offsets = itk::GenerateRectangularImageNeighborhoodOffsets(radius); - itk::ShapedImageNeighborhoodRange range{ *image, location, offsets }; + const itk::ShapedImageNeighborhoodRange range{ *image, location, offsets }; const unsigned int numberOfNeighborhoodPixels = 3; ASSERT_EQ(numberOfNeighborhoodPixels, range.size()); @@ -405,7 +405,7 @@ TEST(ShapedImageNeighborhoodRange, IteratorsCanBePassedToStdInnerProduct) const itk::Size radius = { { 0, 1 } }; const std::vector> offsets = itk::GenerateRectangularImageNeighborhoodOffsets(radius); - itk::ShapedImageNeighborhoodRange range{ *image, location, offsets }; + const itk::ShapedImageNeighborhoodRange range{ *image, location, offsets }; const double innerProduct = std::inner_product(range.begin(), range.end(), range.begin(), 0.0); @@ -430,7 +430,7 @@ TEST(ShapedImageNeighborhoodRange, IteratorsCanBePassedToStdForEach) const itk::Size radius = { { 0, 1 } }; const std::vector> offsets = itk::GenerateRectangularImageNeighborhoodOffsets(radius); - itk::ShapedImageNeighborhoodRange range{ *image, location, offsets }; + const itk::ShapedImageNeighborhoodRange range{ *image, location, offsets }; std::for_each(range.begin(), range.end(), [](const PixelType pixel) { EXPECT_TRUE(pixel > 0); }); } @@ -455,7 +455,7 @@ TEST(ShapedImageNeighborhoodRange, CanBeUsedAsExpressionOfRangeBasedForLoop) const itk::Size radius = { { 0, 1 } }; const std::vector> offsets = itk::GenerateRectangularImageNeighborhoodOffsets(radius); - RangeType range{ *image, location, offsets }; + const RangeType range{ *image, location, offsets }; constexpr PixelType reference_value = 42; for (const PixelType pixel : range) @@ -500,7 +500,7 @@ TEST(ShapedImageNeighborhoodRange, DistanceBetweenIteratorsCanBeObtainedBySubtra const itk::Size radius = { { 2, 3 } }; const std::vector> offsets = itk::GenerateRectangularImageNeighborhoodOffsets(radius); - itk::ShapedImageNeighborhoodRange range{ *image, location, offsets }; + const itk::ShapedImageNeighborhoodRange range{ *image, location, offsets }; itk::ShapedImageNeighborhoodRange::iterator it1 = range.begin(); @@ -573,19 +573,19 @@ TEST(ShapedImageNeighborhoodRange, IteratorReferenceActsLikeARealReference) const itk::Size radius = { { 1, 0 } }; const std::vector> offsets = itk::GenerateRectangularImageNeighborhoodOffsets(radius); - RangeType range{ *image, location, offsets }; + const RangeType range{ *image, location, offsets }; RangeType::iterator it = range.begin(); - RangeType::iterator::reference reference1 = *it; - RangeType::iterator::reference reference2 = *(++it); - RangeType::const_iterator::reference reference3 = *(++it); + RangeType::iterator::reference reference1 = *it; + RangeType::iterator::reference reference2 = *(++it); + const RangeType::const_iterator::reference reference3 = *(++it); EXPECT_EQ(reference1, 1); EXPECT_EQ(reference2, 2); EXPECT_EQ(reference3, 3); - RangeType::const_iterator::reference reference4 = reference1; - RangeType::const_iterator::reference reference5 = reference2; - RangeType::const_iterator::reference reference6 = reference3; + const RangeType::const_iterator::reference reference4 = reference1; + const RangeType::const_iterator::reference reference5 = reference2; + const RangeType::const_iterator::reference reference6 = reference3; EXPECT_EQ(reference4, 1); EXPECT_EQ(reference5, 2); EXPECT_EQ(reference6, 3); @@ -636,9 +636,9 @@ TEST(ShapedImageNeighborhoodRange, SupportsVectorImage) itk::GenerateRectangularImageNeighborhoodOffsets(radius); using RangeType = itk::ShapedImageNeighborhoodRange; - RangeType range{ *image, location, offsets }; + const RangeType range{ *image, location, offsets }; - for (PixelType pixelValue : range) + for (const PixelType pixelValue : range) { EXPECT_EQ(pixelValue, fillPixelValue); } @@ -671,7 +671,7 @@ TEST(ShapedImageNeighborhoodRange, IteratorsCanBePassedToStdSort) const itk::Size radius = { { 1, 1 } }; const std::vector> offsets = itk::GenerateRectangularImageNeighborhoodOffsets(radius); - itk::ShapedImageNeighborhoodRange range{ *image, location, offsets }; + const itk::ShapedImageNeighborhoodRange range{ *image, location, offsets }; // Initial order: (1, 2, 3, ..., 9). const std::vector initiallyOrderedPixels(range.cbegin(), range.cend()); @@ -706,7 +706,7 @@ TEST(ShapedImageNeighborhoodRange, IteratorsCanBePassedToStdNthElement) const itk::Size radius = { { 1, 1 } }; const std::vector> offsets = itk::GenerateRectangularImageNeighborhoodOffsets(radius); - itk::ShapedImageNeighborhoodRange range{ *image, location, offsets }; + const itk::ShapedImageNeighborhoodRange range{ *image, location, offsets }; std::reverse(range.begin(), range.end()); @@ -749,7 +749,7 @@ TEST(ShapedImageNeighborhoodRange, IteratorsSupportRandomAccess) const itk::Size radius = { { 1, 1 } }; const std::vector> offsets = itk::GenerateRectangularImageNeighborhoodOffsets(radius); - RangeType range{ *image, location, offsets }; + const RangeType range{ *image, location, offsets }; // Testing expressions from Table 111 "Random access iterator requirements // (in addition to bidirectional iterator)", C++11 Standard, section 24.2.7 @@ -758,8 +758,8 @@ TEST(ShapedImageNeighborhoodRange, IteratorsSupportRandomAccess) // Note: The 1-letter identifiers (X, a, b, n, r) and the operational semantics // are directly from the C++11 Standard. using X = RangeType::iterator; - X a = range.begin(); - X b = range.end(); + const X a = range.begin(); + const X b = range.end(); const X initialIterator = range.begin(); X mutableIterator = initialIterator; @@ -770,14 +770,14 @@ TEST(ShapedImageNeighborhoodRange, IteratorsSupportRandomAccess) { // Expression to be tested: 'r += n' - difference_type n = 3; + constexpr difference_type n = 3; static_assert(std::is_same_v, "Return type tested"); r = initialIterator; - const auto expectedResult = [&r, n] { + const auto expectedResult = [&r](const difference_type nn) { // Operational semantics, as specified by the C++11 Standard: - difference_type m = n; + difference_type m = nn; if (m >= 0) while (m--) ++r; @@ -785,53 +785,53 @@ TEST(ShapedImageNeighborhoodRange, IteratorsSupportRandomAccess) while (m++) --r; return r; - }(); + }(n); r = initialIterator; const auto actualResult = r += n; EXPECT_EQ(actualResult, expectedResult); } { // Expressions to be tested: 'a + n' and 'n + a' - difference_type n = 3; + constexpr difference_type n = 3; static_assert(std::is_same_v, "Return type tested"); static_assert(std::is_same_v, "Return type tested"); - const auto expectedResult = [a, n] { + const auto expectedResult = [a](const difference_type nn) { // Operational semantics, as specified by the C++11 Standard: X tmp = a; - return tmp += n; - }(); + return tmp += nn; + }(n); EXPECT_EQ(a + n, expectedResult); EXPECT_TRUE(a + n == n + a); } { // Expression to be tested: 'r -= n' - difference_type n = 3; + constexpr difference_type n = 3; static_assert(std::is_same_v, "Return type tested"); r = initialIterator; - const auto expectedResult = [&r, n] { + const auto expectedResult = [&r](const difference_type nn) { // Operational semantics, as specified by the C++11 Standard: - return r += -n; - }(); + return r += -nn; + }(n); r = initialIterator; const auto actualResult = r -= n; EXPECT_EQ(actualResult, expectedResult); } { // Expression to be tested: 'a - n' - difference_type n = -3; + constexpr difference_type n = -3; static_assert(std::is_same_v, "Return type tested"); - const auto expectedResult = [a, n] { + const auto expectedResult = [a](const difference_type nn) { // Operational semantics, as specified by the C++11 Standard: X tmp = a; - return tmp -= n; - }(); + return tmp -= nn; + }(n); EXPECT_EQ(a - n, expectedResult); } @@ -839,13 +839,13 @@ TEST(ShapedImageNeighborhoodRange, IteratorsSupportRandomAccess) // Expression to be tested: 'b - a' static_assert(std::is_same_v, "Return type tested"); - difference_type n = b - a; + const difference_type n = b - a; EXPECT_TRUE(a + n == b); EXPECT_TRUE(b == a + (b - a)); } { // Expression to be tested: 'a[n]' - difference_type n = 3; + constexpr difference_type n = 3; static_assert(std::is_convertible_v, "Return type tested"); EXPECT_EQ(a[n], *(a + n)); } @@ -880,7 +880,7 @@ TEST(ShapedImageNeighborhoodRange, SupportsSubscript) const itk::Size radius = { { 1, 1 } }; const std::vector> offsets = itk::GenerateRectangularImageNeighborhoodOffsets(radius); - RangeType range{ *image, location, offsets }; + const RangeType range{ *image, location, offsets }; const size_t numberOfNeighbors = range.size(); @@ -888,7 +888,7 @@ TEST(ShapedImageNeighborhoodRange, SupportsSubscript) for (size_t i = 0; i < numberOfNeighbors; ++i) { - RangeType::iterator::reference neighbor = range[i]; + const RangeType::iterator::reference neighbor = range[i]; EXPECT_EQ(neighbor, *it); ++it; } @@ -911,7 +911,7 @@ TEST(ShapedImageNeighborhoodRange, ProvidesReverseIterators) const itk::Size radius = { { 0, 1 } }; const std::vector> offsets = itk::GenerateRectangularImageNeighborhoodOffsets(radius); - RangeType range{ *image, location, offsets }; + const RangeType range{ *image, location, offsets }; constexpr unsigned int numberOfNeighborhoodPixels = 3; ASSERT_EQ(numberOfNeighborhoodPixels, range.size()); diff --git a/Modules/Core/Common/test/itkShapedNeighborhoodIteratorTest.cxx b/Modules/Core/Common/test/itkShapedNeighborhoodIteratorTest.cxx index 0a25310fdcb..ceda8347449 100644 --- a/Modules/Core/Common/test/itkShapedNeighborhoodIteratorTest.cxx +++ b/Modules/Core/Common/test/itkShapedNeighborhoodIteratorTest.cxx @@ -24,7 +24,7 @@ int itkShapedNeighborhoodIteratorTest(int, char *[]) { - TestImageType::Pointer img = GetTestImage(10, 10, 5, 3); + const TestImageType::Pointer img = GetTestImage(10, 10, 5, 3); itk::ShapedNeighborhoodIterator::IndexType loc; loc[0] = 4; loc[1] = 4; diff --git a/Modules/Core/Common/test/itkSimpleFilterWatcherTest.cxx b/Modules/Core/Common/test/itkSimpleFilterWatcherTest.cxx index 0a714fdaef5..b0855f7858b 100644 --- a/Modules/Core/Common/test/itkSimpleFilterWatcherTest.cxx +++ b/Modules/Core/Common/test/itkSimpleFilterWatcherTest.cxx @@ -122,7 +122,7 @@ itkSimpleFilterWatcherTest(int, char *[]) } // Test GetNameOfClass(). - std::string name = watcher3.GetNameOfClass(); + const std::string name = watcher3.GetNameOfClass(); if (name != filter->GetNameOfClass()) { std::cout << "GetNameOfClass failed. Expected: " << filter->GetNameOfClass() diff --git a/Modules/Core/Common/test/itkSinRegularizedHeavisideStepFunctionTest1.cxx b/Modules/Core/Common/test/itkSinRegularizedHeavisideStepFunctionTest1.cxx index 455ba33fe58..f77b4a47a1e 100644 --- a/Modules/Core/Common/test/itkSinRegularizedHeavisideStepFunctionTest1.cxx +++ b/Modules/Core/Common/test/itkSinRegularizedHeavisideStepFunctionTest1.cxx @@ -55,9 +55,9 @@ itkSinRegularizedHeavisideStepFunctionTest1(int, char *[]) for (int x = minValue; x < maxValue; ++x) { - const InputType ix = x * incValue; - OutputType f = functionBase0->Evaluate(ix); - OutputType df = functionBase0->EvaluateDerivative(ix); + const InputType ix = x * incValue; + const OutputType f = functionBase0->Evaluate(ix); + const OutputType df = functionBase0->EvaluateDerivative(ix); std::cout << ix << ' ' << f << ' ' << df << std::endl; } diff --git a/Modules/Core/Common/test/itkSliceIteratorTest.cxx b/Modules/Core/Common/test/itkSliceIteratorTest.cxx index 6b21d68085e..a5cc6057c73 100644 --- a/Modules/Core/Common/test/itkSliceIteratorTest.cxx +++ b/Modules/Core/Common/test/itkSliceIteratorTest.cxx @@ -156,13 +156,13 @@ itkSliceIteratorTest(int, char *[]) reg.SetIndex(zeroIndex); reg.SetSize(imgSize); - std::slice hslice(10, 5, 1); // slice through the horizontal center - std::slice vslice(2, 5, 5); // slice through the vertical center - itk::Neighborhood temp; - itk::SliceIterator> hnsi(&temp, hslice); - itk::SliceIterator> vnsi(&temp, vslice); - itk::ConstSliceIterator> hnsi2(&temp, hslice); - itk::ConstSliceIterator> vnsi2(&temp, vslice); + const std::slice hslice(10, 5, 1); // slice through the horizontal center + const std::slice vslice(2, 5, 5); // slice through the vertical center + itk::Neighborhood temp; + const itk::SliceIterator> hnsi(&temp, hslice); + const itk::SliceIterator> vnsi(&temp, vslice); + const itk::ConstSliceIterator> hnsi2(&temp, hslice); + const itk::ConstSliceIterator> vnsi2(&temp, vslice); itk::Neighborhood op; op.SetRadius(hoodRadius); @@ -170,7 +170,7 @@ itkSliceIteratorTest(int, char *[]) itk::Index<2> idx; idx[0] = idx[1] = 0; - itk::Image::Pointer ip = itk::Image::New(); + const itk::Image::Pointer ip = itk::Image::New(); ip->SetRegions(reg); ip->Allocate(); diff --git a/Modules/Core/Common/test/itkSmartPointerGTest.cxx b/Modules/Core/Common/test/itkSmartPointerGTest.cxx index 78c5d187f0b..9f7c8ab9f73 100644 --- a/Modules/Core/Common/test/itkSmartPointerGTest.cxx +++ b/Modules/Core/Common/test/itkSmartPointerGTest.cxx @@ -151,11 +151,11 @@ TEST(SmartPointer, EmptyAndNull) // EXPECT_TRUE( 0 == ptr ); // Exercise pointer assignment - auto p1 = Derived2::New(); - Derived2::Pointer p2 = p1; - Derived2::ConstPointer cp1 = p1; - Derived2::ConstPointer cp2(p1); - Derived2::ConstPointer cp3{ p1 }; + auto p1 = Derived2::New(); + const Derived2::Pointer p2 = p1; + const Derived2::ConstPointer cp1 = p1; + const Derived2::ConstPointer cp2(p1); + const Derived2::ConstPointer cp3{ p1 }; } @@ -168,20 +168,20 @@ TEST(SmartPointer, Converting) using Derived1Pointer = itk::SmartPointer; using ConstDerived1Pointer = itk::SmartPointer; - Derived1Pointer d1ptr = Derived1::New(); + const Derived1Pointer d1ptr = Derived1::New(); EXPECT_TRUE(d1ptr.IsNotNull()); EXPECT_FALSE(d1ptr.IsNull()); EXPECT_TRUE(static_cast(d1ptr)); EXPECT_FALSE(d1ptr == nullptr); EXPECT_TRUE(d1ptr != nullptr); - ConstDerived1Pointer cd1ptr(d1ptr); + const ConstDerived1Pointer cd1ptr(d1ptr); EXPECT_TRUE(cd1ptr.GetPointer() == d1ptr.GetPointer()); EXPECT_TRUE(cd1ptr == d1ptr); - BasePointer ptr(d1ptr); - ConstBasePointer cptr1(d1ptr); - ConstBasePointer cptr2(cd1ptr); + BasePointer ptr(d1ptr); + const ConstBasePointer cptr1(d1ptr); + const ConstBasePointer cptr2(cd1ptr); ptr = d1ptr; @@ -219,27 +219,27 @@ TEST(SmartPointer, ConvertingRegisterCount) // Copy constructor to const { - Derived1Pointer d1ptr = Derived1::New(); + const Derived1Pointer d1ptr = Derived1::New(); EXPECT_EQ(1, d1ptr->GetRegisterCount()); - ConstDerived1Pointer cd1ptr = d1ptr; + const ConstDerived1Pointer cd1ptr = d1ptr; EXPECT_EQ(2, d1ptr->GetRegisterCount()); EXPECT_EQ(2, cd1ptr->GetRegisterCount()); } // Copy constructor to base { - Derived1Pointer d1ptr = Derived1::New(); + const Derived1Pointer d1ptr = Derived1::New(); EXPECT_EQ(1, d1ptr->GetRegisterCount()); - BasePointer bptr = d1ptr; + const BasePointer bptr = d1ptr; EXPECT_EQ(2, d1ptr->GetRegisterCount()); EXPECT_EQ(2, static_cast(bptr.GetPointer())->GetRegisterCount()); } // Assignment operator { - Derived1Pointer d1ptr = Derived1::New(); + const Derived1Pointer d1ptr = Derived1::New(); EXPECT_EQ(1, d1ptr->GetRegisterCount()); Derived1Pointer d1ptr2; @@ -251,7 +251,7 @@ TEST(SmartPointer, ConvertingRegisterCount) // Assignment to const pointer { - Derived1Pointer d1ptr = Derived1::New(); + const Derived1Pointer d1ptr = Derived1::New(); EXPECT_EQ(1, d1ptr->GetRegisterCount()); ConstDerived1Pointer cd1ptr; @@ -263,7 +263,7 @@ TEST(SmartPointer, ConvertingRegisterCount) // Assignment to base pointer { - Derived1Pointer d1ptr = Derived1::New(); + const Derived1Pointer d1ptr = Derived1::New(); EXPECT_EQ(1, d1ptr->GetRegisterCount()); BasePointer bptr; @@ -275,7 +275,7 @@ TEST(SmartPointer, ConvertingRegisterCount) // Assignment to raw pointer { - Derived1Pointer d1ptr = Derived1::New(); + const Derived1Pointer d1ptr = Derived1::New(); EXPECT_EQ(1, d1ptr->GetRegisterCount()); Derived1 * rptr = d1ptr; @@ -285,7 +285,7 @@ TEST(SmartPointer, ConvertingRegisterCount) // Assignment to raw const pointer { - Derived1Pointer d1ptr = Derived1::New(); + const Derived1Pointer d1ptr = Derived1::New(); EXPECT_EQ(1, d1ptr->GetRegisterCount()); const Derived1 * rptr = d1ptr; @@ -298,7 +298,7 @@ TEST(SmartPointer, ConvertingRegisterCount) Derived1Pointer d1ptr = Derived1::New(); EXPECT_EQ(1, d1ptr->GetRegisterCount()); - Derived1Pointer d1ptr2(std::move(d1ptr)); + const Derived1Pointer d1ptr2(std::move(d1ptr)); EXPECT_EQ(1, d1ptr2->GetRegisterCount()); EXPECT_TRUE(d1ptr.IsNull()); } @@ -308,7 +308,7 @@ TEST(SmartPointer, ConvertingRegisterCount) Derived1Pointer d1ptr = Derived1::New(); EXPECT_EQ(1, d1ptr->GetRegisterCount()); - ConstDerived1Pointer cd1ptr(std::move(d1ptr)); + const ConstDerived1Pointer cd1ptr(std::move(d1ptr)); EXPECT_EQ(1, cd1ptr->GetRegisterCount()); EXPECT_TRUE(d1ptr.IsNull()); } @@ -318,7 +318,7 @@ TEST(SmartPointer, ConvertingRegisterCount) Derived1Pointer d1ptr = Derived1::New(); EXPECT_EQ(1, d1ptr->GetRegisterCount()); - BasePointer bptr(std::move(d1ptr)); + const BasePointer bptr(std::move(d1ptr)); EXPECT_EQ(1, static_cast(bptr.GetPointer())->GetRegisterCount()); EXPECT_TRUE(d1ptr.IsNull()); } diff --git a/Modules/Core/Common/test/itkSmartPointerTest.cxx b/Modules/Core/Common/test/itkSmartPointerTest.cxx index b729378cce3..f98e64f7ec4 100644 --- a/Modules/Core/Common/test/itkSmartPointerTest.cxx +++ b/Modules/Core/Common/test/itkSmartPointerTest.cxx @@ -107,9 +107,9 @@ int itkSmartPointerTest(int, char *[]) { // Create a base class pointer to a child class - itkTestObject::Pointer to(itkTestObjectSubClass::New()); + const itkTestObject::Pointer to(itkTestObjectSubClass::New()); // test the safe down cast and create a child class Pointer object - itkTestObjectSubClass::Pointer sc = dynamic_cast(to.GetPointer()); + const itkTestObjectSubClass::Pointer sc = dynamic_cast(to.GetPointer()); // Test the up cast with a function that takes a pointer TestUpCast(sc); // Test calling a function that takes a SmartPointer as diff --git a/Modules/Core/Common/test/itkSobelOperatorImageConvolutionTest.cxx b/Modules/Core/Common/test/itkSobelOperatorImageConvolutionTest.cxx index b4674aa033c..119048cb4ec 100644 --- a/Modules/Core/Common/test/itkSobelOperatorImageConvolutionTest.cxx +++ b/Modules/Core/Common/test/itkSobelOperatorImageConvolutionTest.cxx @@ -32,9 +32,9 @@ MakeOnes3x3Image() { typename ImageType::Pointer onesImage = ImageType::New(); { - typename ImageType::SizeType smallest_size{ { 3, 3 } }; - typename ImageType::IndexType start_index{ { 0, 0 } }; - typename ImageType::RegionType my_region(start_index, smallest_size); + const typename ImageType::SizeType smallest_size{ { 3, 3 } }; + const typename ImageType::IndexType start_index{ { 0, 0 } }; + const typename ImageType::RegionType my_region(start_index, smallest_size); onesImage->SetRegions(my_region); } onesImage->Allocate(); @@ -67,8 +67,8 @@ DoConvolution(typename ImageType::Pointer inputImage, unsigned long int directio outputImage->SetRegions(inputImage->GetRequestedRegion()); outputImage->AllocateInitialized(); - IteratorType out(outputImage, inputImage->GetRequestedRegion()); - itk::NeighborhoodInnerProduct innerProduct; + IteratorType out(outputImage, inputImage->GetRequestedRegion()); + const itk::NeighborhoodInnerProduct innerProduct; for (it.GoToBegin(), out.GoToBegin(); !it.IsAtEnd(); ++it, ++out) { const auto pixelValue = innerProduct(it, sobelOperator); @@ -83,11 +83,11 @@ DoSimpleConvolutionTest(unsigned long direction, const std::string & pixelType) { using ImageType = typename itk::Image; - typename ImageType::Pointer smallestOnesImage = MakeOnes3x3Image(); - typename ImageType::Pointer output3x3Image = DoConvolution(smallestOnesImage, direction); + const typename ImageType::Pointer smallestOnesImage = MakeOnes3x3Image(); + const typename ImageType::Pointer output3x3Image = DoConvolution(smallestOnesImage, direction); - typename ImageType::IndexType center_index{ { 1, 1 } }; - typename ImageType::PixelType center_value = output3x3Image->GetPixel(center_index); + const typename ImageType::IndexType center_index{ { 1, 1 } }; + const typename ImageType::PixelType center_value = output3x3Image->GetPixel(center_index); if (center_value != 0) { std::cout << "ERROR: Constant image convolution with SobelOperator should return 0, " @@ -152,7 +152,7 @@ itkSobelOperatorImageConvolutionTest(int argc, char * argv[]) // to be stored in uint8_t have an implied 0 at about pixel value 128. Many web based viewers // for the difference images in the testing outputs render better in this positive png range. using RescaleIntensityType = itk::RescaleIntensityImageFilter; - RescaleIntensityType::Pointer rescalerForVisualization = RescaleIntensityType::New(); + const RescaleIntensityType::Pointer rescalerForVisualization = RescaleIntensityType::New(); rescalerForVisualization->SetInput(signedSobelImage); rescalerForVisualization->SetOutputMinimum(0); rescalerForVisualization->SetOutputMaximum(255); diff --git a/Modules/Core/Common/test/itkSobelOperatorImageFilterTest.cxx b/Modules/Core/Common/test/itkSobelOperatorImageFilterTest.cxx index e5c3066c365..12ea327c791 100644 --- a/Modules/Core/Common/test/itkSobelOperatorImageFilterTest.cxx +++ b/Modules/Core/Common/test/itkSobelOperatorImageFilterTest.cxx @@ -66,7 +66,7 @@ itkSobelOperatorImageFilterTest(int argc, char * argv[]) // to be stored in uint8_t have an implied 0 at about pixel value 128. Many web based viewers // for the difference images in the testing outputs render better in this positive png range. using RescaleIntensityType = itk::RescaleIntensityImageFilter; - RescaleIntensityType::Pointer rescalerForVisualization = RescaleIntensityType::New(); + const RescaleIntensityType::Pointer rescalerForVisualization = RescaleIntensityType::New(); rescalerForVisualization->SetInput(filter->GetOutput()); rescalerForVisualization->SetOutputMinimum(0); rescalerForVisualization->SetOutputMaximum(255); diff --git a/Modules/Core/Common/test/itkSobelOperatorTest.cxx b/Modules/Core/Common/test/itkSobelOperatorTest.cxx index 88b5fdd9e41..66eddff878c 100644 --- a/Modules/Core/Common/test/itkSobelOperatorTest.cxx +++ b/Modules/Core/Common/test/itkSobelOperatorTest.cxx @@ -136,7 +136,7 @@ itkSobelOperatorTest(int, char *[]) using SobelOperatorType = itk::SobelOperator; SobelOperatorType sobelOperator; - unsigned long direction = 0; + const unsigned long direction = 0; sobelOperator.SetDirection(direction); auto radius = itk::Size::Filled(1); ITK_TRY_EXPECT_EXCEPTION(sobelOperator.CreateToRadius(radius)); diff --git a/Modules/Core/Common/test/itkSparseFieldLayerTest.cxx b/Modules/Core/Common/test/itkSparseFieldLayerTest.cxx index 4b4d9e7b4ef..6cc938a0625 100644 --- a/Modules/Core/Common/test/itkSparseFieldLayerTest.cxx +++ b/Modules/Core/Common/test/itkSparseFieldLayerTest.cxx @@ -33,7 +33,7 @@ itkSparseFieldLayerTest(int, char *[]) { auto * store = new node_type[4000]; - itk::SparseFieldLayer::Pointer layer = itk::SparseFieldLayer::New(); + const itk::SparseFieldLayer::Pointer layer = itk::SparseFieldLayer::New(); for (unsigned int j = 0; j < 2; ++j) { diff --git a/Modules/Core/Common/test/itkSparseImageTest.cxx b/Modules/Core/Common/test/itkSparseImageTest.cxx index dfcd29acadf..b86f19b89d0 100644 --- a/Modules/Core/Common/test/itkSparseImageTest.cxx +++ b/Modules/Core/Common/test/itkSparseImageTest.cxx @@ -46,10 +46,10 @@ itkSparseImageTest(int, char *[]) using SparseImageType = itk::SparseImage; using ImageType = SparseImageType::Superclass; - auto im = SparseImageType::New(); - ImageType::RegionType r; - ImageType::SizeType sz = { { 24, 24 } }; - ImageType::IndexType idx = { { 0, 0 } }; + auto im = SparseImageType::New(); + ImageType::RegionType r; + const ImageType::SizeType sz = { { 24, 24 } }; + const ImageType::IndexType idx = { { 0, 0 } }; r.SetSize(sz); r.SetIndex(idx); diff --git a/Modules/Core/Common/test/itkSpatialFunctionTest.cxx b/Modules/Core/Common/test/itkSpatialFunctionTest.cxx index 7964556c559..83afdd2fede 100644 --- a/Modules/Core/Common/test/itkSpatialFunctionTest.cxx +++ b/Modules/Core/Common/test/itkSpatialFunctionTest.cxx @@ -52,7 +52,7 @@ itkSpatialFunctionTest(int, char *[]) //----------------Test evaluation of function------------------ // We're going to evaluate it at the center of the sphere (10,10,10) - bool funcVal = spatialFunc->Evaluate(center); + const bool funcVal = spatialFunc->Evaluate(center); printf("Sphere function value is %i\n", funcVal); // The function should have returned a value of 1, since the center is inside diff --git a/Modules/Core/Common/test/itkSpatialOrientationAdaptorGTest.cxx b/Modules/Core/Common/test/itkSpatialOrientationAdaptorGTest.cxx index 3d519a71053..d2fe5a27bf2 100644 --- a/Modules/Core/Common/test/itkSpatialOrientationAdaptorGTest.cxx +++ b/Modules/Core/Common/test/itkSpatialOrientationAdaptorGTest.cxx @@ -37,7 +37,7 @@ TEST(SpatialOrientationAdaptor, test1) const itk::SpacePrecisionType data[] = { 0.5986634407395047, 0.22716302314740483, -0.768113953548866, 0.5627936241740271, 0.563067040943212, 0.6051601804419384, 0.5699696670095713, -0.794576911518317, 0.20924175102261847 }; - DirectionType d2{ DirectionType::InternalMatrixType{ data } }; + const DirectionType d2{ DirectionType::InternalMatrixType{ data } }; EXPECT_EQ(itk::SpatialOrientationEnums::ValidCoordinateOrientations::ITK_COORDINATE_ORIENTATION_ASL, adapter.FromDirectionCosines(d2)); } diff --git a/Modules/Core/Common/test/itkStdStreamLogOutputTest.cxx b/Modules/Core/Common/test/itkStdStreamLogOutputTest.cxx index af007ff71dd..65ad1cb535e 100644 --- a/Modules/Core/Common/test/itkStdStreamLogOutputTest.cxx +++ b/Modules/Core/Common/test/itkStdStreamLogOutputTest.cxx @@ -28,7 +28,7 @@ itkStdStreamLogOutputTest(int argc, char * argv[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope // scope. - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); try { @@ -40,7 +40,7 @@ itkStdStreamLogOutputTest(int argc, char * argv[]) } // Create an ITK StdStreamLogOutput - itk::StdStreamLogOutput::Pointer output = itk::StdStreamLogOutput::New(); + const itk::StdStreamLogOutput::Pointer output = itk::StdStreamLogOutput::New(); std::cout << "Testing itk::StdStreamLogOutput" << std::endl; diff --git a/Modules/Core/Common/test/itkStdStreamStateSaveTest.cxx b/Modules/Core/Common/test/itkStdStreamStateSaveTest.cxx index cb99beeabb1..45864ee08ed 100644 --- a/Modules/Core/Common/test/itkStdStreamStateSaveTest.cxx +++ b/Modules/Core/Common/test/itkStdStreamStateSaveTest.cxx @@ -29,27 +29,27 @@ itkStdStreamStateSaveTest(int, char *[]) std::cout.fill(' '); // Get the state for each format state variable for std::cout - std::streamsize defaultPrecision = std::cout.precision(); - std::streamsize defaultWidth = std::cout.width(); - const char defaultFill = std::cout.fill(); - std::ios_base::fmtflags defaultFlags = std::cout.flags(); + const std::streamsize defaultPrecision = std::cout.precision(); + const std::streamsize defaultWidth = std::cout.width(); + const char defaultFill = std::cout.fill(); + const std::ios_base::fmtflags defaultFlags = std::cout.flags(); { - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); // Change some representative state variables std::cout.precision(14); std::cout.width(25); - int anInt = 123; + const int anInt = 123; std::cout.fill('%'); std::cout << std::left << anInt << std::endl; std::cout << std::showpos << anInt << std::endl; std::cout << std::hex << anInt << std::endl; std::cout << std::showbase << std::hex << anInt << std::endl; - bool aBool = false; + const bool aBool = false; std::cout << aBool << std::endl; std::cout << std::boolalpha << aBool << std::endl; - double aDouble = 123.e-5; + const double aDouble = 123.e-5; std::cout << aDouble << std::endl; std::cout << std::scientific << aDouble << std::endl; @@ -59,23 +59,23 @@ itkStdStreamStateSaveTest(int, char *[]) // Set the fillch of std::stringstream with an explicit default fill character stream.fill(' '); - int originalInt = 10; + const int originalInt = 10; { - itk::StdStreamStateSave sstreamState(stream); + const itk::StdStreamStateSave sstreamState(stream); // Change some representative state variables stream.precision(14); stream.width(25); - int anInt = originalInt; + const int anInt = originalInt; stream.fill('%'); stream << std::left << anInt << std::endl; stream << std::showpos << anInt << std::endl; stream << std::hex << anInt << std::endl; stream << std::showbase << std::hex << anInt << std::endl; - bool aBool = false; + const bool aBool = false; stream << aBool << std::endl; stream << std::boolalpha << aBool << std::endl; - double aDouble = 123.e-5; + const double aDouble = 123.e-5; stream << aDouble << std::endl; stream << std::scientific << aDouble << std::endl; diff --git a/Modules/Core/Common/test/itkStreamingImageFilterTest.cxx b/Modules/Core/Common/test/itkStreamingImageFilterTest.cxx index 0cf9553b375..ca4e1edac51 100644 --- a/Modules/Core/Common/test/itkStreamingImageFilterTest.cxx +++ b/Modules/Core/Common/test/itkStreamingImageFilterTest.cxx @@ -34,9 +34,9 @@ itkStreamingImageFilterTest(int, char *[]) auto if2 = ShortImage::New(); // fill in an image - ShortImage::IndexType index = { { 0, 0 } }; - ShortImage::SizeType size = { { 80, 122 } }; - ShortImage::RegionType region{ index, size }; + const ShortImage::IndexType index = { { 0, 0 } }; + const ShortImage::SizeType size = { { 80, 122 } }; + const ShortImage::RegionType region{ index, size }; if2->SetLargestPossibleRegion(region); if2->SetBufferedRegion(region); if2->Allocate(); @@ -131,7 +131,7 @@ itkStreamingImageFilterTest(int, char *[]) short row = (shrink->GetShrinkFactors()[1] * iterator2.GetIndex()[1] + (shrink->GetShrinkFactors()[1] - 1) / 2); row += rowOffset; - short trueValue = col + region.GetSize()[0] * row; + const short trueValue = col + region.GetSize()[0] * row; if (iterator2.Get() != trueValue) { diff --git a/Modules/Core/Common/test/itkStreamingImageFilterTest2.cxx b/Modules/Core/Common/test/itkStreamingImageFilterTest2.cxx index db7242d74b9..6be7d8446e5 100644 --- a/Modules/Core/Common/test/itkStreamingImageFilterTest2.cxx +++ b/Modules/Core/Common/test/itkStreamingImageFilterTest2.cxx @@ -28,8 +28,8 @@ int itkStreamingImageFilterTest2(int, char *[]) { - constexpr unsigned int numberOfStreamDivisions = 25; - itk::XMLFileOutputWindow::Pointer logger = itk::XMLFileOutputWindow::New(); + constexpr unsigned int numberOfStreamDivisions = 25; + const itk::XMLFileOutputWindow::Pointer logger = itk::XMLFileOutputWindow::New(); logger->SetInstance(logger); // type alias to simplify the syntax @@ -39,9 +39,9 @@ itkStreamingImageFilterTest2(int, char *[]) auto if2 = ShortImage::New(); // fill in an image - ShortImage::IndexType index = { { 0, 0 } }; - ShortImage::SizeType size = { { 42, 64 } }; - ShortImage::RegionType region{ index, size }; + const ShortImage::IndexType index = { { 0, 0 } }; + const ShortImage::SizeType size = { { 42, 64 } }; + const ShortImage::RegionType region{ index, size }; if2->SetLargestPossibleRegion(region); if2->SetBufferedRegion(region); if2->Allocate(); @@ -130,7 +130,7 @@ itkStreamingImageFilterTest2(int, char *[]) auto row = itk::Math::RoundHalfIntegerUp(static_cast( shrink->GetShrinkFactors()[1] * iterator2.GetIndex()[1] + (shrink->GetShrinkFactors()[1]) / 2.0)); row += rowOffset; - short trueValue = col + region.GetSize()[0] * row; + const short trueValue = col + region.GetSize()[0] * row; if (iterator2.Get() != trueValue) { diff --git a/Modules/Core/Common/test/itkStreamingImageFilterTest3.cxx b/Modules/Core/Common/test/itkStreamingImageFilterTest3.cxx index caa923a141a..5f821ca4612 100644 --- a/Modules/Core/Common/test/itkStreamingImageFilterTest3.cxx +++ b/Modules/Core/Common/test/itkStreamingImageFilterTest3.cxx @@ -37,9 +37,9 @@ itkStreamingImageFilterTest3(int argc, char * argv[]) return EXIT_FAILURE; } - const std::string inputFilename = argv[1]; - const std::string outputFilename = argv[2]; - unsigned int numberOfStreamDivisions = std::stoi(argv[3]); + const std::string inputFilename = argv[1]; + const std::string outputFilename = argv[2]; + const unsigned int numberOfStreamDivisions = std::stoi(argv[3]); using PixelType = unsigned char; using ImageType = itk::Image; @@ -68,7 +68,7 @@ itkStreamingImageFilterTest3(int argc, char * argv[]) itk::WriteImage(streamer->GetOutput(), outputFilename); - unsigned int expectedNumberOfStreams = + const unsigned int expectedNumberOfStreams = splitter->GetNumberOfSplits(streamer->GetOutput()->GetLargestPossibleRegion(), numberOfStreamDivisions); std::cout << "ExpectedNumberOfStreams: " << expectedNumberOfStreams << std::endl; diff --git a/Modules/Core/Common/test/itkSymmetricEigenAnalysisTest.cxx b/Modules/Core/Common/test/itkSymmetricEigenAnalysisTest.cxx index 106f60ffe55..e70970bca5a 100644 --- a/Modules/Core/Common/test/itkSymmetricEigenAnalysisTest.cxx +++ b/Modules/Core/Common/test/itkSymmetricEigenAnalysisTest.cxx @@ -45,9 +45,9 @@ itkSymmetricEigenAnalysisTest(int argc, char * argv[]) if (argc == 2) { - std::string inputSelectWhatToTest = argv[1]; - std::string optionEigen = "onlyEigen"; - std::string optionLegacy = "onlyLegacy"; + const std::string inputSelectWhatToTest = argv[1]; + const std::string optionEigen = "onlyEigen"; + const std::string optionLegacy = "onlyLegacy"; if (inputSelectWhatToTest == optionEigen) { testUseEigenLibraryIndices[0] = 1; @@ -82,7 +82,7 @@ itkSymmetricEigenAnalysisTest(int argc, char * argv[]) -2.4446, 3.6702, -0.2282, -1.6045, 3.9419, 2.5821, 20.2380, -0.2282, 28.6779, 3.9419, 2.5821, 44.0636, }; - InputMatrixType S(Sdata, 6, 6); + const InputMatrixType S(Sdata, 6, 6); EigenValuesArrayType eigenvalues; EigenVectorMatrixType eigenvectors; SymmetricEigenAnalysisType symmetricEigenSystem(6); @@ -99,10 +99,10 @@ itkSymmetricEigenAnalysisTest(int argc, char * argv[]) std::cout << "EigenVectors (each row is an an eigen vector): " << std::endl; std::cout << eigenvectors << std::endl; - double eigvec3[6] = { 0.5236407, -0.0013422, -0.4199706, -0.5942299, 0.4381326, 0.0659837 }; - double eigvals[6] = { 0.170864, 2.16934, 3.79272, 15.435, 24.6083, 78.2994 }; + const double eigvec3[6] = { 0.5236407, -0.0013422, -0.4199706, -0.5942299, 0.4381326, 0.0659837 }; + const double eigvals[6] = { 0.170864, 2.16934, 3.79272, 15.435, 24.6083, 78.2994 }; - double tolerance = 0.01; + const double tolerance = 0.01; for (unsigned int i = 0; i < 6; ++i) { if (itk::Math::abs(eigvals[i] - eigenvalues[i]) > tolerance) @@ -130,7 +130,7 @@ itkSymmetricEigenAnalysisTest(int argc, char * argv[]) using SymmetricEigenAnalysisType = itk::SymmetricEigenAnalysis; - double Sdata[36] = { + const double Sdata[36] = { 30.0000, -3.4273, 13.9254, 13.7049, -2.4446, 20.2380, -3.4273, 13.7049, -2.4446, 1.3659, 3.6702, -0.2282, 13.9254, -2.4446, 20.2380, 3.6702, -0.2282, 28.6779, 13.7049, 1.3659, 3.6702, 12.5273, -1.6045, 3.9419, -2.4446, 3.6702, -0.2282, -1.6045, 3.9419, 2.5821, 20.2380, -0.2282, 28.6779, 3.9419, 2.5821, 44.0636, @@ -162,10 +162,10 @@ itkSymmetricEigenAnalysisTest(int argc, char * argv[]) std::cout << "EigenVectors (each row is an an eigen vector): " << std::endl; std::cout << eigenvectors << std::endl; - double eigvec3[6] = { 0.5236407, -0.0013422, -0.4199706, -0.5942299, 0.4381326, 0.0659837 }; - double eigvals[6] = { 0.170864, 2.16934, 3.79272, 15.435, 24.6083, 78.2994 }; + const double eigvec3[6] = { 0.5236407, -0.0013422, -0.4199706, -0.5942299, 0.4381326, 0.0659837 }; + const double eigvals[6] = { 0.170864, 2.16934, 3.79272, 15.435, 24.6083, 78.2994 }; - double tolerance = 0.01; + const double tolerance = 0.01; for (unsigned int i = 0; i < 6; ++i) { if (itk::Math::abs(eigvals[i] - eigenvalues[i]) > tolerance) @@ -193,7 +193,7 @@ itkSymmetricEigenAnalysisTest(int argc, char * argv[]) using SymmetricEigenAnalysisType = itk::SymmetricEigenAnalysisFixedDimension<6, InputMatrixType, EigenValuesArrayType, EigenVectorMatrixType>; - double Sdata[36] = { + const double Sdata[36] = { 30.0000, -3.4273, 13.9254, 13.7049, -2.4446, 20.2380, -3.4273, 13.7049, -2.4446, 1.3659, 3.6702, -0.2282, 13.9254, -2.4446, 20.2380, 3.6702, -0.2282, 28.6779, 13.7049, 1.3659, 3.6702, 12.5273, -1.6045, 3.9419, -2.4446, 3.6702, -0.2282, -1.6045, 3.9419, 2.5821, 20.2380, -0.2282, 28.6779, 3.9419, 2.5821, 44.0636, @@ -209,9 +209,9 @@ itkSymmetricEigenAnalysisTest(int argc, char * argv[]) } } - EigenValuesArrayType eigenvalues; - EigenVectorMatrixType eigenvectors; - SymmetricEigenAnalysisType symmetricEigenSystem; + EigenValuesArrayType eigenvalues; + EigenVectorMatrixType eigenvectors; + const SymmetricEigenAnalysisType symmetricEigenSystem; std::cout << "UseEigenLibrary with FixedDimension " << std::endl; symmetricEigenSystem.ComputeEigenValuesAndVectors(S, eigenvalues, eigenvectors); @@ -219,10 +219,10 @@ itkSymmetricEigenAnalysisTest(int argc, char * argv[]) std::cout << "EigenVectors (each row is an an eigen vector): " << std::endl; std::cout << eigenvectors << std::endl; - double eigvec3[6] = { 0.5236407, -0.0013422, -0.4199706, -0.5942299, 0.4381326, 0.0659837 }; - double eigvals[6] = { 0.170864, 2.16934, 3.79272, 15.435, 24.6083, 78.2994 }; + const double eigvec3[6] = { 0.5236407, -0.0013422, -0.4199706, -0.5942299, 0.4381326, 0.0659837 }; + const double eigvals[6] = { 0.170864, 2.16934, 3.79272, 15.435, 24.6083, 78.2994 }; - double tolerance = 0.01; + const double tolerance = 0.01; for (unsigned int i = 0; i < 6; ++i) { if (itk::Math::abs(eigvals[i] - eigenvalues[i]) > tolerance) @@ -251,7 +251,7 @@ itkSymmetricEigenAnalysisTest(int argc, char * argv[]) using SymmetricEigenAnalysisType = itk::SymmetricEigenAnalysis; - double Sdata[36] = { + const double Sdata[36] = { 30.0000, -3.4273, 13.9254, 13.7049, -2.4446, 20.2380, -3.4273, 13.7049, -2.4446, 1.3659, 3.6702, -0.2282, 13.9254, -2.4446, 20.2380, 3.6702, -0.2282, 28.6779, 13.7049, 1.3659, 3.6702, 12.5273, -1.6045, 3.9419, -2.4446, 3.6702, -0.2282, -1.6045, 3.9419, 2.5821, 20.2380, -0.2282, 28.6779, 3.9419, 2.5821, 44.0636, @@ -282,10 +282,10 @@ itkSymmetricEigenAnalysisTest(int argc, char * argv[]) std::cout << "EigenVectors (each row is an an eigen vector): " << std::endl; std::cout << eigenvectors << std::endl; - double eigvec3[6] = { 0.5236407, -0.0013422, -0.4199706, -0.5942299, 0.4381326, 0.0659837 }; - double eigvals[6] = { 0.170864, 2.16934, 3.79272, 15.435, 24.6083, 78.2994 }; + const double eigvec3[6] = { 0.5236407, -0.0013422, -0.4199706, -0.5942299, 0.4381326, 0.0659837 }; + const double eigvals[6] = { 0.170864, 2.16934, 3.79272, 15.435, 24.6083, 78.2994 }; - double tolerance = 0.01; + const double tolerance = 0.01; for (unsigned int i = 0; i < 6; ++i) { if (itk::Math::abs(eigvals[i] - eigenvalues[i]) > tolerance) @@ -313,7 +313,7 @@ itkSymmetricEigenAnalysisTest(int argc, char * argv[]) using SymmetricEigenAnalysisType = itk::SymmetricEigenAnalysis; - double Sdata[9] = { + const double Sdata[9] = { -3.0, 0.0, 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, -1.0, }; @@ -343,10 +343,10 @@ itkSymmetricEigenAnalysisTest(int argc, char * argv[]) std::cout << "EigenVectors (each row is an an eigen vector): " << std::endl; std::cout << eigenvectors << std::endl; - double eigvec3[3] = { 0.0, 1.0, 0.0 }; - double eigvals[3] = { -1.0, -3.0, 5.0 }; + const double eigvec3[3] = { 0.0, 1.0, 0.0 }; + const double eigvals[3] = { -1.0, -3.0, 5.0 }; - double tolerance = 0.01; + const double tolerance = 0.01; for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::abs(eigvals[i] - eigenvalues[i]) > tolerance) @@ -375,8 +375,8 @@ itkSymmetricEigenAnalysisTest(int argc, char * argv[]) using SymmetricEigenAnalysisType = itk::SymmetricEigenAnalysis; - float Sdata[9] = { -7.31129000e+00f, 2.33080000e+01f, 0.00000000e+00f, 2.33080000e+01f, -4.64210000e-01f, - 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, -3.26256000e-06f }; + const float Sdata[9] = { -7.31129000e+00f, 2.33080000e+01f, 0.00000000e+00f, 2.33080000e+01f, -4.64210000e-01f, + 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, -3.26256000e-06f }; InputMatrixType S; @@ -404,10 +404,10 @@ itkSymmetricEigenAnalysisTest(int argc, char * argv[]) std::cout << "EigenVectors (each row is an an eigen vector): " << std::endl; std::cout << eigenvectors << std::endl; - float eigvec2[3] = { 0.75674412f, -0.6537112f, 0.0f }; - float eigvals[3] = { -3.26256000e-06f, 1.96703376e+01f, -2.74458376e+01f }; + const float eigvec2[3] = { 0.75674412f, -0.6537112f, 0.0f }; + const float eigvals[3] = { -3.26256000e-06f, 1.96703376e+01f, -2.74458376e+01f }; - float tolerance = 0.01; + const float tolerance = 0.01; for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::abs(eigvals[i] - eigenvalues[i]) > tolerance) diff --git a/Modules/Core/Common/test/itkSymmetricEllipsoidInteriorExteriorSpatialFunctionTest.cxx b/Modules/Core/Common/test/itkSymmetricEllipsoidInteriorExteriorSpatialFunctionTest.cxx index 62b2aeace6b..14b3e416d96 100644 --- a/Modules/Core/Common/test/itkSymmetricEllipsoidInteriorExteriorSpatialFunctionTest.cxx +++ b/Modules/Core/Common/test/itkSymmetricEllipsoidInteriorExteriorSpatialFunctionTest.cxx @@ -36,9 +36,9 @@ itkSymmetricEllipsoidInteriorExteriorSpatialFunctionTest(int, char *[]) auto spatialFunc = TSymEllipsoidFunctionType::New(); // Define function doitkSymmetricEllipsoidInteriorExteriorSpatialFunctionTest, which encapsulates ellipsoid. - int xExtent = 50; - int yExtent = 50; - int zExtent = 50; + const int xExtent = 50; + const int yExtent = 50; + const int zExtent = 50; // Define and set the center of the ellipsoid in the center of // the function doitkSymmetricEllipsoidInteriorExteriorSpatialFunctionTest @@ -55,8 +55,8 @@ itkSymmetricEllipsoidInteriorExteriorSpatialFunctionTest(int, char *[]) orientation[1] = 1 / std::sqrt(2.0); orientation[2] = 0; - double uniqueAxisLength = 45; - double symmetricAxesLength = 30; + const double uniqueAxisLength = 45; + const double symmetricAxesLength = 30; spatialFunc->SetOrientation(orientation, uniqueAxisLength, symmetricAxesLength); @@ -94,10 +94,10 @@ itkSymmetricEllipsoidInteriorExteriorSpatialFunctionTest(int, char *[]) functionValue = spatialFunc->Evaluate(testPosition); // Volume of ellipsoid using V=(4/3)*pi*(a/2)*(b/2)*(c/2) - double volume = 4.18879013333 * (uniqueAxisLength / 2) * (symmetricAxesLength / 2) * (symmetricAxesLength / 2); + const double volume = 4.18879013333 * (uniqueAxisLength / 2) * (symmetricAxesLength / 2) * (symmetricAxesLength / 2); // Percent difference in volume measurement and calculation - double volumeError = (itk::Math::abs(volume - interiorPixelCounter) / volume) * 100; + const double volumeError = (itk::Math::abs(volume - interiorPixelCounter) / volume) * 100; // 5% error was randomly chosen as a successful ellipsoid fill. // This should actually be some function of the image/ellipsoid size. diff --git a/Modules/Core/Common/test/itkSymmetricSecondRankTensorImageReadTest.cxx b/Modules/Core/Common/test/itkSymmetricSecondRankTensorImageReadTest.cxx index f5809ade3f1..aa80c5722f4 100644 --- a/Modules/Core/Common/test/itkSymmetricSecondRankTensorImageReadTest.cxx +++ b/Modules/Core/Common/test/itkSymmetricSecondRankTensorImageReadTest.cxx @@ -41,9 +41,9 @@ itkSymmetricSecondRankTensorImageReadTest(int argc, char * argv[]) auto size = MatrixImageType::SizeType::Filled(10); - MatrixImageType::IndexType start{}; + const MatrixImageType::IndexType start{}; - MatrixImageType::RegionType region{ start, size }; + const MatrixImageType::RegionType region{ start, size }; matrixImage->SetRegions(region); matrixImage->Allocate(); diff --git a/Modules/Core/Common/test/itkSymmetricSecondRankTensorImageWriteReadTest.cxx b/Modules/Core/Common/test/itkSymmetricSecondRankTensorImageWriteReadTest.cxx index fb2f21df5cb..34ce0b141ea 100644 --- a/Modules/Core/Common/test/itkSymmetricSecondRankTensorImageWriteReadTest.cxx +++ b/Modules/Core/Common/test/itkSymmetricSecondRankTensorImageWriteReadTest.cxx @@ -39,9 +39,9 @@ itkSymmetricSecondRankTensorImageWriteReadTest(int argc, char * argv[]) auto size = TensorImageType::SizeType::Filled(10); - TensorImageType::IndexType start{}; + const TensorImageType::IndexType start{}; - TensorImageType::RegionType region{ start, size }; + const TensorImageType::RegionType region{ start, size }; tensorImageInput->SetRegions(region); tensorImageInput->Allocate(); diff --git a/Modules/Core/Common/test/itkSymmetricSecondRankTensorTest.cxx b/Modules/Core/Common/test/itkSymmetricSecondRankTensorTest.cxx index cba52c5efc8..008e399d57d 100644 --- a/Modules/Core/Common/test/itkSymmetricSecondRankTensorTest.cxx +++ b/Modules/Core/Common/test/itkSymmetricSecondRankTensorTest.cxx @@ -396,7 +396,7 @@ itkSymmetricSecondRankTensorTest(int, char *[]) const double tolerance = 1e-4; - AccumulateValueType computedTrace = tensor3D.GetTrace(); + const AccumulateValueType computedTrace = tensor3D.GetTrace(); if (itk::Math::abs(computedTrace - expectedTrace) > tolerance) { std::cerr << "Error computing the Trace" << std::endl; @@ -489,7 +489,7 @@ itkSymmetricSecondRankTensorTest(int, char *[]) Float3DTensorType floatTensor3 = static_cast(intTensor); // Check that all floatTensors have are the same - float precision = 1e-6; + const float precision = 1e-6; for (unsigned int i = 0; i < Float3DTensorType::InternalDimension; ++i) { auto intVal = static_cast(intTensor[i]); diff --git a/Modules/Core/Common/test/itkThreadLoggerTest.cxx b/Modules/Core/Common/test/itkThreadLoggerTest.cxx index 97f98f1d2df..5fe4ab6c92d 100644 --- a/Modules/Core/Common/test/itkThreadLoggerTest.cxx +++ b/Modules/Core/Common/test/itkThreadLoggerTest.cxx @@ -104,14 +104,14 @@ itkThreadLoggerTest(int argc, char * argv[]) } // Create an ITK StdStreamLogOutputs - itk::StdStreamLogOutput::Pointer coutput = itk::StdStreamLogOutput::New(); - itk::StdStreamLogOutput::Pointer foutput = itk::StdStreamLogOutput::New(); + const itk::StdStreamLogOutput::Pointer coutput = itk::StdStreamLogOutput::New(); + const itk::StdStreamLogOutput::Pointer foutput = itk::StdStreamLogOutput::New(); coutput->SetStream(std::cout); std::ofstream fout(argv[1]); foutput->SetStream(fout); // Create an ITK ThreadLogger - itk::ThreadLogger::Pointer logger = itk::ThreadLogger::New(); + const itk::ThreadLogger::Pointer logger = itk::ThreadLogger::New(); std::cout << "Testing itk::ThreadLogger" << std::endl; @@ -156,8 +156,8 @@ itkThreadLoggerTest(int argc, char * argv[]) std::cout << " Flushing by the ThreadLogger is synchronized." << std::endl; std::cout << "Beginning multi-threaded portion of test." << std::endl; - ThreadDataVec threadData = create_threaded_data(numWorkUnits, logger); - itk::MultiThreaderBase::Pointer threader = itk::MultiThreaderBase::New(); + ThreadDataVec threadData = create_threaded_data(numWorkUnits, logger); + const itk::MultiThreaderBase::Pointer threader = itk::MultiThreaderBase::New(); itk::MultiThreaderBase::SetGlobalMaximumNumberOfThreads(numWorkUnits + 10); threader->SetNumberOfWorkUnits(numWorkUnits); threader->SetSingleMethod(ThreadedGenerateLogMessages, &threadData); diff --git a/Modules/Core/Common/test/itkThreadedImageRegionPartitionerTest.cxx b/Modules/Core/Common/test/itkThreadedImageRegionPartitionerTest.cxx index b3d851d1ecc..4ca65e51c22 100644 --- a/Modules/Core/Common/test/itkThreadedImageRegionPartitionerTest.cxx +++ b/Modules/Core/Common/test/itkThreadedImageRegionPartitionerTest.cxx @@ -27,7 +27,7 @@ itkThreadedImageRegionPartitionerTest(int, char *[]) constexpr unsigned int Dimension = 2; using ThreadedImageRegionPartitionerType = itk::ThreadedImageRegionPartitioner; - ThreadedImageRegionPartitionerType::Pointer threadedImageRegionPartitioner = + const ThreadedImageRegionPartitionerType::Pointer threadedImageRegionPartitioner = ThreadedImageRegionPartitionerType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS( @@ -43,7 +43,7 @@ itkThreadedImageRegionPartitionerTest(int, char *[]) auto index = itk::MakeFilled(4); - ImageRegionType completeRegion{ index, size }; + const ImageRegionType completeRegion{ index, size }; // Define the expected results ImageRegionType expectedRegion; diff --git a/Modules/Core/Common/test/itkThreadedIndexedContainerPartitionerTest.cxx b/Modules/Core/Common/test/itkThreadedIndexedContainerPartitionerTest.cxx index 1a5cb9afb51..6419d9016c2 100644 --- a/Modules/Core/Common/test/itkThreadedIndexedContainerPartitionerTest.cxx +++ b/Modules/Core/Common/test/itkThreadedIndexedContainerPartitionerTest.cxx @@ -116,7 +116,7 @@ ThreadedIndexedContainerPartitionerRunTest(DomainThreaderAssociate & enclosingCl std::cout << "Testing with " << numberOfThreads << " threads and complete domain " << fullRange << " ..." << std::endl; - DomainThreaderAssociate::TestDomainThreader::Pointer domainThreader = enclosingClass.GetDomainThreader(); + const DomainThreaderAssociate::TestDomainThreader::Pointer domainThreader = enclosingClass.GetDomainThreader(); // Exercise GetMultiThreader(). domainThreader->GetMultiThreader(); @@ -192,8 +192,8 @@ ThreadedIndexedContainerPartitionerRunTest(DomainThreaderAssociate & enclosingCl int itkThreadedIndexedContainerPartitionerTest(int, char *[]) { - DomainThreaderAssociate enclosingClass; - DomainThreaderAssociate::TestDomainThreader::ConstPointer domainThreader = enclosingClass.GetDomainThreader(); + DomainThreaderAssociate enclosingClass; + const DomainThreaderAssociate::TestDomainThreader::ConstPointer domainThreader = enclosingClass.GetDomainThreader(); /* Check # of threads */ std::cout << "GetGlobalMaximumNumberOfThreads: " @@ -238,7 +238,7 @@ itkThreadedIndexedContainerPartitionerTest(int, char *[]) /* Test with max number of threads and check that we only used as * many as is reasonable. */ - itk::ThreadIdType maxNumberOfThreads = domainThreader->GetMultiThreader()->GetGlobalMaximumNumberOfThreads(); + const itk::ThreadIdType maxNumberOfThreads = domainThreader->GetMultiThreader()->GetGlobalMaximumNumberOfThreads(); fullRange[0] = 6; fullRange[1] = fullRange[0] + maxNumberOfThreads - 2; if (ThreadedIndexedContainerPartitionerRunTest(enclosingClass, maxNumberOfThreads, fullRange) != EXIT_SUCCESS) diff --git a/Modules/Core/Common/test/itkThreadedIteratorRangePartitionerTest.cxx b/Modules/Core/Common/test/itkThreadedIteratorRangePartitionerTest.cxx index da7e43d4dd5..af708a791e3 100644 --- a/Modules/Core/Common/test/itkThreadedIteratorRangePartitionerTest.cxx +++ b/Modules/Core/Common/test/itkThreadedIteratorRangePartitionerTest.cxx @@ -60,7 +60,7 @@ class IteratorRangeDomainThreaderAssociate BeforeThreadedExecution() override { this->m_DomainInThreadedExecution.resize(this->GetNumberOfWorkUnitsUsed()); - BorderValuesType unsetBorderValues(2, -1); + const BorderValuesType unsetBorderValues(2, -1); for (auto & i : m_DomainInThreadedExecution) { i = unsetBorderValues; @@ -129,7 +129,8 @@ ThreadedIteratorRangePartitionerRunTest( { std::cout << "Testing with " << numberOfThreads << " threads." << std::endl; - IteratorRangeDomainThreaderAssociate::TestDomainThreader::Pointer domainThreader = enclosingClass.GetDomainThreader(); + const IteratorRangeDomainThreaderAssociate::TestDomainThreader::Pointer domainThreader = + enclosingClass.GetDomainThreader(); // Exercise GetMultiThreader(). domainThreader->GetMultiThreader(); @@ -230,7 +231,7 @@ setStartEnd(const unsigned int getIteratorFromIndex(start, container, beginIt); getIteratorFromIndex(end, container, endIt); - IteratorRangeDomainThreaderAssociate::TestDomainThreader::DomainType newDomain(beginIt, endIt); + const IteratorRangeDomainThreaderAssociate::TestDomainThreader::DomainType newDomain(beginIt, endIt); fullDomain = newDomain; } } // namespace @@ -238,8 +239,8 @@ setStartEnd(const unsigned int int itkThreadedIteratorRangePartitionerTest(int, char *[]) { - IteratorRangeDomainThreaderAssociate enclosingClass; - IteratorRangeDomainThreaderAssociate::TestDomainThreader::ConstPointer domainThreader = + IteratorRangeDomainThreaderAssociate enclosingClass; + const IteratorRangeDomainThreaderAssociate::TestDomainThreader::ConstPointer domainThreader = enclosingClass.GetDomainThreader(); /* Check # of threads */ @@ -287,7 +288,7 @@ itkThreadedIteratorRangePartitionerTest(int, char *[]) /* Test with max number of threads and check that we only used as * many as is reasonable. */ - itk::ThreadIdType maxNumberOfThreads = domainThreader->GetMultiThreader()->GetGlobalMaximumNumberOfThreads(); + const itk::ThreadIdType maxNumberOfThreads = domainThreader->GetMultiThreader()->GetGlobalMaximumNumberOfThreads(); setStartEnd(6, 6 + maxNumberOfThreads, container, fullDomain); if (ThreadedIteratorRangePartitionerRunTest(enclosingClass, maxNumberOfThreads, fullDomain) != EXIT_SUCCESS) { diff --git a/Modules/Core/Common/test/itkThreadedIteratorRangePartitionerTest2.cxx b/Modules/Core/Common/test/itkThreadedIteratorRangePartitionerTest2.cxx index e7d989df893..699afd4ff49 100644 --- a/Modules/Core/Common/test/itkThreadedIteratorRangePartitionerTest2.cxx +++ b/Modules/Core/Common/test/itkThreadedIteratorRangePartitionerTest2.cxx @@ -63,7 +63,7 @@ class IteratorRangeDomainThreaderAssociate BeforeThreadedExecution() override { this->m_DomainInThreadedExecution.resize(this->GetNumberOfWorkUnitsUsed()); - BorderValuesType unsetBorderValues(2, -1); + const BorderValuesType unsetBorderValues(2, -1); for (auto & i : m_DomainInThreadedExecution) { i = unsetBorderValues; @@ -133,7 +133,7 @@ ThreadedIteratorRangePartitionerRunTest( std::cout << "Testing with " << numberOfThreads << " threads." << std::endl; using TestDomainThreaderType = IteratorRangeDomainThreaderAssociate::TestDomainThreader; - TestDomainThreaderType::Pointer domainThreader = enclosingClass.GetDomainThreader(); + const TestDomainThreaderType::Pointer domainThreader = enclosingClass.GetDomainThreader(); // Exercise GetMultiThreader(). domainThreader->GetMultiThreader(); @@ -237,7 +237,7 @@ setStartEnd(const unsigned int getIteratorFromIndex(start, container, beginIt); getIteratorFromIndex(end, container, endIt); - IteratorRangeDomainThreaderAssociate::TestDomainThreader::DomainType newDomain(beginIt, endIt); + const IteratorRangeDomainThreaderAssociate::TestDomainThreader::DomainType newDomain(beginIt, endIt); fullDomain = newDomain; } } // namespace @@ -245,8 +245,8 @@ setStartEnd(const unsigned int int itkThreadedIteratorRangePartitionerTest2(int, char *[]) { - IteratorRangeDomainThreaderAssociate enclosingClass; - IteratorRangeDomainThreaderAssociate::TestDomainThreader::ConstPointer domainThreader = + IteratorRangeDomainThreaderAssociate enclosingClass; + const IteratorRangeDomainThreaderAssociate::TestDomainThreader::ConstPointer domainThreader = enclosingClass.GetDomainThreader(); if (domainThreader->GetMultiThreader()) @@ -305,7 +305,7 @@ itkThreadedIteratorRangePartitionerTest2(int, char *[]) /* Test with max number of threads and check that we only used as * many as is reasonable. */ - itk::ThreadIdType maxNumberOfThreads = domainThreader->GetMultiThreader()->GetGlobalMaximumNumberOfThreads(); + const itk::ThreadIdType maxNumberOfThreads = domainThreader->GetMultiThreader()->GetGlobalMaximumNumberOfThreads(); setStartEnd(6, 6 + maxNumberOfThreads, container, fullDomain); if (ThreadedIteratorRangePartitionerRunTest(enclosingClass, maxNumberOfThreads, fullDomain) != EXIT_SUCCESS) { diff --git a/Modules/Core/Common/test/itkThreadedIteratorRangePartitionerTest3.cxx b/Modules/Core/Common/test/itkThreadedIteratorRangePartitionerTest3.cxx index 7f1951f6dc3..4a871be2fec 100644 --- a/Modules/Core/Common/test/itkThreadedIteratorRangePartitionerTest3.cxx +++ b/Modules/Core/Common/test/itkThreadedIteratorRangePartitionerTest3.cxx @@ -63,7 +63,7 @@ class IteratorRangeDomainThreaderAssociate BeforeThreadedExecution() override { this->m_DomainInThreadedExecution.resize(this->GetNumberOfWorkUnitsUsed()); - BorderValuesType unsetBorderValues(2, -1); + const BorderValuesType unsetBorderValues(2, -1); for (auto & i : m_DomainInThreadedExecution) { i = unsetBorderValues; @@ -133,7 +133,7 @@ ThreadedIteratorRangePartitionerRunTest( std::cout << "Testing with " << numberOfThreads << " threads." << std::endl; using TestDomainThreaderType = IteratorRangeDomainThreaderAssociate::TestDomainThreader; - TestDomainThreaderType::Pointer domainThreader = enclosingClass.GetDomainThreader(); + const TestDomainThreaderType::Pointer domainThreader = enclosingClass.GetDomainThreader(); // Exercise GetMultiThreader(). domainThreader->GetMultiThreader(); @@ -237,7 +237,7 @@ setStartEnd(const unsigned int getIteratorFromIndex(start, container, beginIt); getIteratorFromIndex(end, container, endIt); - IteratorRangeDomainThreaderAssociate::TestDomainThreader::DomainType newDomain(beginIt, endIt); + const IteratorRangeDomainThreaderAssociate::TestDomainThreader::DomainType newDomain(beginIt, endIt); fullDomain = newDomain; } } // namespace @@ -245,8 +245,8 @@ setStartEnd(const unsigned int int itkThreadedIteratorRangePartitionerTest3(int, char *[]) { - IteratorRangeDomainThreaderAssociate enclosingClass; - IteratorRangeDomainThreaderAssociate::TestDomainThreader::ConstPointer domainThreader = + IteratorRangeDomainThreaderAssociate enclosingClass; + const IteratorRangeDomainThreaderAssociate::TestDomainThreader::ConstPointer domainThreader = enclosingClass.GetDomainThreader(); if (domainThreader->GetMultiThreader()) @@ -304,7 +304,7 @@ itkThreadedIteratorRangePartitionerTest3(int, char *[]) /* Test with max number of threads and check that we only used as * many as is reasonable. */ - itk::ThreadIdType maxNumberOfThreads = domainThreader->GetMultiThreader()->GetGlobalMaximumNumberOfThreads(); + const itk::ThreadIdType maxNumberOfThreads = domainThreader->GetMultiThreader()->GetGlobalMaximumNumberOfThreads(); setStartEnd(6, 6 + maxNumberOfThreads, container, fullDomain); if (ThreadedIteratorRangePartitionerRunTest(enclosingClass, maxNumberOfThreads, fullDomain) != EXIT_SUCCESS) { diff --git a/Modules/Core/Common/test/itkTimeProbeTest.cxx b/Modules/Core/Common/test/itkTimeProbeTest.cxx index 05ed9acbf5c..ebb6e1cbf08 100644 --- a/Modules/Core/Common/test/itkTimeProbeTest.cxx +++ b/Modules/Core/Common/test/itkTimeProbeTest.cxx @@ -82,7 +82,7 @@ itkTimeProbeTest(int, char *[]) } /** Invoke GetRealTimeClock. */ - itk::RealTimeStamp timeStamp = localTimer.GetRealTimeClock()->GetRealTimeStamp(); + const itk::RealTimeStamp timeStamp = localTimer.GetRealTimeClock()->GetRealTimeStamp(); std::cout << "TimeInDays: " << timeStamp.GetTimeInDays() << std::endl; std::cout << "TimeInHours: " << timeStamp.GetTimeInHours() << std::endl; std::cout << "TimeInMinutes: " << timeStamp.GetTimeInMinutes() << std::endl; @@ -91,7 +91,7 @@ itkTimeProbeTest(int, char *[]) std::cout << "TimeInMicroSeconds: " << timeStamp.GetTimeInMicroSeconds() << std::endl; // Exercise the Print method - itk::Indent indent{}; + const itk::Indent indent{}; localTimer.Print(std::cout, indent); diff --git a/Modules/Core/Common/test/itkTimeProbeTest2.cxx b/Modules/Core/Common/test/itkTimeProbeTest2.cxx index b99448d0b47..594524cfa2b 100644 --- a/Modules/Core/Common/test/itkTimeProbeTest2.cxx +++ b/Modules/Core/Common/test/itkTimeProbeTest2.cxx @@ -62,7 +62,7 @@ itkTimeProbeTest2(int, char *[]) std::cout << "Maximum: " << localTimer.GetMaximum() << std::endl; std::cout << "StandardDeviation: " << localTimer.GetStandardDeviation() << std::endl; - unsigned int iteration(100); + const unsigned int iteration(100); for (unsigned int it = 0; it < iteration; ++it) { @@ -126,7 +126,7 @@ itkTimeProbeTest2(int, char *[]) } /** Invoke GetRealTimeClock. */ - itk::RealTimeStamp timeStamp = localTimer.GetRealTimeClock()->GetRealTimeStamp(); + const itk::RealTimeStamp timeStamp = localTimer.GetRealTimeClock()->GetRealTimeStamp(); std::cout << std::endl << "Check RealTimeStamp" << std::endl; std::cout << "TimeInDays: " << timeStamp.GetTimeInDays() << std::endl; std::cout << "TimeInHours: " << timeStamp.GetTimeInHours() << std::endl; diff --git a/Modules/Core/Common/test/itkTimeProbesTest.cxx b/Modules/Core/Common/test/itkTimeProbesTest.cxx index b8fb99a7808..33b1716574a 100644 --- a/Modules/Core/Common/test/itkTimeProbesTest.cxx +++ b/Modules/Core/Common/test/itkTimeProbesTest.cxx @@ -130,8 +130,8 @@ itkTimeProbesTest(int, char *[]) using Region3DType = itk::ImageRegion<3>; using Size3DType = Region3DType::SizeType; - Region3DType region3D; - Size3DType size3D = { { 1000, 1000, 1000 } }; + Region3DType region3D; + const Size3DType size3D = { { 1000, 1000, 1000 } }; region3D.SetSize(size3D); collector.Start("i:TransformIndexToPhysicalPoint"); diff --git a/Modules/Core/Common/test/itkTimeStampTest.cxx b/Modules/Core/Common/test/itkTimeStampTest.cxx index cd2d80f7af6..ed0c8634cdd 100644 --- a/Modules/Core/Common/test/itkTimeStampTest.cxx +++ b/Modules/Core/Common/test/itkTimeStampTest.cxx @@ -64,7 +64,7 @@ itkTimeStampTest(int, char *[]) TimeStampTestHelper helper; // Set up the multithreader - itk::MultiThreaderBase::Pointer multithreader = itk::MultiThreaderBase::New(); + const itk::MultiThreaderBase::Pointer multithreader = itk::MultiThreaderBase::New(); multithreader->SetNumberOfWorkUnits(itk::ITK_MAX_THREADS + 10); // this will be clamped multithreader->SetSingleMethod(modified_function, &helper); diff --git a/Modules/Core/Common/test/itkTorusInteriorExteriorSpatialFunctionTest.cxx b/Modules/Core/Common/test/itkTorusInteriorExteriorSpatialFunctionTest.cxx index cfdf46e2660..321bdfe6bca 100644 --- a/Modules/Core/Common/test/itkTorusInteriorExteriorSpatialFunctionTest.cxx +++ b/Modules/Core/Common/test/itkTorusInteriorExteriorSpatialFunctionTest.cxx @@ -37,7 +37,7 @@ itkTorusInteriorExteriorSpatialFunctionTest(int, char *[]) using TorusInteriorExteriorSpatialFunctionType = itk::TorusInteriorExteriorSpatialFunction; // Create the torus spatial function - TorusInteriorExteriorSpatialFunctionType::Pointer torusInteriorExteriorSpatialFunction = + const TorusInteriorExteriorSpatialFunctionType::Pointer torusInteriorExteriorSpatialFunction = TorusInteriorExteriorSpatialFunctionType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS( @@ -49,11 +49,11 @@ itkTorusInteriorExteriorSpatialFunctionTest(int, char *[]) torusInteriorExteriorSpatialFunction->SetOrigin(origin); ITK_TEST_SET_GET_VALUE(origin, torusInteriorExteriorSpatialFunction->GetOrigin()); - double majorRadius = 10.0; + const double majorRadius = 10.0; torusInteriorExteriorSpatialFunction->SetMajorRadius(majorRadius); ITK_TEST_SET_GET_VALUE(majorRadius, torusInteriorExteriorSpatialFunction->GetMajorRadius()); - double minorRadius = 4.0; + const double minorRadius = 4.0; torusInteriorExteriorSpatialFunction->SetMinorRadius(minorRadius); ITK_TEST_SET_GET_VALUE(minorRadius, torusInteriorExteriorSpatialFunction->GetMinorRadius()); @@ -68,10 +68,10 @@ itkTorusInteriorExteriorSpatialFunctionTest(int, char *[]) outsidePoint[1] = 2.0; outsidePoint[2] = 1.0; - TorusInteriorExteriorSpatialFunctionType::OutputType insidePointOutputValue = + const TorusInteriorExteriorSpatialFunctionType::OutputType insidePointOutputValue = torusInteriorExteriorSpatialFunction->Evaluate(insidePoint); - TorusInteriorExteriorSpatialFunctionType::OutputType outsidePointOutputValue = + const TorusInteriorExteriorSpatialFunctionType::OutputType outsidePointOutputValue = torusInteriorExteriorSpatialFunction->Evaluate(outsidePoint); int testStatus = EXIT_SUCCESS; diff --git a/Modules/Core/Common/test/itkVNLRoundProfileTest1.cxx b/Modules/Core/Common/test/itkVNLRoundProfileTest1.cxx index 45bdf2d6577..5e811023db9 100644 --- a/Modules/Core/Common/test/itkVNLRoundProfileTest1.cxx +++ b/Modules/Core/Common/test/itkVNLRoundProfileTest1.cxx @@ -95,7 +95,7 @@ itkVNLRoundProfileTest1(int, char *[]) ArrayType::const_iterator outItr1src = output1.begin(); auto outItr2dst = output2.begin(); - ArrayType::const_iterator outEnd1 = output1.end(); + const ArrayType::const_iterator outEnd1 = output1.end(); chronometer.Start("std::vector"); @@ -198,8 +198,8 @@ itkVNLRoundProfileTest1(int, char *[]) // // Now test the correctness of the output // - ArrayType::const_iterator inpItr = input.begin(); - ArrayType::const_iterator inputEnd = input.end(); + ArrayType::const_iterator inpItr = input.begin(); + const ArrayType::const_iterator inputEnd = input.end(); ArrayType::const_iterator outItr1 = output1.begin(); ArrayType::const_iterator outItr2 = output2.begin(); diff --git a/Modules/Core/Common/test/itkVariableLengthVectorTest.cxx b/Modules/Core/Common/test/itkVariableLengthVectorTest.cxx index eaa1eaa6227..bba1808a8c0 100644 --- a/Modules/Core/Common/test/itkVariableLengthVectorTest.cxx +++ b/Modules/Core/Common/test/itkVariableLengthVectorTest.cxx @@ -71,7 +71,7 @@ itkVariableLengthVectorTest(int, char *[]) d[1] = 0.2; d[2] = 0.3; { - DoubleVariableLengthVectorType x(d, 3, false); + const DoubleVariableLengthVectorType x(d, 3, false); } { DoubleVariableLengthVectorType x(d, 3, false); @@ -398,12 +398,12 @@ itkVariableLengthVectorTest(int, char *[]) { // Testing empty vectors - FloatVariableLengthVectorType v1{}; - FloatVariableLengthVectorType v2 = v1; + FloatVariableLengthVectorType v1{}; + const FloatVariableLengthVectorType v2 = v1; v1 = v2; - FloatVariableLengthVectorType v3; - FloatVariableLengthVectorType v4; + const FloatVariableLengthVectorType v3; + const FloatVariableLengthVectorType v4; v1 = 2 * v2 + (v3 - v4) / 6; v1.SetSize(0, FloatVariableLengthVectorType::DontShrinkToFit(), FloatVariableLengthVectorType::KeepOldValues()); diff --git a/Modules/Core/Common/test/itkVariableSizeMatrixTest.cxx b/Modules/Core/Common/test/itkVariableSizeMatrixTest.cxx index 789563b654b..d001ba35d01 100644 --- a/Modules/Core/Common/test/itkVariableSizeMatrixTest.cxx +++ b/Modules/Core/Common/test/itkVariableSizeMatrixTest.cxx @@ -56,10 +56,10 @@ itkVariableSizeMatrixTest(int, char *[]) std::cout << "***** h" << std::endl << h << std::endl; - FloatVariableSizeMatrixType hDouble = h * 2.0; + const FloatVariableSizeMatrixType hDouble = h * 2.0; std::cout << "***** h * 2" << std::endl << hDouble << std::endl; - FloatVariableSizeMatrixType hHalf = h / 2.0; + const FloatVariableSizeMatrixType hHalf = h / 2.0; std::cout << "***** h / 2" << std::endl << hHalf << std::endl; if (hDouble == hHalf) @@ -105,7 +105,7 @@ itkVariableSizeMatrixTest(int, char *[]) } // Product by vnl_matrix - vnl_matrix dVnl(2, 3, 10.0); + const vnl_matrix dVnl(2, 3, 10.0); std::cout << "***** h" << std::endl << h << std::endl; std::cout << "***** dVnl" << std::endl << dVnl << std::endl; std::cout << "***** h * dVnl" << std::endl << h * dVnl << std::endl; diff --git a/Modules/Core/Common/test/itkVectorContainerTest.cxx b/Modules/Core/Common/test/itkVectorContainerTest.cxx index ad34f5ebb42..38529a3e799 100644 --- a/Modules/Core/Common/test/itkVectorContainerTest.cxx +++ b/Modules/Core/Common/test/itkVectorContainerTest.cxx @@ -33,10 +33,10 @@ itkVectorContainerTest(int, char *[]) // Iterator { - [[maybe_unused]] ContainerType::Iterator p_null; - ContainerType::Iterator p = container->Begin(); - ContainerType::Iterator p_copy(p); - ContainerType::Iterator p_assign = p; + [[maybe_unused]] const ContainerType::Iterator p_null; + ContainerType::Iterator p = container->Begin(); + ContainerType::Iterator p_copy(p); + ContainerType::Iterator p_assign = p; while (p != container->End()) { @@ -51,10 +51,10 @@ itkVectorContainerTest(int, char *[]) // ConstIterator { - [[maybe_unused]] ContainerType::ConstIterator p_null; - ContainerType::ConstIterator p = container->Begin(); - ContainerType::ConstIterator p_copy(p); - ContainerType::ConstIterator p_assign = p; + [[maybe_unused]] const ContainerType::ConstIterator p_null; + ContainerType::ConstIterator p = container->Begin(); + ContainerType::ConstIterator p_copy(p); + ContainerType::ConstIterator p_assign = p; while (p != container->End()) { diff --git a/Modules/Core/Common/test/itkVectorGeometryTest.cxx b/Modules/Core/Common/test/itkVectorGeometryTest.cxx index db1a54e4124..3ce9fde51cd 100644 --- a/Modules/Core/Common/test/itkVectorGeometryTest.cxx +++ b/Modules/Core/Common/test/itkVectorGeometryTest.cxx @@ -70,7 +70,7 @@ itkVectorGeometryTest(int, char *[]) std::cout << "vb = (1,3,5) = "; std::cout << vb << std::endl; - VectorType vc = vb - va; + const VectorType vc = vb - va; std::cout << "vc = vb - va = "; std::cout << vc << std::endl; @@ -90,21 +90,21 @@ itkVectorGeometryTest(int, char *[]) std::cout << "ve -= vb = "; std::cout << ve << std::endl; - VectorType vh = vb; + const VectorType vh = vb; std::cout << "vh = vb = "; std::cout << vh << std::endl; - VectorType vg(va); + const VectorType vg(va); std::cout << "vg( va ) = "; std::cout << vg << std::endl; - ValueType norm2 = vg.GetSquaredNorm(); + const ValueType norm2 = vg.GetSquaredNorm(); std::cout << "vg squared norm = "; std::cout << norm2 << std::endl; - ValueType norm = vg.GetNorm(); + const ValueType norm = vg.GetNorm(); std::cout << "vg norm = "; std::cout << norm << std::endl; @@ -152,7 +152,7 @@ itkVectorGeometryTest(int, char *[]) vv[1] = 3; vv[2] = 5; - VectorType vw{}; + const VectorType vw{}; if (vv == vw) { diff --git a/Modules/Core/Common/test/itkVectorTest.cxx b/Modules/Core/Common/test/itkVectorTest.cxx index 030b09d82b9..137dd854873 100644 --- a/Modules/Core/Common/test/itkVectorTest.cxx +++ b/Modules/Core/Common/test/itkVectorTest.cxx @@ -211,7 +211,7 @@ itkVectorTest(int, char *[]) b[0] = 0.0; b[1] = 1.0; b[2] = 0.0; - RealVector3 c = itk::CrossProduct(a, b); + const RealVector3 c = itk::CrossProduct(a, b); std::cout << '(' << a << ") cross (" << b << ") : (" << c << ')' << std::endl; using DoubleVector3 = itk::Vector; @@ -224,7 +224,7 @@ itkVectorTest(int, char *[]) bb[0] = 0.0; bb[1] = 1.0; bb[2] = 0.0; - DoubleVector3 cc = itk::CrossProduct(aa, bb); + const DoubleVector3 cc = itk::CrossProduct(aa, bb); std::cout << '(' << aa << ") cross (" << bb << ") : (" << cc << ')' << std::endl; DoubleVector3 ia; ia[0] = 1; @@ -234,7 +234,7 @@ itkVectorTest(int, char *[]) ib[0] = 0; ib[1] = 1; ib[2] = 0; - DoubleVector3 ic = itk::CrossProduct(ia, ib); + const DoubleVector3 ic = itk::CrossProduct(ia, ib); std::cout << '(' << ia << ") cross (" << ib << ") : (" << ic << ')' << std::endl; if (passed) { diff --git a/Modules/Core/Common/test/itkVersionTest.cxx b/Modules/Core/Common/test/itkVersionTest.cxx index 0624466b2d1..9750cfdc63d 100644 --- a/Modules/Core/Common/test/itkVersionTest.cxx +++ b/Modules/Core/Common/test/itkVersionTest.cxx @@ -25,22 +25,22 @@ int itkVersionTest(int, char *[]) { - int testPassStatus = EXIT_SUCCESS; + const int testPassStatus = EXIT_SUCCESS; - itk::Version::Pointer version = itk::Version::New(); + const itk::Version::Pointer version = itk::Version::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(version, Version, Object); const char * itkVersion = itk::Version::GetITKVersion(); std::cout << "itk version: " << itkVersion << std::endl; - int itkMajorVersion = itk::Version::GetITKMajorVersion(); + const int itkMajorVersion = itk::Version::GetITKMajorVersion(); std::cout << "itk Major version: " << itkMajorVersion << std::endl; - int itkMinorVersion = itk::Version::GetITKMinorVersion(); + const int itkMinorVersion = itk::Version::GetITKMinorVersion(); std::cout << "itk Minor version: " << itkMinorVersion << std::endl; - int itkBuildVersion = itk::Version::GetITKBuildVersion(); + const int itkBuildVersion = itk::Version::GetITKBuildVersion(); std::cout << "itk Build version: " << itkBuildVersion << std::endl; const char * itkSourceVersion = itk::Version::GetITKSourceVersion(); diff --git a/Modules/Core/Common/test/itkVersorTest.cxx b/Modules/Core/Common/test/itkVersorTest.cxx index cb41716411b..da5aaf4bbcf 100644 --- a/Modules/Core/Common/test/itkVersorTest.cxx +++ b/Modules/Core/Common/test/itkVersorTest.cxx @@ -52,7 +52,7 @@ TestCreateRotationMatrixFromAngles(const double alpha, const double beta, const R(2, 0) = -sb; R(2, 1) = sa * cb; R(2, 2) = ca * cb; - itk::Matrix::InternalMatrixType test = R.GetVnlMatrix() * R.GetTranspose(); + const itk::Matrix::InternalMatrixType test = R.GetVnlMatrix() * R.GetTranspose(); if (!test.is_identity(1.0e-10)) { std::cout << "Computed matrix is not orthogonal!!!" << std::endl; @@ -109,7 +109,7 @@ RotationMatrixToVersorTest() constexpr double steps = 0; const double small_degree_steps = onedegree / 1000.0; // 1/1000 of a degree - for (double center : centers) + for (const double center : centers) { for (double alpha = center - steps * small_degree_steps; alpha <= center + steps * small_degree_steps; alpha += small_degree_steps) @@ -120,8 +120,8 @@ RotationMatrixToVersorTest() for (double gamma = center - steps * small_degree_steps; gamma <= center + steps * small_degree_steps; gamma += small_degree_steps) { - itk::Matrix MR = TestCreateRotationMatrixFromAngles(alpha, beta, gamma); - itk::Versor VR = TestCreateRotationVersorFromAngles(alpha, beta, gamma); + const itk::Matrix MR = TestCreateRotationMatrixFromAngles(alpha, beta, gamma); + const itk::Versor VR = TestCreateRotationVersorFromAngles(alpha, beta, gamma); itk::Point testPoint; testPoint[0] = -1020.27; @@ -130,9 +130,9 @@ RotationMatrixToVersorTest() itk::Versor VFROMMR; VFROMMR.Set(MR); - itk::Matrix VRMatrix = VR.GetMatrix(); - const itk::Point newMRtestPoint = (MR)*testPoint; - const itk::Point newVRtestPoint = (VRMatrix)*testPoint; + const itk::Matrix VRMatrix = VR.GetMatrix(); + const itk::Point newMRtestPoint = (MR)*testPoint; + const itk::Point newVRtestPoint = (VRMatrix)*testPoint; const itk::Point newVRFROMMRPoint = (VFROMMR.GetMatrix()) * testPoint; const itk::Point newVRFROMMRTransformPoint = VFROMMR.Transform(testPoint); @@ -202,7 +202,7 @@ itkVersorTest(int, char *[]) { std::cout << "Test default constructor... "; - VersorType qa; + const VersorType qa; if (itk::Math::abs(qa.GetX()) > epsilon) { std::cout << "Error ! " << std::endl; @@ -231,7 +231,7 @@ itkVersorTest(int, char *[]) std::cout << "Test initialization and GetMatrix()... "; VersorType qa; qa.SetIdentity(); - MatrixType ma = qa.GetMatrix(); + const MatrixType ma = qa.GetMatrix(); std::cout << "Matrix = " << std::endl; std::cout << ma << std::endl; } @@ -243,7 +243,7 @@ itkVersorTest(int, char *[]) xa[0] = 0.0; xa[1] = 0.0; xa[2] = 0.0; - ValueType angle = 0; + const ValueType angle = 0; try { qa.Set(xa, angle); @@ -263,13 +263,13 @@ itkVersorTest(int, char *[]) xa[0] = 2.5; xa[1] = 1.5; xa[2] = 0.5; - ValueType angle = std::atan(1.0) / 3.0; // 15 degrees in radians + const ValueType angle = std::atan(1.0) / 3.0; // 15 degrees in radians qa.Set(xa, angle); xa.Normalize(); - ValueType cosangle = std::cos(angle / 2.0); - ValueType sinangle = std::sin(angle / 2.0); + const ValueType cosangle = std::cos(angle / 2.0); + const ValueType sinangle = std::sin(angle / 2.0); VectorType xb; @@ -306,8 +306,8 @@ itkVersorTest(int, char *[]) { std::cout << "Test for setting Right part..."; - ValueType angle = std::atan(1.0) * 30.0 / 45.0; - ValueType sin2a = std::sin(angle / 2.0); + const ValueType angle = std::atan(1.0) * 30.0 / 45.0; + const ValueType sin2a = std::sin(angle / 2.0); VectorType xa; xa[0] = 0.7; @@ -319,7 +319,7 @@ itkVersorTest(int, char *[]) VersorType qa; qa.Set(xa, angle); - ValueType cos2a = std::cos(angle / 2.0); + const ValueType cos2a = std::cos(angle / 2.0); if (itk::Math::abs(qa.GetW() - cos2a) > epsilon) { @@ -339,8 +339,8 @@ itkVersorTest(int, char *[]) { std::cout << "Test for Square Root..."; - ValueType angle = std::atan(1.0) * 30.0 / 45.0; - ValueType sin2a = std::sin(angle / 2.0); + const ValueType angle = std::atan(1.0) * 30.0 / 45.0; + const ValueType sin2a = std::sin(angle / 2.0); VectorType xa; xa[0] = 0.7; @@ -372,7 +372,7 @@ itkVersorTest(int, char *[]) xa[0] = 2.5; xa[1] = 2.5; xa[2] = 2.5; - ValueType angle = 8.0 * std::atan(1.0) / 3.0; // 120 degrees in radians + const ValueType angle = 8.0 * std::atan(1.0) / 3.0; // 120 degrees in radians VersorType qa; qa.Set(xa, angle); @@ -407,13 +407,13 @@ itkVersorTest(int, char *[]) xa[0] = 2.5; xa[1] = 2.5; xa[2] = 2.5; - ValueType angle = 8.0 * std::atan(1.0) / 3.0; // 120 degrees in radians + const ValueType angle = 8.0 * std::atan(1.0) / 3.0; // 120 degrees in radians VersorType qa; qa.Set(xa, angle); - PointType::ValueType xbInit[3] = { 3.0, 7.0, 9.0 }; - PointType xb = xbInit; + const PointType::ValueType xbInit[3] = { 3.0, 7.0, 9.0 }; + PointType xb = xbInit; PointType xc = qa.Transform(xb); @@ -443,7 +443,7 @@ itkVersorTest(int, char *[]) xa[0] = 2.5; xa[1] = 2.5; xa[2] = 2.5; - ValueType angle = 8.0 * std::atan(1.0) / 3.0; // 120 degrees in radians + const ValueType angle = 8.0 * std::atan(1.0) / 3.0; // 120 degrees in radians VersorType qa; qa.Set(xa, angle); @@ -478,7 +478,7 @@ itkVersorTest(int, char *[]) xa[0] = 2.5; xa[1] = 2.5; xa[2] = 2.5; - ValueType angle = 8.0 * std::atan(1.0) / 3.0; // 120 degrees in radians + const ValueType angle = 8.0 * std::atan(1.0) / 3.0; // 120 degrees in radians VersorType qa; qa.Set(xa, angle); @@ -514,19 +514,19 @@ itkVersorTest(int, char *[]) // First, create a known versor VectorType::ValueType x1Init[3] = { 2.5f, 1.5f, 3.5f }; - VectorType x1 = x1Init; + const VectorType x1 = x1Init; - ValueType angle1 = std::atan(1.0) / 3.0; // 15 degrees in radians + const ValueType angle1 = std::atan(1.0) / 3.0; // 15 degrees in radians VersorType v1; v1.Set(x1, angle1); // Get the components and scale them - ValueType scale = 5.5; - ValueType x = v1.GetX() * scale; - ValueType y = v1.GetY() * scale; - ValueType z = v1.GetZ() * scale; - ValueType w = v1.GetW() * scale; + const ValueType scale = 5.5; + ValueType x = v1.GetX() * scale; + ValueType y = v1.GetY() * scale; + ValueType z = v1.GetZ() * scale; + ValueType w = v1.GetW() * scale; VersorType v2; v2.Set(x, y, z, w); @@ -589,20 +589,20 @@ itkVersorTest(int, char *[]) VectorType::ValueType x1Init[3] = { 2.5f, 1.5f, 0.5f }; VectorType x1 = x1Init; - ValueType angle1 = std::atan(1.0) / 3.0; // 15 degrees in radians + const ValueType angle1 = std::atan(1.0) / 3.0; // 15 degrees in radians VectorType::ValueType x2Init[3] = { 1.5f, 0.5f, 0.5f }; VectorType x2 = x2Init; - ValueType angle2 = std::atan(1.0) / 1.0; // 45 degrees in radians + const ValueType angle2 = std::atan(1.0) / 1.0; // 45 degrees in radians VersorType v1; v1.Set(x1, angle1); VersorType v2; v2.Set(x2, angle2); - VersorType v2r = v2.GetReciprocal(); - VersorType unit = v2 * v2r; + const VersorType v2r = v2.GetReciprocal(); + VersorType unit = v2 * v2r; if (itk::Math::abs(unit.GetX()) > epsilon || itk::Math::abs(unit.GetY()) > epsilon || itk::Math::abs(unit.GetZ()) > epsilon || itk::Math::abs(unit.GetW() - 1.0) > epsilon) @@ -643,8 +643,8 @@ itkVersorTest(int, char *[]) x2.Normalize(); - VersorType v3 = v1 * v2; - VersorType v4 = v3 * v2r; + const VersorType v3 = v1 * v2; + const VersorType v4 = v3 * v2r; if (itk::Math::abs(v1.GetX() - v4.GetX()) > epsilon || itk::Math::abs(v1.GetY() - v4.GetY()) > epsilon || itk::Math::abs(v1.GetZ() - v4.GetZ()) > epsilon || itk::Math::abs(v1.GetW() - v4.GetW()) > epsilon) diff --git a/Modules/Core/Common/test/itkWeakPointerGTest.cxx b/Modules/Core/Common/test/itkWeakPointerGTest.cxx index e85b43b3391..d2658d00f56 100644 --- a/Modules/Core/Common/test/itkWeakPointerGTest.cxx +++ b/Modules/Core/Common/test/itkWeakPointerGTest.cxx @@ -52,22 +52,22 @@ TEST(WeakPointer, DefaultConstructedEqualsNullptr) TEST(WeakPointer, CheckNull) { - WeakPointerType nullPtr; + const WeakPointerType nullPtr; ASSERT_TRUE(nullPtr.IsNull()); - itk::LightObject::Pointer lightObject = itk::LightObject::New(); - WeakPointerType ptr = lightObject.GetPointer(); + const itk::LightObject::Pointer lightObject = itk::LightObject::New(); + const WeakPointerType ptr = lightObject.GetPointer(); ASSERT_TRUE(ptr.IsNotNull()); } TEST(WeakPointer, CheckSerialization) { - WeakPointerType nullPtr; + const WeakPointerType nullPtr; std::cout << nullPtr << std::endl; - itk::LightObject::Pointer lightObject = itk::LightObject::New(); - WeakPointerType ptr = lightObject.GetPointer(); + const itk::LightObject::Pointer lightObject = itk::LightObject::New(); + const WeakPointerType ptr = lightObject.GetPointer(); std::cout << ptr << std::endl; } diff --git a/Modules/Core/Common/test/itkXMLFileOutputWindowTest.cxx b/Modules/Core/Common/test/itkXMLFileOutputWindowTest.cxx index 442f8d4cdf9..4590a68dbad 100644 --- a/Modules/Core/Common/test/itkXMLFileOutputWindowTest.cxx +++ b/Modules/Core/Common/test/itkXMLFileOutputWindowTest.cxx @@ -41,7 +41,7 @@ DoTestXMLFileOutputWindow(std::string currentLoggerFilename, const unsigned int const std::string fileBaseName = []() -> std::string { // If no input filename is provided, remove the default file to avoid counting existing lines when // contents are appended. - itk::XMLFileOutputWindow::Pointer logger = itk::XMLFileOutputWindow::New(); + const itk::XMLFileOutputWindow::Pointer logger = itk::XMLFileOutputWindow::New(); // In order to initialize the filename, some text needs to be written first const char * regularText = "text"; logger->DisplayText(regularText); @@ -55,7 +55,7 @@ DoTestXMLFileOutputWindow(std::string currentLoggerFilename, const unsigned int } - itk::XMLFileOutputWindow::Pointer logger = itk::XMLFileOutputWindow::New(); + const itk::XMLFileOutputWindow::Pointer logger = itk::XMLFileOutputWindow::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(logger, XMLFileOutputWindow, FileOutputWindow); diff --git a/Modules/Core/Common/test/itkXMLFilterWatcherTest.cxx b/Modules/Core/Common/test/itkXMLFilterWatcherTest.cxx index c5827531b60..f08cf282e5e 100644 --- a/Modules/Core/Common/test/itkXMLFilterWatcherTest.cxx +++ b/Modules/Core/Common/test/itkXMLFilterWatcherTest.cxx @@ -44,7 +44,7 @@ itkXMLFilterWatcherTest(int argc, char * argv[]) reader->SetFileName(argv[1]); - itk::XMLFilterWatcher watcher(reader, "filter"); + const itk::XMLFilterWatcher watcher(reader, "filter"); reader->Update(); diff --git a/Modules/Core/Common/test/itkZeroFluxBoundaryConditionTest.cxx b/Modules/Core/Common/test/itkZeroFluxBoundaryConditionTest.cxx index 717bb069786..ebf3cd7a44c 100644 --- a/Modules/Core/Common/test/itkZeroFluxBoundaryConditionTest.cxx +++ b/Modules/Core/Common/test/itkZeroFluxBoundaryConditionTest.cxx @@ -74,9 +74,9 @@ TestPrintNeighborhood(IteratorType & p, VectorIteratorType & v) // Access the pixel value through three different methods in the // boundary condition. - int pixel1 = p.GetBoundaryCondition()->GetPixel(index, p.GetImagePointer()); - int pixel2 = p.GetPixel(i); - int pixel3 = v.GetPixel(i)[0]; + const int pixel1 = p.GetBoundaryCondition()->GetPixel(index, p.GetImagePointer()); + const int pixel2 = p.GetPixel(i); + const int pixel3 = v.GetPixel(i)[0]; std::cout << pixel1 << ' '; @@ -124,9 +124,9 @@ itkZeroFluxBoundaryConditionTest(int, char *[]) // Test an image to cover one operator() method. auto image = ImageType::New(); - const SizeType imageSize = { { 5, 5 } }; - const IndexType imageIndex = { { 0, 0 } }; - RegionType imageRegion{ imageIndex, imageSize }; + const SizeType imageSize = { { 5, 5 } }; + const IndexType imageIndex = { { 0, 0 } }; + const RegionType imageRegion{ imageIndex, imageSize }; image->SetRegions(imageRegion); image->Allocate(); @@ -168,7 +168,7 @@ itkZeroFluxBoundaryConditionTest(int, char *[]) for (it.GoToBegin(), vit.GoToBegin(); !it.IsAtEnd(); ++it, ++vit) { std::cout << "Index: " << it.GetIndex() << std::endl; - bool success = TestPrintNeighborhood(it, vit); + const bool success = TestPrintNeighborhood(it, vit); if (!success) { return EXIT_FAILURE; @@ -190,7 +190,7 @@ itkZeroFluxBoundaryConditionTest(int, char *[]) for (it2.GoToBegin(), vit2.GoToBegin(); !it2.IsAtEnd(); ++it2, ++vit2) { std::cout << "Index: " << it2.GetIndex() << std::endl; - bool success = TestPrintNeighborhood(it2, vit2); + const bool success = TestPrintNeighborhood(it2, vit2); if (!success) { return EXIT_FAILURE; diff --git a/Modules/Core/FiniteDifference/include/itkDenseFiniteDifferenceImageFilter.hxx b/Modules/Core/FiniteDifference/include/itkDenseFiniteDifferenceImageFilter.hxx index ac8850191f4..59d7410a238 100644 --- a/Modules/Core/FiniteDifference/include/itkDenseFiniteDifferenceImageFilter.hxx +++ b/Modules/Core/FiniteDifference/include/itkDenseFiniteDifferenceImageFilter.hxx @@ -31,8 +31,8 @@ template void DenseFiniteDifferenceImageFilter::CopyInputToOutput() { - typename TInputImage::ConstPointer input = this->GetInput(); - typename TOutputImage::Pointer output = this->GetOutput(); + const typename TInputImage::ConstPointer input = this->GetInput(); + const typename TOutputImage::Pointer output = this->GetOutput(); if (!input || !output) { @@ -64,7 +64,7 @@ void DenseFiniteDifferenceImageFilter::AllocateUpdateBuffer() { // The update buffer looks just like the output. - typename TOutputImage::Pointer output = this->GetOutput(); + const typename TOutputImage::Pointer output = this->GetOutput(); m_UpdateBuffer->SetOrigin(output->GetOrigin()); m_UpdateBuffer->SetSpacing(output->GetSpacing()); @@ -98,16 +98,16 @@ template ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION DenseFiniteDifferenceImageFilter::ApplyUpdateThreaderCallback(void * arg) { - ThreadIdType workUnitID = ((MultiThreaderBase::WorkUnitInfo *)(arg))->WorkUnitID; - ThreadIdType workUnitCount = ((MultiThreaderBase::WorkUnitInfo *)(arg))->NumberOfWorkUnits; + const ThreadIdType workUnitID = ((MultiThreaderBase::WorkUnitInfo *)(arg))->WorkUnitID; + const ThreadIdType workUnitCount = ((MultiThreaderBase::WorkUnitInfo *)(arg))->NumberOfWorkUnits; auto * str = (DenseFDThreadStruct *)(((MultiThreaderBase::WorkUnitInfo *)(arg))->UserData); // Execute the actual method with appropriate output region // first find out how many pieces extent can be split into. // Using the SplitRequestedRegion method from itk::ImageSource. - ThreadRegionType splitRegion; - ThreadIdType total = str->Filter->SplitRequestedRegion(workUnitID, workUnitCount, splitRegion); + ThreadRegionType splitRegion; + const ThreadIdType total = str->Filter->SplitRequestedRegion(workUnitID, workUnitCount, splitRegion); if (workUnitID < total) { @@ -133,7 +133,7 @@ DenseFiniteDifferenceImageFilter::CalculateChange() - // Initialize the list of time step values that will be generated by the // various threads. There is one distinct slot for each possible thread, // so this data structure is thread-safe. - ThreadIdType workUnitCount = this->GetMultiThreader()->GetNumberOfWorkUnits(); + const ThreadIdType workUnitCount = this->GetMultiThreader()->GetNumberOfWorkUnits(); str.TimeStepList.clear(); str.TimeStepList.resize(workUnitCount, TimeStepType{}); @@ -145,7 +145,7 @@ DenseFiniteDifferenceImageFilter::CalculateChange() - this->GetMultiThreader()->SingleMethodExecute(); // Resolve the single value time step to return - TimeStepType dt = this->ResolveTimeStep(str.TimeStepList, str.ValidTimeStepList); + const TimeStepType dt = this->ResolveTimeStep(str.TimeStepList, str.ValidTimeStepList); // Explicitly call Modified on m_UpdateBuffer here // since ThreadedCalculateChange changes this buffer @@ -160,8 +160,8 @@ template ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION DenseFiniteDifferenceImageFilter::CalculateChangeThreaderCallback(void * arg) { - ThreadIdType workUnitID = ((MultiThreaderBase::WorkUnitInfo *)(arg))->WorkUnitID; - ThreadIdType workUnitCount = ((MultiThreaderBase::WorkUnitInfo *)(arg))->NumberOfWorkUnits; + const ThreadIdType workUnitID = ((MultiThreaderBase::WorkUnitInfo *)(arg))->WorkUnitID; + const ThreadIdType workUnitCount = ((MultiThreaderBase::WorkUnitInfo *)(arg))->NumberOfWorkUnits; auto * str = (DenseFDThreadStruct *)(((MultiThreaderBase::WorkUnitInfo *)(arg))->UserData); @@ -170,7 +170,7 @@ DenseFiniteDifferenceImageFilter::CalculateChangeThre // Using the SplitRequestedRegion method from itk::ImageSource. ThreadRegionType splitRegion; - ThreadIdType total = str->Filter->SplitRequestedRegion(workUnitID, workUnitCount, splitRegion); + const ThreadIdType total = str->Filter->SplitRequestedRegion(workUnitID, workUnitCount, splitRegion); if (workUnitID < total) { @@ -211,7 +211,7 @@ DenseFiniteDifferenceImageFilter::ThreadedCalculateCh using UpdateIteratorType = ImageRegionIterator; - typename OutputImageType::Pointer output = this->GetOutput(); + const typename OutputImageType::Pointer output = this->GetOutput(); // Get the FiniteDifferenceFunction to use in calculations. const typename FiniteDifferenceFunctionType::Pointer df = this->GetDifferenceFunction(); @@ -267,7 +267,7 @@ DenseFiniteDifferenceImageFilter::ThreadedCalculateCh // Ask the finite difference function to compute the time step for // this iteration. We give it the global data pointer to use, then // ask it to free the global data memory. - TimeStepType timeStep = df->ComputeGlobalTimeStep(globalData); + const TimeStepType timeStep = df->ComputeGlobalTimeStep(globalData); df->ReleaseGlobalDataPointer(globalData); return timeStep; diff --git a/Modules/Core/FiniteDifference/include/itkFiniteDifferenceImageFilter.hxx b/Modules/Core/FiniteDifference/include/itkFiniteDifferenceImageFilter.hxx index 9f4e778ef09..a67099755fe 100644 --- a/Modules/Core/FiniteDifference/include/itkFiniteDifferenceImageFilter.hxx +++ b/Modules/Core/FiniteDifference/include/itkFiniteDifferenceImageFilter.hxx @@ -79,7 +79,7 @@ FiniteDifferenceImageFilter::GenerateData() // global values, or otherwise setting up // for the next iteration - TimeStepType dt = this->CalculateChange(); + const TimeStepType dt = this->CalculateChange(); this->ApplyUpdate(dt); ++m_ElapsedIterations; @@ -115,7 +115,7 @@ FiniteDifferenceImageFilter::GenerateInputRequestedRe Superclass::GenerateInputRequestedRegion(); // get pointers to the input - typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); + const typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); if (!inputPtr) { @@ -124,7 +124,7 @@ FiniteDifferenceImageFilter::GenerateInputRequestedRe // Get the size of the neighborhood on which we are going to operate. This // radius is supplied by the difference function we are using. - RadiusType radius = this->GetDifferenceFunction()->GetRadius(); + const RadiusType radius = this->GetDifferenceFunction()->GetRadius(); // Try to set up a buffered region that will accommodate our // neighborhood operations. This may not be possible and we diff --git a/Modules/Core/FiniteDifference/include/itkFiniteDifferenceSparseImageFilter.hxx b/Modules/Core/FiniteDifference/include/itkFiniteDifferenceSparseImageFilter.hxx index b9826969a05..d805e2a5969 100644 --- a/Modules/Core/FiniteDifference/include/itkFiniteDifferenceSparseImageFilter.hxx +++ b/Modules/Core/FiniteDifference/include/itkFiniteDifferenceSparseImageFilter.hxx @@ -89,16 +89,16 @@ template ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION FiniteDifferenceSparseImageFilter::ApplyUpdateThreaderCallback(void * arg) { - ThreadIdType workUnitID = ((MultiThreaderBase::WorkUnitInfo *)(arg))->WorkUnitID; - ThreadIdType workUnitCount = ((MultiThreaderBase::WorkUnitInfo *)(arg))->NumberOfWorkUnits; - FDThreadStruct * str = (FDThreadStruct *)(((MultiThreaderBase::WorkUnitInfo *)(arg))->UserData); + const ThreadIdType workUnitID = ((MultiThreaderBase::WorkUnitInfo *)(arg))->WorkUnitID; + const ThreadIdType workUnitCount = ((MultiThreaderBase::WorkUnitInfo *)(arg))->NumberOfWorkUnits; + FDThreadStruct * str = (FDThreadStruct *)(((MultiThreaderBase::WorkUnitInfo *)(arg))->UserData); // Execute the actual method with appropriate output region // first find out how many pieces extent can be split into. // Use GetSplitRegion to access partition previously computed by // the SplitRegions function in the SparseFieldLayer class. - ThreadRegionType splitRegion; - ThreadIdType total = str->Filter->GetSplitRegion(workUnitID, workUnitCount, splitRegion); + ThreadRegionType splitRegion; + const ThreadIdType total = str->Filter->GetSplitRegion(workUnitID, workUnitCount, splitRegion); if (workUnitID < total) { @@ -159,7 +159,7 @@ FiniteDifferenceSparseImageFilter::Calc // various threads. There is one distinct slot for each possible thread, // so this data structure is thread-safe. All of the time steps calculated // in each thread will be combined in the ResolveTimeStep method. - ThreadIdType workUnitCount = this->GetMultiThreader()->GetNumberOfWorkUnits(); + const ThreadIdType workUnitCount = this->GetMultiThreader()->GetNumberOfWorkUnits(); str.TimeStepList.resize(workUnitCount, false); str.ValidTimeStepList.resize(workUnitCount); @@ -169,7 +169,7 @@ FiniteDifferenceSparseImageFilter::Calc // Resolve the single value time step to return. The default implementation // of ResolveTimeStep is to return the lowest value in the list that it is // given. - TimeStepType dt = this->ResolveTimeStep(str.TimeStepList, str.ValidTimeStepList); + const TimeStepType dt = this->ResolveTimeStep(str.TimeStepList, str.ValidTimeStepList); return dt; } @@ -178,8 +178,8 @@ template ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION FiniteDifferenceSparseImageFilter::CalculateChangeThreaderCallback(void * arg) { - ThreadIdType workUnitID = ((MultiThreaderBase::WorkUnitInfo *)(arg))->WorkUnitID; - ThreadIdType workUnitCount = ((MultiThreaderBase::WorkUnitInfo *)(arg))->NumberOfWorkUnits; + const ThreadIdType workUnitID = ((MultiThreaderBase::WorkUnitInfo *)(arg))->WorkUnitID; + const ThreadIdType workUnitCount = ((MultiThreaderBase::WorkUnitInfo *)(arg))->NumberOfWorkUnits; FDThreadStruct * str = (FDThreadStruct *)(((MultiThreaderBase::WorkUnitInfo *)(arg))->UserData); @@ -187,8 +187,8 @@ FiniteDifferenceSparseImageFilter::Calc // first find out how many pieces extent can be split into. // Use GetSplitRegion to access partition previously computed by // the SplitRegions function in the SparseFieldLayer class. - ThreadRegionType splitRegion; - ThreadIdType total = str->Filter->GetSplitRegion(workUnitID, workUnitCount, splitRegion); + ThreadRegionType splitRegion; + const ThreadIdType total = str->Filter->GetSplitRegion(workUnitID, workUnitCount, splitRegion); if (workUnitID < total) { @@ -204,8 +204,8 @@ ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION FiniteDifferenceSparseImageFilter::PrecalculateChangeThreaderCallback( void * arg) { - ThreadIdType workUnitID = ((MultiThreaderBase::WorkUnitInfo *)(arg))->WorkUnitID; - ThreadIdType workUnitCount = ((MultiThreaderBase::WorkUnitInfo *)(arg))->NumberOfWorkUnits; + const ThreadIdType workUnitID = ((MultiThreaderBase::WorkUnitInfo *)(arg))->WorkUnitID; + const ThreadIdType workUnitCount = ((MultiThreaderBase::WorkUnitInfo *)(arg))->NumberOfWorkUnits; FDThreadStruct * str = (FDThreadStruct *)(((MultiThreaderBase::WorkUnitInfo *)(arg))->UserData); @@ -213,8 +213,8 @@ FiniteDifferenceSparseImageFilter::Prec // first find out how many pieces extent can be split into. // Use GetSplitRegion to access partition previously computed by // the SplitRegions function in the SparseFieldLayer class. - ThreadRegionType splitRegion; - ThreadIdType total = str->Filter->GetSplitRegion(workUnitID, workUnitCount, splitRegion); + ThreadRegionType splitRegion; + const ThreadIdType total = str->Filter->GetSplitRegion(workUnitID, workUnitCount, splitRegion); if (workUnitID < total) { @@ -232,7 +232,7 @@ FiniteDifferenceSparseImageFilter::Thre { using NeighborhoodIteratorType = typename FiniteDifferenceFunctionType::NeighborhoodType; - typename SparseOutputImageType::Pointer output = this->GetOutput(); + const typename SparseOutputImageType::Pointer output = this->GetOutput(); const SizeType radius = m_SparseFunction->GetRadius(); @@ -254,7 +254,7 @@ FiniteDifferenceSparseImageFilter::Thre // Ask the finite difference function to compute the time step for // this iteration. We give it the global data pointer to use, then // ask it to free the global data memory. - TimeStepType timeStep = m_SparseFunction->ComputeGlobalTimeStep(globalData); + const TimeStepType timeStep = m_SparseFunction->ComputeGlobalTimeStep(globalData); m_SparseFunction->ReleaseGlobalDataPointer(globalData); return timeStep; @@ -268,7 +268,7 @@ FiniteDifferenceSparseImageFilter::Thre { using NeighborhoodIteratorType = typename FiniteDifferenceFunctionType::NeighborhoodType; - typename SparseOutputImageType::Pointer output = this->GetOutput(); + const typename SparseOutputImageType::Pointer output = this->GetOutput(); const SizeType radius = m_SparseFunction->GetRadius(); diff --git a/Modules/Core/ImageAdaptors/include/itkNthElementPixelAccessor.h b/Modules/Core/ImageAdaptors/include/itkNthElementPixelAccessor.h index e0cf8e6953d..70ee2adb153 100644 --- a/Modules/Core/ImageAdaptors/include/itkNthElementPixelAccessor.h +++ b/Modules/Core/ImageAdaptors/include/itkNthElementPixelAccessor.h @@ -156,7 +156,7 @@ class NthElementPixelAccessor(input[m_ElementNumber]); + const ExternalType output = static_cast(input[m_ElementNumber]); return output; } diff --git a/Modules/Core/ImageAdaptors/include/itkVectorImageToImageAdaptor.h b/Modules/Core/ImageAdaptors/include/itkVectorImageToImageAdaptor.h index 9ea7a74233d..9ccfb9e6709 100644 --- a/Modules/Core/ImageAdaptors/include/itkVectorImageToImageAdaptor.h +++ b/Modules/Core/ImageAdaptors/include/itkVectorImageToImageAdaptor.h @@ -74,7 +74,7 @@ class VectorImageToImagePixelAccessor : private DefaultVectorPixelAccessorSetRegions(size); image->Allocate(); - ImageType::RegionType region = image->GetLargestPossibleRegion(); + const ImageType::RegionType region = image->GetLargestPossibleRegion(); srand(50L); itk::ImageRegionIterator iter(image, region); for (iter.GoToBegin(); !iter.IsAtEnd(); ++iter) { - auto randMax = static_cast(RAND_MAX); - PixelType pixel(static_cast(rand()) / randMax, static_cast(rand()) / randMax); + auto randMax = static_cast(RAND_MAX); + const PixelType pixel(static_cast(rand()) / randMax, static_cast(rand()) / randMax); iter.Set(pixel); } @@ -56,8 +56,8 @@ itkComplexConjugateImageAdaptorTest(int, char *[]) for (iterA.GoToBegin(), iterB.GoToBegin(); !iterA.IsAtEnd(); ++iterA, ++iterB) { - PixelType imageValue = iterA.Get(); - PixelType adaptedValue = iterB.Get(); + const PixelType imageValue = iterA.Get(); + const PixelType adaptedValue = iterB.Get(); // Check that the adapted value is as expected. if (imageValue != std::conj(adaptedValue)) @@ -69,7 +69,7 @@ itkComplexConjugateImageAdaptorTest(int, char *[]) // Try setting the value and reading it again. iterB.Set(adaptedValue); - PixelType newValue = iterB.Get(); + const PixelType newValue = iterB.Get(); if (adaptedValue != newValue) { std::cerr << "Setting adapted pixel value failed." << std::endl; diff --git a/Modules/Core/ImageAdaptors/test/itkImageAdaptorTest.cxx b/Modules/Core/ImageAdaptors/test/itkImageAdaptorTest.cxx index 98c84eacccb..73db9ae359b 100644 --- a/Modules/Core/ImageAdaptors/test/itkImageAdaptorTest.cxx +++ b/Modules/Core/ImageAdaptors/test/itkImageAdaptorTest.cxx @@ -65,7 +65,7 @@ itkImageAdaptorTest(int, char *[]) index[0] = 0; index[1] = 0; - myImageType::RegionType region{ index, size }; + const myImageType::RegionType region{ index, size }; auto myImage = myImageType::New(); @@ -77,7 +77,7 @@ itkImageAdaptorTest(int, char *[]) // Value to initialize the pixels myImageType::PixelType::ComponentType colorInit[3] = { 1.0f, 0.5f, 0.5f }; - myImageType::PixelType color = colorInit; + const myImageType::PixelType color = colorInit; // Initializing all the pixel in the image it1.GoToBegin(); diff --git a/Modules/Core/ImageAdaptors/test/itkNthElementPixelAccessorTest.cxx b/Modules/Core/ImageAdaptors/test/itkNthElementPixelAccessorTest.cxx index d0534335db6..b14a7b2f9f0 100644 --- a/Modules/Core/ImageAdaptors/test/itkNthElementPixelAccessorTest.cxx +++ b/Modules/Core/ImageAdaptors/test/itkNthElementPixelAccessorTest.cxx @@ -63,7 +63,7 @@ itkNthElementPixelAccessorTest(int, char *[]) index[0] = 0; index[1] = 0; - myImageType::RegionType region{ index, size }; + const myImageType::RegionType region{ index, size }; auto myImage = myImageType::New(); @@ -74,7 +74,7 @@ itkNthElementPixelAccessorTest(int, char *[]) // Value to initialize the pixels myImageType::PixelType::ComponentType colorInit[3] = { 1.0f, 0.5f, 0.5f }; - myImageType::PixelType color = colorInit; + const myImageType::PixelType color = colorInit; // Initializing all the pixel in the image it1.GoToBegin(); diff --git a/Modules/Core/ImageAdaptors/test/itkRGBToVectorImageAdaptorTest.cxx b/Modules/Core/ImageAdaptors/test/itkRGBToVectorImageAdaptorTest.cxx index 2787408ccc3..c62eb20321a 100644 --- a/Modules/Core/ImageAdaptors/test/itkRGBToVectorImageAdaptorTest.cxx +++ b/Modules/Core/ImageAdaptors/test/itkRGBToVectorImageAdaptorTest.cxx @@ -64,7 +64,7 @@ itkRGBToVectorImageAdaptorTest(int, char *[]) index[0] = 0; index[1] = 0; - ImageType::RegionType region{ index, size }; + const ImageType::RegionType region{ index, size }; auto image = ImageType::New(); diff --git a/Modules/Core/ImageAdaptors/test/itkVectorImageTest.cxx b/Modules/Core/ImageAdaptors/test/itkVectorImageTest.cxx index d712f5728f5..2d5a6183364 100644 --- a/Modules/Core/ImageAdaptors/test/itkVectorImageTest.cxx +++ b/Modules/Core/ImageAdaptors/test/itkVectorImageTest.cxx @@ -83,11 +83,11 @@ testVectorImageAdaptor(typename TAdaptor::Pointer & { using CovariantVectorType = itk::CovariantVector; - CovariantVectorType input{ 0.0 }; - CovariantVectorType output1; + const CovariantVectorType input{ 0.0 }; + CovariantVectorType output1; vectorImageAdaptor->TransformLocalVectorToPhysicalVector(input, output1); - CovariantVectorType output2 = vectorImageAdaptor->TransformLocalVectorToPhysicalVector(input); - constexpr double diff_tolerance = 1e-13; + const CovariantVectorType output2 = vectorImageAdaptor->TransformLocalVectorToPhysicalVector(input); + constexpr double diff_tolerance = 1e-13; if ((input - output1).GetSquaredNorm() > diff_tolerance || (input - output2).GetSquaredNorm() > diff_tolerance) { std::cerr << "[FAILED] "; @@ -98,11 +98,11 @@ testVectorImageAdaptor(typename TAdaptor::Pointer & } { using CovariantVectorType = itk::CovariantVector; - CovariantVectorType input{ 0.0 }; - CovariantVectorType output1; + const CovariantVectorType input{ 0.0 }; + CovariantVectorType output1; vectorImageAdaptor->TransformPhysicalVectorToLocalVector(input, output1); - CovariantVectorType output2 = vectorImageAdaptor->TransformPhysicalVectorToLocalVector(input); - constexpr double diff_tolerance = 1e-13; + const CovariantVectorType output2 = vectorImageAdaptor->TransformPhysicalVectorToLocalVector(input); + constexpr double diff_tolerance = 1e-13; if ((input - output1).GetSquaredNorm() > diff_tolerance || (input - output2).GetSquaredNorm() > diff_tolerance) { std::cerr << "[FAILED] "; @@ -124,7 +124,7 @@ testVectorImageAdaptor(typename TAdaptor::Pointer & } while (!adaptIt.IsAtEnd()) { - PixelType pixel = adaptIt.Get(); + const PixelType pixel = adaptIt.Get(); if (itk::Math::NotExactlyEquals(pixel, f[componentToExtract])) { itFailed = true; @@ -156,9 +156,9 @@ testVectorImageBasicMethods() std::cout << "Testing Get/SetPixel methods." << std::endl; - auto image = VectorImageType::New(); - typename VectorImageType::SizeType size = { { 11, 9, 7 } }; - typename VectorImageType::RegionType region; + auto image = VectorImageType::New(); + const typename VectorImageType::SizeType size = { { 11, 9, 7 } }; + typename VectorImageType::RegionType region; region.SetSize(size); image->SetRegions(region); image->SetNumberOfComponentsPerPixel(VectorLength); @@ -169,9 +169,9 @@ testVectorImageBasicMethods() image->FillBuffer(f); - typename VectorImageType::IndexType idx = { { 1, 1, 1 } }; + const typename VectorImageType::IndexType idx = { { 1, 1, 1 } }; - typename VectorImageType::ConstPointer cimage(image); + const typename VectorImageType::ConstPointer cimage(image); // test get methods @@ -228,7 +228,7 @@ testVectorImageBasicMethods() // comp error // cimage->GetPixel(idx) = f; - typename VectorImageType::PixelType temp2 = cimage->GetPixel(idx); + const typename VectorImageType::PixelType temp2 = cimage->GetPixel(idx); // the image actually get modified!!! :( // The following line modifies the image and is considered a bug in // the interface design that it works. @@ -303,13 +303,13 @@ itkVectorImageTest(int, char * argv[]) } start.Fill(0); size.Fill(50); - VariableLengthVectorImageType::RegionType region{ start, size }; + const VariableLengthVectorImageType::RegionType region{ start, size }; image->SetRegions(region); image->Allocate(); image->FillBuffer(f); clock.Stop(); - double timeTaken = clock.GetMean(); + const double timeTaken = clock.GetMean(); std::cout << "Allocating an image of itk::VariableLengthVector of length " << VectorLength << " with image size " << size << " took " << timeTaken << " s." << std::endl; @@ -347,13 +347,13 @@ itkVectorImageTest(int, char * argv[]) } start.Fill(0); size.Fill(50); - FixedArrayImageType::RegionType region{ start, size }; + const FixedArrayImageType::RegionType region{ start, size }; image->SetRegions(region); image->Allocate(); image->FillBuffer(f); clock.Stop(); - double timeTaken = clock.GetMean(); + const double timeTaken = clock.GetMean(); std::cout << "Allocating an image of itk::FixedArray of length " << VectorLength << " with image size " << size << " took " << timeTaken << " s." << std::endl; @@ -404,14 +404,14 @@ itkVectorImageTest(int, char * argv[]) } start.Fill(0); size.Fill(50); - VectorImageType::RegionType region{ start, size }; + const VectorImageType::RegionType region{ start, size }; vectorImage->SetVectorLength(VectorLength); vectorImage->SetRegions(region); vectorImage->Allocate(); vectorImage->FillBuffer(f); clock.Stop(); - double timeTaken = clock.GetMean(); + const double timeTaken = clock.GetMean(); std::cout << "Allocating an image of itk::VectorImage with pixels length " << VectorLength << " with image size " << size << " took " << timeTaken << " s." << std::endl; @@ -480,7 +480,7 @@ itkVectorImageTest(int, char * argv[]) { midCtr *= size[i]; } - VectorImageType::RegionType region(start, size); + const VectorImageType::RegionType region(start, size); vectorImage->SetVectorLength(VectorLength); vectorImage->SetRegions(region); vectorImage->Allocate(); @@ -490,7 +490,7 @@ itkVectorImageTest(int, char * argv[]) start[Dimension - 1] = 2; size.Fill(4); size[Dimension - 1] = 2; - VectorImageType::RegionType subRegion(start, size); + const VectorImageType::RegionType subRegion(start, size); using ImageRegionIteratorType = itk::ImageRegionIterator; ImageRegionIteratorType rit(vectorImage, subRegion); rit.GoToBegin(); @@ -508,7 +508,7 @@ itkVectorImageTest(int, char * argv[]) midCtr /= 2; while (!cit.IsAtEnd()) { - itk::VariableLengthVector value = cit.Get(); + const itk::VariableLengthVector value = cit.Get(); ++cit; if (ctr == midCtr) { @@ -583,10 +583,10 @@ itkVectorImageTest(int, char * argv[]) // Create an image using itk::Vector using VectorPixelType = itk::Vector; using VectorImageType = itk::Image, Dimension>; - auto image = VectorImageType::New(); - VectorImageType::IndexType start{}; - auto size = VectorImageType::SizeType::Filled(5); - VectorImageType::RegionType region(start, size); + auto image = VectorImageType::New(); + const VectorImageType::IndexType start{}; + auto size = VectorImageType::SizeType::Filled(5); + const VectorImageType::RegionType region(start, size); image->SetRegions(region); image->Allocate(); @@ -624,7 +624,7 @@ itkVectorImageTest(int, char * argv[]) reader->SetFileName(argv[1]); reader->Update(); - VectorImageType::Pointer vectorImage = reader->GetOutput(); + const VectorImageType::Pointer vectorImage = reader->GetOutput(); using IteratorType = itk::ImageRegionConstIteratorWithIndex; IteratorType cit(vectorImage, vectorImage->GetBufferedRegion()); @@ -783,8 +783,8 @@ itkVectorImageTest(int, char * argv[]) --cNit; auto offset = itk::MakeFilled(1); cNit -= offset; - itk::VariableLengthVector pixel = cNit.GetCenterPixel(); - itk::VariableLengthVector correctAnswer(VectorLength); + const itk::VariableLengthVector pixel = cNit.GetCenterPixel(); + itk::VariableLengthVector correctAnswer(VectorLength); correctAnswer.Fill(3); if (pixel != correctAnswer) { @@ -993,7 +993,7 @@ itkVectorImageTest(int, char * argv[]) sNit.ActivateOffset(offset1); sNit.SetLocation(location); - ShapedNeighborhoodIteratorType::Iterator shit = sNit.Begin(); + const ShapedNeighborhoodIteratorType::Iterator shit = sNit.Begin(); p[0] = p[3] = 10; p[1] = p[4] = 20; p[2] = p[5] = 30; diff --git a/Modules/Core/ImageAdaptors/test/itkVectorImageToImageAdaptorTest.cxx b/Modules/Core/ImageAdaptors/test/itkVectorImageToImageAdaptorTest.cxx index 9dd2e08ef32..0408c2d74d1 100644 --- a/Modules/Core/ImageAdaptors/test/itkVectorImageToImageAdaptorTest.cxx +++ b/Modules/Core/ImageAdaptors/test/itkVectorImageToImageAdaptorTest.cxx @@ -51,7 +51,7 @@ itkVectorImageToImageAdaptorTest(int, char *[]) start.Fill(0); size.Fill(50); - VectorImageType::RegionType region{ start, size }; + const VectorImageType::RegionType region{ start, size }; vectorImage->SetVectorLength(VectorLength); vectorImage->SetRegions(region); vectorImage->Allocate(); @@ -74,7 +74,7 @@ itkVectorImageToImageAdaptorTest(int, char *[]) adaptIt.GoToBegin(); while (!adaptIt.IsAtEnd()) { - PixelType pixelV = adaptIt.Get(); + const PixelType pixelV = adaptIt.Get(); if (itk::Math::NotAlmostEquals(pixelV, PixelType(componentToExtract))) { std::cout << "Wrong Pixel Value: adaptIt(" << adaptIt.GetIndex() << ") = " << adaptIt.Get() << std::endl; @@ -88,7 +88,7 @@ itkVectorImageToImageAdaptorTest(int, char *[]) auto index = VectorImageToImageAdaptorType::IndexType::Filled(10); ITK_TEST_EXPECT_EQUAL(PixelType(componentToExtract), vectorImageToImageAdaptor->GetPixel(index)); - PixelType v = 4.4f; + const PixelType v = 4.4f; vectorImageToImageAdaptor->SetPixel(index, v); ITK_TEST_EXPECT_EQUAL(v, vectorImageToImageAdaptor->GetPixel(index)); diff --git a/Modules/Core/ImageFunction/include/itkBSplineDecompositionImageFilter.hxx b/Modules/Core/ImageFunction/include/itkBSplineDecompositionImageFilter.hxx index 16605b30a73..2431b1cf2c7 100644 --- a/Modules/Core/ImageFunction/include/itkBSplineDecompositionImageFilter.hxx +++ b/Modules/Core/ImageFunction/include/itkBSplineDecompositionImageFilter.hxx @@ -200,9 +200,9 @@ BSplineDecompositionImageFilter::SetInitialCausalCoef else { // Full loop - double iz = 1.0 / z; - double z2n = std::pow(z, static_cast(m_DataLength[m_IteratorDirection] - 1L)); - CoeffType sum = m_Scratch[0] + z2n * m_Scratch[m_DataLength[m_IteratorDirection] - 1L]; + const double iz = 1.0 / z; + double z2n = std::pow(z, static_cast(m_DataLength[m_IteratorDirection] - 1L)); + CoeffType sum = m_Scratch[0] + z2n * m_Scratch[m_DataLength[m_IteratorDirection] - 1L]; z2n *= z2n * iz; for (unsigned int n = 1; n <= (m_DataLength[m_IteratorDirection] - 2); ++n) { @@ -230,11 +230,11 @@ template void BSplineDecompositionImageFilter::DataToCoefficientsND() { - OutputImagePointer output = this->GetOutput(); + const OutputImagePointer output = this->GetOutput(); Size size = output->GetBufferedRegion().GetSize(); - unsigned int count = output->GetBufferedRegion().GetNumberOfPixels() / size[0] * ImageDimension; + const unsigned int count = output->GetBufferedRegion().GetNumberOfPixels() / size[0] * ImageDimension; ProgressReporter progress(this, 0, count, 10); @@ -312,7 +312,7 @@ void BSplineDecompositionImageFilter::GenerateInputRequestedRegion() { // This filter requires all of the input image to be in the buffer - InputImagePointer inputPtr = const_cast(this->GetInput()); + const InputImagePointer inputPtr = const_cast(this->GetInput()); if (inputPtr) { @@ -337,7 +337,7 @@ void BSplineDecompositionImageFilter::GenerateData() { // Allocate scratch memory - InputImageConstPointer inputPtr = this->GetInput(); + const InputImageConstPointer inputPtr = this->GetInput(); m_DataLength = inputPtr->GetBufferedRegion().GetSize(); @@ -352,7 +352,7 @@ BSplineDecompositionImageFilter::GenerateData() m_Scratch.resize(maxLength); // Allocate memory for output image - OutputImagePointer outputPtr = this->GetOutput(); + const OutputImagePointer outputPtr = this->GetOutput(); outputPtr->SetBufferedRegion(outputPtr->GetRequestedRegion()); outputPtr->Allocate(); diff --git a/Modules/Core/ImageFunction/include/itkBSplineInterpolateImageFunction.hxx b/Modules/Core/ImageFunction/include/itkBSplineInterpolateImageFunction.hxx index a618b973364..6709ed23d53 100644 --- a/Modules/Core/ImageFunction/include/itkBSplineInterpolateImageFunction.hxx +++ b/Modules/Core/ImageFunction/include/itkBSplineInterpolateImageFunction.hxx @@ -49,7 +49,7 @@ BSplineInterpolateImageFunction::BSpl m_Coefficients = CoefficientImageType::New(); m_SplineOrder = 0; - unsigned int SplineOrder = 3; + const unsigned int SplineOrder = 3; this->SetSplineOrder(SplineOrder); } @@ -181,7 +181,7 @@ BSplineInterpolateImageFunction::SetI { for (unsigned int n = 0; n < ImageDimension; ++n) { - double w = x[n] - static_cast(EvaluateIndex[n][1]); + const double w = x[n] - static_cast(EvaluateIndex[n][1]); weights[n][3] = (1.0 / 6.0) * w * w * w; weights[n][0] = (1.0 / 6.0) + 0.5 * w * (w - 1.0) - weights[n][3]; weights[n][2] = w + weights[n][0] - 2.0 * weights[n][3]; @@ -201,7 +201,7 @@ BSplineInterpolateImageFunction::SetI { for (unsigned int n = 0; n < ImageDimension; ++n) { - double w = x[n] - static_cast(EvaluateIndex[n][0]); + const double w = x[n] - static_cast(EvaluateIndex[n][0]); weights[n][1] = w; weights[n][0] = 1.0 - w; } @@ -212,7 +212,7 @@ BSplineInterpolateImageFunction::SetI for (unsigned int n = 0; n < ImageDimension; ++n) { /* x */ - double w = x[n] - static_cast(EvaluateIndex[n][1]); + const double w = x[n] - static_cast(EvaluateIndex[n][1]); weights[n][1] = 0.75 - w * w; weights[n][2] = 0.5 * (w - weights[n][1] + 1.0); weights[n][0] = 1.0 - weights[n][1] - weights[n][2]; @@ -224,14 +224,14 @@ BSplineInterpolateImageFunction::SetI for (unsigned int n = 0; n < ImageDimension; ++n) { /* x */ - double w = x[n] - static_cast(EvaluateIndex[n][2]); - double w2 = w * w; - double t = (1.0 / 6.0) * w2; + const double w = x[n] - static_cast(EvaluateIndex[n][2]); + const double w2 = w * w; + const double t = (1.0 / 6.0) * w2; weights[n][0] = 0.5 - w; weights[n][0] *= weights[n][0]; weights[n][0] *= (1.0 / 24.0) * weights[n][0]; - double t0 = w * (t - 11.0 / 24.0); - double t1 = 19.0 / 96.0 + w2 * (0.25 - t); + const double t0 = w * (t - 11.0 / 24.0); + const double t1 = 19.0 / 96.0 + w2 * (0.25 - t); weights[n][1] = t1 + t0; weights[n][3] = t1 - t0; weights[n][4] = weights[n][0] + t0 + 0.5 * w; @@ -248,9 +248,9 @@ BSplineInterpolateImageFunction::SetI double w2 = w * w; weights[n][5] = (1.0 / 120.0) * w * w2 * w2; w2 -= w; - double w4 = w2 * w2; + const double w4 = w2 * w2; w -= 0.5; - double t = w2 * (w2 - 3.0); + const double t = w2 * (w2 - 3.0); weights[n][0] = (1.0 / 24.0) * (1.0 / 5.0 + w2 + w4) - weights[n][5]; double t0 = (1.0 / 24.0) * (w2 * (w2 - 5.0) + 46.0 / 5.0); double t1 = (-1.0 / 12.0) * w * (t + 4.0); @@ -289,7 +289,7 @@ BSplineInterpolateImageFunction::SetD // the number // of switch statement executions to one per routine call. // Left as is for now for readability. - int derivativeSplineOrder = static_cast(splineOrder) - 1; + const int derivativeSplineOrder = static_cast(splineOrder) - 1; switch (derivativeSplineOrder) { @@ -317,9 +317,9 @@ BSplineInterpolateImageFunction::SetD { for (unsigned int n = 0; n < ImageDimension; ++n) { - double w = x[n] + 0.5 - static_cast(EvaluateIndex[n][1]); + const double w = x[n] + 0.5 - static_cast(EvaluateIndex[n][1]); // w2 = w; - double w1 = 1.0 - w; + const double w1 = 1.0 - w; weights[n][0] = 0.0 - w1; weights[n][1] = w1 - w; @@ -331,10 +331,10 @@ BSplineInterpolateImageFunction::SetD { for (unsigned int n = 0; n < ImageDimension; ++n) { - double w = x[n] + .5 - static_cast(EvaluateIndex[n][2]); - double w2 = 0.75 - w * w; - double w3 = 0.5 * (w - w2 + 1.0); - double w1 = 1.0 - w2 - w3; + const double w = x[n] + .5 - static_cast(EvaluateIndex[n][2]); + const double w2 = 0.75 - w * w; + const double w3 = 0.5 * (w - w2 + 1.0); + const double w1 = 1.0 - w2 - w3; weights[n][0] = 0.0 - w1; weights[n][1] = w1 - w2; @@ -347,11 +347,11 @@ BSplineInterpolateImageFunction::SetD { for (unsigned int n = 0; n < ImageDimension; ++n) { - double w = x[n] + 0.5 - static_cast(EvaluateIndex[n][2]); - double w4 = (1.0 / 6.0) * w * w * w; - double w1 = (1.0 / 6.0) + 0.5 * w * (w - 1.0) - w4; - double w3 = w + w1 - 2.0 * w4; - double w2 = 1.0 - w1 - w3 - w4; + const double w = x[n] + 0.5 - static_cast(EvaluateIndex[n][2]); + const double w4 = (1.0 / 6.0) * w * w * w; + const double w1 = (1.0 / 6.0) + 0.5 * w * (w - 1.0) - w4; + const double w3 = w + w1 - 2.0 * w4; + const double w2 = 1.0 - w1 - w3 - w4; weights[n][0] = 0.0 - w1; weights[n][1] = w1 - w2; @@ -365,18 +365,18 @@ BSplineInterpolateImageFunction::SetD { for (unsigned int n = 0; n < ImageDimension; ++n) { - double w = x[n] + .5 - static_cast(EvaluateIndex[n][3]); - double t2 = w * w; - double t = (1.0 / 6.0) * t2; - double w1 = 0.5 - w; + const double w = x[n] + .5 - static_cast(EvaluateIndex[n][3]); + const double t2 = w * w; + const double t = (1.0 / 6.0) * t2; + double w1 = 0.5 - w; w1 *= w1; w1 *= (1.0 / 24.0) * w1; - double t0 = w * (t - 11.0 / 24.0); - double t1 = 19.0 / 96.0 + t2 * (0.25 - t); - double w2 = t1 + t0; - double w4 = t1 - t0; - double w5 = w1 + t0 + 0.5 * w; - double w3 = 1.0 - w1 - w2 - w4 - w5; + const double t0 = w * (t - 11.0 / 24.0); + const double t1 = 19.0 / 96.0 + t2 * (0.25 - t); + const double w2 = t1 + t0; + const double w4 = t1 - t0; + const double w5 = w1 + t0 + 0.5 * w; + const double w3 = 1.0 - w1 - w2 - w4 - w5; weights[n][0] = 0.0 - w1; weights[n][1] = w1 - w2; @@ -516,7 +516,7 @@ BSplineInterpolateImageFunction::Eval double w = 1.0; for (unsigned int n = 0; n < ImageDimension; ++n) { - unsigned int indx = m_PointsToIndex[p][n]; + const unsigned int indx = m_PointsToIndex[p][n]; w *= (weights)[n][indx]; coefficientIndex[n] = (evaluateIndex)[n][indx]; } @@ -558,11 +558,11 @@ BSplineInterpolateImageFunction:: { indx = m_PointsToIndex[p][n]; coefficientIndex[n] = (evaluateIndex)[n][indx]; - double tmpW = (weights)[n][indx]; + const double tmpW = (weights)[n][indx]; w *= tmpW; w1 *= tmpW; } - double tmpV = m_Coefficients->GetPixel(coefficientIndex); + const double tmpV = m_Coefficients->GetPixel(coefficientIndex); value += w * tmpV; derivativeValue[0] += w1 * tmpV; } @@ -575,7 +575,7 @@ BSplineInterpolateImageFunction:: double w1 = 1.0; for (unsigned int n1 = 0; n1 < ImageDimension; ++n1) { - unsigned int indx = m_PointsToIndex[p][n1]; + const unsigned int indx = m_PointsToIndex[p][n1]; coefficientIndex[n1] = (evaluateIndex)[n1][indx]; if (n1 == n) @@ -631,7 +631,7 @@ BSplineInterpolateImageFunction::Eval double tempValue = 1.0; for (unsigned int n1 = 0; n1 < ImageDimension; ++n1) { - unsigned int indx = m_PointsToIndex[p][n1]; + const unsigned int indx = m_PointsToIndex[p][n1]; coefficientIndex[n1] = (evaluateIndex)[n1][indx]; if (n1 == n) diff --git a/Modules/Core/ImageFunction/include/itkBinaryThresholdImageFunction.h b/Modules/Core/ImageFunction/include/itkBinaryThresholdImageFunction.h index 057f9cb773e..6d3ea990999 100644 --- a/Modules/Core/ImageFunction/include/itkBinaryThresholdImageFunction.h +++ b/Modules/Core/ImageFunction/include/itkBinaryThresholdImageFunction.h @@ -122,7 +122,7 @@ class ITK_TEMPLATE_EXPORT BinaryThresholdImageFunction : public ImageFunctionGetInputImage()->GetPixel(index); + const PixelType value = this->GetInputImage()->GetPixel(index); return (m_Lower <= value && value <= m_Upper); } diff --git a/Modules/Core/ImageFunction/include/itkCentralDifferenceImageFunction.hxx b/Modules/Core/ImageFunction/include/itkCentralDifferenceImageFunction.hxx index 5f745b7f8e6..567e8b75436 100644 --- a/Modules/Core/ImageFunction/include/itkCentralDifferenceImageFunction.hxx +++ b/Modules/Core/ImageFunction/include/itkCentralDifferenceImageFunction.hxx @@ -44,7 +44,7 @@ CentralDifferenceImageFunction::SetInputI // case can't be tested. if (inputData != nullptr) { - SizeValueType nComponents = OutputConvertType::GetNumberOfComponents(); + const SizeValueType nComponents = OutputConvertType::GetNumberOfComponents(); if (nComponents > 0) { if (nComponents != inputData->GetNumberOfComponentsPerPixel() * TInputImage::ImageDimension) @@ -273,7 +273,7 @@ CentralDifferenceImageFunction::EvaluateS const unsigned int MaxDims = Self::ImageDimension; for (unsigned int dim = 0; dim < MaxDims; ++dim) { - PointValueType offset = static_cast(0.5) * spacing[dim]; + const PointValueType offset = static_cast(0.5) * spacing[dim]; // Check the bounds using the point because the image direction may swap dimensions, // making checks in index space inaccurate. // If on a boundary, we set the derivative to zero. This is done to match the behavior @@ -295,7 +295,7 @@ CentralDifferenceImageFunction::EvaluateS continue; } - PointValueType delta = neighPoint2[dim] - neighPoint1[dim]; + const PointValueType delta = neighPoint2[dim] - neighPoint1[dim]; if (delta > 10.0 * NumericTraits::epsilon()) { orientedDerivative[dim] = @@ -341,7 +341,7 @@ CentralDifferenceImageFunction::EvaluateS bool dimOutOfBounds[Self::ImageDimension]; const unsigned int MaxDims = Self::ImageDimension; PointValueType delta[Self::ImageDimension]; - PixelType zeroPixel{}; + const PixelType zeroPixel{}; ScalarDerivativeType componentDerivativeOut; ScalarDerivativeType componentDerivative{}; @@ -366,7 +366,7 @@ CentralDifferenceImageFunction::EvaluateS // making checks in index space inaccurate. // If on a boundary, we set the derivative to zero. This is done to match the behavior // of EvaluateAtIndex. Another approach is to calculate the 1-sided difference. - PointValueType offset = static_cast(0.5) * spacing[dim]; + const PointValueType offset = static_cast(0.5) * spacing[dim]; neighPoint1[dim] = point[dim] - offset; neighPoint2[dim] = point[dim] + offset; dimOutOfBounds[dim] = (!this->IsInsideBuffer(neighPoint1) || !this->IsInsideBuffer(neighPoint2)); @@ -397,8 +397,8 @@ CentralDifferenceImageFunction::EvaluateS if (delta[dim] > 10.0 * NumericTraits::epsilon()) { - OutputValueType left = InputPixelConvertType::GetNthComponent(nc, neighPixels[dim][0]); - OutputValueType right = InputPixelConvertType::GetNthComponent(nc, neighPixels[dim][1]); + const OutputValueType left = InputPixelConvertType::GetNthComponent(nc, neighPixels[dim][0]); + const OutputValueType right = InputPixelConvertType::GetNthComponent(nc, neighPixels[dim][1]); componentDerivative[dim] = (left - right) / delta[dim]; } else @@ -520,7 +520,7 @@ CentralDifferenceImageFunction::EvaluateA PixelType neighPixels[Self::ImageDimension][2]; bool dimOutOfBounds[Self::ImageDimension]; const unsigned int MaxDims = Self::ImageDimension; - PixelType zeroPixel{}; + const PixelType zeroPixel{}; for (unsigned int dim = 0; dim < MaxDims; ++dim) { diff --git a/Modules/Core/ImageFunction/include/itkGaussianInterpolateImageFunction.hxx b/Modules/Core/ImageFunction/include/itkGaussianInterpolateImageFunction.hxx index fe0040fdc0f..39a3331416c 100644 --- a/Modules/Core/ImageFunction/include/itkGaussianInterpolateImageFunction.hxx +++ b/Modules/Core/ImageFunction/include/itkGaussianInterpolateImageFunction.hxx @@ -56,10 +56,10 @@ GaussianInterpolateImageFunction::ComputeBoundingBox() return; } - typename InputImageType::ConstPointer input = this->GetInputImage(); - typename InputImageType::SpacingType spacing = input->GetSpacing(); - typename InputImageType::IndexType index = input->GetLargestPossibleRegion().GetIndex(); - typename InputImageType::SizeType size = input->GetLargestPossibleRegion().GetSize(); + const typename InputImageType::ConstPointer input = this->GetInputImage(); + typename InputImageType::SpacingType spacing = input->GetSpacing(); + typename InputImageType::IndexType index = input->GetLargestPossibleRegion().GetIndex(); + typename InputImageType::SizeType size = input->GetLargestPossibleRegion().GetSize(); for (unsigned int d = 0; d < ImageDimension; ++d) { @@ -79,10 +79,10 @@ GaussianInterpolateImageFunction::ComputeInterpolation RegionType region = this->GetInputImage()->GetBufferedRegion(); for (unsigned int d = 0; d < ImageDimension; ++d) { - TCoordinate cBegin = cindex[d] + 0.5 - this->m_CutOffDistance[d]; - IndexValueType begin = std::max(region.GetIndex()[d], static_cast(std::floor(cBegin))); - TCoordinate cEnd = cindex[d] + 0.5 + this->m_CutOffDistance[d]; - SizeValueType end = + TCoordinate cBegin = cindex[d] + 0.5 - this->m_CutOffDistance[d]; + const IndexValueType begin = std::max(region.GetIndex()[d], static_cast(std::floor(cBegin))); + TCoordinate cEnd = cindex[d] + 0.5 + this->m_CutOffDistance[d]; + const SizeValueType end = std::min(region.GetIndex()[d] + region.GetSize()[d], static_cast(std::ceil(cEnd))); region.SetIndex(d, begin); region.SetSize(d, end - begin); @@ -99,7 +99,7 @@ GaussianInterpolateImageFunction::EvaluateAtContinuousI vnl_vector erfArray[ImageDimension]; vnl_vector gerfArray[ImageDimension]; - RegionType region = this->ComputeInterpolationRegion(cindex); + const RegionType region = this->ComputeInterpolationRegion(cindex); // Compute the ERF difference arrays for (unsigned int d = 0; d < ImageDimension; ++d) @@ -148,7 +148,7 @@ GaussianInterpolateImageFunction::EvaluateAtContinuousI } } } - RealType V = It.Get(); + const RealType V = It.Get(); sum_me += V * w; sum_m += w; if (grad) @@ -160,7 +160,7 @@ GaussianInterpolateImageFunction::EvaluateAtContinuousI } } } - RealType rc = sum_me / sum_m; + const RealType rc = sum_me / sum_m; if (grad) { @@ -199,11 +199,11 @@ GaussianInterpolateImageFunction::ComputeErrorFunctionA for (unsigned int i = 0; i < region.GetSize()[dimension]; ++i) { t += this->m_ScalingFactor[dimension]; - RealType e_now = vnl_erf(t); + const RealType e_now = vnl_erf(t); erfArray[i] = e_now - e_last; if (evaluateGradient) { - RealType g_now = itk::Math::two_over_sqrtpi * std::exp(-itk::Math::sqr(t)); + const RealType g_now = itk::Math::two_over_sqrtpi * std::exp(-itk::Math::sqr(t)); gerfArray[i] = g_now - g_last; g_last = g_now; } diff --git a/Modules/Core/ImageFunction/include/itkImageFunction.h b/Modules/Core/ImageFunction/include/itkImageFunction.h index b24f8ec114a..45ea240b867 100644 --- a/Modules/Core/ImageFunction/include/itkImageFunction.h +++ b/Modules/Core/ImageFunction/include/itkImageFunction.h @@ -179,7 +179,7 @@ class ITK_TEMPLATE_EXPORT ImageFunction : public FunctionBase erfArray[ImageDimension]; vnl_vector gerfArray[ImageDimension]; - typename Superclass::RegionType region = this->ComputeInterpolationRegion(cindex); + const typename Superclass::RegionType region = this->ComputeInterpolationRegion(cindex); // Compute the ERF difference arrays for (unsigned int d = 0; d < ImageDimension; ++d) diff --git a/Modules/Core/ImageFunction/include/itkMahalanobisDistanceThresholdImageFunction.hxx b/Modules/Core/ImageFunction/include/itkMahalanobisDistanceThresholdImageFunction.hxx index 47f56923247..4bdc9d01c64 100644 --- a/Modules/Core/ImageFunction/include/itkMahalanobisDistanceThresholdImageFunction.hxx +++ b/Modules/Core/ImageFunction/include/itkMahalanobisDistanceThresholdImageFunction.hxx @@ -83,7 +83,7 @@ template bool MahalanobisDistanceThresholdImageFunction::EvaluateAtIndex(const IndexType & index) const { - double mahalanobisDistance = this->EvaluateDistanceAtIndex(index); + const double mahalanobisDistance = this->EvaluateDistanceAtIndex(index); return (mahalanobisDistance <= m_Threshold); } @@ -104,7 +104,7 @@ double MahalanobisDistanceThresholdImageFunction::EvaluateDistanceAtIndex( const IndexType & index) const { - double mahalanobisDistanceSquared = + const double mahalanobisDistanceSquared = m_MahalanobisDistanceMembershipFunction->Evaluate(this->GetInputImage()->GetPixel(index)); double mahalanobisDistance; diff --git a/Modules/Core/ImageFunction/include/itkNeighborhoodBinaryThresholdImageFunction.hxx b/Modules/Core/ImageFunction/include/itkNeighborhoodBinaryThresholdImageFunction.hxx index a55aeb0c8ce..6ace6d7ea68 100644 --- a/Modules/Core/ImageFunction/include/itkNeighborhoodBinaryThresholdImageFunction.hxx +++ b/Modules/Core/ImageFunction/include/itkNeighborhoodBinaryThresholdImageFunction.hxx @@ -62,8 +62,8 @@ NeighborhoodBinaryThresholdImageFunction::EvaluateAtIn // Walk the neighborhood bool allInside = true; - PixelType lower = this->GetLower(); - PixelType upper = this->GetUpper(); + const PixelType lower = this->GetLower(); + const PixelType upper = this->GetUpper(); PixelType value; const unsigned int size = it.Size(); for (unsigned int i = 0; i < size; ++i) diff --git a/Modules/Core/ImageFunction/include/itkNeighborhoodOperatorImageFunction.hxx b/Modules/Core/ImageFunction/include/itkNeighborhoodOperatorImageFunction.hxx index 61ad848e762..0bb11d4a34c 100644 --- a/Modules/Core/ImageFunction/include/itkNeighborhoodOperatorImageFunction.hxx +++ b/Modules/Core/ImageFunction/include/itkNeighborhoodOperatorImageFunction.hxx @@ -40,7 +40,7 @@ template TOutput NeighborhoodOperatorImageFunction::EvaluateAtIndex(const IndexType & index) const { - NeighborhoodInnerProduct smartInnerProduct; + const NeighborhoodInnerProduct smartInnerProduct; const TInputImage * const image = this->GetInputImage(); assert(image != nullptr); diff --git a/Modules/Core/ImageFunction/include/itkRayCastInterpolateImageFunction.hxx b/Modules/Core/ImageFunction/include/itkRayCastInterpolateImageFunction.hxx index c146cfcd61a..0be1a116b1c 100644 --- a/Modules/Core/ImageFunction/include/itkRayCastInterpolateImageFunction.hxx +++ b/Modules/Core/ImageFunction/include/itkRayCastInterpolateImageFunction.hxx @@ -409,22 +409,22 @@ RayCastInterpolateImageFunction::RayCastHelper::CalcPl } // lines from one corner to another in x,y,z dirns - double line1x = m_BoundingCorner[c1][0] - m_BoundingCorner[c2][0]; - double line2x = m_BoundingCorner[c1][0] - m_BoundingCorner[c3][0]; + const double line1x = m_BoundingCorner[c1][0] - m_BoundingCorner[c2][0]; + const double line2x = m_BoundingCorner[c1][0] - m_BoundingCorner[c3][0]; - double line1y = m_BoundingCorner[c1][1] - m_BoundingCorner[c2][1]; - double line2y = m_BoundingCorner[c1][1] - m_BoundingCorner[c3][1]; + const double line1y = m_BoundingCorner[c1][1] - m_BoundingCorner[c2][1]; + const double line2y = m_BoundingCorner[c1][1] - m_BoundingCorner[c3][1]; - double line1z = m_BoundingCorner[c1][2] - m_BoundingCorner[c2][2]; - double line2z = m_BoundingCorner[c1][2] - m_BoundingCorner[c3][2]; + const double line1z = m_BoundingCorner[c1][2] - m_BoundingCorner[c2][2]; + const double line2z = m_BoundingCorner[c1][2] - m_BoundingCorner[c3][2]; // take cross product - double A = line1y * line2z - line2y * line1z; - double B = line2x * line1z - line1x * line2z; - double C = line1x * line2y - line2x * line1y; + const double A = line1y * line2z - line2y * line1z; + const double B = line2x * line1z - line1x * line2z; + const double C = line1x * line2y - line2x * line1y; // find constant - double D = -(A * m_BoundingCorner[c1][0] + B * m_BoundingCorner[c1][1] + C * m_BoundingCorner[c1][2]); + const double D = -(A * m_BoundingCorner[c1][0] + B * m_BoundingCorner[c1][1] + C * m_BoundingCorner[c1][2]); // initialise plane value and normalise m_BoundingPlane[j][0] = A / std::sqrt(A * A + B * B + C * C); @@ -755,9 +755,9 @@ void RayCastInterpolateImageFunction::RayCastHelper::CalcDirnVector() { // Calculate the number of voxels in each direction - double xNum = itk::Math::abs(m_RayVoxelStartPosition[0] - m_RayVoxelEndPosition[0]); - double yNum = itk::Math::abs(m_RayVoxelStartPosition[1] - m_RayVoxelEndPosition[1]); - double zNum = itk::Math::abs(m_RayVoxelStartPosition[2] - m_RayVoxelEndPosition[2]); + const double xNum = itk::Math::abs(m_RayVoxelStartPosition[0] - m_RayVoxelEndPosition[0]); + const double yNum = itk::Math::abs(m_RayVoxelStartPosition[1] - m_RayVoxelEndPosition[1]); + const double zNum = itk::Math::abs(m_RayVoxelStartPosition[2] - m_RayVoxelEndPosition[2]); // The direction iterated in is that with the greatest number of voxels // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1038,9 +1038,9 @@ template void RayCastInterpolateImageFunction::RayCastHelper::InitialiseVoxelPointers() { - int Ix = static_cast(m_RayVoxelStartPosition[0]); - int Iy = static_cast(m_RayVoxelStartPosition[1]); - int Iz = static_cast(m_RayVoxelStartPosition[2]); + const int Ix = static_cast(m_RayVoxelStartPosition[0]); + const int Iy = static_cast(m_RayVoxelStartPosition[1]); + const int Iz = static_cast(m_RayVoxelStartPosition[2]); m_RayIntersectionVoxelIndex[0] = Ix; m_RayIntersectionVoxelIndex[1] = Iy; @@ -1167,23 +1167,23 @@ template void RayCastInterpolateImageFunction::RayCastHelper::IncrementVoxelPointers() { - double xBefore = m_Position3Dvox[0].GetSum(); - double yBefore = m_Position3Dvox[1].GetSum(); - double zBefore = m_Position3Dvox[2].GetSum(); + const double xBefore = m_Position3Dvox[0].GetSum(); + const double yBefore = m_Position3Dvox[1].GetSum(); + const double zBefore = m_Position3Dvox[2].GetSum(); m_Position3Dvox[0] += m_VoxelIncrement[0]; m_Position3Dvox[1] += m_VoxelIncrement[1]; m_Position3Dvox[2] += m_VoxelIncrement[2]; - int dx = static_cast(m_Position3Dvox[0].GetSum()) - static_cast(xBefore); - int dy = static_cast(m_Position3Dvox[1].GetSum()) - static_cast(yBefore); - int dz = static_cast(m_Position3Dvox[2].GetSum()) - static_cast(zBefore); + const int dx = static_cast(m_Position3Dvox[0].GetSum()) - static_cast(xBefore); + const int dy = static_cast(m_Position3Dvox[1].GetSum()) - static_cast(yBefore); + const int dz = static_cast(m_Position3Dvox[2].GetSum()) - static_cast(zBefore); m_RayIntersectionVoxelIndex[0] += dx; m_RayIntersectionVoxelIndex[1] += dy; m_RayIntersectionVoxelIndex[2] += dz; - int totalRayVoxelPlanes = dx + dy * m_NumberOfVoxelsInX + dz * m_NumberOfVoxelsInX * m_NumberOfVoxelsInY; + const int totalRayVoxelPlanes = dx + dy * m_NumberOfVoxelsInX + dz * m_NumberOfVoxelsInX * m_NumberOfVoxelsInY; m_RayIntersectionVoxels[0] += totalRayVoxelPlanes; m_RayIntersectionVoxels[1] += totalRayVoxelPlanes; @@ -1203,10 +1203,10 @@ RayCastInterpolateImageFunction::RayCastHelper::GetCur { return 0; } - double a = static_cast(*m_RayIntersectionVoxels[0]); - double b = static_cast(*m_RayIntersectionVoxels[1] - a); - double c = static_cast(*m_RayIntersectionVoxels[2] - a); - double d = static_cast(*m_RayIntersectionVoxels[3] - a - b - c); + const double a = static_cast(*m_RayIntersectionVoxels[0]); + const double b = static_cast(*m_RayIntersectionVoxels[1] - a); + const double c = static_cast(*m_RayIntersectionVoxels[2] - a); + const double d = static_cast(*m_RayIntersectionVoxels[3] - a - b - c); double y; double z; @@ -1267,7 +1267,7 @@ RayCastInterpolateImageFunction::RayCastHelper::Integr for (m_NumVoxelPlanesTraversed = 0; m_NumVoxelPlanesTraversed < m_TotalRayVoxelPlanes; ++m_NumVoxelPlanesTraversed) { - double intensity = this->GetCurrentIntensity(); + const double intensity = this->GetCurrentIntensity(); if (intensity > threshold) { @@ -1388,9 +1388,9 @@ RayCastInterpolateImageFunction::Evaluate(const PointT { double integral = 0; - OutputPointType transformedFocalPoint = m_Transform->TransformPoint(m_FocalPoint); + const OutputPointType transformedFocalPoint = m_Transform->TransformPoint(m_FocalPoint); - DirectionType direction = transformedFocalPoint - point; + const DirectionType direction = transformedFocalPoint - point; RayCastInterpolateImageFunction::RayCastHelper ray; ray.SetImage(this->m_Image); diff --git a/Modules/Core/ImageFunction/include/itkVectorMeanImageFunction.hxx b/Modules/Core/ImageFunction/include/itkVectorMeanImageFunction.hxx index e7940e54cca..a303b0f719f 100644 --- a/Modules/Core/ImageFunction/include/itkVectorMeanImageFunction.hxx +++ b/Modules/Core/ImageFunction/include/itkVectorMeanImageFunction.hxx @@ -19,6 +19,7 @@ #define itkVectorMeanImageFunction_hxx #include "itkConstNeighborhoodIterator.h" +#include "itkMakeFilled.h" namespace itk { diff --git a/Modules/Core/ImageFunction/include/itkWindowedSincInterpolateImageFunction.hxx b/Modules/Core/ImageFunction/include/itkWindowedSincInterpolateImageFunction.hxx index cfb9088742e..fbf5460a377 100644 --- a/Modules/Core/ImageFunction/include/itkWindowedSincInterpolateImageFunction.hxx +++ b/Modules/Core/ImageFunction/include/itkWindowedSincInterpolateImageFunction.hxx @@ -67,12 +67,12 @@ WindowedSincInterpolateImageFunction::Filled(VRadius); // Initialize the neighborhood - IteratorType it(radius, image, image->GetBufferedRegion()); + const IteratorType it(radius, image, image->GetBufferedRegion()); // Compute the offset tables (we ignore all the zero indices // in the neighborhood) unsigned int iOffset = 0; - int empty = VRadius; + const int empty = VRadius; for (unsigned int iPos = 0; iPos < it.Size(); ++iPos) { // Get the offset (index) @@ -187,7 +187,7 @@ WindowedSincInterpolateImageFunction; using BSplineInterpolatorFunctionType = itk::BSplineInterpolateImageFunction; - unsigned int splineOrder = std::stoi(argv[1]); - BSplineInterpolatorFunctionType::Pointer interpolator = + const unsigned int splineOrder = std::stoi(argv[1]); + const BSplineInterpolatorFunctionType::Pointer interpolator = makeRandomImageInterpolator(splineOrder); - ImageType::ConstPointer randImage = interpolator->GetInputImage(); + const ImageType::ConstPointer randImage = interpolator->GetInputImage(); using FilterType = itk::BSplineDecompositionImageFilter; auto filter = FilterType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, BSplineDecompositionImageFilter, ImageToImageFilter); - itk::SimpleFilterWatcher watcher(filter, "BSplineDecompositionImageFilter"); + const itk::SimpleFilterWatcher watcher(filter, "BSplineDecompositionImageFilter"); filter->SetInput(randImage); - int unsupportedSplineOrder = 6; + const int unsupportedSplineOrder = 6; ITK_TRY_EXPECT_EXCEPTION(filter->SetSplineOrder(unsupportedSplineOrder)); @@ -113,11 +113,11 @@ itkBSplineDecompositionImageFilterTest(int argc, char * argv[]) ITK_TEST_EXPECT_EQUAL(filter->GetNumberOfPoles(), expectedSplinePoles.size()); FilterType::SplinePolesVectorType resultSplinePoles = filter->GetSplinePoles(); - double tolerance1 = 1e-10; + const double tolerance1 = 1e-10; for (unsigned int i = 0; i < resultSplinePoles.size(); ++i) { - FilterType::SplinePolesVectorType::value_type expectedSplinePole = expectedSplinePoles[i]; - FilterType::SplinePolesVectorType::value_type resultSplinePole = resultSplinePoles[i]; + const FilterType::SplinePolesVectorType::value_type expectedSplinePole = expectedSplinePoles[i]; + const FilterType::SplinePolesVectorType::value_type resultSplinePole = resultSplinePoles[i]; if (!itk::Math::FloatAlmostEqual(expectedSplinePole, resultSplinePole, 10, tolerance1)) { std::cerr.precision(static_cast(itk::Math::abs(std::log10(tolerance1)))); @@ -150,7 +150,7 @@ itkBSplineDecompositionImageFilterTest(int argc, char * argv[]) const double minValue = randImage->GetOrigin()[0]; const double maxValue = lastPhysicalLocation[0]; - double tolerance2 = 1e-5; + const double tolerance2 = 1e-5; for (unsigned int k = 0; k < 10; ++k) { ResampleFunctionType::PointType point; diff --git a/Modules/Core/ImageFunction/test/itkBSplineInterpolateImageFunctionTest.cxx b/Modules/Core/ImageFunction/test/itkBSplineInterpolateImageFunctionTest.cxx index a6e64f564e0..6a80b830594 100644 --- a/Modules/Core/ImageFunction/test/itkBSplineInterpolateImageFunctionTest.cxx +++ b/Modules/Core/ImageFunction/test/itkBSplineInterpolateImageFunctionTest.cxx @@ -135,7 +135,7 @@ TestGeometricPoint(const TInterpolator * interp, const PointType & point, bool i std::cout << " Point: " << point; - bool bvalue = interp->IsInsideBuffer(point); + const bool bvalue = interp->IsInsideBuffer(point); std::cout << " Inside: " << bvalue << ' '; if (bvalue != isInside) @@ -146,7 +146,7 @@ TestGeometricPoint(const TInterpolator * interp, const PointType & point, bool i if (isInside) { - double value = interp->Evaluate(point); + const double value = interp->Evaluate(point); std::cout << " Value: " << value; if (itk::Math::abs(value - trueValue) > 1e-9) @@ -171,7 +171,7 @@ TestContinuousIndex(const TInterpolator * interp, const ContinuousIndexType & in std::cout << " Index: " << index; - bool bvalue = interp->IsInsideBuffer(index); + const bool bvalue = interp->IsInsideBuffer(index); std::cout << " Inside: " << bvalue; if (bvalue != isInside) @@ -182,7 +182,7 @@ TestContinuousIndex(const TInterpolator * interp, const ContinuousIndexType & in if (isInside) { - double value = interp->EvaluateAtContinuousIndex(index); + const double value = interp->EvaluateAtContinuousIndex(index); std::cout << " Value: " << value; if (itk::Math::abs(value - trueValue) > 1e-4) @@ -209,7 +209,7 @@ TestContinuousIndexDerivative(const TInterpolator * interp, std::cout << " Index: " << index; - bool bvalue = interp->IsInsideBuffer(index); + const bool bvalue = interp->IsInsideBuffer(index); std::cout << " Inside: " << bvalue << '\n'; if (bvalue != isInside) @@ -221,7 +221,7 @@ TestContinuousIndexDerivative(const TInterpolator * interp, if (isInside) { typename TInterpolator::CovariantVectorType value; - double value2 = interp->EvaluateAtContinuousIndex(index); + const double value2 = interp->EvaluateAtContinuousIndex(index); std::cout << "Interpolated Value: " << value2 << '\n'; value = interp->EvaluateDerivativeAtContinuousIndex(index); std::cout << " Value: "; @@ -252,7 +252,7 @@ test1DCubicSpline() int flag = 0; // Allocate a simple test image - ImageTypePtr1D image = ImageType1D::New(); + const ImageTypePtr1D image = ImageType1D::New(); set1DInterpData(image); @@ -268,11 +268,11 @@ test1DCubicSpline() ITK_EXERCISE_BASIC_OBJECT_METHODS(interp, BSplineInterpolateImageFunction, InterpolateImageFunction); - itk::ThreadIdType numberOfWorkUnits = 1; + const itk::ThreadIdType numberOfWorkUnits = 1; interp->SetNumberOfWorkUnits(numberOfWorkUnits); ITK_TEST_SET_GET_VALUE(numberOfWorkUnits, interp->GetNumberOfWorkUnits()); - bool useImageDirection = true; + const bool useImageDirection = true; ITK_TEST_SET_GET_BOOLEAN(interp, UseImageDirection, useImageDirection); interp->SetInputImage(image); @@ -291,9 +291,9 @@ test1DCubicSpline() // 3) integer value // 4) outside image #define NPOINTS 5 // number of points - itk::SpacePrecisionType darray1[NPOINTS] = { 1.4, 8.9, 10.0, 40.0, -0.3 }; - double truth[NPOINTS] = { 334.41265437584, 18.158173426944, 4.0000, 0, 442.24157192006658 }; - bool b_Inside[NPOINTS] = { true, true, true, false, true }; + const itk::SpacePrecisionType darray1[NPOINTS] = { 1.4, 8.9, 10.0, 40.0, -0.3 }; + const double truth[NPOINTS] = { 334.41265437584, 18.158173426944, 4.0000, 0, 442.24157192006658 }; + const bool b_Inside[NPOINTS] = { true, true, true, false, true }; // an integer position inside the image for (int ii = 0; ii < NPOINTS; ++ii) @@ -325,7 +325,7 @@ test2DSpline() int flag = 0; /* Allocate a simple test image */ - ImageTypePtr2D image = ImageType2D::New(); + const ImageTypePtr2D image = ImageType2D::New(); set2DInterpData(image); @@ -406,7 +406,7 @@ test3DSpline() int flag = 0; /* Allocate a simple test image */ - ImageTypePtr3D image = ImageType3D::New(); + const ImageTypePtr3D image = ImageType3D::New(); set3DInterpData(image); @@ -483,7 +483,7 @@ test3DSplineDerivative() int flag = 0; /* Allocate a simple test image */ - ImageTypePtr3D image = ImageType3D::New(); + const ImageTypePtr3D image = ImageType3D::New(); set3DDerivativeData(image); @@ -631,8 +631,8 @@ testEvaluateValueAndDerivative() using ImageType = itk::Image; using BSplineInterpolatorFunctionType = itk::BSplineInterpolateImageFunction; - constexpr unsigned int SplineOrder = 3; - BSplineInterpolatorFunctionType::Pointer interpolator = + constexpr unsigned int SplineOrder = 3; + const BSplineInterpolatorFunctionType::Pointer interpolator = makeRandomImageInterpolator(SplineOrder); /** Test the EvaluateDerivative and EvaluateValueAndDerivative functions **/ @@ -699,7 +699,7 @@ void set1DInterpData(ImageType1D::Pointer imgPtr) { - SizeType1D size = { { 36 } }; + const SizeType1D size = { { 36 } }; constexpr double mydata[36] = { 454.0000, 369.4000, 295.2000, 230.8000, 175.6000, 129.0000, 90.4000, 59.2000, 34.8000, 16.6000, 4.0000, -3.6000, -6.8000, -6.2000, -2.4000, 4.0000, 12.4000, 22.2000, 32.8000, 43.6000, 54.0000, 63.4000, 71.2000, 76.8000, @@ -729,7 +729,7 @@ set1DInterpData(ImageType1D::Pointer imgPtr) void set2DInterpData(ImageType2D::Pointer imgPtr) { - SizeType2D size = { { 7, 7 } }; + const SizeType2D size = { { 7, 7 } }; constexpr double mydata[49] = { 154.5000, 82.4000, 30.9000, 0, -10.3000, 0, 30.9000, 117.0000, 62.4000, 23.4000, 0, -7.8000, 0, 23.4000, 18.0000, 9.6000, 3.6000, 0, -1.2000, 0, 3.6000, -120.0000, -64.0000, -24.0000, 0, 8.0000, 0, -24.0000, @@ -739,7 +739,7 @@ set2DInterpData(ImageType2D::Pointer imgPtr) auto index = ImageType2D::IndexType::Filled(10); - ImageType2D::RegionType region{ index, size }; + const ImageType2D::RegionType region{ index, size }; imgPtr->SetRegions(region); imgPtr->Allocate(); @@ -785,16 +785,16 @@ set3DDerivativeData(ImageType3D::Pointer imgPtr) for (unsigned int slice = 0; slice < size[2]; ++slice) { index[2] = slice; - double slice1 = slice - 20.0; // Center offset + const double slice1 = slice - 20.0; // Center offset for (unsigned int row = 0; row < size[1]; ++row) { index[1] = row; - double row1 = row - 20.0; // Center + const double row1 = row - 20.0; // Center for (unsigned int col = 0; col < size[0]; ++col) { index[0] = col; - double col1 = col - 20.0; // Center - double value = 0.1 * col1 * col1 * col1 * col1 - 0.5 * col1 * col1 * col1 + 2.0 * col1 - 43.0; + const double col1 = col - 20.0; // Center + double value = 0.1 * col1 * col1 * col1 * col1 - 0.5 * col1 * col1 * col1 + 2.0 * col1 - 43.0; value += 5.0 * row1 + 7.0; value += -2.0 * slice1 * slice1 - 6.0 * slice1 + 10.0; imgPtr->SetPixel(index, value); diff --git a/Modules/Core/ImageFunction/test/itkBSplineResampleImageFunctionTest.cxx b/Modules/Core/ImageFunction/test/itkBSplineResampleImageFunctionTest.cxx index f75df5349d5..2400ed5c893 100644 --- a/Modules/Core/ImageFunction/test/itkBSplineResampleImageFunctionTest.cxx +++ b/Modules/Core/ImageFunction/test/itkBSplineResampleImageFunctionTest.cxx @@ -42,14 +42,14 @@ itkBSplineResampleImageFunctionTest(int, char *[]) using ImageType = itk::Image; using BSplineInterpolatorFunctionType = itk::BSplineInterpolateImageFunction; - constexpr unsigned int SplineOrder = 3; - BSplineInterpolatorFunctionType::Pointer interpolator = + constexpr unsigned int SplineOrder = 3; + const BSplineInterpolatorFunctionType::Pointer interpolator = makeRandomImageInterpolator(SplineOrder); - ImageType::ConstPointer randImage = interpolator->GetInputImage(); + const ImageType::ConstPointer randImage = interpolator->GetInputImage(); using FilterType = itk::BSplineDecompositionImageFilter; - auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter, "filter"); + auto filter = FilterType::New(); + const itk::SimpleFilterWatcher watcher(filter, "filter"); filter->SetSplineOrder(interpolator->GetSplineOrder()); filter->SetInput(randImage); diff --git a/Modules/Core/ImageFunction/test/itkCentralDifferenceImageFunctionOnVectorSpeedTest.cxx b/Modules/Core/ImageFunction/test/itkCentralDifferenceImageFunctionOnVectorSpeedTest.cxx index 166fdacb2ef..7ac17917d41 100644 --- a/Modules/Core/ImageFunction/test/itkCentralDifferenceImageFunctionOnVectorSpeedTest.cxx +++ b/Modules/Core/ImageFunction/test/itkCentralDifferenceImageFunctionOnVectorSpeedTest.cxx @@ -24,11 +24,11 @@ template int itkCentralDifferenceImageFunctionOnVectorSpeedTestRun(char * argv[]) { - int imageSize = std::stoi(argv[1]); - int reps = std::stoi(argv[2]); - bool doEAI = std::stoi(argv[3]); - bool doEACI = std::stoi(argv[4]); - bool doE = std::stoi(argv[5]); + const int imageSize = std::stoi(argv[1]); + const int reps = std::stoi(argv[2]); + const bool doEAI = std::stoi(argv[3]); + const bool doEACI = std::stoi(argv[4]); + const bool doE = std::stoi(argv[5]); std::cout << "imageSize: " << imageSize << " reps: " << reps << " doEAI, doEACI, doE: " << doEAI << ", " << doEACI << ", " << doE << std::endl; @@ -38,9 +38,9 @@ itkCentralDifferenceImageFunctionOnVectorSpeedTestRun(char * argv[]) using PixelType = itk::Vector; using ImageType = itk::Image; - auto image = ImageType::New(); - auto size = ImageType::SizeType::Filled(imageSize); - typename ImageType::RegionType region(size); + auto image = ImageType::New(); + auto size = ImageType::SizeType::Filled(imageSize); + const typename ImageType::RegionType region(size); image->SetRegions(region); image->Allocate(); @@ -99,7 +99,7 @@ itkCentralDifferenceImageFunctionOnVectorSpeedTestRun(char * argv[]) typename FunctionType::ContinuousIndexType cindex; cindex[0] = index[0] + 0.1; cindex[1] = index[1] + 0.1; - OutputType continuousIndexOutput = function->EvaluateAtContinuousIndex(cindex); + const OutputType continuousIndexOutput = function->EvaluateAtContinuousIndex(cindex); total += continuousIndexOutput; } @@ -107,7 +107,7 @@ itkCentralDifferenceImageFunctionOnVectorSpeedTestRun(char * argv[]) { typename FunctionType::PointType point; image->TransformIndexToPhysicalPoint(index, point); - OutputType pointOutput = function->Evaluate(point); + const OutputType pointOutput = function->Evaluate(point); total += pointOutput; } @@ -128,7 +128,7 @@ itkCentralDifferenceImageFunctionOnVectorSpeedTest(int argc, char * argv[]) << std::endl; return EXIT_FAILURE; } - int vecLength = std::stoi(argv[6]); + const int vecLength = std::stoi(argv[6]); switch (vecLength) { diff --git a/Modules/Core/ImageFunction/test/itkCentralDifferenceImageFunctionOnVectorTest.cxx b/Modules/Core/ImageFunction/test/itkCentralDifferenceImageFunctionOnVectorTest.cxx index 0461b3bbfdf..9f702326992 100644 --- a/Modules/Core/ImageFunction/test/itkCentralDifferenceImageFunctionOnVectorTest.cxx +++ b/Modules/Core/ImageFunction/test/itkCentralDifferenceImageFunctionOnVectorTest.cxx @@ -52,9 +52,9 @@ itkCentralDifferenceImageFunctionOnVectorTestRun() using PixelType = itk::Vector; using ImageType = itk::Image; - auto image = ImageType::New(); - auto size = ImageType::SizeType::Filled(16); - typename ImageType::RegionType region(size); + auto image = ImageType::New(); + auto size = ImageType::SizeType::Filled(16); + const typename ImageType::RegionType region(size); image->SetRegions(region); image->Allocate(); diff --git a/Modules/Core/ImageFunction/test/itkCentralDifferenceImageFunctionSpeedTest.cxx b/Modules/Core/ImageFunction/test/itkCentralDifferenceImageFunctionSpeedTest.cxx index e74d4b01e1a..1432b37dbe7 100644 --- a/Modules/Core/ImageFunction/test/itkCentralDifferenceImageFunctionSpeedTest.cxx +++ b/Modules/Core/ImageFunction/test/itkCentralDifferenceImageFunctionSpeedTest.cxx @@ -29,11 +29,11 @@ itkCentralDifferenceImageFunctionSpeedTest(int argc, char * argv[]) return EXIT_FAILURE; } - int imageSize = std::stoi(argv[1]); - int reps = std::stoi(argv[2]); - bool doEAI = std::stoi(argv[3]); - bool doEACI = std::stoi(argv[4]); - bool doE = std::stoi(argv[5]); + const int imageSize = std::stoi(argv[1]); + const int reps = std::stoi(argv[2]); + const bool doEAI = std::stoi(argv[3]); + const bool doEACI = std::stoi(argv[4]); + const bool doE = std::stoi(argv[5]); std::cout << "imageSize: " << imageSize << " reps: " << reps << " doEAI, doEACI, doE: " << doEAI << ", " << doEACI << ", " << doE << std::endl; @@ -42,9 +42,9 @@ itkCentralDifferenceImageFunctionSpeedTest(int argc, char * argv[]) using PixelType = unsigned int; using ImageType = itk::Image; - auto image = ImageType::New(); - auto size = ImageType::SizeType::Filled(imageSize); - ImageType::RegionType region(size); + auto image = ImageType::New(); + auto size = ImageType::SizeType::Filled(imageSize); + const ImageType::RegionType region(size); image->SetRegions(region); image->Allocate(); @@ -86,7 +86,7 @@ itkCentralDifferenceImageFunctionSpeedTest(int argc, char * argv[]) index = iter.GetIndex(); if (doEAI) { - OutputType indexOutput = function->EvaluateAtIndex(index); + const OutputType indexOutput = function->EvaluateAtIndex(index); total += indexOutput; } @@ -95,7 +95,7 @@ itkCentralDifferenceImageFunctionSpeedTest(int argc, char * argv[]) FunctionType::ContinuousIndexType cindex; cindex[0] = index[0] + 0.1; cindex[1] = index[1] + 0.1; - OutputType continuousIndexOutput = function->EvaluateAtContinuousIndex(cindex); + const OutputType continuousIndexOutput = function->EvaluateAtContinuousIndex(cindex); total += continuousIndexOutput; } @@ -103,7 +103,7 @@ itkCentralDifferenceImageFunctionSpeedTest(int argc, char * argv[]) { FunctionType::PointType point; image->TransformIndexToPhysicalPoint(index, point); - OutputType pointOutput = function->Evaluate(point); + const OutputType pointOutput = function->Evaluate(point); total += pointOutput; } diff --git a/Modules/Core/ImageFunction/test/itkCentralDifferenceImageFunctionTest.cxx b/Modules/Core/ImageFunction/test/itkCentralDifferenceImageFunctionTest.cxx index a9d26a93481..20aa2d990e4 100644 --- a/Modules/Core/ImageFunction/test/itkCentralDifferenceImageFunctionTest.cxx +++ b/Modules/Core/ImageFunction/test/itkCentralDifferenceImageFunctionTest.cxx @@ -30,9 +30,9 @@ itkCentralDifferenceImageFunctionTest(int, char *[]) using PixelType = unsigned int; using ImageType = itk::Image; - auto image = ImageType::New(); - auto size = ImageType::SizeType::Filled(16); - ImageType::RegionType region(size); + auto image = ImageType::New(); + auto size = ImageType::SizeType::Filled(16); + const ImageType::RegionType region(size); image->SetRegions(region); image->Allocate(); @@ -295,10 +295,10 @@ itkCentralDifferenceImageFunctionTest(int, char *[]) // with image direction disabled, result should be same as with // identity direction - bool useImageDirection = false; + const bool useImageDirection = false; ITK_TEST_SET_GET_BOOLEAN(function, UseImageDirection, useImageDirection); - OutputType directionOffDerivative = function->Evaluate(point); + const OutputType directionOffDerivative = function->Evaluate(point); std::cout << "Point: " << point << " directionOffDerivative: " << directionOffDerivative << std::endl; if (directionOffDerivative != origDerivative) diff --git a/Modules/Core/ImageFunction/test/itkCovarianceImageFunctionTest.cxx b/Modules/Core/ImageFunction/test/itkCovarianceImageFunctionTest.cxx index d8982df8697..f7bc213d935 100644 --- a/Modules/Core/ImageFunction/test/itkCovarianceImageFunctionTest.cxx +++ b/Modules/Core/ImageFunction/test/itkCovarianceImageFunctionTest.cxx @@ -43,7 +43,7 @@ itkCovarianceImageFunctionTest(int, char *[]) size[1] = 20; size[2] = 20; - ImageType::IndexValueType imageValue = 0; + const ImageType::IndexValueType imageValue = 0; start.Fill(imageValue); region.SetIndex(start); @@ -66,7 +66,7 @@ itkCovarianceImageFunctionTest(int, char *[]) function->SetInputImage(image); - unsigned int neighborhoodRadius = 5; + const unsigned int neighborhoodRadius = 5; function->SetNeighborhoodRadius(neighborhoodRadius); ITK_TEST_SET_GET_VALUE(neighborhoodRadius, function->GetNeighborhoodRadius()); diff --git a/Modules/Core/ImageFunction/test/itkGaussianBlurImageFunctionTest.cxx b/Modules/Core/ImageFunction/test/itkGaussianBlurImageFunctionTest.cxx index a1da8c8d4c0..ccfacee5828 100644 --- a/Modules/Core/ImageFunction/test/itkGaussianBlurImageFunctionTest.cxx +++ b/Modules/Core/ImageFunction/test/itkGaussianBlurImageFunctionTest.cxx @@ -120,11 +120,11 @@ itkGaussianBlurImageFunctionTest(int, char *[]) // Testing Set/GetMaximumKernelWidth() { std::cout << "Testing Set/GetMaximumKernelWidth(): "; - int setKernelWidth = 47; + const int setKernelWidth = 47; gaussianFunction->SetMaximumKernelWidth(setKernelWidth); - int readKernelWidth = gaussianFunction->GetMaximumKernelWidth(); + const int readKernelWidth = gaussianFunction->GetMaximumKernelWidth(); if (readKernelWidth != setKernelWidth) { diff --git a/Modules/Core/ImageFunction/test/itkGaussianDerivativeImageFunctionTest.cxx b/Modules/Core/ImageFunction/test/itkGaussianDerivativeImageFunctionTest.cxx index e871fecfb3e..1cb728c7a93 100644 --- a/Modules/Core/ImageFunction/test/itkGaussianDerivativeImageFunctionTest.cxx +++ b/Modules/Core/ImageFunction/test/itkGaussianDerivativeImageFunctionTest.cxx @@ -59,7 +59,7 @@ TestGaussianDerivativeImageFunction() using DoGFunctionType = itk::GaussianDerivativeImageFunction; auto DoG = DoGFunctionType::New(); - bool useImageSpacing = true; + const bool useImageSpacing = true; ITK_TEST_SET_GET_BOOLEAN(DoG, UseImageSpacing, useImageSpacing); DoG->SetInputImage(image); diff --git a/Modules/Core/ImageFunction/test/itkGaussianInterpolateImageFunctionTest.cxx b/Modules/Core/ImageFunction/test/itkGaussianInterpolateImageFunctionTest.cxx index dca4ddfb6b6..9d949c006d4 100644 --- a/Modules/Core/ImageFunction/test/itkGaussianInterpolateImageFunctionTest.cxx +++ b/Modules/Core/ImageFunction/test/itkGaussianInterpolateImageFunctionTest.cxx @@ -36,17 +36,17 @@ itkGaussianInterpolateImageFunctionTest(int, char *[]) interpolator->SetSigma(sigma); ITK_TEST_SET_GET_VALUE(sigma, interpolator->GetSigma()); - InterpolatorType::RealType alpha = 1.0; + const InterpolatorType::RealType alpha = 1.0; interpolator->SetAlpha(alpha); ITK_TEST_SET_GET_VALUE(alpha, interpolator->GetAlpha()); auto image = ImageType::New(); - ImageType::IndexType start{}; + const ImageType::IndexType start{}; auto size = ImageType::SizeType::Filled(3); - ImageType::RegionType region{ start, size }; + const ImageType::RegionType region{ start, size }; image->SetRegions(region); image->Allocate(); @@ -88,7 +88,7 @@ itkGaussianInterpolateImageFunctionTest(int, char *[]) for (unsigned int j = 0; j < 5; ++j) { - InterpolatorType::OutputType computedValue = interpolator->Evaluate(point); + const InterpolatorType::OutputType computedValue = interpolator->Evaluate(point); if (!itk::Math::FloatAlmostEqual(computedValue, expectedValue[j], 7, 5e-6)) { diff --git a/Modules/Core/ImageFunction/test/itkImageAdaptorInterpolateImageFunctionTest.cxx b/Modules/Core/ImageFunction/test/itkImageAdaptorInterpolateImageFunctionTest.cxx index 2ae68554502..e94b120ff62 100644 --- a/Modules/Core/ImageFunction/test/itkImageAdaptorInterpolateImageFunctionTest.cxx +++ b/Modules/Core/ImageFunction/test/itkImageAdaptorInterpolateImageFunctionTest.cxx @@ -78,7 +78,7 @@ TestGeometricPoint(const InterpolatorType * interp, const PointType & point, boo if (isInside) { - OutputType value = interp->Evaluate(point); + const OutputType value = interp->Evaluate(point); std::cout << " Value: " << value << std::endl; if (itk::Math::abs(value - trueValue) > 1e-9) @@ -117,7 +117,7 @@ TestContinuousIndex(const InterpolatorType * interp, if (isInside) { - OutputType value = interp->EvaluateAtContinuousIndex(index); + const OutputType value = interp->EvaluateAtContinuousIndex(index); std::cout << " Value: " << value << std::endl; if (itk::Math::abs(value - trueValue) > 1e-9) @@ -152,9 +152,9 @@ itkImageAdaptorInterpolateImageFunctionTest(int, char *[]) const unsigned int ImageDimension = ImageAdaptorInterpolate::ImageDimension; - ImageType::SizeType size = { { 20, 40, 80 } }; - double origin[3] = { 0.5, 0.5, 0.5 }; - double spacing[3] = { 0.1, 0.05, 0.025 }; + const ImageType::SizeType size = { { 20, 40, 80 } }; + double origin[3] = { 0.5, 0.5, 0.5 }; + double spacing[3] = { 0.1, 0.05, 0.025 }; // Create a test image @@ -217,7 +217,7 @@ itkImageAdaptorInterpolateImageFunctionTest(int, char *[]) // an integer position inside the image { itk::SpacePrecisionType darray[3] = { 10, 20, 40 }; - double temp = 70.0; + const double temp = 70.0; output = OutputType(temp); cindex = ContinuousIndexType(darray); passed = ImageAdaptorInterpolate::TestContinuousIndex(interp, cindex, true, output); @@ -239,7 +239,7 @@ itkImageAdaptorInterpolateImageFunctionTest(int, char *[]) // position at the image border { itk::SpacePrecisionType darray[3] = { 0, 20, 40 }; - double temp = 60.0; + const double temp = 60.0; output = OutputType(temp); cindex = ContinuousIndexType(darray); passed = ImageAdaptorInterpolate::TestContinuousIndex(interp, cindex, true, output); @@ -260,9 +260,9 @@ itkImageAdaptorInterpolateImageFunctionTest(int, char *[]) // position near image border { - itk::SpacePrecisionType epsilon = 1.0e-10; - itk::SpacePrecisionType darray[3] = { 19 - epsilon, 20, 40 }; - double temp = 79.0; + const itk::SpacePrecisionType epsilon = 1.0e-10; + itk::SpacePrecisionType darray[3] = { 19 - epsilon, 20, 40 }; + const double temp = 79.0; output = OutputType(temp); cindex = ContinuousIndexType(darray); passed = ImageAdaptorInterpolate::TestContinuousIndex(interp, cindex, true, output); @@ -284,7 +284,7 @@ itkImageAdaptorInterpolateImageFunctionTest(int, char *[]) // position outside the image { itk::SpacePrecisionType darray[3] = { 20, 20, 40 }; - double temp = 1.0; + const double temp = 1.0; output = OutputType(temp); cindex = ContinuousIndexType(darray); passed = ImageAdaptorInterpolate::TestContinuousIndex(interp, cindex, false, output); @@ -306,7 +306,7 @@ itkImageAdaptorInterpolateImageFunctionTest(int, char *[]) // at non-integer position { itk::SpacePrecisionType darray[3] = { 5.25, 12.5, 42.0 }; - double temp = 59.75; + const double temp = 59.75; output = OutputType(temp); cindex = ContinuousIndexType(darray); passed = ImageAdaptorInterpolate::TestContinuousIndex(interp, cindex, true, output); diff --git a/Modules/Core/ImageFunction/test/itkInterpolateTest.cxx b/Modules/Core/ImageFunction/test/itkInterpolateTest.cxx index cda7b45935e..e8c46514505 100644 --- a/Modules/Core/ImageFunction/test/itkInterpolateTest.cxx +++ b/Modules/Core/ImageFunction/test/itkInterpolateTest.cxx @@ -53,7 +53,7 @@ TestGeometricPoint(const TInterpolator * interp, const PointType & point, bool i std::cout << " Point: " << point; - bool bvalue = interp->IsInsideBuffer(point); + const bool bvalue = interp->IsInsideBuffer(point); std::cout << " Inside: " << bvalue; if (bvalue != isInside) @@ -64,7 +64,7 @@ TestGeometricPoint(const TInterpolator * interp, const PointType & point, bool i if (isInside) { - double value = interp->Evaluate(point); + const double value = interp->Evaluate(point); std::cout << " Value: " << value; if (itk::Math::abs(value - trueValue) > 1e-9) @@ -89,7 +89,7 @@ TestContinuousIndex(const TInterpolator * interp, const ContinuousIndexType & in std::cout << " Index: " << index; - bool bvalue = interp->IsInsideBuffer(index); + const bool bvalue = interp->IsInsideBuffer(index); std::cout << " Inside: " << bvalue; if (bvalue != isInside) @@ -100,7 +100,7 @@ TestContinuousIndex(const TInterpolator * interp, const ContinuousIndexType & in if (isInside) { - double value = interp->EvaluateAtContinuousIndex(index); + const double value = interp->EvaluateAtContinuousIndex(index); std::cout << " Value: " << value; if (itk::Math::abs(value - trueValue) > 1e-9) @@ -210,8 +210,8 @@ itkInterpolateTest(int, char *[]) } // position near image border - itk::SpacePrecisionType epsilon = 1.0e-10; - itk::SpacePrecisionType darray3[3] = { 19 - epsilon, 20, 40 }; + const itk::SpacePrecisionType epsilon = 1.0e-10; + itk::SpacePrecisionType darray3[3] = { 19 - epsilon, 20, 40 }; cindex = ContinuousIndexType(darray3); passed = TestContinuousIndex(interp, cindex, true, 79); diff --git a/Modules/Core/ImageFunction/test/itkLabelImageGaussianInterpolateImageFunctionTest.cxx b/Modules/Core/ImageFunction/test/itkLabelImageGaussianInterpolateImageFunctionTest.cxx index 2079d2110f1..308b784bb99 100644 --- a/Modules/Core/ImageFunction/test/itkLabelImageGaussianInterpolateImageFunctionTest.cxx +++ b/Modules/Core/ImageFunction/test/itkLabelImageGaussianInterpolateImageFunctionTest.cxx @@ -43,7 +43,7 @@ itkLabelImageGaussianInterpolateImageFunctionTest(int, char *[]) { RegionType region; { - IndexType start{}; + const IndexType start{}; SizeType size; size[0] = small_xSize; @@ -69,7 +69,7 @@ itkLabelImageGaussianInterpolateImageFunctionTest(int, char *[]) // Intensity = f(x,y) = x + 3 * y // // - PixelType valarray[small_xSize][small_ySize] = { { 255, 255, 255 }, { 255, 171, 7 }, { 7, 7, 7 } }; + const PixelType valarray[small_xSize][small_ySize] = { { 255, 255, 255 }, { 255, 171, 7 }, { 7, 7, 7 } }; for (itk::IndexValueType y = 0; y < small_ySize; ++y) { @@ -113,7 +113,7 @@ itkLabelImageGaussianInterpolateImageFunctionTest(int, char *[]) { RegionType region; { - IndexType start{}; + const IndexType start{}; SizeType size; size[0] = large_xSize; @@ -176,16 +176,16 @@ itkLabelImageGaussianInterpolateImageFunctionTest(int, char *[]) At: [5, 4] computed value = 17 known_value = 17 */ - PixelType valarray[large_xSize][large_ySize] = { { 255, 255, 255, 255, 255 }, - { 255, 255, 255, 255, 255 }, - { 255, 255, 171, 7, 7 }, - { 7, 7, 7, 7, 7 }, - { 7, 7, 7, 7, 7 }, - { default_background_value, - default_background_value, - default_background_value, - default_background_value, - default_background_value } }; + const PixelType valarray[large_xSize][large_ySize] = { { 255, 255, 255, 255, 255 }, + { 255, 255, 255, 255, 255 }, + { 255, 255, 171, 7, 7 }, + { 7, 7, 7, 7, 7 }, + { 7, 7, 7, 7, 7 }, + { default_background_value, + default_background_value, + default_background_value, + default_background_value, + default_background_value } }; for (itk::IndexValueType y = 0; y < large_ySize; ++y) { @@ -231,7 +231,7 @@ itkLabelImageGaussianInterpolateImageFunctionTest(int, char *[]) if( interpolator->IsInsideBuffer( point ) ) { //test scalar small_image - const double computedValue = interpolator->Evaluate( point ); + const double computedValue = interpolator->Evaluate( point ); std::cout << "computed value = " << computedValue << std::endl; } } diff --git a/Modules/Core/ImageFunction/test/itkLinearInterpolateImageFunctionTest.cxx b/Modules/Core/ImageFunction/test/itkLinearInterpolateImageFunctionTest.cxx index 4256a7dae61..4aadf436d1a 100644 --- a/Modules/Core/ImageFunction/test/itkLinearInterpolateImageFunctionTest.cxx +++ b/Modules/Core/ImageFunction/test/itkLinearInterpolateImageFunctionTest.cxx @@ -60,13 +60,13 @@ RunLinearInterpolateTest() auto variablevectorimage = VariableVectorImageType::New(); variablevectorimage->SetVectorLength(VectorDimension); - IndexType start{}; + const IndexType start{}; SizeType size; constexpr int dimMaxLength = 3; size.Fill(dimMaxLength); - RegionType region{ start, size }; + const RegionType region{ start, size }; image->SetRegions(region); image->Allocate(); diff --git a/Modules/Core/ImageFunction/test/itkMeanImageFunctionTest.cxx b/Modules/Core/ImageFunction/test/itkMeanImageFunctionTest.cxx index 50ea9a2683a..cbe0706ab18 100644 --- a/Modules/Core/ImageFunction/test/itkMeanImageFunctionTest.cxx +++ b/Modules/Core/ImageFunction/test/itkMeanImageFunctionTest.cxx @@ -51,7 +51,7 @@ itkMeanImageFunctionTest(int, char *[]) image->SetRegions(region); image->Allocate(); - ImageType::PixelType initialValue = 27; + const ImageType::PixelType initialValue = 27; image->FillBuffer(initialValue); @@ -61,7 +61,7 @@ itkMeanImageFunctionTest(int, char *[]) function->SetInputImage(image); - unsigned int neighborhoodRadius = 5; + const unsigned int neighborhoodRadius = 5; function->SetNeighborhoodRadius(neighborhoodRadius); ITK_TEST_SET_GET_VALUE(neighborhoodRadius, function->GetNeighborhoodRadius()); @@ -74,7 +74,7 @@ itkMeanImageFunctionTest(int, char *[]) FunctionType::RealType mean; mean = function->EvaluateAtIndex(index); - double epsilon = 1e-7; + const double epsilon = 1e-7; if (!itk::Math::FloatAlmostEqual(static_cast(initialValue), mean, 10, epsilon)) { std::cout.precision(static_cast(itk::Math::abs(std::log10(epsilon)))); diff --git a/Modules/Core/ImageFunction/test/itkMedianImageFunctionTest.cxx b/Modules/Core/ImageFunction/test/itkMedianImageFunctionTest.cxx index ed175a2b4a7..feb8d73646f 100644 --- a/Modules/Core/ImageFunction/test/itkMedianImageFunctionTest.cxx +++ b/Modules/Core/ImageFunction/test/itkMedianImageFunctionTest.cxx @@ -48,7 +48,7 @@ itkMedianImageFunctionTest(int, char *[]) image->SetRegions(region); image->Allocate(); - ImageType::PixelType initialValue = 27; + const ImageType::PixelType initialValue = 27; image->FillBuffer(initialValue); @@ -140,7 +140,7 @@ itkMedianImageFunctionTest(int, char *[]) } // now set the radius - unsigned int neighborhoodRadius = 2; + const unsigned int neighborhoodRadius = 2; function->SetNeighborhoodRadius(neighborhoodRadius); ITK_TEST_SET_GET_VALUE(neighborhoodRadius, function->GetNeighborhoodRadius()); diff --git a/Modules/Core/ImageFunction/test/itkNearestNeighborExtrapolateImageFunctionTest.cxx b/Modules/Core/ImageFunction/test/itkNearestNeighborExtrapolateImageFunctionTest.cxx index f795354cfff..4c65c5ffcad 100644 --- a/Modules/Core/ImageFunction/test/itkNearestNeighborExtrapolateImageFunctionTest.cxx +++ b/Modules/Core/ImageFunction/test/itkNearestNeighborExtrapolateImageFunctionTest.cxx @@ -40,7 +40,7 @@ itkNearestNeighborExtrapolateImageFunctionTest(int, char *[]) ImageType::SizeType imageSize; imageSize[0] = 5; imageSize[1] = 7; - ImageType::RegionType imageRegion(imageSize); + const ImageType::RegionType imageRegion(imageSize); auto image = ImageType::New(); image->SetRegions(imageRegion); diff --git a/Modules/Core/ImageFunction/test/itkNearestNeighborInterpolateImageFunctionTest.cxx b/Modules/Core/ImageFunction/test/itkNearestNeighborInterpolateImageFunctionTest.cxx index e55502bc692..11833eb6785 100644 --- a/Modules/Core/ImageFunction/test/itkNearestNeighborInterpolateImageFunctionTest.cxx +++ b/Modules/Core/ImageFunction/test/itkNearestNeighborInterpolateImageFunctionTest.cxx @@ -58,11 +58,11 @@ itkNearestNeighborInterpolateImageFunctionTest(int, char *[]) auto variablevectorimage = VariableVectorImageType::New(); variablevectorimage->SetVectorLength(VectorDimension); - IndexType start{}; + const IndexType start{}; auto size = SizeType::Filled(3); - RegionType region{ start, size }; + const RegionType region{ start, size }; image->SetRegions(region); image->Allocate(); @@ -90,8 +90,8 @@ itkNearestNeighborInterpolateImageFunctionTest(int, char *[]) image->Print(std::cout); - unsigned int maxx = 3; - unsigned int maxy = 3; + const unsigned int maxx = 3; + const unsigned int maxy = 3; // // Fill up the image values with the function diff --git a/Modules/Core/ImageFunction/test/itkNeighborhoodOperatorImageFunctionTest.cxx b/Modules/Core/ImageFunction/test/itkNeighborhoodOperatorImageFunctionTest.cxx index b99c6726612..49742c290ea 100644 --- a/Modules/Core/ImageFunction/test/itkNeighborhoodOperatorImageFunctionTest.cxx +++ b/Modules/Core/ImageFunction/test/itkNeighborhoodOperatorImageFunctionTest.cxx @@ -50,7 +50,7 @@ itkNeighborhoodOperatorImageFunctionTest(int, char *[]) image->SetRegions(region); image->Allocate(); - ImageType::PixelType initialValue = 27; + const ImageType::PixelType initialValue = 27; image->FillBuffer(initialValue); diff --git a/Modules/Core/ImageFunction/test/itkRGBInterpolateImageFunctionTest.cxx b/Modules/Core/ImageFunction/test/itkRGBInterpolateImageFunctionTest.cxx index 02e2feddad8..abd635d66ea 100644 --- a/Modules/Core/ImageFunction/test/itkRGBInterpolateImageFunctionTest.cxx +++ b/Modules/Core/ImageFunction/test/itkRGBInterpolateImageFunctionTest.cxx @@ -52,7 +52,7 @@ TestGeometricPoint(const InterpolatorType * interp, const PointType & point, boo std::cout << " Point: " << point; - bool bvalue = interp->IsInsideBuffer(point); + const bool bvalue = interp->IsInsideBuffer(point); std::cout << " Inside: " << bvalue; if (bvalue != isInside) @@ -109,7 +109,7 @@ TestContinuousIndex(const InterpolatorType * interp, std::cout << " Index: " << index; - bool bvalue = interp->IsInsideBuffer(index); + const bool bvalue = interp->IsInsideBuffer(index); std::cout << " Inside: " << bvalue; if (bvalue != isInside) @@ -172,9 +172,9 @@ itkRGBInterpolateImageFunctionTest(int, char *[]) const unsigned int ImageDimension = RGBInterpolate::ImageDimension; - ImageType::SizeType size = { { 20, 40, 80 } }; - double origin[3] = { 0.5, 0.5, 0.5 }; - double spacing[3] = { 0.1, 0.05, 0.025 }; + const ImageType::SizeType size = { { 20, 40, 80 } }; + double origin[3] = { 0.5, 0.5, 0.5 }; + double spacing[3] = { 0.1, 0.05, 0.025 }; // Create a test image @@ -274,9 +274,9 @@ itkRGBInterpolateImageFunctionTest(int, char *[]) // position near image border { - itk::SpacePrecisionType epsilon = 1.0e-10; - itk::SpacePrecisionType darray[3] = { 19 - epsilon, 20, 40 }; - double temp[3] = { 79, 158, 237 }; + const itk::SpacePrecisionType epsilon = 1.0e-10; + itk::SpacePrecisionType darray[3] = { 19 - epsilon, 20, 40 }; + double temp[3] = { 79, 158, 237 }; output = OutputType(temp); cindex = ContinuousIndexType(darray); passed = RGBInterpolate::TestContinuousIndex(interp, cindex, true, output); diff --git a/Modules/Core/ImageFunction/test/itkRayCastInterpolateImageFunctionTest.cxx b/Modules/Core/ImageFunction/test/itkRayCastInterpolateImageFunctionTest.cxx index f13834b0338..1790753cfe8 100644 --- a/Modules/Core/ImageFunction/test/itkRayCastInterpolateImageFunctionTest.cxx +++ b/Modules/Core/ImageFunction/test/itkRayCastInterpolateImageFunctionTest.cxx @@ -41,9 +41,9 @@ itkRayCastInterpolateImageFunctionTest(int itkNotUsed(argc), char * itkNotUsed(a using RegionType = ImageType::RegionType; /* Allocate a simple test image */ - auto image = ImageType::New(); - IndexType start{}; - SizeType size; + auto image = ImageType::New(); + const IndexType start{}; + SizeType size; size[0] = 30; size[1] = 30; size[2] = 30; @@ -54,7 +54,7 @@ itkRayCastInterpolateImageFunctionTest(int itkNotUsed(argc), char * itkNotUsed(a image->SetRegions(region); image->Allocate(); - PointType origin{}; + const PointType origin{}; auto spacing = itk::MakeFilled(1.0); @@ -118,7 +118,7 @@ itkRayCastInterpolateImageFunctionTest(int itkNotUsed(argc), char * itkNotUsed(a ITK_TEST_SET_GET_VALUE(auxInterpolator, interp->GetInterpolator()); /* Exercise the SetThreshold() method */ - double threshold = 1.0; + const double threshold = 1.0; interp->SetThreshold(threshold); ITK_TEST_SET_GET_VALUE(threshold, interp->GetThreshold()); diff --git a/Modules/Core/ImageFunction/test/itkScatterMatrixImageFunctionTest.cxx b/Modules/Core/ImageFunction/test/itkScatterMatrixImageFunctionTest.cxx index dad53d24a85..7f14d6e33fb 100644 --- a/Modules/Core/ImageFunction/test/itkScatterMatrixImageFunctionTest.cxx +++ b/Modules/Core/ImageFunction/test/itkScatterMatrixImageFunctionTest.cxx @@ -64,7 +64,7 @@ itkScatterMatrixImageFunctionTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(function, ScatterMatrixImageFunction, ImageFunction); - unsigned int neighborhoodRadius = 5; + const unsigned int neighborhoodRadius = 5; function->SetNeighborhoodRadius(neighborhoodRadius); ITK_TEST_SET_GET_VALUE(neighborhoodRadius, function->GetNeighborhoodRadius()); diff --git a/Modules/Core/ImageFunction/test/itkSumOfSquaresImageFunctionGTest.cxx b/Modules/Core/ImageFunction/test/itkSumOfSquaresImageFunctionGTest.cxx index 519608a864d..143bc00ef68 100644 --- a/Modules/Core/ImageFunction/test/itkSumOfSquaresImageFunctionGTest.cxx +++ b/Modules/Core/ImageFunction/test/itkSumOfSquaresImageFunctionGTest.cxx @@ -102,13 +102,13 @@ TestBasicObjectProperties() ITK_EXERCISE_BASIC_OBJECT_METHODS(imageFunction, SumOfSquaresImageFunction, ImageFunction); - unsigned int radius = 1; + const unsigned int radius = 1; imageFunction->SetNeighborhoodRadius(radius); EXPECT_EQ(radius, imageFunction->GetNeighborhoodRadius()); auto size = TImage::SizeType::Filled(radius); const itk::RectangularImageNeighborhoodShape shape(size); - unsigned int neighborhoodSize = shape.GetNumberOfOffsets(); + const unsigned int neighborhoodSize = shape.GetNumberOfOffsets(); EXPECT_EQ(neighborhoodSize, imageFunction->GetNeighborhoodSize()); return EXIT_SUCCESS; diff --git a/Modules/Core/ImageFunction/test/itkVectorInterpolateImageFunctionTest.cxx b/Modules/Core/ImageFunction/test/itkVectorInterpolateImageFunctionTest.cxx index 5cfbb5c1b54..1cd2a5f517a 100644 --- a/Modules/Core/ImageFunction/test/itkVectorInterpolateImageFunctionTest.cxx +++ b/Modules/Core/ImageFunction/test/itkVectorInterpolateImageFunctionTest.cxx @@ -47,7 +47,7 @@ TestGeometricPoint(const InterpolatorType * interp, const PointType & point, boo std::cout << " Point: " << point; - bool bvalue = interp->IsInsideBuffer(point); + const bool bvalue = interp->IsInsideBuffer(point); std::cout << " Inside: " << bvalue; if (bvalue != isInside) @@ -105,7 +105,7 @@ TestContinuousIndex(const InterpolatorType * interp, std::cout << " Index: " << index; - bool bvalue = interp->IsInsideBuffer(index); + const bool bvalue = interp->IsInsideBuffer(index); std::cout << " Inside: " << bvalue; if (bvalue != isInside) @@ -156,9 +156,9 @@ itkVectorInterpolateImageFunctionTest(int, char *[]) std::cout << "Testing vector image interpolation: " << std::endl; - ImageType::SizeType size = { { 20, 40, 80 } }; - double origin[3] = { 0.5, 0.5, 0.5 }; - double spacing[3] = { 0.1, 0.05, 0.025 }; + const ImageType::SizeType size = { { 20, 40, 80 } }; + double origin[3] = { 0.5, 0.5, 0.5 }; + double spacing[3] = { 0.1, 0.05, 0.025 }; // Create a test image auto image = ImageType::New(); diff --git a/Modules/Core/ImageFunction/test/itkVectorLinearInterpolateNearestNeighborExtrapolateImageFunctionTest.cxx b/Modules/Core/ImageFunction/test/itkVectorLinearInterpolateNearestNeighborExtrapolateImageFunctionTest.cxx index 0e9d0465281..7a7e4af1dca 100644 --- a/Modules/Core/ImageFunction/test/itkVectorLinearInterpolateNearestNeighborExtrapolateImageFunctionTest.cxx +++ b/Modules/Core/ImageFunction/test/itkVectorLinearInterpolateNearestNeighborExtrapolateImageFunctionTest.cxx @@ -54,7 +54,7 @@ TestGeometricPoint(const InterpolatorType * interp, std::cout << " Point: " << point; - bool bvalue = interp->IsInsideBuffer(point); + const bool bvalue = interp->IsInsideBuffer(point); std::cout << " Inside: " << bvalue; if (bvalue != true) @@ -114,7 +114,7 @@ TestContinuousIndex(const InterpolatorType * interp, std::cout << " Index: " << index; - bool bvalue = interp->IsInsideBuffer(index); + const bool bvalue = interp->IsInsideBuffer(index); std::cout << " Inside: " << bvalue; if (bvalue != true) @@ -167,9 +167,9 @@ itkVectorLinearInterpolateNearestNeighborExtrapolateImageFunctionTest(int, char std::cout << "Testing vector image interpolation: " << std::endl; - ImageType::SizeType size = { { 20, 40, 80 } }; - double origin[3] = { 0.5, 0.5, 0.5 }; - double spacing[3] = { 0.1, 0.05, 0.025 }; + const ImageType::SizeType size = { { 20, 40, 80 } }; + double origin[3] = { 0.5, 0.5, 0.5 }; + double spacing[3] = { 0.1, 0.05, 0.025 }; // Create a test image auto image = ImageType::New(); diff --git a/Modules/Core/ImageFunction/test/itkWindowedSincInterpolateImageFunctionTest.cxx b/Modules/Core/ImageFunction/test/itkWindowedSincInterpolateImageFunctionTest.cxx index 8280a7ebeb3..2b701ca09e6 100644 --- a/Modules/Core/ImageFunction/test/itkWindowedSincInterpolateImageFunctionTest.cxx +++ b/Modules/Core/ImageFunction/test/itkWindowedSincInterpolateImageFunctionTest.cxx @@ -60,7 +60,7 @@ TestGeometricPoint(const InterpolatorType * interp, const PointType & point, boo std::cout << " Point: " << point; - bool bvalue = interp->IsInsideBuffer(point); + const bool bvalue = interp->IsInsideBuffer(point); std::cout << " Inside: " << bvalue << std::endl; if (bvalue != isInside) @@ -71,7 +71,7 @@ TestGeometricPoint(const InterpolatorType * interp, const PointType & point, boo if (isInside) { - OutputType value = interp->Evaluate(point); + const OutputType value = interp->Evaluate(point); std::cout << " Value: " << value << std::endl; if (itk::Math::abs(value - trueValue) > 1e-9) @@ -98,7 +98,7 @@ TestContinuousIndex(const InterpolatorType * interp, std::cout << " Index: " << index; - bool bvalue = interp->IsInsideBuffer(index); + const bool bvalue = interp->IsInsideBuffer(index); std::cout << " Inside: " << bvalue << std::endl; if (bvalue != isInside) @@ -109,7 +109,7 @@ TestContinuousIndex(const InterpolatorType * interp, if (isInside) { - OutputType value = interp->EvaluateAtContinuousIndex(index); + const OutputType value = interp->EvaluateAtContinuousIndex(index); std::cout << " Value: " << value << std::endl; if (itk::Math::abs(value - trueValue) > 1e-9) @@ -145,9 +145,9 @@ itkWindowedSincInterpolateImageFunctionTest(int, char *[]) const unsigned int ImageDimension = SincInterpolate::ImageDimension; - ImageType::SizeType size = { { 20, 40, 80 } }; - double origin[3] = { 0.5, 0.5, 0.5 }; - double spacing[3] = { 0.1, 0.05, 0.025 }; + const ImageType::SizeType size = { { 20, 40, 80 } }; + double origin[3] = { 0.5, 0.5, 0.5 }; + double spacing[3] = { 0.1, 0.05, 0.025 }; // Create a test image @@ -246,7 +246,7 @@ itkWindowedSincInterpolateImageFunctionTest(int, char *[]) // position near image border { - double epsilon = 1.0e-10; + const double epsilon = 1.0e-10; CoordinateType darray[3] = { 19 - epsilon, 20, 40 }; output = OutputType(79); cindex = ContinuousIndexType(darray); diff --git a/Modules/Core/ImageFunction/test/makeRandomImageBsplineInterpolator.h b/Modules/Core/ImageFunction/test/makeRandomImageBsplineInterpolator.h index 5a1f37335af..aaed05900eb 100644 --- a/Modules/Core/ImageFunction/test/makeRandomImageBsplineInterpolator.h +++ b/Modules/Core/ImageFunction/test/makeRandomImageBsplineInterpolator.h @@ -30,7 +30,7 @@ makeRandomImageInterpolator(const int SplineOrder) /** Generate a random input image and connect to BSpline decomposition filter */ using SourceType = itk::RandomImageSource; - typename SourceType::Pointer source = SourceType::New(); + const typename SourceType::Pointer source = SourceType::New(); { using DirectionType = typename ImageType::DirectionType; DirectionType nonTrivialDirection; @@ -61,7 +61,7 @@ makeRandomImageInterpolator(const int SplineOrder) source->SetMin(0.0); source->SetMax(10.0); source->Update(); - typename ImageType::Pointer randImage = source->GetOutput(); + const typename ImageType::Pointer randImage = source->GetOutput(); /** Set up a BSplineInterpolateImageFunction for comparison. */ diff --git a/Modules/Core/Mesh/include/itkAutomaticTopologyMeshSource.h b/Modules/Core/Mesh/include/itkAutomaticTopologyMeshSource.h index 9a183cb4231..3b6e6447b7d 100644 --- a/Modules/Core/Mesh/include/itkAutomaticTopologyMeshSource.h +++ b/Modules/Core/Mesh/include/itkAutomaticTopologyMeshSource.h @@ -384,8 +384,8 @@ class ITK_TEMPLATE_EXPORT AutomaticTopologyMeshSource : public MeshSource auto AutomaticTopologyMeshSource::AddPoint(const PointType & p0) -> IdentifierType { - IdentifierType nextNewPointID = m_OutputMesh->GetNumberOfPoints(); - IdentifierType & pointIDPlusOne = m_PointsHashTable[p0]; - IdentifierType pointID; + const IdentifierType nextNewPointID = m_OutputMesh->GetNumberOfPoints(); + IdentifierType & pointIDPlusOne = m_PointsHashTable[p0]; + IdentifierType pointID; if (pointIDPlusOne != 0) { @@ -82,10 +82,10 @@ AutomaticTopologyMeshSource::AddPoint(CoordinateType x0, CoordinateType x4, CoordinateType x5) -> IdentifierType { - CoordinateType p0[] = { x0, x1, x2, x3, x4, x5 }; - PointType newPoint; - unsigned int i; - unsigned int end = (PointDimension < 6 ? PointDimension : 6); + const CoordinateType p0[] = { x0, x1, x2, x3, x4, x5 }; + PointType newPoint; + unsigned int i; + const unsigned int end = (PointDimension < 6 ? PointDimension : 6); for (i = 0; i < end; ++i) { @@ -155,7 +155,7 @@ AutomaticTopologyMeshSource::AddLine(const IdentifierArrayType & po IdentifierType i; for (i = 0; i < pointIdsEnd; ++i) { - IdentifierType pointID = pointIDs[i]; + const IdentifierType pointID = pointIDs[i]; vertexArray[i] = AddVertex(pointID); newCell->SetPointId(i, pointID); } @@ -171,7 +171,7 @@ AutomaticTopologyMeshSource::AddLine(const IdentifierArrayType & po for (i = 0; i < pointIdsEnd; ++i) { - IdentifierType boundaryID = vertexArray[i]; + const IdentifierType boundaryID = vertexArray[i]; m_OutputMesh->SetBoundaryAssignment(0, cellID, i, boundaryID); } } @@ -206,7 +206,7 @@ AutomaticTopologyMeshSource::AddTriangle(const IdentifierArrayType IdentifierArrayType vertexArray(pointIdsEnd); for (i = 0; i < pointIdsEnd; ++i) { - IdentifierType pointID = pointIDs[i]; + const IdentifierType pointID = pointIDs[i]; vertexArray[i] = AddVertex(pointID); newCell->SetPointId(i, pointID); } @@ -268,7 +268,7 @@ AutomaticTopologyMeshSource::AddQuadrilateral(const IdentifierArray IdentifierArrayType vertexArray(pointIdsEnd); for (i = 0; i < pointIdsEnd; ++i) { - IdentifierType pointID = pointIDs[i]; + const IdentifierType pointID = pointIDs[i]; vertexArray[i] = AddVertex(pointID); newCell->SetPointId(i, pointID); } @@ -330,7 +330,7 @@ AutomaticTopologyMeshSource::AddTetrahedron(const IdentifierArrayTy IdentifierArrayType vertexArray(pointIdsEnd); for (i = 0; i < pointIdsEnd; ++i) { - IdentifierType pointID = pointIDs[i]; + const IdentifierType pointID = pointIDs[i]; vertexArray[i] = AddVertex(pointID); newCell->SetPointId(i, pointID); } @@ -407,7 +407,7 @@ AutomaticTopologyMeshSource::AddHexahedron(const IdentifierArrayTyp IdentifierArrayType vertexArray(pointIdsEnd); for (i = 0; i < pointIdsEnd; ++i) { - IdentifierType pointID = pointIDs[i]; + const IdentifierType pointID = pointIDs[i]; vertexArray[i] = AddVertex(pointID); newCell->SetPointId(i, pointID); } diff --git a/Modules/Core/Mesh/include/itkBinaryMask3DMeshSource.hxx b/Modules/Core/Mesh/include/itkBinaryMask3DMeshSource.hxx index e2fc0a00236..80cd529c934 100644 --- a/Modules/Core/Mesh/include/itkBinaryMask3DMeshSource.hxx +++ b/Modules/Core/Mesh/include/itkBinaryMask3DMeshSource.hxx @@ -33,7 +33,7 @@ BinaryMask3DMeshSource::BinaryMask3DMeshSource() // Modify superclass default values, can be overridden by subclasses this->SetNumberOfRequiredInputs(1); - SizeType size{}; + const SizeType size{}; m_RegionOfInterest.SetSize(size); this->GetOutput()->GetPoints()->Reserve(m_NodeLimit); @@ -431,7 +431,7 @@ template void BinaryMask3DMeshSource::inverse(unsigned char * x) { - unsigned char tmp = x[2]; + const unsigned char tmp = x[2]; x[2] = x[1]; x[1] = tmp; } @@ -1038,8 +1038,8 @@ BinaryMask3DMeshSource::CreateMesh() m_ImageWidth = inputImageSize[0]; m_ImageHeight = inputImageSize[1]; m_ImageDepth = inputImageSize[2]; - int frame = m_ImageWidth * m_ImageHeight; - int row = m_ImageWidth; + const int frame = m_ImageWidth * m_ImageHeight; + const int row = m_ImageWidth; int i = 0; int j; diff --git a/Modules/Core/Mesh/include/itkConnectedRegionsMeshFilter.hxx b/Modules/Core/Mesh/include/itkConnectedRegionsMeshFilter.hxx index bd9831c73e6..e54ceae5727 100644 --- a/Modules/Core/Mesh/include/itkConnectedRegionsMeshFilter.hxx +++ b/Modules/Core/Mesh/include/itkConnectedRegionsMeshFilter.hxx @@ -139,17 +139,17 @@ template void ConnectedRegionsMeshFilter::GenerateData() { - InputMeshConstPointer input = this->GetInput(); - OutputMeshPointer output = this->GetOutput(); - InputMeshPointsContainerConstPointer inPts = input->GetPoints(); - InputMeshCellsContainerConstPointer inCells = input->GetCells(); - InputMeshCellDataContainerConstPointer inCellData = input->GetCellData(); + const InputMeshConstPointer input = this->GetInput(); + const OutputMeshPointer output = this->GetOutput(); + const InputMeshPointsContainerConstPointer inPts = input->GetPoints(); + const InputMeshCellsContainerConstPointer inCells = input->GetCells(); + const InputMeshCellDataContainerConstPointer inCellData = input->GetCellData(); itkDebugMacro("Executing connectivity"); // Check input/allocate storage - IdentifierType numCells = input->GetNumberOfCells(); - IdentifierType numPts = input->GetNumberOfPoints(); + const IdentifierType numCells = input->GetNumberOfCells(); + const IdentifierType numPts = input->GetNumberOfPoints(); if (numPts < 1 || numCells < 1) { itkDebugMacro("No data to connect!"); @@ -180,8 +180,8 @@ ConnectedRegionsMeshFilter::GenerateData() IdentifierType maxCellsInRegion = 0; IdentifierType largestRegionId = 0; - int tenth = numCells / 10 + 1; - int cellId = 0; + const int tenth = numCells / 10 + 1; + int cellId = 0; if (m_ExtractionMode != PointSeededRegions && m_ExtractionMode != CellSeededRegions && m_ExtractionMode != ClosestPointRegion) { // visit all cells marking with region number @@ -253,7 +253,7 @@ ConnectedRegionsMeshFilter::GenerateData() } // get the cells using the closest point and use them as seeds - InputMeshCellLinksContainerConstPointer cellLinks = input->GetCellLinks(); + const InputMeshCellLinksContainerConstPointer cellLinks = input->GetCellLinks(); auto links = cellLinks->ElementAt(minId); for (auto citer = links.cbegin(); citer != links.cend(); ++citer) @@ -280,12 +280,12 @@ ConnectedRegionsMeshFilter::GenerateData() // Create output cells // - InputMeshCellsContainerPointer outCells(InputMeshCellsContainer::New()); - InputMeshCellDataContainerPointer outCellData(InputMeshCellDataContainer::New()); + const InputMeshCellsContainerPointer outCells(InputMeshCellsContainer::New()); + const InputMeshCellDataContainerPointer outCellData(InputMeshCellDataContainer::New()); cellId = 0; CellsContainerConstIterator cell; CellDataContainerConstIterator cellData; - bool CellDataPresent = (nullptr != inCellData && !inCellData->empty()); + const bool CellDataPresent = (nullptr != inCellData && !inCellData->empty()); InputMeshCellPointer cellCopy; // need an autopointer to duplicate a cell int inserted_count = 0; @@ -404,12 +404,12 @@ template void ConnectedRegionsMeshFilter::PropagateConnectedWave() { - InputMeshConstPointer input = this->GetInput(); - IdentifierType cellId; - InputMeshCellPointer cellPtr; - InputMeshPointIdConstIterator piter; - InputMeshCellLinksContainerConstPointer cellLinks = input->GetCellLinks(); - InputMeshCellLinksContainer links; + const InputMeshConstPointer input = this->GetInput(); + IdentifierType cellId; + InputMeshCellPointer cellPtr; + InputMeshPointIdConstIterator piter; + const InputMeshCellLinksContainerConstPointer cellLinks = input->GetCellLinks(); + InputMeshCellLinksContainer links; std::vector::iterator i; std::vector * tmpWave; diff --git a/Modules/Core/Mesh/include/itkImageToMeshFilter.hxx b/Modules/Core/Mesh/include/itkImageToMeshFilter.hxx index 095d282a49a..00d72c3038c 100644 --- a/Modules/Core/Mesh/include/itkImageToMeshFilter.hxx +++ b/Modules/Core/Mesh/include/itkImageToMeshFilter.hxx @@ -28,7 +28,7 @@ ImageToMeshFilter::ImageToMeshFilter() { this->ProcessObject::SetNumberOfRequiredInputs(1); - OutputMeshPointer output = dynamic_cast(this->MakeOutput(0).GetPointer()); + const OutputMeshPointer output = dynamic_cast(this->MakeOutput(0).GetPointer()); this->ProcessObject::SetNumberOfRequiredOutputs(1); this->ProcessObject::SetNthOutput(0, output.GetPointer()); @@ -41,7 +41,7 @@ template DataObject::Pointer ImageToMeshFilter::MakeOutput(DataObjectPointerArraySizeType) { - OutputMeshPointer outputMesh = OutputMeshType::New(); + const OutputMeshPointer outputMesh = OutputMeshType::New(); return dynamic_cast(outputMesh.GetPointer()); } diff --git a/Modules/Core/Mesh/include/itkImageToParametricSpaceFilter.hxx b/Modules/Core/Mesh/include/itkImageToParametricSpaceFilter.hxx index 8db2f8d632d..428b2b60371 100644 --- a/Modules/Core/Mesh/include/itkImageToParametricSpaceFilter.hxx +++ b/Modules/Core/Mesh/include/itkImageToParametricSpaceFilter.hxx @@ -56,8 +56,8 @@ template void ImageToParametricSpaceFilter::GenerateOutputInformation() { - OutputMeshPointer mesh = this->GetOutput(); - PointsContainerPointer points = mesh->GetPoints(); + const OutputMeshPointer mesh = this->GetOutput(); + const PointsContainerPointer points = mesh->GetPoints(); PointDataContainerPointer pointData; if (mesh->GetPointData()) @@ -69,8 +69,8 @@ ImageToParametricSpaceFilter::GenerateOutputInformatio pointData = PointDataContainer::New(); } - InputImageConstPointer image = this->GetInput(0); - const SizeValueType numberOfPixels = image->GetRequestedRegion().GetNumberOfPixels(); + const InputImageConstPointer image = this->GetInput(0); + const SizeValueType numberOfPixels = image->GetRequestedRegion().GetNumberOfPixels(); points->Reserve(numberOfPixels); pointData->Reserve(numberOfPixels); @@ -84,13 +84,13 @@ template void ImageToParametricSpaceFilter::GenerateData() { - OutputMeshPointer mesh = this->GetOutput(); - PointsContainerPointer points = mesh->GetPoints(); - PointDataContainerPointer pointData = PointDataContainer::New(); - InputImageConstPointer image = this->GetInput(0); - InputImageRegionType region = image->GetRequestedRegion(); + const OutputMeshPointer mesh = this->GetOutput(); + const PointsContainerPointer points = mesh->GetPoints(); + const PointDataContainerPointer pointData = PointDataContainer::New(); + InputImageConstPointer image = this->GetInput(0); + const InputImageRegionType region = image->GetRequestedRegion(); - SizeValueType numberOfPixels = region.GetNumberOfPixels(); + const SizeValueType numberOfPixels = region.GetNumberOfPixels(); points->Reserve(numberOfPixels); pointData->Reserve(numberOfPixels); diff --git a/Modules/Core/Mesh/include/itkInteriorExteriorMeshFilter.hxx b/Modules/Core/Mesh/include/itkInteriorExteriorMeshFilter.hxx index 5f905a55cee..eaf04872ed3 100644 --- a/Modules/Core/Mesh/include/itkInteriorExteriorMeshFilter.hxx +++ b/Modules/Core/Mesh/include/itkInteriorExteriorMeshFilter.hxx @@ -30,7 +30,7 @@ template InteriorExteriorMeshFilter::InteriorExteriorMeshFilter() { m_SpatialFunction = SpatialFunctionType::New(); - SpatialFunctionDataObjectPointer spatialFunctionObject = SpatialFunctionDataObjectType::New(); + const SpatialFunctionDataObjectPointer spatialFunctionObject = SpatialFunctionDataObjectType::New(); spatialFunctionObject->Set(m_SpatialFunction); this->ProcessObject::SetNthInput(1, spatialFunctionObject); } @@ -61,8 +61,8 @@ InteriorExteriorMeshFilter::GenerateD using InputPointDataContainerConstPointer = typename TInputMesh::PointDataContainerConstPointer; - const InputMeshType * inputMesh = this->GetInput(); - OutputMeshPointer outputMesh = this->GetOutput(); + const InputMeshType * inputMesh = this->GetInput(); + const OutputMeshPointer outputMesh = this->GetOutput(); if (!inputMesh) { @@ -82,8 +82,8 @@ InteriorExteriorMeshFilter::GenerateD outputMesh->SetBufferedRegion(outputMesh->GetRequestedRegion()); - InputPointsContainerConstPointer inPoints = inputMesh->GetPoints(); - InputPointDataContainerConstPointer inData = inputMesh->GetPointData(); + const InputPointsContainerConstPointer inPoints = inputMesh->GetPoints(); + const InputPointDataContainerConstPointer inData = inputMesh->GetPointData(); typename InputPointsContainer::ConstIterator inputPoint = inPoints->Begin(); typename InputPointDataContainer::ConstIterator inputData; @@ -109,7 +109,7 @@ InteriorExteriorMeshFilter::GenerateD while (inputPoint != inPoints->End()) { - ValueType value = m_SpatialFunction->Evaluate(inputPoint.Value()); + const ValueType value = m_SpatialFunction->Evaluate(inputPoint.Value()); if (value) // Assumes return type is "bool" { @@ -134,7 +134,7 @@ InteriorExteriorMeshFilter::GenerateD this->CopyInputMeshToOutputMeshCells(); this->CopyInputMeshToOutputMeshCellData(); - unsigned int maxDimension = TInputMesh::MaxTopologicalDimension; + const unsigned int maxDimension = TInputMesh::MaxTopologicalDimension; for (unsigned int dim = 0; dim < maxDimension; ++dim) { diff --git a/Modules/Core/Mesh/include/itkMesh.hxx b/Modules/Core/Mesh/include/itkMesh.hxx index 55415d0ff45..0c4747e4935 100644 --- a/Modules/Core/Mesh/include/itkMesh.hxx +++ b/Modules/Core/Mesh/include/itkMesh.hxx @@ -112,8 +112,8 @@ Mesh::GetCellsArray() -> CellsVectorContain IdentifierType index = 0; for (auto cellItr = m_CellsContainer->Begin(); cellItr != m_CellsContainer->End(); ++cellItr) { - auto cellPointer = cellItr->Value(); - unsigned int numOfPoints = cellPointer->GetNumberOfPoints(); + auto cellPointer = cellItr->Value(); + const unsigned int numOfPoints = cellPointer->GetNumberOfPoints(); // Insert the cell type cellOutputVectorContainer->InsertElement(index++, static_cast(cellPointer->GetType())); @@ -189,8 +189,8 @@ Mesh::SetCellsArray(CellsVectorContainer * while (index < cells->Size()) { - int currentCellType = static_cast(cells->GetElement(index++)); - int numOfPoints = static_cast(cells->GetElement(index++)); + const int currentCellType = static_cast(cells->GetElement(index++)); + const int numOfPoints = static_cast(cells->GetElement(index++)); CellAutoPointer cellPointer; @@ -418,7 +418,7 @@ Mesh::SetBoundaryAssignment(int CellFeatureIdentifier featureId, CellIdentifier boundaryId) { - BoundaryAssignmentIdentifier assignId(cellId, featureId); + const BoundaryAssignmentIdentifier assignId(cellId, featureId); /** * Make sure a boundary assignment container exists for the given dimension. @@ -449,7 +449,7 @@ Mesh::GetBoundaryAssignment(int CellFeatureIdentifier featureId, CellIdentifier * boundaryId) const { - BoundaryAssignmentIdentifier assignId(cellId, featureId); + const BoundaryAssignmentIdentifier assignId(cellId, featureId); /** * If the boundary assignments container for the given dimension doesn't @@ -871,8 +871,8 @@ Mesh::GetAssignedCellBoundaryIfOneExists(in { if (m_BoundaryAssignmentsContainers[dimension].IsNotNull()) { - BoundaryAssignmentIdentifier assignId(cellId, featureId); - CellIdentifier boundaryId; + const BoundaryAssignmentIdentifier assignId(cellId, featureId); + CellIdentifier boundaryId; if (m_BoundaryAssignmentsContainers[dimension]->GetElementIfIndexExists(assignId, &boundaryId)) { @@ -945,8 +945,8 @@ Mesh::BuildCellLinks() const */ for (CellsContainerIterator cellItr = m_CellsContainer->Begin(); cellItr != m_CellsContainer->End(); ++cellItr) { - CellIdentifier cellId = cellItr->Index(); - CellType * cellptr = cellItr->Value(); + const CellIdentifier cellId = cellItr->Index(); + CellType * cellptr = cellItr->Value(); /** * For each point, make sure the cell links container has its index, @@ -1045,8 +1045,8 @@ Mesh::ReleaseCellsMemory() // It is assumed that every cell was allocated independently. // A Cell iterator is created for going through the cells // deleting one by one. - CellsContainerIterator cell = m_CellsContainer->Begin(); - CellsContainerIterator end = m_CellsContainer->End(); + CellsContainerIterator cell = m_CellsContainer->Begin(); + const CellsContainerIterator end = m_CellsContainer->End(); while (cell != end) { const CellType * cellToBeDeleted = cell->Value(); diff --git a/Modules/Core/Mesh/include/itkMeshSource.hxx b/Modules/Core/Mesh/include/itkMeshSource.hxx index 3160b3b6641..bd4803da723 100644 --- a/Modules/Core/Mesh/include/itkMeshSource.hxx +++ b/Modules/Core/Mesh/include/itkMeshSource.hxx @@ -27,7 +27,7 @@ MeshSource::MeshSource() { // Create the output. We use static_cast<> here because we know the default // output must be of type TOutputMesh - OutputMeshPointer output = static_cast(this->MakeOutput(0).GetPointer()); + const OutputMeshPointer output = static_cast(this->MakeOutput(0).GetPointer()); this->ProcessObject::SetNumberOfRequiredOutputs(1); this->ProcessObject::SetNthOutput(0, output.GetPointer()); diff --git a/Modules/Core/Mesh/include/itkMeshToMeshFilter.hxx b/Modules/Core/Mesh/include/itkMeshToMeshFilter.hxx index f03713d51cb..c20b92364f0 100644 --- a/Modules/Core/Mesh/include/itkMeshToMeshFilter.hxx +++ b/Modules/Core/Mesh/include/itkMeshToMeshFilter.hxx @@ -66,8 +66,8 @@ template void MeshToMeshFilter::CopyInputMeshToOutputMeshPoints() { - const InputMeshType * inputMesh = this->GetInput(); - OutputMeshPointer outputMesh = this->GetOutput(); + const InputMeshType * inputMesh = this->GetInput(); + const OutputMeshPointer outputMesh = this->GetOutput(); using OutputPointsContainer = typename TOutputMesh::PointsContainer; using InputPointsContainer = typename TInputMesh::PointsContainer; @@ -79,8 +79,8 @@ MeshToMeshFilter::CopyInputMeshToOutputMeshPoints() { outputPoints->Reserve(inputPoints->Size()); - typename InputPointsContainer::ConstIterator inputItr = inputPoints->Begin(); - typename InputPointsContainer::ConstIterator inputEnd = inputPoints->End(); + typename InputPointsContainer::ConstIterator inputItr = inputPoints->Begin(); + const typename InputPointsContainer::ConstIterator inputEnd = inputPoints->End(); typename OutputPointsContainer::Iterator outputItr = outputPoints->Begin(); @@ -99,8 +99,8 @@ template void MeshToMeshFilter::CopyInputMeshToOutputMeshPointData() { - const InputMeshType * inputMesh = this->GetInput(); - OutputMeshPointer outputMesh = this->GetOutput(); + const InputMeshType * inputMesh = this->GetInput(); + const OutputMeshPointer outputMesh = this->GetOutput(); using OutputPointDataContainer = typename TOutputMesh::PointDataContainer; using InputPointDataContainer = typename TInputMesh::PointDataContainer; @@ -112,8 +112,8 @@ MeshToMeshFilter::CopyInputMeshToOutputMeshPointData() { outputPointData->Reserve(inputPointData->Size()); - typename InputPointDataContainer::ConstIterator inputItr = inputPointData->Begin(); - typename InputPointDataContainer::ConstIterator inputEnd = inputPointData->End(); + typename InputPointDataContainer::ConstIterator inputItr = inputPointData->Begin(); + const typename InputPointDataContainer::ConstIterator inputEnd = inputPointData->End(); typename OutputPointDataContainer::Iterator outputItr = outputPointData->Begin(); @@ -132,8 +132,8 @@ template void MeshToMeshFilter::CopyInputMeshToOutputMeshCellLinks() { - const InputMeshType * inputMesh = this->GetInput(); - OutputMeshPointer outputMesh = this->GetOutput(); + const InputMeshType * inputMesh = this->GetInput(); + const OutputMeshPointer outputMesh = this->GetOutput(); using OutputCellLinksContainer = typename TOutputMesh::CellLinksContainer; using InputCellLinksContainer = typename TInputMesh::CellLinksContainer; @@ -145,8 +145,8 @@ MeshToMeshFilter::CopyInputMeshToOutputMeshCellLinks() { outputCellLinks->Reserve(inputCellLinks->Size()); - typename InputCellLinksContainer::ConstIterator inputItr = inputCellLinks->Begin(); - typename InputCellLinksContainer::ConstIterator inputEnd = inputCellLinks->End(); + typename InputCellLinksContainer::ConstIterator inputItr = inputCellLinks->Begin(); + const typename InputCellLinksContainer::ConstIterator inputEnd = inputCellLinks->End(); typename OutputCellLinksContainer::Iterator outputItr = outputCellLinks->Begin(); @@ -165,8 +165,8 @@ template void MeshToMeshFilter::CopyInputMeshToOutputMeshCells() { - const InputMeshType * inputMesh = this->GetInput(); - OutputMeshPointer outputMesh = this->GetOutput(); + const InputMeshType * inputMesh = this->GetInput(); + const OutputMeshPointer outputMesh = this->GetOutput(); using OutputCellsContainer = typename TOutputMesh::CellsContainer; using InputCellsContainer = typename TInputMesh::CellsContainer; @@ -181,8 +181,8 @@ MeshToMeshFilter::CopyInputMeshToOutputMeshCells() { outputCells->Reserve(inputCells->Size()); - typename InputCellsContainer::ConstIterator inputItr = inputCells->Begin(); - typename InputCellsContainer::ConstIterator inputEnd = inputCells->End(); + typename InputCellsContainer::ConstIterator inputItr = inputCells->Begin(); + const typename InputCellsContainer::ConstIterator inputEnd = inputCells->End(); typename OutputCellsContainer::Iterator outputItr = outputCells->Begin(); @@ -208,8 +208,8 @@ template void MeshToMeshFilter::CopyInputMeshToOutputMeshCellData() { - const InputMeshType * inputMesh = this->GetInput(); - OutputMeshPointer outputMesh = this->GetOutput(); + const InputMeshType * inputMesh = this->GetInput(); + const OutputMeshPointer outputMesh = this->GetOutput(); using OutputCellDataContainer = typename TOutputMesh::CellDataContainer; using InputCellDataContainer = typename TInputMesh::CellDataContainer; @@ -221,8 +221,8 @@ MeshToMeshFilter::CopyInputMeshToOutputMeshCellData() { outputCellData->Reserve(inputCellData->Size()); - typename InputCellDataContainer::ConstIterator inputItr = inputCellData->Begin(); - typename InputCellDataContainer::ConstIterator inputEnd = inputCellData->End(); + typename InputCellDataContainer::ConstIterator inputItr = inputCellData->Begin(); + const typename InputCellDataContainer::ConstIterator inputEnd = inputCellData->End(); typename OutputCellDataContainer::Iterator outputItr = outputCellData->Begin(); diff --git a/Modules/Core/Mesh/include/itkParametricSpaceToImageSpaceMeshFilter.hxx b/Modules/Core/Mesh/include/itkParametricSpaceToImageSpaceMeshFilter.hxx index eb3d735befd..3ec0811767f 100644 --- a/Modules/Core/Mesh/include/itkParametricSpaceToImageSpaceMeshFilter.hxx +++ b/Modules/Core/Mesh/include/itkParametricSpaceToImageSpaceMeshFilter.hxx @@ -51,8 +51,8 @@ ParametricSpaceToImageSpaceMeshFilter::GenerateData() using OutputPointDataContainerPointer = typename TOutputMesh::PointDataContainerPointer; - const InputMeshType * inputMesh = this->GetInput(); - OutputMeshPointer outputMesh = this->GetOutput(); + const InputMeshType * inputMesh = this->GetInput(); + const OutputMeshPointer outputMesh = this->GetOutput(); if (!inputMesh) { @@ -66,13 +66,13 @@ ParametricSpaceToImageSpaceMeshFilter::GenerateData() outputMesh->SetBufferedRegion(outputMesh->GetRequestedRegion()); - const InputPointsContainer * inPoints = inputMesh->GetPoints(); - OutputPointsContainerPointer outPoints = OutputPointsContainer::New(); + const InputPointsContainer * inPoints = inputMesh->GetPoints(); + const OutputPointsContainerPointer outPoints = OutputPointsContainer::New(); outPoints->Reserve(inputMesh->GetNumberOfPoints()); - const InputPointDataContainer * inData = inputMesh->GetPointData(); - OutputPointDataContainerPointer outData = OutputPointDataContainer::New(); + const InputPointDataContainer * inData = inputMesh->GetPointData(); + const OutputPointDataContainerPointer outData = OutputPointDataContainer::New(); outData->Reserve(inputMesh->GetNumberOfPoints()); @@ -89,9 +89,9 @@ ParametricSpaceToImageSpaceMeshFilter::GenerateData() return; } - typename InputPointsContainer::ConstIterator inputPointIt = inPoints->Begin(); - typename InputPointsContainer::ConstIterator inputPointEnd = inPoints->End(); - typename InputPointDataContainer::ConstIterator inputDataIt = inData->Begin(); + typename InputPointsContainer::ConstIterator inputPointIt = inPoints->Begin(); + const typename InputPointsContainer::ConstIterator inputPointEnd = inPoints->End(); + typename InputPointDataContainer::ConstIterator inputDataIt = inData->Begin(); typename OutputPointsContainer::Iterator outputPointIt = outPoints->Begin(); typename OutputPointDataContainer::Iterator outputDataIt = outData->Begin(); diff --git a/Modules/Core/Mesh/include/itkRegularSphereMeshSource.hxx b/Modules/Core/Mesh/include/itkRegularSphereMeshSource.hxx index fac9ca3deac..f7ee850085b 100644 --- a/Modules/Core/Mesh/include/itkRegularSphereMeshSource.hxx +++ b/Modules/Core/Mesh/include/itkRegularSphereMeshSource.hxx @@ -47,11 +47,11 @@ RegularSphereMeshSource::GenerateData() { typename OutputMeshType::PointIdentifier tripoints[3] = { 0, 1, 2 }; - typename OutputMeshType::Pointer outputMesh = this->GetOutput(); + const typename OutputMeshType::Pointer outputMesh = this->GetOutput(); outputMesh->SetCellsAllocationMethod(MeshEnums::MeshClassCellsAllocationMethod::CellsAllocatedDynamicallyCellByCell); - PointsContainerPointer myPoints = outputMesh->GetPoints(); + const PointsContainerPointer myPoints = outputMesh->GetPoints(); PointType p1; IdentifierType idx = 0; @@ -141,8 +141,8 @@ RegularSphereMeshSource::GenerateData() unsigned int i; for (i = 0; i < m_Resolution; ++i) { - typename OutputMeshType::CellsContainerPointer myCells = outputMesh->GetCells(); - typename OutputMeshType::CellsContainer::Iterator cells = myCells->Begin(); + const typename OutputMeshType::CellsContainerPointer myCells = outputMesh->GetCells(); + typename OutputMeshType::CellsContainer::Iterator cells = myCells->Begin(); auto result = OutputMeshType::New(); PointType v[3]; @@ -150,10 +150,10 @@ RegularSphereMeshSource::GenerateData() v_pt[0] = &v[0]; v_pt[1] = &v[1]; v_pt[2] = &v[2]; - IdentifierType cellIdx = 0; - IdentifierType pointIdxOffset = outputMesh->GetNumberOfPoints(); - IdentifierType pointIdx = pointIdxOffset; - IdentifierType newIdx[3] = { 0, 1, 2 }; + IdentifierType cellIdx = 0; + const IdentifierType pointIdxOffset = outputMesh->GetNumberOfPoints(); + IdentifierType pointIdx = pointIdxOffset; + IdentifierType newIdx[3] = { 0, 1, 2 }; // container for the processed edges // when subdividing a triangle, the corresponding subdivided diff --git a/Modules/Core/Mesh/include/itkSimplexMesh.hxx b/Modules/Core/Mesh/include/itkSimplexMesh.hxx index 1bfd144a7b5..6239d9db3e9 100644 --- a/Modules/Core/Mesh/include/itkSimplexMesh.hxx +++ b/Modules/Core/Mesh/include/itkSimplexMesh.hxx @@ -40,9 +40,9 @@ SimplexMesh::~SimplexMesh() { itkDebugMacro("Mesh Destructor "); - GeometryMapPointer geometryMap = this->GetGeometryData(); - GeometryMapIterator pointDataIterator = geometryMap->Begin(); - GeometryMapIterator pointDataEnd = geometryMap->End(); + const GeometryMapPointer geometryMap = this->GetGeometryData(); + GeometryMapIterator pointDataIterator = geometryMap->Begin(); + const GeometryMapIterator pointDataEnd = geometryMap->End(); while (pointDataIterator != pointDataEnd) { @@ -176,8 +176,8 @@ auto SimplexMesh::AddEdge(PointIdentifier startPointId, PointIdentifier endPointId) -> CellIdentifier { - CellAutoPointer NewCellPointer(new LineType, true); - CellIdentifier edgeId = m_LastCellId; + CellAutoPointer NewCellPointer(new LineType, true); + const CellIdentifier edgeId = m_LastCellId; NewCellPointer->SetPointId(0, startPointId); NewCellPointer->SetPointId(1, endPointId); diff --git a/Modules/Core/Mesh/include/itkSimplexMeshAdaptTopologyFilter.h b/Modules/Core/Mesh/include/itkSimplexMeshAdaptTopologyFilter.h index c709e474bdd..c16b30cca71 100644 --- a/Modules/Core/Mesh/include/itkSimplexMeshAdaptTopologyFilter.h +++ b/Modules/Core/Mesh/include/itkSimplexMeshAdaptTopologyFilter.h @@ -129,9 +129,9 @@ class ITK_TEMPLATE_EXPORT SimplexMeshAdaptTopologyFilter : public MeshToMeshFilt { typename InputPolygonType::PointIdIterator it = poly->PointIdsBegin(); - double meanCurvature = 0; - PointIdentifier refPoint = *it; - double val = mesh->GetMeanCurvature(*it++); + double meanCurvature = 0; + const PointIdentifier refPoint = *it; + double val = mesh->GetMeanCurvature(*it++); meanCurvature += itk::Math::abs(val); PointIdentifier id1 = *it; @@ -144,7 +144,7 @@ class ITK_TEMPLATE_EXPORT SimplexMeshAdaptTopologyFilter : public MeshToMeshFilt while (it != poly->PointIdsEnd()) { - PointIdentifier id2 = *it; + const PointIdentifier id2 = *it; area += ComputeArea(refPoint, id1, id2); id1 = id2; val = mesh->GetMeanCurvature(*it); diff --git a/Modules/Core/Mesh/include/itkSimplexMeshAdaptTopologyFilter.hxx b/Modules/Core/Mesh/include/itkSimplexMeshAdaptTopologyFilter.hxx index 89dcc341e96..cd970eed42e 100644 --- a/Modules/Core/Mesh/include/itkSimplexMeshAdaptTopologyFilter.hxx +++ b/Modules/Core/Mesh/include/itkSimplexMeshAdaptTopologyFilter.hxx @@ -65,8 +65,8 @@ template void SimplexMeshAdaptTopologyFilter::CopyInputMeshToOutputMeshGeometryData() { - const InputMeshType * inputMesh = this->GetInput(); - OutputMeshPointer outputMesh = this->GetOutput(); + const InputMeshType * inputMesh = this->GetInput(); + const OutputMeshPointer outputMesh = this->GetOutput(); const PointIdentifier numberOfPoints = inputMesh->GetNumberOfPoints(); @@ -74,9 +74,9 @@ SimplexMeshAdaptTopologyFilter::CopyInputMeshToOutputMe using GeometryMapPointer = typename InputMeshType::GeometryMapPointer; using GeometryMapConstIterator = typename InputMeshType::GeometryMapConstIterator; - GeometryMapPointer inputGeometryData = inputMesh->GetGeometryData(); + const GeometryMapPointer inputGeometryData = inputMesh->GetGeometryData(); - GeometryMapPointer outputGeometryData = GeometryMapType::New(); + const GeometryMapPointer outputGeometryData = GeometryMapType::New(); outputGeometryData->Reserve(numberOfPoints); @@ -100,26 +100,26 @@ template void SimplexMeshAdaptTopologyFilter::ComputeCellParameters() { - OutputMeshPointer outputMesh = this->GetOutput(); + const OutputMeshPointer outputMesh = this->GetOutput(); // Ensure that cells will be deallocated by the Mesh. outputMesh->SetCellsAllocationMethod(MeshEnums::MeshClassCellsAllocationMethod::CellsAllocatedDynamicallyCellByCell); - SimplexVisitorInterfacePointer simplexVisitor = SimplexVisitorInterfaceType::New(); + const SimplexVisitorInterfacePointer simplexVisitor = SimplexVisitorInterfaceType::New(); simplexVisitor->mesh = outputMesh; - CellMultiVisitorPointer mv = CellMultiVisitorType::New(); + const CellMultiVisitorPointer mv = CellMultiVisitorType::New(); mv->AddVisitor(simplexVisitor); outputMesh->Accept(mv); - typename DoubleValueMapType::Pointer areas = simplexVisitor->GetAreaMap(); - DoubleContainerIterator areaIt = areas->Begin(); - typename DoubleValueMapType::Pointer curvatures = simplexVisitor->GetCurvatureMap(); - DoubleContainerIterator curvatureIt = curvatures->Begin(); + const typename DoubleValueMapType::Pointer areas = simplexVisitor->GetAreaMap(); + DoubleContainerIterator areaIt = areas->Begin(); + const typename DoubleValueMapType::Pointer curvatures = simplexVisitor->GetCurvatureMap(); + DoubleContainerIterator curvatureIt = curvatures->Begin(); - double averageCurvature = simplexVisitor->GetTotalMeanCurvature(); + const double averageCurvature = simplexVisitor->GetTotalMeanCurvature(); - double rangeCellSize = simplexVisitor->GetMaximumCellSize() - simplexVisitor->GetMinimumCellSize(); - double rangeCurvature = simplexVisitor->GetMaximumCurvature() - simplexVisitor->GetMinimumCurvature(); + const double rangeCellSize = simplexVisitor->GetMaximumCellSize() - simplexVisitor->GetMinimumCellSize(); + const double rangeCurvature = simplexVisitor->GetMaximumCurvature() - simplexVisitor->GetMinimumCurvature(); while (curvatureIt != curvatures->End()) { @@ -158,13 +158,13 @@ SimplexMeshAdaptTopologyFilter::ComputeCellParameters() InputCellAutoPointer poly; outputMesh->GetCell(curvatureIt.Index(), poly); - InputPointType cellCenter = this->ComputeCellCenter(poly); + const InputPointType cellCenter = this->ComputeCellCenter(poly); typename InputPolygonType::PointIdIterator pointIds = poly->PointIdsBegin(); - PointIdentifier lineOneFirstIdx = *pointIds; + const PointIdentifier lineOneFirstIdx = *pointIds; ++pointIds; - PointIdentifier lineOneSecondIdx = *pointIds; + const PointIdentifier lineOneSecondIdx = *pointIds; unsigned short cnt = 0; @@ -173,13 +173,13 @@ SimplexMeshAdaptTopologyFilter::ComputeCellParameters() ++pointIds; ++cnt; } - PointIdentifier lineTwoFirstIdx = *pointIds; + const PointIdentifier lineTwoFirstIdx = *pointIds; ++pointIds; - PointIdentifier lineTwoSecondIdx = *pointIds; + const PointIdentifier lineTwoSecondIdx = *pointIds; - PointIdentifier newPointId = outputMesh->GetNumberOfPoints(); - PointIdentifier firstNewIndex = newPointId; - PointIdentifier secondNewIndex = newPointId + 1; + const PointIdentifier newPointId = outputMesh->GetNumberOfPoints(); + const PointIdentifier firstNewIndex = newPointId; + const PointIdentifier secondNewIndex = newPointId + 1; // create first new point InputPointType p1{}; @@ -250,7 +250,7 @@ SimplexMeshAdaptTopologyFilter::ComputeCellParameters() pointIds = poly->PointIdsBegin(); - PointIdentifier firstPointId = *pointIds++; + const PointIdentifier firstPointId = *pointIds++; while (*pointIds != lineTwoSecondIdx) { @@ -296,7 +296,7 @@ SimplexMeshAdaptTopologyFilter::ModifyNeighborCells(Cel CellIdentifier id2, PointIdentifier insertPointId) { - OutputMeshPointer outputMesh = this->GetOutput(); + const OutputMeshPointer outputMesh = this->GetOutput(); std::set cells1 = outputMesh->GetCellLinks()->GetElement(id1); std::set cells2 = outputMesh->GetCellLinks()->GetElement(id2); @@ -324,8 +324,8 @@ SimplexMeshAdaptTopologyFilter::ModifyNeighborCells(Cel if (nextCell->GetNumberOfPoints() == 2) { InputCellPointIdIterator lineIt = nextCell->PointIdsBegin(); - PointIdentifier first = *lineIt++; - PointIdentifier second = *lineIt; + const PointIdentifier first = *lineIt++; + const PointIdentifier second = *lineIt; outputMesh->AddEdge(first, insertPointId); outputMesh->AddEdge(insertPointId, second); @@ -341,7 +341,7 @@ SimplexMeshAdaptTopologyFilter::ModifyNeighborCells(Cel InputPolygonPointIdIterator pointIt = nextCell->PointIdsBegin(); PointIdentifier cnt{}; PointIdentifier first = *pointIt++; - PointIdentifier startId = first; + const PointIdentifier startId = first; PointIdentifier second = 0; @@ -395,7 +395,7 @@ auto SimplexMeshAdaptTopologyFilter::ComputeCellCenter(InputCellAutoPointer & simplexCell) -> InputPointType { - OutputMeshPointer outputMesh = this->GetOutput(); + const OutputMeshPointer outputMesh = this->GetOutput(); InputPolygonPointIdIterator pointIt = simplexCell->PointIdsBegin(); InputPointType p1{}; diff --git a/Modules/Core/Mesh/include/itkSimplexMeshToTriangleMeshFilter.hxx b/Modules/Core/Mesh/include/itkSimplexMeshToTriangleMeshFilter.hxx index 1d00a75ed4b..7441ef87066 100644 --- a/Modules/Core/Mesh/include/itkSimplexMeshToTriangleMeshFilter.hxx +++ b/Modules/Core/Mesh/include/itkSimplexMeshToTriangleMeshFilter.hxx @@ -34,10 +34,10 @@ template void SimplexMeshToTriangleMeshFilter::Initialize() { - SimplexVisitorInterfacePointer simplexVisitor = SimplexVisitorInterfaceType::New(); + const SimplexVisitorInterfacePointer simplexVisitor = SimplexVisitorInterfaceType::New(); simplexVisitor->SetMesh(this->GetInput(0)); - CellMultiVisitorPointer mv = CellMultiVisitorType::New(); + const CellMultiVisitorPointer mv = CellMultiVisitorType::New(); mv->AddVisitor(simplexVisitor); this->GetInput(0)->Accept(mv); this->GetInput(0)->BuildCellLinks(); @@ -50,8 +50,8 @@ SimplexMeshToTriangleMeshFilter::CreateTriangles() { auto meshSource = AutoMeshSourceType::New(); - typename TInputMesh::ConstPointer inputMesh = this->GetInput(0); - typename InputPointsContainer::ConstPointer points = inputMesh->GetPoints(); + const typename TInputMesh::ConstPointer inputMesh = this->GetInput(0); + const typename InputPointsContainer::ConstPointer points = inputMesh->GetPoints(); typename TInputMesh::PointsContainerConstIterator pointsIt = points->Begin(); meshSource->Update(); @@ -60,16 +60,16 @@ SimplexMeshToTriangleMeshFilter::CreateTriangles() { typename InputMeshType::IndexArray n = this->GetInput(0)->GetNeighbors(pointsIt.Index()); - CellIdentifier newId1 = FindCellId(n[0], pointsIt.Index(), n[1]); - CellIdentifier newId2 = FindCellId(n[1], pointsIt.Index(), n[2]); - CellIdentifier newId3 = FindCellId(n[2], pointsIt.Index(), n[0]); + const CellIdentifier newId1 = FindCellId(n[0], pointsIt.Index(), n[1]); + const CellIdentifier newId2 = FindCellId(n[1], pointsIt.Index(), n[2]); + const CellIdentifier newId3 = FindCellId(n[2], pointsIt.Index(), n[0]); typename AutoMeshSourceType::PointType p1; - bool b1 = m_Centers->GetElementIfIndexExists(newId1, &p1); + const bool b1 = m_Centers->GetElementIfIndexExists(newId1, &p1); typename AutoMeshSourceType::PointType p2; - bool b2 = m_Centers->GetElementIfIndexExists(newId2, &p2); + const bool b2 = m_Centers->GetElementIfIndexExists(newId2, &p2); typename AutoMeshSourceType::PointType p3; - bool b3 = m_Centers->GetElementIfIndexExists(newId3, &p3); + const bool b3 = m_Centers->GetElementIfIndexExists(newId3, &p3); meshSource->AddTriangle(p1, p2, p3); diff --git a/Modules/Core/Mesh/include/itkSimplexMeshVolumeCalculator.hxx b/Modules/Core/Mesh/include/itkSimplexMeshVolumeCalculator.hxx index ba29f7ed711..db092ecbdc6 100644 --- a/Modules/Core/Mesh/include/itkSimplexMeshVolumeCalculator.hxx +++ b/Modules/Core/Mesh/include/itkSimplexMeshVolumeCalculator.hxx @@ -27,10 +27,10 @@ template void SimplexMeshVolumeCalculator::Initialize() { - SimplexVisitorInterfacePointer simplexVisitor = SimplexVisitorInterfaceType::New(); + const SimplexVisitorInterfacePointer simplexVisitor = SimplexVisitorInterfaceType::New(); simplexVisitor->SetMesh(m_SimplexMesh); - CellMultiVisitorPointer mv = CellMultiVisitorType::New(); + const CellMultiVisitorPointer mv = CellMultiVisitorType::New(); mv->AddVisitor(simplexVisitor); m_SimplexMesh->Accept(mv); m_SimplexMesh->BuildCellLinks(); @@ -121,7 +121,7 @@ SimplexMeshVolumeCalculator::CalculateTriangleVolume(InputPointType // Normalize normal // - double length = std::sqrt(u[0] * u[0] + u[1] * u[1] + u[2] * u[2]); + const double length = std::sqrt(u[0] * u[0] + u[1] * u[1] + u[2] * u[2]); if (length != 0.0) { u[0] /= length; @@ -192,17 +192,17 @@ SimplexMeshVolumeCalculator::CalculateTriangleVolume(InputPointType // Area of a triangle using Heron's formula... // - double a = std::sqrt(ii[1] + jj[1] + kk[1]); - double b = std::sqrt(ii[0] + jj[0] + kk[0]); - double c = std::sqrt(ii[2] + jj[2] + kk[2]); - double s = 0.5 * (a + b + c); - double area = std::sqrt(itk::Math::abs(s * (s - a) * (s - b) * (s - c))); + const double a = std::sqrt(ii[1] + jj[1] + kk[1]); + const double b = std::sqrt(ii[0] + jj[0] + kk[0]); + const double c = std::sqrt(ii[2] + jj[2] + kk[2]); + const double s = 0.5 * (a + b + c); + const double area = std::sqrt(itk::Math::abs(s * (s - a) * (s - b) * (s - c))); // Volume elements ... // - double zavg = (p1[2] + p2[2] + p3[2]) / 3.0; - double yavg = (p1[1] + p2[1] + p3[1]) / 3.0; - double xavg = (p1[0] + p2[0] + p3[0]) / 3.0; + const double zavg = (p1[2] + p2[2] + p3[2]) / 3.0; + const double yavg = (p1[1] + p2[1] + p3[1]) / 3.0; + const double xavg = (p1[0] + p2[0] + p3[0]) / 3.0; m_VolumeX += (area * static_cast(u[2]) * static_cast(zavg)); m_VolumeY += (area * static_cast(u[1]) * static_cast(yavg)); @@ -223,21 +223,21 @@ SimplexMeshVolumeCalculator::Compute() InputPointType p2{}; InputPointType p3{}; - InputPointsContainerPointer Points = m_SimplexMesh->GetPoints(); - InputPointsContainerIterator pointsIt = Points->Begin(); - InputPointsContainerIterator pointsEnd = Points->End(); + const InputPointsContainerPointer Points = m_SimplexMesh->GetPoints(); + InputPointsContainerIterator pointsIt = Points->Begin(); + const InputPointsContainerIterator pointsEnd = Points->End(); while (pointsIt != pointsEnd) { typename InputMeshType::IndexArray n = m_SimplexMesh->GetNeighbors(pointsIt.Index()); - IdentifierType newId1 = FindCellId(n[0], pointsIt.Index(), n[1]); - IdentifierType newId2 = FindCellId(n[1], pointsIt.Index(), n[2]); - IdentifierType newId3 = FindCellId(n[2], pointsIt.Index(), n[0]); + const IdentifierType newId1 = FindCellId(n[0], pointsIt.Index(), n[1]); + const IdentifierType newId2 = FindCellId(n[1], pointsIt.Index(), n[2]); + const IdentifierType newId3 = FindCellId(n[2], pointsIt.Index(), n[0]); - bool b1 = m_Centers->GetElementIfIndexExists(newId1, &p1); - bool b2 = m_Centers->GetElementIfIndexExists(newId2, &p2); - bool b3 = m_Centers->GetElementIfIndexExists(newId3, &p3); + const bool b1 = m_Centers->GetElementIfIndexExists(newId1, &p1); + const bool b2 = m_Centers->GetElementIfIndexExists(newId2, &p2); + const bool b3 = m_Centers->GetElementIfIndexExists(newId3, &p3); if (!(b1 && b2 && b3)) { diff --git a/Modules/Core/Mesh/include/itkSphereMeshSource.hxx b/Modules/Core/Mesh/include/itkSphereMeshSource.hxx index c89720e7a3e..41b09a878dd 100644 --- a/Modules/Core/Mesh/include/itkSphereMeshSource.hxx +++ b/Modules/Core/Mesh/include/itkSphereMeshSource.hxx @@ -50,13 +50,13 @@ void SphereMeshSource::GenerateData() { // calculate the number os cells and points - IdentifierType numpts = m_ResolutionX * m_ResolutionY + 2; + const IdentifierType numpts = m_ResolutionX * m_ResolutionY + 2; // calculate the steps using resolution - double ustep = itk::Math::pi / (m_ResolutionX + 1); - double vstep = 2.0 * itk::Math::pi / m_ResolutionY; - double ubeg = (-itk::Math::pi / 2.0) + ustep; - double vbeg = -itk::Math::pi; + const double ustep = itk::Math::pi / (m_ResolutionX + 1); + const double vstep = 2.0 * itk::Math::pi / m_ResolutionY; + const double ubeg = (-itk::Math::pi / 2.0) + ustep; + const double vbeg = -itk::Math::pi; /////////////////////////////////////////////////////////////////////////// // nodes allocation @@ -65,13 +65,13 @@ SphereMeshSource::GenerateData() typename OutputMeshType::PointIdentifier tripoints[3] = { 0, 1, 2 }; // memory allocation for nodes - typename OutputMeshType::Pointer outputMesh = this->GetOutput(); + const typename OutputMeshType::Pointer outputMesh = this->GetOutput(); outputMesh->GetPoints()->Reserve(numpts); outputMesh->SetCellsAllocationMethod(MeshEnums::MeshClassCellsAllocationMethod::CellsAllocatedDynamicallyCellByCell); - PointsContainerPointer myPoints = outputMesh->GetPoints(); + const PointsContainerPointer myPoints = outputMesh->GetPoints(); typename PointsContainer::Iterator point = myPoints->Begin(); OPointType p1; @@ -177,7 +177,7 @@ SphereMeshSource::GenerateData() { for (unsigned int jj = 0; jj < m_ResolutionY; ++jj) { - IdentifierType jn = (jj + 1) % m_ResolutionY; + const IdentifierType jn = (jj + 1) % m_ResolutionY; tripoints[0] = ii * m_ResolutionY + jj; tripoints[1] = tripoints[0] - jj + jn; tripoints[2] = tripoints[0] + m_ResolutionY; @@ -199,7 +199,7 @@ SphereMeshSource::GenerateData() // store cells containing the south pole nodes for (unsigned int jj = 0; jj < m_ResolutionY; ++jj) { - IdentifierType jn = (jj + 1) % m_ResolutionY; + const IdentifierType jn = (jj + 1) % m_ResolutionY; tripoints[0] = numpts - 2; tripoints[1] = jn; tripoints[2] = jj; @@ -213,7 +213,7 @@ SphereMeshSource::GenerateData() // store cells containing the north pole nodes for (unsigned int jj = 0; jj < m_ResolutionY; ++jj) { - IdentifierType jn = (jj + 1) % m_ResolutionY; + const IdentifierType jn = (jj + 1) % m_ResolutionY; tripoints[2] = (m_ResolutionX - 1) * m_ResolutionY + jj; tripoints[1] = numpts - 1; tripoints[0] = tripoints[2] - jj + jn; diff --git a/Modules/Core/Mesh/include/itkTransformMeshFilter.hxx b/Modules/Core/Mesh/include/itkTransformMeshFilter.hxx index becb3a15894..fb938c19383 100644 --- a/Modules/Core/Mesh/include/itkTransformMeshFilter.hxx +++ b/Modules/Core/Mesh/include/itkTransformMeshFilter.hxx @@ -58,8 +58,8 @@ TransformMeshFilter::GenerateData() using InputPointsContainerConstPointer = typename TInputMesh::PointsContainerConstPointer; using OutputPointsContainerPointer = typename TOutputMesh::PointsContainerPointer; - const InputMeshType * inputMesh = this->GetInput(); - OutputMeshPointer outputMesh = this->GetOutput(); + const InputMeshType * inputMesh = this->GetInput(); + const OutputMeshPointer outputMesh = this->GetOutput(); if (!inputMesh) { @@ -78,8 +78,8 @@ TransformMeshFilter::GenerateData() outputMesh->SetBufferedRegion(outputMesh->GetRequestedRegion()); - InputPointsContainerConstPointer inPoints = inputMesh->GetPoints(); - OutputPointsContainerPointer outPoints = outputMesh->GetPoints(); + const InputPointsContainerConstPointer inPoints = inputMesh->GetPoints(); + const OutputPointsContainerPointer outPoints = outputMesh->GetPoints(); outPoints->Reserve(inputMesh->GetNumberOfPoints()); outPoints->Squeeze(); // in case the previous mesh had @@ -106,7 +106,7 @@ TransformMeshFilter::GenerateData() // FIXME: DELETEME outputMesh->SetCells( inputMesh->GetCells() ); // FIXME: DELETEME outputMesh->SetCellData( inputMesh->GetCellData() ); - unsigned int maxDimension = TInputMesh::MaxTopologicalDimension; + const unsigned int maxDimension = TInputMesh::MaxTopologicalDimension; for (unsigned int dim = 0; dim < maxDimension; ++dim) { diff --git a/Modules/Core/Mesh/include/itkTriangleMeshCurvatureCalculator.hxx b/Modules/Core/Mesh/include/itkTriangleMeshCurvatureCalculator.hxx index 6e725959959..4942cdd75e1 100644 --- a/Modules/Core/Mesh/include/itkTriangleMeshCurvatureCalculator.hxx +++ b/Modules/Core/Mesh/include/itkTriangleMeshCurvatureCalculator.hxx @@ -78,16 +78,16 @@ TriangleMeshCurvatureCalculator::ComputeGaussCurvature(const InputMe { const unsigned int numberOfPoints = inputMesh->GetNumberOfPoints(); - const auto K = make_unique_for_overwrite(numberOfPoints); - const auto dA = std::make_unique(numberOfPoints); - double pi2 = itk::Math::twopi; + const auto K = make_unique_for_overwrite(numberOfPoints); + const auto dA = std::make_unique(numberOfPoints); + const double pi2 = itk::Math::twopi; for (unsigned int k = 0; k < numberOfPoints; ++k) { K[k] = pi2; } - CellsContainerConstPointer outCells = inputMesh->GetCells(); - CellsContainerConstIterator cellsItr = outCells->Begin(); + const CellsContainerConstPointer outCells = inputMesh->GetCells(); + CellsContainerConstIterator cellsItr = outCells->Begin(); while (cellsItr != outCells->End()) { @@ -128,12 +128,12 @@ TriangleMeshCurvatureCalculator::ComputeGaussCurvature(const InputMe e2[1] -= v2[1]; e2[2] -= v2[2]; - double alpha0 = itk::Math::pi - angle(e1.GetVnlVector(), e2.GetVnlVector()); - double alpha1 = itk::Math::pi - angle(e2.GetVnlVector(), e0.GetVnlVector()); - double alpha2 = itk::Math::pi - angle(e0.GetVnlVector(), e1.GetVnlVector()); + const double alpha0 = itk::Math::pi - angle(e1.GetVnlVector(), e2.GetVnlVector()); + const double alpha1 = itk::Math::pi - angle(e2.GetVnlVector(), e0.GetVnlVector()); + const double alpha2 = itk::Math::pi - angle(e0.GetVnlVector(), e1.GetVnlVector()); // Surface area - double A = static_cast( + const double A = static_cast( itk::Math::abs(vnl_cross_3d((v1 - v0).GetVnlVector(), (v2 - v0).GetVnlVector()).two_norm() / 2.0)); dA[point_ids[0]] += A; diff --git a/Modules/Core/Mesh/include/itkTriangleMeshToBinaryImageFilter.hxx b/Modules/Core/Mesh/include/itkTriangleMeshToBinaryImageFilter.hxx index b4d4c7ed309..807a4ae8318 100644 --- a/Modules/Core/Mesh/include/itkTriangleMeshToBinaryImageFilter.hxx +++ b/Modules/Core/Mesh/include/itkTriangleMeshToBinaryImageFilter.hxx @@ -85,8 +85,8 @@ template void TriangleMeshToBinaryImageFilter::SetSpacing(const float spacing[3]) { - Vector sf(spacing); - SpacingType s; + const Vector sf(spacing); + SpacingType s; s.CastFrom(sf); this->SetSpacing(s); } @@ -95,7 +95,7 @@ template void TriangleMeshToBinaryImageFilter::SetOrigin(const double origin[3]) { - PointType p(origin); + const PointType p(origin); this->SetOrigin(p); } @@ -104,8 +104,8 @@ template void TriangleMeshToBinaryImageFilter::SetOrigin(const float origin[3]) { - Point of(origin); - PointType p; + const Point of(origin); + PointType p; p.CastFrom(of); this->SetOrigin(p); } @@ -139,7 +139,7 @@ TriangleMeshToBinaryImageFilter::GenerateData() itkDebugMacro("TriangleMeshToBinaryImageFilter::Update() called"); // Get the input and output pointers - OutputImagePointer OutputImage = this->GetOutput(); + const OutputImagePointer OutputImage = this->GetOutput(); if (m_InfoImage == nullptr) { if (m_Size[0] == 0 || m_Size[1] == 0 || m_Size[2] == 0) @@ -183,8 +183,8 @@ TriangleMeshToBinaryImageFilter::PolygonToImageRaster( // convert the polygon into a rasterizable form by finding its // intersection with each z plane, and store the (x,y) coords // of each intersection in a vector called "matrix" - int zSize = extent[5] - extent[4] + 1; - int zInc = extent[3] - extent[2] + 1; + const int zSize = extent[5] - extent[4] + 1; + const int zInc = extent[3] - extent[2] + 1; Point2DArray matrix(zSize); // each iteration of the following loop examines one edge of the @@ -200,10 +200,10 @@ TriangleMeshToBinaryImageFilter::PolygonToImageRaster( // calculate the area (actually double the area) of the polygon's // projection into the zy plane via cross product, one triangle // at a time - double v1y = p1[1] - p0[1]; - double v1z = p1[2] - p0[2]; - double v2y = p2[1] - p0[1]; - double v2z = p2[2] - p0[2]; + const double v1y = p1[1] - p0[1]; + const double v1z = p1[2] - p0[2]; + const double v2y = p2[1] - p0[1]; + const double v2z = p2[2] - p0[2]; area += (v1y * v2z - v2y * v1z); // skip any line segments that are perfectly horizontal @@ -233,12 +233,12 @@ TriangleMeshToBinaryImageFilter::PolygonToImageRaster( { zmax = extent[5] + 1; } - double temp = 1.0 / (p2[2] - p1[2]); + const double temp = 1.0 / (p2[2] - p1[2]); for (int z = zmin; z < zmax; ++z) { - double r = (p2[2] - static_cast(z)) * temp; - double f = 1.0 - r; - Point2DType XY; + const double r = (p2[2] - static_cast(z)) * temp; + const double f = 1.0 - r; + Point2DType XY; XY[0] = r * p1[0] + f * p2[0]; XY[1] = r * p1[1] + f * p2[1]; matrix[z - extent[4]].push_back(XY); @@ -283,27 +283,27 @@ TriangleMeshToBinaryImageFilter::PolygonToImageRaster( for (int k = 0; k < n; ++k) { Point2DType & p2D1 = xylist[2 * k]; - double X1 = p2D1[0]; - double Y1 = p2D1[1]; + const double X1 = p2D1[0]; + const double Y1 = p2D1[1]; Point2DType & p2D2 = xylist[2 * k + 1]; - double X2 = p2D2[0]; - double Y2 = p2D2[1]; + const double X2 = p2D2[0]; + const double Y2 = p2D2[1]; if (Math::ExactlyEquals(Y2, Y1)) { continue; } - double temp = 1.0 / (Y2 - Y1); - auto ymin = static_cast(std::ceil(Y1)); - auto ymax = static_cast(std::ceil(Y2)); + const double temp = 1.0 / (Y2 - Y1); + auto ymin = static_cast(std::ceil(Y1)); + auto ymax = static_cast(std::ceil(Y2)); for (int y = ymin; y < ymax; ++y) { - double r = (Y2 - y) * temp; - double f = 1.0 - r; - double X = r * X1 + f * X2; + const double r = (Y2 - y) * temp; + const double f = 1.0 - r; + const double X = r * X1 + f * X2; if (extent[2] <= y && y <= extent[3]) { - int zyidx = (z - extent[4]) * zInc + (y - extent[2]); + const int zyidx = (z - extent[4]) * zInc + (y - extent[2]); zymatrix[zyidx].push_back(Point1D(X, sign)); } } @@ -317,10 +317,10 @@ template void TriangleMeshToBinaryImageFilter::RasterizeTriangles() { - InputMeshPointer input = this->GetInput(0); + const InputMeshPointer input = this->GetInput(0); - InputPointsContainerPointer myPoints = input->GetPoints(); - InputPointsContainerIterator points = myPoints->Begin(); + const InputPointsContainerPointer myPoints = input->GetPoints(); + InputPointsContainerIterator points = myPoints->Begin(); int extent[6]; @@ -332,7 +332,7 @@ TriangleMeshToBinaryImageFilter::RasterizeTriangles() extent[4] = m_Index[2]; extent[5] = m_Size[2] - 1; - OutputImagePointer OutputImage = this->GetOutput(); + const OutputImagePointer OutputImage = this->GetOutput(); // need to transform points from physical to index coordinates auto NewPoints = PointsContainer::New(); @@ -343,7 +343,7 @@ TriangleMeshToBinaryImageFilter::RasterizeTriangles() while (points != myPoints->End()) { - PointType p = points.Value(); + const PointType p = points.Value(); // the index value type must match the point value type const ContinuousIndex ind = OutputImage->template TransformPhysicalPointToContinuousIndex(p); @@ -356,13 +356,13 @@ TriangleMeshToBinaryImageFilter::RasterizeTriangles() // the stencil is kept in 'zymatrix' that provides // the x extents for each (y,z) coordinate for which a ray // parallel to the x axis intersects the polydata - int zInc = extent[3] - extent[2] + 1; - int zSize = extent[5] - extent[4] + 1; + const int zInc = extent[3] - extent[2] + 1; + const int zSize = extent[5] - extent[4] + 1; Point1DArray zymatrix(zInc * zSize); PointVector coords; - CellsContainerPointer cells = input->GetCells(); - CellsContainerIterator cellIt = cells->Begin(); + const CellsContainerPointer cells = input->GetCells(); + CellsContainerIterator cellIt = cells->Begin(); while (cellIt != cells->End()) { @@ -399,14 +399,14 @@ TriangleMeshToBinaryImageFilter::RasterizeTriangles() ++cellIt; } - OutputImagePointer outputImage = this->GetOutput(); + const OutputImagePointer outputImage = this->GetOutput(); outputImage->FillBuffer(m_OutsideValue); for (int z = extent[4]; z <= extent[5]; ++z) { for (int y = extent[2]; y <= extent[3]; ++y) { - int zyidx = (z - extent[4]) * zInc + (y - extent[2]); + const int zyidx = (z - extent[4]) * zInc + (y - extent[2]); Point1DVector xlist = zymatrix[zyidx]; if (xlist.size() <= 1) @@ -430,12 +430,12 @@ TriangleMeshToBinaryImageFilter::RasterizeTriangles() // surface std::vector nlist; - size_t m = xlist.size(); + const size_t m = xlist.size(); for (size_t j = 1; j < m; ++j) { - Point1D p1D = xlist[j]; - double x = p1D.m_X; - int sign = p1D.m_Sign; + const Point1D p1D = xlist[j]; + const double x = p1D.m_X; + const int sign = p1D.m_Sign; // check absolute distance from lastx to x if (itk::Math::abs(x - lastx) > m_Tolerance) @@ -453,8 +453,8 @@ TriangleMeshToBinaryImageFilter::RasterizeTriangles() nlist.push_back(lastx); // create the stencil extents - int minx1 = extent[0]; // minimum allowable x1 value - int n = static_cast(nlist.size()) / 2; + int minx1 = extent[0]; // minimum allowable x1 value + const int n = static_cast(nlist.size()) / 2; for (int i = 0; i < n; ++i) { diff --git a/Modules/Core/Mesh/include/itkTriangleMeshToSimplexMeshFilter.hxx b/Modules/Core/Mesh/include/itkTriangleMeshToSimplexMeshFilter.hxx index 4b5e1d58a59..86cdaee0ce1 100644 --- a/Modules/Core/Mesh/include/itkTriangleMeshToSimplexMeshFilter.hxx +++ b/Modules/Core/Mesh/include/itkTriangleMeshToSimplexMeshFilter.hxx @@ -32,7 +32,7 @@ TriangleMeshToSimplexMeshFilter::TriangleMeshToSimplexM , m_EdgeCellId(0) , m_HandledEdgeIds(IdVectorType::New()) { - OutputMeshPointer output = TOutputMesh::New(); + const OutputMeshPointer output = TOutputMesh::New(); this->ProcessObject::SetNumberOfRequiredOutputs(1); this->ProcessObject::SetNthOutput(0, output.GetPointer()); @@ -114,11 +114,11 @@ TriangleMeshToSimplexMeshFilter::CreateSimplexPoints() while (faceIterator != m_FaceSet->end()) { - InputPointType newPoint = ComputeFaceCenter(*faceIterator, input); - OutputPointType copyPoint; + const InputPointType newPoint = ComputeFaceCenter(*faceIterator, input); + OutputPointType copyPoint; copyPoint.CastFrom(newPoint); - unsigned int id = *faceIterator; + const unsigned int id = *faceIterator; output->SetPoint(id, copyPoint); output->SetGeometryData(id, new itk::SimplexMeshGeometry()); ++faceIterator; @@ -131,7 +131,7 @@ TriangleMeshToSimplexMeshFilter::CreateEdgeForTriangleP CellIdentifier boundaryId, TOutputMesh * outputMesh) { - EdgeIdentifierType facePair = m_EdgeNeighborList->GetElement(boundaryId); + const EdgeIdentifierType facePair = m_EdgeNeighborList->GetElement(boundaryId); if (facePair.first == pointIndex) { @@ -144,7 +144,7 @@ TriangleMeshToSimplexMeshFilter::CreateEdgeForTriangleP if (!m_HandledEdgeIds->IndexExists(boundaryId)) { - CellIdentifier edgeId = outputMesh->AddEdge(facePair.first, facePair.second); + const CellIdentifier edgeId = outputMesh->AddEdge(facePair.first, facePair.second); m_LineCellIndices->InsertElement(facePair, edgeId); m_HandledEdgeIds->InsertElement(boundaryId, edgeId); } @@ -157,21 +157,21 @@ TriangleMeshToSimplexMeshFilter::CreateSimplexNeighbors TOutputMesh * output = this->GetOutput(0); // add neighbor vertices - OutputPointsContainerPointer outputPointsContainer = output->GetPoints(); - OutputPointsContainerIterator points = outputPointsContainer->Begin(); + const OutputPointsContainerPointer outputPointsContainer = output->GetPoints(); + OutputPointsContainerIterator points = outputPointsContainer->Begin(); - InputBoundaryAssignmentsContainerPointer cntlines = this->GetInput(0)->GetBoundaryAssignments(1); + const InputBoundaryAssignmentsContainerPointer cntlines = this->GetInput(0)->GetBoundaryAssignments(1); while (points != outputPointsContainer->End()) { - PointIdentifier idx = points.Index(); - InputBoundnaryAssignmentIdentifier key0(idx, 0); - InputBoundnaryAssignmentIdentifier key1(idx, 1); - InputBoundnaryAssignmentIdentifier key2(idx, 2); + const PointIdentifier idx = points.Index(); + const InputBoundnaryAssignmentIdentifier key0(idx, 0); + const InputBoundnaryAssignmentIdentifier key1(idx, 1); + const InputBoundnaryAssignmentIdentifier key2(idx, 2); - CellIdentifier tp0 = cntlines->GetElement(key0); - CellIdentifier tp1 = cntlines->GetElement(key1); - CellIdentifier tp2 = cntlines->GetElement(key2); + const CellIdentifier tp0 = cntlines->GetElement(key0); + const CellIdentifier tp1 = cntlines->GetElement(key1); + const CellIdentifier tp2 = cntlines->GetElement(key2); CreateEdgeForTrianglePair(idx, tp0, output); CreateEdgeForTrianglePair(idx, tp1, output); @@ -194,8 +194,8 @@ TriangleMeshToSimplexMeshFilter::CreateNewEdge(CellIden // The filter shouldn't modify the input... auto * nonConstInput = const_cast(input); - EdgeIdentifierType edge = std::make_pair(startPointId, endPointId); - EdgeIdentifierType edgeInv = std::make_pair(endPointId, startPointId); + const EdgeIdentifierType edge = std::make_pair(startPointId, endPointId); + const EdgeIdentifierType edgeInv = std::make_pair(endPointId, startPointId); if (!m_Edges->IndexExists(edge) && !m_Edges->IndexExists(edgeInv)) { @@ -222,7 +222,7 @@ TriangleMeshToSimplexMeshFilter::CreateNewEdge(CellIden if (!m_EdgeNeighborList->IndexExists(boundaryId)) { - EdgeIdentifierType neighboringCells = + const EdgeIdentifierType neighboringCells = std::make_pair(currentCellId, (CellIdentifier)NumericTraits::max()); m_EdgeNeighborList->InsertElement(boundaryId, neighboringCells); } @@ -304,8 +304,8 @@ TriangleMeshToSimplexMeshFilter::CreateCells() while (points != pointsContainer->End()) { - PointIdentifier idx = points.Index(); - IndexSetType vertexNeighbors = m_VertexNeighborList->GetElement(idx); + const PointIdentifier idx = points.Index(); + IndexSetType vertexNeighbors = m_VertexNeighborList->GetElement(idx); auto iterator1 = vertexNeighbors.begin(); @@ -318,7 +318,7 @@ TriangleMeshToSimplexMeshFilter::CreateCells() { if (startIdx == NumericTraits::max()) { - EdgeIdentifierType neighboringCells = m_EdgeNeighborList->GetElement(*iterator1); + const EdgeIdentifierType neighboringCells = m_EdgeNeighborList->GetElement(*iterator1); startIdx = neighboringCells.first; tmpMap->InsertElement(neighboringCells.first, neighboringCells.second); @@ -330,7 +330,7 @@ TriangleMeshToSimplexMeshFilter::CreateCells() auto iterator2 = vertexNeighbors.begin(); while (iterator2 != vertexNeighbors.end()) { - EdgeIdentifierType compare = m_EdgeNeighborList->GetElement(*iterator2); + const EdgeIdentifierType compare = m_EdgeNeighborList->GetElement(*iterator2); if (compare.first == lastIdx && compare.second != wrongIdx) { tmpMap->InsertElement(compare.first, compare.second); @@ -357,15 +357,15 @@ TriangleMeshToSimplexMeshFilter::CreateCells() CellIdentifier nextIdx = startIdx; CellFeatureIdentifier featureId = 0; - CellIdentifier faceIndex = outputMesh->AddFace(m_NewSimplexCellPointer); + const CellIdentifier faceIndex = outputMesh->AddFace(m_NewSimplexCellPointer); while (tmpMap->IndexExists(nextIdx)) { m_NewSimplexCellPointer->SetPointId(vertexIdx++, nextIdx); - CellIdentifier newIdx = tmpMap->GetElement(nextIdx); + const CellIdentifier newIdx = tmpMap->GetElement(nextIdx); - EdgeIdentifierType line = std::make_pair(nextIdx, newIdx); - EdgeIdentifierType lineInv = std::make_pair(newIdx, nextIdx); + const EdgeIdentifierType line = std::make_pair(nextIdx, newIdx); + const EdgeIdentifierType lineInv = std::make_pair(newIdx, nextIdx); CellIdentifier edgeIdx{}; diff --git a/Modules/Core/Mesh/include/itkVTKPolyDataReader.hxx b/Modules/Core/Mesh/include/itkVTKPolyDataReader.hxx index 5ff2a269df9..d80c8bb00d8 100644 --- a/Modules/Core/Mesh/include/itkVTKPolyDataReader.hxx +++ b/Modules/Core/Mesh/include/itkVTKPolyDataReader.hxx @@ -43,7 +43,7 @@ template void VTKPolyDataReader::GenerateData() { - typename OutputMeshType::Pointer outputMesh = this->GetOutput(); + const typename OutputMeshType::Pointer outputMesh = this->GetOutput(); outputMesh->SetCellsAllocationMethod(MeshEnums::MeshClassCellsAllocationMethod::CellsAllocatedDynamicallyCellByCell); @@ -116,7 +116,7 @@ VTKPolyDataReader::GenerateData() } itkDebugMacro("POINTS line" << line); - std::string pointLine(line, strlen("POINTS "), line.length()); + const std::string pointLine(line, strlen("POINTS "), line.length()); itkDebugMacro("pointLine " << pointLine); // we must use long here because this is the exact type specified by scanf @@ -178,7 +178,7 @@ VTKPolyDataReader::GenerateData() itkDebugMacro("POLYGONS line" << line); - std::string polygonLine(line, strlen("POLYGONS "), line.length()); + const std::string polygonLine(line, strlen("POLYGONS "), line.length()); itkDebugMacro("polygonLine " << polygonLine); // diff --git a/Modules/Core/Mesh/include/itkVTKPolyDataWriter.hxx b/Modules/Core/Mesh/include/itkVTKPolyDataWriter.hxx index 35d8fb12954..4e08e0ae14c 100644 --- a/Modules/Core/Mesh/include/itkVTKPolyDataWriter.hxx +++ b/Modules/Core/Mesh/include/itkVTKPolyDataWriter.hxx @@ -93,7 +93,7 @@ VTKPolyDataWriter::GenerateData() // POINTS go first - unsigned int numberOfPoints = this->m_Input->GetNumberOfPoints(); + const unsigned int numberOfPoints = this->m_Input->GetNumberOfPoints(); outputFile << "POINTS " << numberOfPoints << " float" << std::endl; const PointsContainer * points = this->m_Input->GetPoints(); @@ -103,8 +103,8 @@ VTKPolyDataWriter::GenerateData() if (points) { - PointIterator pointIterator = points->Begin(); - PointIterator pointEnd = points->End(); + PointIterator pointIterator = points->Begin(); + const PointIterator pointEnd = points->End(); while (pointIterator != pointEnd) { @@ -136,8 +136,8 @@ VTKPolyDataWriter::GenerateData() if (cells) { - CellIterator cellIterator = cells->Begin(); - CellIterator cellEnd = cells->End(); + CellIterator cellIterator = cells->Begin(); + const CellIterator cellEnd = cells->End(); while (cellIterator != cellEnd) { diff --git a/Modules/Core/Mesh/include/itkWarpMeshFilter.hxx b/Modules/Core/Mesh/include/itkWarpMeshFilter.hxx index 750c2e5c6e2..5023fd6eca5 100644 --- a/Modules/Core/Mesh/include/itkWarpMeshFilter.hxx +++ b/Modules/Core/Mesh/include/itkWarpMeshFilter.hxx @@ -73,9 +73,9 @@ WarpMeshFilter::GenerateData() using OutputPointsContainerPointer = typename TOutputMesh::PointsContainerPointer; - const InputMeshType * inputMesh = this->GetInput(); - OutputMeshPointer outputMesh = this->GetOutput(); - DisplacementFieldPointer fieldPtr = this->GetDisplacementField(); + const InputMeshType * inputMesh = this->GetInput(); + const OutputMeshPointer outputMesh = this->GetOutput(); + const DisplacementFieldPointer fieldPtr = this->GetDisplacementField(); if (!inputMesh) { @@ -89,8 +89,8 @@ WarpMeshFilter::GenerateData() outputMesh->SetBufferedRegion(outputMesh->GetRequestedRegion()); - const InputPointsContainer * inPoints = inputMesh->GetPoints(); - OutputPointsContainerPointer outPoints = outputMesh->GetPoints(); + const InputPointsContainer * inPoints = inputMesh->GetPoints(); + const OutputPointsContainerPointer outPoints = outputMesh->GetPoints(); outPoints->Reserve(inputMesh->GetNumberOfPoints()); outPoints->Squeeze(); // in case the previous mesh had @@ -132,7 +132,7 @@ WarpMeshFilter::GenerateData() this->CopyInputMeshToOutputMeshCellLinks(); this->CopyInputMeshToOutputMeshCellData(); - unsigned int maxDimension = TInputMesh::MaxTopologicalDimension; + const unsigned int maxDimension = TInputMesh::MaxTopologicalDimension; for (unsigned int dim = 0; dim < maxDimension; ++dim) { diff --git a/Modules/Core/Mesh/src/itkSimplexMeshGeometry.cxx b/Modules/Core/Mesh/src/itkSimplexMeshGeometry.cxx index afca0684ae6..dfe7b383a88 100644 --- a/Modules/Core/Mesh/src/itkSimplexMeshGeometry.cxx +++ b/Modules/Core/Mesh/src/itkSimplexMeshGeometry.cxx @@ -25,8 +25,8 @@ namespace itk { SimplexMeshGeometry::SimplexMeshGeometry() { - double c = 1.0 / 3.0; - PointType p{}; + const double c = 1.0 / 3.0; + const PointType p{}; pos.Fill(0); oldPos.Fill(0); @@ -73,7 +73,7 @@ SimplexMeshGeometry::ComputeGeometry() tmp.SetVnlVector(b.GetSquaredNorm() * vnl_cross_3d(cXb.GetVnlVector(), c.GetVnlVector()) + c.GetSquaredNorm() * vnl_cross_3d(b.GetVnlVector(), cXb.GetVnlVector())); - double cXbSquaredNorm = 2 * cXb.GetSquaredNorm(); + const double cXbSquaredNorm = 2 * cXb.GetSquaredNorm(); circleRadius = tmp.GetNorm() / (cXbSquaredNorm); tmp[0] /= (cXbSquaredNorm); diff --git a/Modules/Core/Mesh/test/itkBinaryMask3DMeshSourceTest.cxx b/Modules/Core/Mesh/test/itkBinaryMask3DMeshSourceTest.cxx index 6a390a07a7f..b56ee7e6da7 100644 --- a/Modules/Core/Mesh/test/itkBinaryMask3DMeshSourceTest.cxx +++ b/Modules/Core/Mesh/test/itkBinaryMask3DMeshSourceTest.cxx @@ -80,21 +80,21 @@ itkBinaryMask3DMeshSourceTest(int argc, char * argv[]) size[1] = 128; size[2] = 128; - IndexType start{}; + const IndexType start{}; RegionType region{ start, size }; - ImagePointerType image = ImageType::New(); + const ImagePointerType image = ImageType::New(); image->SetRegions(region); image->Allocate(); image->FillBuffer(backgroundValue); for (unsigned char counter = 0; counter < 18; ++counter) { - unsigned int i = (counter / 1) % 2; // 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1. - unsigned int j = (counter / 2) % 2; // 0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1. - unsigned int k = (counter / 4) % 2; // 0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1. - unsigned int l = (counter / 8) % 2; // 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1. + const unsigned int i = (counter / 1) % 2; // 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1. + const unsigned int j = (counter / 2) % 2; // 0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1. + const unsigned int k = (counter / 4) % 2; // 0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1. + const unsigned int l = (counter / 8) % 2; // 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1. Create16CubeConfig(image, 0, 0, 3 * counter, i, j, k, l); } diff --git a/Modules/Core/Mesh/test/itkCellInterfaceTest.cxx b/Modules/Core/Mesh/test/itkCellInterfaceTest.cxx index fcd498b3801..df097213b01 100644 --- a/Modules/Core/Mesh/test/itkCellInterfaceTest.cxx +++ b/Modules/Core/Mesh/test/itkCellInterfaceTest.cxx @@ -46,7 +46,7 @@ template int TestCellInterface(std::string name, TCell * aCell) { - CellAutoPointer cell(aCell, true); + const CellAutoPointer cell(aCell, true); std::cout << "-------- " << name << " (" << aCell->GetNameOfClass() << ')' << std::endl; std::cout << " Type: " << static_cast(cell->GetType()) << std::endl; diff --git a/Modules/Core/Mesh/test/itkConnectedRegionsMeshFilterTest1.cxx b/Modules/Core/Mesh/test/itkConnectedRegionsMeshFilterTest1.cxx index a1c73a3589d..7fd59dc2c36 100644 --- a/Modules/Core/Mesh/test/itkConnectedRegionsMeshFilterTest1.cxx +++ b/Modules/Core/Mesh/test/itkConnectedRegionsMeshFilterTest1.cxx @@ -44,9 +44,9 @@ itkConnectedRegionsMeshFilterTest1(int, char *[]) // Pass the mesh through the filter in a variety of ways. // - PointType::ValueType pInit[3] = { 1, 2, 3 }; - PointType p = pInit; - auto connect = ConnectFilterType::New(); + const PointType::ValueType pInit[3] = { 1, 2, 3 }; + PointType p = pInit; + auto connect = ConnectFilterType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(connect, ConnectedRegionsMeshFilter, MeshToMeshFilter); @@ -96,9 +96,9 @@ itkConnectedRegionsMeshFilterTest1(int, char *[]) auto meshSource = SphereMeshSourceType::New(); - PointType center{}; - PointType::ValueType scaleInit[3] = { 1, 1, 1 }; - PointType scale = scaleInit; + const PointType center{}; + const PointType::ValueType scaleInit[3] = { 1, 1, 1 }; + const PointType scale = scaleInit; meshSource->SetCenter(center); meshSource->SetResolutionX(10); diff --git a/Modules/Core/Mesh/test/itkConnectedRegionsMeshFilterTest2.cxx b/Modules/Core/Mesh/test/itkConnectedRegionsMeshFilterTest2.cxx index 2cb18d24a0a..3d1a11bb00c 100644 --- a/Modules/Core/Mesh/test/itkConnectedRegionsMeshFilterTest2.cxx +++ b/Modules/Core/Mesh/test/itkConnectedRegionsMeshFilterTest2.cxx @@ -36,9 +36,9 @@ itkConnectedRegionsMeshFilterTest2(int argc, char * argv[]) } // Check if input file is a mesh file or image file by checking presence of .vtk - std::string fileName(argv[1]); - size_t found = fileName.find(".vtk"); - bool imageSource = true; + const std::string fileName(argv[1]); + const size_t found = fileName.find(".vtk"); + bool imageSource = true; if (found != std::string::npos) { @@ -87,14 +87,14 @@ itkConnectedRegionsMeshFilterTest2(int argc, char * argv[]) { // Read the test mesh using MeshFileReader using ReaderType = itk::MeshFileReader; - ReaderType::Pointer polyDataReader = ReaderType::New(); + const ReaderType::Pointer polyDataReader = ReaderType::New(); polyDataReader->SetFileName(fileName); ITK_TRY_EXPECT_NO_EXCEPTION(polyDataReader->Update()); mesh = polyDataReader->GetOutput(); } - unsigned int numberOfConnectedComponents = std::stoi(argv[2]); - unsigned int numberOfCellsInLargestComponent = std::stoi(argv[3]); + const unsigned int numberOfConnectedComponents = std::stoi(argv[2]); + const unsigned int numberOfCellsInLargestComponent = std::stoi(argv[3]); // Check number of connected components in the mesh using ConnectFilterType = itk::ConnectedRegionsMeshFilter; diff --git a/Modules/Core/Mesh/test/itkDynamicMeshTest.cxx b/Modules/Core/Mesh/test/itkDynamicMeshTest.cxx index 29014adad38..839b13e795a 100644 --- a/Modules/Core/Mesh/test/itkDynamicMeshTest.cxx +++ b/Modules/Core/Mesh/test/itkDynamicMeshTest.cxx @@ -63,7 +63,7 @@ itkDynamicMeshTest(int, char *[]) /** * Create the mesh through its object factory. */ - MeshType::Pointer mesh(MeshType::New()); + const MeshType::Pointer mesh(MeshType::New()); PointType pointA; PointType pointB; @@ -80,7 +80,7 @@ itkDynamicMeshTest(int, char *[]) pointC = pointB + displacement; pointD = pointC + displacement; - PointsContainer::Pointer pointsContainter = mesh->GetPoints(); + const PointsContainer::Pointer pointsContainter = mesh->GetPoints(); pointsContainter->SetElement(0, pointA); pointsContainter->SetElement(1, pointB); @@ -90,8 +90,8 @@ itkDynamicMeshTest(int, char *[]) std::cout << "Number of Points = " << mesh->GetNumberOfPoints() << std::endl; - PointsIterator point = pointsContainter->Begin(); - PointsIterator endpoint = pointsContainter->End(); + PointsIterator point = pointsContainter->Begin(); + const PointsIterator endpoint = pointsContainter->End(); while (point != endpoint) { diff --git a/Modules/Core/Mesh/test/itkImageToParametricSpaceFilterTest.cxx b/Modules/Core/Mesh/test/itkImageToParametricSpaceFilterTest.cxx index b3ce99da502..6761a2b3bff 100644 --- a/Modules/Core/Mesh/test/itkImageToParametricSpaceFilterTest.cxx +++ b/Modules/Core/Mesh/test/itkImageToParametricSpaceFilterTest.cxx @@ -47,7 +47,7 @@ itkImageToParametricSpaceFilterTest(int, char *[]) auto inputMesh = MeshType::New(); // Insert data on the Mesh - PointsContainerPointer points = inputMesh->GetPoints(); + const PointsContainerPointer points = inputMesh->GetPoints(); // Declare the type for the images @@ -59,16 +59,16 @@ itkImageToParametricSpaceFilterTest(int, char *[]) using FilterPointer = FilterType::Pointer; - ImagePointer imageX = ImageType::New(); - ImagePointer imageY = ImageType::New(); - ImagePointer imageZ = ImageType::New(); + const ImagePointer imageX = ImageType::New(); + const ImagePointer imageY = ImageType::New(); + const ImagePointer imageZ = ImageType::New(); - ImageType::SizeType size; - ImageType::IndexType start{}; + ImageType::SizeType size; + const ImageType::IndexType start{}; size[0] = 10; size[1] = 10; - ImageType::RegionType region{ start, size }; + const ImageType::RegionType region{ start, size }; imageX->SetRegions(region); imageY->SetRegions(region); @@ -106,12 +106,12 @@ itkImageToParametricSpaceFilterTest(int, char *[]) } - FilterPointer filter = FilterType::New(); + const FilterPointer filter = FilterType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, ImageToParametricSpaceFilter, ImageToMeshFilter); - bool computeIndices = true; + const bool computeIndices = true; ITK_TEST_SET_GET_BOOLEAN(filter, ComputeIndices, computeIndices); // Connect the inputs @@ -123,12 +123,12 @@ itkImageToParametricSpaceFilterTest(int, char *[]) filter->Update(); // Get the Smart Pointer to the Filter Output - MeshType::Pointer outputMesh = filter->GetOutput(); + const MeshType::Pointer outputMesh = filter->GetOutput(); // Get the point container - MeshType::PointsContainer::Iterator beginPoint = outputMesh->GetPoints()->Begin(); + const MeshType::PointsContainer::Iterator beginPoint = outputMesh->GetPoints()->Begin(); - MeshType::PointsContainer::Iterator endPoint = outputMesh->GetPoints()->End(); + const MeshType::PointsContainer::Iterator endPoint = outputMesh->GetPoints()->End(); MeshType::PointsContainer::Iterator pointIt = beginPoint; diff --git a/Modules/Core/Mesh/test/itkInteriorExteriorMeshFilterTest.cxx b/Modules/Core/Mesh/test/itkInteriorExteriorMeshFilterTest.cxx index 4765004b46d..a119abd4d10 100644 --- a/Modules/Core/Mesh/test/itkInteriorExteriorMeshFilterTest.cxx +++ b/Modules/Core/Mesh/test/itkInteriorExteriorMeshFilterTest.cxx @@ -48,10 +48,10 @@ itkInteriorExteriorMeshFilterTest(int, char *[]) auto inputMesh = MeshType::New(); // Insert data on the Mesh - PointsContainerPointer points = inputMesh->GetPoints(); + const PointsContainerPointer points = inputMesh->GetPoints(); // Fill a cube with points , just to get some data - int n = 3; // let's start with a few of them + const int n = 3; // let's start with a few of them PointsContainerType::ElementIdentifier count = 0; // count them for (int x = -n; x <= n; ++x) @@ -111,17 +111,17 @@ itkInteriorExteriorMeshFilterTest(int, char *[]) filter->Update(); // Get the Smart Pointer to the Filter Output - MeshType::Pointer outputMesh = filter->GetOutput(); + const MeshType::Pointer outputMesh = filter->GetOutput(); // Get the point container - MeshType::PointsContainerPointer transformedPoints = outputMesh->GetPoints(); + const MeshType::PointsContainerPointer transformedPoints = outputMesh->GetPoints(); PointsContainerType::ConstIterator it = transformedPoints->Begin(); while (it != transformedPoints->End()) { - PointType p = it.Value(); + const PointType p = it.Value(); const double distance = p.EuclideanDistanceTo(center); if (distance > radius) diff --git a/Modules/Core/Mesh/test/itkMeshRegionTest.cxx b/Modules/Core/Mesh/test/itkMeshRegionTest.cxx index 9ed127c5bb0..f69c3677e0b 100644 --- a/Modules/Core/Mesh/test/itkMeshRegionTest.cxx +++ b/Modules/Core/Mesh/test/itkMeshRegionTest.cxx @@ -31,11 +31,11 @@ itkMeshRegionTest(int, char *[]) ITK_TEST_SET_GET_VALUE(itk::MeshRegion::Superclass::RegionEnum::ITK_UNSTRUCTURED_REGION, meshRegion.GetRegionType()); - itk::SizeValueType numRegions = 10; + const itk::SizeValueType numRegions = 10; meshRegion.SetNumberOfRegions(numRegions); ITK_TEST_SET_GET_VALUE(numRegions, meshRegion.GetNumberOfRegions()); - itk::SizeValueType idx = 1; + const itk::SizeValueType idx = 1; meshRegion.SetRegion(idx); ITK_TEST_SET_GET_VALUE(idx, meshRegion.GetRegion()); diff --git a/Modules/Core/Mesh/test/itkMeshSourceGraftOutputTest.cxx b/Modules/Core/Mesh/test/itkMeshSourceGraftOutputTest.cxx index 528d4b843fb..198b239d099 100644 --- a/Modules/Core/Mesh/test/itkMeshSourceGraftOutputTest.cxx +++ b/Modules/Core/Mesh/test/itkMeshSourceGraftOutputTest.cxx @@ -101,8 +101,8 @@ template void MeshSourceGraftOutputFilter::GenerateData() { - const InputMeshType * inputMesh = this->GetInput(); - OutputMeshPointer outputMesh = this->GetOutput(); + const InputMeshType * inputMesh = this->GetInput(); + const OutputMeshPointer outputMesh = this->GetOutput(); if (!inputMesh) { @@ -182,7 +182,7 @@ itkMeshSourceGraftOutputTest(int, char *[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope // scope. - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); // Declare the mesh pixel type. // Those are the values associated @@ -207,10 +207,10 @@ itkMeshSourceGraftOutputTest(int, char *[]) auto inputMesh = MeshType::New(); // Insert data on the Mesh - PointsContainerPointer points = inputMesh->GetPoints(); + const PointsContainerPointer points = inputMesh->GetPoints(); // Fill a cube with points , just to get some data - int n = 1; // let's start with a few of them + const int n = 1; // let's start with a few of them PointsContainerType::ElementIdentifier count = 0; // count them for (int x = -n; x <= n; ++x) @@ -258,7 +258,7 @@ itkMeshSourceGraftOutputTest(int, char *[]) auto affineTransform = TransformType::New(); affineTransform->Scale(3.5); TransformType::OffsetType::ValueType tInit[3] = { 100, 200, 300 }; - TransformType::OffsetType translation = tInit; + const TransformType::OffsetType translation = tInit; affineTransform->Translate(translation); // Connect the inputs @@ -270,13 +270,13 @@ itkMeshSourceGraftOutputTest(int, char *[]) std::cout << "Filter: " << filter; // Get the Smart Pointer to the Filter Output - MeshType::Pointer outputMesh = filter->GetOutput(); + const MeshType::Pointer outputMesh = filter->GetOutput(); std::cout << "Output Mesh has " << outputMesh->GetNumberOfPoints(); std::cout << " points " << std::endl; // Get the point container - MeshType::PointsContainerPointer transformedPoints = outputMesh->GetPoints(); + const MeshType::PointsContainerPointer transformedPoints = outputMesh->GetPoints(); PointsContainerType::ConstIterator it = transformedPoints->Begin(); diff --git a/Modules/Core/Mesh/test/itkMeshSpatialObjectIOTest.cxx b/Modules/Core/Mesh/test/itkMeshSpatialObjectIOTest.cxx index 2d103b11378..77ef5e2178b 100644 --- a/Modules/Core/Mesh/test/itkMeshSpatialObjectIOTest.cxx +++ b/Modules/Core/Mesh/test/itkMeshSpatialObjectIOTest.cxx @@ -41,8 +41,8 @@ itkMeshSpatialObjectIOTest(int argc, char * argv[]) std::cout << "Creating Mesh File: "; auto mesh = MeshType::New(); - MeshType::CoordinateType testPointCoords[8][3] = { { 0, 1, 2 }, { 1, 2, 3 }, { 2, 3, 4 }, { 3, 4, 5 }, - { 4, 5, 6 }, { 5, 6, 7 }, { 6, 7, 8 }, { 7, 8, 9 } }; + const MeshType::CoordinateType testPointCoords[8][3] = { { 0, 1, 2 }, { 1, 2, 3 }, { 2, 3, 4 }, { 3, 4, 5 }, + { 4, 5, 6 }, { 5, 6, 7 }, { 6, 7, 8 }, { 7, 8, 9 } }; MeshType::PointIdentifier tetraPoints[4] = { 0, 1, 2, 3 }; @@ -138,7 +138,7 @@ itkMeshSpatialObjectIOTest(int argc, char * argv[]) reader->SetFileName(argv[1]); } reader->Update(); - ReaderType::GroupPointer myScene = reader->GetGroup(); + const ReaderType::GroupPointer myScene = reader->GetGroup(); if (!myScene) { std::cout << "No Scene : [FAILED]" << std::endl; @@ -154,7 +154,8 @@ itkMeshSpatialObjectIOTest(int argc, char * argv[]) return EXIT_FAILURE; } - MeshSpatialObjectType::Pointer meshSO2 = dynamic_cast((*(children->begin())).GetPointer()); + const MeshSpatialObjectType::Pointer meshSO2 = + dynamic_cast((*(children->begin())).GetPointer()); std::cout << "Testing ID : "; if (meshSO2->GetId() != 3) @@ -165,7 +166,7 @@ itkMeshSpatialObjectIOTest(int argc, char * argv[]) std::cout << " [PASSED]" << std::endl; std::cout << "Testing Points: "; - MeshType::Pointer mesh2 = meshSO2->GetMesh(); + const MeshType::Pointer mesh2 = meshSO2->GetMesh(); // Testing points const MeshType::PointsContainer * points = mesh2->GetPoints(); MeshType::PointsContainer::ConstIterator it_points = points->Begin(); diff --git a/Modules/Core/Mesh/test/itkMeshTest.cxx b/Modules/Core/Mesh/test/itkMeshTest.cxx index 7c6b6f89869..cf3cca6b019 100644 --- a/Modules/Core/Mesh/test/itkMeshTest.cxx +++ b/Modules/Core/Mesh/test/itkMeshTest.cxx @@ -142,14 +142,14 @@ itkMeshTest(int, char *[]) using namespace itkMeshTestTypes; // open the namespace here. // this is safe because only happens locally. - itk::FileOutputWindow::Pointer fow = itk::FileOutputWindow::New(); + const itk::FileOutputWindow::Pointer fow = itk::FileOutputWindow::New(); fow->SetInstance(fow); /** * Define the 3d geometric positions for 8 points in a cube. */ - MeshType::CoordinateType testPointCoords[8][3] = { { 0, 0, 0 }, { 9, 0, 0 }, { 9, 0, 9 }, { 0, 0, 9 }, - { 0, 9, 0 }, { 9, 9, 0 }, { 9, 9, 9 }, { 0, 9, 9 } }; + const MeshType::CoordinateType testPointCoords[8][3] = { { 0, 0, 0 }, { 9, 0, 0 }, { 9, 0, 9 }, { 0, 0, 9 }, + { 0, 9, 0 }, { 9, 9, 0 }, { 9, 9, 9 }, { 0, 9, 9 } }; /** * List the points that the tetrahedron will use from the mesh. @@ -210,8 +210,8 @@ itkMeshTest(int, char *[]) iter != cellPointMap.end(); ++iter) { - itk::CellGeometryEnum cellType = iter->first; - unsigned int numOfPoints = iter->second; + const itk::CellGeometryEnum cellType = iter->first; + const unsigned int numOfPoints = iter->second; // Insert cell type cellVectorContainer->InsertElement(index++, static_cast(cellType)); @@ -235,8 +235,8 @@ itkMeshTest(int, char *[]) iter != cellPointMap.end(); ++iter) { - unsigned int numOfPoints = iter->second; - CellAutoPointer temp_cell; + const unsigned int numOfPoints = iter->second; + CellAutoPointer temp_cell; if (mesh0->GetCell(index++, temp_cell)) { @@ -249,7 +249,7 @@ itkMeshTest(int, char *[]) // Test the SetCellsArray with same cell type functionality index = 0; - unsigned int numOfCells = 3; + const unsigned int numOfCells = 3; cellVectorContainer->Initialize(); for (unsigned int i = 0; i < numOfCells; ++i) @@ -432,7 +432,7 @@ itkMeshTest(int, char *[]) * triangles that bound the 3D cells haven't been added, so they * don't show up as additional neighbors.) */ - int numberOfNeighbors = + const int numberOfNeighbors = mesh->GetCellBoundaryFeatureNeighbors(1, // Topological dimension of feature. 1, // CellIdentifier 1, // CellFeatureIdentifier @@ -691,14 +691,14 @@ itkMeshTest(int, char *[]) MeshType::CoordinateType, MeshType::PointsContainer>; - BoundingBox::Pointer bbox(BoundingBox::New()); + const BoundingBox::Pointer bbox(BoundingBox::New()); bbox->SetPoints(mesh->GetPoints()); bbox->ComputeBoundingBox(); /** * Set up some visitors */ - MeshType::CellType::MultiVisitor::Pointer mv = MeshType::CellType::MultiVisitor::New(); + const MeshType::CellType::MultiVisitor::Pointer mv = MeshType::CellType::MultiVisitor::New(); /** * Create a class to hold the counts of each cell type */ diff --git a/Modules/Core/Mesh/test/itkNewTest.cxx b/Modules/Core/Mesh/test/itkNewTest.cxx index 2bde9407729..996b0c0c310 100644 --- a/Modules/Core/Mesh/test/itkNewTest.cxx +++ b/Modules/Core/Mesh/test/itkNewTest.cxx @@ -57,7 +57,7 @@ itkNewTest(int, char *[]) // Call New and Print on as many classes as possible // CellInterfaceVisitorImplementation - itk::CellInterfaceVisitorImplementation::CellTraits, Bogus, Bogus>::Pointer CIVI = + const itk::CellInterfaceVisitorImplementation::CellTraits, Bogus, Bogus>::Pointer CIVI = itk::CellInterfaceVisitorImplementation::CellTraits, Bogus, Bogus>::New(); if (CIVI.IsNull()) { diff --git a/Modules/Core/Mesh/test/itkParametricSpaceToImageSpaceMeshFilterTest.cxx b/Modules/Core/Mesh/test/itkParametricSpaceToImageSpaceMeshFilterTest.cxx index cd98f733044..5bbfc6cf411 100644 --- a/Modules/Core/Mesh/test/itkParametricSpaceToImageSpaceMeshFilterTest.cxx +++ b/Modules/Core/Mesh/test/itkParametricSpaceToImageSpaceMeshFilterTest.cxx @@ -92,7 +92,7 @@ InternalTest(int argc, char * argv[]) // Store the input image for convenience - typename ImageType::Pointer image = reader->GetOutput(); + const typename ImageType::Pointer image = reader->GetOutput(); auto mesh = InputMeshType::New(); @@ -106,7 +106,7 @@ InternalTest(int argc, char * argv[]) using PointDataContainer = typename InputMeshType::PointDataContainer; using PointDataContainerPointer = typename InputMeshType::PointDataContainerPointer; - PointDataContainerPointer pointData = PointDataContainer::New(); + const PointDataContainerPointer pointData = PointDataContainer::New(); // Define arbitrary initial value for mesh point data typename InputMeshType::PointIdentifier pointId = 0; @@ -126,7 +126,7 @@ InternalTest(int argc, char * argv[]) mesh->SetPoint(pointId, point); // Transfer the data to the value associated with the elementId - PositionType position = helper::GetPosition(image.GetPointer(), imageIterator); + const PositionType position = helper::GetPosition(image.GetPointer(), imageIterator); pointData->InsertElement(pointId, position); ++imageIterator; ++pointId; diff --git a/Modules/Core/Mesh/test/itkQuadrilateralCellTest.cxx b/Modules/Core/Mesh/test/itkQuadrilateralCellTest.cxx index cf52294c457..fd0f0402126 100644 --- a/Modules/Core/Mesh/test/itkQuadrilateralCellTest.cxx +++ b/Modules/Core/Mesh/test/itkQuadrilateralCellTest.cxx @@ -88,8 +88,9 @@ itkQuadrilateralCellTest(int, char *[]) */ constexpr unsigned int Dimension = 3; // Test points are on a plane at an angle (3^2 + 4^2 = 5^2) with xy plane - MeshType::CoordinateType testPointCoords[numberOfPoints][Dimension] = { { 0, 0, 0 }, { 10, 0, 0 }, { 0, 8, 6 }, - { 10, 8, 6 }, { 0, 16, 12 }, { 10, 16, 12 } }; + const MeshType::CoordinateType testPointCoords[numberOfPoints][Dimension] = { { 0, 0, 0 }, { 10, 0, 0 }, + { 0, 8, 6 }, { 10, 8, 6 }, + { 0, 16, 12 }, { 10, 16, 12 } }; /** * Add our test points to the mesh. diff --git a/Modules/Core/Mesh/test/itkRegularSphereMeshSourceTest.cxx b/Modules/Core/Mesh/test/itkRegularSphereMeshSourceTest.cxx index 67d17b19d60..1aad4be455a 100644 --- a/Modules/Core/Mesh/test/itkRegularSphereMeshSourceTest.cxx +++ b/Modules/Core/Mesh/test/itkRegularSphereMeshSourceTest.cxx @@ -47,7 +47,7 @@ itkRegularSphereMeshSourceTest(int, char *[]) mySphereMeshSource->SetCenter(center); ITK_TEST_SET_GET_VALUE(center, mySphereMeshSource->GetCenter()); - unsigned int resolution = 1; + const unsigned int resolution = 1; mySphereMeshSource->SetResolution(resolution); ITK_TEST_SET_GET_VALUE(resolution, mySphereMeshSource->GetResolution()); @@ -59,7 +59,7 @@ itkRegularSphereMeshSourceTest(int, char *[]) ITK_TRY_EXPECT_NO_EXCEPTION(mySphereMeshSource->Update()); - MeshType::Pointer myMesh = mySphereMeshSource->GetOutput(); + const MeshType::Pointer myMesh = mySphereMeshSource->GetOutput(); PointType pt{}; @@ -83,7 +83,7 @@ itkRegularSphereMeshSourceTest(int, char *[]) using CellsContainerPointer = MeshType::CellsContainerPointer; using CellType = MeshType::CellType; - CellsContainerPointer cells = myMesh->GetCells(); + const CellsContainerPointer cells = myMesh->GetCells(); unsigned int faceId = 0; diff --git a/Modules/Core/Mesh/test/itkRegularSphereMeshSourceTest2.cxx b/Modules/Core/Mesh/test/itkRegularSphereMeshSourceTest2.cxx index 8ed512e916f..488443aace6 100644 --- a/Modules/Core/Mesh/test/itkRegularSphereMeshSourceTest2.cxx +++ b/Modules/Core/Mesh/test/itkRegularSphereMeshSourceTest2.cxx @@ -37,7 +37,7 @@ itkRegularSphereMeshSourceTest2(int, char *[]) source1->SetScale(scale); source1->Update(); - MeshType::Pointer mesh1 = source1->GetOutput(); + const MeshType::Pointer mesh1 = source1->GetOutput(); if (mesh1->GetCellsAllocationMethod() != itk::MeshEnums::MeshClassCellsAllocationMethod::CellsAllocatedDynamicallyCellByCell) @@ -52,16 +52,16 @@ itkRegularSphereMeshSourceTest2(int, char *[]) source2->SetScale(scale); source2->Update(); - MeshType::Pointer mesh2 = source2->GetOutput(); + const MeshType::Pointer mesh2 = source2->GetOutput(); mesh2->Graft(mesh1); - MeshType::PointsContainerConstPointer points = mesh2->GetPoints(); - MeshType::PointsContainerConstIterator it = points->Begin(); - MeshType::PointsContainerConstIterator end = points->End(); + const MeshType::PointsContainerConstPointer points = mesh2->GetPoints(); + MeshType::PointsContainerConstIterator it = points->Begin(); + const MeshType::PointsContainerConstIterator end = points->End(); - MeshType::PointType center = source2->GetCenter(); - SphereMeshSourceType::VectorType scale2 = source2->GetScale(); + MeshType::PointType center = source2->GetCenter(); + const SphereMeshSourceType::VectorType scale2 = source2->GetScale(); if ((scale2 - scale).GetNorm() != 0.) { diff --git a/Modules/Core/Mesh/test/itkSimplexMeshAdaptTopologyFilterTest.cxx b/Modules/Core/Mesh/test/itkSimplexMeshAdaptTopologyFilterTest.cxx index 45d30fd3a82..b26b05e9b8d 100644 --- a/Modules/Core/Mesh/test/itkSimplexMeshAdaptTopologyFilterTest.cxx +++ b/Modules/Core/Mesh/test/itkSimplexMeshAdaptTopologyFilterTest.cxx @@ -48,7 +48,7 @@ itkSimplexMeshAdaptTopologyFilterTest(int argc, char * argv[]) auto mySphereMeshSource = SphereMeshSourceType::New(); auto center = itk::MakeFilled(10); PointType::ValueType scaleInit[3] = { 3, 3, 3 }; - VectorType scale = scaleInit; + const VectorType scale = scaleInit; mySphereMeshSource->SetCenter(center); mySphereMeshSource->SetResolution(2); @@ -60,7 +60,7 @@ itkSimplexMeshAdaptTopologyFilterTest(int argc, char * argv[]) simplexFilter->SetInput(mySphereMeshSource->GetOutput()); simplexFilter->Update(); - SimplexMeshType::Pointer simplexMesh = simplexFilter->GetOutput(); + const SimplexMeshType::Pointer simplexMesh = simplexFilter->GetOutput(); simplexMesh->DisconnectPipeline(); std::cout << "Simplex Mesh: " << simplexMesh << std::endl; diff --git a/Modules/Core/Mesh/test/itkSimplexMeshTest.cxx b/Modules/Core/Mesh/test/itkSimplexMeshTest.cxx index 0b9810fd162..5efe5afeda7 100644 --- a/Modules/Core/Mesh/test/itkSimplexMeshTest.cxx +++ b/Modules/Core/Mesh/test/itkSimplexMeshTest.cxx @@ -41,8 +41,8 @@ itkSimplexMeshTest(int, char *[]) /** * Define the 3d geometric positions for 8 points in a cube. */ - SimplexMeshType::CoordinateType testPointCoords[8][3] = { { 0, 0, 0 }, { 9, 0, 0 }, { 9, 0, 9 }, { 0, 0, 9 }, - { 0, 9, 0 }, { 9, 9, 0 }, { 9, 9, 9 }, { 0, 9, 9 } }; + const SimplexMeshType::CoordinateType testPointCoords[8][3] = { { 0, 0, 0 }, { 9, 0, 0 }, { 9, 0, 9 }, { 0, 0, 9 }, + { 0, 9, 0 }, { 9, 9, 0 }, { 9, 9, 9 }, { 0, 9, 9 } }; /** diff --git a/Modules/Core/Mesh/test/itkSimplexMeshToTriangleMeshFilterTest.cxx b/Modules/Core/Mesh/test/itkSimplexMeshToTriangleMeshFilterTest.cxx index 7359f954961..cc1a15a66e0 100644 --- a/Modules/Core/Mesh/test/itkSimplexMeshToTriangleMeshFilterTest.cxx +++ b/Modules/Core/Mesh/test/itkSimplexMeshToTriangleMeshFilterTest.cxx @@ -42,9 +42,9 @@ itkSimplexMeshToTriangleMeshFilterTest(int, char *[]) using TriangleFilterType = itk::SimplexMeshToTriangleMeshFilter; using TriangleMeshPointer = TriangleMeshType::Pointer; auto mySphereMeshSource = SphereMeshSourceType::New(); - PointType center{}; + const PointType center{}; PointType::ValueType scaleInit[3] = { 5, 5, 5 }; - VectorType scale = scaleInit; + const VectorType scale = scaleInit; mySphereMeshSource->SetCenter(center); mySphereMeshSource->SetResolution(1); @@ -58,14 +58,14 @@ itkSimplexMeshToTriangleMeshFilterTest(int, char *[]) backFilter->Update(); backFilter->Print(std::cout); - SimplexMeshType::Pointer simplexMesh = simplexFilter->GetOutput(); - TriangleMeshPointer originalTriangleMesh = mySphereMeshSource->GetOutput(); + const SimplexMeshType::Pointer simplexMesh = simplexFilter->GetOutput(); + TriangleMeshPointer originalTriangleMesh = mySphereMeshSource->GetOutput(); std::cout << "Original triangle mesh: " << std::endl; std::cout << originalTriangleMesh << std::endl; std::cout << "Simplex Mesh: " << simplexMesh << std::endl; - TriangleMeshType::Pointer triangleMesh = backFilter->GetOutput(); + const TriangleMeshType::Pointer triangleMesh = backFilter->GetOutput(); std::cout << "Back filtered Triangle Mesh: " << triangleMesh << std::endl; diff --git a/Modules/Core/Mesh/test/itkSimplexMeshVolumeCalculatorTest.cxx b/Modules/Core/Mesh/test/itkSimplexMeshVolumeCalculatorTest.cxx index 2a52c785013..5addd4b6013 100644 --- a/Modules/Core/Mesh/test/itkSimplexMeshVolumeCalculatorTest.cxx +++ b/Modules/Core/Mesh/test/itkSimplexMeshVolumeCalculatorTest.cxx @@ -43,9 +43,9 @@ itkSimplexMeshVolumeCalculatorTest(int, char *[]) using SimplexFilterType = itk::TriangleMeshToSimplexMeshFilter; auto mySphereMeshSource = SphereMeshSourceType::New(); - PointType center{}; + const PointType center{}; PointType::ValueType scaleInit[3] = { 10, 10, 10 }; - VectorType scale = scaleInit; + const VectorType scale = scaleInit; mySphereMeshSource->SetCenter(center); mySphereMeshSource->SetScale(scale); @@ -74,7 +74,7 @@ itkSimplexMeshVolumeCalculatorTest(int, char *[]) calculator->Print(std::cout); - double volume = calculator->GetVolume(); + const double volume = calculator->GetVolume(); const double pi = std::atan(1.0) * 4.0; const double knownVolume = 4.0 / 3.0 * pi * (1000.0); // scale was 10 = radius diff --git a/Modules/Core/Mesh/test/itkSphereMeshSourceTest.cxx b/Modules/Core/Mesh/test/itkSphereMeshSourceTest.cxx index 6240877f005..dc7762b01b5 100644 --- a/Modules/Core/Mesh/test/itkSphereMeshSourceTest.cxx +++ b/Modules/Core/Mesh/test/itkSphereMeshSourceTest.cxx @@ -31,19 +31,19 @@ itkSphereMeshSourceTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(mySphereMeshSource, SphereMeshSource, MeshSource); - fPointType center{}; - fPointType::ValueType scaleInit[3] = { 1, 1, 1 }; - fPointType scale = scaleInit; + const fPointType center{}; + const fPointType::ValueType scaleInit[3] = { 1, 1, 1 }; + const fPointType scale = scaleInit; mySphereMeshSource->SetCenter(center); mySphereMeshSource->SetResolutionX(1); mySphereMeshSource->SetResolutionY(10); mySphereMeshSource->SetScale(scale); - double squareness1 = 1.0; + const double squareness1 = 1.0; mySphereMeshSource->SetSquareness1(squareness1); - double squareness2 = 1.0; + const double squareness2 = 1.0; mySphereMeshSource->SetSquareness2(squareness2); mySphereMeshSource->Modified(); diff --git a/Modules/Core/Mesh/test/itkTransformMeshFilterTest.cxx b/Modules/Core/Mesh/test/itkTransformMeshFilterTest.cxx index b82a7352d13..92a42e2a6bf 100644 --- a/Modules/Core/Mesh/test/itkTransformMeshFilterTest.cxx +++ b/Modules/Core/Mesh/test/itkTransformMeshFilterTest.cxx @@ -28,7 +28,7 @@ itkTransformMeshFilterTest(int, char *[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope // scope. - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); // Declare the mesh pixel type. // Those are the values associated @@ -53,10 +53,10 @@ itkTransformMeshFilterTest(int, char *[]) auto inputMesh = MeshType::New(); // Insert data on the Mesh - PointsContainerPointer points = inputMesh->GetPoints(); + const PointsContainerPointer points = inputMesh->GetPoints(); // Fill a cube with points , just to get some data - int n = 1; // let's start with a few of them + const int n = 1; // let's start with a few of them PointsContainerType::ElementIdentifier count = 0; // count them for (int x = -n; x <= n; ++x) @@ -110,7 +110,7 @@ itkTransformMeshFilterTest(int, char *[]) auto affineTransform = TransformType::New(); affineTransform->Scale(3.5); TransformType::OffsetType::ValueType tInit[3] = { 100, 200, 300 }; - TransformType::OffsetType translation = tInit; + const TransformType::OffsetType translation = tInit; affineTransform->Translate(translation); // Connect the inputs @@ -129,8 +129,8 @@ itkTransformMeshFilterTest(int, char *[]) std::cout << "Filter with base transform: " << filterwithbasetrfs; // Get the Smart Pointer to the Filter Output - MeshType::Pointer outputMesh = filter->GetOutput(); - MeshType::Pointer outputMeshFromWithBase = filterwithbasetrfs->GetOutput(); + const MeshType::Pointer outputMesh = filter->GetOutput(); + const MeshType::Pointer outputMeshFromWithBase = filterwithbasetrfs->GetOutput(); std::cout << "Output Mesh has " << outputMesh->GetNumberOfPoints() << " points " << std::endl; @@ -138,9 +138,9 @@ itkTransformMeshFilterTest(int, char *[]) << std::endl; // Get the point container - MeshType::PointsContainerPointer transformedPoints = outputMesh->GetPoints(); + const MeshType::PointsContainerPointer transformedPoints = outputMesh->GetPoints(); - MeshType::PointsContainerPointer transformedPointsFromWithBase = outputMeshFromWithBase->GetPoints(); + const MeshType::PointsContainerPointer transformedPointsFromWithBase = outputMeshFromWithBase->GetPoints(); PointsContainerType::ConstIterator it = transformedPoints->Begin(); diff --git a/Modules/Core/Mesh/test/itkTriangleCellTest.cxx b/Modules/Core/Mesh/test/itkTriangleCellTest.cxx index 64e3026b951..73df885bf18 100644 --- a/Modules/Core/Mesh/test/itkTriangleCellTest.cxx +++ b/Modules/Core/Mesh/test/itkTriangleCellTest.cxx @@ -88,7 +88,7 @@ itkTriangleCellTest(int, char *[]) /** * Define the 3d geometric positions for 4 points in a square. */ - MeshType::CoordinateType testPointCoords[numberOfPoints][3] = { + const MeshType::CoordinateType testPointCoords[numberOfPoints][3] = { { 0, 0, 0 }, { 10, 0, 0 }, { 10, 10, 0 }, { 0, 10, 0 } }; diff --git a/Modules/Core/Mesh/test/itkTriangleMeshCurvatureCalculatorTest.cxx b/Modules/Core/Mesh/test/itkTriangleMeshCurvatureCalculatorTest.cxx index 139ca17ca36..e07c92a1657 100644 --- a/Modules/Core/Mesh/test/itkTriangleMeshCurvatureCalculatorTest.cxx +++ b/Modules/Core/Mesh/test/itkTriangleMeshCurvatureCalculatorTest.cxx @@ -77,7 +77,7 @@ itkTriangleMeshCurvatureCalculatorTest(int argc, char * argv[]) using VectorType = SphereMeshSourceType::VectorType; auto mySphereMeshSource = SphereMeshSourceType::New(); - PointType center{}; + const PointType center{}; PointType::ValueType scaleInit_1[Dimension] = { 5, 5, 5 }; VectorType scale = scaleInit_1; @@ -95,8 +95,8 @@ itkTriangleMeshCurvatureCalculatorTest(int argc, char * argv[]) gaussCurvatureData = curvCalculator->GetGaussCurvatureData(); // Values obtained using the VTK Gaussian Curvature - float v1 = 0.06087285; - float v2 = 0.04463759; + const float v1 = 0.06087285; + const float v2 = 0.04463759; // Test if values are correct for scale 5 and resolution 1 sphere for (unsigned int k = 0; k < triangleMesh->GetNumberOfPoints(); ++k) @@ -128,8 +128,8 @@ itkTriangleMeshCurvatureCalculatorTest(int argc, char * argv[]) gaussCurvatureData = curvCalculator->GetGaussCurvatureData(); - float v3 = 0.00015218; - float v4 = 0.00011159; + const float v3 = 0.00015218; + const float v4 = 0.00011159; // Test if values are correct for scale 100 and resolution 1 sphere. for (unsigned int k = 0; k < triangleMesh->GetNumberOfPoints(); ++k) @@ -184,11 +184,11 @@ itkTriangleMeshCurvatureCalculatorTest(int argc, char * argv[]) if (argc > 1) { using ReaderType = itk::MeshFileReader; - ReaderType::Pointer polyDataReader = ReaderType::New(); + const ReaderType::Pointer polyDataReader = ReaderType::New(); polyDataReader->SetFileName(argv[1]); polyDataReader->Update(); - TriangleMeshType::Pointer inputMesh = polyDataReader->GetOutput(); + const TriangleMeshType::Pointer inputMesh = polyDataReader->GetOutput(); curvCalculator->SetTriangleMesh(inputMesh); curvCalculator->SetCurvatureTypeToGaussian(); curvCalculator->Compute(); diff --git a/Modules/Core/Mesh/test/itkTriangleMeshToBinaryImageFilterTest.cxx b/Modules/Core/Mesh/test/itkTriangleMeshToBinaryImageFilterTest.cxx index 03cbc3502c6..bc38419a77d 100644 --- a/Modules/Core/Mesh/test/itkTriangleMeshToBinaryImageFilterTest.cxx +++ b/Modules/Core/Mesh/test/itkTriangleMeshToBinaryImageFilterTest.cxx @@ -48,7 +48,7 @@ itkTriangleMeshToBinaryImageFilterTest(int argc, char * argv[]) center[1] = 50; center[2] = 50; PointType::ValueType scaleInit[3] = { 10, 10, 10 }; - VectorType scale = scaleInit; + const VectorType scale = scaleInit; mySphereMeshSource->SetCenter(center); mySphereMeshSource->SetResolution(3); diff --git a/Modules/Core/Mesh/test/itkTriangleMeshToBinaryImageFilterTest1.cxx b/Modules/Core/Mesh/test/itkTriangleMeshToBinaryImageFilterTest1.cxx index 6f28bdf49bd..cd534333f16 100644 --- a/Modules/Core/Mesh/test/itkTriangleMeshToBinaryImageFilterTest1.cxx +++ b/Modules/Core/Mesh/test/itkTriangleMeshToBinaryImageFilterTest1.cxx @@ -39,7 +39,7 @@ itkTriangleMeshToBinaryImageFilterTest1(int argc, char * argv[]) auto mySphereMeshSource = SphereMeshSourceType::New(); auto center = itk::MakeFilled(50); PointType::ValueType scaleInit[3] = { 10, 10, 10 }; - VectorType scale = scaleInit; + const VectorType scale = scaleInit; mySphereMeshSource->SetCenter(center); mySphereMeshSource->SetResolution(3); @@ -68,7 +68,7 @@ itkTriangleMeshToBinaryImageFilterTest1(int argc, char * argv[]) roifilter->SetInput(im); roifilter->SetRegionOfInterest(region); ITK_TRY_EXPECT_NO_EXCEPTION(roifilter->Update()); - ImageType::Pointer roiImage = roifilter->GetOutput(); + const ImageType::Pointer roiImage = roifilter->GetOutput(); imageFilter->SetInfoImage(roiImage); ITK_TRY_EXPECT_NO_EXCEPTION(imageFilter->Update()); diff --git a/Modules/Core/Mesh/test/itkTriangleMeshToBinaryImageFilterTest2.cxx b/Modules/Core/Mesh/test/itkTriangleMeshToBinaryImageFilterTest2.cxx index 6d7c3d3cd09..992e6db1b05 100644 --- a/Modules/Core/Mesh/test/itkTriangleMeshToBinaryImageFilterTest2.cxx +++ b/Modules/Core/Mesh/test/itkTriangleMeshToBinaryImageFilterTest2.cxx @@ -46,7 +46,7 @@ itkTriangleMeshToBinaryImageFilterTest2(int argc, char * argv[]) auto mySphereMeshSource = SphereMeshSourceType::New(); auto center = itk::MakeFilled(-5); PointType::ValueType scaleInit[3] = { 10, 10, 10 }; - VectorType scale = scaleInit; + const VectorType scale = scaleInit; mySphereMeshSource->SetCenter(center); mySphereMeshSource->SetResolution(3); @@ -59,8 +59,8 @@ itkTriangleMeshToBinaryImageFilterTest2(int argc, char * argv[]) backFilter->SetInput(simplexFilter->GetOutput()); backFilter->Update(); - SimplexMeshType::Pointer simplexMesh = simplexFilter->GetOutput(); - TriangleMeshPointer originalTriangleMesh = mySphereMeshSource->GetOutput(); + const SimplexMeshType::Pointer simplexMesh = simplexFilter->GetOutput(); + const TriangleMeshPointer originalTriangleMesh = mySphereMeshSource->GetOutput(); std::cout << " Number of Points and Cells in Original Triangle Mesh" << std::endl; std::cout << originalTriangleMesh->GetNumberOfPoints() << std::endl; @@ -70,7 +70,7 @@ itkTriangleMeshToBinaryImageFilterTest2(int argc, char * argv[]) std::cout << "Simplex Mesh: " << simplexMesh << std::endl; - TriangleMeshType::Pointer triangleMesh = backFilter->GetOutput(); + const TriangleMeshType::Pointer triangleMesh = backFilter->GetOutput(); std::cout << " Number of Points and Cells in Back Filtered Triangle Mesh" << std::endl; std::cout << triangleMesh->GetNumberOfPoints() << std::endl; diff --git a/Modules/Core/Mesh/test/itkTriangleMeshToBinaryImageFilterTest4.cxx b/Modules/Core/Mesh/test/itkTriangleMeshToBinaryImageFilterTest4.cxx index 764dc7a0ac2..852c2e31679 100644 --- a/Modules/Core/Mesh/test/itkTriangleMeshToBinaryImageFilterTest4.cxx +++ b/Modules/Core/Mesh/test/itkTriangleMeshToBinaryImageFilterTest4.cxx @@ -86,8 +86,8 @@ itkTriangleMeshToBinaryImageFilterTest4(int argc, char * argv[]) spacing[2] = std::stod(argv[11]); - ImageType::IndexType index3D = { { 0, 0, 0 } }; - ImageType::RegionType region3D{ index3D, size }; + const ImageType::IndexType index3D = { { 0, 0, 0 } }; + const ImageType::RegionType region3D{ index3D, size }; auto inputImage = ImageType::New(); inputImage->SetRegions(region3D); diff --git a/Modules/Core/Mesh/test/itkTriangleMeshToSimplexMeshFilter2Test.cxx b/Modules/Core/Mesh/test/itkTriangleMeshToSimplexMeshFilter2Test.cxx index aa9873d5855..832b00cf5e7 100644 --- a/Modules/Core/Mesh/test/itkTriangleMeshToSimplexMeshFilter2Test.cxx +++ b/Modules/Core/Mesh/test/itkTriangleMeshToSimplexMeshFilter2Test.cxx @@ -43,9 +43,9 @@ itkTriangleMeshToSimplexMeshFilter2Test(int, char *[]) using SimplexFilterType = itk::TriangleMeshToSimplexMeshFilter; auto mySphereMeshSource = SphereMeshSourceType::New(); - PointType center{}; + const PointType center{}; PointType::ValueType scaleInit[3] = { 10, 10, 10 }; - VectorType scale = scaleInit; + const VectorType scale = scaleInit; mySphereMeshSource->SetCenter(center); mySphereMeshSource->SetResolution(2); @@ -55,7 +55,7 @@ itkTriangleMeshToSimplexMeshFilter2Test(int, char *[]) simplexFilter->SetInput(mySphereMeshSource->GetOutput()); simplexFilter->Update(); - SimplexMeshType::Pointer simplexMesh = simplexFilter->GetOutput(); + const SimplexMeshType::Pointer simplexMesh = simplexFilter->GetOutput(); simplexMesh->DisconnectPipeline(); using NeighborsListType = SimplexMeshType::NeighborListType; diff --git a/Modules/Core/Mesh/test/itkTriangleMeshToSimplexMeshFilterTest.cxx b/Modules/Core/Mesh/test/itkTriangleMeshToSimplexMeshFilterTest.cxx index 2b2b3b4e5d9..be709633196 100644 --- a/Modules/Core/Mesh/test/itkTriangleMeshToSimplexMeshFilterTest.cxx +++ b/Modules/Core/Mesh/test/itkTriangleMeshToSimplexMeshFilterTest.cxx @@ -41,9 +41,9 @@ itkTriangleMeshToSimplexMeshFilterTest(int, char *[]) using SimplexFilterType = itk::TriangleMeshToSimplexMeshFilter; auto mySphereMeshSource = SphereMeshSourceType::New(); - PointType center{}; + const PointType center{}; PointType::ValueType scaleInit[3] = { 5, 5, 5 }; - VectorType scale = scaleInit; + const VectorType scale = scaleInit; mySphereMeshSource->SetCenter(center); mySphereMeshSource->SetResolution(0); @@ -59,7 +59,7 @@ itkTriangleMeshToSimplexMeshFilterTest(int, char *[]) simplexFilter->SetInput(mySphereMeshSource->GetOutput()); simplexFilter->Update(); - SimplexMeshType::Pointer simplexMesh = simplexFilter->GetOutput(); + const SimplexMeshType::Pointer simplexMesh = simplexFilter->GetOutput(); std::cout << "Simplex Mesh: " << simplexMesh << std::endl; diff --git a/Modules/Core/Mesh/test/itkVTKPolyDataReaderTest.cxx b/Modules/Core/Mesh/test/itkVTKPolyDataReaderTest.cxx index 30c6e5bdfb5..b1c781d3c3a 100644 --- a/Modules/Core/Mesh/test/itkVTKPolyDataReaderTest.cxx +++ b/Modules/Core/Mesh/test/itkVTKPolyDataReaderTest.cxx @@ -40,7 +40,7 @@ itkVTKPolyDataReaderTest(int argc, char * argv[]) using PointType = ReaderType::PointType; - std::string filename = argv[1]; + const std::string filename = argv[1]; polyDataReader->SetFileName(filename); ITK_TEST_SET_GET_VALUE(filename, polyDataReader->GetFileName()); @@ -50,12 +50,12 @@ itkVTKPolyDataReaderTest(int argc, char * argv[]) std::cout << "Version: " << polyDataReader->GetVersion() << std::endl; std::cout << "Header: " << polyDataReader->GetHeader() << std::endl; - MeshType::Pointer mesh = polyDataReader->GetOutput(); + const MeshType::Pointer mesh = polyDataReader->GetOutput(); PointType point; - unsigned int numberOfPoints = mesh->GetNumberOfPoints(); - unsigned int numberOfCells = mesh->GetNumberOfCells(); + const unsigned int numberOfPoints = mesh->GetNumberOfPoints(); + const unsigned int numberOfCells = mesh->GetNumberOfCells(); std::cout << "numberOfPoints= " << numberOfPoints << std::endl; std::cout << "numberOfCells= " << numberOfCells << std::endl; diff --git a/Modules/Core/Mesh/test/itkVTKPolyDataWriterTest01.cxx b/Modules/Core/Mesh/test/itkVTKPolyDataWriterTest01.cxx index 610065032e0..8055f3551e8 100644 --- a/Modules/Core/Mesh/test/itkVTKPolyDataWriterTest01.cxx +++ b/Modules/Core/Mesh/test/itkVTKPolyDataWriterTest01.cxx @@ -47,9 +47,9 @@ itkVTKPolyDataWriterTest01(int argc, char * argv[]) constexpr unsigned int numberOfPoints = 4; constexpr unsigned int numberOfCells = 9; - float rawPoints[12] = { 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0 }; + const float rawPoints[12] = { 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0 }; - unsigned long rawCells[24] = { 0, 2, 1, 0, 1, 3, 0, 3, 2, 1, 2, 3, 0, 1, 0, 2, 0, 3, 1, 2, 1, 3, 2, 3 }; + const unsigned long rawCells[24] = { 0, 2, 1, 0, 1, 3, 0, 3, 2, 1, 2, 3, 0, 1, 0, 2, 0, 3, 1, 2, 1, 3, 2, 3 }; mesh->GetPoints()->Reserve(numberOfPoints); mesh->GetCells()->Reserve(numberOfCells); @@ -98,7 +98,7 @@ itkVTKPolyDataWriterTest01(int argc, char * argv[]) writer->SetInput(mesh); - std::string inputFileName = argv[1]; + const std::string inputFileName = argv[1]; writer->SetFileName(inputFileName); ITK_TEST_SET_GET_VALUE(inputFileName, writer->GetFileName()); diff --git a/Modules/Core/Mesh/test/itkVTKPolyDataWriterTest02.cxx b/Modules/Core/Mesh/test/itkVTKPolyDataWriterTest02.cxx index d3852a2d8f1..45701d7f6e9 100644 --- a/Modules/Core/Mesh/test/itkVTKPolyDataWriterTest02.cxx +++ b/Modules/Core/Mesh/test/itkVTKPolyDataWriterTest02.cxx @@ -60,7 +60,7 @@ itkVTKPolyDataWriterTest02(int argc, char * argv[]) std::cout << "mySphereMeshSource: " << mySphereMeshSource; - MeshType::Pointer myMesh = mySphereMeshSource->GetOutput(); + const MeshType::Pointer myMesh = mySphereMeshSource->GetOutput(); PointType pt{}; @@ -86,7 +86,7 @@ itkVTKPolyDataWriterTest02(int argc, char * argv[]) using CellsContainerPointer = MeshType::CellsContainerPointer; using CellType = MeshType::CellType; - CellsContainerPointer cells = myMesh->GetCells(); + const CellsContainerPointer cells = myMesh->GetCells(); unsigned int faceId = 0; diff --git a/Modules/Core/Mesh/test/itkWarpMeshFilterTest.cxx b/Modules/Core/Mesh/test/itkWarpMeshFilterTest.cxx index 8306a2b97b8..d20a7e6e8d2 100644 --- a/Modules/Core/Mesh/test/itkWarpMeshFilterTest.cxx +++ b/Modules/Core/Mesh/test/itkWarpMeshFilterTest.cxx @@ -69,7 +69,7 @@ itkWarpMeshFilterTest(int, char *[]) size[1] = 25; size[2] = 25; - DisplacementFieldType::RegionType region{ start, size }; + const DisplacementFieldType::RegionType region{ start, size }; deformationField->SetRegions(region); @@ -118,17 +118,17 @@ itkWarpMeshFilterTest(int, char *[]) ITK_TRY_EXPECT_NO_EXCEPTION(warpFilter->Update()); - MeshType::Pointer outputMesh = warpFilter->GetOutput(); - MeshType::ConstPointer inputMesh = warpFilter->GetInput(); + const MeshType::Pointer outputMesh = warpFilter->GetOutput(); + const MeshType::ConstPointer inputMesh = warpFilter->GetInput(); - MeshType::PointsContainerPointer outPoints = outputMesh->GetPoints(); - MeshType::PointsContainerConstPointer inPoints = inputMesh->GetPoints(); + const MeshType::PointsContainerPointer outPoints = outputMesh->GetPoints(); + const MeshType::PointsContainerConstPointer inPoints = inputMesh->GetPoints(); MeshType::PointsContainer::ConstIterator inputPoint = inPoints->Begin(); MeshType::PointsContainer::ConstIterator outputPoint = outPoints->Begin(); - MeshType::PointsContainer::ConstIterator lastInputPoint = inPoints->End(); - MeshType::PointsContainer::ConstIterator lastOutputPoint = outPoints->End(); + const MeshType::PointsContainer::ConstIterator lastInputPoint = inPoints->End(); + const MeshType::PointsContainer::ConstIterator lastOutputPoint = outPoints->End(); const double tolerance = 1e-8; diff --git a/Modules/Core/QuadEdgeMesh/include/itkGeometricalQuadEdge.hxx b/Modules/Core/QuadEdgeMesh/include/itkGeometricalQuadEdge.hxx index ecb30b53d5c..1eba82c2e90 100644 --- a/Modules/Core/QuadEdgeMesh/include/itkGeometricalQuadEdge.hxx +++ b/Modules/Core/QuadEdgeMesh/include/itkGeometricalQuadEdge.hxx @@ -165,9 +165,9 @@ GeometricalQuadEdge::IsLnextSh // The condition isn't complicated: if left faces aren't set, // continue, if just one is set return false, if both are set // check if the face is the same - bool facesAreNotSet = !this->IsLeftSet() && !it.Value()->IsLeftSet(); - bool facesAreTheSame = this->GetLeft() == it.Value()->GetLeft(); - bool facesAreSet = this->IsLeftSet() && it.Value()->IsLeftSet(); + const bool facesAreNotSet = !this->IsLeftSet() && !it.Value()->IsLeftSet(); + const bool facesAreTheSame = this->GetLeft() == it.Value()->GetLeft(); + const bool facesAreSet = this->IsLeftSet() && it.Value()->IsLeftSet(); // // FIXME: This boolean expression can be simplified. // ALEX : what about the version below ? @@ -310,8 +310,8 @@ GeometricalQuadEdge::GetNextBo } // Ok, no more special cases - IteratorGeom it = edgeTest->BeginGeomOnext(); - IteratorGeom end = edgeTest->EndGeomOnext(); + IteratorGeom it = edgeTest->BeginGeomOnext(); + const IteratorGeom end = edgeTest->EndGeomOnext(); while (it != end) { @@ -605,7 +605,7 @@ GeometricalQuadEdge::Disconnec else if (this->IsInternal()) { // Consolidate face - DualOriginRefType face = this->GetRight(); + const DualOriginRefType face = this->GetRight(); for (IteratorGeom it = this->BeginGeomLnext(); it != this->EndGeomLnext(); ++it) { it.Value()->SetLeft(face); diff --git a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMesh.hxx b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMesh.hxx index 6bd439a7642..c5a79008399 100644 --- a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMesh.hxx +++ b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMesh.hxx @@ -99,7 +99,7 @@ template auto QuadEdgeMesh::Splice(QEPrimal * a, QEPrimal * b) -> PointIdentifier { - bool SplitingOrigin = a->IsInOnextRing(b); + const bool SplitingOrigin = a->IsInOnextRing(b); PointIdentifier resultingOriginId; if (SplitingOrigin) @@ -150,15 +150,15 @@ QuadEdgeMesh::Splice(QEPrimal * a, QEPrimal * b) -> ////////// Handle the geometrical references: // Make sure the Origin's edge entry doesn't point to an entry edge // that isn't any more in the Onext ring: - PointIdentifier orgId = a->GetOrigin(); - PointType org = this->GetPoint(orgId); + const PointIdentifier orgId = a->GetOrigin(); + PointType org = this->GetPoint(orgId); org.SetEdge(a); this->SetPoint(orgId, org); // Create a newOrigin point by duplicating the geometry of Origin... PointType newOrigin = org; newOrigin.SetEdge(b); - PointIdentifier newOriginId = this->AddPoint(newOrigin); + const PointIdentifier newOriginId = this->AddPoint(newOrigin); // ...and inform Onext ring of b that their Origin() have changed: typename QEPrimal::IteratorGeom it; @@ -220,8 +220,8 @@ QuadEdgeMesh::Splice(QEPrimal * a, QEPrimal * b) -> ///////////////////////////////////////////////////////////// // First, consider the vertices: Origin and oldOrigin must be different. - PointIdentifier oldOriginId = b->GetOrigin(); - PointIdentifier orgId = a->GetOrigin(); + const PointIdentifier oldOriginId = b->GetOrigin(); + const PointIdentifier orgId = a->GetOrigin(); if (oldOriginId == orgId) { @@ -268,8 +268,8 @@ QuadEdgeMesh::Splice(QEPrimal * a, QEPrimal * b) -> * and the vertices we wish to splice are at least two vertices aside. */ - FaceRefType aLeftFace = a->GetLeft(); - FaceRefType bLeftFace = b->GetLeft(); + const FaceRefType aLeftFace = a->GetLeft(); + const FaceRefType bLeftFace = b->GetLeft(); bool MustReconstructFace = false; if ((aLeftFace == m_NoFace && bLeftFace != m_NoFace) || (aLeftFace != m_NoFace && bLeftFace == m_NoFace)) @@ -353,9 +353,9 @@ QuadEdgeMesh::SetCell(CellIdentifier itkNotUsed(cId } else if ((pe = dynamic_cast(cell.GetPointer())) != nullptr) { - PointIdList points; - PointIdInternalIterator pit = pe->InternalPointIdsBegin(); - PointIdInternalIterator pend = pe->InternalPointIdsEnd(); + PointIdList points; + PointIdInternalIterator pit = pe->InternalPointIdsBegin(); + const PointIdInternalIterator pend = pe->InternalPointIdsEnd(); while (pit != pend) { points.push_back(*pit); @@ -368,9 +368,9 @@ QuadEdgeMesh::SetCell(CellIdentifier itkNotUsed(cId } else // non-QE cell, i.e. original itk cells for example { - PointIdentifier numPoint = cell->GetNumberOfPoints(); - PointIdIterator pointId = cell->PointIdsBegin(); - PointIdIterator endId = cell->PointIdsEnd(); + const PointIdentifier numPoint = cell->GetNumberOfPoints(); + PointIdIterator pointId = cell->PointIdsBegin(); + PointIdIterator endId = cell->PointIdsEnd(); // Edge if (numPoint == 2) { @@ -404,8 +404,8 @@ template auto QuadEdgeMesh::FindFirstUnusedPointIndex() -> PointIdentifier { - PointIdentifier pid = 0; - PointIdentifier maxpid = this->GetNumberOfPoints(); + PointIdentifier pid = 0; + const PointIdentifier maxpid = this->GetNumberOfPoints(); if (!m_FreePointIndexes.empty()) { @@ -458,13 +458,13 @@ QuadEdgeMesh::SqueezePointsIds() } // Get hold on the last point in the container - PointsContainerPointer points = this->GetPoints(); + const PointsContainerPointer points = this->GetPoints(); PointsContainerConstIterator last = points->End(); --last; // Check if there is any data - PointDataContainerPointer pointData = this->GetPointData(); - bool HasPointData = (pointData->Size() != 0); + const PointDataContainerPointer pointData = this->GetPointData(); + const bool HasPointData = (pointData->Size() != 0); // if there is get hold on the last point's data PointDataContainerIterator lastData = pointData->End(); @@ -525,7 +525,7 @@ template auto QuadEdgeMesh::AddPoint(const PointType & p) -> PointIdentifier { - PointIdentifier pid = this->FindFirstUnusedPointIndex(); + const PointIdentifier pid = this->FindFirstUnusedPointIndex(); this->SetPoint(pid, p); return (pid); @@ -676,7 +676,7 @@ auto QuadEdgeMesh::AddEdgeWithSecurePointList(const PointIdentifier & orgPid, const PointIdentifier & destPid) -> QEPrimal * { - PointsContainerPointer points = this->GetPoints(); + const PointsContainerPointer points = this->GetPoints(); PointType & pOrigin = points->ElementAt(orgPid); PointType & pDestination = points->ElementAt(destPid); @@ -763,7 +763,7 @@ QuadEdgeMesh::DeleteEdge(QEPrimal * e) const PointIdentifier & orgPid = e->GetOrigin(); const PointIdentifier & destPid = e->GetDestination(); - PointsContainerPointer points = this->GetPoints(); + const PointsContainerPointer points = this->GetPoints(); // Check if the Origin point's edge ring entry should be changed PointType & pOrigin = points->ElementAt(orgPid); @@ -903,7 +903,7 @@ QuadEdgeMesh::LightWeightDeleteEdge(EdgeCellType * const PointIdentifier & orgPid = e->GetOrigin(); const PointIdentifier & destPid = e->GetDestination(); - PointsContainerPointer points = this->GetPoints(); + const PointsContainerPointer points = this->GetPoints(); if (orgPid != e->m_NoPoint && destPid != e->m_NoPoint) { @@ -996,7 +996,7 @@ QuadEdgeMesh::LightWeightDeleteEdge(QEPrimal * e) return; } - CellIdentifier LineIdent = e->GetIdent(); + const CellIdentifier LineIdent = e->GetIdent(); if (LineIdent != m_NoPoint) { auto * edgeCell = dynamic_cast(this->GetEdgeCells()->GetElement(LineIdent)); @@ -1015,8 +1015,8 @@ template void QuadEdgeMesh::DeleteFace(FaceRefType faceToDelete) { - CellsContainerPointer cells = this->GetCells(); - CellType * c; + const CellsContainerPointer cells = this->GetCells(); + CellType * c; if (!cells->GetElementIfIndexExists(faceToDelete, &c)) { @@ -1074,9 +1074,9 @@ QuadEdgeMesh::GetEdge() const -> QEPrimal * return ((QEPrimal *)nullptr); } - const CellsContainer * edgeCells = this->GetEdgeCells(); - CellsContainerConstIterator cit = edgeCells->Begin(); - auto * e = dynamic_cast(cit.Value()); + const CellsContainer * edgeCells = this->GetEdgeCells(); + const CellsContainerConstIterator cit = edgeCells->Begin(); + auto * e = dynamic_cast(cit.Value()); return (e->GetQEGeom()); } @@ -1121,8 +1121,8 @@ QuadEdgeMesh::FindEdge(const PointIdentifier & pid0 if (initialEdge) { - typename QEPrimal::IteratorGeom it = initialEdge->BeginGeomOnext(); - typename QEPrimal::IteratorGeom end = initialEdge->EndGeomOnext(); + typename QEPrimal::IteratorGeom it = initialEdge->BeginGeomOnext(); + const typename QEPrimal::IteratorGeom end = initialEdge->EndGeomOnext(); while (it != end) { if (it.Value()->GetDestination() == pid1) @@ -1147,7 +1147,7 @@ QuadEdgeMesh::FindEdgeCell(const PointIdentifier & if (EdgeGeom != (QEPrimal *)nullptr) { - CellIdentifier LineIdent = EdgeGeom->GetIdent(); + const CellIdentifier LineIdent = EdgeGeom->GetIdent(); if (LineIdent != m_NoPoint) { result = dynamic_cast(this->GetEdgeCells()->GetElement(LineIdent)); @@ -1162,7 +1162,7 @@ template auto QuadEdgeMesh::AddFace(const PointIdList & points) -> QEPrimal * { - size_t N = points.size(); + const size_t N = points.size(); #ifndef NDEBUG @@ -1204,8 +1204,8 @@ QuadEdgeMesh::AddFace(const PointIdList & points) - // Check if existing edges have no face on the left. for (size_t i = 0; i < N; ++i) { - PointIdentifier pid0 = points[i]; - PointIdentifier pid1 = points[(i + 1) % N]; + const PointIdentifier pid0 = points[i]; + const PointIdentifier pid1 = points[(i + 1) % N]; QEPrimal * edge = this->FindEdge(pid0, pid1); @@ -1246,9 +1246,9 @@ QuadEdgeMesh::AddFaceWithSecurePointList(const Poin // Now create edge list and create missing edges if needed. for (PointIdentifier i = 0; i < numberOfPoints; ++i) { - PointIdentifier pid0 = points[i]; - PointIdentifier pid1 = points[(i + 1) % numberOfPoints]; - QEPrimal * edge = this->FindEdge(pid0, pid1); + const PointIdentifier pid0 = points[i]; + const PointIdentifier pid1 = points[(i + 1) % numberOfPoints]; + QEPrimal * edge = this->FindEdge(pid0, pid1); if (!edge && CheckEdges) { @@ -1308,16 +1308,16 @@ void QuadEdgeMesh::AddFace(QEPrimal * entry) { // Create the cell and add it to the container - auto * faceCell = new PolygonCellType(entry); - CellIdentifier fid = this->FindFirstUnusedCellIndex(); + auto * faceCell = new PolygonCellType(entry); + const CellIdentifier fid = this->FindFirstUnusedCellIndex(); faceCell->SetIdent(fid); // Associate the above generated CellIndex as the default FaceRefType // of the new face [ i.e. use the itk level CellIdentifier as the // GeometricalQuadEdge::m_Origin of dual edges (edges of type QEDual) ]. - typename QEPrimal::IteratorGeom it = entry->BeginGeomLnext(); - typename QEPrimal::IteratorGeom end = entry->EndGeomLnext(); + typename QEPrimal::IteratorGeom it = entry->BeginGeomLnext(); + const typename QEPrimal::IteratorGeom end = entry->EndGeomLnext(); while (it != end) { @@ -1373,8 +1373,8 @@ QuadEdgeMesh::ClearCellsContainer() { if (m_EdgeCellsContainer->GetReferenceCount() == 1) { - CellsContainerIterator EdgeCell = m_EdgeCellsContainer->Begin(); - CellsContainerIterator EdgeEnd = m_EdgeCellsContainer->End(); + CellsContainerIterator EdgeCell = m_EdgeCellsContainer->Begin(); + const CellsContainerIterator EdgeEnd = m_EdgeCellsContainer->End(); while (EdgeCell != EdgeEnd) { const CellType * EdgeCellToBeDeleted = EdgeCell->Value(); @@ -1419,9 +1419,9 @@ QuadEdgeMesh::ComputeNumberOfPoints() const -> Poin return (0); } - PointIdentifier numberOfPoints{}; - PointsContainerConstIterator pointIterator = points->Begin(); - PointsContainerConstIterator pointEnd = points->End(); + PointIdentifier numberOfPoints{}; + PointsContainerConstIterator pointIterator = points->Begin(); + const PointsContainerConstIterator pointEnd = points->End(); while (pointIterator != pointEnd) { @@ -1445,9 +1445,9 @@ template auto QuadEdgeMesh::ComputeNumberOfFaces() const -> CellIdentifier { - CellIdentifier numberOfFaces{}; - CellsContainerConstIterator cellIterator = this->GetCells()->Begin(); - CellsContainerConstIterator cellEnd = this->GetCells()->End(); + CellIdentifier numberOfFaces{}; + CellsContainerConstIterator cellIterator = this->GetCells()->Begin(); + const CellsContainerConstIterator cellEnd = this->GetCells()->End(); PointIdentifier NumOfPoints; diff --git a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshBoundaryEdgesMeshFunction.hxx b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshBoundaryEdgesMeshFunction.hxx index b18162af335..71d0c4f3018 100644 --- a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshBoundaryEdgesMeshFunction.hxx +++ b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshBoundaryEdgesMeshFunction.hxx @@ -30,8 +30,8 @@ QuadEdgeMeshBoundaryEdgesMeshFunction::Evaluate(const InputType & mesh) c using CellsContainerConstIterator = typename MeshType::CellsContainerConstIterator; std::set boundaryList; - CellsContainerConstIterator cellIterator = mesh.GetEdgeCells()->Begin(); - CellsContainerConstIterator cellEnd = mesh.GetEdgeCells()->End(); + CellsContainerConstIterator cellIterator = mesh.GetEdgeCells()->Begin(); + const CellsContainerConstIterator cellEnd = mesh.GetEdgeCells()->End(); while (cellIterator != cellEnd) { @@ -72,8 +72,8 @@ QuadEdgeMeshBoundaryEdgesMeshFunction::Evaluate(const InputType & mesh) c // Follow, with Lnext(), the boundary while removing edges // from boundary list: - typename QEPrimal::IteratorGeom bIt = bdryEdge->BeginGeomLnext(); - typename QEPrimal::IteratorGeom bEnd = bdryEdge->EndGeomLnext(); + typename QEPrimal::IteratorGeom bIt = bdryEdge->BeginGeomLnext(); + const typename QEPrimal::IteratorGeom bEnd = bdryEdge->EndGeomLnext(); while (bIt != bEnd) { diff --git a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshEulerOperatorCreateCenterVertexFunction.hxx b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshEulerOperatorCreateCenterVertexFunction.hxx index 710153affde..9f9ac5129d2 100644 --- a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshEulerOperatorCreateCenterVertexFunction.hxx +++ b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshEulerOperatorCreateCenterVertexFunction.hxx @@ -51,9 +51,9 @@ QuadEdgeMeshEulerOperatorCreateCenterVertexFunction::Evaluate(QE this->m_Mesh->DeleteFace(e->GetLeft()); // create new point geometry - unsigned int sum = 0; - VectorType vec{}; - PointIdentifier pid = this->m_Mesh->FindFirstUnusedPointIndex(); + unsigned int sum = 0; + VectorType vec{}; + const PointIdentifier pid = this->m_Mesh->FindFirstUnusedPointIndex(); using AssociatedBarycenters = std::map; AssociatedBarycenters m_AssocBary; using QEIterator = typename QEType::IteratorGeom; diff --git a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshEulerOperatorDeleteCenterVertexFunction.hxx b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshEulerOperatorDeleteCenterVertexFunction.hxx index 7dd4e04e374..de4ff946222 100644 --- a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshEulerOperatorDeleteCenterVertexFunction.hxx +++ b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshEulerOperatorDeleteCenterVertexFunction.hxx @@ -70,8 +70,8 @@ QuadEdgeMeshEulerOperatorDeleteCenterVertexFunction::Evaluate(QE PointIdentifier PointId2; PointId2 = pList.back(); pList.pop_back(); - FaceRefType FirstFace = this->m_Mesh->FindEdge(PointId1, PointId2)->GetLeft(); - bool SecondFaceFound = false; + const FaceRefType FirstFace = this->m_Mesh->FindEdge(PointId1, PointId2)->GetLeft(); + bool SecondFaceFound = false; while ((pList.size()) && (!SecondFaceFound)) { PointId1 = PointId2; diff --git a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshEulerOperatorJoinVertexFunction.hxx b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshEulerOperatorJoinVertexFunction.hxx index 5147af9bb86..31cba699981 100644 --- a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshEulerOperatorJoinVertexFunction.hxx +++ b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshEulerOperatorJoinVertexFunction.hxx @@ -128,15 +128,15 @@ QuadEdgeMeshEulerOperatorJoinVertexFunction::Process(QEType * e) QEType * e_sym = e->GetSym(); // General case - bool wasLeftFace = e->IsLeftSet(); - bool wasRiteFace = e->IsRightSet(); - bool wasLeftTriangle = e->IsLnextOfTriangle(); - bool wasRiteTriangle = e_sym->IsLnextOfTriangle(); + const bool wasLeftFace = e->IsLeftSet(); + const bool wasRiteFace = e->IsRightSet(); + const bool wasLeftTriangle = e->IsLnextOfTriangle(); + const bool wasRiteTriangle = e_sym->IsLnextOfTriangle(); - PointIdentifier NewDest = e->GetDestination(); - PointIdentifier NewOrg = e->GetOrigin(); - QEType * leftZip = e->GetLnext(); - QEType * riteZip = e->GetOprev(); + const PointIdentifier NewDest = e->GetDestination(); + PointIdentifier NewOrg = e->GetOrigin(); + QEType * leftZip = e->GetLnext(); + QEType * riteZip = e->GetOprev(); // // \ | / // @@ -240,7 +240,7 @@ QuadEdgeMeshEulerOperatorJoinVertexFunction::ProcessIsolatedQuad m_OldPointID = temp->GetSym()->GetOrigin(); - bool e_leftset = e->IsLeftSet(); + const bool e_leftset = e->IsLeftSet(); this->m_Mesh->LightWeightDeleteEdge(e); if (e_leftset) { @@ -261,8 +261,8 @@ QuadEdgeMeshEulerOperatorJoinVertexFunction::ProcessIsolatedFace QEType * e, std::stack & EdgesToBeDeleted) { - PointIdentifier org = e->GetOrigin(); - PointIdentifier dest = e->GetDestination(); + const PointIdentifier org = e->GetOrigin(); + const PointIdentifier dest = e->GetDestination(); // delete all elements while (!EdgesToBeDeleted.empty()) @@ -334,8 +334,8 @@ QuadEdgeMeshEulerOperatorJoinVertexFunction::CheckStatus(QEType QEType * e_sym = e->GetSym(); - bool IsEdgeIsolated = e->IsIsolated(); - bool IsSymEdgeIsolated = e_sym->IsIsolated(); + const bool IsEdgeIsolated = e->IsIsolated(); + const bool IsSymEdgeIsolated = e_sym->IsIsolated(); if (IsEdgeIsolated || IsSymEdgeIsolated) { if (IsEdgeIsolated && IsSymEdgeIsolated) @@ -369,7 +369,7 @@ QuadEdgeMeshEulerOperatorJoinVertexFunction::CheckStatus(QEType return QUADEDGE_ISOLATED; } - PointIdentifier number_common_vertices = CommonVertexNeighboor(e); + const PointIdentifier number_common_vertices = CommonVertexNeighboor(e); if (number_common_vertices > 2) { itkDebugMacro("The 2 vertices have more than 2 common neighboor vertices."); @@ -386,8 +386,8 @@ QuadEdgeMeshEulerOperatorJoinVertexFunction::CheckStatus(QEType } // General case - bool wasLeftFace = e->IsLeftSet(); - bool wasRiteFace = e->IsRightSet(); + const bool wasLeftFace = e->IsLeftSet(); + const bool wasRiteFace = e->IsRightSet(); if (wasLeftFace && wasRiteFace) { @@ -435,8 +435,8 @@ QuadEdgeMeshEulerOperatorJoinVertexFunction::IsTetrahedron(QETyp { if (e_sym->GetLprev()->GetOrder() == 3) { - bool left_triangle = e->IsLnextOfTriangle(); - bool right_triangle = e_sym->IsLnextOfTriangle(); + const bool left_triangle = e->IsLnextOfTriangle(); + const bool right_triangle = e_sym->IsLnextOfTriangle(); if (left_triangle && right_triangle) { @@ -505,8 +505,8 @@ template bool QuadEdgeMeshEulerOperatorJoinVertexFunction::IsEye(QEType * e) { - bool OriginOrderIsTwo = (e->GetOrder() == 2); - bool DestinationOrderIsTwo = (e->GetSym()->GetOrder() == 2); + const bool OriginOrderIsTwo = (e->GetOrder() == 2); + const bool DestinationOrderIsTwo = (e->GetSym()->GetOrder() == 2); return ((OriginOrderIsTwo && !DestinationOrderIsTwo) || (!OriginOrderIsTwo && DestinationOrderIsTwo)); } diff --git a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshEulerOperatorSplitFacetFunction.hxx b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshEulerOperatorSplitFacetFunction.hxx index 3baf4344ea9..04acef95046 100644 --- a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshEulerOperatorSplitFacetFunction.hxx +++ b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshEulerOperatorSplitFacetFunction.hxx @@ -74,8 +74,8 @@ QuadEdgeMeshEulerOperatorSplitFacetFunction::Evaluate(QEType * h using VertexRefType = typename MeshType::VertexRefType; this->m_Mesh->DeleteFace(h->GetLeft()); - VertexRefType orgPid = h->GetDestination(); - VertexRefType destPid = g->GetDestination(); + const VertexRefType orgPid = h->GetDestination(); + const VertexRefType destPid = g->GetDestination(); // Create an new isolated edge and set its geometry: auto * newEdge = new EdgeCellType; diff --git a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshEulerOperatorsTestHelper.h b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshEulerOperatorsTestHelper.h index 8ad48d58e89..2da1cae5207 100644 --- a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshEulerOperatorsTestHelper.h +++ b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshEulerOperatorsTestHelper.h @@ -82,11 +82,12 @@ CreateSquareQuadMesh(typename TMesh::Pointer mesh) } ///////////////////////////////////////////////////////////// - int expectedNumPts = 25; - int expectedNumCells = 16; - int simpleSquareCells[64] = { 0, 1, 6, 5, 1, 2, 7, 6, 2, 3, 8, 7, 3, 4, 9, 8, 5, 6, 11, 10, 6, 7, - 12, 11, 7, 8, 13, 12, 8, 9, 14, 13, 10, 11, 16, 15, 11, 12, 17, 16, 12, 13, 18, 17, - 13, 14, 19, 18, 15, 16, 21, 20, 16, 17, 22, 21, 17, 18, 23, 22, 18, 19, 24, 23 }; + const int expectedNumPts = 25; + const int expectedNumCells = 16; + const int simpleSquareCells[64] = { 0, 1, 6, 5, 1, 2, 7, 6, 2, 3, 8, 7, 3, 4, 9, 8, + 5, 6, 11, 10, 6, 7, 12, 11, 7, 8, 13, 12, 8, 9, 14, 13, + 10, 11, 16, 15, 11, 12, 17, 16, 12, 13, 18, 17, 13, 14, 19, 18, + 15, 16, 21, 20, 16, 17, 22, 21, 17, 18, 23, 22, 18, 19, 24, 23 }; using PointType = typename MeshType::PointType; @@ -129,13 +130,13 @@ CreateSquareTriangularMesh(typename TMesh::Pointer mesh) } ///////////////////////////////////////////////////////////// - int expectedNumPts = 25; - int expectedNumCells = 32; - int simpleSquareCells[96] = { 0, 1, 6, 0, 6, 5, 1, 2, 7, 1, 7, 6, 2, 3, 8, 2, 8, 7, 3, 4, - 9, 3, 9, 8, 5, 6, 11, 5, 11, 10, 6, 7, 12, 6, 12, 11, 7, 8, 13, 7, - 13, 12, 8, 9, 14, 8, 14, 13, 10, 11, 16, 10, 16, 15, 11, 12, 17, 11, 17, 16, - 12, 13, 18, 12, 18, 17, 13, 14, 19, 13, 19, 18, 15, 16, 21, 15, 21, 20, 16, 17, - 22, 16, 22, 21, 17, 18, 23, 17, 23, 22, 18, 19, 24, 18, 24, 23 }; + const int expectedNumPts = 25; + const int expectedNumCells = 32; + const int simpleSquareCells[96] = { 0, 1, 6, 0, 6, 5, 1, 2, 7, 1, 7, 6, 2, 3, 8, 2, 8, 7, 3, 4, + 9, 3, 9, 8, 5, 6, 11, 5, 11, 10, 6, 7, 12, 6, 12, 11, 7, 8, 13, 7, + 13, 12, 8, 9, 14, 8, 14, 13, 10, 11, 16, 10, 16, 15, 11, 12, 17, 11, 17, 16, + 12, 13, 18, 12, 18, 17, 13, 14, 19, 13, 19, 18, 15, 16, 21, 15, 21, 20, 16, 17, + 22, 16, 22, 21, 17, 18, 23, 17, 23, 22, 18, 19, 24, 18, 24, 23 }; using PointType = typename TMesh::PointType; std::vector pts = GeneratePointCoordinates(5); @@ -176,9 +177,9 @@ CreateTetraedronMesh(typename TMesh::Pointer mesh) } ///////////////////////////////////////////////////////////// - int expectedNumPts = 4; - int expectedNumCells = 4; - int simpleSquareCells[12] = { 0, 1, 2, 1, 0, 3, 1, 3, 2, 2, 3, 0 }; + const int expectedNumPts = 4; + const int expectedNumCells = 4; + const int simpleSquareCells[12] = { 0, 1, 2, 1, 0, 3, 1, 3, 2, 2, 3, 0 }; using PointType = typename TMesh::PointType; std::vector pts(4); @@ -233,9 +234,9 @@ CreateSamosa(typename TMesh::Pointer mesh) } ///////////////////////////////////////////////////////////// - int expectedNumPts = 3; - int expectedNumCells = 2; - int simpleSquareCells[6] = { 0, 1, 2, 1, 0, 2 }; + const int expectedNumPts = 3; + const int expectedNumCells = 2; + const int simpleSquareCells[6] = { 0, 1, 2, 1, 0, 2 }; using PointType = typename TMesh::PointType; std::vector pts(3); diff --git a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshFrontIterator.hxx b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshFrontIterator.hxx index 0f469052967..e53006deacd 100644 --- a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshFrontIterator.hxx +++ b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshFrontIterator.hxx @@ -105,7 +105,7 @@ QuadEdgeMeshFrontBaseIterator::operator++() m_IsPointVisited->SetElement(oEdge->GetDestination(), true); // Compute the Cost of the new OriginType: - CoordinateType oCost = this->GetCost(oEdge) + fit->m_Cost; + const CoordinateType oCost = this->GetCost(oEdge) + fit->m_Cost; // Push the Sym() on the front: m_Front->push_back(FrontAtom(oEdge->GetSym(), oCost)); diff --git a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshLineCell.hxx b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshLineCell.hxx index 7adcf04256e..36544746796 100644 --- a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshLineCell.hxx +++ b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshLineCell.hxx @@ -107,7 +107,7 @@ void QuadEdgeMeshLineCell::Accept(CellIdentifier cellId, MultiVisitor * mv) { using IntVis = CellInterfaceVisitor; - typename IntVis::Pointer v = mv->GetVisitor(this->GetType()); + const typename IntVis::Pointer v = mv->GetVisitor(this->GetType()); if (v) { v->VisitFromCell(cellId, this); diff --git a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshPolygonCell.h b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshPolygonCell.h index 702e5af9d8d..3371dca1a00 100644 --- a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshPolygonCell.h +++ b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshPolygonCell.h @@ -173,8 +173,8 @@ class ITK_TEMPLATE_EXPORT QuadEdgeMeshPolygonCell : public TCellInterface { PointIdentifier i = 0; - PointIdInternalConstIterator it = this->InternalPointIdsBegin(); - PointIdInternalConstIterator end = this->InternalPointIdsEnd(); + PointIdInternalConstIterator it = this->InternalPointIdsBegin(); + const PointIdInternalConstIterator end = this->InternalPointIdsEnd(); while (it != end) { @@ -288,8 +288,8 @@ class ITK_TEMPLATE_EXPORT QuadEdgeMeshPolygonCell : public TCellInterface { m_PointIds.clear(); - PointIdInternalConstIterator it = this->InternalPointIdsBegin(); - PointIdInternalConstIterator end = this->InternalPointIdsEnd(); + PointIdInternalConstIterator it = this->InternalPointIdsBegin(); + const PointIdInternalConstIterator end = this->InternalPointIdsEnd(); while (it != end) { diff --git a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshPolygonCell.hxx b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshPolygonCell.hxx index 63ec53a022b..7761c385187 100644 --- a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshPolygonCell.hxx +++ b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshPolygonCell.hxx @@ -108,7 +108,7 @@ void QuadEdgeMeshPolygonCell::Accept(CellIdentifier cellId, MultiVisitor * mv) { using IntVis = CellInterfaceVisitor; - typename IntVis::Pointer v = mv->GetVisitor(this->GetType()); + const typename IntVis::Pointer v = mv->GetVisitor(this->GetType()); if (v) { v->VisitFromCell(cellId, this); @@ -121,9 +121,9 @@ unsigned int QuadEdgeMeshPolygonCell::GetNumberOfPoints() const { // The constructor creates one edge by default - unsigned int n = 0; - PointIdInternalConstIterator it = this->InternalPointIdsBegin(); - PointIdInternalConstIterator end = this->InternalPointIdsEnd(); + unsigned int n = 0; + PointIdInternalConstIterator it = this->InternalPointIdsBegin(); + const PointIdInternalConstIterator end = this->InternalPointIdsEnd(); while (it != end) { @@ -175,9 +175,9 @@ QuadEdgeMeshPolygonCell::SetPointIds(PointIdConstIterator first) { if (this->GetNumberOfPoints() > 2) { - PointIdConstIterator i2 = first; - PointIdInternalIterator i1 = this->InternalPointIdsBegin(); - PointIdInternalIterator end = this->InternalPointIdsEnd(); + PointIdConstIterator i2 = first; + PointIdInternalIterator i1 = this->InternalPointIdsBegin(); + const PointIdInternalIterator end = this->InternalPointIdsEnd(); while (i1 != end) { @@ -195,9 +195,9 @@ QuadEdgeMeshPolygonCell::InternalSetPointIds(PointIdInternalCons { if (this->GetNumberOfPoints() > 2) { - PointIdInternalConstIterator i2 = first; - PointIdInternalIterator i1 = this->InternalPointIdsBegin(); - PointIdInternalIterator end = this->InternalPointIdsEnd(); + PointIdInternalConstIterator i2 = first; + PointIdInternalIterator i1 = this->InternalPointIdsBegin(); + const PointIdInternalIterator end = this->InternalPointIdsEnd(); while (i1 != end) { @@ -213,9 +213,9 @@ template void QuadEdgeMeshPolygonCell::SetPointIds(PointIdConstIterator first, PointIdConstIterator last) { - PointIdInternalIterator i1 = this->InternalPointIdsBegin(); - PointIdInternalIterator end = this->InternalPointIdsEnd(); - PointIdConstIterator i2 = first; + PointIdInternalIterator i1 = this->InternalPointIdsBegin(); + const PointIdInternalIterator end = this->InternalPointIdsEnd(); + PointIdConstIterator i2 = first; while (i1 != end && i2 != last) { @@ -231,9 +231,9 @@ void QuadEdgeMeshPolygonCell::InternalSetPointIds(PointIdInternalConstIterator first, PointIdInternalConstIterator last) { - PointIdInternalIterator i1 = this->InternalPointIdsBegin(); - PointIdInternalIterator end = this->InternalPointIdsEnd(); - PointIdInternalConstIterator i2 = first; + PointIdInternalIterator i1 = this->InternalPointIdsBegin(); + const PointIdInternalIterator end = this->InternalPointIdsEnd(); + PointIdInternalConstIterator i2 = first; while (i1 != end && i2 != last) { @@ -248,9 +248,9 @@ template void QuadEdgeMeshPolygonCell::SetPointId(int localId, PointIdentifier pId) { - int n = 0; - PointIdInternalIterator it = this->InternalPointIdsBegin(); - PointIdInternalIterator end = this->InternalPointIdsEnd(); + int n = 0; + PointIdInternalIterator it = this->InternalPointIdsBegin(); + const PointIdInternalIterator end = this->InternalPointIdsEnd(); while (it != end && n <= localId) { @@ -305,8 +305,8 @@ template auto QuadEdgeMeshPolygonCell::InternalGetPointIds() const -> PointIdInternalConstIterator { - const QuadEdgeType * edge = const_cast(m_EdgeRingEntry); - PointIdInternalConstIterator iterator(edge->BeginGeomLnext()); + const QuadEdgeType * edge = const_cast(m_EdgeRingEntry); + const PointIdInternalConstIterator iterator(edge->BeginGeomLnext()); return iterator; } @@ -316,8 +316,8 @@ template auto QuadEdgeMeshPolygonCell::InternalPointIdsBegin() const -> PointIdInternalConstIterator { - const QuadEdgeType * edge = const_cast(m_EdgeRingEntry); - PointIdInternalConstIterator iterator(edge->BeginGeomLnext()); + const QuadEdgeType * edge = const_cast(m_EdgeRingEntry); + const PointIdInternalConstIterator iterator(edge->BeginGeomLnext()); return iterator; } @@ -327,8 +327,8 @@ template auto QuadEdgeMeshPolygonCell::InternalPointIdsEnd() const -> PointIdInternalConstIterator { - const auto * edge = const_cast(m_EdgeRingEntry); - PointIdInternalConstIterator iterator = edge->EndGeomLnext(); + const auto * edge = const_cast(m_EdgeRingEntry); + const PointIdInternalConstIterator iterator = edge->EndGeomLnext(); return iterator; } diff --git a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshScalarDataVTKPolyDataWriter.hxx b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshScalarDataVTKPolyDataWriter.hxx index 36b1d72ff5f..2b26e953818 100644 --- a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshScalarDataVTKPolyDataWriter.hxx +++ b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshScalarDataVTKPolyDataWriter.hxx @@ -44,7 +44,7 @@ template void QuadEdgeMeshScalarDataVTKPolyDataWriter::WriteCellData() { - CellDataContainerConstPointer celldata = this->m_Input->GetCellData(); + const CellDataContainerConstPointer celldata = this->m_Input->GetCellData(); if (celldata) { @@ -67,8 +67,8 @@ QuadEdgeMeshScalarDataVTKPolyDataWriter::WriteCellData() SizeValueType k(0); - CellsContainerConstPointer cells = this->m_Input->GetCells(); - CellsContainerConstIterator it = cells->Begin(); + const CellsContainerConstPointer cells = this->m_Input->GetCells(); + CellsContainerConstIterator it = cells->Begin(); CellDataContainerConstIterator c_it = celldata->Begin(); @@ -97,7 +97,7 @@ template void QuadEdgeMeshScalarDataVTKPolyDataWriter::WritePointData() { - PointDataContainerConstPointer pointdata = this->m_Input->GetPointData(); + const PointDataContainerConstPointer pointdata = this->m_Input->GetPointData(); if (pointdata) { diff --git a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshToQuadEdgeMeshFilter.h b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshToQuadEdgeMeshFilter.h index 3a89efdf7e3..1ce98643481 100644 --- a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshToQuadEdgeMeshFilter.h +++ b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshToQuadEdgeMeshFilter.h @@ -156,7 +156,7 @@ CopyMeshToMeshCellData(const TInputMesh * in, TOutputMesh * out) using InputCellDataContainerConstPointer = typename InputCellDataContainer::ConstPointer; using OutputCellDataContainerPointer = typename OutputCellDataContainer::Pointer; - InputCellDataContainerConstPointer inputCellData = in->GetCellData(); + const InputCellDataContainerConstPointer inputCellData = in->GetCellData(); if (inputCellData == nullptr) { @@ -164,7 +164,7 @@ CopyMeshToMeshCellData(const TInputMesh * in, TOutputMesh * out) return; } - OutputCellDataContainerPointer outputCellData = OutputCellDataContainer::New(); + const OutputCellDataContainerPointer outputCellData = OutputCellDataContainer::New(); outputCellData->Reserve(inputCellData->Size()); // Copy point data @@ -172,7 +172,7 @@ CopyMeshToMeshCellData(const TInputMesh * in, TOutputMesh * out) InputCellDataContainerConstIterator inIt = inputCellData->Begin(); while (inIt != inputCellData->End()) { - typename OutputCellDataContainer::Element point(inIt.Value()); + const typename OutputCellDataContainer::Element point(inIt.Value()); outputCellData->SetElement(inIt.Index(), point); ++inIt; } @@ -197,7 +197,7 @@ CopyMeshToMeshPointData(const TInputMesh * in, TOutputMesh * out) return; } - OutputPointDataContainerPointer outputPointData = OutputPointDataContainer::New(); + const OutputPointDataContainerPointer outputPointData = OutputPointDataContainer::New(); outputPointData->Reserve(inputPointData->Size()); // Copy point data @@ -205,7 +205,7 @@ CopyMeshToMeshPointData(const TInputMesh * in, TOutputMesh * out) InputPointDataContainerConstIterator inIt = inputPointData->Begin(); while (inIt != inputPointData->End()) { - typename OutputPointDataContainer::Element point(inIt.Value()); + const typename OutputPointDataContainer::Element point(inIt.Value()); outputPointData->SetElement(inIt.Index(), point); ++inIt; } @@ -229,7 +229,7 @@ CopyMeshToMeshCells(const TInputMesh * in, TOutputMesh * out) out->SetCellsAllocationMethod(MeshEnums::MeshClassCellsAllocationMethod::CellsAllocatedDynamicallyCellByCell); - InputCellsContainerConstPointer inCells = in->GetCells(); + const InputCellsContainerConstPointer inCells = in->GetCells(); if (inCells == nullptr) { @@ -237,16 +237,16 @@ CopyMeshToMeshCells(const TInputMesh * in, TOutputMesh * out) return; } - InputCellsContainerConstIterator cIt = inCells->Begin(); - InputCellsContainerConstIterator cEnd = inCells->End(); + InputCellsContainerConstIterator cIt = inCells->Begin(); + const InputCellsContainerConstIterator cEnd = inCells->End(); while (cIt != cEnd) { auto * pe = dynamic_cast(cIt.Value()); if (pe) { - InputPointIdList points; - InputPointsIdInternalIterator pIt = pe->InternalPointIdsBegin(); - InputPointsIdInternalIterator pEnd = pe->InternalPointIdsEnd(); + InputPointIdList points; + InputPointsIdInternalIterator pIt = pe->InternalPointIdsBegin(); + const InputPointsIdInternalIterator pEnd = pe->InternalPointIdsEnd(); while (pIt != pEnd) { @@ -270,7 +270,7 @@ CopyMeshToMeshEdgeCells(const TInputMesh * in, TOutputMesh * out) using InputCellsContainerConstIterator = typename InputCellsContainer::ConstIterator; using InputEdgeCellType = typename TInputMesh::EdgeCellType; - InputCellsContainerConstPointer inEdgeCells = in->GetEdgeCells(); + const InputCellsContainerConstPointer inEdgeCells = in->GetEdgeCells(); if (inEdgeCells == nullptr) { @@ -278,8 +278,8 @@ CopyMeshToMeshEdgeCells(const TInputMesh * in, TOutputMesh * out) return; } - InputCellsContainerConstIterator ecIt = inEdgeCells->Begin(); - InputCellsContainerConstIterator ecEnd = inEdgeCells->End(); + InputCellsContainerConstIterator ecIt = inEdgeCells->Begin(); + const InputCellsContainerConstIterator ecEnd = inEdgeCells->End(); while (ecIt != ecEnd) { @@ -305,7 +305,7 @@ CopyMeshToMeshPoints(const TInputMesh * in, TOutputMesh * out) using OutputPointsContainerPointer = typename TOutputMesh::PointsContainerPointer; using OutputPointType = typename TOutputMesh::PointType; - InputPointsContainerConstPointer inPoints = in->GetPoints(); + const InputPointsContainerConstPointer inPoints = in->GetPoints(); if (inPoints == nullptr) { @@ -313,8 +313,8 @@ CopyMeshToMeshPoints(const TInputMesh * in, TOutputMesh * out) return; } - InputPointsContainerConstIterator inIt = inPoints->Begin(); - InputPointsContainerConstIterator inEnd = inPoints->End(); + InputPointsContainerConstIterator inIt = inPoints->Begin(); + const InputPointsContainerConstIterator inEnd = inPoints->End(); OutputPointsContainerPointer oPoints = out->GetPoints(); if (oPoints == nullptr) diff --git a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshTopologyChecker.hxx b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshTopologyChecker.hxx index f43a5398329..1e9f3434ea5 100644 --- a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshTopologyChecker.hxx +++ b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshTopologyChecker.hxx @@ -44,11 +44,11 @@ QuadEdgeMeshTopologyChecker::ValidateEulerCharacteristic() const auto boundaryEdges = BoundaryEdges::New(); // Number of USED points - PointIdentifier numPoints = m_Mesh->ComputeNumberOfPoints(); + const PointIdentifier numPoints = m_Mesh->ComputeNumberOfPoints(); // Number of USED edges - CellIdentifier numEdges = m_Mesh->ComputeNumberOfEdges(); + const CellIdentifier numEdges = m_Mesh->ComputeNumberOfEdges(); // Number of USED faces - CellIdentifier numFaces = m_Mesh->ComputeNumberOfFaces(); + const CellIdentifier numFaces = m_Mesh->ComputeNumberOfFaces(); // Number of Boundaries typename BoundaryEdges::OutputType listOfBoundaries = boundaryEdges->Evaluate((*m_Mesh)); auto numBounds = static_cast(listOfBoundaries->size()); @@ -78,8 +78,8 @@ QuadEdgeMeshTopologyChecker::ValidateEulerCharacteristic() const // hence ( 2 - numBounds - numFaces + numEdges - numPoints ) must // be an odd number. Let's check it out: // Note that genus can take a negative value... - OffsetValueType twiceGenus = OffsetValueType(2) - OffsetValueType(numBounds) - OffsetValueType(numFaces) + - OffsetValueType(numEdges) - OffsetValueType(numPoints); + const OffsetValueType twiceGenus = OffsetValueType(2) - OffsetValueType(numBounds) - OffsetValueType(numFaces) + + OffsetValueType(numEdges) - OffsetValueType(numPoints); if (twiceGenus % 2) { @@ -87,8 +87,8 @@ QuadEdgeMeshTopologyChecker::ValidateEulerCharacteristic() const } // Look is they are isolated edges - CellsContainerConstIterator cellIterator = m_Mesh->GetCells()->Begin(); - CellsContainerConstIterator cellEnd = m_Mesh->GetCells()->End(); + CellsContainerConstIterator cellIterator = m_Mesh->GetCells()->Begin(); + const CellsContainerConstIterator cellEnd = m_Mesh->GetCells()->End(); while (cellIterator != cellEnd) { // Is the cell an Edge ? diff --git a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshZipMeshFunction.hxx b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshZipMeshFunction.hxx index ba7a562ea2b..b9c51850568 100644 --- a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshZipMeshFunction.hxx +++ b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshZipMeshFunction.hxx @@ -75,13 +75,13 @@ QuadEdgeMeshZipMeshFunction::Evaluate(QEType * e) -> OutputType // / | \ // // // Store for latter usage (since e and e->GetRight() will be deleted): - QEType * a = e->GetLnext(); - QEType * b = e->GetOnext()->GetSym(); - OutputType VLeft = e->GetDestination(); - OutputType VRite = b->GetOrigin(); - bool wasFacePresent = e->IsRightSet(); - const auto rightFaceID = e->GetRight(); - OutputType resultingPointId = QEType::m_NoPoint; + QEType * a = e->GetLnext(); + QEType * b = e->GetOnext()->GetSym(); + const OutputType VLeft = e->GetDestination(); + const OutputType VRite = b->GetOrigin(); + const bool wasFacePresent = e->IsRightSet(); + const auto rightFaceID = e->GetRight(); + OutputType resultingPointId = QEType::m_NoPoint; // We should be cautious and consider the case when the very // initial situation was the following: diff --git a/Modules/Core/QuadEdgeMesh/test/itkDynamicQuadEdgeMeshTest.cxx b/Modules/Core/QuadEdgeMesh/test/itkDynamicQuadEdgeMeshTest.cxx index 823662b96b7..16f0e2d7ff6 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkDynamicQuadEdgeMeshTest.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkDynamicQuadEdgeMeshTest.cxx @@ -57,20 +57,20 @@ itkDynamicQuadEdgeMeshTest(int, char *[]) /** * Create the mesh through its object factory. */ - MeshType::Pointer mesh(MeshType::New()); + const MeshType::Pointer mesh(MeshType::New()); VectorType displacement; displacement[0] = 2; displacement[1] = 5; displacement[2] = 0; - PointType pointA{}; + const PointType pointA{}; - PointType pointB = pointA + displacement; - PointType pointC = pointB + displacement; - PointType pointD = pointC + displacement; + const PointType pointB = pointA + displacement; + const PointType pointC = pointB + displacement; + const PointType pointD = pointC + displacement; - PointsContainer::Pointer pointsContainter = mesh->GetPoints(); + const PointsContainer::Pointer pointsContainter = mesh->GetPoints(); pointsContainter->SetElement(0, pointA); pointsContainter->SetElement(1, pointB); @@ -79,8 +79,8 @@ itkDynamicQuadEdgeMeshTest(int, char *[]) std::cout << "Number of Points = " << mesh->GetNumberOfPoints() << std::endl; - PointsIterator point = pointsContainter->Begin(); - PointsIterator endpoint = pointsContainter->End(); + PointsIterator point = pointsContainter->Begin(); + const PointsIterator endpoint = pointsContainter->End(); while (point != endpoint) { diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshAddFaceTest1.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshAddFaceTest1.cxx index 89320cfd34a..7c6a0c0489a 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshAddFaceTest1.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshAddFaceTest1.cxx @@ -89,7 +89,7 @@ itkQuadEdgeMeshAddFaceTest1(int argc, char * argv[]) pid[i] = mesh->AddPoint(points[i]); } - int testType = std::stoi(argv[1]); + const int testType = std::stoi(argv[1]); if (testType == 0) { diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshAddFaceTest2.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshAddFaceTest2.cxx index c0606a551eb..73a8908efb3 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshAddFaceTest2.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshAddFaceTest2.cxx @@ -27,13 +27,13 @@ itkQuadEdgeMeshAddFaceTest2(int, char *[]) using CellType = MeshType::CellType; using QEPolygonCellType = itk::QuadEdgeMeshPolygonCell; - int numPts = 7; - int numCells = 4; + const int numPts = 7; + const int numCells = 4; std::cout << "numPts= " << numPts << std::endl; std::cout << "numCells= " << numCells << std::endl; - int oddConnectivityCells[12] = { + const int oddConnectivityCells[12] = { 0, 1, 2, 3, 4, 5, 6, 4, 0, 0, 4, 6, }; @@ -51,7 +51,7 @@ itkQuadEdgeMeshAddFaceTest2(int, char *[]) // Then we try to add a fourth triangle, which is the third triangle // inverted i.e. [0 4 6]. This triangle can not be added. - MeshPointer mesh = MeshType::New(); + const MeshPointer mesh = MeshType::New(); MeshType::PointType pts[7]; @@ -82,7 +82,7 @@ itkQuadEdgeMeshAddFaceTest2(int, char *[]) mesh->SetPoint(i, pts[i]); } - int computedNumPts = mesh->GetNumberOfPoints(); + const int computedNumPts = mesh->GetNumberOfPoints(); std::cout << "computedNumPts= " << computedNumPts << std::endl; CellType::CellAutoPointer cellpointer; @@ -98,7 +98,7 @@ itkQuadEdgeMeshAddFaceTest2(int, char *[]) mesh->SetCell(i, cellpointer); } - int computedNumFaces = mesh->ComputeNumberOfFaces(); + const int computedNumFaces = mesh->ComputeNumberOfFaces(); std::cout << "computedNumFaces= " << computedNumFaces << std::endl; std::cout << "Test whether the fourth face was rejected" << std::endl; diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshBasicLayerTest.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshBasicLayerTest.cxx index 373143d0070..5ca198f5dea 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshBasicLayerTest.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshBasicLayerTest.cxx @@ -86,8 +86,8 @@ itkQuadEdgeMeshBasicLayerTest(int, char *[]) ////////////////////////////////////////////////////////// std::cout << "Setting Origin() and Destination() values... " << std::endl; - int org[5] = { 0, 1, 2, 3, 0 }; - int dest[5] = { 1, 2, 3, 0, 2 }; + const int org[5] = { 0, 1, 2, 3, 0 }; + const int dest[5] = { 1, 2, 3, 0, 2 }; for (int i = 0; i < 5; ++i) { @@ -152,11 +152,11 @@ itkQuadEdgeMeshBasicLayerTest(int, char *[]) ////////////////////////////////////////////////////////// using IteratorGeom = PrimalType::IteratorGeom; std::cout << "Testing Onext iterators... " << std::endl; - int onextDestination[5][3] = { { 1, 2, 3 }, - { 2, 0, 0 }, // Last 0 is a dummy - { 3, 0, 1 }, - { 0, 2, 0 }, // Last 0 is a dummy - { 2, 3, 1 } }; + const int onextDestination[5][3] = { { 1, 2, 3 }, + { 2, 0, 0 }, // Last 0 is a dummy + { 3, 0, 1 }, + { 0, 2, 0 }, // Last 0 is a dummy + { 2, 3, 1 } }; for (int edge = 0; edge < 5; ++edge) { int test = 0; @@ -176,7 +176,7 @@ itkQuadEdgeMeshBasicLayerTest(int, char *[]) ////////////////////////////////////////////////////////// std::cout << "Testing Lnext iterators... " << std::endl; - int lnextDestination[5][3] = { { 0, 1, 2 }, { 1, 2, 0 }, { 2, 3, 0 }, { 3, 0, 2 }, { 0, 2, 3 } }; + const int lnextDestination[5][3] = { { 0, 1, 2 }, { 1, 2, 0 }, { 2, 3, 0 }, { 3, 0, 2 }, { 0, 2, 3 } }; for (int edge = 0; edge < 5; ++edge) { int test = 0; @@ -193,8 +193,8 @@ itkQuadEdgeMeshBasicLayerTest(int, char *[]) } std::cout << "on Sym()... " << std::endl; - int lnextDestinationOnSym[3] = { 2, 0, 1 }; - int test = 0; + const int lnextDestinationOnSym[3] = { 2, 0, 1 }; + int test = 0; for (IteratorGeom itLnext = e[4]->GetSym()->BeginGeomLnext(); itLnext != e[4]->GetSym()->EndGeomLnext(); itLnext++, test++) { @@ -212,7 +212,7 @@ itkQuadEdgeMeshBasicLayerTest(int, char *[]) ////////////////////////////////////////////////////////// std::cout << "Testing Sym iterators... " << std::endl; - int symDestination[5][3] = { { 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 0 }, { 0, 2 } }; + const int symDestination[5][3] = { { 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 0 }, { 0, 2 } }; for (int edge = 0; edge < 5; ++edge) { test = 0; diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshCellInterfaceTest.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshCellInterfaceTest.cxx index f13d0fb3492..805c3a1ecb3 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshCellInterfaceTest.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshCellInterfaceTest.cxx @@ -69,8 +69,8 @@ int TestCellInterface(std::string name, TCell * aCell) { - CellAutoPointer cell(aCell, true); - const TCell * cell2 = aCell; + const CellAutoPointer cell(aCell, true); + const TCell * cell2 = aCell; std::cout << "-------- " << name << '(' << aCell->GetNameOfClass() << ')' << std::endl; std::cout << " Type: " << static_cast(cell->GetType()) << std::endl; @@ -182,8 +182,8 @@ TestQECellInterface(std::string name, TCell * aCell) const TCell * cell2 = aCell; std::cout << " QE Iterator test: PointIds for empty cell: "; - typename TCell::PointIdInternalIterator pointId = cell->InternalPointIdsBegin(); - typename TCell::PointIdInternalIterator endId = cell->InternalPointIdsEnd(); + typename TCell::PointIdInternalIterator pointId = cell->InternalPointIdsBegin(); + const typename TCell::PointIdInternalIterator endId = cell->InternalPointIdsEnd(); while (pointId != endId) { std::cout << *pointId << ", "; @@ -192,8 +192,8 @@ TestQECellInterface(std::string name, TCell * aCell) std::cout << std::endl; std::cout << " ConstIterator test: PointIds for empty cell: "; - typename TCell::PointIdInternalConstIterator cpointId = cell2->InternalPointIdsBegin(); - typename TCell::PointIdInternalConstIterator cendId = cell2->InternalPointIdsEnd(); + typename TCell::PointIdInternalConstIterator cpointId = cell2->InternalPointIdsBegin(); + const typename TCell::PointIdInternalConstIterator cendId = cell2->InternalPointIdsEnd(); while (cpointId != cendId) { @@ -222,8 +222,8 @@ TestQECellInterface(std::string name, TCell * aCell) std::cout << " ConstIterator test: PointIds for populated cell: "; - typename TCell::PointIdInternalConstIterator ppointId = cell2->InternalPointIdsBegin(); - typename TCell::PointIdInternalConstIterator pendId = cell2->InternalPointIdsEnd(); + typename TCell::PointIdInternalConstIterator ppointId = cell2->InternalPointIdsBegin(); + const typename TCell::PointIdInternalConstIterator pendId = cell2->InternalPointIdsEnd(); while (ppointId != pendId) { std::cout << *ppointId << ", "; @@ -233,8 +233,8 @@ TestQECellInterface(std::string name, TCell * aCell) cell->InternalSetPointIds(cell2->InternalPointIdsBegin(), cell2->InternalPointIdsEnd()); std::cout << " Iterator test: PointIds for populated cell: "; - typename TCell::PointIdInternalIterator pxpointId = cell->InternalPointIdsBegin(); - typename TCell::PointIdInternalIterator pxendId = cell->InternalPointIdsEnd(); + typename TCell::PointIdInternalIterator pxpointId = cell->InternalPointIdsBegin(); + const typename TCell::PointIdInternalIterator pxendId = cell->InternalPointIdsEnd(); while (pxpointId != pxendId) { std::cout << *pxpointId << ", "; @@ -412,22 +412,22 @@ itkQuadEdgeMeshCellInterfaceTest(int, char *[]) // test 4 very specific QELineCell destructor cases { - QELineCellType test; - QEType * m_QuadEdgeGeom = test.GetQEGeom(); + const QELineCellType test; + QEType * m_QuadEdgeGeom = test.GetQEGeom(); delete m_QuadEdgeGeom->GetRot()->GetRot()->GetRot(); m_QuadEdgeGeom->GetRot()->GetRot()->SetRot(nullptr); } { - QELineCellType test; - QEType * m_QuadEdgeGeom = test.GetQEGeom(); + const QELineCellType test; + QEType * m_QuadEdgeGeom = test.GetQEGeom(); delete m_QuadEdgeGeom->GetRot()->GetRot()->GetRot(); m_QuadEdgeGeom->GetRot()->GetRot()->SetRot(nullptr); delete m_QuadEdgeGeom->GetRot()->GetRot(); m_QuadEdgeGeom->GetRot()->SetRot(nullptr); } { - QELineCellType test; - QEType * m_QuadEdgeGeom = test.GetQEGeom(); + const QELineCellType test; + QEType * m_QuadEdgeGeom = test.GetQEGeom(); delete m_QuadEdgeGeom->GetRot()->GetRot()->GetRot(); m_QuadEdgeGeom->GetRot()->GetRot()->SetRot(nullptr); delete m_QuadEdgeGeom->GetRot()->GetRot(); diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshCountingCellsTest.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshCountingCellsTest.cxx index b937c367040..a000782a4ba 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshCountingCellsTest.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshCountingCellsTest.cxx @@ -24,7 +24,7 @@ itkQuadEdgeMeshCountingCellsTest(int, char *[]) using MeshType = itk::QuadEdgeMesh; using MeshPointer = MeshType::Pointer; - MeshPointer mesh = MeshType::New(); + const MeshPointer mesh = MeshType::New(); CreateSquareTriangularMesh(mesh); // The initial configuration and numbering of simpleSquare.vtk: diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshDeleteEdgeTest.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshDeleteEdgeTest.cxx index 14c7a79bdf3..1a35e419edf 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshDeleteEdgeTest.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshDeleteEdgeTest.cxx @@ -23,7 +23,7 @@ itkQuadEdgeMeshDeleteEdgeTest(int, char *[]) { using PixelType = double; using MeshType = itk::QuadEdgeMesh; - std::string indent = " "; + const std::string indent = " "; auto mesh = MeshType::New(); @@ -56,12 +56,12 @@ itkQuadEdgeMeshDeleteEdgeTest(int, char *[]) p5[1] = 3.09016994374947; p5[2] = 0.0; - MeshType::PointIdentifier pid0 = mesh->AddPoint(p0); - MeshType::PointIdentifier pid1 = mesh->AddPoint(p1); - MeshType::PointIdentifier pid2 = mesh->AddPoint(p2); - MeshType::PointIdentifier pid3 = mesh->AddPoint(p3); - MeshType::PointIdentifier pid4 = mesh->AddPoint(p4); - MeshType::PointIdentifier pid5 = mesh->AddPoint(p5); + const MeshType::PointIdentifier pid0 = mesh->AddPoint(p0); + const MeshType::PointIdentifier pid1 = mesh->AddPoint(p1); + const MeshType::PointIdentifier pid2 = mesh->AddPoint(p2); + const MeshType::PointIdentifier pid3 = mesh->AddPoint(p3); + const MeshType::PointIdentifier pid4 = mesh->AddPoint(p4); + const MeshType::PointIdentifier pid5 = mesh->AddPoint(p5); // Cells in a proper way mesh->AddEdge(pid3, pid4); @@ -81,15 +81,15 @@ itkQuadEdgeMeshDeleteEdgeTest(int, char *[]) mesh->AddEdge(pid2, pid0); mesh->AddEdge(pid2, pid3); - itk::IdentifierType edgesBefore = mesh->ComputeNumberOfEdges(); + const itk::IdentifierType edgesBefore = mesh->ComputeNumberOfEdges(); // Deleting two arbitrary edges: mesh->DeleteEdge(pid3, pid4); mesh->DeleteEdge(pid0, pid5); std::cout << indent << "Trying to remove only two edges..."; - itk::IdentifierType expectedEdgeCount = 2; - itk::IdentifierType obtainedEdgeCount = edgesBefore - mesh->ComputeNumberOfEdges(); + const itk::IdentifierType expectedEdgeCount = 2; + const itk::IdentifierType obtainedEdgeCount = edgesBefore - mesh->ComputeNumberOfEdges(); if (obtainedEdgeCount != expectedEdgeCount) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshDeletePointAndReorderIDsTest.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshDeletePointAndReorderIDsTest.cxx index 07835174b0a..9e28352a753 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshDeletePointAndReorderIDsTest.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshDeletePointAndReorderIDsTest.cxx @@ -56,7 +56,7 @@ itkQuadEdgeMeshDeletePointAndReorderIDsTest(int, char *[]) } // create a tetahedra and one isolated point: id = 0 - int specialCells[12] = { 4, 1, 2, 4, 2, 3, 3, 1, 4, 1, 3, 2 }; + const int specialCells[12] = { 4, 1, 2, 4, 2, 3, 3, 1, 4, 1, 3, 2 }; CellType::CellAutoPointer cellpointer; QEPolygonCellType * poly; diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorCreateCenterVertexTest.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorCreateCenterVertexTest.cxx index 082c20d1a6c..8b53f6d856a 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorCreateCenterVertexTest.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorCreateCenterVertexTest.cxx @@ -60,7 +60,7 @@ itkQuadEdgeMeshEulerOperatorCreateCenterVertexTest(int, char *[]) std::cout << "Checking CreateCenterVertex." << std::endl; - MeshPointer mesh = MeshType::New(); + const MeshPointer mesh = MeshType::New(); CreateSquareTriangularMesh(mesh); auto createCenterVertex = CreateCenterVertex::New(); diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorDeleteCenterVertexTest.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorDeleteCenterVertexTest.cxx index 9fbbd842f6d..a1fd6544578 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorDeleteCenterVertexTest.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorDeleteCenterVertexTest.cxx @@ -67,7 +67,7 @@ itkQuadEdgeMeshEulerOperatorDeleteCenterVertexTest(int itkNotUsed(argc), char * // 0 ---------- 1 ---------- 2 --------- 3 --------- 4 std::cout << "Checking DeleteCenterVertex." << std::endl; - MeshPointer mesh = MeshType::New(); + const MeshPointer mesh = MeshType::New(); CreateSquareTriangularMesh(mesh); auto deleteCenterVertex = DeleteCenterVertex::New(); @@ -104,8 +104,8 @@ itkQuadEdgeMeshEulerOperatorDeleteCenterVertexTest(int itkNotUsed(argc), char * std::cout << "OK" << std::endl; { - MeshPointer specialmesh = MeshType::New(); - PointType pts3[4]; + const MeshPointer specialmesh = MeshType::New(); + PointType pts3[4]; pts3[0][0] = 0.0; pts3[0][1] = 0.0; pts3[0][2] = 0.0; @@ -122,7 +122,7 @@ itkQuadEdgeMeshEulerOperatorDeleteCenterVertexTest(int itkNotUsed(argc), char * { specialmesh->SetPoint(i, pts3[i]); } - int specialCells[12] = { 0, 1, 2, 0, 2, 3, 3, 1, 0, 1, 3, 2 }; + const int specialCells[12] = { 0, 1, 2, 0, 2, 3, 3, 1, 0, 1, 3, 2 }; CellType::CellAutoPointer cellpointer; using QEPolygonCellType = itk::QuadEdgeMeshPolygonCell; diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorFlipTest.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorFlipTest.cxx index fe4ff72a566..f5198144ebb 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorFlipTest.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorFlipTest.cxx @@ -29,7 +29,7 @@ itkQuadEdgeMeshEulerOperatorFlipTest(int, char *[]) using FlipEdge = itk::QuadEdgeMeshEulerOperatorFlipEdgeFunction; - MeshPointer mesh = MeshType::New(); + const MeshPointer mesh = MeshType::New(); CreateSquareTriangularMesh(mesh); auto flipEdge = FlipEdge::New(); std::cout << flipEdge << std::endl; diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorJoinFacetTest.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorJoinFacetTest.cxx index 31a5b013a59..d1449fc7c1d 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorJoinFacetTest.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorJoinFacetTest.cxx @@ -31,7 +31,7 @@ itkQuadEdgeMeshEulerOperatorJoinFacetTest(int, char *[]) using JoinFacet = itk::QuadEdgeMeshEulerOperatorJoinFacetFunction; // EULER OPERATOR TESTS - MeshPointer mesh = MeshType::New(); + const MeshPointer mesh = MeshType::New(); CreateSquareTriangularMesh(mesh); // The initial configuration and numbering of simpleSquare.vtk: diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorJoinVertexTest.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorJoinVertexTest.cxx index 9a94cacdb30..fc10266f21c 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorJoinVertexTest.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorJoinVertexTest.cxx @@ -60,8 +60,8 @@ itkQuadEdgeMeshEulerOperatorJoinVertexTest(int argc, char * argv[]) using JoinVertexType = itk::QuadEdgeMeshEulerOperatorJoinVertexFunction; - MeshPointer mesh = MeshType::New(); - PointIdentifier start_id(12); + const MeshPointer mesh = MeshType::New(); + PointIdentifier start_id(12); switch (InputType) { @@ -247,11 +247,11 @@ itkQuadEdgeMeshEulerOperatorJoinVertexTest(int argc, char * argv[]) while (qe != nullptr) { joinVertex->SetInput(mesh); - PointIdentifier id_org = qe->GetOrigin(); - PointIdentifier id_dest = qe->GetDestination(); + const PointIdentifier id_org = qe->GetOrigin(); + const PointIdentifier id_dest = qe->GetDestination(); - QEType * qe_output = joinVertex->Evaluate(qe); - JoinVertexType::EdgeStatusType status = joinVertex->GetEdgeStatus(); + QEType * qe_output = joinVertex->Evaluate(qe); + const JoinVertexType::EdgeStatusType status = joinVertex->GetEdgeStatus(); std::cout << "*** " << kk << " ***" << std::endl; std::cout << "org: " << id_org << ' ' << "dest: " << id_dest << ' ' << status << std::endl; @@ -270,7 +270,7 @@ itkQuadEdgeMeshEulerOperatorJoinVertexTest(int argc, char * argv[]) return EXIT_FAILURE; } - PointIdentifier old_id = joinVertex->GetOldPointID(); + const PointIdentifier old_id = joinVertex->GetOldPointID(); mesh->DeletePoint(old_id); diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorSplitEdgeTest.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorSplitEdgeTest.cxx index 38339251254..4ae3e4cf074 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorSplitEdgeTest.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorSplitEdgeTest.cxx @@ -36,7 +36,7 @@ itkQuadEdgeMeshEulerOperatorSplitEdgeTest(int, char *[]) // ///////////////////////////////////////// std::cout << "Checking SplitEdge." << std::endl; - MeshPointer mesh = MeshType::New(); + const MeshPointer mesh = MeshType::New(); CreateSquareTriangularMesh(mesh); auto splitEdge = SplitEdge::New(); diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorSplitFaceTest.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorSplitFaceTest.cxx index 75ebdc4a048..943a8411aef 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorSplitFaceTest.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorSplitFaceTest.cxx @@ -55,7 +55,7 @@ itkQuadEdgeMeshEulerOperatorSplitFaceTest(int, char *[]) } std::cout << "OK" << std::endl; - MeshPointer mesh = MeshType::New(); + const MeshPointer mesh = MeshType::New(); CreateSquareTriangularMesh(mesh); splitFacet->SetInput(mesh); diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorSplitVertexTest.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorSplitVertexTest.cxx index d99594febab..5121d5648e5 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorSplitVertexTest.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorSplitVertexTest.cxx @@ -39,7 +39,7 @@ itkQuadEdgeMeshEulerOperatorSplitVertexTest(int, char *[]) // ///////////////////////////////////////// std::cout << "Checking SplitVertex." << std::endl; - MeshPointer mesh = MeshType::New(); + const MeshPointer mesh = MeshType::New(); CreateSquareTriangularMesh(mesh); auto splitVertex = SplitVertex::New(); diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshFrontIteratorTest.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshFrontIteratorTest.cxx index b6558f3cb52..9d40404b272 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshFrontIteratorTest.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshFrontIteratorTest.cxx @@ -45,18 +45,18 @@ itkQuadEdgeMeshFrontIteratorTest(int, char *[]) using FrontIterator = MeshType::FrontIterator; using QEType = FrontIterator::QEType; - int expectedNumPts = 25; - int expectedNumCells = 32; + const int expectedNumPts = 25; + const int expectedNumCells = 32; std::cout << "expectedNumPts= " << expectedNumPts << std::endl; std::cout << "expectedNumCells= " << expectedNumCells << std::endl; ///////////////////////////////////////////////////////////// - int simpleSquareCells[96] = { 0, 1, 6, 0, 6, 5, 1, 2, 7, 1, 7, 6, 2, 3, 8, 2, 8, 7, 3, 4, - 9, 3, 9, 8, 5, 6, 11, 5, 11, 10, 6, 7, 12, 6, 12, 11, 7, 8, 13, 7, - 13, 12, 8, 9, 14, 8, 14, 13, 10, 11, 16, 10, 16, 15, 11, 12, 17, 11, 17, 16, - 12, 13, 18, 12, 18, 17, 13, 14, 19, 13, 19, 18, 15, 16, 21, 15, 21, 20, 16, 17, - 22, 16, 22, 21, 17, 18, 23, 17, 23, 22, 18, 19, 24, 18, 24, 23 }; + const int simpleSquareCells[96] = { 0, 1, 6, 0, 6, 5, 1, 2, 7, 1, 7, 6, 2, 3, 8, 2, 8, 7, 3, 4, + 9, 3, 9, 8, 5, 6, 11, 5, 11, 10, 6, 7, 12, 6, 12, 11, 7, 8, 13, 7, + 13, 12, 8, 9, 14, 8, 14, 13, 10, 11, 16, 10, 16, 15, 11, 12, 17, 11, 17, 16, + 12, 13, 18, 12, 18, 17, 13, 14, 19, 13, 19, 18, 15, 16, 21, 15, 21, 20, 16, 17, + 22, 16, 22, 21, 17, 18, 23, 17, 23, 22, 18, 19, 24, 18, 24, 23 }; // Configuration of simpleSquare mesh: // #Vertices= 25 , #Edges= 56, #Faces= 32, #Boundary= 1, Chi= 1 @@ -83,7 +83,7 @@ itkQuadEdgeMeshFrontIteratorTest(int, char *[]) // | / | / | / | / | // 0 ---------- 1 ---------- 2 --------- 3 --------- 4 - MeshPointer mesh = MeshType::New(); + const MeshPointer mesh = MeshType::New(); MeshType::PointType pts[25]; @@ -168,7 +168,7 @@ itkQuadEdgeMeshFrontIteratorTest(int, char *[]) mesh->SetPoint(i, pts[i]); } - int numPts = mesh->GetNumberOfPoints(); + const int numPts = mesh->GetNumberOfPoints(); std::cout << "numPts= " << numPts << std::endl; CellType::CellAutoPointer cellpointer; @@ -184,7 +184,7 @@ itkQuadEdgeMeshFrontIteratorTest(int, char *[]) mesh->SetCell(i, cellpointer); } - int numCells = mesh->GetNumberOfCells(); + const int numCells = mesh->GetNumberOfCells(); std::cout << "numCells= " << numCells << std::endl; // Use a FrontIterator (Primal) to visit the points. @@ -194,8 +194,8 @@ itkQuadEdgeMeshFrontIteratorTest(int, char *[]) { QEType * edge = it.Value(); - PointIdentifier origin = edge->GetOrigin(); - PointIdentifier destination = edge->GetDestination(); + const PointIdentifier origin = edge->GetOrigin(); + const PointIdentifier destination = edge->GetDestination(); if (!visitedSet.count(origin)) { @@ -208,8 +208,8 @@ itkQuadEdgeMeshFrontIteratorTest(int, char *[]) } // Compare with Mesh container iteration version - size_t numberOfPoints = visitedSet.size(); - int computedNumberOfPoints = mesh->ComputeNumberOfPoints(); + const size_t numberOfPoints = visitedSet.size(); + const int computedNumberOfPoints = mesh->ComputeNumberOfPoints(); std::cout << "numberOfPoints " << numberOfPoints << std::endl; std::cout << "computedNumberOfPoints= " << computedNumberOfPoints << std::endl; diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshIteratorTest.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshIteratorTest.cxx index 073dffc63f1..24d514d2e37 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshIteratorTest.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshIteratorTest.cxx @@ -49,7 +49,7 @@ itkQuadEdgeMeshIteratorTest(int, char *[]) #define NumPoints 6 #define NumEdges 6 MeshType::PixelType a = std::sqrt(3.0) / 2.0; - MeshType::PixelType points[NumPoints][3] = { { 1.0, 0.0, 0.0 }, { 0.5, a, 0.0 }, { -0.5, a, 0.0 }, + const MeshType::PixelType points[NumPoints][3] = { { 1.0, 0.0, 0.0 }, { 0.5, a, 0.0 }, { -0.5, a, 0.0 }, { -1.0, 0.0, 0.0 }, { -0.5, -a, 0.0 }, { 0.5, -a, 0.0 } }; MeshType::PointType pnts[NumPoints]; MeshType::PointIdentifier pids[NumPoints]; diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshNoPointConstTest.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshNoPointConstTest.cxx index 6184eaf871e..badb326a58a 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshNoPointConstTest.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshNoPointConstTest.cxx @@ -26,9 +26,9 @@ itkQuadEdgeMeshNoPointConstTest(int, char *[]) using QEType = MeshType::QEType; using OriginRefType = QEType::OriginRefType; - OriginRefType NUM_LIMIT = std::numeric_limits::max(); - OriginRefType GQE_LIMIT = QEType::m_NoPoint; - OriginRefType QEM_LIMIT = MeshType::m_NoPoint; + const OriginRefType NUM_LIMIT = std::numeric_limits::max(); + const OriginRefType GQE_LIMIT = QEType::m_NoPoint; + const OriginRefType QEM_LIMIT = MeshType::m_NoPoint; std::cout << "VCL limit: " << NUM_LIMIT << std::endl; std::cout << "Geom QE limit: " << GQE_LIMIT << std::endl; diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshPointTest1.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshPointTest1.cxx index 12c731e0f0c..857cc78cef8 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshPointTest1.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshPointTest1.cxx @@ -44,16 +44,12 @@ itkQuadEdgeMeshPointTest1(int, char *[]) using SuperclassPointType = PointType::Superclass; - - PointType p0; // Test default constructor - PointType p1; - p1[0] = 17.7; p1[1] = 39.7; p1[2] = -49.7; - PointType p2(p1); // Test copy constructor + const PointType p2(p1); // Test copy constructor if (p1.EuclideanDistanceTo(p2) > 1e-6) { @@ -70,7 +66,7 @@ itkQuadEdgeMeshPointTest1(int, char *[]) ps[1] = 31; ps[2] = 37; - PointType pp = ps; + const PointType pp = ps; if (pp.EuclideanDistanceTo(ps) > 1e-6) { @@ -92,7 +88,7 @@ itkQuadEdgeMeshPointTest1(int, char *[]) cc[1] = 39.7; cc[2] = -49.7; - PointType p3(cc); // Test Array based constructor + const PointType p3(cc); // Test Array based constructor if (p2.EuclideanDistanceTo(p1) > 1e-6) { diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshScalarDataVTKPolyDataWriterTest1.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshScalarDataVTKPolyDataWriterTest1.cxx index d7fefeb0bf2..d3981bdd55f 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshScalarDataVTKPolyDataWriterTest1.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshScalarDataVTKPolyDataWriterTest1.cxx @@ -43,7 +43,7 @@ itkQuadEdgeMeshScalarDataVTKPolyDataWriterTest1(int argc, char * argv[]) using PointType = SphereMeshSourceType::PointType; using VectorType = SphereMeshSourceType::VectorType; - PointType center{}; + const PointType center{}; auto scale = itk::MakeFilled(1.0); @@ -58,7 +58,7 @@ itkQuadEdgeMeshScalarDataVTKPolyDataWriterTest1(int argc, char * argv[]) std::cout << "mySphereMeshSource: " << mySphereMeshSource; - MeshType::Pointer myMesh = mySphereMeshSource->GetOutput(); + const MeshType::Pointer myMesh = mySphereMeshSource->GetOutput(); PointType pt{}; @@ -73,7 +73,7 @@ itkQuadEdgeMeshScalarDataVTKPolyDataWriterTest1(int argc, char * argv[]) using CellsContainerPointer = MeshType::CellsContainerPointer; using CellType = MeshType::CellType; - CellsContainerPointer cells = myMesh->GetCells(); + const CellsContainerPointer cells = myMesh->GetCells(); unsigned int faceId = 0; @@ -105,11 +105,11 @@ itkQuadEdgeMeshScalarDataVTKPolyDataWriterTest1(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(writer, QuadEdgeMeshScalarDataVTKPolyDataWriter, VTKPolyDataWriter); - std::string cellDataName = "SphereCellData"; + const std::string cellDataName = "SphereCellData"; writer->SetCellDataName(cellDataName); ITK_TEST_SET_GET_VALUE(cellDataName, writer->GetCellDataName()); - std::string pointDataName = "SpherePointData"; + const std::string pointDataName = "SpherePointData"; writer->SetPointDataName(pointDataName); ITK_TEST_SET_GET_VALUE(pointDataName, writer->GetPointDataName()); diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshTest1.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshTest1.cxx index 588e5f33371..95d5f5933d9 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshTest1.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshTest1.cxx @@ -76,13 +76,13 @@ itkQuadEdgeMeshTest1(int, char *[]) } using PointsIterator = MeshType::PointsContainer::Iterator; - PointsIterator pointIterator = mesh->GetPoints()->Begin(); - PointsIterator end = mesh->GetPoints()->End(); + PointsIterator pointIterator = mesh->GetPoints()->Begin(); + const PointsIterator end = mesh->GetPoints()->End(); int nPoints = 0; while (pointIterator != end) { - MeshType::PointType p = pointIterator.Value(); + const MeshType::PointType p = pointIterator.Value(); if (p != pts[nPoints]) { @@ -116,7 +116,7 @@ itkQuadEdgeMeshTest1(int, char *[]) } // create a tetahedra and one isolated point: id = 4 - int specialCells[12] = { 0, 1, 2, 0, 2, 3, 3, 1, 0, 1, 3, 2 }; + const int specialCells[12] = { 0, 1, 2, 0, 2, 3, 3, 1, 0, 1, 3, 2 }; CellType::CellAutoPointer cellpointer; QEPolygonCellType * poly; diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshTest2.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshTest2.cxx index d3e57aec060..948bba903c6 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshTest2.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshTest2.cxx @@ -81,9 +81,9 @@ itkQuadEdgeMeshTest2(int, char *[]) } using CellIterator = MeshType::CellsContainer::Iterator; - CellIterator cellIterator = mesh->GetCells()->Begin(); - unsigned int ids[] = { 0, 1, 2, 1, 2, 0, 2, 0, 1 }; - int itIds = 0; + CellIterator cellIterator = mesh->GetCells()->Begin(); + const unsigned int ids[] = { 0, 1, 2, 1, 2, 0, 2, 0, 1 }; + int itIds = 0; while (cellIterator != mesh->GetCells()->End()) { diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshTest3.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshTest3.cxx index c9ea1abcfb5..227f143214a 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshTest3.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshTest3.cxx @@ -135,8 +135,8 @@ itkQuadEdgeMeshTest3(int, char *[]) std::cout << "numCells = " << mesh->GetNumberOfCells() << std::endl; using PointIterator = MeshType::PointsContainer::ConstIterator; - PointIterator pointIterator = mesh->GetPoints()->Begin(); - PointIterator pointEnd = mesh->GetPoints()->End(); + PointIterator pointIterator = mesh->GetPoints()->Begin(); + const PointIterator pointEnd = mesh->GetPoints()->End(); while (pointIterator != pointEnd) { diff --git a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeTest1.cxx b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeTest1.cxx index 7e22468270f..0bc1da2b284 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeTest1.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkQuadEdgeTest1.cxx @@ -36,9 +36,9 @@ itkQuadEdgeTest1(int, char *[]) auto * quadEdge2 = new QuadEdgeType; auto * quadEdge3 = new QuadEdgeType; - QuadEdgeTypePointer quadEdge1p(quadEdge1, true); - QuadEdgeTypePointer quadEdge2p(quadEdge2, true); - QuadEdgeTypePointer quadEdge3p(quadEdge3, true); + const QuadEdgeTypePointer quadEdge1p(quadEdge1, true); + const QuadEdgeTypePointer quadEdge2p(quadEdge2, true); + const QuadEdgeTypePointer quadEdge3p(quadEdge3, true); const QuadEdgeType * quadEdge1c = quadEdge1; @@ -80,8 +80,8 @@ itkQuadEdgeTest1(int, char *[]) auto * quadEdge1 = new QuadEdgeType; auto * quadEdge2 = new QuadEdgeType; - QuadEdgeTypePointer quadEdge1p(quadEdge1, true); - QuadEdgeTypePointer quadEdge2p(quadEdge2, true); + const QuadEdgeTypePointer quadEdge1p(quadEdge1, true); + const QuadEdgeTypePointer quadEdge2p(quadEdge2, true); const QuadEdgeType * quadEdge1c = quadEdge1; @@ -103,8 +103,8 @@ itkQuadEdgeTest1(int, char *[]) } // Verify that it can be changed. - auto * quadEdge3 = new QuadEdgeType; - QuadEdgeTypePointer quadEdge3p(quadEdge3, true); + auto * quadEdge3 = new QuadEdgeType; + const QuadEdgeTypePointer quadEdge3p(quadEdge3, true); quadEdge1->SetOnext(quadEdge3); @@ -131,10 +131,10 @@ itkQuadEdgeTest1(int, char *[]) auto * quadEdge3 = new QuadEdgeType; auto * quadEdge4 = new QuadEdgeType; - QuadEdgeTypePointer quadEdge1p(quadEdge1, true); - QuadEdgeTypePointer quadEdge2p(quadEdge2, true); - QuadEdgeTypePointer quadEdge3p(quadEdge3, true); - QuadEdgeTypePointer quadEdge4p(quadEdge4, true); + const QuadEdgeTypePointer quadEdge1p(quadEdge1, true); + const QuadEdgeTypePointer quadEdge2p(quadEdge2, true); + const QuadEdgeTypePointer quadEdge3p(quadEdge3, true); + const QuadEdgeTypePointer quadEdge4p(quadEdge4, true); const QuadEdgeType * quadEdge1c = quadEdge1; const QuadEdgeType * quadEdge2c = quadEdge2; @@ -222,12 +222,12 @@ itkQuadEdgeTest1(int, char *[]) auto * quadEdgeA = new QuadEdgeType; auto * quadEdgeB = new QuadEdgeType; - QuadEdgeTypePointer quadEdge1p(quadEdge1, true); - QuadEdgeTypePointer quadEdge2p(quadEdge2, true); - QuadEdgeTypePointer quadEdge3p(quadEdge3, true); - QuadEdgeTypePointer quadEdge4p(quadEdge4, true); - QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); - QuadEdgeTypePointer quadEdgeBp(quadEdgeB, true); + const QuadEdgeTypePointer quadEdge1p(quadEdge1, true); + const QuadEdgeTypePointer quadEdge2p(quadEdge2, true); + const QuadEdgeTypePointer quadEdge3p(quadEdge3, true); + const QuadEdgeTypePointer quadEdge4p(quadEdge4, true); + const QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); + const QuadEdgeTypePointer quadEdgeBp(quadEdgeB, true); const QuadEdgeType * quadEdge1c = quadEdge1; @@ -301,12 +301,12 @@ itkQuadEdgeTest1(int, char *[]) auto * quadEdgeA = new QuadEdgeType; auto * quadEdgeB = new QuadEdgeType; - QuadEdgeTypePointer quadEdge1p(quadEdge1, true); - QuadEdgeTypePointer quadEdge2p(quadEdge2, true); - QuadEdgeTypePointer quadEdge3p(quadEdge3, true); - QuadEdgeTypePointer quadEdge4p(quadEdge4, true); - QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); - QuadEdgeTypePointer quadEdgeBp(quadEdgeB, true); + const QuadEdgeTypePointer quadEdge1p(quadEdge1, true); + const QuadEdgeTypePointer quadEdge2p(quadEdge2, true); + const QuadEdgeTypePointer quadEdge3p(quadEdge3, true); + const QuadEdgeTypePointer quadEdge4p(quadEdge4, true); + const QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); + const QuadEdgeTypePointer quadEdgeBp(quadEdgeB, true); const QuadEdgeType * quadEdgeAc = quadEdgeA; @@ -387,15 +387,15 @@ itkQuadEdgeTest1(int, char *[]) auto * quadEdgeC = new QuadEdgeType; auto * quadEdgeD = new QuadEdgeType; - QuadEdgeTypePointer quadEdge1p(quadEdge1, true); - QuadEdgeTypePointer quadEdge2p(quadEdge2, true); - QuadEdgeTypePointer quadEdge3p(quadEdge3, true); - QuadEdgeTypePointer quadEdge4p(quadEdge4, true); + const QuadEdgeTypePointer quadEdge1p(quadEdge1, true); + const QuadEdgeTypePointer quadEdge2p(quadEdge2, true); + const QuadEdgeTypePointer quadEdge3p(quadEdge3, true); + const QuadEdgeTypePointer quadEdge4p(quadEdge4, true); - QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); - QuadEdgeTypePointer quadEdgeBp(quadEdgeB, true); - QuadEdgeTypePointer quadEdgeCp(quadEdgeC, true); - QuadEdgeTypePointer quadEdgeDp(quadEdgeD, true); + const QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); + const QuadEdgeTypePointer quadEdgeBp(quadEdgeB, true); + const QuadEdgeTypePointer quadEdgeCp(quadEdgeC, true); + const QuadEdgeTypePointer quadEdgeDp(quadEdgeD, true); const QuadEdgeType * quadEdge1c = quadEdge1; @@ -475,15 +475,15 @@ itkQuadEdgeTest1(int, char *[]) auto * quadEdgeC = new QuadEdgeType; auto * quadEdgeD = new QuadEdgeType; - QuadEdgeTypePointer quadEdge1p(quadEdge1, true); - QuadEdgeTypePointer quadEdge2p(quadEdge2, true); - QuadEdgeTypePointer quadEdge3p(quadEdge3, true); - QuadEdgeTypePointer quadEdge4p(quadEdge4, true); + const QuadEdgeTypePointer quadEdge1p(quadEdge1, true); + const QuadEdgeTypePointer quadEdge2p(quadEdge2, true); + const QuadEdgeTypePointer quadEdge3p(quadEdge3, true); + const QuadEdgeTypePointer quadEdge4p(quadEdge4, true); - QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); - QuadEdgeTypePointer quadEdgeBp(quadEdgeB, true); - QuadEdgeTypePointer quadEdgeCp(quadEdgeC, true); - QuadEdgeTypePointer quadEdgeDp(quadEdgeD, true); + const QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); + const QuadEdgeTypePointer quadEdgeBp(quadEdgeB, true); + const QuadEdgeTypePointer quadEdgeCp(quadEdgeC, true); + const QuadEdgeTypePointer quadEdgeDp(quadEdgeD, true); const QuadEdgeType * quadEdge1c = quadEdge1; @@ -563,15 +563,15 @@ itkQuadEdgeTest1(int, char *[]) auto * quadEdgeC = new QuadEdgeType; auto * quadEdgeD = new QuadEdgeType; - QuadEdgeTypePointer quadEdge1p(quadEdge1, true); - QuadEdgeTypePointer quadEdge2p(quadEdge2, true); - QuadEdgeTypePointer quadEdge3p(quadEdge3, true); - QuadEdgeTypePointer quadEdge4p(quadEdge4, true); + const QuadEdgeTypePointer quadEdge1p(quadEdge1, true); + const QuadEdgeTypePointer quadEdge2p(quadEdge2, true); + const QuadEdgeTypePointer quadEdge3p(quadEdge3, true); + const QuadEdgeTypePointer quadEdge4p(quadEdge4, true); - QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); - QuadEdgeTypePointer quadEdgeBp(quadEdgeB, true); - QuadEdgeTypePointer quadEdgeCp(quadEdgeC, true); - QuadEdgeTypePointer quadEdgeDp(quadEdgeD, true); + const QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); + const QuadEdgeTypePointer quadEdgeBp(quadEdgeB, true); + const QuadEdgeTypePointer quadEdgeCp(quadEdgeC, true); + const QuadEdgeTypePointer quadEdgeDp(quadEdgeD, true); const QuadEdgeType * quadEdge1c = quadEdge1; @@ -643,15 +643,15 @@ itkQuadEdgeTest1(int, char *[]) auto * quadEdgeC = new QuadEdgeType; auto * quadEdgeD = new QuadEdgeType; - QuadEdgeTypePointer quadEdge1p(quadEdge1, true); - QuadEdgeTypePointer quadEdge2p(quadEdge2, true); - QuadEdgeTypePointer quadEdge3p(quadEdge3, true); - QuadEdgeTypePointer quadEdge4p(quadEdge4, true); + const QuadEdgeTypePointer quadEdge1p(quadEdge1, true); + const QuadEdgeTypePointer quadEdge2p(quadEdge2, true); + const QuadEdgeTypePointer quadEdge3p(quadEdge3, true); + const QuadEdgeTypePointer quadEdge4p(quadEdge4, true); - QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); - QuadEdgeTypePointer quadEdgeBp(quadEdgeB, true); - QuadEdgeTypePointer quadEdgeCp(quadEdgeC, true); - QuadEdgeTypePointer quadEdgeDp(quadEdgeD, true); + const QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); + const QuadEdgeTypePointer quadEdgeBp(quadEdgeB, true); + const QuadEdgeTypePointer quadEdgeCp(quadEdgeC, true); + const QuadEdgeTypePointer quadEdgeDp(quadEdgeD, true); const QuadEdgeType * quadEdge1c = quadEdge1; @@ -725,15 +725,15 @@ itkQuadEdgeTest1(int, char *[]) auto * quadEdgeC = new QuadEdgeType; auto * quadEdgeD = new QuadEdgeType; - QuadEdgeTypePointer quadEdge1p(quadEdge1, true); - QuadEdgeTypePointer quadEdge2p(quadEdge2, true); - QuadEdgeTypePointer quadEdge3p(quadEdge3, true); - QuadEdgeTypePointer quadEdge4p(quadEdge4, true); + const QuadEdgeTypePointer quadEdge1p(quadEdge1, true); + const QuadEdgeTypePointer quadEdge2p(quadEdge2, true); + const QuadEdgeTypePointer quadEdge3p(quadEdge3, true); + const QuadEdgeTypePointer quadEdge4p(quadEdge4, true); - QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); - QuadEdgeTypePointer quadEdgeBp(quadEdgeB, true); - QuadEdgeTypePointer quadEdgeCp(quadEdgeC, true); - QuadEdgeTypePointer quadEdgeDp(quadEdgeD, true); + const QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); + const QuadEdgeTypePointer quadEdgeBp(quadEdgeB, true); + const QuadEdgeTypePointer quadEdgeCp(quadEdgeC, true); + const QuadEdgeTypePointer quadEdgeDp(quadEdgeD, true); const QuadEdgeType * quadEdge1c = quadEdge1; @@ -806,10 +806,10 @@ itkQuadEdgeTest1(int, char *[]) auto * quadEdge3 = new QuadEdgeType; auto * quadEdge4 = new QuadEdgeType; - QuadEdgeTypePointer quadEdge1p(quadEdge1, true); - QuadEdgeTypePointer quadEdge2p(quadEdge2, true); - QuadEdgeTypePointer quadEdge3p(quadEdge3, true); - QuadEdgeTypePointer quadEdge4p(quadEdge4, true); + const QuadEdgeTypePointer quadEdge1p(quadEdge1, true); + const QuadEdgeTypePointer quadEdge2p(quadEdge2, true); + const QuadEdgeTypePointer quadEdge3p(quadEdge3, true); + const QuadEdgeTypePointer quadEdge4p(quadEdge4, true); const QuadEdgeType * quadEdge1c = quadEdge1; @@ -877,15 +877,15 @@ itkQuadEdgeTest1(int, char *[]) auto * quadEdgeC = new QuadEdgeType; auto * quadEdgeD = new QuadEdgeType; - QuadEdgeTypePointer quadEdge1p(quadEdge1, true); - QuadEdgeTypePointer quadEdge2p(quadEdge2, true); - QuadEdgeTypePointer quadEdge3p(quadEdge3, true); - QuadEdgeTypePointer quadEdge4p(quadEdge4, true); + const QuadEdgeTypePointer quadEdge1p(quadEdge1, true); + const QuadEdgeTypePointer quadEdge2p(quadEdge2, true); + const QuadEdgeTypePointer quadEdge3p(quadEdge3, true); + const QuadEdgeTypePointer quadEdge4p(quadEdge4, true); - QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); - QuadEdgeTypePointer quadEdgeBp(quadEdgeB, true); - QuadEdgeTypePointer quadEdgeCp(quadEdgeC, true); - QuadEdgeTypePointer quadEdgeDp(quadEdgeD, true); + const QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); + const QuadEdgeTypePointer quadEdgeBp(quadEdgeB, true); + const QuadEdgeTypePointer quadEdgeCp(quadEdgeC, true); + const QuadEdgeTypePointer quadEdgeDp(quadEdgeD, true); const QuadEdgeType * quadEdge1c = quadEdge1; @@ -945,15 +945,15 @@ itkQuadEdgeTest1(int, char *[]) auto * quadEdgeC = new QuadEdgeType; auto * quadEdgeD = new QuadEdgeType; - QuadEdgeTypePointer quadEdge1p(quadEdge1, true); - QuadEdgeTypePointer quadEdge2p(quadEdge2, true); - QuadEdgeTypePointer quadEdge3p(quadEdge3, true); - QuadEdgeTypePointer quadEdge4p(quadEdge4, true); + const QuadEdgeTypePointer quadEdge1p(quadEdge1, true); + const QuadEdgeTypePointer quadEdge2p(quadEdge2, true); + const QuadEdgeTypePointer quadEdge3p(quadEdge3, true); + const QuadEdgeTypePointer quadEdge4p(quadEdge4, true); - QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); - QuadEdgeTypePointer quadEdgeBp(quadEdgeB, true); - QuadEdgeTypePointer quadEdgeCp(quadEdgeC, true); - QuadEdgeTypePointer quadEdgeDp(quadEdgeD, true); + const QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); + const QuadEdgeTypePointer quadEdgeBp(quadEdgeB, true); + const QuadEdgeTypePointer quadEdgeCp(quadEdgeC, true); + const QuadEdgeTypePointer quadEdgeDp(quadEdgeD, true); const QuadEdgeType * quadEdge1c = quadEdge1; @@ -1012,15 +1012,15 @@ itkQuadEdgeTest1(int, char *[]) auto * quadEdgeC = new QuadEdgeType; auto * quadEdgeD = new QuadEdgeType; - QuadEdgeTypePointer quadEdge1p(quadEdge1, true); - QuadEdgeTypePointer quadEdge2p(quadEdge2, true); - QuadEdgeTypePointer quadEdge3p(quadEdge3, true); - QuadEdgeTypePointer quadEdge4p(quadEdge4, true); + const QuadEdgeTypePointer quadEdge1p(quadEdge1, true); + const QuadEdgeTypePointer quadEdge2p(quadEdge2, true); + const QuadEdgeTypePointer quadEdge3p(quadEdge3, true); + const QuadEdgeTypePointer quadEdge4p(quadEdge4, true); - QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); - QuadEdgeTypePointer quadEdgeBp(quadEdgeB, true); - QuadEdgeTypePointer quadEdgeCp(quadEdgeC, true); - QuadEdgeTypePointer quadEdgeDp(quadEdgeD, true); + const QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); + const QuadEdgeTypePointer quadEdgeBp(quadEdgeB, true); + const QuadEdgeTypePointer quadEdgeCp(quadEdgeC, true); + const QuadEdgeTypePointer quadEdgeDp(quadEdgeD, true); const QuadEdgeType * quadEdge1c = quadEdge1; @@ -1080,15 +1080,15 @@ itkQuadEdgeTest1(int, char *[]) auto * quadEdgeC = new QuadEdgeType; auto * quadEdgeD = new QuadEdgeType; - QuadEdgeTypePointer quadEdge1p(quadEdge1, true); - QuadEdgeTypePointer quadEdge2p(quadEdge2, true); - QuadEdgeTypePointer quadEdge3p(quadEdge3, true); - QuadEdgeTypePointer quadEdge4p(quadEdge4, true); + const QuadEdgeTypePointer quadEdge1p(quadEdge1, true); + const QuadEdgeTypePointer quadEdge2p(quadEdge2, true); + const QuadEdgeTypePointer quadEdge3p(quadEdge3, true); + const QuadEdgeTypePointer quadEdge4p(quadEdge4, true); - QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); - QuadEdgeTypePointer quadEdgeBp(quadEdgeB, true); - QuadEdgeTypePointer quadEdgeCp(quadEdgeC, true); - QuadEdgeTypePointer quadEdgeDp(quadEdgeD, true); + const QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); + const QuadEdgeTypePointer quadEdgeBp(quadEdgeB, true); + const QuadEdgeTypePointer quadEdgeCp(quadEdgeC, true); + const QuadEdgeTypePointer quadEdgeDp(quadEdgeD, true); const QuadEdgeType * quadEdge1c = quadEdge1; @@ -1141,9 +1141,9 @@ itkQuadEdgeTest1(int, char *[]) auto * quadEdge2 = new QuadEdgeType; auto * quadEdgeA = new QuadEdgeType; - QuadEdgeTypePointer quadEdge1p(quadEdge1, true); - QuadEdgeTypePointer quadEdge2p(quadEdge2, true); - QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); + const QuadEdgeTypePointer quadEdge1p(quadEdge1, true); + const QuadEdgeTypePointer quadEdge2p(quadEdge2, true); + const QuadEdgeTypePointer quadEdgeAp(quadEdgeA, true); const QuadEdgeType * quadEdge1c = quadEdge1; @@ -1182,9 +1182,9 @@ itkQuadEdgeTest1(int, char *[]) // Tests for the IsIsolated() method { // create a local scope for these tests - auto * quadEdge1 = new QuadEdgeType; - QuadEdgeTypePointer quadEdge1p(quadEdge1, true); - const QuadEdgeType * quadEdge1c = quadEdge1; + auto * quadEdge1 = new QuadEdgeType; + const QuadEdgeTypePointer quadEdge1p(quadEdge1, true); + const QuadEdgeType * quadEdge1c = quadEdge1; if (quadEdge1c->IsIsolated() != true) { @@ -1193,8 +1193,8 @@ itkQuadEdgeTest1(int, char *[]) return EXIT_FAILURE; } - auto * quadEdge2 = new QuadEdgeType; - QuadEdgeTypePointer quadEdge2p(quadEdge2, true); + auto * quadEdge2 = new QuadEdgeType; + const QuadEdgeTypePointer quadEdge2p(quadEdge2, true); quadEdge1->SetOnext(quadEdge2); @@ -1224,12 +1224,12 @@ itkQuadEdgeTest1(int, char *[]) auto * quadEdge5 = new QuadEdgeType; auto * quadEdge6 = new QuadEdgeType; - QuadEdgeTypePointer quadEdge1p(quadEdge1, true); - QuadEdgeTypePointer quadEdge2p(quadEdge2, true); - QuadEdgeTypePointer quadEdge3p(quadEdge3, true); - QuadEdgeTypePointer quadEdge4p(quadEdge4, true); - QuadEdgeTypePointer quadEdge5p(quadEdge5, true); - QuadEdgeTypePointer quadEdge6p(quadEdge6, true); + const QuadEdgeTypePointer quadEdge1p(quadEdge1, true); + const QuadEdgeTypePointer quadEdge2p(quadEdge2, true); + const QuadEdgeTypePointer quadEdge3p(quadEdge3, true); + const QuadEdgeTypePointer quadEdge4p(quadEdge4, true); + const QuadEdgeTypePointer quadEdge5p(quadEdge5, true); + const QuadEdgeTypePointer quadEdge6p(quadEdge6, true); const QuadEdgeType * quadEdge1c = quadEdge1; @@ -1304,20 +1304,20 @@ itkQuadEdgeTest1(int, char *[]) auto * quadEdgeC3 = new QuadEdgeType; auto * quadEdgeC4 = new QuadEdgeType; - QuadEdgeTypePointer quadEdgeA1p(quadEdgeA1, true); - QuadEdgeTypePointer quadEdgeA2p(quadEdgeA2, true); - QuadEdgeTypePointer quadEdgeA3p(quadEdgeA3, true); - QuadEdgeTypePointer quadEdgeA4p(quadEdgeA4, true); + const QuadEdgeTypePointer quadEdgeA1p(quadEdgeA1, true); + const QuadEdgeTypePointer quadEdgeA2p(quadEdgeA2, true); + const QuadEdgeTypePointer quadEdgeA3p(quadEdgeA3, true); + const QuadEdgeTypePointer quadEdgeA4p(quadEdgeA4, true); - QuadEdgeTypePointer quadEdgeB1p(quadEdgeB1, true); - QuadEdgeTypePointer quadEdgeB2p(quadEdgeB2, true); - QuadEdgeTypePointer quadEdgeB3p(quadEdgeB3, true); - QuadEdgeTypePointer quadEdgeB4p(quadEdgeB4, true); + const QuadEdgeTypePointer quadEdgeB1p(quadEdgeB1, true); + const QuadEdgeTypePointer quadEdgeB2p(quadEdgeB2, true); + const QuadEdgeTypePointer quadEdgeB3p(quadEdgeB3, true); + const QuadEdgeTypePointer quadEdgeB4p(quadEdgeB4, true); - QuadEdgeTypePointer quadEdgeC1p(quadEdgeC1, true); - QuadEdgeTypePointer quadEdgeC2p(quadEdgeC2, true); - QuadEdgeTypePointer quadEdgeC3p(quadEdgeC3, true); - QuadEdgeTypePointer quadEdgeC4p(quadEdgeC4, true); + const QuadEdgeTypePointer quadEdgeC1p(quadEdgeC1, true); + const QuadEdgeTypePointer quadEdgeC2p(quadEdgeC2, true); + const QuadEdgeTypePointer quadEdgeC3p(quadEdgeC3, true); + const QuadEdgeTypePointer quadEdgeC4p(quadEdgeC4, true); const QuadEdgeType * quadEdgeA1c = quadEdgeA1; const QuadEdgeType * quadEdgeB1c = quadEdgeB1; diff --git a/Modules/Core/QuadEdgeMesh/test/itkVTKPolyDataIOQuadEdgeMeshTest.cxx b/Modules/Core/QuadEdgeMesh/test/itkVTKPolyDataIOQuadEdgeMeshTest.cxx index d44ed008d27..592a96db8f5 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkVTKPolyDataIOQuadEdgeMeshTest.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkVTKPolyDataIOQuadEdgeMeshTest.cxx @@ -49,7 +49,7 @@ itkVTKPolyDataIOQuadEdgeMeshTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(polyDataReader->Update()); - MeshType::Pointer mesh = polyDataReader->GetOutput(); + const MeshType::Pointer mesh = polyDataReader->GetOutput(); polyDataWriter->SetInput(mesh); diff --git a/Modules/Core/QuadEdgeMesh/test/itkVTKPolyDataReaderQuadEdgeMeshTest.cxx b/Modules/Core/QuadEdgeMesh/test/itkVTKPolyDataReaderQuadEdgeMeshTest.cxx index 9427853611b..26bbd8dc885 100644 --- a/Modules/Core/QuadEdgeMesh/test/itkVTKPolyDataReaderQuadEdgeMeshTest.cxx +++ b/Modules/Core/QuadEdgeMesh/test/itkVTKPolyDataReaderQuadEdgeMeshTest.cxx @@ -53,17 +53,18 @@ itkVTKPolyDataReaderQuadEdgeMeshTest(int argc, char * argv[]) std::cout << "polyDataReader:" << std::endl; std::cout << polyDataReader << std::endl; - MeshType::Pointer mesh = polyDataReader->GetOutput(); + const MeshType::Pointer mesh = polyDataReader->GetOutput(); std::cout << "Using following MeshType :"; std::cout << mesh->GetNameOfClass() << std::endl; - PointType point; + const PointType point{}; + std::cout << "Testing itk::VTKPolyDataReader" << std::endl; - unsigned int numberOfPoints = mesh->GetNumberOfPoints(); - unsigned int numberOfCells = mesh->GetNumberOfCells(); + const unsigned int numberOfPoints = mesh->GetNumberOfPoints(); + const unsigned int numberOfCells = mesh->GetNumberOfCells(); std::cout << "numberOfPoints= " << numberOfPoints << std::endl; std::cout << "numberOfCells= " << numberOfCells << std::endl; diff --git a/Modules/Core/SpatialObjects/include/itkArrowSpatialObject.hxx b/Modules/Core/SpatialObjects/include/itkArrowSpatialObject.hxx index f05cf09f886..09d71cef399 100644 --- a/Modules/Core/SpatialObjects/include/itkArrowSpatialObject.hxx +++ b/Modules/Core/SpatialObjects/include/itkArrowSpatialObject.hxx @@ -52,7 +52,7 @@ ArrowSpatialObject::ComputeMyBoundingBox() { itkDebugMacro("Computing Rectangle bounding box"); - PointType pnt = this->GetPositionInObjectSpace(); + const PointType pnt = this->GetPositionInObjectSpace(); this->GetModifiableMyBoundingBoxInObjectSpace()->SetMinimum(pnt); this->GetModifiableMyBoundingBoxInObjectSpace()->SetMaximum(pnt); @@ -128,7 +128,7 @@ ArrowSpatialObject::GetLengthInWorldSpace() const pnt = this->GetObjectToWorldTransform()->TransformPoint(pnt); pnt2 = this->GetObjectToWorldTransform()->TransformPoint(pnt2); - double len = pnt.EuclideanDistanceTo(pnt2); + const double len = pnt.EuclideanDistanceTo(pnt2); return len; } @@ -141,7 +141,7 @@ ArrowSpatialObject::InternalClone() const // this to new transform. typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Core/SpatialObjects/include/itkBlobSpatialObject.hxx b/Modules/Core/SpatialObjects/include/itkBlobSpatialObject.hxx index a2a4865f415..7093978169d 100644 --- a/Modules/Core/SpatialObjects/include/itkBlobSpatialObject.hxx +++ b/Modules/Core/SpatialObjects/include/itkBlobSpatialObject.hxx @@ -43,7 +43,7 @@ BlobSpatialObject::InternalClone() const // this to new transform. typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Core/SpatialObjects/include/itkBoxSpatialObject.hxx b/Modules/Core/SpatialObjects/include/itkBoxSpatialObject.hxx index 36b91a34984..79d4d605bdd 100644 --- a/Modules/Core/SpatialObjects/include/itkBoxSpatialObject.hxx +++ b/Modules/Core/SpatialObjects/include/itkBoxSpatialObject.hxx @@ -82,7 +82,7 @@ BoxSpatialObject::InternalClone() const // this to new transform. typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Core/SpatialObjects/include/itkContourSpatialObject.hxx b/Modules/Core/SpatialObjects/include/itkContourSpatialObject.hxx index 7cf6f179ee5..ca9d12c70ff 100644 --- a/Modules/Core/SpatialObjects/include/itkContourSpatialObject.hxx +++ b/Modules/Core/SpatialObjects/include/itkContourSpatialObject.hxx @@ -132,7 +132,7 @@ ContourSpatialObject::InternalClone() const // this to new transform. typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Core/SpatialObjects/include/itkDTITubeSpatialObject.hxx b/Modules/Core/SpatialObjects/include/itkDTITubeSpatialObject.hxx index 69276c1c714..5087902682a 100644 --- a/Modules/Core/SpatialObjects/include/itkDTITubeSpatialObject.hxx +++ b/Modules/Core/SpatialObjects/include/itkDTITubeSpatialObject.hxx @@ -36,7 +36,7 @@ DTITubeSpatialObject::InternalClone() const // this to new transform. typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Core/SpatialObjects/include/itkDTITubeSpatialObjectPoint.hxx b/Modules/Core/SpatialObjects/include/itkDTITubeSpatialObjectPoint.hxx index bf42b9c8376..4d292d8828d 100644 --- a/Modules/Core/SpatialObjects/include/itkDTITubeSpatialObjectPoint.hxx +++ b/Modules/Core/SpatialObjects/include/itkDTITubeSpatialObjectPoint.hxx @@ -71,7 +71,7 @@ template void DTITubeSpatialObjectPoint::AddField(const char * name, float value) { - FieldType field(itksys::SystemTools::LowerCase(name), value); + const FieldType field(itksys::SystemTools::LowerCase(name), value); m_Fields.push_back(field); } @@ -96,7 +96,7 @@ template void DTITubeSpatialObjectPoint::SetField(DTITubeSpatialObjectPointFieldEnum name, float value) { - std::string charname = this->TranslateEnumToChar(name); + const std::string charname = this->TranslateEnumToChar(name); if (!charname.empty()) { @@ -112,11 +112,11 @@ template void DTITubeSpatialObjectPoint::AddField(DTITubeSpatialObjectPointFieldEnum name, float value) { - std::string charname = this->TranslateEnumToChar(name); + const std::string charname = this->TranslateEnumToChar(name); if (!charname.empty()) { - FieldType field(itksys::SystemTools::LowerCase(charname).c_str(), value); + const FieldType field(itksys::SystemTools::LowerCase(charname).c_str(), value); m_Fields.push_back(field); } else @@ -146,7 +146,7 @@ template float DTITubeSpatialObjectPoint::GetField(DTITubeSpatialObjectPointFieldEnum name) const { - std::string charname = this->TranslateEnumToChar(name); + const std::string charname = this->TranslateEnumToChar(name); if (!charname.empty()) { return this->GetField(itksys::SystemTools::LowerCase(charname).c_str()); diff --git a/Modules/Core/SpatialObjects/include/itkEllipseSpatialObject.hxx b/Modules/Core/SpatialObjects/include/itkEllipseSpatialObject.hxx index 3c39f906e96..ab39af776c6 100644 --- a/Modules/Core/SpatialObjects/include/itkEllipseSpatialObject.hxx +++ b/Modules/Core/SpatialObjects/include/itkEllipseSpatialObject.hxx @@ -118,7 +118,7 @@ EllipseSpatialObject::InternalClone() const { typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("Downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Core/SpatialObjects/include/itkGaussianSpatialObject.hxx b/Modules/Core/SpatialObjects/include/itkGaussianSpatialObject.hxx index 9d762266ada..5f35c23d8d3 100644 --- a/Modules/Core/SpatialObjects/include/itkGaussianSpatialObject.hxx +++ b/Modules/Core/SpatialObjects/include/itkGaussianSpatialObject.hxx @@ -171,7 +171,7 @@ GaussianSpatialObject::InternalClone() const // this to new transform. typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Core/SpatialObjects/include/itkGroupSpatialObject.hxx b/Modules/Core/SpatialObjects/include/itkGroupSpatialObject.hxx index ec3d9e12c59..8c4744c2ab5 100644 --- a/Modules/Core/SpatialObjects/include/itkGroupSpatialObject.hxx +++ b/Modules/Core/SpatialObjects/include/itkGroupSpatialObject.hxx @@ -36,7 +36,7 @@ GroupSpatialObject::InternalClone() const // this to new transform. typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Core/SpatialObjects/include/itkImageMaskSpatialObject.hxx b/Modules/Core/SpatialObjects/include/itkImageMaskSpatialObject.hxx index 4482382fd1a..b5bbc4630c0 100644 --- a/Modules/Core/SpatialObjects/include/itkImageMaskSpatialObject.hxx +++ b/Modules/Core/SpatialObjects/include/itkImageMaskSpatialObject.hxx @@ -122,7 +122,7 @@ ImageMaskSpatialObject::InternalClone() const // this to new transform. typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Core/SpatialObjects/include/itkImageSpatialObject.hxx b/Modules/Core/SpatialObjects/include/itkImageSpatialObject.hxx index 91a17b460eb..e7436d399e6 100644 --- a/Modules/Core/SpatialObjects/include/itkImageSpatialObject.hxx +++ b/Modules/Core/SpatialObjects/include/itkImageSpatialObject.hxx @@ -90,7 +90,7 @@ ImageSpatialObject::ValueAtInObjectSpace(const PointType if (this->IsEvaluableAtInObjectSpace(point, 0, name)) { ContinuousIndexType cIndex; - bool isInside = m_Image->TransformPhysicalPointToContinuousIndex(point, cIndex); + const bool isInside = m_Image->TransformPhysicalPointToContinuousIndex(point, cIndex); if (isInside) { @@ -175,7 +175,7 @@ ImageSpatialObject::InternalClone() const // this to new transform. typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Core/SpatialObjects/include/itkLandmarkSpatialObject.hxx b/Modules/Core/SpatialObjects/include/itkLandmarkSpatialObject.hxx index d5403a3dece..bf5c52ce66b 100644 --- a/Modules/Core/SpatialObjects/include/itkLandmarkSpatialObject.hxx +++ b/Modules/Core/SpatialObjects/include/itkLandmarkSpatialObject.hxx @@ -43,7 +43,7 @@ LandmarkSpatialObject::InternalClone() const // this to new transform. typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Core/SpatialObjects/include/itkLineSpatialObject.hxx b/Modules/Core/SpatialObjects/include/itkLineSpatialObject.hxx index 22a0d6922ca..45fe2cc35b0 100644 --- a/Modules/Core/SpatialObjects/include/itkLineSpatialObject.hxx +++ b/Modules/Core/SpatialObjects/include/itkLineSpatialObject.hxx @@ -40,7 +40,7 @@ LineSpatialObject::InternalClone() const // this to new transform. typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Core/SpatialObjects/include/itkLineSpatialObjectPoint.hxx b/Modules/Core/SpatialObjects/include/itkLineSpatialObjectPoint.hxx index 323517b4b65..7bb0343f78c 100644 --- a/Modules/Core/SpatialObjects/include/itkLineSpatialObjectPoint.hxx +++ b/Modules/Core/SpatialObjects/include/itkLineSpatialObjectPoint.hxx @@ -25,8 +25,8 @@ namespace itk template LineSpatialObjectPoint::LineSpatialObjectPoint() { - unsigned int ii = 0; - CovariantVectorType normal{}; + unsigned int ii = 0; + const CovariantVectorType normal{}; while (ii < TPointDimension - 1) { this->m_NormalArrayInObjectSpace[ii] = normal; diff --git a/Modules/Core/SpatialObjects/include/itkMeshSpatialObject.hxx b/Modules/Core/SpatialObjects/include/itkMeshSpatialObject.hxx index c405c932bb8..7882906b6cc 100644 --- a/Modules/Core/SpatialObjects/include/itkMeshSpatialObject.hxx +++ b/Modules/Core/SpatialObjects/include/itkMeshSpatialObject.hxx @@ -54,7 +54,7 @@ MeshSpatialObject::IsInsideInObjectSpace(const PointType & point) const { if (this->GetMyBoundingBoxInObjectSpace()->IsInside(point)) { - typename MeshType::CellsContainerPointer cells = m_Mesh->GetCells(); + const typename MeshType::CellsContainerPointer cells = m_Mesh->GetCells(); typename MeshType::CellsContainer::ConstIterator it = cells->Begin(); while (it != cells->End()) { @@ -141,7 +141,7 @@ MeshSpatialObject::InternalClone() const // this to new transform. typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Core/SpatialObjects/include/itkMetaArrowConverter.hxx b/Modules/Core/SpatialObjects/include/itkMetaArrowConverter.hxx index 6f70aedbf32..6d530129053 100644 --- a/Modules/Core/SpatialObjects/include/itkMetaArrowConverter.hxx +++ b/Modules/Core/SpatialObjects/include/itkMetaArrowConverter.hxx @@ -39,11 +39,11 @@ MetaArrowConverter::MetaObjectToSpatialObject(const MetaObjectType * { itkExceptionMacro("Can't convert MetaObject to MetaArrow"); } - ArrowSpatialObjectPointer arrowSO = ArrowSpatialObjectType::New(); + const ArrowSpatialObjectPointer arrowSO = ArrowSpatialObjectType::New(); this->MetaObjectToSpatialObjectBase(mo, arrowSO); - float lengthInObjectSpace = metaArrow->Length(); + const float lengthInObjectSpace = metaArrow->Length(); arrowSO->SetLengthInObjectSpace(lengthInObjectSpace); const double * metaPosition = metaArrow->Position(); @@ -77,7 +77,7 @@ template auto MetaArrowConverter::SpatialObjectToMetaObject(const SpatialObjectType * spatialObject) -> MetaObjectType * { - ArrowSpatialObjectConstPointer arrowSO = dynamic_cast(spatialObject); + const ArrowSpatialObjectConstPointer arrowSO = dynamic_cast(spatialObject); if (arrowSO.IsNull()) { itkExceptionMacro("Can't downcast SpatialObject to ArrowSpatialObject"); @@ -89,7 +89,7 @@ MetaArrowConverter::SpatialObjectToMetaObject(const SpatialObjectTyp this->SpatialObjectToMetaObjectBase(spatialObject, mo); - float metaLength = arrowSO->GetLengthInObjectSpace(); + const float metaLength = arrowSO->GetLengthInObjectSpace(); mo->Length(metaLength); // convert position and direction diff --git a/Modules/Core/SpatialObjects/include/itkMetaBlobConverter.hxx b/Modules/Core/SpatialObjects/include/itkMetaBlobConverter.hxx index 5cf687cbef7..8af898b857a 100644 --- a/Modules/Core/SpatialObjects/include/itkMetaBlobConverter.hxx +++ b/Modules/Core/SpatialObjects/include/itkMetaBlobConverter.hxx @@ -54,7 +54,7 @@ MetaBlobConverter::MetaObjectToSpatialObject(const MetaObjectType * auto it2 = Blob->GetPoints().begin(); - vnl_vector v(VDimension); + const vnl_vector v(VDimension); for (unsigned int identifier = 0; identifier < Blob->GetPoints().size(); ++identifier) { @@ -87,7 +87,7 @@ template auto MetaBlobConverter::SpatialObjectToMetaObject(const SpatialObjectType * spatialObject) -> MetaObjectType * { - BlobSpatialObjectConstPointer blobSO = dynamic_cast(spatialObject); + const BlobSpatialObjectConstPointer blobSO = dynamic_cast(spatialObject); if (blobSO.IsNull()) { itkExceptionMacro("Can't downcast SpatialObject to BlobSpatialObject"); diff --git a/Modules/Core/SpatialObjects/include/itkMetaContourConverter.hxx b/Modules/Core/SpatialObjects/include/itkMetaContourConverter.hxx index 70e11fea8f6..04e5054daaa 100644 --- a/Modules/Core/SpatialObjects/include/itkMetaContourConverter.hxx +++ b/Modules/Core/SpatialObjects/include/itkMetaContourConverter.hxx @@ -40,7 +40,7 @@ MetaContourConverter::MetaObjectToSpatialObject(const MetaObjectType itkExceptionMacro("Can't downcast MetaObject to MetaContour"); } - ContourSpatialObjectPointer contourSO = ContourSpatialObjectType::New(); + const ContourSpatialObjectPointer contourSO = ContourSpatialObjectType::New(); contourSO->GetProperty().SetName(contourMO->Name()); contourSO->SetId(contourMO->ID()); @@ -132,7 +132,7 @@ template auto MetaContourConverter::SpatialObjectToMetaObject(const SpatialObjectType * so) -> MetaObjectType * { - ContourSpatialObjectConstPointer contourSO = dynamic_cast(so); + const ContourSpatialObjectConstPointer contourSO = dynamic_cast(so); if (contourSO.IsNull()) { itkExceptionMacro("Can't downcast SpatialObject to ContourSpatialObject"); diff --git a/Modules/Core/SpatialObjects/include/itkMetaConverterBase.hxx b/Modules/Core/SpatialObjects/include/itkMetaConverterBase.hxx index 31dce9cf696..5d8700bd51f 100644 --- a/Modules/Core/SpatialObjects/include/itkMetaConverterBase.hxx +++ b/Modules/Core/SpatialObjects/include/itkMetaConverterBase.hxx @@ -64,10 +64,11 @@ MetaConverterBase::SpatialObjectToMetaObjectBase(SpatialObjectConstP if (spatialObject->GetParent()) { mo->ParentID(spatialObject->GetParent()->GetId()); - typename SpatialObject::TransformType::ConstPointer tfm = spatialObject->GetObjectToParentTransform(); - double mo_off[10]; - double mo_mat[100]; - double mo_cen[10]; + const typename SpatialObject::TransformType::ConstPointer tfm = + spatialObject->GetObjectToParentTransform(); + double mo_off[10]; + double mo_mat[100]; + double mo_cen[10]; for (unsigned int i = 0; i < VDimension; ++i) { mo_off[i] = tfm->GetOffset()[i]; diff --git a/Modules/Core/SpatialObjects/include/itkMetaDTITubeConverter.hxx b/Modules/Core/SpatialObjects/include/itkMetaDTITubeConverter.hxx index 73f1d190fae..b3940d6760d 100644 --- a/Modules/Core/SpatialObjects/include/itkMetaDTITubeConverter.hxx +++ b/Modules/Core/SpatialObjects/include/itkMetaDTITubeConverter.hxx @@ -40,7 +40,7 @@ MetaDTITubeConverter::MetaObjectToSpatialObject(const MetaObjectType { itkExceptionMacro("Can't downcast MetaObject to MetaDTITube"); } - DTITubeSpatialObjectPointer tubeSO = DTITubeSpatialObjectType::New(); + const DTITubeSpatialObjectPointer tubeSO = DTITubeSpatialObjectType::New(); tubeSO->SetTypeName("DTITubeSpatialObject"); tubeSO->GetProperty().SetName(tube->Name()); @@ -178,7 +178,7 @@ template auto MetaDTITubeConverter::SpatialObjectToMetaObject(const SpatialObjectType * spatialObject) -> MetaObjectType * { - DTITubeSpatialObjectConstPointer DTITubeSO = dynamic_cast(spatialObject); + const DTITubeSpatialObjectConstPointer DTITubeSO = dynamic_cast(spatialObject); if (DTITubeSO.IsNull()) { itkExceptionMacro("Can't downcast SpatialObject to DTITubeSpatialObject"); diff --git a/Modules/Core/SpatialObjects/include/itkMetaEllipseConverter.hxx b/Modules/Core/SpatialObjects/include/itkMetaEllipseConverter.hxx index 2a353edb567..7bf16f808b6 100644 --- a/Modules/Core/SpatialObjects/include/itkMetaEllipseConverter.hxx +++ b/Modules/Core/SpatialObjects/include/itkMetaEllipseConverter.hxx @@ -40,7 +40,7 @@ MetaEllipseConverter::MetaObjectToSpatialObject(const MetaObjectType itkExceptionMacro("Can't downcast MetaObject to EllipseMetaObject"); } - EllipseSpatialObjectPointer ellipseSO = EllipseSpatialObjectType::New(); + const EllipseSpatialObjectPointer ellipseSO = EllipseSpatialObjectType::New(); typename EllipseSpatialObjectType::ArrayType radii; for (unsigned int i = 0; i < VDimension; ++i) @@ -65,7 +65,7 @@ template auto MetaEllipseConverter::SpatialObjectToMetaObject(const SpatialObjectType * so) -> MetaObjectType * { - EllipseSpatialObjectConstPointer ellipseSO = dynamic_cast(so); + const EllipseSpatialObjectConstPointer ellipseSO = dynamic_cast(so); if (ellipseSO.IsNull()) { itkExceptionMacro("Can't downcast SpatialObject to EllipseSpatialObject"); diff --git a/Modules/Core/SpatialObjects/include/itkMetaGaussianConverter.hxx b/Modules/Core/SpatialObjects/include/itkMetaGaussianConverter.hxx index 43fdb33b897..f2f9f8c88b1 100644 --- a/Modules/Core/SpatialObjects/include/itkMetaGaussianConverter.hxx +++ b/Modules/Core/SpatialObjects/include/itkMetaGaussianConverter.hxx @@ -40,7 +40,7 @@ MetaGaussianConverter::MetaObjectToSpatialObject(const MetaObjectTyp itkExceptionMacro("Can't convert MetaObject to MetaGaussian"); } - GaussianSpatialObjectPointer gaussianSO = GaussianSpatialObjectType::New(); + const GaussianSpatialObjectPointer gaussianSO = GaussianSpatialObjectType::New(); gaussianSO->SetMaximum(metaGaussian->Maximum()); gaussianSO->SetRadiusInObjectSpace(metaGaussian->Radius()); @@ -61,8 +61,8 @@ template auto MetaGaussianConverter::SpatialObjectToMetaObject(const SpatialObjectType * so) -> MetaObjectType * { - GaussianSpatialObjectConstPointer gaussianSO = dynamic_cast(so); - auto * metaGaussian = new GaussianMetaObjectType; + const GaussianSpatialObjectConstPointer gaussianSO = dynamic_cast(so); + auto * metaGaussian = new GaussianMetaObjectType; if (gaussianSO.IsNull()) { itkExceptionMacro("Can't downcast SpatialObject to GaussianSpatialObject"); diff --git a/Modules/Core/SpatialObjects/include/itkMetaGroupConverter.hxx b/Modules/Core/SpatialObjects/include/itkMetaGroupConverter.hxx index 9c129f2df63..0c49ed7d43e 100644 --- a/Modules/Core/SpatialObjects/include/itkMetaGroupConverter.hxx +++ b/Modules/Core/SpatialObjects/include/itkMetaGroupConverter.hxx @@ -39,7 +39,7 @@ MetaGroupConverter::MetaObjectToSpatialObject(const MetaObjectType * itkExceptionMacro("Can't convert MetaObject to MetaGroup"); } - GroupSpatialObjectPointer groupSO = GroupSpatialObjectType::New(); + const GroupSpatialObjectPointer groupSO = GroupSpatialObjectType::New(); groupSO->GetProperty().SetName(group->Name()); groupSO->GetProperty().SetRed(group->Color()[0]); @@ -56,7 +56,7 @@ template auto MetaGroupConverter::SpatialObjectToMetaObject(const SpatialObjectType * so) -> MetaObjectType * { - GroupSpatialObjectConstPointer groupSO = dynamic_cast(so); + const GroupSpatialObjectConstPointer groupSO = dynamic_cast(so); if (groupSO.IsNull()) { itkExceptionMacro("Can't downcast SpatialObject to GroupSpatialObject"); diff --git a/Modules/Core/SpatialObjects/include/itkMetaImageConverter.hxx b/Modules/Core/SpatialObjects/include/itkMetaImageConverter.hxx index f60935049d1..db82cd0d97d 100644 --- a/Modules/Core/SpatialObjects/include/itkMetaImageConverter.hxx +++ b/Modules/Core/SpatialObjects/include/itkMetaImageConverter.hxx @@ -99,9 +99,9 @@ MetaImageConverter::MetaObjectToSpati itkExceptionMacro("Can't convert MetaObject to MetaImage"); } - ImageSpatialObjectPointer imageSO = ImageSpatialObjectType::New(); + const ImageSpatialObjectPointer imageSO = ImageSpatialObjectType::New(); - typename ImageType::Pointer myImage = this->AllocateImage(imageMO); + const typename ImageType::Pointer myImage = this->AllocateImage(imageMO); this->MetaObjectToSpatialObjectBase(imageMO, imageSO); @@ -131,7 +131,7 @@ MetaImageConverter::SpatialObjectToMe } using ImageConstPointer = typename ImageType::ConstPointer; - ImageConstPointer SOImage = imageSO->GetImage(); + const ImageConstPointer SOImage = imageSO->GetImage(); int size[VDimension]; double spacing[VDimension]; diff --git a/Modules/Core/SpatialObjects/include/itkMetaLandmarkConverter.hxx b/Modules/Core/SpatialObjects/include/itkMetaLandmarkConverter.hxx index 155121259b5..3a72cf981e4 100644 --- a/Modules/Core/SpatialObjects/include/itkMetaLandmarkConverter.hxx +++ b/Modules/Core/SpatialObjects/include/itkMetaLandmarkConverter.hxx @@ -40,7 +40,7 @@ MetaLandmarkConverter::MetaObjectToSpatialObject(const MetaObjectTyp itkExceptionMacro("Can't convert MetaObject to MetaLandmark"); } - LandmarkSpatialObjectPointer landmarkSO = LandmarkSpatialObjectType::New(); + const LandmarkSpatialObjectPointer landmarkSO = LandmarkSpatialObjectType::New(); landmarkSO->GetProperty().SetName(landmarkMO->Name()); landmarkSO->SetId(landmarkMO->ID()); diff --git a/Modules/Core/SpatialObjects/include/itkMetaLineConverter.hxx b/Modules/Core/SpatialObjects/include/itkMetaLineConverter.hxx index 86e3f99a65f..d1f1117c9c9 100644 --- a/Modules/Core/SpatialObjects/include/itkMetaLineConverter.hxx +++ b/Modules/Core/SpatialObjects/include/itkMetaLineConverter.hxx @@ -40,7 +40,7 @@ MetaLineConverter::MetaObjectToSpatialObject(const MetaObjectType * itkExceptionMacro("Can't convert MetaObject to MetaLine"); } - LineSpatialObjectPointer lineSO = LineSpatialObjectType::New(); + const LineSpatialObjectPointer lineSO = LineSpatialObjectType::New(); lineSO->GetProperty().SetName(lineMO->Name()); lineSO->SetId(lineMO->ID()); @@ -95,7 +95,7 @@ template auto MetaLineConverter::SpatialObjectToMetaObject(const SpatialObjectType * spatialObject) -> MetaObjectType * { - LineSpatialObjectConstPointer lineSO = dynamic_cast(spatialObject); + const LineSpatialObjectConstPointer lineSO = dynamic_cast(spatialObject); if (lineSO.IsNull()) { itkExceptionMacro("Can't downcast SpatialObject to LineSpatialObject"); diff --git a/Modules/Core/SpatialObjects/include/itkMetaMeshConverter.hxx b/Modules/Core/SpatialObjects/include/itkMetaMeshConverter.hxx index 387eb6f1f7f..f4febe8a70d 100644 --- a/Modules/Core/SpatialObjects/include/itkMetaMeshConverter.hxx +++ b/Modules/Core/SpatialObjects/include/itkMetaMeshConverter.hxx @@ -214,7 +214,7 @@ MetaMeshConverter::SpatialObjectToMetaObject } auto * metamesh = new MeshMetaObjectType(VDimension); - typename MeshType::ConstPointer mesh = meshSO->GetMesh(); + const typename MeshType::ConstPointer mesh = meshSO->GetMesh(); if (!mesh) { @@ -249,8 +249,8 @@ MetaMeshConverter::SpatialObjectToMetaObject while (it_cells != cells->End()) { - unsigned int celldim = (*it_cells)->Value()->GetNumberOfPoints(); - auto * cell = new MeshCell(celldim); + const unsigned int celldim = (*it_cells)->Value()->GetNumberOfPoints(); + auto * cell = new MeshCell(celldim); typename MeshType::CellTraits::PointIdConstIterator itptids = (*it_cells)->Value()->GetPointIds(); unsigned int i = 0; @@ -261,7 +261,7 @@ MetaMeshConverter::SpatialObjectToMetaObject } cell->m_Id = (*it_cells)->Index(); - CellGeometryEnum geom = (*it_cells)->Value()->GetType(); + const CellGeometryEnum geom = (*it_cells)->Value()->GetType(); switch (geom) { diff --git a/Modules/Core/SpatialObjects/include/itkMetaSceneConverter.hxx b/Modules/Core/SpatialObjects/include/itkMetaSceneConverter.hxx index 0bac58e5462..9951b5285ad 100644 --- a/Modules/Core/SpatialObjects/include/itkMetaSceneConverter.hxx +++ b/Modules/Core/SpatialObjects/include/itkMetaSceneConverter.hxx @@ -147,7 +147,7 @@ MetaSceneConverter::CreateSpatialObjectScene } currentSO = converterIt->second->MetaObjectToSpatialObject(*it); } - int tmpParentId = currentSO->GetParentId(); + const int tmpParentId = currentSO->GetParentId(); if (soScene != nullptr) { soScene->AddChild(currentSO); @@ -211,7 +211,7 @@ MetaSceneConverter::CreateMetaScene(const Sp while (it != itEnd) { - std::string spatialObjectTypeName((*it)->GetTypeName()); + const std::string spatialObjectTypeName((*it)->GetTypeName()); if (spatialObjectTypeName == "GroupSpatialObject") { currentMeta = this->SpatialObjectToMetaObject>(*it); diff --git a/Modules/Core/SpatialObjects/include/itkMetaSurfaceConverter.hxx b/Modules/Core/SpatialObjects/include/itkMetaSurfaceConverter.hxx index 9c2b9eae1d4..616cc3405a9 100644 --- a/Modules/Core/SpatialObjects/include/itkMetaSurfaceConverter.hxx +++ b/Modules/Core/SpatialObjects/include/itkMetaSurfaceConverter.hxx @@ -91,7 +91,7 @@ template auto MetaSurfaceConverter::SpatialObjectToMetaObject(const SpatialObjectType * so) -> MetaObjectType * { - SurfaceSpatialObjectConstPointer surfaceSO = dynamic_cast(so); + const SurfaceSpatialObjectConstPointer surfaceSO = dynamic_cast(so); if (surfaceSO.IsNull()) { diff --git a/Modules/Core/SpatialObjects/include/itkMetaTubeConverter.hxx b/Modules/Core/SpatialObjects/include/itkMetaTubeConverter.hxx index 18d44ca2fd4..19b80feb33c 100644 --- a/Modules/Core/SpatialObjects/include/itkMetaTubeConverter.hxx +++ b/Modules/Core/SpatialObjects/include/itkMetaTubeConverter.hxx @@ -125,7 +125,7 @@ template auto MetaTubeConverter::SpatialObjectToMetaObject(const SpatialObjectType * spatialObject) -> MetaObjectType * { - TubeSpatialObjectConstPointer tubeSO = dynamic_cast(spatialObject); + const TubeSpatialObjectConstPointer tubeSO = dynamic_cast(spatialObject); if (tubeSO.IsNull()) { itkExceptionMacro("Can't downcast SpatialObject to TubeSpatialObject"); diff --git a/Modules/Core/SpatialObjects/include/itkPointBasedSpatialObject.hxx b/Modules/Core/SpatialObjects/include/itkPointBasedSpatialObject.hxx index f13ee642d9d..1cbd266a2ce 100644 --- a/Modules/Core/SpatialObjects/include/itkPointBasedSpatialObject.hxx +++ b/Modules/Core/SpatialObjects/include/itkPointBasedSpatialObject.hxx @@ -130,8 +130,8 @@ PointBasedSpatialObject::ClosestPointInWorl double closestPointDistance = NumericTraits::max(); while (it != itend) { - typename SpatialObjectPoint::PointType curpos = it->GetPositionInWorldSpace(); - double curdistance = curpos.EuclideanDistanceTo(point); + const typename SpatialObjectPoint::PointType curpos = it->GetPositionInWorldSpace(); + const double curdistance = curpos.EuclideanDistanceTo(point); if (curdistance < closestPointDistance) { closestPoint = (*it); @@ -154,13 +154,13 @@ PointBasedSpatialObject::ComputeMyBoundingB if (it == end) { - typename BoundingBoxType::PointType pnt{}; + const typename BoundingBoxType::PointType pnt{}; this->GetModifiableMyBoundingBoxInObjectSpace()->SetMinimum(pnt); this->GetModifiableMyBoundingBoxInObjectSpace()->SetMaximum(pnt); return; } - PointType pt = it->GetPositionInObjectSpace(); + const PointType pt = it->GetPositionInObjectSpace(); this->GetModifiableMyBoundingBoxInObjectSpace()->SetMinimum(pt); this->GetModifiableMyBoundingBoxInObjectSpace()->SetMaximum(pt); @@ -212,7 +212,7 @@ PointBasedSpatialObject::InternalClone() co // this to new transform. typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Core/SpatialObjects/include/itkPolygonSpatialObject.hxx b/Modules/Core/SpatialObjects/include/itkPolygonSpatialObject.hxx index fcba4e80290..d96b12a7867 100644 --- a/Modules/Core/SpatialObjects/include/itkPolygonSpatialObject.hxx +++ b/Modules/Core/SpatialObjects/include/itkPolygonSpatialObject.hxx @@ -96,10 +96,10 @@ PolygonSpatialObject::MeasureAreaInObjectSpace() const // where N is a unit vector normal to the plane. The `.' represents the // dot product operator, the `x' represents the cross product operator, // and itk::Math::abs() is the absolute value function. - double area = 0.0; - int numpoints = this->GetNumberOfPoints(); - int X = 0; - int Y = 1; + double area = 0.0; + const int numpoints = this->GetNumberOfPoints(); + int X = 0; + int Y = 1; if (numpoints < 3) { @@ -158,8 +158,8 @@ template double PolygonSpatialObject::MeasurePerimeterInObjectSpace() const { - double perimeter = 0.0; - int numpoints = this->GetNumberOfPoints(); + double perimeter = 0.0; + const int numpoints = this->GetNumberOfPoints(); if (numpoints < 3) { @@ -180,7 +180,7 @@ PolygonSpatialObject::MeasurePerimeterInObjectSpace() const { continue; } - double curdistance = a.EuclideanDistanceTo(b); + const double curdistance = a.EuclideanDistanceTo(b); perimeter += curdistance; a = b; ++it; @@ -192,7 +192,7 @@ PolygonSpatialObject::MeasurePerimeterInObjectSpace() const // closed PolygonGroup may have the first and last points the same if (a != b) { - double curdistance = a.EuclideanDistanceTo(b); + const double curdistance = a.EuclideanDistanceTo(b); perimeter += curdistance; } } @@ -205,9 +205,9 @@ PolygonSpatialObject::IsInsideInObjectSpace(const PointType & point) { if (this->GetIsClosed() && this->GetMyBoundingBoxInObjectSpace()->IsInside(point)) { - int numpoints = this->GetNumberOfPoints(); - int X = -1; - int Y = -1; + const int numpoints = this->GetNumberOfPoints(); + int X = -1; + int Y = -1; if (numpoints >= 3) { @@ -290,7 +290,7 @@ PolygonSpatialObject::InternalClone() const // this to new transform. typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Core/SpatialObjects/include/itkSpatialObject.hxx b/Modules/Core/SpatialObjects/include/itkSpatialObject.hxx index cc532a78215..23792dca694 100644 --- a/Modules/Core/SpatialObjects/include/itkSpatialObject.hxx +++ b/Modules/Core/SpatialObjects/include/itkSpatialObject.hxx @@ -38,7 +38,7 @@ template void SpatialObject::Clear() { - typename BoundingBoxType::PointType pnt{}; + const typename BoundingBoxType::PointType pnt{}; m_FamilyBoundingBoxInObjectSpace->SetMinimum(pnt); m_FamilyBoundingBoxInObjectSpace->SetMaximum(pnt); m_FamilyBoundingBoxInWorldSpace->SetMinimum(pnt); @@ -333,7 +333,7 @@ SpatialObject::InternalClone() const { typename LightObject::Pointer loPtr = CreateAnother(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); @@ -600,7 +600,7 @@ template void SpatialObject::ComputeMyBoundingBox() { - typename BoundingBoxType::PointType pnt{}; + const typename BoundingBoxType::PointType pnt{}; if (m_MyBoundingBoxInObjectSpace->GetMinimum() != pnt || m_MyBoundingBoxInObjectSpace->GetMaximum() != pnt) { m_MyBoundingBoxInObjectSpace->SetMinimum(pnt); @@ -636,7 +636,7 @@ SpatialObject::ComputeFamilyBoundingBox(unsigned int depth, const st { itkDebugMacro("Computing Bounding Box"); - typename BoundingBoxType::PointType zeroPnt{}; + const typename BoundingBoxType::PointType zeroPnt{}; m_FamilyBoundingBoxInObjectSpace->SetMinimum(zeroPnt); m_FamilyBoundingBoxInObjectSpace->SetMaximum(zeroPnt); bool bbDefined = false; @@ -941,7 +941,7 @@ SpatialObject::FixIdValidity() id2 = (*it2)->GetId(); if (id == id2 || id2 == -1) { - int idNew = this->GetNextAvailableId(); + const int idNew = this->GetNextAvailableId(); (*it2)->SetId(idNew); ChildrenListType * children2 = (*it2)->GetChildren(0); auto childIt2 = children2->begin(); diff --git a/Modules/Core/SpatialObjects/include/itkSpatialObjectDuplicator.hxx b/Modules/Core/SpatialObjects/include/itkSpatialObjectDuplicator.hxx index a6c989bbebf..b61d9966f26 100644 --- a/Modules/Core/SpatialObjects/include/itkSpatialObjectDuplicator.hxx +++ b/Modules/Core/SpatialObjects/include/itkSpatialObjectDuplicator.hxx @@ -36,7 +36,7 @@ SpatialObjectDuplicator::CopyObject(const InternalSpatialOb { using SOType = itk::SpatialObject; - typename SOType::Pointer newSO = source->Clone(); + const typename SOType::Pointer newSO = source->Clone(); destination->AddChild(newSO); destination->Update(); @@ -61,9 +61,9 @@ SpatialObjectDuplicator::Update() } // Update only if the input SpatialObject has been modified - ModifiedTimeType t1 = m_Input->GetPipelineMTime(); - ModifiedTimeType t2 = m_Input->GetMTime(); - ModifiedTimeType t = (t1 > t2 ? t1 : t2); + const ModifiedTimeType t1 = m_Input->GetPipelineMTime(); + const ModifiedTimeType t2 = m_Input->GetMTime(); + const ModifiedTimeType t = (t1 > t2 ? t1 : t2); if (t == m_InternalSpatialObjectTime) { diff --git a/Modules/Core/SpatialObjects/include/itkSpatialObjectFactory.h b/Modules/Core/SpatialObjects/include/itkSpatialObjectFactory.h index 4b184e0d0d3..cb8c5bb3617 100644 --- a/Modules/Core/SpatialObjects/include/itkSpatialObjectFactory.h +++ b/Modules/Core/SpatialObjects/include/itkSpatialObjectFactory.h @@ -45,8 +45,8 @@ class SpatialObjectFactory : public SpatialObjectFactoryBase static void RegisterSpatialObject() { - auto t = T::New(); - SpatialObjectFactoryBase::Pointer f = SpatialObjectFactoryBase::GetFactory(); + auto t = T::New(); + const SpatialObjectFactoryBase::Pointer f = SpatialObjectFactoryBase::GetFactory(); f->RegisterSpatialObject(t->GetClassNameAndDimension().c_str(), t->GetClassNameAndDimension().c_str(), t->GetClassNameAndDimension().c_str(), diff --git a/Modules/Core/SpatialObjects/include/itkSpatialObjectToImageFilter.hxx b/Modules/Core/SpatialObjects/include/itkSpatialObjectToImageFilter.hxx index f6cc6afaaed..41b1e948dd3 100644 --- a/Modules/Core/SpatialObjects/include/itkSpatialObjectToImageFilter.hxx +++ b/Modules/Core/SpatialObjects/include/itkSpatialObjectToImageFilter.hxx @@ -293,7 +293,7 @@ SpatialObjectToImageFilter::GenerateData() // Get the input and output pointers const InputSpatialObjectType * InputObject = this->GetInput(); - OutputImagePointer OutputImage = this->GetOutput(); + const OutputImagePointer OutputImage = this->GetOutput(); // Generate the image SizeType size; @@ -359,7 +359,7 @@ SpatialObjectToImageFilter::GenerateData() double val = 0; - bool evaluable = InputObject->ValueAtInWorldSpace(objectPoint, val, m_ChildrenDepth); + const bool evaluable = InputObject->ValueAtInWorldSpace(objectPoint, val, m_ChildrenDepth); if (Math::NotExactlyEquals(m_InsideValue, ValueType{}) || Math::NotExactlyEquals(m_OutsideValue, ValueType{})) { if (evaluable) diff --git a/Modules/Core/SpatialObjects/include/itkSpatialObjectToImageStatisticsCalculator.hxx b/Modules/Core/SpatialObjects/include/itkSpatialObjectToImageStatisticsCalculator.hxx index d81768de545..e3b2702a8c4 100644 --- a/Modules/Core/SpatialObjects/include/itkSpatialObjectToImageStatisticsCalculator.hxx +++ b/Modules/Core/SpatialObjects/include/itkSpatialObjectToImageStatisticsCalculator.hxx @@ -109,13 +109,13 @@ SpatialObjectToImageStatisticsCalculator; using MaskSOType = ImageMaskSpatialObject; - typename MaskSOType::Pointer maskSpatialObject = dynamic_cast(m_SpatialObject.GetPointer()); + const typename MaskSOType::Pointer maskSpatialObject = dynamic_cast(m_SpatialObject.GetPointer()); if (maskSpatialObject.IsNull()) { itkExceptionMacro("Invalid dynamic cast."); } - typename MaskImageType::ConstPointer maskImage = maskSpatialObject->GetImage(); + const typename MaskImageType::ConstPointer maskImage = maskSpatialObject->GetImage(); using MaskIteratorType = ImageRegionConstIteratorWithIndex; MaskIteratorType it(maskImage, maskImage->GetLargestPossibleRegion()); @@ -169,7 +169,7 @@ SpatialObjectToImageStatisticsCalculator indMax[i]) { - int tmpI = indMin[i]; + const int tmpI = indMin[i]; indMin[i] = indMax[i]; indMax[i] = tmpI; } diff --git a/Modules/Core/SpatialObjects/include/itkSpatialObjectToPointSetFilter.hxx b/Modules/Core/SpatialObjects/include/itkSpatialObjectToPointSetFilter.hxx index f032aee5529..6d0f6f0545b 100644 --- a/Modules/Core/SpatialObjects/include/itkSpatialObjectToPointSetFilter.hxx +++ b/Modules/Core/SpatialObjects/include/itkSpatialObjectToPointSetFilter.hxx @@ -66,8 +66,8 @@ void SpatialObjectToPointSetFilter::GenerateData() { // Get the input and output pointers - const SpatialObjectType * inputObject = this->GetInput(); - typename OutputPointSetType::Pointer outputPointSet = this->GetOutput(); + const SpatialObjectType * inputObject = this->GetInput(); + const typename OutputPointSetType::Pointer outputPointSet = this->GetOutput(); using PointIdentifier = typename OutputPointSetType::PointIdentifier; diff --git a/Modules/Core/SpatialObjects/include/itkSurfaceSpatialObject.hxx b/Modules/Core/SpatialObjects/include/itkSurfaceSpatialObject.hxx index a2ab1c933f5..d2e31f28f70 100644 --- a/Modules/Core/SpatialObjects/include/itkSurfaceSpatialObject.hxx +++ b/Modules/Core/SpatialObjects/include/itkSurfaceSpatialObject.hxx @@ -56,7 +56,7 @@ SurfaceSpatialObject::InternalClone() const // this to new transform. typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Core/SpatialObjects/include/itkTubeSpatialObject.hxx b/Modules/Core/SpatialObjects/include/itkTubeSpatialObject.hxx index 4fef24fe7b9..3a9b94b6bc4 100644 --- a/Modules/Core/SpatialObjects/include/itkTubeSpatialObject.hxx +++ b/Modules/Core/SpatialObjects/include/itkTubeSpatialObject.hxx @@ -91,7 +91,7 @@ TubeSpatialObject::InternalClone() const { typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); @@ -126,7 +126,7 @@ TubeSpatialObject::ComputeMyBoundingBox() if (it == end) { - typename BoundingBoxType::PointType pnt{}; + const typename BoundingBoxType::PointType pnt{}; this->GetModifiableMyBoundingBoxInObjectSpace()->SetMinimum(pnt); this->GetModifiableMyBoundingBoxInObjectSpace()->SetMaximum(pnt); return; @@ -187,10 +187,10 @@ TubeSpatialObject::IsInsideInObjectSpace(const Point auto last = end; --last; - PointType firstP = first->GetPositionInObjectSpace(); - double firstR = first->GetRadiusInObjectSpace(); - PointType lastP = last->GetPositionInObjectSpace(); - double lastR = last->GetRadiusInObjectSpace(); + const PointType firstP = first->GetPositionInObjectSpace(); + const double firstR = first->GetRadiusInObjectSpace(); + const PointType lastP = last->GetPositionInObjectSpace(); + const double lastR = last->GetRadiusInObjectSpace(); bool withinEndCap = false; while (it2 != end) @@ -233,10 +233,10 @@ TubeSpatialObject::IsInsideInObjectSpace(const Point double lambda = A / B; B = std::sqrt(B); - double lambdaMin = 0; - double lambdaMax = 1; - double lambdaMinR = it->GetRadiusInObjectSpace(); - double lambdaMaxR = it2->GetRadiusInObjectSpace(); + double lambdaMin = 0; + double lambdaMax = 1; + const double lambdaMinR = it->GetRadiusInObjectSpace(); + const double lambdaMaxR = it2->GetRadiusInObjectSpace(); if (m_EndRounded || !withinEndCap) { lambdaMin = -(lambdaMinR / B); @@ -262,7 +262,7 @@ TubeSpatialObject::IsInsideInObjectSpace(const Point lambda = 1; } - double lambdaR = lambdaMinR + lambda * (lambdaMaxR - lambdaMinR); + const double lambdaR = lambdaMinR + lambda * (lambdaMaxR - lambdaMinR); PointType p; for (unsigned int i = 0; i < TDimension; ++i) diff --git a/Modules/Core/SpatialObjects/test/itkArrowSpatialObjectTest.cxx b/Modules/Core/SpatialObjects/test/itkArrowSpatialObjectTest.cxx index a31820af0a8..00d867b2f5c 100644 --- a/Modules/Core/SpatialObjects/test/itkArrowSpatialObjectTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkArrowSpatialObjectTest.cxx @@ -43,7 +43,7 @@ itkArrowSpatialObjectTest(int, char *[]) // Testing the length std::cout << "Testing length : "; - double length = 2; + const double length = 2; myArrow->SetLengthInObjectSpace(length); ITK_TEST_SET_GET_VALUE(length, myArrow->GetLengthInObjectSpace()); diff --git a/Modules/Core/SpatialObjects/test/itkBlobSpatialObjectTest.cxx b/Modules/Core/SpatialObjects/test/itkBlobSpatialObjectTest.cxx index 723db2eba4c..03067143f95 100644 --- a/Modules/Core/SpatialObjects/test/itkBlobSpatialObjectTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkBlobSpatialObjectTest.cxx @@ -58,7 +58,7 @@ itkBlobSpatialObjectTest(int, char *[]) p.Print(std::cout); // Create a Blob Spatial Object - BlobPointer blob = BlobType::New(); + const BlobPointer blob = BlobType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(blob, BlobSpatialObject, PointBasedSpatialObject); diff --git a/Modules/Core/SpatialObjects/test/itkCastSpatialObjectFilterTest.cxx b/Modules/Core/SpatialObjects/test/itkCastSpatialObjectFilterTest.cxx index 8efe87af30b..dfbbb18072e 100644 --- a/Modules/Core/SpatialObjects/test/itkCastSpatialObjectFilterTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkCastSpatialObjectFilterTest.cxx @@ -69,7 +69,7 @@ itkCastSpatialObjectFilterTest(int, char *[]) std::unique_ptr tList(caster->GetTubes()); - TubeType::Pointer tListTube = tList->begin()->GetPointer(); + const TubeType::Pointer tListTube = tList->begin()->GetPointer(); bool found = false; if (!strcmp(tListTube->GetTypeName().c_str(), "TubeSpatialObject")) diff --git a/Modules/Core/SpatialObjects/test/itkContourSpatialObjectPointTest.cxx b/Modules/Core/SpatialObjects/test/itkContourSpatialObjectPointTest.cxx index 8307a808cb6..a7bcbb1ac1b 100644 --- a/Modules/Core/SpatialObjects/test/itkContourSpatialObjectPointTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkContourSpatialObjectPointTest.cxx @@ -146,9 +146,9 @@ itkContourSpatialObjectPointTest(int, char *[]) pOriginal.SetPickedPointInObjectSpace(picked); // Copy - ContourSpatialObjectPoint3DType pCopy(pOriginal); + const ContourSpatialObjectPoint3DType pCopy(pOriginal); // Assign - ContourSpatialObjectPoint3DType pAssign = pOriginal; + const ContourSpatialObjectPoint3DType pAssign = pOriginal; std::vector pointVector; pointVector.push_back(pCopy); diff --git a/Modules/Core/SpatialObjects/test/itkContourSpatialObjectTest.cxx b/Modules/Core/SpatialObjects/test/itkContourSpatialObjectTest.cxx index 6acf2f8b2fc..038918569db 100644 --- a/Modules/Core/SpatialObjects/test/itkContourSpatialObjectTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkContourSpatialObjectTest.cxx @@ -295,7 +295,7 @@ itkContourSpatialObjectTest(int, char *[]) // Run PrintSelf for the sake of coverage (and to make sure no // segfault/exceptions arise) // - itk::Indent idt; + const itk::Indent idt; contour->Print(std::cout, idt); // Test streaming enumeration for ContourSpatialObjectEnum::InterpolationMethod elements diff --git a/Modules/Core/SpatialObjects/test/itkDTITubeSpatialObjectTest.cxx b/Modules/Core/SpatialObjects/test/itkDTITubeSpatialObjectTest.cxx index 4f634850994..400579a97e3 100644 --- a/Modules/Core/SpatialObjects/test/itkDTITubeSpatialObjectTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkDTITubeSpatialObjectTest.cxx @@ -50,7 +50,7 @@ itkDTITubeSpatialObjectTest(int, char *[]) std::cout << "==================================" << std::endl; std::cout << "Testing SpatialObject:" << std::endl << std::endl; - TubePointer tube1 = TubeType::New(); + const TubePointer tube1 = TubeType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(tube1, DTITubeSpatialObject, TubeSpatialObject); @@ -106,7 +106,7 @@ itkDTITubeSpatialObjectTest(int, char *[]) return EXIT_FAILURE; } - TubeType::CovariantVectorType expectedDerivative{}; + const TubeType::CovariantVectorType expectedDerivative{}; if (expectedDerivative != derivative) { @@ -139,19 +139,19 @@ itkDTITubeSpatialObjectTest(int, char *[]) ChildrenListPointer returnedList; unsigned int nbChildren; - TubePointer tube2 = TubeType::New(); + const TubePointer tube2 = TubeType::New(); tube2->GetProperty().SetName("Tube 2"); tube2->SetId(2); tube2->SetPoints(list); tube2->Update(); - TubePointer tube3 = TubeType::New(); + const TubePointer tube3 = TubeType::New(); tube3->GetProperty().SetName("Tube 3"); tube3->SetId(3); tube3->SetPoints(list); tube3->Update(); - GroupPointer tubeNet1 = GroupType::New(); + const GroupPointer tubeNet1 = GroupType::New(); tubeNet1->GetProperty().SetName("tube network 1"); @@ -356,8 +356,8 @@ itkDTITubeSpatialObjectTest(int, char *[]) std::cout << "==============================================" << std::endl; std::cout << "Testing references behavior for SpatialObject:" << std::endl << std::endl; - TubePointer tube = TubeType::New(); - GroupPointer net = GroupType::New(); + const TubePointer tube = TubeType::New(); + const GroupPointer net = GroupType::New(); unsigned int tubeCount = tube->GetReferenceCount(); @@ -371,7 +371,7 @@ itkDTITubeSpatialObjectTest(int, char *[]) } else { - TubePointer localTube = tube; + const TubePointer localTube = tube; tubeCount = tube->GetReferenceCount(); if (tubeCount != 2) { @@ -387,7 +387,7 @@ itkDTITubeSpatialObjectTest(int, char *[]) } else { - GroupPointer localNet = net; + const GroupPointer localNet = net; netCount = net->GetReferenceCount(); if (netCount != 2) { @@ -546,13 +546,13 @@ itkDTITubeSpatialObjectTest(int, char *[]) pOriginal.SetAlpha3(11.0); // itk::DTITubeSpatialObjectTest.cxx - itk::DiffusionTensor3D tensor{}; + const itk::DiffusionTensor3D tensor{}; pOriginal.SetTensorMatrix(tensor); // Copy - TubePointType pCopy(pOriginal); + const TubePointType pCopy(pOriginal); // Assign - TubePointType pAssign = pOriginal; + const TubePointType pAssign = pOriginal; std::vector pointVector; pointVector.push_back(pCopy); diff --git a/Modules/Core/SpatialObjects/test/itkEllipseSpatialObjectTest.cxx b/Modules/Core/SpatialObjects/test/itkEllipseSpatialObjectTest.cxx index 89ed45c2917..035e9a67662 100644 --- a/Modules/Core/SpatialObjects/test/itkEllipseSpatialObjectTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkEllipseSpatialObjectTest.cxx @@ -44,7 +44,7 @@ itkEllipseSpatialObjectTest(int, char *[]) ITK_TEST_SET_GET_VALUE(radii, myEllipse->GetRadiusInObjectSpace()); - EllipseType::ArrayType objectSpaceRadius(3); + const EllipseType::ArrayType objectSpaceRadius(3); myEllipse->SetRadiusInObjectSpace(objectSpaceRadius); myEllipse->Update(); diff --git a/Modules/Core/SpatialObjects/test/itkGaussianSpatialObjectTest.cxx b/Modules/Core/SpatialObjects/test/itkGaussianSpatialObjectTest.cxx index d06d25a1fd0..fb607b90a42 100644 --- a/Modules/Core/SpatialObjects/test/itkGaussianSpatialObjectTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkGaussianSpatialObjectTest.cxx @@ -29,19 +29,19 @@ itkGaussianSpatialObjectTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(myGaussian, GaussianSpatialObject, SpatialObject); - GaussianType::ScalarType maximum = 2; + const GaussianType::ScalarType maximum = 2; myGaussian->SetMaximum(maximum); ITK_TEST_SET_GET_VALUE(maximum, myGaussian->GetMaximum()); - GaussianType::ScalarType radius = 3; + const GaussianType::ScalarType radius = 3; myGaussian->SetRadiusInObjectSpace(radius); ITK_TEST_SET_GET_VALUE(radius, myGaussian->GetRadiusInObjectSpace()); - GaussianType::ScalarType sigma = 1.5; + const GaussianType::ScalarType sigma = 1.5; myGaussian->SetSigmaInObjectSpace(sigma); ITK_TEST_SET_GET_VALUE(sigma, myGaussian->GetSigmaInObjectSpace()); - GaussianType::PointType center{}; + const GaussianType::PointType center{}; myGaussian->SetCenterInObjectSpace(center); ITK_TEST_SET_GET_VALUE(center, myGaussian->GetCenterInObjectSpace()); diff --git a/Modules/Core/SpatialObjects/test/itkImageMaskSpatialObjectTest.cxx b/Modules/Core/SpatialObjects/test/itkImageMaskSpatialObjectTest.cxx index 35a7ab0990b..f82985329b3 100644 --- a/Modules/Core/SpatialObjects/test/itkImageMaskSpatialObjectTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkImageMaskSpatialObjectTest.cxx @@ -41,10 +41,10 @@ itkImageMaskSpatialObjectTest(int, char *[]) using ImageType = ImageMaskSpatialObject::ImageType; using Iterator = itk::ImageRegionIterator; - auto image = ImageType::New(); - ImageType::SizeType size = { { 50, 50, 50 } }; - ImageType::IndexType index = { { 0, 0, 0 } }; - ImageType::RegionType region; + auto image = ImageType::New(); + const ImageType::SizeType size = { { 50, 50, 50 } }; + const ImageType::IndexType index = { { 0, 0, 0 } }; + ImageType::RegionType region; region.SetSize(size); region.SetIndex(index); @@ -52,9 +52,9 @@ itkImageMaskSpatialObjectTest(int, char *[]) image->SetRegions(region); image->AllocateInitialized(); - ImageType::RegionType insideRegion; - ImageType::SizeType insideSize = { { 30, 30, 30 } }; - ImageType::IndexType insideIndex = { { 10, 10, 10 } }; + ImageType::RegionType insideRegion; + const ImageType::SizeType insideSize = { { 30, 30, 30 } }; + const ImageType::IndexType insideIndex = { { 10, 10, 10 } }; insideRegion.SetSize(insideSize); insideRegion.SetIndex(insideIndex); diff --git a/Modules/Core/SpatialObjects/test/itkImageMaskSpatialObjectTest2.cxx b/Modules/Core/SpatialObjects/test/itkImageMaskSpatialObjectTest2.cxx index 51aac5d9233..376d4936521 100644 --- a/Modules/Core/SpatialObjects/test/itkImageMaskSpatialObjectTest2.cxx +++ b/Modules/Core/SpatialObjects/test/itkImageMaskSpatialObjectTest2.cxx @@ -76,7 +76,7 @@ itkImageMaskSpatialObjectTest2(int, char *[]) constexpr unsigned int index_offset = 6543; const ImageType::IndexType index = { { index_offset, index_offset, index_offset } }; - ImageType::RegionType region{ index, size }; + const ImageType::RegionType region{ index, size }; image->SetRegions(region); image->AllocateInitialized(); @@ -176,8 +176,8 @@ itkImageMaskSpatialObjectTest2(int, char *[]) // Check if insideregion is properly computed at the image boundary { - ImageType::IndexType startPointIndex = { { INSIDE_SIZE - 2, INSIDE_SIZE - 2, INSIDE_SIZE - 2 } }; - ImageType::IndexType endPointIndex = { + const ImageType::IndexType startPointIndex = { { INSIDE_SIZE - 2, INSIDE_SIZE - 2, INSIDE_SIZE - 2 } }; + const ImageType::IndexType endPointIndex = { { INSIDE_INDEX + INSIDE_SIZE + 2, INSIDE_INDEX + INSIDE_SIZE + 2, INSIDE_INDEX + INSIDE_SIZE + 2 } }; ImageType::PointType startPoint; @@ -202,7 +202,7 @@ itkImageMaskSpatialObjectTest2(int, char *[]) const bool isZero = (itk::Math::ExactlyEquals(value, PixelType{})); if ((isInside && isZero) || (!isInside && !isZero)) { - ImageType::IndexType pointIndex = image->TransformPhysicalPointToIndex(point); + const ImageType::IndexType pointIndex = image->TransformPhysicalPointToIndex(point); std::cerr << "Error in the evaluation ValueAt and IsInside (all the points inside the mask shall have non-zero value) " << std::endl; diff --git a/Modules/Core/SpatialObjects/test/itkImageMaskSpatialObjectTest3.cxx b/Modules/Core/SpatialObjects/test/itkImageMaskSpatialObjectTest3.cxx index af4c720f14e..f220d310152 100644 --- a/Modules/Core/SpatialObjects/test/itkImageMaskSpatialObjectTest3.cxx +++ b/Modules/Core/SpatialObjects/test/itkImageMaskSpatialObjectTest3.cxx @@ -42,15 +42,15 @@ itkImageMaskSpatialObjectTest3(int, char *[]) using PixelType = ImageMaskSpatialObjectType::PixelType; using ImageType = itk::Image; - auto image = ImageType::New(); - ImageType::SizeType size = { { 5, 5, 5 } }; - ImageType::PointType origin{}; + auto image = ImageType::New(); + const ImageType::SizeType size = { { 5, 5, 5 } }; + const ImageType::PointType origin{}; image->SetOrigin(origin); auto spacing = itk::MakeFilled(1); image->SetSpacing(spacing); - ImageType::IndexType index{}; + const ImageType::IndexType index{}; ImageType::DirectionType direction{}; direction[0][1] = 1; @@ -69,10 +69,12 @@ itkImageMaskSpatialObjectTest3(int, char *[]) imageMaskSpatialObject->SetImage(image); imageMaskSpatialObject->Update(); - ImageMaskSpatialObjectType::PointType bndMin = imageMaskSpatialObject->GetMyBoundingBoxInWorldSpace()->GetMinimum(); + const ImageMaskSpatialObjectType::PointType bndMin = + imageMaskSpatialObject->GetMyBoundingBoxInWorldSpace()->GetMinimum(); ImageMaskSpatialObjectType::IndexType bndMinI = image->TransformPhysicalPointToIndex(bndMin); - ImageMaskSpatialObjectType::PointType bndMax = imageMaskSpatialObject->GetMyBoundingBoxInWorldSpace()->GetMaximum(); + const ImageMaskSpatialObjectType::PointType bndMax = + imageMaskSpatialObject->GetMyBoundingBoxInWorldSpace()->GetMaximum(); ImageMaskSpatialObjectType::IndexType bndMaxI = image->TransformPhysicalPointToIndex(bndMax); ImageMaskSpatialObjectType::RegionType::SizeType regionSize; diff --git a/Modules/Core/SpatialObjects/test/itkImageMaskSpatialObjectTest5.cxx b/Modules/Core/SpatialObjects/test/itkImageMaskSpatialObjectTest5.cxx index ad14b5dc740..4067c002872 100644 --- a/Modules/Core/SpatialObjects/test/itkImageMaskSpatialObjectTest5.cxx +++ b/Modules/Core/SpatialObjects/test/itkImageMaskSpatialObjectTest5.cxx @@ -41,10 +41,10 @@ itkImageMaskSpatialObjectTest5(int, char *[]) using ImageType = ImageMaskSpatialObject::ImageType; using Iterator = itk::ImageRegionIterator; - auto image = ImageType::New(); - ImageType::SizeType size = { { 50, 50, 50 } }; - ImageType::IndexType index = { { 0, 0, 0 } }; - ImageType::RegionType region; + auto image = ImageType::New(); + const ImageType::SizeType size = { { 50, 50, 50 } }; + const ImageType::IndexType index = { { 0, 0, 0 } }; + ImageType::RegionType region; region.SetSize(size); region.SetIndex(index); @@ -52,9 +52,9 @@ itkImageMaskSpatialObjectTest5(int, char *[]) image->SetRegions(region); image->AllocateInitialized(); - ImageType::RegionType insideRegion; - ImageType::SizeType insideSize = { { 30, 30, 30 } }; - ImageType::IndexType insideIndex = { { 10, 10, 10 } }; + ImageType::RegionType insideRegion; + const ImageType::SizeType insideSize = { { 30, 30, 30 } }; + const ImageType::IndexType insideIndex = { { 10, 10, 10 } }; insideRegion.SetSize(insideSize); insideRegion.SetIndex(insideIndex); diff --git a/Modules/Core/SpatialObjects/test/itkImageSpatialObjectTest.cxx b/Modules/Core/SpatialObjects/test/itkImageSpatialObjectTest.cxx index ba5a285fb82..cac4044c291 100644 --- a/Modules/Core/SpatialObjects/test/itkImageSpatialObjectTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkImageSpatialObjectTest.cxx @@ -44,11 +44,11 @@ itkImageSpatialObjectTest(int, char *[]) using Iterator = itk::ImageRegionIterator; using PointType = itk::Point; - auto image = ImageType::New(); - ImageType::SizeType size = { { 10, 10, 10 } }; - ImageType::IndexType index = { { 0, 0, 0 } }; - ImageType::RegionType region; - auto origin = itk::MakeFilled(5); + auto image = ImageType::New(); + const ImageType::SizeType size = { { 10, 10, 10 } }; + const ImageType::IndexType index = { { 0, 0, 0 } }; + ImageType::RegionType region; + auto origin = itk::MakeFilled(5); region.SetSize(size); region.SetIndex(index); @@ -70,7 +70,7 @@ itkImageSpatialObjectTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(imageSO, ImageSpatialObject, SpatialObject); - typename ImageSpatialObject::IndexType sliceNumber{}; + const typename ImageSpatialObject::IndexType sliceNumber{}; imageSO->SetSliceNumber(sliceNumber); ITK_TEST_SET_GET_VALUE(sliceNumber, imageSO->GetSliceNumber()); diff --git a/Modules/Core/SpatialObjects/test/itkLandmarkSpatialObjectTest.cxx b/Modules/Core/SpatialObjects/test/itkLandmarkSpatialObjectTest.cxx index 9454222e09e..aa638e0a99e 100644 --- a/Modules/Core/SpatialObjects/test/itkLandmarkSpatialObjectTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkLandmarkSpatialObjectTest.cxx @@ -51,7 +51,7 @@ itkLandmarkSpatialObjectTest(int, char *[]) } // Create a Landmark Spatial Object - LandmarkPointer landmark = LandmarkType::New(); + const LandmarkPointer landmark = LandmarkType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(landmark, LandmarkSpatialObject, PointBasedSpatialObject); diff --git a/Modules/Core/SpatialObjects/test/itkLineSpatialObjectTest.cxx b/Modules/Core/SpatialObjects/test/itkLineSpatialObjectTest.cxx index 6488846296f..e671390d02d 100644 --- a/Modules/Core/SpatialObjects/test/itkLineSpatialObjectTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkLineSpatialObjectTest.cxx @@ -55,7 +55,7 @@ itkLineSpatialObjectTest(int, char *[]) p.Print(std::cout); // Create a Line Spatial Object - LinePointer line = LineType::New(); + const LinePointer line = LineType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(line, LineSpatialObject, PointBasedSpatialObject); @@ -179,9 +179,9 @@ itkLineSpatialObjectTest(int, char *[]) pOriginal.SetNormalInObjectSpace(normal, 0); // Copy - LinePointType pCopy(pOriginal); + const LinePointType pCopy(pOriginal); // Assign - LinePointType pAssign = pOriginal; + const LinePointType pAssign = pOriginal; std::vector pointVector; pointVector.push_back(pCopy); diff --git a/Modules/Core/SpatialObjects/test/itkMeshSpatialObjectTest.cxx b/Modules/Core/SpatialObjects/test/itkMeshSpatialObjectTest.cxx index c6fbb822462..5cf9425272a 100644 --- a/Modules/Core/SpatialObjects/test/itkMeshSpatialObjectTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkMeshSpatialObjectTest.cxx @@ -38,7 +38,7 @@ itkMeshSpatialObjectTest(int, char *[]) // Create an itkMesh auto mesh = MeshType::New(); - MeshType::CoordinateType testPointCoords[4][3] = { { 0, 0, 0 }, { 9, 0, 0 }, { 9, 9, 0 }, { 0, 0, 9 } }; + const MeshType::CoordinateType testPointCoords[4][3] = { { 0, 0, 0 }, { 9, 0, 0 }, { 9, 9, 0 }, { 0, 0, 9 } }; MeshType::PointIdentifier tetraPoints[4] = { 0, 1, 2, 3 }; @@ -60,7 +60,7 @@ itkMeshSpatialObjectTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(meshSO, MeshSpatialObject, SpatialObject); - double isInsidePrecisionInObjectSpace = 1; + const double isInsidePrecisionInObjectSpace = 1; meshSO->SetIsInsidePrecisionInObjectSpace(isInsidePrecisionInObjectSpace); ITK_TEST_SET_GET_VALUE(isInsidePrecisionInObjectSpace, meshSO->GetIsInsidePrecisionInObjectSpace()); @@ -140,7 +140,7 @@ itkMeshSpatialObjectTest(int, char *[]) // Create an itkMesh auto meshTriangle = MeshType::New(); - MeshType::CoordinateType testTrianglePointCoords[4][3] = { + const MeshType::CoordinateType testTrianglePointCoords[4][3] = { { 50, 50, 64 }, { 50, 100, 64 }, { 100, 50, 64 }, { 100, 100, 64 } }; diff --git a/Modules/Core/SpatialObjects/test/itkMetaArrowConverterTest.cxx b/Modules/Core/SpatialObjects/test/itkMetaArrowConverterTest.cxx index b397d13d988..ed2213464be 100644 --- a/Modules/Core/SpatialObjects/test/itkMetaArrowConverterTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkMetaArrowConverterTest.cxx @@ -94,7 +94,7 @@ itkMetaArrowConverterTest(int argc, char * argv[]) mPosition[2] = -3; // length - double length = 2.3; + const double length = 2.3; // color float color[4]; @@ -129,7 +129,7 @@ itkMetaArrowConverterTest(int argc, char * argv[]) metaArrow->ParentID(itkParent->GetId()); // precision limit for comparing floats and doubles - double precisionLimit = .000001; + const double precisionLimit = .000001; // // test itk to metaArrow @@ -141,7 +141,7 @@ itkMetaArrowConverterTest(int argc, char * argv[]) } // check length - double metaLength = newMetaArrow->Length(); + const double metaLength = newMetaArrow->Length(); // if (metaLength != static_cast(length)) if (itk::Math::abs(metaLength - length) > precisionLimit) @@ -215,7 +215,7 @@ itkMetaArrowConverterTest(int argc, char * argv[]) // // test metaArrow to itk // - SpatialObjectType::Pointer newItkArrow = + const SpatialObjectType::Pointer newItkArrow = dynamic_cast(converter->MetaObjectToSpatialObject(metaArrow).GetPointer()); newItkArrow->Update(); @@ -301,7 +301,8 @@ itkMetaArrowConverterTest(int argc, char * argv[]) // // test reading // - SpatialObjectType::Pointer reLoad = dynamic_cast(converter->ReadMeta(argv[1]).GetPointer()); + const SpatialObjectType::Pointer reLoad = + dynamic_cast(converter->ReadMeta(argv[1]).GetPointer()); // check length if (itk::Math::abs(reLoad->GetLengthInWorldSpace() - length) > precisionLimit) diff --git a/Modules/Core/SpatialObjects/test/itkMetaGaussianConverterTest.cxx b/Modules/Core/SpatialObjects/test/itkMetaGaussianConverterTest.cxx index c995fd68e8b..5f8a7c899c5 100644 --- a/Modules/Core/SpatialObjects/test/itkMetaGaussianConverterTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkMetaGaussianConverterTest.cxx @@ -67,9 +67,9 @@ itkMetaGaussianConverterTest(int argc, char * argv[]) auto GaussianSpatialObj = SpatialObjectType::New(); // Gaussian spatial object properties - SpatialObjectType::ScalarType maximum = 2; - SpatialObjectType::ScalarType radius = 3; - SpatialObjectType::ScalarType sigma = 1.5; + const SpatialObjectType::ScalarType maximum = 2; + const SpatialObjectType::ScalarType radius = 3; + const SpatialObjectType::ScalarType sigma = 1.5; GaussianSpatialObj->SetMaximum(maximum); GaussianSpatialObj->SetRadiusInObjectSpace(radius); @@ -100,7 +100,7 @@ itkMetaGaussianConverterTest(int argc, char * argv[]) metaGaussian->ParentID(parentSpatialObj->GetId()); // Precision limit for comparing floats and doubles - double precisionLimit = .000001; + const double precisionLimit = .000001; // // Test GaussianSpatialObject to MetaGaussian @@ -112,7 +112,7 @@ itkMetaGaussianConverterTest(int argc, char * argv[]) } // Check maximum - double metaMaximum = newMetaGaussian->Maximum(); + const double metaMaximum = newMetaGaussian->Maximum(); // if (metaMaximum != static_cast(maximum)) if (itk::Math::abs(metaMaximum - maximum) > precisionLimit) @@ -123,7 +123,7 @@ itkMetaGaussianConverterTest(int argc, char * argv[]) std::cout << "[PASSED] SpatialObject -> MetaObject: maximum: " << metaMaximum << std::endl; // Check radius - double metaRadius = newMetaGaussian->Radius(); + const double metaRadius = newMetaGaussian->Radius(); // if (metaRadius != static_cast(radius)) if (itk::Math::abs(metaRadius - radius) > precisionLimit) @@ -134,7 +134,7 @@ itkMetaGaussianConverterTest(int argc, char * argv[]) std::cout << "[PASSED] SpatialObject -> MetaObject: radius: " << metaRadius << std::endl; // Check sigma - double metaSigma = newMetaGaussian->Sigma(); + const double metaSigma = newMetaGaussian->Sigma(); // if (metaSigma != static_cast(sigma)) if (itk::Math::abs(metaSigma - sigma) > precisionLimit) @@ -176,7 +176,7 @@ itkMetaGaussianConverterTest(int argc, char * argv[]) // // Test MetaGaussian to GaussianSpatialObject // - SpatialObjectType::Pointer newGaussianSpatialObj = + const SpatialObjectType::Pointer newGaussianSpatialObj = dynamic_cast(converter->MetaObjectToSpatialObject(metaGaussian).GetPointer()); @@ -250,7 +250,8 @@ itkMetaGaussianConverterTest(int argc, char * argv[]) // // Test reading // - SpatialObjectType::Pointer reLoad = dynamic_cast(converter->ReadMeta(argv[1]).GetPointer()); + const SpatialObjectType::Pointer reLoad = + dynamic_cast(converter->ReadMeta(argv[1]).GetPointer()); // Check maximum if (itk::Math::abs(reLoad->GetMaximum() - maximum) > precisionLimit) diff --git a/Modules/Core/SpatialObjects/test/itkNewMetaObjectTypeTest.cxx b/Modules/Core/SpatialObjects/test/itkNewMetaObjectTypeTest.cxx index e83bbe6b53e..b999f770e6d 100644 --- a/Modules/Core/SpatialObjects/test/itkNewMetaObjectTypeTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkNewMetaObjectTypeTest.cxx @@ -167,7 +167,7 @@ class MetaDummyConverter : public MetaConverterBase { itkExceptionMacro("Can't convert MetaObject to MetaDummy"); } - DummySpatialObjectPointer dummySO = DummySpatialObjectType::New(); + const DummySpatialObjectPointer dummySO = DummySpatialObjectType::New(); dummySO->SetValue(dummyMO->GetValue()); dummySO->GetProperty().SetName(dummyMO->Name()); @@ -185,7 +185,7 @@ class MetaDummyConverter : public MetaConverterBase MetaObjectType * SpatialObjectToMetaObject(const SpatialObjectType * spatialObject) override { - DummySpatialObjectConstPointer dummySO = dynamic_cast(spatialObject); + const DummySpatialObjectConstPointer dummySO = dynamic_cast(spatialObject); if (dummySO.IsNull()) { itkExceptionMacro("Can't downcast SpatialObject to DummySpatialObject"); @@ -228,16 +228,16 @@ itkNewMetaObjectTypeTest(int, char *[]) using DummyConverterType = itk::MetaDummyConverter<3>; - GroupType::Pointer group(GroupType::New()); + const GroupType::Pointer group(GroupType::New()); - DummyType::Pointer dummy(DummyType::New()); + const DummyType::Pointer dummy(DummyType::New()); dummy->GetProperty().SetName("Dummy"); dummy->SetId(1); dummy->SetValue(Pi); group->AddChild(dummy); - DummyConverterType::Pointer dummyConverter(DummyConverterType::New()); + const DummyConverterType::Pointer dummyConverter(DummyConverterType::New()); auto converter = MetaSceneConverterType::New(); @@ -247,7 +247,7 @@ itkNewMetaObjectTypeTest(int, char *[]) auto binaryPoints = false; ITK_TEST_SET_GET_BOOLEAN(converter, BinaryPoints, binaryPoints); - unsigned int transformPrecision = 6; + const unsigned int transformPrecision = 6; converter->SetTransformPrecision(transformPrecision); ITK_TEST_SET_GET_VALUE(transformPrecision, converter->GetTransformPrecision()); @@ -258,7 +258,7 @@ itkNewMetaObjectTypeTest(int, char *[]) MetaScene * metaScene = converter->CreateMetaScene(group); - SpatialObjectType::Pointer myScene = converter->CreateSpatialObjectScene(metaScene); + const SpatialObjectType::Pointer myScene = converter->CreateSpatialObjectScene(metaScene); if (!myScene) @@ -281,7 +281,7 @@ itkNewMetaObjectTypeTest(int, char *[]) for (obj = mySceneChildren->begin(); obj != mySceneChildren->end(); ++obj) { - std::string childType((*obj)->GetTypeName()); + const std::string childType((*obj)->GetTypeName()); if (childType != "DummySpatialObject") { std::cout << "Expected child type Dummy but found " << childType << " [FAILED]" << std::endl; @@ -289,7 +289,7 @@ itkNewMetaObjectTypeTest(int, char *[]) delete mySceneChildren; return EXIT_FAILURE; } - DummyType::Pointer p = dynamic_cast(obj->GetPointer()); + const DummyType::Pointer p = dynamic_cast(obj->GetPointer()); if (p.IsNull()) { std::cout << "Unable to downcast child SpatialObject to DummySpatialObject" @@ -298,7 +298,7 @@ itkNewMetaObjectTypeTest(int, char *[]) delete mySceneChildren; return EXIT_FAILURE; } - float value = p->GetValue(); + const float value = p->GetValue(); if (itk::Math::abs(value - Pi) > 0.00001) { std::cout << "Expected value " << Pi << "but found " << value << std::endl; diff --git a/Modules/Core/SpatialObjects/test/itkPolygonSpatialObjectIsInsideInObjectSpaceTest.cxx b/Modules/Core/SpatialObjects/test/itkPolygonSpatialObjectIsInsideInObjectSpaceTest.cxx index 70ed050af83..b91b7ad74cf 100644 --- a/Modules/Core/SpatialObjects/test/itkPolygonSpatialObjectIsInsideInObjectSpaceTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkPolygonSpatialObjectIsInsideInObjectSpaceTest.cxx @@ -77,8 +77,8 @@ itkPolygonSpatialObjectIsInsideInObjectSpaceTest(int argc, char * argv[]) { std::stringstream ss(data); - PolygonPointType polygonPt; - itk::SpatialObject::Pointer so = itk::SpatialObject::New(); + PolygonPointType polygonPt; + const itk::SpatialObject::Pointer so = itk::SpatialObject::New(); polygonPt.SetSpatialObject(so); PointType pt; diff --git a/Modules/Core/SpatialObjects/test/itkPolygonSpatialObjectTest.cxx b/Modules/Core/SpatialObjects/test/itkPolygonSpatialObjectTest.cxx index 390ddd96753..3651cf85dd7 100644 --- a/Modules/Core/SpatialObjects/test/itkPolygonSpatialObjectTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkPolygonSpatialObjectTest.cxx @@ -33,14 +33,14 @@ itkPolygonSpatialObjectTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(rectangle, PolygonSpatialObject, PointBasedSpatialObject); - double d1[3] = { 0.0, 0.0, 0.0 }; - PolygonType::PointType p1(d1); - double d2[3] = { 2.0, 0.0, 0.0 }; - PolygonType::PointType p2(d2); - double d3[3] = { 2.0, 1.0, 0.0 }; - PolygonType::PointType p3(d3); - double d4[3] = { 0.0, 1.0, 0.0 }; - PolygonType::PointType p4(d4); + const double d1[3] = { 0.0, 0.0, 0.0 }; + const PolygonType::PointType p1(d1); + const double d2[3] = { 2.0, 0.0, 0.0 }; + const PolygonType::PointType p2(d2); + const double d3[3] = { 2.0, 1.0, 0.0 }; + const PolygonType::PointType p3(d3); + const double d4[3] = { 0.0, 1.0, 0.0 }; + const PolygonType::PointType p4(d4); PolygonType::PolygonPointListType pList; PolygonType::PolygonPointType pPoint; @@ -55,11 +55,11 @@ itkPolygonSpatialObjectTest(int, char *[]) pList.push_back(pPoint); rectangle->SetPoints(pList); - double objectSpaceThickness = 10; + const double objectSpaceThickness = 10; rectangle->SetThicknessInObjectSpace(objectSpaceThickness); ITK_TEST_SET_GET_VALUE(objectSpaceThickness, rectangle->GetThicknessInObjectSpace()); - bool isClosed = true; + const bool isClosed = true; rectangle->SetIsClosed(isClosed); ITK_TEST_SET_GET_BOOLEAN(rectangle, IsClosed, isClosed); @@ -131,8 +131,8 @@ itkPolygonSpatialObjectTest(int, char *[]) // // test number of points std::cout << "Testing closest point for rectangle: "; - double tp1[3] = { 0.25, 0.0, 0.0 }; - PolygonType::PointType testPoint1(tp1); + const double tp1[3] = { 0.25, 0.0, 0.0 }; + const PolygonType::PointType testPoint1(tp1); const PolygonType::PolygonPointType closestPoint = rectangle->ClosestPointInWorldSpace(testPoint1); if (closestPoint.GetPositionInObjectSpace() != p1) { @@ -148,8 +148,8 @@ itkPolygonSpatialObjectTest(int, char *[]) // // test number of points std::cout << "Testing closest point for rectangle (2): "; - double tp2[3] = { 0.25, 5.0, 5.0 }; - PolygonType::PointType testPoint2(tp2); + const double tp2[3] = { 0.25, 5.0, 5.0 }; + const PolygonType::PointType testPoint2(tp2); const PolygonType::PolygonPointType closestPoint2 = rectangle->ClosestPointInWorldSpace(testPoint2); if (closestPoint2.GetPositionInObjectSpace() != p4) { diff --git a/Modules/Core/SpatialObjects/test/itkSpatialObjectDuplicatorTest.cxx b/Modules/Core/SpatialObjects/test/itkSpatialObjectDuplicatorTest.cxx index 7b088e3ee4d..9790658c722 100644 --- a/Modules/Core/SpatialObjects/test/itkSpatialObjectDuplicatorTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkSpatialObjectDuplicatorTest.cxx @@ -51,7 +51,7 @@ itkSpatialObjectDuplicatorTest(int, char *[]) std::cout << "ModifiedOutput: " << duplicator->GetModifiedOutput() << std::endl; #endif - EllipseType::Pointer ellipse_copy = duplicator->GetOutput(); + const EllipseType::Pointer ellipse_copy = duplicator->GetOutput(); std::cout << ellipse_copy->GetRadiusInObjectSpace() << std::endl; std::cout << ellipse_copy->GetProperty().GetColor() << std::endl; @@ -65,11 +65,11 @@ itkSpatialObjectDuplicatorTest(int, char *[]) auto duplicatorGroup = DuplicatorGroupType::New(); duplicatorGroup->SetInput(group); duplicatorGroup->Update(); - GroupType::Pointer groupCopy = duplicatorGroup->GetOutput(); + const GroupType::Pointer groupCopy = duplicatorGroup->GetOutput(); GroupType::ChildrenListType * children = groupCopy->GetChildren(); - EllipseType::Pointer ellipse_copy2 = static_cast((*(children->begin())).GetPointer()); + const EllipseType::Pointer ellipse_copy2 = static_cast((*(children->begin())).GetPointer()); std::cout << ellipse_copy2->GetRadiusInObjectSpace() << std::endl; delete children; @@ -118,7 +118,7 @@ itkSpatialObjectDuplicatorTest(int, char *[]) auto duplicatorDti = DuplicatorDTIType::New(); duplicatorDti->SetInput(dtiTube); duplicatorDti->Update(); - DTITubeType::Pointer dtiTube_copy = duplicatorDti->GetOutput(); + const DTITubeType::Pointer dtiTube_copy = duplicatorDti->GetOutput(); // Testing DTITubeSO std::cout << "Testing DTITubeSpatialObject: "; diff --git a/Modules/Core/SpatialObjects/test/itkSpatialObjectToImageFilterTest.cxx b/Modules/Core/SpatialObjects/test/itkSpatialObjectToImageFilterTest.cxx index 7dee28db8f5..9d88896fda7 100644 --- a/Modules/Core/SpatialObjects/test/itkSpatialObjectToImageFilterTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkSpatialObjectToImageFilterTest.cxx @@ -56,15 +56,15 @@ itkSpatialObjectToImageFilterTest(int, char *[]) imageFilter->SetInput(ellipse); - SpatialObjectToImageFilterType::ValueType insideValue = 2; + const SpatialObjectToImageFilterType::ValueType insideValue = 2; imageFilter->SetInsideValue(insideValue); ITK_TEST_SET_GET_VALUE(insideValue, imageFilter->GetInsideValue()); - SpatialObjectToImageFilterType::ValueType outsideValue = 0; + const SpatialObjectToImageFilterType::ValueType outsideValue = 0; imageFilter->SetOutsideValue(0); ITK_TEST_SET_GET_VALUE(outsideValue, imageFilter->GetOutsideValue()); - unsigned int childrenDepth = 1; + const unsigned int childrenDepth = 1; imageFilter->SetChildrenDepth(childrenDepth); ITK_TEST_SET_GET_VALUE(childrenDepth, imageFilter->GetChildrenDepth()); @@ -167,7 +167,7 @@ itkSpatialObjectToImageFilterTest(int, char *[]) // Update the filter imageFilter->Update(); - ImageType::Pointer image = imageFilter->GetOutput(); + const ImageType::Pointer image = imageFilter->GetOutput(); std::cout << "Testing Output Image: "; @@ -191,7 +191,7 @@ itkSpatialObjectToImageFilterTest(int, char *[]) std::cout << "[PASSED]" << std::endl; // Test the UseObjectValue - bool useObjectValue = true; + const bool useObjectValue = true; imageFilter->SetUseObjectValue(useObjectValue); ITK_TEST_SET_GET_BOOLEAN(imageFilter, UseObjectValue, useObjectValue); diff --git a/Modules/Core/SpatialObjects/test/itkSpatialObjectToImageStatisticsCalculatorTest.cxx b/Modules/Core/SpatialObjects/test/itkSpatialObjectToImageStatisticsCalculatorTest.cxx index 6396c76e384..b6b0fd9d42f 100644 --- a/Modules/Core/SpatialObjects/test/itkSpatialObjectToImageStatisticsCalculatorTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkSpatialObjectToImageStatisticsCalculatorTest.cxx @@ -53,7 +53,7 @@ itkSpatialObjectToImageStatisticsCalculatorTest(int, char *[]) filter->SetInsideValue(255); filter->Update(); - ImageType::Pointer image = filter->GetOutput(); + const ImageType::Pointer image = filter->GetOutput(); offset.Fill(25); ellipse->GetModifiableObjectToParentTransform()->SetOffset(offset); @@ -68,7 +68,7 @@ itkSpatialObjectToImageStatisticsCalculatorTest(int, char *[]) calculator->SetImage(image); calculator->SetSpatialObject(ellipse); - unsigned int sampleDirection = CalculatorType::SampleDimension - 1; + const unsigned int sampleDirection = CalculatorType::SampleDimension - 1; calculator->SetSampleDirection(sampleDirection); ITK_TEST_SET_GET_VALUE(sampleDirection, calculator->GetSampleDirection()); @@ -139,8 +139,8 @@ itkSpatialObjectToImageStatisticsCalculatorTest(int, char *[]) size3D[0] = 50; size3D[1] = 50; size3D[2] = 3; - IndexType start{}; - RegionType region3D; + const IndexType start{}; + RegionType region3D; region3D.SetIndex(start); region3D.SetSize(size3D); image3D->SetRegions(region3D); diff --git a/Modules/Core/SpatialObjects/test/itkSpatialObjectToPointSetFilterTest.cxx b/Modules/Core/SpatialObjects/test/itkSpatialObjectToPointSetFilterTest.cxx index bfdc33a5742..037fba213e5 100644 --- a/Modules/Core/SpatialObjects/test/itkSpatialObjectToPointSetFilterTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkSpatialObjectToPointSetFilterTest.cxx @@ -34,7 +34,7 @@ itkSpatialObjectToPointSetFilterTest(int, char *[]) using TubePointListType = TubeType::TubePointListType; using TubePointType = TubeType::TubePointType; - TubePointer tube1 = TubeType::New(); + const TubePointer tube1 = TubeType::New(); TubePointListType list; for (unsigned int i = 0; i < 10; ++i) @@ -58,7 +58,7 @@ itkSpatialObjectToPointSetFilterTest(int, char *[]) pointSetFilter->SetChildrenDepth(childrenDepth); ITK_TEST_SET_GET_VALUE(childrenDepth, pointSetFilter->GetChildrenDepth()); - unsigned int samplingFactor = 1; + const unsigned int samplingFactor = 1; pointSetFilter->SetSamplingFactor(samplingFactor); ITK_TEST_SET_GET_VALUE(samplingFactor, pointSetFilter->GetSamplingFactor()); @@ -67,7 +67,7 @@ itkSpatialObjectToPointSetFilterTest(int, char *[]) pointSetFilter->Update(); - PointSetType::Pointer pointSet = pointSetFilter->GetOutput(); + const PointSetType::Pointer pointSet = pointSetFilter->GetOutput(); std::cout << "Testing pointSet exists : "; if (!pointSet.GetPointer()) @@ -89,8 +89,8 @@ itkSpatialObjectToPointSetFilterTest(int, char *[]) std::cout << "Testing pointSet validity : "; using PointIterator = PointSetType::PointsContainer::ConstIterator; - PointIterator pointItr = pointSet->GetPoints()->Begin(); - PointIterator pointEnd = pointSet->GetPoints()->End(); + PointIterator pointItr = pointSet->GetPoints()->Begin(); + const PointIterator pointEnd = pointSet->GetPoints()->End(); unsigned int val = 0; while (pointItr != pointEnd) @@ -157,7 +157,7 @@ itkSpatialObjectToPointSetFilterTest(int, char *[]) pointSetFilter3D->Update(); - PointSet3DType::Pointer pointSet3D = pointSetFilter3D->GetOutput(); + const PointSet3DType::Pointer pointSet3D = pointSetFilter3D->GetOutput(); std::cout << "Testing pointSet3D exists : "; if (!pointSet3D.GetPointer()) @@ -178,8 +178,8 @@ itkSpatialObjectToPointSetFilterTest(int, char *[]) std::cout << "Testing pointSet3D validity : "; using PointIterator3D = PointSet3DType::PointsContainer::ConstIterator; - PointIterator3D pointItr2 = pointSet3D->GetPoints()->Begin(); - PointIterator3D pointEnd2 = pointSet3D->GetPoints()->End(); + PointIterator3D pointItr2 = pointSet3D->GetPoints()->Begin(); + const PointIterator3D pointEnd2 = pointSet3D->GetPoints()->End(); val = 0; while (pointItr2 != pointEnd2) diff --git a/Modules/Core/SpatialObjects/test/itkSurfaceSpatialObjectTest.cxx b/Modules/Core/SpatialObjects/test/itkSurfaceSpatialObjectTest.cxx index dfe4977ba04..0ff84bf1cd4 100644 --- a/Modules/Core/SpatialObjects/test/itkSurfaceSpatialObjectTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkSurfaceSpatialObjectTest.cxx @@ -53,7 +53,7 @@ itkSurfaceSpatialObjectTest(int, char *[]) p.Print(std::cout); // Create a Surface Spatial Object - SurfacePointer Surface = SurfaceType::New(); + const SurfacePointer Surface = SurfaceType::New(); Surface->GetProperty().SetName("Surface 1"); Surface->SetId(1); Surface->SetPoints(list); @@ -193,9 +193,9 @@ itkSurfaceSpatialObjectTest(int, char *[]) } // Copy - SurfacePointType pCopy(pOriginal); + const SurfacePointType pCopy(pOriginal); // Assign - SurfacePointType pAssign = pOriginal; + const SurfacePointType pAssign = pOriginal; std::vector pointVector; pointVector.push_back(pCopy); diff --git a/Modules/Core/SpatialObjects/test/itkTubeSpatialObjectTest.cxx b/Modules/Core/SpatialObjects/test/itkTubeSpatialObjectTest.cxx index 4aee714db12..1239dc360c2 100644 --- a/Modules/Core/SpatialObjects/test/itkTubeSpatialObjectTest.cxx +++ b/Modules/Core/SpatialObjects/test/itkTubeSpatialObjectTest.cxx @@ -50,7 +50,7 @@ itkTubeSpatialObjectTest(int, char *[]) std::cout << "==================================" << std::endl; std::cout << "Testing SpatialObject:" << std::endl << std::endl; - TubePointer tube1 = TubeType::New(); + const TubePointer tube1 = TubeType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(tube1, TubeSpatialObject, PointBasedSpatialObject); @@ -117,7 +117,7 @@ itkTubeSpatialObjectTest(int, char *[]) return EXIT_FAILURE; } - TubeType::CovariantVectorType expectedDerivative{}; + const TubeType::CovariantVectorType expectedDerivative{}; if (expectedDerivative != derivative) { @@ -150,19 +150,19 @@ itkTubeSpatialObjectTest(int, char *[]) ChildrenListPointer returnedList; unsigned int nbChildren; - TubePointer tube2 = TubeType::New(); + const TubePointer tube2 = TubeType::New(); tube2->GetProperty().SetName("Tube 2"); tube2->SetId(2); tube2->SetPoints(list); tube2->Update(); - TubePointer tube3 = TubeType::New(); + const TubePointer tube3 = TubeType::New(); tube3->GetProperty().SetName("Tube 3"); tube3->SetId(3); tube3->SetPoints(list); tube3->Update(); - GroupPointer tubeNet1 = GroupType::New(); + const GroupPointer tubeNet1 = GroupType::New(); tubeNet1->GetProperty().SetName("tube network 1"); @@ -366,8 +366,8 @@ itkTubeSpatialObjectTest(int, char *[]) std::cout << "==============================================" << std::endl; std::cout << "Testing references behavior for SpatialObject:" << std::endl << std::endl; - TubePointer tube = TubeType::New(); - GroupPointer net = GroupType::New(); + const TubePointer tube = TubeType::New(); + const GroupPointer net = GroupType::New(); unsigned int tubeCount = tube->GetReferenceCount(); unsigned int netCount = net->GetReferenceCount(); @@ -380,7 +380,7 @@ itkTubeSpatialObjectTest(int, char *[]) } else { - TubePointer localTube = tube; + const TubePointer localTube = tube; tubeCount = tube->GetReferenceCount(); if (tubeCount != 2) { @@ -396,7 +396,7 @@ itkTubeSpatialObjectTest(int, char *[]) } else { - GroupPointer localNet = net; + const GroupPointer localNet = net; netCount = net->GetReferenceCount(); if (netCount != 2) { @@ -557,9 +557,9 @@ itkTubeSpatialObjectTest(int, char *[]) pOriginal.SetAlpha3(11.0); // Copy - TubePointType pCopy(pOriginal); + const TubePointType pCopy(pOriginal); // Assign - TubePointType pAssign = pOriginal; + const TubePointType pAssign = pOriginal; std::vector pointVector; pointVector.push_back(pCopy); diff --git a/Modules/Core/TestKernel/include/itkPipelineMonitorImageFilter.hxx b/Modules/Core/TestKernel/include/itkPipelineMonitorImageFilter.hxx index db299589f77..f026e61e1ba 100644 --- a/Modules/Core/TestKernel/include/itkPipelineMonitorImageFilter.hxx +++ b/Modules/Core/TestKernel/include/itkPipelineMonitorImageFilter.hxx @@ -75,7 +75,7 @@ template bool PipelineMonitorImageFilter::VerifyInputFilterMatchedUpdateOutputInformation() { - InputImageConstPointer input = this->GetInput(); + const InputImageConstPointer input = this->GetInput(); if (input->GetSpacing() != m_UpdatedOutputSpacing) { itkWarningMacro("The input filter's Spacing does not match UpdateOutputInformation"); @@ -221,7 +221,7 @@ PipelineMonitorImageFilter::GenerateOutputInformation() Superclass::GenerateOutputInformation(); - InputImageConstPointer input = this->GetInput(); + const InputImageConstPointer input = this->GetInput(); m_UpdatedOutputOrigin = input->GetOrigin(); m_UpdatedOutputDirection = input->GetDirection(); m_UpdatedOutputSpacing = input->GetSpacing(); @@ -273,8 +273,8 @@ void PipelineMonitorImageFilter::GenerateData() { // Get pointers to the input and output - InputImagePointer output = this->GetOutput(); - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer output = this->GetOutput(); + const InputImagePointer input = const_cast(this->GetInput()); // Graft the input Onto the output, so that we run "in-place" this->GraftOutput(input); diff --git a/Modules/Core/TestKernel/include/itkRandomImageSource.hxx b/Modules/Core/TestKernel/include/itkRandomImageSource.hxx index a7e2a79bece..1c73b9c9315 100644 --- a/Modules/Core/TestKernel/include/itkRandomImageSource.hxx +++ b/Modules/Core/TestKernel/include/itkRandomImageSource.hxx @@ -216,7 +216,7 @@ RandomImageSource::DynamicThreadedGenerateData(const OutputImageRe using scalarType = typename TOutputImage::PixelType; - typename TOutputImage::Pointer image = this->GetOutput(0); + const typename TOutputImage::Pointer image = this->GetOutput(0); TotalProgressReporter progress(this, image->GetRequestedRegion().GetNumberOfPixels()); diff --git a/Modules/Core/TestKernel/include/itkTestDriverAfterTest.inc b/Modules/Core/TestKernel/include/itkTestDriverAfterTest.inc index 4bdc7d4396a..65bef9a5421 100644 --- a/Modules/Core/TestKernel/include/itkTestDriverAfterTest.inc +++ b/Modules/Core/TestKernel/include/itkTestDriverAfterTest.inc @@ -28,7 +28,7 @@ if (redirectOutputParameters.redirect) redirectStream.close(); } -std::vector< HashPairType >& hashTestList = GetHashTestList(); +std::vector< HashPairType > const& hashTestList = GetHashTestList(); // before the image to image compare we first check md5 hashes for(auto & li : hashTestList) diff --git a/Modules/Core/TestKernel/include/itkTestDriverBeforeTest.inc b/Modules/Core/TestKernel/include/itkTestDriverBeforeTest.inc index 1d36814fc78..721cd31872c 100644 --- a/Modules/Core/TestKernel/include/itkTestDriverBeforeTest.inc +++ b/Modules/Core/TestKernel/include/itkTestDriverBeforeTest.inc @@ -25,7 +25,7 @@ std::ofstream redirectStream; std::streambuf *redirectBuf; std::streambuf *oldCoutBuf = nullptr; - RedirectOutputParameters& redirectOutputParameters = GetRedirectOutputParameters(); + RedirectOutputParameters const& redirectOutputParameters = GetRedirectOutputParameters(); if (redirectOutputParameters.redirect) { std::cout << "Test output has been redirected to: " << redirectOutputParameters.fileName << std::endl; diff --git a/Modules/Core/TestKernel/include/itkTestingComparisonImageFilter.hxx b/Modules/Core/TestKernel/include/itkTestingComparisonImageFilter.hxx index 0b2c7d890b2..beba23bcc16 100644 --- a/Modules/Core/TestKernel/include/itkTestingComparisonImageFilter.hxx +++ b/Modules/Core/TestKernel/include/itkTestingComparisonImageFilter.hxx @@ -142,24 +142,24 @@ ComparisonImageFilter::DynamicThreadedGenerateData( for (valid.GoToBegin(), test.GoToBegin(), out.GoToBegin(); !valid.IsAtEnd(); ++valid, ++test, ++out) { // Get the current valid pixel. - InputPixelType t = valid.Get(); + const InputPixelType t = valid.Get(); // Assume a good match - so test center pixel first, for speed - RealType difference = std::abs(static_cast(t) - test.GetCenterPixel()); - auto minimumDifference = static_cast(difference); + const RealType difference = std::abs(static_cast(t) - test.GetCenterPixel()); + auto minimumDifference = static_cast(difference); // If center pixel isn't good enough, then test the neighborhood if (minimumDifference > m_DifferenceThreshold) { - unsigned int neighborhoodSize = test.Size(); + const unsigned int neighborhoodSize = test.Size(); // Find the closest-valued pixel in the neighborhood of the test // image. for (unsigned int i = 0; i < neighborhoodSize; ++i) { // Use the RealType for the difference to make sure we get the // sign. - RealType differenceReal = std::abs(static_cast(t) - test.GetPixel(i)); - auto d = static_cast(differenceReal); + const RealType differenceReal = std::abs(static_cast(t) - test.GetPixel(i)); + auto d = static_cast(differenceReal); if (d < minimumDifference) { minimumDifference = d; diff --git a/Modules/Core/TestKernel/include/itkTestingExtractSliceImageFilter.hxx b/Modules/Core/TestKernel/include/itkTestingExtractSliceImageFilter.hxx index 1a8a33a060f..9e4f6daf869 100644 --- a/Modules/Core/TestKernel/include/itkTestingExtractSliceImageFilter.hxx +++ b/Modules/Core/TestKernel/include/itkTestingExtractSliceImageFilter.hxx @@ -53,7 +53,7 @@ ExtractSliceImageFilter::CallCopyOutputRegionToInputR InputImageRegionType & destRegion, const OutputImageRegionType & srcRegion) { - ExtractSliceImageFilterRegionCopierType extractImageRegionCopier; + const ExtractSliceImageFilterRegionCopierType extractImageRegionCopier; extractImageRegionCopier(destRegion, srcRegion, m_ExtractionRegion); } diff --git a/Modules/Core/TestKernel/include/itkTestingHashImageFilter.hxx b/Modules/Core/TestKernel/include/itkTestingHashImageFilter.hxx index add9f8e7147..8caebeaed37 100644 --- a/Modules/Core/TestKernel/include/itkTestingHashImageFilter.hxx +++ b/Modules/Core/TestKernel/include/itkTestingHashImageFilter.hxx @@ -65,7 +65,7 @@ HashImageFilter::AfterThreadedGenerateData() try { - typename ImageType::ConstPointer input = this->GetInput(); + const typename ImageType::ConstPointer input = this->GetInput(); // make a good guess about the number of components in each pixel size_t numberOfComponent = sizeof(PixelType) / sizeof(ValueType); @@ -83,8 +83,8 @@ HashImageFilter::AfterThreadedGenerateData() // we feel bad about accessing the data this way const void * const buffer = input->GetBufferPointer(); - typename ImageType::RegionType largestRegion = input->GetBufferedRegion(); - const size_t numberOfValues = largestRegion.GetNumberOfPixels() * numberOfComponent; + const typename ImageType::RegionType largestRegion = input->GetBufferedRegion(); + const size_t numberOfValues = largestRegion.GetNumberOfPixels() * numberOfComponent; // Possible byte swap so we always calculate on little endian data const auto ByteSwapBigEndian = [buffer, numberOfValues] { diff --git a/Modules/Core/TestKernel/include/itkTestingStretchIntensityImageFilter.hxx b/Modules/Core/TestKernel/include/itkTestingStretchIntensityImageFilter.hxx index 3cc38139af9..0a643454778 100644 --- a/Modules/Core/TestKernel/include/itkTestingStretchIntensityImageFilter.hxx +++ b/Modules/Core/TestKernel/include/itkTestingStretchIntensityImageFilter.hxx @@ -105,7 +105,7 @@ StretchIntensityImageFilter::DynamicThreadedGenerateD TotalProgressReporter progress(this, outputPtr->GetRequestedRegion().GetNumberOfPixels()); - InputImageRegionType inputRegionForThread = outputRegionForThread; + const InputImageRegionType inputRegionForThread = outputRegionForThread; ImageRegionConstIterator inputIt(inputPtr, inputRegionForThread); ImageRegionIterator outputIt(outputPtr, outputRegionForThread); diff --git a/Modules/Core/TestKernel/src/itkTestDriver.cxx b/Modules/Core/TestKernel/src/itkTestDriver.cxx index 054596d7b52..d8862be649b 100644 --- a/Modules/Core/TestKernel/src/itkTestDriver.cxx +++ b/Modules/Core/TestKernel/src/itkTestDriver.cxx @@ -195,7 +195,7 @@ TestDriverInvokeProcess(const ArgumentsList & args) delete[] argv; - int state = itksysProcess_GetState(process); + const int state = itksysProcess_GetState(process); switch (state) { case itksysProcess_State_Error: @@ -250,7 +250,7 @@ TestDriverInvokeProcess(const ArgumentsList & args) } } - int retCode = itksysProcess_GetExitValue(process); + const int retCode = itksysProcess_GetExitValue(process); if (retCode != 0) { std::cerr << "itkTestDriver: Process exited with return value: " << retCode << std::endl; diff --git a/Modules/Core/TestKernel/src/itkTestDriverInclude.cxx b/Modules/Core/TestKernel/src/itkTestDriverInclude.cxx index c07df69f9b7..576d649f3cb 100644 --- a/Modules/Core/TestKernel/src/itkTestDriverInclude.cxx +++ b/Modules/Core/TestKernel/src/itkTestDriverInclude.cxx @@ -503,8 +503,8 @@ RegressionTestHelper(const char * testImageFilename, } // The sizes of the baseline and test image must match - typename ImageType::SizeType baselineSize = baselineReader->GetOutput()->GetLargestPossibleRegion().GetSize(); - typename ImageType::SizeType testSize = testReader->GetOutput()->GetLargestPossibleRegion().GetSize(); + const typename ImageType::SizeType baselineSize = baselineReader->GetOutput()->GetLargestPossibleRegion().GetSize(); + const typename ImageType::SizeType testSize = testReader->GetOutput()->GetLargestPossibleRegion().GetSize(); if (baselineSize != testSize) { @@ -526,13 +526,13 @@ RegressionTestHelper(const char * testImageFilename, diff->SetDirectionTolerance(directionTolerance); diff->UpdateLargestPossibleRegion(); - itk::SizeValueType status = diff->GetNumberOfPixelsWithDifferences(); + const itk::SizeValueType status = diff->GetNumberOfPixelsWithDifferences(); if (!reportErrors) { // The measurement errors should be reported for both success and errors // to facilitate setting tight tolerances of tests. - std::string shortFilename = itksys::SystemTools::GetFilenameName(baselineImageFilename); + const std::string shortFilename = itksys::SystemTools::GetFilenameName(baselineImageFilename); std::cout << ""; std::cout << status; @@ -809,7 +809,7 @@ ComputeHash(const char * testImageFilename) int HashTestImage(const char * testImageFilename, const std::vector & baselineMD5Vector) { - itk::ImageIOBase::Pointer iobase = + const itk::ImageIOBase::Pointer iobase = itk::ImageIOFactory::CreateImageIO(testImageFilename, itk::ImageIOFactory::IOFileModeEnum::ReadMode); if (iobase.IsNull()) @@ -822,7 +822,7 @@ HashTestImage(const char * testImageFilename, const std::vector & b iobase->ReadImageInformation(); // get output information about input image - itk::IOComponentEnum componentType = iobase->GetComponentType(); + const itk::IOComponentEnum componentType = iobase->GetComponentType(); std::string testMD5 = ""; switch (componentType) @@ -966,9 +966,9 @@ RegressionTestBaselines(char * baselineFilename) std::string originalBaseline(baselineFilename); - int x = 0; - std::string::size_type suffixPos = originalBaseline.rfind("."); - std::string suffix; + int x = 0; + const std::string::size_type suffixPos = originalBaseline.rfind("."); + std::string suffix; if (suffixPos != std::string::npos) { suffix = originalBaseline.substr(suffixPos, originalBaseline.length()); diff --git a/Modules/Core/TestKernel/test/itkTestingComparisonImageFilterGTest.cxx b/Modules/Core/TestKernel/test/itkTestingComparisonImageFilterGTest.cxx index dbed4c759ae..cfa2b36a936 100644 --- a/Modules/Core/TestKernel/test/itkTestingComparisonImageFilterGTest.cxx +++ b/Modules/Core/TestKernel/test/itkTestingComparisonImageFilterGTest.cxx @@ -40,9 +40,9 @@ TEST(itkTestingComparisonImageFilterTest, TestZeroImages) { // Create two 16x16 images of all zeros using ImageType = itk::Image; - auto image1 = ImageType::New(); - auto image2 = ImageType::New(); - ImageType::SizeType size = { { 16, 16 } }; + auto image1 = ImageType::New(); + auto image2 = ImageType::New(); + const ImageType::SizeType size = { { 16, 16 } }; image1->SetRegions(size); image2->SetRegions(size); image1->AllocateInitialized(); @@ -70,9 +70,9 @@ TEST(itkTestingComparisonImageFilterTest, TestOneDifferentPixel) { // Create two 16x16 images of all zeros but pixel at (5,5) is 1 using ImageType = itk::Image; - auto image1 = ImageType::New(); - auto image2 = ImageType::New(); - ImageType::SizeType size = { { 16, 16 } }; + auto image1 = ImageType::New(); + auto image2 = ImageType::New(); + const ImageType::SizeType size = { { 16, 16 } }; image1->SetRegions(size); image2->SetRegions(size); image1->AllocateInitialized(); diff --git a/Modules/Core/TestKernel/test/itkTestingStretchIntensityImageFilterTest.cxx b/Modules/Core/TestKernel/test/itkTestingStretchIntensityImageFilterTest.cxx index db14ef51011..b5637e0ad13 100644 --- a/Modules/Core/TestKernel/test/itkTestingStretchIntensityImageFilterTest.cxx +++ b/Modules/Core/TestKernel/test/itkTestingStretchIntensityImageFilterTest.cxx @@ -30,8 +30,8 @@ itkTestingStretchIntensityImageFilterTest(int itkNotUsed(argc), char * itkNotUse using StretchFilterType = itk::Testing::StretchIntensityImageFilter; using StatsFilterType = itk::StatisticsImageFilter; - ImageType::SizeType imageSize = { { 32, 32 } }; - auto image = ImageType::New(); + const ImageType::SizeType imageSize = { { 32, 32 } }; + auto image = ImageType::New(); image->SetRegions(imageSize); image->Allocate(); PixelType i = -511; diff --git a/Modules/Core/Transform/include/itkAffineTransform.hxx b/Modules/Core/Transform/include/itkAffineTransform.hxx index 6584a104649..d31c52d02e0 100644 --- a/Modules/Core/Transform/include/itkAffineTransform.hxx +++ b/Modules/Core/Transform/include/itkAffineTransform.hxx @@ -175,16 +175,16 @@ AffineTransform::Rotate3D(const OutputVectorTy bool pre) { // Convert the axis to a unit vector - ScalarType r = std::sqrt(axis[0] * axis[0] + axis[1] * axis[1] + axis[2] * axis[2]); - ScalarType x1 = axis[0] / r; - ScalarType x2 = axis[1] / r; - ScalarType x3 = axis[2] / r; + const ScalarType r = std::sqrt(axis[0] * axis[0] + axis[1] * axis[1] + axis[2] * axis[2]); + const ScalarType x1 = axis[0] / r; + const ScalarType x2 = axis[1] / r; + const ScalarType x3 = axis[2] / r; // Compute quaternion elements - ScalarType q0 = std::cos(angle / 2.0); - ScalarType q1 = x1 * std::sin(angle / 2.0); - ScalarType q2 = x2 * std::sin(angle / 2.0); - ScalarType q3 = x3 * std::sin(angle / 2.0); + const ScalarType q0 = std::cos(angle / 2.0); + const ScalarType q1 = x1 * std::sin(angle / 2.0); + const ScalarType q2 = x2 * std::sin(angle / 2.0); + const ScalarType q3 = x3 * std::sin(angle / 2.0); MatrixType trans; // Compute elements of the rotation matrix @@ -264,10 +264,10 @@ AffineTransform::Metric(const Self * other) co { for (unsigned int j = 0; j < VDimension; ++j) { - ScalarType term1 = this->GetMatrix()[i][j] - other->GetMatrix()[i][j]; + const ScalarType term1 = this->GetMatrix()[i][j] - other->GetMatrix()[i][j]; result += term1 * term1; } - ScalarType term2 = this->GetOffset()[i] - other->GetOffset()[i]; + const ScalarType term2 = this->GetOffset()[i] - other->GetOffset()[i]; result += term2 * term2; } return std::sqrt(result); @@ -294,7 +294,7 @@ AffineTransform::Metric() const -> ScalarType } result += term * term; } - ScalarType term2 = this->GetOffset()[i]; + const ScalarType term2 = this->GetOffset()[i]; result += term2 * term2; } diff --git a/Modules/Core/Transform/include/itkAzimuthElevationToCartesianTransform.hxx b/Modules/Core/Transform/include/itkAzimuthElevationToCartesianTransform.hxx index 4abf7980147..0eed576a8b0 100644 --- a/Modules/Core/Transform/include/itkAzimuthElevationToCartesianTransform.hxx +++ b/Modules/Core/Transform/include/itkAzimuthElevationToCartesianTransform.hxx @@ -75,15 +75,15 @@ auto AzimuthElevationToCartesianTransform::TransformAzElToCartesian( const InputPointType & point) const -> OutputPointType { - OutputPointType result; - ScalarType Azimuth = + OutputPointType result; + const ScalarType Azimuth = ((2 * itk::Math::pi) / 360) * (point[0] * m_AzimuthAngularSeparation - ((m_MaxAzimuth - 1) / 2.0)); - ScalarType Elevation = + const ScalarType Elevation = ((2 * itk::Math::pi) / 360) * (point[1] * m_ElevationAngularSeparation - ((m_MaxElevation - 1) / 2.0)); - ScalarType r = (m_FirstSampleDistance + point[2]) * m_RadiusSampleSize; + const ScalarType r = (m_FirstSampleDistance + point[2]) * m_RadiusSampleSize; - ScalarType cosOfAzimuth = std::cos(Azimuth); - ScalarType tanOfElevation = std::tan(Elevation); + const ScalarType cosOfAzimuth = std::cos(Azimuth); + const ScalarType tanOfElevation = std::tan(Elevation); result[2] = (r * cosOfAzimuth) / std::sqrt((1 + cosOfAzimuth * cosOfAzimuth * tanOfElevation * tanOfElevation)); result[0] = result[2] * std::tan(Azimuth); diff --git a/Modules/Core/Transform/include/itkBSplineBaseTransform.hxx b/Modules/Core/Transform/include/itkBSplineBaseTransform.hxx index 5ddf3cf719e..dcd985f54b0 100644 --- a/Modules/Core/Transform/include/itkBSplineBaseTransform.hxx +++ b/Modules/Core/Transform/include/itkBSplineBaseTransform.hxx @@ -121,7 +121,7 @@ BSplineBaseTransform::UpdateTran const DerivativeType & update, TParametersValueType factor) { - NumberOfParametersType numberOfParameters = this->GetNumberOfParameters(); + const NumberOfParametersType numberOfParameters = this->GetNumberOfParameters(); if (update.Size() != numberOfParameters) { diff --git a/Modules/Core/Transform/include/itkBSplineDeformableTransform.h b/Modules/Core/Transform/include/itkBSplineDeformableTransform.h index d785020a1e0..fc917133503 100644 --- a/Modules/Core/Transform/include/itkBSplineDeformableTransform.h +++ b/Modules/Core/Transform/include/itkBSplineDeformableTransform.h @@ -132,7 +132,7 @@ class ITK_TEMPLATE_EXPORT BSplineDeformableTransform CreateAnother() const override { itk::LightObject::Pointer smartPtr; - Pointer copyPtr = Self::New().GetPointer(); + const Pointer copyPtr = Self::New().GetPointer(); // THE FOLLOWING LINE IS DIFFERENT FROM THE DEFAULT MACRO! copyPtr->m_BulkTransform = this->GetBulkTransform(); smartPtr = static_cast(copyPtr); diff --git a/Modules/Core/Transform/include/itkBSplineDeformableTransform.hxx b/Modules/Core/Transform/include/itkBSplineDeformableTransform.hxx index 61d5bd0e591..aa4e99da5f0 100644 --- a/Modules/Core/Transform/include/itkBSplineDeformableTransform.hxx +++ b/Modules/Core/Transform/include/itkBSplineDeformableTransform.hxx @@ -577,7 +577,7 @@ BSplineDeformableTransform::Comp const RegionType supportRegion(supportIndex, supportSize); - IndexType startIndex = this->m_CoefficientImages[0]->GetLargestPossibleRegion().GetIndex(); + const IndexType startIndex = this->m_CoefficientImages[0]->GetLargestPossibleRegion().GetIndex(); const SizeType & MeshGridSize = this->m_GridRegion.GetSize(); SizeType cumulativeGridSizes; @@ -587,7 +587,7 @@ BSplineDeformableTransform::Comp cumulativeGridSizes[d] = cumulativeGridSizes[d - 1] * MeshGridSize[d]; } - SizeValueType numberOfParametersPerDimension = this->GetNumberOfParametersPerDimension(); + const SizeValueType numberOfParametersPerDimension = this->GetNumberOfParametersPerDimension(); unsigned long counter = 0; for (ImageRegionConstIteratorWithIndex It(this->m_CoefficientImages[0], supportRegion); !It.IsAtEnd(); diff --git a/Modules/Core/Transform/include/itkBSplineTransform.hxx b/Modules/Core/Transform/include/itkBSplineTransform.hxx index adf11d6b078..d9ede2d87af 100644 --- a/Modules/Core/Transform/include/itkBSplineTransform.hxx +++ b/Modules/Core/Transform/include/itkBSplineTransform.hxx @@ -47,8 +47,8 @@ BSplineTransform::BSplineTransfo // dir[0][2],dir[1][2],dir[2][2]] - OriginType meshOrigin{}; - auto meshPhysical = MakeFilled(1.0); + const OriginType meshOrigin{}; + auto meshPhysical = MakeFilled(1.0); DirectionType meshDirection; meshDirection.SetIdentity(); @@ -167,7 +167,7 @@ BSplineTransform::GetTransformDo PhysicalDimensionsType physicalDim; for (unsigned int i = 0; i < VDimension; ++i) { - ScalarType spacing = this->m_FixedParameters[2 * VDimension + i]; + const ScalarType spacing = this->m_FixedParameters[2 * VDimension + i]; physicalDim[i] = size[i] * spacing; } return physicalDim; @@ -305,7 +305,7 @@ BSplineTransform::SetFixedParame PointType origin{}; for (unsigned int i = 0; i < VDimension; ++i) { - ScalarType gridSpacing = meshPhysical[i] / static_cast(meshSize[i]); + const ScalarType gridSpacing = meshPhysical[i] / static_cast(meshSize[i]); origin[i] = -0.5 * gridSpacing * (SplineOrder - 1); } @@ -318,7 +318,7 @@ BSplineTransform::SetFixedParame // Set the spacing parameters for (unsigned int i = 0; i < VDimension; ++i) { - ScalarType gridSpacing = meshPhysical[i] / static_cast(meshSize[i]); + const ScalarType gridSpacing = meshPhysical[i] / static_cast(meshSize[i]); this->m_FixedParameters[2 * VDimension + i] = static_cast(gridSpacing); } @@ -623,7 +623,7 @@ BSplineTransform::ComputeJacobia const RegionType supportRegion(supportIndex, supportSize); - IndexType startIndex = this->m_CoefficientImages[0]->GetLargestPossibleRegion().GetIndex(); + const IndexType startIndex = this->m_CoefficientImages[0]->GetLargestPossibleRegion().GetIndex(); const MeshSizeType meshSize = this->GetTransformDomainMeshSize(); SizeType cumulativeGridSizes; @@ -633,7 +633,7 @@ BSplineTransform::ComputeJacobia cumulativeGridSizes[d] = cumulativeGridSizes[d - 1] * (meshSize[d] + SplineOrder); } - SizeValueType numberOfParametersPerDimension = this->GetNumberOfParametersPerDimension(); + const SizeValueType numberOfParametersPerDimension = this->GetNumberOfParametersPerDimension(); unsigned long counter = 0; for (ImageRegionConstIteratorWithIndex It(this->m_CoefficientImages[0], supportRegion); !It.IsAtEnd(); diff --git a/Modules/Core/Transform/include/itkBSplineTransformInitializer.hxx b/Modules/Core/Transform/include/itkBSplineTransformInitializer.hxx index ea4e1ed7c1d..24dec9a03f4 100644 --- a/Modules/Core/Transform/include/itkBSplineTransformInitializer.hxx +++ b/Modules/Core/Transform/include/itkBSplineTransformInitializer.hxx @@ -144,7 +144,7 @@ BSplineTransformInitializer::InitializeTransform() const PointType corner{}; cornerPoints->GetPoint(d, &corner); - RealType distance = corner.SquaredEuclideanDistanceTo(bbox->GetMinimum()); + const RealType distance = corner.SquaredEuclideanDistanceTo(bbox->GetMinimum()); if (distance < minDistance) { transformDomainOrigin.CastFrom(corner); @@ -174,7 +174,7 @@ BSplineTransformInitializer::InitializeTransform() const for (unsigned int i = 0; i < SpaceDimension; ++i) { - PointIdentifier oppositeCornerId = + const PointIdentifier oppositeCornerId = (static_cast(1) << static_cast(i)) ^ transformDomainOriginId; PointType corner{}; @@ -183,7 +183,7 @@ BSplineTransformInitializer::InitializeTransform() const VectorType vector = corner - transformDomainOrigin; vector.Normalize(); - double theta = angle(vectorAxis.GetVnlVector(), vector.GetVnlVector()); + const double theta = angle(vectorAxis.GetVnlVector(), vector.GetVnlVector()); if (theta < minAngle[d]) { diff --git a/Modules/Core/Transform/include/itkCenteredEuler3DTransform.hxx b/Modules/Core/Transform/include/itkCenteredEuler3DTransform.hxx index 6e67bebcc2b..ca2e7f26c46 100644 --- a/Modules/Core/Transform/include/itkCenteredEuler3DTransform.hxx +++ b/Modules/Core/Transform/include/itkCenteredEuler3DTransform.hxx @@ -101,7 +101,7 @@ template auto CenteredEuler3DTransform::GetParameters() const -> const ParametersType & { - ParametersType parameters; + const ParametersType parameters; this->m_Parameters[0] = this->GetAngleX(); this->m_Parameters[1] = this->GetAngleY(); diff --git a/Modules/Core/Transform/include/itkComposeScaleSkewVersor3DTransform.hxx b/Modules/Core/Transform/include/itkComposeScaleSkewVersor3DTransform.hxx index e707dae09ca..bce04d814c0 100644 --- a/Modules/Core/Transform/include/itkComposeScaleSkewVersor3DTransform.hxx +++ b/Modules/Core/Transform/include/itkComposeScaleSkewVersor3DTransform.hxx @@ -103,7 +103,7 @@ ComposeScaleSkewVersor3DTransform::SetParameters(const Par norm = std::sqrt(norm); } - double epsilon = 1e-10; + const double epsilon = 1e-10; if (norm >= 1.0 - epsilon) { axis = axis / (norm + epsilon * norm); @@ -213,7 +213,7 @@ ComposeScaleSkewVersor3DTransform::ComputeMatrix() { this->Superclass::ComputeMatrix(); - MatrixType newMatrix = this->GetMatrix(); + const MatrixType newMatrix = this->GetMatrix(); MatrixType scaleM; scaleM.SetIdentity(); @@ -232,8 +232,8 @@ ComposeScaleSkewVersor3DTransform::ComputeMatrix() skewM(2, 1) = 0; skewM(2, 2) = 1; - MatrixType Q = scaleM * skewM; - MatrixType res = newMatrix * Q; + const MatrixType Q = scaleM * skewM; + const MatrixType res = newMatrix * Q; this->SetVarMatrix(res); } @@ -253,7 +253,7 @@ ComposeScaleSkewVersor3DTransform::ComputeMatrixParameters M(1, 0) /= m_Scale[0]; M(2, 0) /= m_Scale[0]; - double ortho = M(0, 0) * M(0, 1) + M(1, 0) * M(1, 1) + M(2, 0) * M(2, 1); + const double ortho = M(0, 0) * M(0, 1) + M(1, 0) * M(1, 1) + M(2, 0) * M(2, 1); M(0, 1) -= ortho * M(0, 0); M(1, 1) -= ortho * M(1, 0); M(2, 1) -= ortho * M(2, 0); @@ -266,8 +266,8 @@ ComposeScaleSkewVersor3DTransform::ComputeMatrixParameters M(2, 1) /= m_Scale[1]; m_Skew[0] = ortho / m_Scale[0]; - double ortho0 = M(0, 0) * M(0, 2) + M(1, 0) * M(1, 2) + M(2, 0) * M(2, 2); - double ortho1 = M(0, 1) * M(0, 2) + M(1, 1) * M(1, 2) + M(2, 1) * M(2, 2); + const double ortho0 = M(0, 0) * M(0, 2) + M(1, 0) * M(1, 2) + M(2, 0) * M(2, 2); + const double ortho1 = M(0, 1) * M(0, 2) + M(1, 1) * M(1, 2) + M(2, 1) * M(2, 2); M(0, 2) -= (ortho0 * M(0, 0) + ortho1 * M(0, 1)); M(1, 2) -= (ortho0 * M(1, 0) + ortho1 * M(1, 1)); M(2, 2) -= (ortho0 * M(2, 0) + ortho1 * M(2, 1)); @@ -355,15 +355,15 @@ ComposeScaleSkewVersor3DTransform::ComputeJacobianWithResp jacobian.SetSize(3, this->GetNumberOfLocalParameters()); jacobian.Fill(0.0); - double v0v0 = v0 * v0; - double v0v1 = v0 * v1; - double v0v2 = v0 * v2; - double v0w = v0 * w; - double v1v1 = v1 * v1; - double v1v2 = v1 * v2; - double v1w = v1 * w; - double v2v2 = v2 * v2; - double v2w = v2 * w; + const double v0v0 = v0 * v0; + const double v0v1 = v0 * v1; + const double v0v2 = v0 * v2; + const double v0w = v0 * w; + const double v1v1 = v1 * v1; + const double v1v2 = v1 * v2; + const double v1w = v1 * w; + const double v2v2 = v2 * v2; + const double v2w = v2 * w; // compute Jacobian with respect to quaternion parameters jacobian[0][0] = 2 * s1 * v1 * x1 + x2 * (2 * k2 * s1 * v1 + 2 * s2 * v2); diff --git a/Modules/Core/Transform/include/itkCompositeTransform.hxx b/Modules/Core/Transform/include/itkCompositeTransform.hxx index 5b5d9c0f9a1..894d78825a0 100644 --- a/Modules/Core/Transform/include/itkCompositeTransform.hxx +++ b/Modules/Core/Transform/include/itkCompositeTransform.hxx @@ -27,7 +27,7 @@ auto CompositeTransform::GetTransformCategory() const -> TransformCategoryEnum { // Check if linear - bool isLinearTransform = this->IsLinear(); + const bool isLinearTransform = this->IsLinear(); if (isLinearTransform) { return Self::TransformCategoryEnum::Linear; @@ -418,7 +418,7 @@ CompositeTransform::GetInverse(Self * inverse) inverse->ClearTransformQueue(); for (it = this->m_TransformQueue.begin(); it != this->m_TransformQueue.end(); ++it) { - TransformTypePointer inverseTransform = ((*it)->GetInverseTransform()).GetPointer(); + const TransformTypePointer inverseTransform = ((*it)->GetInverseTransform()).GetPointer(); if (!inverseTransform) { inverse->ClearTransformQueue(); @@ -833,7 +833,7 @@ CompositeTransform::UpdateTransformParameters( * functor to return whether or not it does threading. If all sub-transforms * return that they don't thread, we could do each sub-transform in its * own thread from here. */ - NumberOfParametersType numberOfParameters = this->GetNumberOfParameters(); + const NumberOfParametersType numberOfParameters = this->GetNumberOfParameters(); if (update.Size() != numberOfParameters) { @@ -979,8 +979,8 @@ CompositeTransform::InternalClone() const // TODO: is it really the right behavior? // LightObject::Pointer loPtr = Superclass::InternalClone(); - LightObject::Pointer loPtr = CreateAnother(); - typename Self::Pointer clone = dynamic_cast(loPtr.GetPointer()); + LightObject::Pointer loPtr = CreateAnother(); + const typename Self::Pointer clone = dynamic_cast(loPtr.GetPointer()); if (clone.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Core/Transform/include/itkEuler3DTransform.hxx b/Modules/Core/Transform/include/itkEuler3DTransform.hxx index ba570fc28ac..f3282ff8360 100644 --- a/Modules/Core/Transform/include/itkEuler3DTransform.hxx +++ b/Modules/Core/Transform/include/itkEuler3DTransform.hxx @@ -180,7 +180,7 @@ Euler3DTransform::ComputeMatrixParameters() if (m_ComputeZYX) { m_AngleY = -std::asin(this->GetMatrix()[2][0]); - double C = std::cos(m_AngleY); + const double C = std::cos(m_AngleY); if (itk::Math::abs(C) > 0.00005) { double x = this->GetMatrix()[2][2] / C; @@ -193,15 +193,15 @@ Euler3DTransform::ComputeMatrixParameters() else { m_AngleX = ScalarType{}; - double x = this->GetMatrix()[1][1]; - double y = -this->GetMatrix()[0][1]; + const double x = this->GetMatrix()[1][1]; + const double y = -this->GetMatrix()[0][1]; m_AngleZ = std::atan2(y, x); } } else { m_AngleX = std::asin(this->GetMatrix()[2][1]); - double A = std::cos(m_AngleX); + const double A = std::cos(m_AngleX); if (itk::Math::abs(A) > 0.00005) { double x = this->GetMatrix()[2][2] / A; @@ -215,8 +215,8 @@ Euler3DTransform::ComputeMatrixParameters() else { m_AngleZ = ScalarType{}; - double x = this->GetMatrix()[0][0]; - double y = this->GetMatrix()[1][0]; + const double x = this->GetMatrix()[0][0]; + const double y = this->GetMatrix()[1][0]; m_AngleY = std::atan2(y, x); } } @@ -332,7 +332,7 @@ Euler3DTransform::ComputeJacobianWithRespectToParameters(c } // compute derivatives for the translation part - unsigned int blockOffset = 3; + const unsigned int blockOffset = 3; for (unsigned int dim = 0; dim < SpaceDimension; ++dim) { jacobian[dim][blockOffset + dim] = 1.0; diff --git a/Modules/Core/Transform/include/itkKernelTransform.hxx b/Modules/Core/Transform/include/itkKernelTransform.hxx index 46c3dcdf924..9ae85818e29 100644 --- a/Modules/Core/Transform/include/itkKernelTransform.hxx +++ b/Modules/Core/Transform/include/itkKernelTransform.hxx @@ -96,7 +96,7 @@ KernelTransform::ComputeDeformationContributio * Default implementation of the the method. This can be overloaded * in transforms whose kernel produce diagonal G matrices. */ - PointIdentifier numberOfLandmarks = this->m_SourceLandmarks->GetNumberOfPoints(); + const PointIdentifier numberOfLandmarks = this->m_SourceLandmarks->GetNumberOfPoints(); PointsIterator sp = this->m_SourceLandmarks->GetPoints()->Begin(); @@ -121,11 +121,11 @@ template void KernelTransform::ComputeD() { - PointIdentifier numberOfLandmarks = this->m_SourceLandmarks->GetNumberOfPoints(); + const PointIdentifier numberOfLandmarks = this->m_SourceLandmarks->GetNumberOfPoints(); - PointsIterator sp = this->m_SourceLandmarks->GetPoints()->Begin(); - PointsIterator tp = this->m_TargetLandmarks->GetPoints()->Begin(); - PointsIterator end = this->m_SourceLandmarks->GetPoints()->End(); + PointsIterator sp = this->m_SourceLandmarks->GetPoints()->Begin(); + PointsIterator tp = this->m_TargetLandmarks->GetPoints()->Begin(); + const PointsIterator end = this->m_SourceLandmarks->GetPoints()->End(); this->m_Displacements->Reserve(numberOfLandmarks); typename VectorSetType::Iterator vt = this->m_Displacements->Begin(); @@ -148,7 +148,7 @@ KernelTransform::ComputeWMatrix() this->ComputeL(); this->ComputeY(); - SVDSolverType svd(this->m_LMatrix, 1e-8); + const SVDSolverType svd(this->m_LMatrix, 1e-8); this->m_WMatrix = svd.solve(this->m_YMatrix); this->ReorganizeW(); @@ -159,9 +159,9 @@ template void KernelTransform::ComputeL() { - PointIdentifier numberOfLandmarks = this->m_SourceLandmarks->GetNumberOfPoints(); + const PointIdentifier numberOfLandmarks = this->m_SourceLandmarks->GetNumberOfPoints(); - vnl_matrix O2(VDimension * (VDimension + 1), VDimension * (VDimension + 1), 0); + const vnl_matrix O2(VDimension * (VDimension + 1), VDimension * (VDimension + 1), 0); this->ComputeP(); this->ComputeK(); @@ -182,7 +182,7 @@ template void KernelTransform::ComputeK() { - PointIdentifier numberOfLandmarks = this->m_SourceLandmarks->GetNumberOfPoints(); + const PointIdentifier numberOfLandmarks = this->m_SourceLandmarks->GetNumberOfPoints(); this->ComputeD(); @@ -191,8 +191,8 @@ KernelTransform::ComputeK() this->m_KMatrix.fill(0.0); - PointsIterator p1 = this->m_SourceLandmarks->GetPoints()->Begin(); - PointsIterator end = this->m_SourceLandmarks->GetPoints()->End(); + PointsIterator p1 = this->m_SourceLandmarks->GetPoints()->Begin(); + const PointsIterator end = this->m_SourceLandmarks->GetPoints()->End(); GMatrixType G; // K matrix is symmetric, so only evaluate the upper triangle and @@ -259,7 +259,7 @@ template void KernelTransform::ComputeY() { - PointIdentifier numberOfLandmarks = this->m_SourceLandmarks->GetNumberOfPoints(); + const PointIdentifier numberOfLandmarks = this->m_SourceLandmarks->GetNumberOfPoints(); typename VectorSetType::ConstIterator displacement = this->m_Displacements->Begin(); @@ -285,7 +285,7 @@ template void KernelTransform::ReorganizeW() { - PointIdentifier numberOfLandmarks = this->m_SourceLandmarks->GetNumberOfPoints(); + const PointIdentifier numberOfLandmarks = this->m_SourceLandmarks->GetNumberOfPoints(); // The deformable (non-affine) part of the registration goes here this->m_DMatrix.set_size(VDimension, numberOfLandmarks); @@ -385,8 +385,8 @@ KernelTransform::SetParameters(const Parameter const unsigned int numberOfLandmarks = parameters.Size() / VDimension; landmarks->Reserve(numberOfLandmarks); - PointsIterator itr = landmarks->Begin(); - PointsIterator end = landmarks->End(); + PointsIterator itr = landmarks->Begin(); + const PointsIterator end = landmarks->End(); InputPointType landMark; @@ -425,8 +425,8 @@ KernelTransform::SetFixedParameters(const Fixe landmarks->Reserve(numberOfLandmarks); - PointsIterator itr = landmarks->Begin(); - PointsIterator end = landmarks->End(); + PointsIterator itr = landmarks->Begin(); + const PointsIterator end = landmarks->End(); InputPointType landMark; @@ -452,8 +452,8 @@ KernelTransform::UpdateParameters() const { this->m_Parameters = ParametersType(this->m_SourceLandmarks->GetNumberOfPoints() * VDimension); - PointsIterator itr = this->m_SourceLandmarks->GetPoints()->Begin(); - PointsIterator end = this->m_SourceLandmarks->GetPoints()->End(); + PointsIterator itr = this->m_SourceLandmarks->GetPoints()->Begin(); + const PointsIterator end = this->m_SourceLandmarks->GetPoints()->End(); unsigned int pcounter = 0; while (itr != end) @@ -487,8 +487,8 @@ KernelTransform::GetFixedParameters() const -> // This was added to support the Transform Reader/Writer mechanism this->m_FixedParameters = ParametersType(this->m_TargetLandmarks->GetNumberOfPoints() * VDimension); - PointsIterator itr = this->m_TargetLandmarks->GetPoints()->Begin(); - PointsIterator end = this->m_TargetLandmarks->GetPoints()->End(); + PointsIterator itr = this->m_TargetLandmarks->GetPoints()->Begin(); + const PointsIterator end = this->m_TargetLandmarks->GetPoints()->End(); unsigned int pcounter = 0; while (itr != end) diff --git a/Modules/Core/Transform/include/itkMultiTransform.hxx b/Modules/Core/Transform/include/itkMultiTransform.hxx index 57d501a9db1..842ee96e738 100644 --- a/Modules/Core/Transform/include/itkMultiTransform.hxx +++ b/Modules/Core/Transform/include/itkMultiTransform.hxx @@ -265,7 +265,7 @@ MultiTransform::UpdateTransfor * functor to return whether or not it does threading. If all sub-transforms * return that they don't thread, we could do each sub-transform in its * own thread from here. */ - NumberOfParametersType numberOfParameters = this->GetNumberOfParameters(); + const NumberOfParametersType numberOfParameters = this->GetNumberOfParameters(); if (update.Size() != numberOfParameters) { @@ -310,7 +310,7 @@ MultiTransform::GetInverse(Sel inverse->ClearTransformQueue(); for (const TransformType * const transform : m_TransformQueue) { - TransformTypePointer inverseTransform = (transform->GetInverseTransform()).GetPointer(); + const TransformTypePointer inverseTransform = (transform->GetInverseTransform()).GetPointer(); if (!inverseTransform) { inverse->ClearTransformQueue(); diff --git a/Modules/Core/Transform/include/itkQuaternionRigidTransform.hxx b/Modules/Core/Transform/include/itkQuaternionRigidTransform.hxx index 8183e19c225..bf4ad381954 100644 --- a/Modules/Core/Transform/include/itkQuaternionRigidTransform.hxx +++ b/Modules/Core/Transform/include/itkQuaternionRigidTransform.hxx @@ -168,7 +168,7 @@ QuaternionRigidTransform::ComputeJacobianWithRespectToPara jacobian[2][3] = jacobian[0][1]; // compute derivatives for the translation part - unsigned int blockOffset = 4; + const unsigned int blockOffset = 4; for (unsigned int dim = 0; dim < SpaceDimension; ++dim) { jacobian[dim][blockOffset + dim] = 1.0; @@ -195,10 +195,10 @@ template void QuaternionRigidTransform::ComputeMatrix() { - VnlQuaternionType conjugateRotation = m_Rotation.conjugate(); + const VnlQuaternionType conjugateRotation = m_Rotation.conjugate(); // this is done to compensate for the transposed representation // between VNL and ITK - MatrixType newMatrix = conjugateRotation.rotation_matrix_transpose(); + const MatrixType newMatrix = conjugateRotation.rotation_matrix_transpose(); this->SetVarMatrix(newMatrix); } @@ -206,7 +206,7 @@ template void QuaternionRigidTransform::ComputeMatrixParameters() { - VnlQuaternionType quat(this->GetMatrix().GetVnlMatrix()); + const VnlQuaternionType quat(this->GetMatrix().GetVnlMatrix()); m_Rotation = quat.conjugate(); } diff --git a/Modules/Core/Transform/include/itkRigid2DTransform.hxx b/Modules/Core/Transform/include/itkRigid2DTransform.hxx index 7d50191a2a1..df0409686c7 100644 --- a/Modules/Core/Transform/include/itkRigid2DTransform.hxx +++ b/Modules/Core/Transform/include/itkRigid2DTransform.hxx @@ -73,7 +73,7 @@ Rigid2DTransform::SetMatrix(const MatrixType & matrix, con itkDebugMacro("setting m_Matrix to " << matrix); // The matrix must be orthogonal otherwise it is not // representing a valid rotation in 2D space - typename MatrixType::InternalMatrixType test = matrix.GetVnlMatrix() * matrix.GetTranspose(); + const typename MatrixType::InternalMatrixType test = matrix.GetVnlMatrix() * matrix.GetTranspose(); if (!test.is_identity(tolerance)) { @@ -292,7 +292,7 @@ Rigid2DTransform::ComputeJacobianWithRespectToParameters(c j[1][0] = ca * (p[0] - cx) - sa * (p[1] - cy); // compute derivatives for the translation part - unsigned int blockOffset = 1; + const unsigned int blockOffset = 1; for (unsigned int dim = 0; dim < OutputSpaceDimension; ++dim) { j[dim][blockOffset + dim] = 1.0; diff --git a/Modules/Core/Transform/include/itkRigid3DPerspectiveTransform.hxx b/Modules/Core/Transform/include/itkRigid3DPerspectiveTransform.hxx index ca2e4bc9c4e..7f97bd55e55 100644 --- a/Modules/Core/Transform/include/itkRigid3DPerspectiveTransform.hxx +++ b/Modules/Core/Transform/include/itkRigid3DPerspectiveTransform.hxx @@ -80,7 +80,7 @@ Rigid3DPerspectiveTransform::SetParameters(const Parameter norm = std::sqrt(norm); } - double epsilon = 1e-10; + const double epsilon = 1e-10; if (norm >= 1.0 - epsilon) { axis = axis / (norm + epsilon * norm); diff --git a/Modules/Core/Transform/include/itkRigid3DTransform.hxx b/Modules/Core/Transform/include/itkRigid3DTransform.hxx index 4017062217f..3a2d3b6f49c 100644 --- a/Modules/Core/Transform/include/itkRigid3DTransform.hxx +++ b/Modules/Core/Transform/include/itkRigid3DTransform.hxx @@ -55,7 +55,7 @@ bool Rigid3DTransform::MatrixIsOrthogonal(const MatrixType & matrix, const TParametersValueType tolerance) { - typename MatrixType::InternalMatrixType test = matrix.GetVnlMatrix() * matrix.GetTranspose(); + const typename MatrixType::InternalMatrixType test = matrix.GetVnlMatrix() * matrix.GetTranspose(); if (!test.is_identity(tolerance)) { diff --git a/Modules/Core/Transform/include/itkScaleSkewVersor3DTransform.hxx b/Modules/Core/Transform/include/itkScaleSkewVersor3DTransform.hxx index 4b46cc4006f..b9b8a212592 100644 --- a/Modules/Core/Transform/include/itkScaleSkewVersor3DTransform.hxx +++ b/Modules/Core/Transform/include/itkScaleSkewVersor3DTransform.hxx @@ -99,7 +99,7 @@ ScaleSkewVersor3DTransform::SetParameters(const Parameters norm = std::sqrt(norm); } - double epsilon = 1e-10; + const double epsilon = 1e-10; if (norm >= 1.0 - epsilon) { axis = axis / (norm + epsilon * norm); diff --git a/Modules/Core/Transform/include/itkSimilarity3DTransform.hxx b/Modules/Core/Transform/include/itkSimilarity3DTransform.hxx index 48492334949..b2bb2b67f9d 100644 --- a/Modules/Core/Transform/include/itkSimilarity3DTransform.hxx +++ b/Modules/Core/Transform/include/itkSimilarity3DTransform.hxx @@ -84,7 +84,7 @@ Similarity3DTransform::SetMatrix(const MatrixType & matrix // multiplied by the scale factor, then its determinant // must be equal to the cube of the scale factor. // - double det = vnl_det(matrix.GetVnlMatrix()); + const double det = vnl_det(matrix.GetVnlMatrix()); if (det == 0.0) { @@ -96,7 +96,7 @@ Similarity3DTransform::SetMatrix(const MatrixType & matrix // It will imply a reflection of the coordinate system. // - double s = itk::Math::cbrt(det); + const double s = itk::Math::cbrt(det); // // A negative scale is not acceptable @@ -147,7 +147,7 @@ Similarity3DTransform::SetParameters(const ParametersType norm = std::sqrt(norm); } - double epsilon = 1e-10; + const double epsilon = 1e-10; if (norm >= 1.0 - epsilon) { axis = axis / (norm + epsilon * norm); diff --git a/Modules/Core/Transform/include/itkThinPlateR2LogRSplineKernelTransform.hxx b/Modules/Core/Transform/include/itkThinPlateR2LogRSplineKernelTransform.hxx index 223639f9bf5..fa93ee76121 100644 --- a/Modules/Core/Transform/include/itkThinPlateR2LogRSplineKernelTransform.hxx +++ b/Modules/Core/Transform/include/itkThinPlateR2LogRSplineKernelTransform.hxx @@ -39,13 +39,13 @@ ThinPlateR2LogRSplineKernelTransform::ComputeD const InputPointType & thisPoint, OutputPointType & result) const { - unsigned long numberOfLandmarks = this->m_SourceLandmarks->GetNumberOfPoints(); + const unsigned long numberOfLandmarks = this->m_SourceLandmarks->GetNumberOfPoints(); PointsIterator sp = this->m_SourceLandmarks->GetPoints()->Begin(); for (unsigned int lnd = 0; lnd < numberOfLandmarks; ++lnd) { - InputVectorType position = thisPoint - sp->Value(); + const InputVectorType position = thisPoint - sp->Value(); const TParametersValueType r = position.GetNorm(); const TParametersValueType R2logR = (r > 1e-8) ? r * r * std::log(r) : TParametersValueType{}; for (unsigned int odim = 0; odim < VDimension; ++odim) diff --git a/Modules/Core/Transform/include/itkThinPlateSplineKernelTransform.hxx b/Modules/Core/Transform/include/itkThinPlateSplineKernelTransform.hxx index ab79381644c..de480e4e880 100644 --- a/Modules/Core/Transform/include/itkThinPlateSplineKernelTransform.hxx +++ b/Modules/Core/Transform/include/itkThinPlateSplineKernelTransform.hxx @@ -40,13 +40,13 @@ ThinPlateSplineKernelTransform::ComputeDeforma const InputPointType & thisPoint, OutputPointType & result) const { - unsigned long numberOfLandmarks = this->m_SourceLandmarks->GetNumberOfPoints(); + const unsigned long numberOfLandmarks = this->m_SourceLandmarks->GetNumberOfPoints(); PointsIterator sp = this->m_SourceLandmarks->GetPoints()->Begin(); for (unsigned int lnd = 0; lnd < numberOfLandmarks; ++lnd) { - InputVectorType position = thisPoint - sp->Value(); + const InputVectorType position = thisPoint - sp->Value(); const TParametersValueType r = position.GetNorm(); for (unsigned int odim = 0; odim < VDimension; ++odim) diff --git a/Modules/Core/Transform/include/itkTransform.hxx b/Modules/Core/Transform/include/itkTransform.hxx index 9471f75f60e..067ced1684e 100644 --- a/Modules/Core/Transform/include/itkTransform.hxx +++ b/Modules/Core/Transform/include/itkTransform.hxx @@ -52,7 +52,7 @@ Transform::InternalClon // this to new transform. typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); @@ -69,7 +69,7 @@ Transform::UpdateTransf const DerivativeType & update, ParametersValueType factor) { - NumberOfParametersType numberOfParameters = this->GetNumberOfParameters(); + const NumberOfParametersType numberOfParameters = this->GetNumberOfParameters(); if (update.Size() != numberOfParameters) { @@ -344,7 +344,7 @@ Transform:: ev2 = ev2 - ev1 * dp; ev2.Normalize(); - CrossHelper> vectorCross; + const CrossHelper> vectorCross; ev3 = vectorCross(ev1, ev2); // Outer product matrices @@ -468,7 +468,7 @@ Transform::ApplyToImage << this->GetNameOfClass() << ". This might produce unexpected results."); } - typename Self::Pointer inverse = this->GetInverseTransform(); + const typename Self::Pointer inverse = this->GetInverseTransform(); // transform origin typename ImageType::PointType origin = image->GetOrigin(); @@ -537,7 +537,7 @@ Transform::ComputeInver using SVDAlgorithmType = vnl_svd_fixed; - SVDAlgorithmType svd(forward_jacobian); + const SVDAlgorithmType svd(forward_jacobian); jacobian.set(svd.inverse().data_block()); } diff --git a/Modules/Core/Transform/include/itkTransformGeometryImageFilter.hxx b/Modules/Core/Transform/include/itkTransformGeometryImageFilter.hxx index 924060ff7d4..3aacfd82a74 100644 --- a/Modules/Core/Transform/include/itkTransformGeometryImageFilter.hxx +++ b/Modules/Core/Transform/include/itkTransformGeometryImageFilter.hxx @@ -40,7 +40,7 @@ TransformGeometryImageFilter::VerifyPreconditions() c { Superclass::VerifyPreconditions(); - TransformConstPointer tx = this->GetTransform(); + const TransformConstPointer tx = this->GetTransform(); if (!tx->IsLinear()) { @@ -58,7 +58,7 @@ TransformGeometryImageFilter::GenerateOutputInformati OutputImageType * outputPtr = this->GetOutput(); - TransformConstPointer tx = this->GetTransform(); + const TransformConstPointer tx = this->GetTransform(); tx->ApplyToImageMetadata(outputPtr); } diff --git a/Modules/Core/Transform/include/itkVersorRigid3DTransform.hxx b/Modules/Core/Transform/include/itkVersorRigid3DTransform.hxx index 766fecf875b..33ca87b59ca 100644 --- a/Modules/Core/Transform/include/itkVersorRigid3DTransform.hxx +++ b/Modules/Core/Transform/include/itkVersorRigid3DTransform.hxx @@ -126,7 +126,7 @@ void VersorRigid3DTransform::UpdateTransformParameters(const DerivativeType & update, TParametersValueType factor) { - SizeValueType numberOfParameters = this->GetNumberOfParameters(); + const SizeValueType numberOfParameters = this->GetNumberOfParameters(); if (update.Size() != numberOfParameters) { @@ -187,7 +187,7 @@ VersorRigid3DTransform::UpdateTransformParameters(const De // Composing the currentRotation with the gradientRotation // produces the new Rotation versor // - VersorType newRotation = currentRotation * gradientRotation; + const VersorType newRotation = currentRotation * gradientRotation; ParametersType newParameters(numberOfParameters); diff --git a/Modules/Core/Transform/include/itkVolumeSplineKernelTransform.hxx b/Modules/Core/Transform/include/itkVolumeSplineKernelTransform.hxx index 4fa8f5c10fa..84bf7d63888 100644 --- a/Modules/Core/Transform/include/itkVolumeSplineKernelTransform.hxx +++ b/Modules/Core/Transform/include/itkVolumeSplineKernelTransform.hxx @@ -41,13 +41,13 @@ VolumeSplineKernelTransform::ComputeDeformatio const InputPointType & thisPoint, OutputPointType & result) const { - unsigned long numberOfLandmarks = this->m_SourceLandmarks->GetNumberOfPoints(); + const unsigned long numberOfLandmarks = this->m_SourceLandmarks->GetNumberOfPoints(); PointsIterator sp = this->m_SourceLandmarks->GetPoints()->Begin(); for (unsigned int lnd = 0; lnd < numberOfLandmarks; ++lnd) { - InputVectorType position = thisPoint - sp->Value(); + const InputVectorType position = thisPoint - sp->Value(); const TParametersValueType r = position.GetNorm(); const TParametersValueType r3 = r * r * r; diff --git a/Modules/Core/Transform/test/itkAffineTransformTest.cxx b/Modules/Core/Transform/test/itkAffineTransformTest.cxx index 267914ba2e5..cda5f3d8253 100644 --- a/Modules/Core/Transform/test/itkAffineTransformTest.cxx +++ b/Modules/Core/Transform/test/itkAffineTransformTest.cxx @@ -114,7 +114,7 @@ itkAffineTransformTest(int, char *[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope // scope. - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); /* Set outstream precision */ std::cout.precision(20); @@ -342,8 +342,8 @@ itkAffineTransformTest(int, char *[]) } /* Transform a point */ - itk::Point u2({ 3, 5 }); - itk::Point v2 = aff2->TransformPoint(u2); + const itk::Point u2({ 3, 5 }); + itk::Point v2 = aff2->TransformPoint(u2); std::cout << "Transform a point:" << std::endl << v2[0] << " , " << v2[1] << std::endl; itk::Point v2T({ 41.37, 26.254 }); @@ -359,8 +359,8 @@ itkAffineTransformTest(int, char *[]) // << v2[0] << " , " << v2[1] << std::endl; /* Transform a vnl_vector */ - vnl_vector_fixed x2{ 1, 2 }; - vnl_vector_fixed y2 = aff2->TransformVector(x2); + const vnl_vector_fixed x2{ 1, 2 }; + vnl_vector_fixed y2 = aff2->TransformVector(x2); std::cout << "Transform a vnl_vector:" << std::endl << y2[0] << " , " << y2[1] << std::endl; @@ -377,8 +377,8 @@ itkAffineTransformTest(int, char *[]) // << y2[0] << " , " << y2[1] << std::endl; /* Transform a vector */ - itk::Vector u3({ 3, 5 }); - itk::Vector v3 = aff2->TransformVector(u3); + const itk::Vector u3({ 3, 5 }); + itk::Vector v3 = aff2->TransformVector(u3); std::cout << "Transform a vector:" << std::endl << v3[0] << " , " << v3[1] << std::endl; itk::Vector v3T({ 35.37, 22.254 }); @@ -468,8 +468,8 @@ itkAffineTransformTest(int, char *[]) Affine3DType::MatrixType matrix3Truth; /* Create a 3D transform and rotate in 3D */ - itk::Vector axis({ .707, .707, .707 }); - auto aff3 = Affine3DType::New(); + const itk::Vector axis({ .707, .707, .707 }); + auto aff3 = Affine3DType::New(); aff3->Rotate3D(axis, 1.0, true); std::cout << "Create and rotate a 3D transform:" << std::endl; aff3->Print(std::cout); @@ -516,7 +516,7 @@ itkAffineTransformTest(int, char *[]) return EXIT_FAILURE; } - Affine3DType::Pointer inv4 = dynamic_cast(aff3->GetInverseTransform().GetPointer()); + const Affine3DType::Pointer inv4 = dynamic_cast(aff3->GetInverseTransform().GetPointer()); if (!inv4) { std::cout << "Cannot compute inverse transformation inv4" << std::endl; @@ -547,7 +547,7 @@ itkAffineTransformTest(int, char *[]) constexpr double data[] = { 5, 10, 15, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 5, 10, 15, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 5, 10, 15, 0, 0, 1 }; - vnl_matrix vnlData(data, 3, 12); + const vnl_matrix vnlData(data, 3, 12); Affine3DType::JacobianType expectedJacobian(vnlData); for (unsigned int i = 0; i < 3; ++i) { @@ -734,7 +734,7 @@ itkAffineTransformTest(int, char *[]) } } /* Update with a non-unit scaling factor */ - double factor = 0.5; + const double factor = 0.5; for (unsigned int i = 0; i < paff->GetNumberOfParameters(); ++i) { update[i] = i; @@ -813,7 +813,8 @@ itkAffineTransformTest(int, char *[]) auto other = TransformType::New(); transform->GetInverse(other); - TransformType::Pointer otherbis = dynamic_cast(transform->GetInverseTransform().GetPointer()); + const TransformType::Pointer otherbis = + dynamic_cast(transform->GetInverseTransform().GetPointer()); parameters2 = other->GetParameters(); TransformType::ParametersType parameters2bis = otherbis->GetParameters(); @@ -861,7 +862,7 @@ itkAffineTransformTest(int, char *[]) return EXIT_FAILURE; } - TransformType::Pointer singularTransformInverse2 = + const TransformType::Pointer singularTransformInverse2 = dynamic_cast(singularTransform->GetInverseTransform().GetPointer()); if (!singularTransformInverse2) { diff --git a/Modules/Core/Transform/test/itkBSplineDeformableTransformTest.cxx b/Modules/Core/Transform/test/itkBSplineDeformableTransformTest.cxx index 06a0c37e663..727f4acd3b8 100644 --- a/Modules/Core/Transform/test/itkBSplineDeformableTransformTest.cxx +++ b/Modules/Core/Transform/test/itkBSplineDeformableTransformTest.cxx @@ -59,7 +59,7 @@ itkBSplineDeformableTransformTest1() */ using OriginType = TransformType::OriginType; - OriginType origin{}; + const OriginType origin{}; using RegionType = TransformType::RegionType; RegionType region; @@ -87,7 +87,7 @@ itkBSplineDeformableTransformTest1() ITK_TEST_SET_GET_VALUE(region, transform->GetGridRegion()); using DirectionType = TransformType::DirectionType; - DirectionType direction = transform->GetCoefficientImages()[0]->GetDirection(); + const DirectionType direction = transform->GetCoefficientImages()[0]->GetDirection(); transform->SetGridDirection(direction); ITK_TEST_SET_GET_VALUE(direction, transform->GetGridDirection()); @@ -96,8 +96,8 @@ itkBSplineDeformableTransformTest1() /** * Allocate memory for the parameters */ - unsigned long numberOfParameters = transform->GetNumberOfParameters(); - ParametersType parameters(numberOfParameters); + const unsigned long numberOfParameters = transform->GetNumberOfParameters(); + ParametersType parameters(numberOfParameters); parameters.Fill(ParametersType::ValueType{}); /** @@ -109,7 +109,7 @@ itkBSplineDeformableTransformTest1() using CoefficientImageType = itk::Image; CoefficientImageType::Pointer coeffImage[SpaceDimension]; - unsigned int numberOfControlPoints = region.GetNumberOfPixels(); + const unsigned int numberOfControlPoints = region.GetNumberOfPixels(); CoefficientType * dataPointer = parameters.data_block(); for (unsigned int j = 0; j < SpaceDimension; ++j) { @@ -127,7 +127,7 @@ itkBSplineDeformableTransformTest1() coeffImage[1]->SetPixel(index, 1.0); - unsigned long n = coeffImage[1]->ComputeOffset(index) + numberOfControlPoints; + const unsigned long n = coeffImage[1]->ComputeOffset(index) + numberOfControlPoints; /** * Set the parameters in the transform @@ -135,7 +135,7 @@ itkBSplineDeformableTransformTest1() transform->SetParameters(parameters); // outParametersCopy should make a copy of the parameters - ParametersType outParametersCopy = transform->GetParameters(); + const ParametersType outParametersCopy = transform->GetParameters(); /** * Set a bulk transform @@ -229,10 +229,10 @@ itkBSplineDeformableTransformTest1() // cycling through all the parameters and weights used in the previous // transformation - unsigned int numberOfCoefficientInSupportRegion = TransformType::NumberOfWeights; - unsigned int numberOfParametersPerDimension = transform->GetNumberOfParametersPerDimension(); - unsigned int linearIndex; - unsigned int baseIndex; + const unsigned int numberOfCoefficientInSupportRegion = TransformType::NumberOfWeights; + const unsigned int numberOfParametersPerDimension = transform->GetNumberOfParametersPerDimension(); + unsigned int linearIndex; + unsigned int baseIndex; std::cout << "Index" << '\t' << "Value" << '\t' << "Weight" << std::endl; for (unsigned int j = 0; j < SpaceDimension; ++j) @@ -585,7 +585,7 @@ itkBSplineDeformableTransformTest3() */ using OriginType = TransformType::OriginType; - OriginType origin{}; + const OriginType origin{}; using RegionType = TransformType::RegionType; RegionType region; @@ -608,8 +608,8 @@ itkBSplineDeformableTransformTest3() /** * Allocate memory for the parameters */ - unsigned long numberOfParameters = transform->GetNumberOfParameters(); - ParametersType parameters(numberOfParameters); + const unsigned long numberOfParameters = transform->GetNumberOfParameters(); + ParametersType parameters(numberOfParameters); /** * Define N * N-D grid of spline coefficients by wrapping the @@ -620,7 +620,7 @@ itkBSplineDeformableTransformTest3() using CoefficientImageType = itk::Image; CoefficientImageType::Pointer coeffImage[SpaceDimension]; - unsigned int numberOfControlPoints = region.GetNumberOfPixels(); + const unsigned int numberOfControlPoints = region.GetNumberOfPixels(); CoefficientType * dataPointer = parameters.data_block(); for (unsigned int j = 0; j < SpaceDimension; ++j) { diff --git a/Modules/Core/Transform/test/itkBSplineDeformableTransformTest2.cxx b/Modules/Core/Transform/test/itkBSplineDeformableTransformTest2.cxx index 305feb34aa0..4e6f7212f7c 100644 --- a/Modules/Core/Transform/test/itkBSplineDeformableTransformTest2.cxx +++ b/Modules/Core/Transform/test/itkBSplineDeformableTransformTest2.cxx @@ -86,7 +86,7 @@ class BSplineDeformableTransformTest2Helper movingReader->SetFileName(argv[3]); - typename FixedImageType::ConstPointer fixedImage = fixedReader->GetOutput(); + const typename FixedImageType::ConstPointer fixedImage = fixedReader->GetOutput(); using FilterType = itk::ResampleImageFilter; @@ -99,17 +99,17 @@ class BSplineDeformableTransformTest2Helper resampler->SetInterpolator(interpolator); - typename FixedImageType::SpacingType fixedSpacing = fixedImage->GetSpacing(); - typename FixedImageType::PointType fixedOrigin = fixedImage->GetOrigin(); - typename FixedImageType::DirectionType fixedDirection = fixedImage->GetDirection(); + typename FixedImageType::SpacingType fixedSpacing = fixedImage->GetSpacing(); + typename FixedImageType::PointType fixedOrigin = fixedImage->GetOrigin(); + const typename FixedImageType::DirectionType fixedDirection = fixedImage->GetDirection(); resampler->SetOutputSpacing(fixedSpacing); resampler->SetOutputOrigin(fixedOrigin); resampler->SetOutputDirection(fixedDirection); - typename FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); - typename FixedImageType::SizeType fixedSize = fixedRegion.GetSize(); + const typename FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); + typename FixedImageType::SizeType fixedSize = fixedRegion.GetSize(); resampler->SetSize(fixedSize); resampler->SetOutputStartIndex(fixedRegion.GetIndex()); diff --git a/Modules/Core/Transform/test/itkBSplineDeformableTransformTest3.cxx b/Modules/Core/Transform/test/itkBSplineDeformableTransformTest3.cxx index f293b506f06..d4f78d6a599 100644 --- a/Modules/Core/Transform/test/itkBSplineDeformableTransformTest3.cxx +++ b/Modules/Core/Transform/test/itkBSplineDeformableTransformTest3.cxx @@ -87,7 +87,7 @@ class BSplineDeformableTransformTest3Helper movingReader->SetFileName(argv[3]); - typename FixedImageType::ConstPointer fixedImage = fixedReader->GetOutput(); + const typename FixedImageType::ConstPointer fixedImage = fixedReader->GetOutput(); using FilterType = itk::ResampleImageFilter; @@ -100,17 +100,17 @@ class BSplineDeformableTransformTest3Helper resampler->SetInterpolator(interpolator); - typename FixedImageType::SpacingType fixedSpacing = fixedImage->GetSpacing(); - typename FixedImageType::PointType fixedOrigin = fixedImage->GetOrigin(); - typename FixedImageType::DirectionType fixedDirection = fixedImage->GetDirection(); + typename FixedImageType::SpacingType fixedSpacing = fixedImage->GetSpacing(); + typename FixedImageType::PointType fixedOrigin = fixedImage->GetOrigin(); + const typename FixedImageType::DirectionType fixedDirection = fixedImage->GetDirection(); resampler->SetOutputSpacing(fixedSpacing); resampler->SetOutputOrigin(fixedOrigin); resampler->SetOutputDirection(fixedDirection); - typename FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); - typename FixedImageType::SizeType fixedSize = fixedRegion.GetSize(); + const typename FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); + typename FixedImageType::SizeType fixedSize = fixedRegion.GetSize(); resampler->SetSize(fixedSize); resampler->SetOutputStartIndex(fixedRegion.GetIndex()); diff --git a/Modules/Core/Transform/test/itkBSplineTransformGTest.cxx b/Modules/Core/Transform/test/itkBSplineTransformGTest.cxx index 21e328ea498..a5d390da022 100644 --- a/Modules/Core/Transform/test/itkBSplineTransformGTest.cxx +++ b/Modules/Core/Transform/test/itkBSplineTransformGTest.cxx @@ -59,8 +59,8 @@ bspline_eq(const itk::BSplineTransform; - typename ImageType::Pointer coeffImage1 = bspline1->GetCoefficientImages()[i]; - typename ImageType::Pointer coeffImage2 = bspline2->GetCoefficientImages()[i]; + const typename ImageType::Pointer coeffImage1 = bspline1->GetCoefficientImages()[i]; + const typename ImageType::Pointer coeffImage2 = bspline2->GetCoefficientImages()[i]; ITK_EXPECT_VECTOR_NEAR(coeffImage1->GetOrigin(), coeffImage2->GetOrigin(), tolerance) << description; EXPECT_EQ(coeffImage1->GetDirection(), coeffImage2->GetDirection()) << description; @@ -113,14 +113,14 @@ TEST(ITKBSplineTransform, Copying_Clone) ASSERT_EQ(coeffImageArray.Size(), 2); - SizeType imageSize = itk::MakeSize(10, 10); - DirectionType imageDirection; // filled with zeros + const SizeType imageSize = itk::MakeSize(10, 10); + DirectionType imageDirection; // filled with zeros imageDirection(0, 1) = -1; imageDirection(1, 0) = 1; - VectorType imageSpacing = itk::MakeVector(1.1, 1.2); + const VectorType imageSpacing = itk::MakeVector(1.1, 1.2); - PointType imageOrigin = itk::MakePoint(0.9, 0.8); + const PointType imageOrigin = itk::MakePoint(0.9, 0.8); coeffImageArray[0] = ImageType::New(); diff --git a/Modules/Core/Transform/test/itkBSplineTransformInitializerTest1.cxx b/Modules/Core/Transform/test/itkBSplineTransformInitializerTest1.cxx index 2fb881d330d..77f94c9774a 100644 --- a/Modules/Core/Transform/test/itkBSplineTransformInitializerTest1.cxx +++ b/Modules/Core/Transform/test/itkBSplineTransformInitializerTest1.cxx @@ -62,7 +62,7 @@ itkBSplineTransformInitializerTest1(int argc, char * argv[]) movingReader->SetFileName(argv[3]); - FixedImageType::ConstPointer fixedImage = fixedReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = fixedReader->GetOutput(); using FilterType = itk::ResampleImageFilter; @@ -74,16 +74,16 @@ itkBSplineTransformInitializerTest1(int argc, char * argv[]) resampler->SetInterpolator(interpolator); - FixedImageType::SpacingType fixedSpacing = fixedImage->GetSpacing(); - FixedImageType::PointType fixedOrigin = fixedImage->GetOrigin(); - FixedImageType::DirectionType fixedDirection = fixedImage->GetDirection(); + const FixedImageType::SpacingType fixedSpacing = fixedImage->GetSpacing(); + const FixedImageType::PointType fixedOrigin = fixedImage->GetOrigin(); + const FixedImageType::DirectionType fixedDirection = fixedImage->GetDirection(); resampler->SetOutputSpacing(fixedSpacing); resampler->SetOutputOrigin(fixedOrigin); resampler->SetOutputDirection(fixedDirection); - FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); - FixedImageType::SizeType fixedSize = fixedRegion.GetSize(); + const FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); + const FixedImageType::SizeType fixedSize = fixedRegion.GetSize(); resampler->SetSize(fixedSize); resampler->SetOutputStartIndex(fixedRegion.GetIndex()); diff --git a/Modules/Core/Transform/test/itkBSplineTransformInitializerTest2.cxx b/Modules/Core/Transform/test/itkBSplineTransformInitializerTest2.cxx index 2926e7a5c36..e9dcf28ca47 100644 --- a/Modules/Core/Transform/test/itkBSplineTransformInitializerTest2.cxx +++ b/Modules/Core/Transform/test/itkBSplineTransformInitializerTest2.cxx @@ -67,7 +67,7 @@ itkBSplineTransformInitializerTest2(int argc, char * argv[]) // We first use the passed fixed image to construct the control point // grid and save the control point locations. - FixedImageType::ConstPointer fixedImage = fixedReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = fixedReader->GetOutput(); const unsigned int SpaceDimension = ImageDimension; constexpr unsigned int SplineOrder = 3; diff --git a/Modules/Core/Transform/test/itkBSplineTransformTest.cxx b/Modules/Core/Transform/test/itkBSplineTransformTest.cxx index 97f449cecc6..2eae7bf587c 100644 --- a/Modules/Core/Transform/test/itkBSplineTransformTest.cxx +++ b/Modules/Core/Transform/test/itkBSplineTransformTest.cxx @@ -95,7 +95,7 @@ itkBSplineTransformTest1() } for (unsigned int i = 0; i < SpaceDimension; ++i) { - double delta = dimensions[i] / static_cast(meshSize[i]); + const double delta = dimensions[i] / static_cast(meshSize[i]); fixedParameters[fixedParametersCount++] = origin[i] - delta; } for (unsigned int i = 0; i < SpaceDimension; ++i) @@ -112,7 +112,7 @@ itkBSplineTransformTest1() std::cout << "Fixed parameters set: " << fixedParameters << std::endl; transform->SetFixedParameters(fixedParameters); - ParametersType returnedParameters = transform->GetFixedParameters(); + const ParametersType returnedParameters = transform->GetFixedParameters(); std::cout << "Fixed parameters returned: " << returnedParameters << std::endl; if (fixedParameters != returnedParameters) @@ -126,8 +126,8 @@ itkBSplineTransformTest1() /** * Allocate memory for the parameters */ - unsigned long numberOfParameters = transform->GetNumberOfParameters(); - ParametersType parameters(numberOfParameters); + const unsigned long numberOfParameters = transform->GetNumberOfParameters(); + ParametersType parameters(numberOfParameters); parameters.Fill(ParametersType::ValueType{}); /** @@ -163,7 +163,7 @@ itkBSplineTransformTest1() coeffImage[1]->SetPixel(index, 1.0); - unsigned long n = coeffImage[1]->ComputeOffset(index) + numberOfControlPoints; + const unsigned long n = coeffImage[1]->ComputeOffset(index) + numberOfControlPoints; /** * Set the parameters in the transform @@ -171,7 +171,7 @@ itkBSplineTransformTest1() transform->SetParameters(parameters); // outParametersCopy should make a copy of the parameters - ParametersType outParametersCopy = transform->GetParameters(); + const ParametersType outParametersCopy = transform->GetParameters(); /** * Transform some points @@ -251,10 +251,10 @@ itkBSplineTransformTest1() // cycling through all the parameters and weights used in the previous // transformation - unsigned int numberOfCoefficientInSupportRegion = TransformType::NumberOfWeights; - unsigned int numberOfParametersPerDimension = transform->GetNumberOfParametersPerDimension(); - unsigned int linearIndex; - unsigned int baseIndex; + const unsigned int numberOfCoefficientInSupportRegion = TransformType::NumberOfWeights; + const unsigned int numberOfParametersPerDimension = transform->GetNumberOfParametersPerDimension(); + unsigned int linearIndex; + unsigned int baseIndex; std::cout << "Index" << '\t' << "Value" << '\t' << "Weight" << std::endl; for (unsigned int j = 0; j < SpaceDimension; ++j) @@ -603,7 +603,7 @@ itkBSplineTransformTest3() */ using OriginType = TransformType::OriginType; - OriginType origin{}; + const OriginType origin{}; using PhysicalDimensionsType = TransformType::PhysicalDimensionsType; auto dimensions = itk::MakeFilled(100); @@ -630,8 +630,8 @@ itkBSplineTransformTest3() /** * Allocate memory for the parameters */ - unsigned long numberOfParameters = transform->GetNumberOfParameters(); - ParametersType parameters(numberOfParameters); + const unsigned long numberOfParameters = transform->GetNumberOfParameters(); + ParametersType parameters(numberOfParameters); parameters.Fill(ParametersType::ValueType{}); /** diff --git a/Modules/Core/Transform/test/itkBSplineTransformTest2.cxx b/Modules/Core/Transform/test/itkBSplineTransformTest2.cxx index ccab2f5b2e4..c8a5b4ede61 100644 --- a/Modules/Core/Transform/test/itkBSplineTransformTest2.cxx +++ b/Modules/Core/Transform/test/itkBSplineTransformTest2.cxx @@ -86,7 +86,7 @@ class BSplineTransformTest2Helper movingReader->SetFileName(argv[3]); - typename FixedImageType::ConstPointer fixedImage = fixedReader->GetOutput(); + const typename FixedImageType::ConstPointer fixedImage = fixedReader->GetOutput(); using FilterType = itk::ResampleImageFilter; @@ -99,17 +99,17 @@ class BSplineTransformTest2Helper resampler->SetInterpolator(interpolator); - typename FixedImageType::SpacingType fixedSpacing = fixedImage->GetSpacing(); - typename FixedImageType::PointType fixedOrigin = fixedImage->GetOrigin(); - typename FixedImageType::DirectionType fixedDirection = fixedImage->GetDirection(); + typename FixedImageType::SpacingType fixedSpacing = fixedImage->GetSpacing(); + const typename FixedImageType::PointType fixedOrigin = fixedImage->GetOrigin(); + const typename FixedImageType::DirectionType fixedDirection = fixedImage->GetDirection(); resampler->SetOutputSpacing(fixedSpacing); resampler->SetOutputOrigin(fixedOrigin); resampler->SetOutputDirection(fixedDirection); - typename FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); - typename FixedImageType::SizeType fixedSize = fixedRegion.GetSize(); + const typename FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); + typename FixedImageType::SizeType fixedSize = fixedRegion.GetSize(); resampler->SetSize(fixedSize); resampler->SetOutputStartIndex(fixedRegion.GetIndex()); diff --git a/Modules/Core/Transform/test/itkBSplineTransformTest3.cxx b/Modules/Core/Transform/test/itkBSplineTransformTest3.cxx index 655e0099535..2ef33944c34 100644 --- a/Modules/Core/Transform/test/itkBSplineTransformTest3.cxx +++ b/Modules/Core/Transform/test/itkBSplineTransformTest3.cxx @@ -86,7 +86,7 @@ class BSplineTransformTest3Helper movingReader->SetFileName(argv[3]); - typename FixedImageType::ConstPointer fixedImage = fixedReader->GetOutput(); + const typename FixedImageType::ConstPointer fixedImage = fixedReader->GetOutput(); using FilterType = itk::ResampleImageFilter; @@ -99,17 +99,17 @@ class BSplineTransformTest3Helper resampler->SetInterpolator(interpolator); - typename FixedImageType::SpacingType fixedSpacing = fixedImage->GetSpacing(); - typename FixedImageType::PointType fixedOrigin = fixedImage->GetOrigin(); - typename FixedImageType::DirectionType fixedDirection = fixedImage->GetDirection(); + typename FixedImageType::SpacingType fixedSpacing = fixedImage->GetSpacing(); + const typename FixedImageType::PointType fixedOrigin = fixedImage->GetOrigin(); + const typename FixedImageType::DirectionType fixedDirection = fixedImage->GetDirection(); resampler->SetOutputSpacing(fixedSpacing); resampler->SetOutputOrigin(fixedOrigin); resampler->SetOutputDirection(fixedDirection); - typename FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); - typename FixedImageType::SizeType fixedSize = fixedRegion.GetSize(); + const typename FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); + typename FixedImageType::SizeType fixedSize = fixedRegion.GetSize(); resampler->SetSize(fixedSize); resampler->SetOutputStartIndex(fixedRegion.GetIndex()); diff --git a/Modules/Core/Transform/test/itkCenteredAffineTransformTest.cxx b/Modules/Core/Transform/test/itkCenteredAffineTransformTest.cxx index c388a470a2f..bc8abe74488 100644 --- a/Modules/Core/Transform/test/itkCenteredAffineTransformTest.cxx +++ b/Modules/Core/Transform/test/itkCenteredAffineTransformTest.cxx @@ -210,7 +210,7 @@ itkCenteredAffineTransformTest(int, char *[]) std::cout << "Create an inverse transformation:" << std::endl; inv3->Print(std::cout); - Affine3DType::Pointer inv4 = dynamic_cast(aff3->GetInverseTransform().GetPointer()); + const Affine3DType::Pointer inv4 = dynamic_cast(aff3->GetInverseTransform().GetPointer()); if (!inv4) { std::cout << "Cannot compute inverse transformation" << std::endl; @@ -221,9 +221,9 @@ itkCenteredAffineTransformTest(int, char *[]) /* Create an image for testing index<->physical transforms */ std::cout << "Creating image for testing index<->physical transforms" << std::endl; - double spacing[3] = { 1.0, 2.0, 3.0 }; - double origin[3] = { 4.0, 5.0, 6.0 }; - itk::Image::Pointer image = itk::Image::New(); + double spacing[3] = { 1.0, 2.0, 3.0 }; + double origin[3] = { 4.0, 5.0, 6.0 }; + const itk::Image::Pointer image = itk::Image::New(); image->SetOrigin(origin); image->SetSpacing(spacing); @@ -259,6 +259,6 @@ itkCenteredAffineTransformTest(int, char *[]) std::cout << "A transform after SetParameters:" << std::endl; jaff->Print(std::cout); - int any = 0; // Any errors detected in testing? + const int any = 0; // Any errors detected in testing? return any; } diff --git a/Modules/Core/Transform/test/itkCenteredEuler3DTransformTest.cxx b/Modules/Core/Transform/test/itkCenteredEuler3DTransformTest.cxx index fd7cac6cf3f..98f050b1af8 100644 --- a/Modules/Core/Transform/test/itkCenteredEuler3DTransformTest.cxx +++ b/Modules/Core/Transform/test/itkCenteredEuler3DTransformTest.cxx @@ -67,7 +67,7 @@ itkCenteredEuler3DTransformTest(int, char *[]) // Rotate an itk::Point EulerTransformType::InputPointType::ValueType pInit[3] = { 10, -5, 3 }; - EulerTransformType::InputPointType p = pInit; + const EulerTransformType::InputPointType p = pInit; EulerTransformType::InputPointType q; itk::Matrix RotationX; @@ -132,7 +132,7 @@ itkCenteredEuler3DTransformTest(int, char *[]) eulerTransform->SetRotation(0, 0, 0); EulerTransformType::OffsetType::ValueType ioffsetInit[3] = { 1, -4, 8 }; - EulerTransformType::OffsetType ioffset = ioffsetInit; + const EulerTransformType::OffsetType ioffset = ioffsetInit; eulerTransform->SetOffset(ioffset); std::cout << "eulerTransform: " << eulerTransform; @@ -271,8 +271,8 @@ itkCenteredEuler3DTransformTest(int, char *[]) { for (unsigned int j = 0; j < 3; ++j) { - double approxDerivative = (plusPoint[j] - minusPoint[j]) / (2.0 * delta); - double computedDerivative = jacobian[j][k]; + const double approxDerivative = (plusPoint[j] - minusPoint[j]) / (2.0 * delta); + const double computedDerivative = jacobian[j][k]; approxJacobian[j][k] = approxDerivative; if (itk::Math::abs(approxDerivative - computedDerivative) > 1e-5) { @@ -376,7 +376,7 @@ itkCenteredEuler3DTransformTest(int, char *[]) (outputTestPoint[2] - testPoint[2]) * (outputTestPoint[2] - testPoint[2]); computeError = std::sqrt(computeError); - double errorTolerance = 0.001; + const double errorTolerance = 0.001; if (computeError > errorTolerance) { std::cout << " [ FAILED ] " << std::endl; diff --git a/Modules/Core/Transform/test/itkCenteredRigid2DTransformTest.cxx b/Modules/Core/Transform/test/itkCenteredRigid2DTransformTest.cxx index 48dbc8fe5bb..63aec93cc9b 100644 --- a/Modules/Core/Transform/test/itkCenteredRigid2DTransformTest.cxx +++ b/Modules/Core/Transform/test/itkCenteredRigid2DTransformTest.cxx @@ -65,9 +65,9 @@ itkCenteredRigid2DTransformTest(int, char *[]) transform->SetAngle(angle); // Rotate an itk::Point - CenteredRigidTransformType::InputPointType::ValueType pInit[2] = { 10, 10 }; - CenteredRigidTransformType::InputPointType p = pInit; - CenteredRigidTransformType::InputPointType q; + const CenteredRigidTransformType::InputPointType::ValueType pInit[2] = { 10, 10 }; + CenteredRigidTransformType::InputPointType p = pInit; + CenteredRigidTransformType::InputPointType q; q[0] = p[0] * costh - p[1] * sinth; q[1] = p[0] * sinth + p[1] * costh; @@ -98,7 +98,7 @@ itkCenteredRigid2DTransformTest(int, char *[]) transform->SetAngle(0); CenteredRigidTransformType::OffsetType::ValueType ioffsetInit[2] = { 1, 4 }; - CenteredRigidTransformType::OffsetType ioffset = ioffsetInit; + const CenteredRigidTransformType::OffsetType ioffset = ioffsetInit; transform->SetOffset(ioffset); @@ -179,7 +179,7 @@ itkCenteredRigid2DTransformTest(int, char *[]) } // Get inverse transform and transform point p2 to obtain point p3 - CenteredRigidTransformType::Pointer inversebis = + const CenteredRigidTransformType::Pointer inversebis = dynamic_cast(transform2->GetInverseTransform().GetPointer()); if (!inversebis) @@ -239,7 +239,7 @@ itkCenteredRigid2DTransformTest(int, char *[]) TransformType::Pointer t2; t1->CloneInverseTo(t2); - TransformType::InputPointType p3 = t2->TransformPoint(p2); + const TransformType::InputPointType p3 = t2->TransformPoint(p2); std::cout << "Test CloneInverseTo(): "; if (!CheckEqual(p1, p3)) @@ -275,7 +275,7 @@ itkCenteredRigid2DTransformTest(int, char *[]) TransformType::Pointer t3; t1->CloneTo(t3); - TransformType::InputPointType p4 = t3->TransformPoint(p1); + const TransformType::InputPointType p4 = t3->TransformPoint(p1); std::cout << "Test Clone(): "; if (!CheckEqual(p2, p4)) diff --git a/Modules/Core/Transform/test/itkComposeScaleSkewVersor3DTransformTest.cxx b/Modules/Core/Transform/test/itkComposeScaleSkewVersor3DTransformTest.cxx index 825bc589ad7..8fae81db839 100644 --- a/Modules/Core/Transform/test/itkComposeScaleSkewVersor3DTransformTest.cxx +++ b/Modules/Core/Transform/test/itkComposeScaleSkewVersor3DTransformTest.cxx @@ -64,7 +64,7 @@ itkComposeScaleSkewVersor3DTransformTest(int, char *[]) auto axis = itk::MakeFilled(1.5); - ValueType angle = 120.0 * std::atan(1.0) / 45.0; + const ValueType angle = 120.0 * std::atan(1.0) / 45.0; VersorType versor; versor.Set(axis, angle); @@ -96,8 +96,8 @@ itkComposeScaleSkewVersor3DTransformTest(int, char *[]) { std::cout << "Test initial rotation matrix " << std::endl; - auto transform = TransformType::New(); - MatrixType matrix = transform->GetMatrix(); + auto transform = TransformType::New(); + const MatrixType matrix = transform->GetMatrix(); std::cout << "Matrix = " << std::endl; std::cout << matrix << std::endl; } @@ -139,9 +139,9 @@ itkComposeScaleSkewVersor3DTransformTest(int, char *[]) { // Rotate an itk::Point - TransformType::InputPointType::ValueType pInit[3] = { 1, 4, 9 }; - TransformType::InputPointType p = pInit; - TransformType::OutputPointType q; + const TransformType::InputPointType::ValueType pInit[3] = { 1, 4, 9 }; + const TransformType::InputPointType p = pInit; + TransformType::OutputPointType q; q = versor.Transform(p); TransformType::OutputPointType r; @@ -170,7 +170,7 @@ itkComposeScaleSkewVersor3DTransformTest(int, char *[]) { // Translate an itk::Vector TransformType::InputVectorType::ValueType pInit[3] = { 1, 4, 9 }; - TransformType::InputVectorType p = pInit; + const TransformType::InputVectorType p = pInit; TransformType::OutputVectorType q; q = versor.Transform(p); @@ -200,7 +200,7 @@ itkComposeScaleSkewVersor3DTransformTest(int, char *[]) { // Translate an itk::CovariantVector TransformType::InputCovariantVectorType::ValueType pInit[3] = { 1, 4, 9 }; - TransformType::InputCovariantVectorType p = pInit; + const TransformType::InputCovariantVectorType p = pInit; TransformType::OutputCovariantVectorType q; q = versor.Transform(p); @@ -306,7 +306,7 @@ itkComposeScaleSkewVersor3DTransformTest(int, char *[]) ParametersType parameters(np); // Number of parameters parameters.Fill(0.0); - VersorType versor; + const VersorType versor; // TODO: Test jacobian with non-zero skew @@ -362,7 +362,7 @@ itkComposeScaleSkewVersor3DTransformTest(int, char *[]) ParametersType parameters(np); // Number of parameters - VersorType versor; + const VersorType versor; parameters[0] = versor.GetX(); // Rotation axis * sin(t/2) parameters[1] = versor.GetY(); @@ -569,7 +569,7 @@ itkComposeScaleSkewVersor3DTransformTest(int, char *[]) TransformType::InputPointType pnt2 = idT->TransformPoint(pnt); for (unsigned int d = 0; d < 3; ++d) { - double pntDiff = (pnt1[d] - pnt2[d]) / (2 * epsilon); + const double pntDiff = (pnt1[d] - pnt2[d]) / (2 * epsilon); if (itk::Math::abs(pntDiff - jacob[d][i]) > itk::Math::abs(0.1 * pntDiff)) { std::cout << "Ideal = " << pntDiff << " Jacob = " << jacob[d][i] << std::endl; diff --git a/Modules/Core/Transform/test/itkCompositeTransformTest.cxx b/Modules/Core/Transform/test/itkCompositeTransformTest.cxx index cbc73720b4d..68ae9b3b685 100644 --- a/Modules/Core/Transform/test/itkCompositeTransformTest.cxx +++ b/Modules/Core/Transform/test/itkCompositeTransformTest.cxx @@ -183,7 +183,7 @@ itkCompositeTransformTest(int, char *[]) /* Retrieve the transform and check that it's the same */ std::cout << "Retrieve 1st transform." << std::endl; - AffineType::ConstPointer affineGet = + const AffineType::ConstPointer affineGet = dynamic_cast(compositeTransform->GetNthTransformConstPointer(0)); if (affineGet.IsNull()) { @@ -192,8 +192,8 @@ itkCompositeTransformTest(int, char *[]) } std::cout << "Retrieve matrix and offset. " << std::endl; - Matrix2Type matrix2Get = affineGet->GetMatrix(); - Vector2Type vector2Get = affineGet->GetOffset(); + const Matrix2Type matrix2Get = affineGet->GetMatrix(); + const Vector2Type vector2Get = affineGet->GetOffset(); if (!testMatrix(matrix2, matrix2Get) || !testVectorArray(vector2, vector2Get)) { std::cout << "Failed retrieving correct transform data." << std::endl; @@ -388,7 +388,7 @@ itkCompositeTransformTest(int, char *[]) CompositeType::OutputVectorType compositeTruthVector = affine2->TransformVector(inputVector); compositeTruthVector = affine->TransformVector(compositeTruthVector); - CompositeType::OutputVectorType outputVector = compositeTransform->TransformVector(inputVector); + const CompositeType::OutputVectorType outputVector = compositeTransform->TransformVector(inputVector); std::cout << "Transform vector with two-component composite transform: " << std::endl << " Test vector: " << inputVector << std::endl << " Truth: " << compositeTruthVector << std::endl @@ -412,7 +412,8 @@ itkCompositeTransformTest(int, char *[]) inputTensor[5] = 1.0; CompositeType::OutputDiffusionTensor3DType compositeTruthTensor = affine2->TransformDiffusionTensor3D(inputTensor); compositeTruthTensor = affine->TransformDiffusionTensor3D(compositeTruthTensor); - CompositeType::OutputDiffusionTensor3DType outputTensor = compositeTransform->TransformDiffusionTensor3D(inputTensor); + const CompositeType::OutputDiffusionTensor3DType outputTensor = + compositeTransform->TransformDiffusionTensor3D(inputTensor); std::cout << "Transform tensor with two-component composite transform: " << std::endl << " Test tensor: " << inputTensor << std::endl << " Truth: " << compositeTruthTensor << std::endl @@ -426,7 +427,7 @@ itkCompositeTransformTest(int, char *[]) CompositeType::OutputSymmetricSecondRankTensorType compositeTruthSTensor = affine2->TransformSymmetricSecondRankTensor(inputSTensor); compositeTruthSTensor = affine->TransformSymmetricSecondRankTensor(compositeTruthSTensor); - CompositeType::OutputSymmetricSecondRankTensorType outputSTensor = + const CompositeType::OutputSymmetricSecondRankTensorType outputSTensor = compositeTransform->TransformSymmetricSecondRankTensor(inputSTensor); std::cout << "Transform tensor with two-component composite transform: " << std::endl << " Test tensor: " << inputSTensor << std::endl @@ -468,7 +469,7 @@ itkCompositeTransformTest(int, char *[]) /* Get inverse transform again, but using other accessor. */ std::cout << "Call GetInverseTransform():" << std::endl; - CompositeType::ConstPointer inverseTransform2 = + const CompositeType::ConstPointer inverseTransform2 = dynamic_cast(compositeTransform->GetInverseTransform().GetPointer()); if (!inverseTransform2) { @@ -501,9 +502,9 @@ itkCompositeTransformTest(int, char *[]) /* Test GetNumberOfParameters */ std::cout << "GetNumberOfParameters: " << std::endl; - unsigned int affineParamsN = affine->GetNumberOfParameters(); - unsigned int affine2ParamsN = affine2->GetNumberOfParameters(); - unsigned int nParameters = compositeTransform->GetNumberOfParameters(); + unsigned int affineParamsN = affine->GetNumberOfParameters(); + unsigned int affine2ParamsN = affine2->GetNumberOfParameters(); + const unsigned int nParameters = compositeTransform->GetNumberOfParameters(); std::cout << "Number of parameters: " << nParameters << std::endl; if (nParameters != affineParamsN + affine2ParamsN) { @@ -645,7 +646,7 @@ itkCompositeTransformTest(int, char *[]) } /* Test accessors */ - CompositeType::TransformQueueType transformQueue = compositeTransform->GetTransformQueue(); + const CompositeType::TransformQueueType transformQueue = compositeTransform->GetTransformQueue(); if (transformQueue.size() != 3) { std::cout << "Failed getting transform queue." << std::endl; @@ -653,7 +654,7 @@ itkCompositeTransformTest(int, char *[]) } std::cout << "Got TransformQueue." << std::endl; - CompositeType::TransformsToOptimizeFlagsType flagsQueue = compositeTransform->GetTransformsToOptimizeFlags(); + const CompositeType::TransformsToOptimizeFlagsType flagsQueue = compositeTransform->GetTransformsToOptimizeFlags(); if (flagsQueue.size() != 3) { std::cout << "Failed getting optimize flags queue." << std::endl; @@ -661,7 +662,7 @@ itkCompositeTransformTest(int, char *[]) } /* Get inverse and check TransformsToOptimize flags are correct */ - CompositeType::ConstPointer inverseTransform3 = + const CompositeType::ConstPointer inverseTransform3 = dynamic_cast(compositeTransform->GetInverseTransform().GetPointer()); if (!inverseTransform3) { @@ -692,7 +693,7 @@ itkCompositeTransformTest(int, char *[]) parametersTest = compositeTransform->GetParameters(); affineParamsN = affine->GetNumberOfParameters(); - unsigned int affine3ParamsN = affine3->GetNumberOfParameters(); + const unsigned int affine3ParamsN = affine3->GetNumberOfParameters(); parametersTruth.SetSize(affineParamsN + affine3ParamsN); for (unsigned int n = 0; n < affine3ParamsN; ++n) { @@ -771,7 +772,7 @@ itkCompositeTransformTest(int, char *[]) compositeTransform->SetNthTransformToOptimizeOff(1); truth = compositeTransform->GetParameters(); update.SetSize(compositeTransform->GetNumberOfParameters()); - AffineType::ScalarType factor = 0.5; + const AffineType::ScalarType factor = 0.5; for (unsigned int i = 0; i < compositeTransform->GetNumberOfParameters(); ++i) { update[i] = i; @@ -790,8 +791,8 @@ itkCompositeTransformTest(int, char *[]) } /* Test RemoveTransform */ - bool opt1 = compositeTransform->GetTransformsToOptimizeFlags()[0]; - bool opt2 = compositeTransform->GetTransformsToOptimizeFlags()[1]; + const bool opt1 = compositeTransform->GetTransformsToOptimizeFlags()[0]; + const bool opt2 = compositeTransform->GetTransformsToOptimizeFlags()[1]; compositeTransform->RemoveTransform(); if (compositeTransform->GetNumberOfTransforms() != 2) { diff --git a/Modules/Core/Transform/test/itkEuler2DTransformTest.cxx b/Modules/Core/Transform/test/itkEuler2DTransformTest.cxx index 5de8398584a..48330a7f6e1 100644 --- a/Modules/Core/Transform/test/itkEuler2DTransformTest.cxx +++ b/Modules/Core/Transform/test/itkEuler2DTransformTest.cxx @@ -79,9 +79,9 @@ itkEuler2DTransformTest(int, char *[]) eulerTransform->SetRotation(angle); // Rotate an itk::Point - EulerTransformType::InputPointType::ValueType pInit[2] = { 10, 10 }; - EulerTransformType::InputPointType p = pInit; - EulerTransformType::InputPointType q; + const EulerTransformType::InputPointType::ValueType pInit[2] = { 10, 10 }; + EulerTransformType::InputPointType p = pInit; + EulerTransformType::InputPointType q; q[0] = p[0] * costh - p[1] * sinth; q[1] = p[0] * sinth + p[1] * costh; @@ -113,7 +113,7 @@ itkEuler2DTransformTest(int, char *[]) eulerTransform->SetRotation(0); EulerTransformType::OffsetType::ValueType ioffsetInit[2] = { 1, 4 }; - EulerTransformType::OffsetType ioffset = ioffsetInit; + const EulerTransformType::OffsetType ioffset = ioffsetInit; eulerTransform->SetOffset(ioffset); @@ -320,8 +320,8 @@ itkEuler2DTransformTest(int, char *[]) minusPoint = t4->TransformPoint(p1); for (unsigned int j = 0; j < 2; ++j) { - double approxDerivative = (plusPoint[j] - minusPoint[j]) / (2.0 * delta); - double computedDerivative = jacobian2[j][k]; + const double approxDerivative = (plusPoint[j] - minusPoint[j]) / (2.0 * delta); + const double computedDerivative = jacobian2[j][k]; approxJacobian[j][k] = approxDerivative; if (itk::Math::abs(approxDerivative - computedDerivative) > 1e-4) { @@ -367,8 +367,8 @@ itkEuler2DTransformTest(int, char *[]) ip[0] = 8.0; ip[1] = 9.0; - TransformType::OutputPointType op1 = t1->TransformPoint(ip); - TransformType::OutputPointType op2 = t23->TransformPoint(ip); + const TransformType::OutputPointType op1 = t1->TransformPoint(ip); + const TransformType::OutputPointType op2 = t23->TransformPoint(ip); std::cout << "Test Set/GetMatrix() and Set/GetOffset(): "; if (!CheckEqual(op1, op2)) diff --git a/Modules/Core/Transform/test/itkEuler3DTransformTest.cxx b/Modules/Core/Transform/test/itkEuler3DTransformTest.cxx index 92e28d7a8d0..489ebe28121 100644 --- a/Modules/Core/Transform/test/itkEuler3DTransformTest.cxx +++ b/Modules/Core/Transform/test/itkEuler3DTransformTest.cxx @@ -67,7 +67,7 @@ itkEuler3DTransformTest(int, char *[]) // Rotate an itk::Point EulerTransformType::InputPointType::ValueType pInit[3] = { 10, -5, 3 }; - EulerTransformType::InputPointType p = pInit; + const EulerTransformType::InputPointType p = pInit; EulerTransformType::InputPointType q; itk::Matrix RotationX; @@ -165,7 +165,7 @@ itkEuler3DTransformTest(int, char *[]) eulerTransform->SetRotation(0, 0, 0); EulerTransformType::OffsetType::ValueType ioffsetInit[3] = { 1, -4, 8 }; - EulerTransformType::OffsetType ioffset = ioffsetInit; + const EulerTransformType::OffsetType ioffset = ioffsetInit; eulerTransform->SetOffset(ioffset); std::cout << "eulerTransform: " << eulerTransform; @@ -311,8 +311,8 @@ itkEuler3DTransformTest(int, char *[]) minusPoint = eulerTransform->TransformPoint(pInit); for (unsigned int j = 0; j < 3; ++j) { - double approxDerivative = (plusPoint[j] - minusPoint[j]) / (2.0 * delta); - double computedDerivative = jacobian[j][k]; + const double approxDerivative = (plusPoint[j] - minusPoint[j]) / (2.0 * delta); + const double computedDerivative = jacobian[j][k]; approxJacobian[j][k] = approxDerivative; if (itk::Math::abs(approxDerivative - computedDerivative) > 1e-5) { @@ -411,7 +411,7 @@ itkEuler3DTransformTest(int, char *[]) // attempt to set an orthogonal matrix matrix.GetVnlMatrix().set_identity(); - double a = 1.0 / 180.0 * itk::Math::pi; + const double a = 1.0 / 180.0 * itk::Math::pi; matrix[0][0] = std::cos(a); matrix[0][1] = -1.0 * std::sin(a); matrix[1][0] = std::sin(a); diff --git a/Modules/Core/Transform/test/itkFixedCenterOfRotationAffineTransformTest.cxx b/Modules/Core/Transform/test/itkFixedCenterOfRotationAffineTransformTest.cxx index d09f3bc1d09..7e45bf459b1 100644 --- a/Modules/Core/Transform/test/itkFixedCenterOfRotationAffineTransformTest.cxx +++ b/Modules/Core/Transform/test/itkFixedCenterOfRotationAffineTransformTest.cxx @@ -28,7 +28,7 @@ itkFixedCenterOfRotationAffineTransformTest(int, char *[]) using FCoRAffine2DType = itk::FixedCenterOfRotationAffineTransform; using FAffine2DType = itk::AffineTransform; FCoRAffine2DType::MatrixType matrix2; - FAffine2DType::Pointer inverse2; + const FAffine2DType::Pointer inverse2; FCoRAffine2DType::InputVectorType vector2; FCoRAffine2DType::InputPointType point2; @@ -115,7 +115,7 @@ itkFixedCenterOfRotationAffineTransformTest(int, char *[]) ITK_TEST_EXPECT_EQUAL(scale1[i], scale3[i]); } - typename FCoRAffine2DType::InputVectorType vScale = itk::MakeVector(2.0, 4.0); + const typename FCoRAffine2DType::InputVectorType vScale = itk::MakeVector(2.0, 4.0); aff2->SetScaleComponent(vScale); ITK_TEST_SET_GET_VALUE(vScale, aff2->GetScaleComponent()); @@ -200,7 +200,7 @@ itkFixedCenterOfRotationAffineTransformTest(int, char *[]) point[0] = 1; point[1] = 2; - FCoRAffine2DType::InputPointType transformedPoint = aff2->TransformPoint(point); + const FCoRAffine2DType::InputPointType transformedPoint = aff2->TransformPoint(point); FCoRAffine2DType::InputPointType expectedPoint; diff --git a/Modules/Core/Transform/test/itkIdentityTransformTest.cxx b/Modules/Core/Transform/test/itkIdentityTransformTest.cxx index b3310cd4e08..a32c26ffa6f 100644 --- a/Modules/Core/Transform/test/itkIdentityTransformTest.cxx +++ b/Modules/Core/Transform/test/itkIdentityTransformTest.cxx @@ -138,7 +138,7 @@ itkIdentityTransformTest(int, char *[]) std::cout << " [ PASSED ] " << std::endl; } - IdentityTransformType::ParametersType params(0); + const IdentityTransformType::ParametersType params(0); transform->SetParameters(params); ITK_TEST_SET_GET_VALUE(params, transform->GetParameters()); diff --git a/Modules/Core/Transform/test/itkMultiTransformTest.cxx b/Modules/Core/Transform/test/itkMultiTransformTest.cxx index ca8b89b1bcb..4df9537f799 100644 --- a/Modules/Core/Transform/test/itkMultiTransformTest.cxx +++ b/Modules/Core/Transform/test/itkMultiTransformTest.cxx @@ -177,7 +177,8 @@ itkMultiTransformTest(int, char *[]) /* Retrieve the transform and check that it's the same */ std::cout << "Retrieve 1st transform." << std::endl; - AffineType::ConstPointer affineGet = dynamic_cast(multiTransform->GetNthTransformConstPointer(0)); + const AffineType::ConstPointer affineGet = + dynamic_cast(multiTransform->GetNthTransformConstPointer(0)); if (affineGet.IsNull()) { std::cout << "Failed retrieving transform from queue." << std::endl; @@ -185,8 +186,8 @@ itkMultiTransformTest(int, char *[]) } std::cout << "Retrieve matrix and offset. " << std::endl; - Matrix2Type matrix2Get = affineGet->GetMatrix(); - Vector2Type vector2Get = affineGet->GetOffset(); + const Matrix2Type matrix2Get = affineGet->GetMatrix(); + const Vector2Type vector2Get = affineGet->GetOffset(); if (!testMatrix(matrix2, matrix2Get) || !testVectorArray(vector2, vector2Get)) { std::cout << "Failed retrieving correct transform data." << std::endl; @@ -324,10 +325,10 @@ itkMultiTransformTest(int, char *[]) auto field = FieldType::New(); // This is based on itk::Image - int dimLength = 4; - auto size = itk::MakeFilled(dimLength); - FieldType::IndexType start{}; - FieldType::RegionType region; + const int dimLength = 4; + auto size = itk::MakeFilled(dimLength); + const FieldType::IndexType start{}; + FieldType::RegionType region; region.SetSize(size); region.SetIndex(start); field->SetRegions(region); @@ -418,9 +419,9 @@ itkMultiTransformTest(int, char *[]) /* Test GetNumberOfParameters */ std::cout << "GetNumberOfParameters: " << std::endl; - unsigned int affineParamsN = affine->GetNumberOfParameters(); - unsigned int displacementParamsN = displacementTransform->GetNumberOfParameters(); - unsigned int nParameters = multiTransform->GetNumberOfParameters(); + unsigned int affineParamsN = affine->GetNumberOfParameters(); + unsigned int displacementParamsN = displacementTransform->GetNumberOfParameters(); + const unsigned int nParameters = multiTransform->GetNumberOfParameters(); std::cout << "Number of parameters: " << nParameters << std::endl; if (nParameters != affineParamsN + displacementParamsN) { @@ -430,9 +431,9 @@ itkMultiTransformTest(int, char *[]) /* Test GetNumberOfLocalParameters */ std::cout << "GetNumberOfLocalParameters: " << std::endl; - unsigned int affineLocalParamsN = affine->GetNumberOfLocalParameters(); - unsigned int displacementLocalParamsN = displacementTransform->GetNumberOfLocalParameters(); - unsigned int nLocalParameters = multiTransform->GetNumberOfLocalParameters(); + const unsigned int affineLocalParamsN = affine->GetNumberOfLocalParameters(); + const unsigned int displacementLocalParamsN = displacementTransform->GetNumberOfLocalParameters(); + const unsigned int nLocalParameters = multiTransform->GetNumberOfLocalParameters(); std::cout << "Number of local parameters: " << nParameters << std::endl; if (nLocalParameters != affineLocalParamsN + displacementLocalParamsN) { @@ -532,9 +533,9 @@ itkMultiTransformTest(int, char *[]) /* Test GetNumberOfFixedParameters */ std::cout << "GetNumberOfFixedParameters: " << std::endl; - unsigned int affineFixedParamsN = affine->GetFixedParameters().size(); - unsigned int displacementFixedParamsN = displacementTransform->GetFixedParameters().size(); - unsigned int nFixedParameters = multiTransform->GetNumberOfFixedParameters(); + const unsigned int affineFixedParamsN = affine->GetFixedParameters().size(); + const unsigned int displacementFixedParamsN = displacementTransform->GetFixedParameters().size(); + const unsigned int nFixedParameters = multiTransform->GetNumberOfFixedParameters(); std::cout << "Number of Fixed parameters: " << nParameters << std::endl; if (nFixedParameters != affineFixedParamsN + displacementFixedParamsN) { @@ -562,7 +563,7 @@ itkMultiTransformTest(int, char *[]) affine->SetOffset(vector2); /* Test accessors */ - Superclass::TransformQueueType transformQueue = multiTransform->GetTransformQueue(); + const Superclass::TransformQueueType transformQueue = multiTransform->GetTransformQueue(); if (transformQueue.size() != 3) { std::cout << "Failed getting transform queue." << std::endl; @@ -589,10 +590,10 @@ itkMultiTransformTest(int, char *[]) Superclass::ParametersType truth = multiTransform->GetParameters(); Superclass::DerivativeType update(multiTransform->GetNumberOfParameters()); update.Fill(10.0); - AffineType::ScalarType factor = 0.5; + const AffineType::ScalarType factor = 0.5; truth += update * factor; multiTransform->UpdateTransformParameters(update, factor); - Superclass::ParametersType updateResult = multiTransform->GetParameters(); + const Superclass::ParametersType updateResult = multiTransform->GetParameters(); if (!testVectorArray(truth, updateResult)) { std::cout << "UpdateTransformParameters 1 failed. " << std::endl diff --git a/Modules/Core/Transform/test/itkQuaternionRigidTransformTest.cxx b/Modules/Core/Transform/test/itkQuaternionRigidTransformTest.cxx index c4d38ec5282..40cfdedaa68 100644 --- a/Modules/Core/Transform/test/itkQuaternionRigidTransformTest.cxx +++ b/Modules/Core/Transform/test/itkQuaternionRigidTransformTest.cxx @@ -84,9 +84,9 @@ itkQuaternionRigidTransformTest(int, char *[]) { // Translate an itk::Point - TransformType::InputPointType::ValueType pInit[3] = { 10, 10, 10 }; - TransformType::InputPointType p = pInit; - TransformType::InputPointType q; + const TransformType::InputPointType::ValueType pInit[3] = { 10, 10, 10 }; + const TransformType::InputPointType p = pInit; + TransformType::InputPointType q; q = p + itransVector; TransformType::OutputPointType r; r = translation->TransformPoint(p); @@ -265,9 +265,9 @@ itkQuaternionRigidTransformTest(int, char *[]) { // Rotate an itk::Point - TransformType::InputPointType::ValueType pInit[3] = { 10, 10, 10 }; - TransformType::InputPointType p = pInit; - TransformType::InputPointType q; + const TransformType::InputPointType::ValueType pInit[3] = { 10, 10, 10 }; + TransformType::InputPointType p = pInit; + TransformType::InputPointType q; q[0] = p[0] * costh - p[1] * sinth; q[1] = p[0] * sinth + p[1] * costh; @@ -408,7 +408,7 @@ itkQuaternionRigidTransformTest(int, char *[]) parameters.Fill(0.0); - double angle = 0.62 / 180.0 * itk::Math::pi; + const double angle = 0.62 / 180.0 * itk::Math::pi; parameters[0] = 2.0 * std::sin(0.5 * angle); parameters[1] = 5.0 * std::sin(0.5 * angle); @@ -450,8 +450,8 @@ itkQuaternionRigidTransformTest(int, char *[]) minusPoint = quaternionRigid->TransformPoint(pInit); for (unsigned int j = 0; j < 3; ++j) { - double approxDerivative = (plusPoint[j] - minusPoint[j]) / (2.0 * delta); - double computedDerivative = jacobian[j][k]; + const double approxDerivative = (plusPoint[j] - minusPoint[j]) / (2.0 * delta); + const double computedDerivative = jacobian[j][k]; approxJacobian[j][k] = approxDerivative; if (itk::Math::abs(approxDerivative - computedDerivative) > 1e-5) { @@ -600,9 +600,9 @@ itkQuaternionRigidTransformTest(int, char *[]) { // Rotate an itk::Point - TransformType::InputPointType::ValueType pInit[3] = { 10, 10, 10 }; - TransformType::InputPointType p = pInit; - TransformType::InputPointType q; + const TransformType::InputPointType::ValueType pInit[3] = { 10, 10, 10 }; + TransformType::InputPointType p = pInit; + TransformType::InputPointType q; const CoordinateType x = p[0] - center[0]; const CoordinateType y = p[1] - center[1]; @@ -789,7 +789,7 @@ itkQuaternionRigidTransformTest(int, char *[]) // attempt to set an orthogonal matrix matrix.GetVnlMatrix().set_identity(); - double a = 1.0 / 180.0 * itk::Math::pi; + const double a = 1.0 / 180.0 * itk::Math::pi; matrix[0][0] = std::cos(a); matrix[0][1] = -1.0 * std::sin(a); matrix[1][0] = std::sin(a); diff --git a/Modules/Core/Transform/test/itkRigid2DTransformTest.cxx b/Modules/Core/Transform/test/itkRigid2DTransformTest.cxx index cc600bedc4e..9d758d2e407 100644 --- a/Modules/Core/Transform/test/itkRigid2DTransformTest.cxx +++ b/Modules/Core/Transform/test/itkRigid2DTransformTest.cxx @@ -124,10 +124,10 @@ itkRigid2DTransformTest(int, char *[]) { // Translate an itk::Point - TransformType::InputPointType::ValueType pInit[2] = { 10, 10 }; - TransformType::InputPointType p = pInit; - TransformType::InputPointType q = p + ioffset; - TransformType::OutputPointType r = translation->TransformPoint(p); + const TransformType::InputPointType::ValueType pInit[2] = { 10, 10 }; + const TransformType::InputPointType p = pInit; + TransformType::InputPointType q = p + ioffset; + TransformType::OutputPointType r = translation->TransformPoint(p); for (unsigned int i = 0; i < N; ++i) { if (itk::Math::abs(q[i] - r[i]) > epsilon) @@ -331,9 +331,9 @@ itkRigid2DTransformTest(int, char *[]) { // Rotate an itk::Point - TransformType::InputPointType::ValueType pInit[2] = { 10, 10 }; - TransformType::InputPointType p = pInit; - TransformType::InputPointType q; + const TransformType::InputPointType::ValueType pInit[2] = { 10, 10 }; + TransformType::InputPointType p = pInit; + TransformType::InputPointType q; q[0] = p[0] * costh + p[1] * sinth; q[1] = -p[0] * sinth + p[1] * costh; @@ -486,7 +486,7 @@ itkRigid2DTransformTest(int, char *[]) TransformType::Pointer t2; t1->CloneInverseTo(t2); - TransformType::InputPointType p3 = t2->TransformPoint(p2); + const TransformType::InputPointType p3 = t2->TransformPoint(p2); std::cout << "Test CloneInverseTo(): "; if (!CheckEqual(p1, p3)) @@ -523,7 +523,7 @@ itkRigid2DTransformTest(int, char *[]) TransformType::Pointer t3; t1->CloneTo(t3); - TransformType::InputPointType p4 = t3->TransformPoint(p1); + const TransformType::InputPointType p4 = t3->TransformPoint(p1); std::cout << "Test Clone(): "; if (!CheckEqual(p2, p4)) diff --git a/Modules/Core/Transform/test/itkRigid3DPerspectiveTransformTest.cxx b/Modules/Core/Transform/test/itkRigid3DPerspectiveTransformTest.cxx index ad2fecfa1a2..f10d26ce3aa 100644 --- a/Modules/Core/Transform/test/itkRigid3DPerspectiveTransformTest.cxx +++ b/Modules/Core/Transform/test/itkRigid3DPerspectiveTransformTest.cxx @@ -39,7 +39,7 @@ itkRigid3DPerspectiveTransformTest(int, char *[]) { auto transform = TransformType::New(); - typename TransformType::InputVectorType vector = itk::MakeVector(1.0, 4.0, 9.0); + const typename TransformType::InputVectorType vector = itk::MakeVector(1.0, 4.0, 9.0); ITK_TRY_EXPECT_EXCEPTION(transform->TransformVector(vector)); typename TransformType::InputVnlVectorType vnlVector; @@ -61,12 +61,12 @@ itkRigid3DPerspectiveTransformTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(transform, Rigid3DPerspectiveTransform, Transform); - typename TransformType::OffsetType fixedOffset{}; + const typename TransformType::OffsetType fixedOffset{}; transform->SetFixedOffset(fixedOffset); ITK_TEST_SET_GET_VALUE(fixedOffset, transform->GetFixedOffset()); - typename TransformType::InputPointType centerOfRotation{}; + const typename TransformType::InputPointType centerOfRotation{}; transform->SetCenterOfRotation(centerOfRotation); ITK_TEST_SET_GET_VALUE(centerOfRotation, transform->GetCenterOfRotation()); @@ -165,18 +165,18 @@ itkRigid3DPerspectiveTransformTest(int, char *[]) auto rigid = TransformType::New(); rigid->SetFocalDistance(focal); - TransformType::OffsetType ioffset{}; + const TransformType::OffsetType ioffset{}; rigid->SetOffset(ioffset); - TransformType::OffsetType offset = rigid->GetOffset(); + const TransformType::OffsetType offset = rigid->GetOffset(); std::cout << "pure Translation test: "; std::cout << offset << std::endl; using VersorType = TransformType::VersorType; - VersorType rotation; - VersorType::VectorType axis; - VersorType::ValueType angle = 30.0f * std::atan(1.0f) / 45.0f; + VersorType rotation; + VersorType::VectorType axis; + const VersorType::ValueType angle = 30.0f * std::atan(1.0f) / 45.0f; axis[0] = 1.0f; axis[1] = 1.0f; axis[2] = 1.0f; diff --git a/Modules/Core/Transform/test/itkRigid3DTransformTest.cxx b/Modules/Core/Transform/test/itkRigid3DTransformTest.cxx index 610474fb23e..d927bde39eb 100644 --- a/Modules/Core/Transform/test/itkRigid3DTransformTest.cxx +++ b/Modules/Core/Transform/test/itkRigid3DTransformTest.cxx @@ -182,9 +182,9 @@ itkRigid3DTransformTest(int, char *[]) { // Translate an itk::Point - TransformType::InputPointType::ValueType pInit[3] = { 10, 10, 10 }; - TransformType::InputPointType p = pInit; - TransformType::InputPointType q; + const TransformType::InputPointType::ValueType pInit[3] = { 10, 10, 10 }; + const TransformType::InputPointType p = pInit; + TransformType::InputPointType q; q = p + ioffset; TransformType::OutputPointType r; r = translation->TransformPoint(p); @@ -358,9 +358,9 @@ itkRigid3DTransformTest(int, char *[]) { // Rotate an itk::Point - TransformType::InputPointType::ValueType pInit[3] = { 10, 10, 10 }; - TransformType::InputPointType p = pInit; - TransformType::InputPointType q; + const TransformType::InputPointType::ValueType pInit[3] = { 10, 10, 10 }; + TransformType::InputPointType p = pInit; + TransformType::InputPointType q; q[0] = p[0] * costh + p[1] * sinth; q[1] = -p[0] * sinth + p[1] * costh; @@ -533,7 +533,7 @@ itkRigid3DTransformTest(int, char *[]) MatrixType matrix; matrix.GetVnlMatrix().set_identity(); - double a = 1.0 / 180.0 * itk::Math::pi; + const double a = 1.0 / 180.0 * itk::Math::pi; matrix[0][0] = std::cos(a); matrix[0][1] = std::sin(a); matrix[1][0] = -1.0 * std::sin(a); @@ -680,7 +680,7 @@ itkRigid3DTransformTest(int, char *[]) // attempt to set an orthogonal matrix matrix.GetVnlMatrix().set_identity(); - double a = 1.0 / 180.0 * itk::Math::pi; + const double a = 1.0 / 180.0 * itk::Math::pi; matrix[0][0] = std::cos(a); matrix[0][1] = std::sin(a); matrix[1][0] = -1.0 * std::sin(a); @@ -707,7 +707,7 @@ itkRigid3DTransformTest(int, char *[]) std::cerr << "Error: caught unexpected exception" << std::endl; return EXIT_FAILURE; } - bool TranslationSettingOK = TestSettingTranslation(); + const bool TranslationSettingOK = TestSettingTranslation(); if (!TranslationSettingOK) { std::cerr << "Error: SetTranslation() did not result in consistent internal state for Rigid3DTransform." @@ -754,7 +754,7 @@ itkRigid3DTransformTest(int, char *[]) mrotation[1][1] = costh; transform->SetMatrix(mrotation); - TransformType::OffsetType ioffset{}; + const TransformType::OffsetType ioffset{}; transform->SetOffset(ioffset); hasInverse = transform->GetInverse(inverse); diff --git a/Modules/Core/Transform/test/itkScaleLogarithmicTransformTest.cxx b/Modules/Core/Transform/test/itkScaleLogarithmicTransformTest.cxx index ae840d60691..a898467b31c 100644 --- a/Modules/Core/Transform/test/itkScaleLogarithmicTransformTest.cxx +++ b/Modules/Core/Transform/test/itkScaleLogarithmicTransformTest.cxx @@ -95,9 +95,9 @@ itkScaleLogarithmicTransformTest(int, char *[]) { // scale an itk::Point - TransformType::InputPointType::ValueType pInit[3] = { 10, 10, 10 }; - TransformType::InputPointType p = pInit; - TransformType::InputPointType q; + const TransformType::InputPointType::ValueType pInit[3] = { 10, 10, 10 }; + TransformType::InputPointType p = pInit; + TransformType::InputPointType q; for (unsigned int j = 0; j < N; ++j) { q[j] = p[j] * iscale[j]; @@ -231,7 +231,7 @@ itkScaleLogarithmicTransformTest(int, char *[]) scaleTransform->SetCenter(center); - CenterType c2 = scaleTransform->GetCenter(); + const CenterType c2 = scaleTransform->GetCenter(); if (c2.EuclideanDistanceTo(center) > 1e-5) { std::cerr << "Error in Set/Get center." << std::endl; diff --git a/Modules/Core/Transform/test/itkScaleSkewVersor3DTransformTest.cxx b/Modules/Core/Transform/test/itkScaleSkewVersor3DTransformTest.cxx index 96651bdd690..2ba1cdb63c7 100644 --- a/Modules/Core/Transform/test/itkScaleSkewVersor3DTransformTest.cxx +++ b/Modules/Core/Transform/test/itkScaleSkewVersor3DTransformTest.cxx @@ -70,7 +70,7 @@ itkScaleSkewVersor3DTransformTest(int, char *[]) auto axis = itk::MakeFilled(1.5); - ValueType angle = 120.0 * std::atan(1.0) / 45.0; + const ValueType angle = 120.0 * std::atan(1.0) / 45.0; VersorType versor; versor.Set(axis, angle); @@ -99,8 +99,8 @@ itkScaleSkewVersor3DTransformTest(int, char *[]) { std::cout << "Test initial rotation matrix " << std::endl; - auto transform = TransformType::New(); - MatrixType matrix = transform->GetMatrix(); + auto transform = TransformType::New(); + const MatrixType matrix = transform->GetMatrix(); std::cout << "Matrix = " << std::endl; std::cout << matrix << std::endl; } @@ -142,9 +142,9 @@ itkScaleSkewVersor3DTransformTest(int, char *[]) { // Rotate an itk::Point - TransformType::InputPointType::ValueType pInit[3] = { 1, 4, 9 }; - TransformType::InputPointType p = pInit; - TransformType::OutputPointType q; + const TransformType::InputPointType::ValueType pInit[3] = { 1, 4, 9 }; + const TransformType::InputPointType p = pInit; + TransformType::OutputPointType q; q = versor.Transform(p); TransformType::OutputPointType r; @@ -173,7 +173,7 @@ itkScaleSkewVersor3DTransformTest(int, char *[]) { // Translate an itk::Vector TransformType::InputVectorType::ValueType pInit[3] = { 1, 4, 9 }; - TransformType::InputVectorType p = pInit; + const TransformType::InputVectorType p = pInit; TransformType::OutputVectorType q; q = versor.Transform(p); @@ -203,7 +203,7 @@ itkScaleSkewVersor3DTransformTest(int, char *[]) { // Translate an itk::CovariantVector TransformType::InputCovariantVectorType::ValueType pInit[3] = { 1, 4, 9 }; - TransformType::InputCovariantVectorType p = pInit; + const TransformType::InputCovariantVectorType p = pInit; TransformType::OutputCovariantVectorType q; q = versor.Transform(p); @@ -309,7 +309,7 @@ itkScaleSkewVersor3DTransformTest(int, char *[]) ParametersType parameters(np); // Number of parameters parameters.Fill(0.0); - VersorType versor; + const VersorType versor; // TODO: Test jacobian with non-zero skew @@ -428,7 +428,7 @@ itkScaleSkewVersor3DTransformTest(int, char *[]) ParametersType parameters(np); // Number of parameters - VersorType versor; + const VersorType versor; parameters[0] = versor.GetX(); // Rotation axis * sin(t/2) parameters[1] = versor.GetY(); diff --git a/Modules/Core/Transform/test/itkScaleTransformTest.cxx b/Modules/Core/Transform/test/itkScaleTransformTest.cxx index 68de75891b7..f07fa82ef50 100644 --- a/Modules/Core/Transform/test/itkScaleTransformTest.cxx +++ b/Modules/Core/Transform/test/itkScaleTransformTest.cxx @@ -98,9 +98,9 @@ itkScaleTransformTest(int, char *[]) { // scale an itk::Point - TransformType::InputPointType::ValueType pInit[3] = { 10, 10, 10 }; - TransformType::InputPointType p = pInit; - TransformType::InputPointType q; + const TransformType::InputPointType::ValueType pInit[3] = { 10, 10, 10 }; + TransformType::InputPointType p = pInit; + TransformType::InputPointType q; for (unsigned int j = 0; j < N; ++j) { q[j] = p[j] * iscale[j]; @@ -234,7 +234,7 @@ itkScaleTransformTest(int, char *[]) scaleTransform->SetCenter(center); - CenterType c2 = scaleTransform->GetCenter(); + const CenterType c2 = scaleTransform->GetCenter(); if (c2.EuclideanDistanceTo(center) > 1e-5) { std::cerr << "Error in Set/Get center." << std::endl; diff --git a/Modules/Core/Transform/test/itkScaleVersor3DTransformTest.cxx b/Modules/Core/Transform/test/itkScaleVersor3DTransformTest.cxx index 4404dbc0315..12287694c0d 100644 --- a/Modules/Core/Transform/test/itkScaleVersor3DTransformTest.cxx +++ b/Modules/Core/Transform/test/itkScaleVersor3DTransformTest.cxx @@ -65,7 +65,7 @@ itkScaleVersor3DTransformTest(int, char *[]) auto axis = itk::MakeFilled(1.5); - ValueType angle = 120.0 * std::atan(1.0) / 45.0; + const ValueType angle = 120.0 * std::atan(1.0) / 45.0; VersorType versor; versor.Set(axis, angle); @@ -97,8 +97,8 @@ itkScaleVersor3DTransformTest(int, char *[]) { std::cout << "Test initial rotation matrix " << std::endl; - auto transform = TransformType::New(); - MatrixType matrix = transform->GetMatrix(); + auto transform = TransformType::New(); + const MatrixType matrix = transform->GetMatrix(); std::cout << "Matrix = " << std::endl; std::cout << matrix << std::endl; @@ -156,9 +156,9 @@ itkScaleVersor3DTransformTest(int, char *[]) { // Rotate an itk::Point - TransformType::InputPointType::ValueType pInit[3] = { 1, 4, 9 }; - TransformType::InputPointType p = pInit; - TransformType::OutputPointType q; + const TransformType::InputPointType::ValueType pInit[3] = { 1, 4, 9 }; + const TransformType::InputPointType p = pInit; + TransformType::OutputPointType q; q = versor.Transform(p); TransformType::OutputPointType r; @@ -187,7 +187,7 @@ itkScaleVersor3DTransformTest(int, char *[]) { // Translate an itk::Vector TransformType::InputVectorType::ValueType pInit[3] = { 1, 4, 9 }; - TransformType::InputVectorType p = pInit; + const TransformType::InputVectorType p = pInit; TransformType::OutputVectorType q; q = versor.Transform(p); @@ -217,7 +217,7 @@ itkScaleVersor3DTransformTest(int, char *[]) { // Translate an itk::CovariantVector TransformType::InputCovariantVectorType::ValueType pInit[3] = { 1, 4, 9 }; - TransformType::InputCovariantVectorType p = pInit; + const TransformType::InputCovariantVectorType p = pInit; TransformType::OutputCovariantVectorType q; q = versor.Transform(p); @@ -323,7 +323,7 @@ itkScaleVersor3DTransformTest(int, char *[]) ParametersType parameters(np); // Number of parameters parameters.Fill(0.0); - VersorType versor; + const VersorType versor; parameters[0] = versor.GetX(); // Rotation axis * sin(t/2) parameters[1] = versor.GetY(); @@ -440,7 +440,7 @@ itkScaleVersor3DTransformTest(int, char *[]) ParametersType parameters(np); // Number of parameters - VersorType versor; + const VersorType versor; parameters[0] = versor.GetX(); // Rotation axis * sin(t/2) parameters[1] = versor.GetY(); diff --git a/Modules/Core/Transform/test/itkSimilarity2DTransformTest.cxx b/Modules/Core/Transform/test/itkSimilarity2DTransformTest.cxx index c463b92193b..0441daa31bd 100644 --- a/Modules/Core/Transform/test/itkSimilarity2DTransformTest.cxx +++ b/Modules/Core/Transform/test/itkSimilarity2DTransformTest.cxx @@ -87,7 +87,7 @@ itkSimilarity2DTransformTest(int, char *[]) auto transform1 = SimilarityTransformType::New(); auto transform2 = SimilarityTransformType::New(); transform1->SetIdentity(); - double angle1 = .125; + const double angle1 = .125; transform1->SetAngle(angle1); transform2->SetMatrix(transform1->GetMatrix()); std::cout << "Testing SetAngle(" << angle1 << ")/GetAngle():"; @@ -196,7 +196,7 @@ itkSimilarity2DTransformTest(int, char *[]) transform->SetAngle(0); SimilarityTransformType::OffsetType::ValueType ioffsetInit[2] = { 1, 4 }; - SimilarityTransformType::OffsetType ioffset = ioffsetInit; + const SimilarityTransformType::OffsetType ioffset = ioffsetInit; transform->SetOffset(ioffset); @@ -327,7 +327,7 @@ itkSimilarity2DTransformTest(int, char *[]) parameters[2] = 12.0; parameters[3] = -8.9; t1->SetParameters(parameters); - bool computedInverse = t1->GetInverse(t2); + const bool computedInverse = t1->GetInverse(t2); if (computedInverse) { std::cout << "Did not report singular matrix when computed inverse of singular matrix" << std::endl; @@ -403,8 +403,8 @@ itkSimilarity2DTransformTest(int, char *[]) minusPoint = t4->TransformPoint(p1); for (unsigned int j = 0; j < 2; ++j) { - double approxDerivative = (plusPoint[j] - minusPoint[j]) / (2.0 * delta); - double computedDerivative = jacobian[j][k]; + const double approxDerivative = (plusPoint[j] - minusPoint[j]) / (2.0 * delta); + const double computedDerivative = jacobian[j][k]; approxJacobian[j][k] = approxDerivative; if (itk::Math::abs(approxDerivative - computedDerivative) > 1e-4) { @@ -561,8 +561,8 @@ itkSimilarity2DTransformTest(int, char *[]) minusPoint = t4->TransformPoint(p1); for (unsigned int j = 0; j < 2; ++j) { - double approxDerivative = (plusPoint[j] - minusPoint[j]) / (2.0 * delta); - double computedDerivative = jacobian[j][k]; + const double approxDerivative = (plusPoint[j] - minusPoint[j]) / (2.0 * delta); + const double computedDerivative = jacobian[j][k]; approxJacobian[j][k] = approxDerivative; if (itk::Math::abs(approxDerivative - computedDerivative) > 1e-4) { @@ -608,8 +608,8 @@ itkSimilarity2DTransformTest(int, char *[]) ip[0] = 8.0; ip[1] = 9.0; - TransformType::OutputPointType op1 = t1->TransformPoint(ip); - TransformType::OutputPointType op2 = t2->TransformPoint(ip); + const TransformType::OutputPointType op1 = t1->TransformPoint(ip); + const TransformType::OutputPointType op2 = t2->TransformPoint(ip); t1->Print(std::cout); std::cout << "Test Set/GetMatrix() and Set/GetOffset(): "; diff --git a/Modules/Core/Transform/test/itkSimilarity3DTransformTest.cxx b/Modules/Core/Transform/test/itkSimilarity3DTransformTest.cxx index 0935e4eb131..6ec96bf2a03 100644 --- a/Modules/Core/Transform/test/itkSimilarity3DTransformTest.cxx +++ b/Modules/Core/Transform/test/itkSimilarity3DTransformTest.cxx @@ -76,7 +76,7 @@ itkSimilarity3DTransformTest(int, char *[]) auto axis = itk::MakeFilled(1.5); - ValueType angle = 120.0 * std::atan(1.0) / 45.0; + const ValueType angle = 120.0 * std::atan(1.0) / 45.0; VersorType versor; versor.Set(axis, angle); @@ -102,8 +102,8 @@ itkSimilarity3DTransformTest(int, char *[]) } { std::cout << "Test initial rotation matrix " << std::endl; - auto transform = TransformType::New(); - MatrixType matrix = transform->GetMatrix(); + auto transform = TransformType::New(); + const MatrixType matrix = transform->GetMatrix(); std::cout << "Matrix = " << std::endl; std::cout << matrix << std::endl; } @@ -144,9 +144,9 @@ itkSimilarity3DTransformTest(int, char *[]) { // Rotate an itk::Point - TransformType::InputPointType::ValueType pInit[3] = { 1, 4, 9 }; - TransformType::InputPointType p = pInit; - TransformType::OutputPointType q; + const TransformType::InputPointType::ValueType pInit[3] = { 1, 4, 9 }; + const TransformType::InputPointType p = pInit; + TransformType::OutputPointType q; q = versor.Transform(p); TransformType::OutputPointType r; @@ -175,7 +175,7 @@ itkSimilarity3DTransformTest(int, char *[]) { // Translate an itk::Vector TransformType::InputVectorType::ValueType pInit[3] = { 1, 4, 9 }; - TransformType::InputVectorType p = pInit; + const TransformType::InputVectorType p = pInit; TransformType::OutputVectorType q; q = versor.Transform(p); @@ -204,7 +204,7 @@ itkSimilarity3DTransformTest(int, char *[]) { // Translate an itk::CovariantVector TransformType::InputCovariantVectorType::ValueType pInit[3] = { 1, 4, 9 }; - TransformType::InputCovariantVectorType p = pInit; + const TransformType::InputCovariantVectorType p = pInit; TransformType::OutputCovariantVectorType q; q = versor.Transform(p); @@ -308,7 +308,7 @@ itkSimilarity3DTransformTest(int, char *[]) ParametersType parameters(np); // Number of parameters - VersorType versor; + const VersorType versor; parameters[0] = versor.GetX(); // Rotation axis * sin(t/2) parameters[1] = versor.GetY(); @@ -415,7 +415,7 @@ itkSimilarity3DTransformTest(int, char *[]) ParametersType parameters(np); // Number of parameters - VersorType versor; + const VersorType versor; parameters[0] = versor.GetX(); // Rotation axis * sin(t/2) parameters[1] = versor.GetY(); @@ -555,8 +555,8 @@ itkSimilarity3DTransformTest(int, char *[]) // attempt to set an (orthogonal + scale) matrix matrix.GetVnlMatrix().set_identity(); - double a = 1.0 / 180.0 * itk::Math::pi; - double s = 0.5; + const double a = 1.0 / 180.0 * itk::Math::pi; + const double s = 0.5; matrix[0][0] = std::cos(a) * s; matrix[0][1] = -1.0 * std::sin(a) * s; matrix[1][0] = std::sin(a) * s; diff --git a/Modules/Core/Transform/test/itkSplineKernelTransformTest.cxx b/Modules/Core/Transform/test/itkSplineKernelTransformTest.cxx index d6f3116f4b2..ad6056b86d8 100644 --- a/Modules/Core/Transform/test/itkSplineKernelTransformTest.cxx +++ b/Modules/Core/Transform/test/itkSplineKernelTransformTest.cxx @@ -103,8 +103,8 @@ itkSplineKernelTransformTest(int, char *[]) ebs2D->ComputeWMatrix(); { // Testing the number of parameters - EBSTransform2DType::ParametersType parameters1 = ebs2D->GetParameters(); - const unsigned int numberOfParameters = parameters1.Size(); + const EBSTransform2DType::ParametersType parameters1 = ebs2D->GetParameters(); + const unsigned int numberOfParameters = parameters1.Size(); if (numberOfParameters != 4 * 2) { std::cerr << "Number of parameters was not updated after" << std::endl; @@ -210,7 +210,7 @@ itkSplineKernelTransformTest(int, char *[]) } } { // Just for code coverage - TPSTransform2DType::VectorSetType::ConstPointer tempDisplacements = tps2D->GetDisplacements(); + const TPSTransform2DType::VectorSetType::ConstPointer tempDisplacements = tps2D->GetDisplacements(); { TPSTransform2DType::InputVectorType testVector; diff --git a/Modules/Core/Transform/test/itkTestTransformGetInverse.cxx b/Modules/Core/Transform/test/itkTestTransformGetInverse.cxx index 5d89054b6bc..6dc3a83171e 100644 --- a/Modules/Core/Transform/test/itkTestTransformGetInverse.cxx +++ b/Modules/Core/Transform/test/itkTestTransformGetInverse.cxx @@ -79,7 +79,7 @@ template unsigned TransformTest() { - typename itk::MultiThreaderBase::Pointer threader = itk::MultiThreaderBase::New(); + const typename itk::MultiThreaderBase::Pointer threader = itk::MultiThreaderBase::New(); ThreadData td; td.m_Transform = TTransform::New(); diff --git a/Modules/Core/Transform/test/itkTransformCloneTest.cxx b/Modules/Core/Transform/test/itkTransformCloneTest.cxx index 89132c96cec..3fb1f77b714 100644 --- a/Modules/Core/Transform/test/itkTransformCloneTest.cxx +++ b/Modules/Core/Transform/test/itkTransformCloneTest.cxx @@ -75,8 +75,8 @@ itkTransformCloneTest(int, char *[]) offset[2] = 32.768; affineXfrm->Translate(offset); - Transform3DType::Pointer clonePtr = affineXfrm->Clone().GetPointer(); - AffineTransformType::Pointer cloneAffineXfrm = dynamic_cast(clonePtr.GetPointer()); + const Transform3DType::Pointer clonePtr = affineXfrm->Clone().GetPointer(); + const AffineTransformType::Pointer cloneAffineXfrm = dynamic_cast(clonePtr.GetPointer()); if (cloneAffineXfrm.IsNull()) { @@ -101,7 +101,7 @@ itkTransformCloneTest(int, char *[]) compositeXfrm->AddTransform(clonePtr); compositeXfrm->SetOnlyMostRecentTransformToOptimizeOn(); - CompositeTransformType::Pointer cloneCompositeXfrm = compositeXfrm->Clone().GetPointer(); + const CompositeTransformType::Pointer cloneCompositeXfrm = compositeXfrm->Clone().GetPointer(); if ((compositeXfrm->GetNumberOfTransforms() != cloneCompositeXfrm->GetNumberOfTransforms())) { @@ -110,9 +110,9 @@ itkTransformCloneTest(int, char *[]) } for (unsigned int i = 0; i < compositeXfrm->GetNumberOfTransforms(); ++i) { - AffineTransformType::ConstPointer originalXfrm = + const AffineTransformType::ConstPointer originalXfrm = dynamic_cast(compositeXfrm->GetNthTransformConstPointer(i)); - AffineTransformType::ConstPointer cloneXfrm = + const AffineTransformType::ConstPointer cloneXfrm = dynamic_cast(cloneCompositeXfrm->GetNthTransformConstPointer(i)); if (originalXfrm.IsNull() || cloneXfrm.IsNull()) diff --git a/Modules/Core/Transform/test/itkTransformGeometryImageFilterTest.cxx b/Modules/Core/Transform/test/itkTransformGeometryImageFilterTest.cxx index 3257e556821..00eaf2a3832 100644 --- a/Modules/Core/Transform/test/itkTransformGeometryImageFilterTest.cxx +++ b/Modules/Core/Transform/test/itkTransformGeometryImageFilterTest.cxx @@ -40,7 +40,7 @@ template bool imagesDifferent(ImageType * baselineImage, ImageType * outputImage) { - double tol = 1.e-3; // tolerance + const double tol = 1.e-3; // tolerance typename ImageType::PointType origin = outputImage->GetOrigin(); typename ImageType::DirectionType direction = outputImage->GetDirection(); @@ -117,7 +117,7 @@ itkTransformGeometryImageFilterTest(int argc, char * argv[]) rotationAxis[1] = 0.2; rotationAxis[2] = 0.7; - double rotationAngle = .5; // Radians + const double rotationAngle = .5; // Radians auto transform = TransformType::New(); // Identity by default transform->SetCenter(center); @@ -144,7 +144,7 @@ itkTransformGeometryImageFilterTest(int argc, char * argv[]) filter->SetTransform(transform); ITK_TEST_SET_GET_VALUE(transform, filter->GetTransform()); ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); - ImagePointer outputImage = filter->GetOutput(); + const ImagePointer outputImage = filter->GetOutput(); ITK_TRY_EXPECT_NO_EXCEPTION(itk::WriteImage(outputImage, argv[3])); // Read in baseline image @@ -162,7 +162,7 @@ itkTransformGeometryImageFilterTest(int argc, char * argv[]) rawPointerTransform->ApplyToImageMetadata(inputImage.GetPointer()); const TransformType * constRawPointerTransform = transform.GetPointer(); constRawPointerTransform->ApplyToImageMetadata(inputImage); - TransformType::ConstPointer constPointerTransform = transform.GetPointer(); + const TransformType::ConstPointer constPointerTransform = transform.GetPointer(); constPointerTransform->ApplyToImageMetadata(inputImage); constPointerTransform->ApplyToImageMetadata(inputImage.GetPointer()); diff --git a/Modules/Core/Transform/test/itkTransformTest.cxx b/Modules/Core/Transform/test/itkTransformTest.cxx index 444015b3ffb..6f94be198d7 100644 --- a/Modules/Core/Transform/test/itkTransformTest.cxx +++ b/Modules/Core/Transform/test/itkTransformTest.cxx @@ -230,7 +230,7 @@ class TransformTester transform->TransformSymmetricSecondRankTensor(vecpix, pnt); std::cout << "TransformSymmetricSecondRankTensor() OK" << std::endl; - typename TransformType::ParametersType parameters(6); + const typename TransformType::ParametersType parameters(6); try { transform->SetParameters(parameters); diff --git a/Modules/Core/Transform/test/itkTranslationTransformTest.cxx b/Modules/Core/Transform/test/itkTranslationTransformTest.cxx index e3acd95a17e..1f588682b39 100644 --- a/Modules/Core/Transform/test/itkTranslationTransformTest.cxx +++ b/Modules/Core/Transform/test/itkTranslationTransformTest.cxx @@ -40,7 +40,7 @@ PrintVector(const VectorType & v) int itkTranslationTransformTest(int, char *[]) { - int any = 0; // Any errors detected in testing? + const int any = 0; // Any errors detected in testing? /* FIXME: This code exercises most of the methods but doesn't actually check that the results are correct. */ diff --git a/Modules/Core/Transform/test/itkVersorRigid3DTransformTest.cxx b/Modules/Core/Transform/test/itkVersorRigid3DTransformTest.cxx index c028c00377c..10d3cb31cdb 100644 --- a/Modules/Core/Transform/test/itkVersorRigid3DTransformTest.cxx +++ b/Modules/Core/Transform/test/itkVersorRigid3DTransformTest.cxx @@ -67,7 +67,7 @@ itkVersorRigid3DTransformTest(int, char *[]) auto axis = itk::MakeFilled(1.5); - ValueType angle = 120.0 * std::atan(1.0) / 45.0; + const ValueType angle = 120.0 * std::atan(1.0) / 45.0; VersorType versor; versor.Set(axis, angle); @@ -93,8 +93,8 @@ itkVersorRigid3DTransformTest(int, char *[]) { std::cout << "Test initial rotation matrix " << std::endl; - auto transform = TransformType::New(); - MatrixType matrix = transform->GetMatrix(); + auto transform = TransformType::New(); + const MatrixType matrix = transform->GetMatrix(); std::cout << "Matrix = " << std::endl; std::cout << matrix << std::endl; } @@ -136,9 +136,9 @@ itkVersorRigid3DTransformTest(int, char *[]) { // Rotate an itk::Point - TransformType::InputPointType::ValueType pInit[3] = { 1, 4, 9 }; - TransformType::InputPointType p = pInit; - TransformType::OutputPointType q; + const TransformType::InputPointType::ValueType pInit[3] = { 1, 4, 9 }; + const TransformType::InputPointType p = pInit; + TransformType::OutputPointType q; q = versor.Transform(p); TransformType::OutputPointType r; @@ -167,7 +167,7 @@ itkVersorRigid3DTransformTest(int, char *[]) { // Translate an itk::Vector TransformType::InputVectorType::ValueType pInit[3] = { 1, 4, 9 }; - TransformType::InputVectorType p = pInit; + const TransformType::InputVectorType p = pInit; TransformType::OutputVectorType q; q = versor.Transform(p); @@ -197,7 +197,7 @@ itkVersorRigid3DTransformTest(int, char *[]) { // Translate an itk::CovariantVector TransformType::InputCovariantVectorType::ValueType pInit[3] = { 1, 4, 9 }; - TransformType::InputCovariantVectorType p = pInit; + const TransformType::InputCovariantVectorType p = pInit; TransformType::OutputCovariantVectorType q; q = versor.Transform(p); @@ -302,7 +302,7 @@ itkVersorRigid3DTransformTest(int, char *[]) ParametersType parameters(np); // Number of parameters - VersorType versor; + const VersorType versor; parameters[0] = versor.GetX(); // Rotation axis * std::sin(t/2) parameters[1] = versor.GetY(); @@ -404,7 +404,7 @@ itkVersorRigid3DTransformTest(int, char *[]) ParametersType parameters(np); // Number of parameters - VersorType versor; + const VersorType versor; parameters[0] = versor.GetX(); // Rotation axis * std::sin(t/2) parameters[1] = versor.GetY(); @@ -474,7 +474,7 @@ itkVersorRigid3DTransformTest(int, char *[]) // attempt to set an orthogonal matrix matrix.GetVnlMatrix().set_identity(); - double a = 1.0 / 180.0 * itk::Math::pi; + const double a = 1.0 / 180.0 * itk::Math::pi; matrix[0][0] = std::cos(a); matrix[0][1] = -1.0 * std::sin(a); matrix[1][0] = std::sin(a); diff --git a/Modules/Core/Transform/test/itkVersorTransformTest.cxx b/Modules/Core/Transform/test/itkVersorTransformTest.cxx index 0aa40704167..d0a40fd4709 100644 --- a/Modules/Core/Transform/test/itkVersorTransformTest.cxx +++ b/Modules/Core/Transform/test/itkVersorTransformTest.cxx @@ -67,7 +67,7 @@ itkVersorTransformTest(int, char *[]) auto axis = itk::MakeFilled(1.5); - ValueType angle = 120.0 * std::atan(1.0) / 45.0; + const ValueType angle = 120.0 * std::atan(1.0) / 45.0; VersorType versor; versor.Set(axis, angle); @@ -90,8 +90,8 @@ itkVersorTransformTest(int, char *[]) { std::cout << "Test initial rotation matrix " << std::endl; - auto transform = TransformType::New(); - MatrixType matrix = transform->GetMatrix(); + auto transform = TransformType::New(); + const MatrixType matrix = transform->GetMatrix(); std::cout << "Matrix = " << std::endl; std::cout << matrix << std::endl; } @@ -133,9 +133,9 @@ itkVersorTransformTest(int, char *[]) { // Rotate an itk::Point - TransformType::InputPointType::ValueType pInit[3] = { 1, 4, 9 }; - TransformType::InputPointType p = pInit; - TransformType::OutputPointType q; + const TransformType::InputPointType::ValueType pInit[3] = { 1, 4, 9 }; + const TransformType::InputPointType p = pInit; + TransformType::OutputPointType q; q = versor.Transform(p); TransformType::OutputPointType r; @@ -164,7 +164,7 @@ itkVersorTransformTest(int, char *[]) { // Translate an itk::Vector TransformType::InputVectorType::ValueType pInit[3] = { 1, 4, 9 }; - TransformType::InputVectorType p = pInit; + const TransformType::InputVectorType p = pInit; TransformType::OutputVectorType q; q = versor.Transform(p); @@ -194,7 +194,7 @@ itkVersorTransformTest(int, char *[]) { // Translate an itk::CovariantVector TransformType::InputCovariantVectorType::ValueType pInit[3] = { 1, 4, 9 }; - TransformType::InputCovariantVectorType p = pInit; + const TransformType::InputCovariantVectorType p = pInit; TransformType::OutputCovariantVectorType q; q = versor.Transform(p); @@ -299,7 +299,7 @@ itkVersorTransformTest(int, char *[]) ParametersType parameters(np); // Number of parameters - VersorType versor; + const VersorType versor; parameters[0] = versor.GetX(); // Rotation axis * std::sin(t/2) parameters[1] = versor.GetY(); @@ -410,7 +410,7 @@ itkVersorTransformTest(int, char *[]) // attempt to set an orthogonal matrix matrix.GetVnlMatrix().set_identity(); - double a = 1.0 / 180.0 * itk::Math::pi; + const double a = 1.0 / 180.0 * itk::Math::pi; matrix[0][0] = std::cos(a); matrix[0][1] = -1.0 * std::sin(a); matrix[1][0] = std::sin(a); diff --git a/Modules/Filtering/AnisotropicSmoothing/include/itkCurvatureNDAnisotropicDiffusionFunction.hxx b/Modules/Filtering/AnisotropicSmoothing/include/itkCurvatureNDAnisotropicDiffusionFunction.hxx index bf39274c808..6a5885efa3b 100644 --- a/Modules/Filtering/AnisotropicSmoothing/include/itkCurvatureNDAnisotropicDiffusionFunction.hxx +++ b/Modules/Filtering/AnisotropicSmoothing/include/itkCurvatureNDAnisotropicDiffusionFunction.hxx @@ -109,8 +109,8 @@ CurvatureNDAnisotropicDiffusionFunction::ComputeUpdate(const Neighborhoo grad_mag_sq_d += 0.25f * (dx[j] + dx_dim) * (dx[j] + dx_dim); } } - double grad_mag = std::sqrt(m_MIN_NORM + grad_mag_sq); - double grad_mag_d = std::sqrt(m_MIN_NORM + grad_mag_sq_d); + const double grad_mag = std::sqrt(m_MIN_NORM + grad_mag_sq); + const double grad_mag_d = std::sqrt(m_MIN_NORM + grad_mag_sq_d); double Cx; double Cxd; @@ -126,8 +126,8 @@ CurvatureNDAnisotropicDiffusionFunction::ComputeUpdate(const Neighborhoo Cxd = std::exp(grad_mag_sq_d / m_K); } // First order normalized finite-difference conductance products - double dx_forward_Cn = (dx_forward[i] / grad_mag) * Cx; - double dx_backward_Cn = (dx_backward[i] / grad_mag_d) * Cxd; + const double dx_forward_Cn = (dx_forward[i] / grad_mag) * Cx; + const double dx_backward_Cn = (dx_backward[i] / grad_mag_d) * Cxd; // Second order conductance-modified curvature speed += (dx_forward_Cn - dx_backward_Cn); diff --git a/Modules/Filtering/AnisotropicSmoothing/include/itkScalarAnisotropicDiffusionFunction.hxx b/Modules/Filtering/AnisotropicSmoothing/include/itkScalarAnisotropicDiffusionFunction.hxx index 34e08d7f064..798f8d83765 100644 --- a/Modules/Filtering/AnisotropicSmoothing/include/itkScalarAnisotropicDiffusionFunction.hxx +++ b/Modules/Filtering/AnisotropicSmoothing/include/itkScalarAnisotropicDiffusionFunction.hxx @@ -85,7 +85,7 @@ ScalarAnisotropicDiffusionFunction::CalculateAverageGradientMagnitudeSqu for (i = 0; i < ImageDimension; ++i) { val = iterator_list[i].GetPixel(Center[i] + Stride[i]) - iterator_list[i].GetPixel(Center[i] - Stride[i]); - PixelRealType tempval = val / -2.0f; + const PixelRealType tempval = val / -2.0f; val = tempval * this->m_ScaleCoefficients[i]; accumulator += val * val; ++iterator_list[i]; @@ -112,7 +112,7 @@ ScalarAnisotropicDiffusionFunction::CalculateAverageGradientMagnitudeSqu { val = face_iterator_list[i].GetPixel(Center[i] + Stride[i]) - face_iterator_list[i].GetPixel(Center[i] - Stride[i]); - PixelRealType tempval = val / -2.0f; + const PixelRealType tempval = val / -2.0f; val = tempval * this->m_ScaleCoefficients[i]; accumulator += val * val; ++face_iterator_list[i]; diff --git a/Modules/Filtering/AnisotropicSmoothing/include/itkVectorAnisotropicDiffusionFunction.hxx b/Modules/Filtering/AnisotropicSmoothing/include/itkVectorAnisotropicDiffusionFunction.hxx index bb98ff02aff..f451617150e 100644 --- a/Modules/Filtering/AnisotropicSmoothing/include/itkVectorAnisotropicDiffusionFunction.hxx +++ b/Modules/Filtering/AnisotropicSmoothing/include/itkVectorAnisotropicDiffusionFunction.hxx @@ -68,7 +68,7 @@ VectorAnisotropicDiffusionFunction::CalculateAverageGradientMagnitudeSqu iterator_list[i] = RNI_type(operator_list[i].GetRadius(), ip, *fit); iterator_list[i].GoToBegin(); } - VectorNeighborhoodInnerProduct IP; + const VectorNeighborhoodInnerProduct IP; while (!iterator_list[0].IsAtEnd()) { ++counter; @@ -86,8 +86,8 @@ VectorAnisotropicDiffusionFunction::CalculateAverageGradientMagnitudeSqu // Go on to the next region(s). These are on the boundary faces. ++fit; - VectorNeighborhoodInnerProduct SIP; - SNI_type face_iterator_list[ImageDimension]; + const VectorNeighborhoodInnerProduct SIP; + SNI_type face_iterator_list[ImageDimension]; while (fit != faceList.end()) { for (unsigned int i = 0; i < ImageDimension; ++i) diff --git a/Modules/Filtering/AnisotropicSmoothing/test/itkCurvatureAnisotropicDiffusionImageFilterTest.cxx b/Modules/Filtering/AnisotropicSmoothing/test/itkCurvatureAnisotropicDiffusionImageFilterTest.cxx index 43700eacb86..cbf440efd94 100644 --- a/Modules/Filtering/AnisotropicSmoothing/test/itkCurvatureAnisotropicDiffusionImageFilterTest.cxx +++ b/Modules/Filtering/AnisotropicSmoothing/test/itkCurvatureAnisotropicDiffusionImageFilterTest.cxx @@ -38,10 +38,10 @@ itkCurvatureAnisotropicDiffusionImageFilterTest(int itkNotUsed(argc), char * itk ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, CurvatureAnisotropicDiffusionImageFilter, AnisotropicDiffusionImageFilter); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); - itk::IdentifierType numberOfIterations = 1; + const itk::IdentifierType numberOfIterations = 1; filter->SetNumberOfIterations(numberOfIterations); ITK_TEST_SET_GET_VALUE(numberOfIterations, filter->GetNumberOfIterations()); @@ -49,7 +49,7 @@ itkCurvatureAnisotropicDiffusionImageFilterTest(int itkNotUsed(argc), char * itk filter->SetConductanceParameter(conductanceParameter); ITK_TEST_SET_GET_VALUE(conductanceParameter, filter->GetConductanceParameter()); - FilterType::TimeStepType timeStep = 0.125; + const FilterType::TimeStepType timeStep = 0.125; filter->SetTimeStep(timeStep); ITK_TEST_SET_GET_VALUE(timeStep, filter->GetTimeStep()); diff --git a/Modules/Filtering/AnisotropicSmoothing/test/itkGradientAnisotropicDiffusionImageFilterTest.cxx b/Modules/Filtering/AnisotropicSmoothing/test/itkGradientAnisotropicDiffusionImageFilterTest.cxx index d92d2a7cd78..0f8d9b4d4e8 100644 --- a/Modules/Filtering/AnisotropicSmoothing/test/itkGradientAnisotropicDiffusionImageFilterTest.cxx +++ b/Modules/Filtering/AnisotropicSmoothing/test/itkGradientAnisotropicDiffusionImageFilterTest.cxx @@ -37,11 +37,11 @@ itkGradientAnisotropicDiffusionImageFilterTest(int itkNotUsed(argc), char * itkN ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, GradientAnisotropicDiffusionImageFilter, AnisotropicDiffusionImageFilter); - itk::IdentifierType numberOfIterations = 1; + const itk::IdentifierType numberOfIterations = 1; filter->SetNumberOfIterations(numberOfIterations); ITK_TEST_SET_GET_VALUE(numberOfIterations, filter->GetNumberOfIterations()); - FilterType::TimeStepType timeStep = 0.125; + const FilterType::TimeStepType timeStep = 0.125; filter->SetTimeStep(timeStep); ITK_TEST_SET_GET_VALUE(timeStep, filter->GetTimeStep()); @@ -49,7 +49,7 @@ itkGradientAnisotropicDiffusionImageFilterTest(int itkNotUsed(argc), char * itkN filter->SetConductanceParameter(conductanceParameter); ITK_TEST_SET_GET_VALUE(conductanceParameter, filter->GetConductanceParameter()); - unsigned int conductanceScalingUpdateInterval = 1; + const unsigned int conductanceScalingUpdateInterval = 1; filter->SetConductanceScalingUpdateInterval(conductanceScalingUpdateInterval); ITK_TEST_SET_GET_VALUE(conductanceScalingUpdateInterval, filter->GetConductanceScalingUpdateInterval()); diff --git a/Modules/Filtering/AnisotropicSmoothing/test/itkGradientAnisotropicDiffusionImageFilterTest2.cxx b/Modules/Filtering/AnisotropicSmoothing/test/itkGradientAnisotropicDiffusionImageFilterTest2.cxx index 72c28e1793a..74f035aec20 100644 --- a/Modules/Filtering/AnisotropicSmoothing/test/itkGradientAnisotropicDiffusionImageFilterTest2.cxx +++ b/Modules/Filtering/AnisotropicSmoothing/test/itkGradientAnisotropicDiffusionImageFilterTest2.cxx @@ -38,9 +38,9 @@ namespace bool SameImage(ImagePointer testImage, ImagePointer baselineImage) { - PixelType intensityTolerance = .001; - int radiusTolerance = 0; - unsigned long numberOfPixelTolerance = 0; + const PixelType intensityTolerance = .001; + const int radiusTolerance = 0; + const unsigned long numberOfPixelTolerance = 0; using DiffType = itk::Testing::ComparisonImageFilter; auto diff = DiffType::New(); @@ -50,7 +50,7 @@ SameImage(ImagePointer testImage, ImagePointer baselineImage) diff->SetToleranceRadius(radiusTolerance); diff->UpdateLargestPossibleRegion(); - unsigned long status = diff->GetNumberOfPixelsWithDifferences(); + const unsigned long status = diff->GetNumberOfPixelsWithDifferences(); if (status > numberOfPixelTolerance) @@ -75,11 +75,11 @@ itkGradientAnisotropicDiffusionImageFilterTest2(int argc, char * argv[]) } - itk::ImageFileReader::Pointer input = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer input = itk::ImageFileReader::New(); input->SetFileName(argv[1]); // Create a filter - itk::GradientAnisotropicDiffusionImageFilter::Pointer filter = + const itk::GradientAnisotropicDiffusionImageFilter::Pointer filter = itk::GradientAnisotropicDiffusionImageFilter::New(); filter->SetNumberOfIterations(10); filter->SetConductanceParameter(1.0f); @@ -88,7 +88,7 @@ itkGradientAnisotropicDiffusionImageFilterTest2(int argc, char * argv[]) filter->SetInput(input->GetOutput()); using myUCharImage = itk::Image; - itk::CastImageFilter::Pointer caster = + const itk::CastImageFilter::Pointer caster = itk::CastImageFilter::New(); caster->SetInput(filter->GetOutput()); @@ -104,7 +104,7 @@ itkGradientAnisotropicDiffusionImageFilterTest2(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update()); - myFloatImage::Pointer normalImage = filter->GetOutput(); + const myFloatImage::Pointer normalImage = filter->GetOutput(); normalImage->DisconnectPipeline(); // We now set up testing when the image spacing is not trivial 1 and diff --git a/Modules/Filtering/AnisotropicSmoothing/test/itkMinMaxCurvatureFlowImageFilterTest.cxx b/Modules/Filtering/AnisotropicSmoothing/test/itkMinMaxCurvatureFlowImageFilterTest.cxx index d186a98471d..ec47b92af0c 100644 --- a/Modules/Filtering/AnisotropicSmoothing/test/itkMinMaxCurvatureFlowImageFilterTest.cxx +++ b/Modules/Filtering/AnisotropicSmoothing/test/itkMinMaxCurvatureFlowImageFilterTest.cxx @@ -78,7 +78,7 @@ itkMinMaxCurvatureFlowImageFilterTest(int, char *[]) niter[1] = 100; radii[0] = 1; radii[1] = 3; - int err2D = testMinMaxCurvatureFlow(size2D, radius, numberOfRuns, niter, radii); + const int err2D = testMinMaxCurvatureFlow(size2D, radius, numberOfRuns, niter, radii); /* Dummy tests to test 3D and ND. @@ -96,7 +96,7 @@ itkMinMaxCurvatureFlowImageFilterTest(int, char *[]) // niter[0] = 20; /* reduced to speedup purify */ niter[0] = 1; radii[1] = 1; - int err3D = testMinMaxCurvatureFlow(size3D, radius, numberOfRuns, niter, radii); + const int err3D = testMinMaxCurvatureFlow(size3D, radius, numberOfRuns, niter, radii); itk::Size<4> size4D; size4D[0] = 8; @@ -108,7 +108,7 @@ itkMinMaxCurvatureFlowImageFilterTest(int, char *[]) numberOfRuns = 1; niter[0] = 1; radii[1] = 1; - int err4D = testMinMaxCurvatureFlow(size4D, radius, numberOfRuns, niter, radii); + const int err4D = testMinMaxCurvatureFlow(size4D, radius, numberOfRuns, niter, radii); std::cout << "2D Test passed: " << !err2D << std::endl; std::cout << "3D Test passed: " << !err3D << std::endl; @@ -148,10 +148,10 @@ testMinMaxCurvatureFlow(itk::Size & size, // ND image s * Create an image containing a circle/sphere with intensity of 0 * and background of 255 with added salt and pepper noise. */ - double sqrRadius = itk::Math::sqr(radius); // radius of the circle/sphere - double fractionNoise = 0.30; // salt & pepper noise fraction - PixelType foreground = 0.0; // intensity value of the foreground - PixelType background = 255.0; // intensity value of the background + const double sqrRadius = itk::Math::sqr(radius); // radius of the circle/sphere + const double fractionNoise = 0.30; // salt & pepper noise fraction + const PixelType foreground = 0.0; // intensity value of the foreground + const PixelType background = 255.0; // intensity value of the background std::cout << "Create an image of circle/sphere with noise" << std::endl; auto circleImage = ImageType::New(); @@ -248,14 +248,14 @@ testMinMaxCurvatureFlow(itk::Size & size, // ND image s IteratorType outIter(swapPointer, swapPointer->GetBufferedRegion()); - PixelType tolerance = itk::Math::abs(foreground - background) * 0.1; + const PixelType tolerance = itk::Math::abs(foreground - background) * 0.1; unsigned long numPixelsWrong = 0; for (; !outIter.IsAtEnd(); ++outIter) { typename ImageType::IndexType index = outIter.GetIndex(); - PixelType value = outIter.Get(); + const PixelType value = outIter.Get(); double lhs = 0.0; for (j = 0; j < ImageDimension; ++j) @@ -275,7 +275,7 @@ testMinMaxCurvatureFlow(itk::Size & size, // ND image s } } - double fractionWrong = static_cast(numPixelsWrong) / static_cast(region.GetNumberOfPixels()); + const double fractionWrong = static_cast(numPixelsWrong) / static_cast(region.GetNumberOfPixels()); std::cout << "Noise reduced from " << fractionNoise << " to "; std::cout << fractionWrong << std::endl; diff --git a/Modules/Filtering/AnisotropicSmoothing/test/itkVectorAnisotropicDiffusionImageFilterTest.cxx b/Modules/Filtering/AnisotropicSmoothing/test/itkVectorAnisotropicDiffusionImageFilterTest.cxx index c1c75bdda50..8c54173003b 100644 --- a/Modules/Filtering/AnisotropicSmoothing/test/itkVectorAnisotropicDiffusionImageFilterTest.cxx +++ b/Modules/Filtering/AnisotropicSmoothing/test/itkVectorAnisotropicDiffusionImageFilterTest.cxx @@ -37,7 +37,7 @@ itkVectorAnisotropicDiffusionImageFilterTest(int itkNotUsed(argc), char * itkNot using ImageType = itk::Image, 2>; // Set up Gradient diffusion filter - itk::VectorGradientAnisotropicDiffusionImageFilter::Pointer filter = + const itk::VectorGradientAnisotropicDiffusionImageFilter::Pointer filter = itk::VectorGradientAnisotropicDiffusionImageFilter::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS( @@ -65,7 +65,7 @@ itkVectorAnisotropicDiffusionImageFilterTest(int itkNotUsed(argc), char * itkNot // Set up Curvature diffusion filter - itk::VectorCurvatureAnisotropicDiffusionImageFilter::Pointer filter2 = + const itk::VectorCurvatureAnisotropicDiffusionImageFilter::Pointer filter2 = itk::VectorCurvatureAnisotropicDiffusionImageFilter::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS( diff --git a/Modules/Filtering/AntiAlias/test/itkAntiAliasBinaryImageFilterTest.cxx b/Modules/Filtering/AntiAlias/test/itkAntiAliasBinaryImageFilterTest.cxx index 08a5b1e022c..774bfd4b581 100644 --- a/Modules/Filtering/AntiAlias/test/itkAntiAliasBinaryImageFilterTest.cxx +++ b/Modules/Filtering/AntiAlias/test/itkAntiAliasBinaryImageFilterTest.cxx @@ -40,12 +40,12 @@ constexpr int V_DEPTH = 64; float sphere(float x, float y, float z) { - float dis = (x - static_cast(V_WIDTH) / 2.0) * (x - static_cast(V_WIDTH) / 2.0) / - ((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) + - (y - static_cast(V_HEIGHT) / 2.0) * (y - static_cast(V_HEIGHT) / 2.0) / - ((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) + - (z - static_cast(V_DEPTH) / 2.0) * (z - static_cast(V_DEPTH) / 2.0) / - ((0.2f * V_DEPTH) * (0.2f * V_DEPTH)); + const float dis = (x - static_cast(V_WIDTH) / 2.0) * (x - static_cast(V_WIDTH) / 2.0) / + ((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) + + (y - static_cast(V_HEIGHT) / 2.0) * (y - static_cast(V_HEIGHT) / 2.0) / + ((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) + + (z - static_cast(V_DEPTH) / 2.0) * (z - static_cast(V_DEPTH) / 2.0) / + ((0.2f * V_DEPTH) * (0.2f * V_DEPTH)); return (1.0f - dis); } @@ -94,7 +94,7 @@ itkAntiAliasBinaryImageFilterTest(int argc, char * argv[]) using BinaryImageType = itk::Image; using RealImageType = itk::Image; - itk::AntiAliasBinaryImageFilter::Pointer antialiaser = + const itk::AntiAliasBinaryImageFilter::Pointer antialiaser = itk::AntiAliasBinaryImageFilter::New(); // Create a binary image of a sphere. diff --git a/Modules/Filtering/BiasCorrection/include/itkCompositeValleyFunction.h b/Modules/Filtering/BiasCorrection/include/itkCompositeValleyFunction.h index 5ef309eaf33..d450203acc9 100644 --- a/Modules/Filtering/BiasCorrection/include/itkCompositeValleyFunction.h +++ b/Modules/Filtering/BiasCorrection/include/itkCompositeValleyFunction.h @@ -175,7 +175,7 @@ class ITKBiasCorrection_EXPORT CompositeValleyFunction : public CacheableScalarF void AddNewClass(double mean, double sigma) { - TargetClass aClass(mean, sigma); + const TargetClass aClass(mean, sigma); m_Targets.push_back(aClass); } diff --git a/Modules/Filtering/BiasCorrection/include/itkMRASlabIdentifier.hxx b/Modules/Filtering/BiasCorrection/include/itkMRASlabIdentifier.hxx index cb0ffb17a54..02a442f158d 100644 --- a/Modules/Filtering/BiasCorrection/include/itkMRASlabIdentifier.hxx +++ b/Modules/Filtering/BiasCorrection/include/itkMRASlabIdentifier.hxx @@ -54,9 +54,9 @@ MRASlabIdentifier::GenerateSlabRegions() region = m_Image->GetLargestPossibleRegion(); size = region.GetSize(); index = region.GetIndex(); - IndexValueType firstSlice = index[m_SlicingDirection]; - IndexValueType lastSlice = firstSlice + size[m_SlicingDirection]; - SizeValueType totalSlices = size[m_SlicingDirection]; + const IndexValueType firstSlice = index[m_SlicingDirection]; + const IndexValueType lastSlice = firstSlice + size[m_SlicingDirection]; + const SizeValueType totalSlices = size[m_SlicingDirection]; double sum; std::vector avgMin(totalSlices); @@ -125,7 +125,7 @@ MRASlabIdentifier::GenerateSlabRegions() ++am_iter; } - double average = sum / static_cast(totalSlices); + const double average = sum / static_cast(totalSlices); // determine slabs am_iter = avgMin.begin(); @@ -144,7 +144,7 @@ MRASlabIdentifier::GenerateSlabRegions() while (am_iter != avgMin.end()) { avgMinValue = *am_iter; - double sign = avgMinValue - average; + const double sign = avgMinValue - average; if ((sign * prevSign < 0) && (itk::Math::abs(sign) > m_Tolerance)) { slabIndex[m_SlicingDirection] = slabBegin; diff --git a/Modules/Filtering/BiasCorrection/include/itkMRIBiasFieldCorrectionFilter.hxx b/Modules/Filtering/BiasCorrection/include/itkMRIBiasFieldCorrectionFilter.hxx index 2daffac04d3..8454fffec5f 100644 --- a/Modules/Filtering/BiasCorrection/include/itkMRIBiasFieldCorrectionFilter.hxx +++ b/Modules/Filtering/BiasCorrection/include/itkMRIBiasFieldCorrectionFilter.hxx @@ -93,7 +93,7 @@ MRIBiasEnergyFunction::GetValue(const Parameters { while (!bIter.IsAtEnd()) { - double diff = iIter.Get() - bIter.Get(); + const double diff = iIter.Get() - bIter.Get(); total = total + (*m_InternalEnergyFunction)(diff); ++bIter; ++iIter; @@ -107,7 +107,7 @@ MRIBiasEnergyFunction::GetValue(const Parameters { if (mIter.Get() > 0.0) { - double diff = iIter.Get() - bIter.Get(); + const double diff = iIter.Get() - bIter.Get(); total = total + (*m_InternalEnergyFunction)(diff); } ++bIter; @@ -489,7 +489,7 @@ MRIBiasFieldCorrectionFilter::EstimateBia scales.Fill(100); optimizer->SetScales(scales); - int noOfBiasFieldCoefficients = bias.GetNumberOfCoefficients(); + const int noOfBiasFieldCoefficients = bias.GetNumberOfCoefficients(); typename EnergyFunctionType::ParametersType initialPosition(noOfBiasFieldCoefficients); for (int i = 0; i < noOfBiasFieldCoefficients; ++i) { @@ -550,8 +550,8 @@ MRIBiasFieldCorrectionFilter::CorrectImag mIter.GoToBegin(); while (!bIter.IsAtEnd()) { - double inputPixel = iIter.Get(); - double diff = inputPixel - bIter.Get(); + const double inputPixel = iIter.Get(); + const double diff = inputPixel - bIter.Get(); if (mIter.Get() > 0.0) { iIter.Set((Pixel)diff); @@ -570,7 +570,7 @@ MRIBiasFieldCorrectionFilter::CorrectImag itkDebugMacro("Output mask is not being used"); while (!bIter.IsAtEnd()) { - double diff = iIter.Get() - bIter.Get(); + const double diff = iIter.Get() - bIter.Get(); iIter.Set((Pixel)diff); ++bIter; ++iIter; @@ -583,7 +583,7 @@ void MRIBiasFieldCorrectionFilter::CorrectInterSliceIntensityInhomogeneity( InputImageRegionType region) { - IndexValueType lastSlice = + const IndexValueType lastSlice = region.GetIndex()[m_SlicingDirection] + static_cast(region.GetSize()[m_SlicingDirection]); InputImageRegionType sliceRegion; InputImageIndexType index = region.GetIndex(); @@ -591,7 +591,7 @@ MRIBiasFieldCorrectionFilter::CorrectInte sliceRegion.SetSize(size); BiasFieldType bias = this->EstimateBiasField(sliceRegion, 0, m_InterSliceCorrectionMaximumIteration); - double globalBiasCoef = bias.GetCoefficients()[0]; + const double globalBiasCoef = bias.GetCoefficients()[0]; size[m_SlicingDirection] = 1; sliceRegion.SetSize(size); @@ -649,7 +649,7 @@ MRIBiasFieldCorrectionFilter::GenerateDat this->GetBiasFieldSize(*iter, biasSize); BiasFieldType bias(static_cast(biasSize.size()), m_BiasFieldDegree, biasSize); - int nCoef = bias.GetNumberOfCoefficients(); + const int nCoef = bias.GetNumberOfCoefficients(); std::vector lastBiasCoef; lastBiasCoef.resize(nCoef); for (int i = 0; i < nCoef; ++i) @@ -765,9 +765,9 @@ template bool MRIBiasFieldCorrectionFilter::CheckMaskImage(ImageMaskType * mask) { - InputImageRegionType region = this->GetInput()->GetBufferedRegion(); + const InputImageRegionType region = this->GetInput()->GetBufferedRegion(); - ImageMaskRegionType m_region = mask->GetBufferedRegion(); + const ImageMaskRegionType m_region = mask->GetBufferedRegion(); if (region.GetSize() != m_region.GetSize()) { @@ -781,7 +781,7 @@ void MRIBiasFieldCorrectionFilter::Log1PImage(InternalImageType * source, InternalImageType * target) { - InternalImageRegionType region = source->GetRequestedRegion(); + const InternalImageRegionType region = source->GetRequestedRegion(); ImageRegionIterator s_iter(source, region); ImageRegionIterator t_iter(target, region); @@ -810,7 +810,7 @@ void MRIBiasFieldCorrectionFilter::ExpImage(InternalImageType * source, InternalImageType * target) { - InternalImageRegionType region = source->GetLargestPossibleRegion(); + const InternalImageRegionType region = source->GetLargestPossibleRegion(); ImageRegionIterator s_iter(source, region); ImageRegionIterator t_iter(target, region); @@ -871,8 +871,8 @@ MRIBiasFieldCorrectionFilter::AdjustSlabR indexLast[i] = indexFirst[i] + static_cast(size[i]) - 1; } - IndexValueType coordFirst = indexFirst[m_SlicingDirection]; - IndexValueType coordLast = indexLast[m_SlicingDirection]; + const IndexValueType coordFirst = indexFirst[m_SlicingDirection]; + const IndexValueType coordLast = indexLast[m_SlicingDirection]; OutputImageSizeType tempSize = size; @@ -881,8 +881,9 @@ MRIBiasFieldCorrectionFilter::AdjustSlabR auto iter = slabs.begin(); while (iter != slabs.end()) { - IndexValueType coordFirst2 = iter->GetIndex()[m_SlicingDirection]; - IndexValueType coordLast2 = coordFirst2 + static_cast(iter->GetSize()[m_SlicingDirection]) - 1; + const IndexValueType coordFirst2 = iter->GetIndex()[m_SlicingDirection]; + const IndexValueType coordLast2 = + coordFirst2 + static_cast(iter->GetSize()[m_SlicingDirection]) - 1; IndexValueType tempCoordFirst; if (coordFirst > coordFirst2) diff --git a/Modules/Filtering/BiasCorrection/include/itkN4BiasFieldCorrectionImageFilter.hxx b/Modules/Filtering/BiasCorrection/include/itkN4BiasFieldCorrectionImageFilter.hxx index 5261a304405..8844e349f45 100644 --- a/Modules/Filtering/BiasCorrection/include/itkN4BiasFieldCorrectionImageFilter.hxx +++ b/Modules/Filtering/BiasCorrection/include/itkN4BiasFieldCorrectionImageFilter.hxx @@ -110,7 +110,7 @@ N4BiasFieldCorrectionImageFilter::Generat } // Calculate the log of the input image. - RealImagePointer logInputImage = RealImageType::New(); + const RealImagePointer logInputImage = RealImageType::New(); logInputImage->CopyInformation(inputImage); logInputImage->SetRegions(inputRegion); logInputImage->Allocate(false); @@ -160,7 +160,7 @@ N4BiasFieldCorrectionImageFilter::Generat logBiasField->SetRegions(inputImage->GetLargestPossibleRegion()); logBiasField->AllocateInitialized(); - RealImagePointer logSharpenedImage = RealImageType::New(); + const RealImagePointer logSharpenedImage = RealImageType::New(); logSharpenedImage->CopyInformation(inputImage); logSharpenedImage->SetRegions(inputImage->GetLargestPossibleRegion()); logSharpenedImage->Allocate(false); @@ -196,13 +196,13 @@ N4BiasFieldCorrectionImageFilter::Generat subtracter1->SetInput1(logUncorrectedImage); subtracter1->SetInput2(logSharpenedImage); - RealImagePointer residualBiasField = subtracter1->GetOutput(); + const RealImagePointer residualBiasField = subtracter1->GetOutput(); residualBiasField->Update(); // Smooth the residual bias field estimate and add the resulting // control point grid to get the new total bias field estimate. - RealImagePointer newLogBiasField = this->UpdateBiasFieldEstimate(residualBiasField, numberOfIncludedPixels); + const RealImagePointer newLogBiasField = this->UpdateBiasFieldEstimate(residualBiasField, numberOfIncludedPixels); this->m_CurrentConvergenceMeasurement = this->CalculateConvergenceMeasurement(logBiasField, newLogBiasField); logBiasField = newLogBiasField; @@ -282,7 +282,7 @@ N4BiasFieldCorrectionImageFilter::Sharpen (!useMaskLabel && maskImageBufferRange[indexValue] != MaskPixelType{})) && (confidenceImageBufferRange.empty() || confidenceImageBufferRange[indexValue] > 0.0)) { - RealType pixel = unsharpenedImageBufferRange[indexValue]; + const RealType pixel = unsharpenedImageBufferRange[indexValue]; if (pixel > binMaximum) { binMaximum = pixel; @@ -293,7 +293,7 @@ N4BiasFieldCorrectionImageFilter::Sharpen } } } - RealType histogramSlope = (binMaximum - binMinimum) / static_cast(this->m_NumberOfHistogramBins - 1); + const RealType histogramSlope = (binMaximum - binMinimum) / static_cast(this->m_NumberOfHistogramBins - 1); // Create the intensity profile (within the masked region, if applicable) // using a triangular parzen windowing scheme. @@ -306,11 +306,11 @@ N4BiasFieldCorrectionImageFilter::Sharpen (!useMaskLabel && maskImageBufferRange[indexValue] != MaskPixelType{})) && (confidenceImageBufferRange.empty() || confidenceImageBufferRange[indexValue] > 0.0)) { - RealType pixel = unsharpenedImageBufferRange[indexValue]; + const RealType pixel = unsharpenedImageBufferRange[indexValue]; - RealType cidx = (static_cast(pixel) - binMinimum) / histogramSlope; - unsigned int idx = itk::Math::floor(cidx); - RealType offset = cidx - static_cast(idx); + const RealType cidx = (static_cast(pixel) - binMinimum) / histogramSlope; + const unsigned int idx = itk::Math::floor(cidx); + const RealType offset = cidx - static_cast(idx); if (offset == 0.0) { @@ -327,9 +327,10 @@ N4BiasFieldCorrectionImageFilter::Sharpen // Determine information about the intensity histogram and zero-pad // histogram to a power of 2. - RealType exponent = std::ceil(std::log(static_cast(this->m_NumberOfHistogramBins)) / std::log(2.0)) + 1; - auto paddedHistogramSize = static_cast(std::pow(static_cast(2.0), exponent) + 0.5); - auto histogramOffset = static_cast(0.5 * (paddedHistogramSize - this->m_NumberOfHistogramBins)); + const RealType exponent = + std::ceil(std::log(static_cast(this->m_NumberOfHistogramBins)) / std::log(2.0)) + 1; + auto paddedHistogramSize = static_cast(std::pow(static_cast(2.0), exponent) + 0.5); + auto histogramOffset = static_cast(0.5 * (paddedHistogramSize - this->m_NumberOfHistogramBins)); using FFTComputationType = double; using FFTComplexType = std::complex; @@ -351,9 +352,9 @@ N4BiasFieldCorrectionImageFilter::Sharpen // Create the Gaussian filter. - RealType scaledFWHM = this->m_BiasFieldFullWidthAtHalfMaximum / histogramSlope; - RealType expFactor = 4.0 * std::log(2.0) / itk::Math::sqr(scaledFWHM); - RealType scaleFactor = 2.0 * std::sqrt(std::log(2.0) / itk::Math::pi) / scaledFWHM; + const RealType scaledFWHM = this->m_BiasFieldFullWidthAtHalfMaximum / histogramSlope; + const RealType expFactor = 4.0 * std::log(2.0) / itk::Math::sqr(scaledFWHM); + const RealType scaleFactor = 2.0 * std::sqrt(std::log(2.0) / itk::Math::pi) / scaledFWHM; vnl_vector F(paddedHistogramSize, FFTComplexType(0.0, 0.0)); @@ -381,7 +382,7 @@ N4BiasFieldCorrectionImageFilter::Sharpen const auto wienerNoiseValue = static_cast(this->m_WienerFilterNoise); for (unsigned int n = 0; n < paddedHistogramSize; ++n) { - FFTComplexType c = vnl_complex_traits::conjugate(Ff[n]); + const FFTComplexType c = vnl_complex_traits::conjugate(Ff[n]); Gf[n] = c / (c * Ff[n] + wienerNoiseValue); } @@ -454,8 +455,8 @@ N4BiasFieldCorrectionImageFilter::Sharpen (!useMaskLabel && maskImageBufferRange[indexValue] != MaskPixelType{})) && (confidenceImageBufferRange.empty() || confidenceImageBufferRange[indexValue] > 0.0)) { - RealType cidx = (unsharpenedImageBufferRange[indexValue] - binMinimum) / histogramSlope; - unsigned int idx = itk::Math::floor(cidx); + const RealType cidx = (unsharpenedImageBufferRange[indexValue] - binMinimum) / histogramSlope; + const unsigned int idx = itk::Math::floor(cidx); RealType correctedPixel = 0; if (idx < E.size() - 1) @@ -498,8 +499,8 @@ N4BiasFieldCorrectionImageFilter::UpdateB const typename ImporterType::OutputImageType * parametricFieldEstimate = importer->GetOutput(); - PointSetPointer fieldPoints = PointSetType::New(); - auto & pointSTLContainer = fieldPoints->GetPoints()->CastToSTLContainer(); + const PointSetPointer fieldPoints = PointSetType::New(); + auto & pointSTLContainer = fieldPoints->GetPoints()->CastToSTLContainer(); pointSTLContainer.reserve(numberOfIncludedPixels); auto & pointDataSTLContainer = fieldPoints->GetPointData()->CastToSTLContainer(); pointDataSTLContainer.reserve(numberOfIncludedPixels); @@ -573,7 +574,7 @@ N4BiasFieldCorrectionImageFilter::UpdateB bspliner->SetPointWeights(weights); bspliner->Update(); - typename BiasFieldControlPointLatticeType::Pointer phiLattice = bspliner->GetPhiLattice(); + const typename BiasFieldControlPointLatticeType::Pointer phiLattice = bspliner->GetPhiLattice(); // Add the bias field control points to the current estimate. @@ -620,7 +621,7 @@ N4BiasFieldCorrectionImageFilter::Reconst reconstructer->SetSplineOrder(this->m_SplineOrder); reconstructer->SetSize(inputImage->GetLargestPossibleRegion().GetSize()); - typename ScalarImageType::Pointer biasFieldBsplineImage = reconstructer->GetOutput(); + const typename ScalarImageType::Pointer biasFieldBsplineImage = reconstructer->GetOutput(); biasFieldBsplineImage->Update(); using SelectorType = VectorIndexSelectionCastImageFilter; @@ -668,7 +669,7 @@ N4BiasFieldCorrectionImageFilter::Calcula (!useMaskLabel && maskImageBufferRange[indexValue] != MaskPixelType{})) && (confidenceImageBufferRange.empty() || confidenceImageBufferRange[indexValue] > 0.0)) { - RealType pixel = std::exp(subtracterImageBufferRange[indexValue]); + const RealType pixel = std::exp(subtracterImageBufferRange[indexValue]); N += 1.0; if (N > 1.0) diff --git a/Modules/Filtering/BiasCorrection/test/itkCompositeValleyFunctionTest.cxx b/Modules/Filtering/BiasCorrection/test/itkCompositeValleyFunctionTest.cxx index 2867e788f56..1fb25d85f1b 100644 --- a/Modules/Filtering/BiasCorrection/test/itkCompositeValleyFunctionTest.cxx +++ b/Modules/Filtering/BiasCorrection/test/itkCompositeValleyFunctionTest.cxx @@ -27,7 +27,7 @@ itkCompositeValleyFunctionTest(int, char *[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope // scope. - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); itk::Array means(2); itk::Array sigmas(2); @@ -54,8 +54,8 @@ itkCompositeValleyFunctionTest(int, char *[]) std::cout.setf(std::ios::scientific); std::cout.precision(12); - double interval1 = function.GetInterval(); - double interval2 = (function.GetUpperBound() - function.GetLowerBound()) / (1000000.0 - 1.0); + const double interval1 = function.GetInterval(); + const double interval2 = (function.GetUpperBound() - function.GetLowerBound()) / (1000000.0 - 1.0); if (itk::Math::abs(interval1 - interval2) > itk::NumericTraits::epsilon()) { std::cout << "Test fails: GetInterval()" << std::endl; @@ -64,10 +64,10 @@ itkCompositeValleyFunctionTest(int, char *[]) return EXIT_FAILURE; } - long numberOfSamples = function.GetNumberOfSamples(); - double measure = function.GetLowerBound() + interval1 * numberOfSamples * 0.5; - double value1 = function(measure); - double value2 = function.Evaluate(measure); + const long numberOfSamples = function.GetNumberOfSamples(); + const double measure = function.GetLowerBound() + interval1 * numberOfSamples * 0.5; + const double value1 = function(measure); + const double value2 = function.Evaluate(measure); if (itk::Math::abs(value1 - value2) > itk::NumericTraits::epsilon()) { diff --git a/Modules/Filtering/BiasCorrection/test/itkMRIBiasFieldCorrectionFilterTest.cxx b/Modules/Filtering/BiasCorrection/test/itkMRIBiasFieldCorrectionFilterTest.cxx index 9ee98409d39..d510464cb53 100644 --- a/Modules/Filtering/BiasCorrection/test/itkMRIBiasFieldCorrectionFilterTest.cxx +++ b/Modules/Filtering/BiasCorrection/test/itkMRIBiasFieldCorrectionFilterTest.cxx @@ -36,7 +36,7 @@ itkMRIBiasFieldCorrectionFilterTest(int, char *[]) using MaskType = itk::Image; using ImageIteratorType = itk::ImageRegionIteratorWithIndex; - bool SaveImages = false; + const bool SaveImages = false; ImageType::SizeType imageSize; ImageType::IndexType imageIndex; ImageType::RegionType imageRegion; @@ -87,7 +87,7 @@ itkMRIBiasFieldCorrectionFilterTest(int, char *[]) classSigmas[1] = 20.0; // creates a normal random variate generator - itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer randomGenerator = + const itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer randomGenerator = itk::Statistics::MersenneTwisterRandomVariateGenerator::New(); // fills the image with a sphere filled with intensity values from a @@ -122,7 +122,7 @@ itkMRIBiasFieldCorrectionFilterTest(int, char *[]) // creates a bias field using BiasFieldType = itk::MultivariateLegendrePolynomial; BiasFieldType::DomainSizeType biasSize(3); - int biasDegree = 3; + const int biasDegree = 3; biasSize[0] = imageSize[0]; biasSize[1] = imageSize[1]; biasSize[2] = imageSize[2]; @@ -181,26 +181,26 @@ itkMRIBiasFieldCorrectionFilterTest(int, char *[]) } std::cout << "Absolute Avg. error before correction = " << sumOfError / (imageSize[0] * imageSize[1] * imageSize[2]) << std::endl; - double origSumError = sumOfError; + const double origSumError = sumOfError; std::cout << "Computing bias correction without mask, 2 classes 10,10 - 200,20" << std::endl; filter->SetInput(imageWithBias); - int slicingDirection = 2; - bool isBiasFieldMultiplicative = true; - bool usingSlabIdentification = true; - bool usingBiasFieldCorrection = true; - bool generatingOutput = true; - unsigned int slabNumberOfSamples = 10; - InputImagePixelType slabBackgroundMinimumThreshold = 0; - double slabTolerance = 0.0; - int volumeCorrectionMaximumIteration = 200; - int interSliceCorrectionMaximumIteration = 100; - double optimizerInitialRadius = 0.02; - double optimizerGrowthFactor = 1.01; - double optimizerShrinkFactor = std::pow(optimizerGrowthFactor, -0.25); - bool usingInterSliceIntensityCorrection = true; + const int slicingDirection = 2; + const bool isBiasFieldMultiplicative = true; + bool usingSlabIdentification = true; + const bool usingBiasFieldCorrection = true; + const bool generatingOutput = true; + const unsigned int slabNumberOfSamples = 10; + const InputImagePixelType slabBackgroundMinimumThreshold = 0; + const double slabTolerance = 0.0; + int volumeCorrectionMaximumIteration = 200; + int interSliceCorrectionMaximumIteration = 100; + double optimizerInitialRadius = 0.02; + const double optimizerGrowthFactor = 1.01; + const double optimizerShrinkFactor = std::pow(optimizerGrowthFactor, -0.25); + bool usingInterSliceIntensityCorrection = true; filter->SetSlabNumberOfSamples(slabNumberOfSamples); diff --git a/Modules/Filtering/BiasCorrection/test/itkN4BiasFieldCorrectionImageFilterTest.cxx b/Modules/Filtering/BiasCorrection/test/itkN4BiasFieldCorrectionImageFilterTest.cxx index 677c44e07b1..797bed7705e 100644 --- a/Modules/Filtering/BiasCorrection/test/itkN4BiasFieldCorrectionImageFilterTest.cxx +++ b/Modules/Filtering/BiasCorrection/test/itkN4BiasFieldCorrectionImageFilterTest.cxx @@ -93,7 +93,7 @@ ConvertVector(std::string optionString) values.push_back(value); while (crosspos != std::string::npos) { - std::string::size_type crossposfrom = crosspos; + const std::string::size_type crossposfrom = crosspos; crosspos = optionString.find('x', crossposfrom + 1); if (crosspos == std::string::npos) { @@ -169,34 +169,34 @@ N4(int argc, char * argv[]) using CorrecterType = itk::N4BiasFieldCorrectionImageFilter; auto correcter = CorrecterType::New(); - unsigned int splineOrder = 3; + const unsigned int splineOrder = 3; correcter->SetSplineOrder(splineOrder); ITK_TEST_SET_GET_VALUE(splineOrder, correcter->GetSplineOrder()); correcter->SetWienerFilterNoise(0.01); - typename CorrecterType::RealType biasFieldFullWidthAtHalfMaximum = 0.15; + const typename CorrecterType::RealType biasFieldFullWidthAtHalfMaximum = 0.15; correcter->SetBiasFieldFullWidthAtHalfMaximum(biasFieldFullWidthAtHalfMaximum); ITK_TEST_SET_GET_VALUE(biasFieldFullWidthAtHalfMaximum, correcter->GetBiasFieldFullWidthAtHalfMaximum()); - typename CorrecterType::RealType convergenceThreshold = 0.0000001; + const typename CorrecterType::RealType convergenceThreshold = 0.0000001; correcter->SetConvergenceThreshold(convergenceThreshold); ITK_TEST_SET_GET_VALUE(convergenceThreshold, correcter->GetConvergenceThreshold()); - unsigned int numberOfHistogramBins = 200; + const unsigned int numberOfHistogramBins = 200; correcter->SetNumberOfHistogramBins(numberOfHistogramBins); ITK_TEST_SET_GET_VALUE(numberOfHistogramBins, correcter->GetNumberOfHistogramBins()); - typename CorrecterType::RealType wienerFilterNoise = 0.01; + const typename CorrecterType::RealType wienerFilterNoise = 0.01; correcter->SetWienerFilterNoise(wienerFilterNoise); ITK_TEST_SET_GET_VALUE(wienerFilterNoise, correcter->GetWienerFilterNoise()); - typename CorrecterType::MaskPixelType maskLabel = + const typename CorrecterType::MaskPixelType maskLabel = itk::NumericTraits::OneValue(); correcter->SetMaskLabel(maskLabel); ITK_TEST_SET_GET_VALUE(maskLabel, correcter->GetMaskLabel()); - bool useMaskLabel = false; + const bool useMaskLabel = false; ITK_TEST_SET_GET_BOOLEAN(correcter, UseMaskLabel, useMaskLabel); // Handle the number of iterations @@ -238,7 +238,7 @@ N4(int argc, char * argv[]) for (unsigned int d = 0; d < ImageDimension; ++d) { - float domain = + const float domain = static_cast(inputImage->GetLargestPossibleRegion().GetSize()[d] - 1) * inputImage->GetSpacing()[d]; auto numberOfSpans = static_cast(std::ceil(domain / splineDistance)); auto extraPadding = @@ -310,11 +310,11 @@ N4(int argc, char * argv[]) // Test the reconstruction of the log bias field - ImagePointer originalInputImage = reader->GetOutput(); + const ImagePointer originalInputImage = reader->GetOutput(); reader->UpdateOutputInformation(); correcter->SetMaskImage(nullptr); correcter->SetInput(originalInputImage); - typename CorrecterType::RealImagePointer biasField = + const typename CorrecterType::RealImagePointer biasField = correcter->ReconstructBiasField(correcter->GetLogBiasFieldControlPointLattice()); WriteImage(biasField.GetPointer(), (std::string(argv[3]) + "-LogBiasField.nrrd").c_str()); diff --git a/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryClosingByReconstructionImageFilter.hxx b/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryClosingByReconstructionImageFilter.hxx index c6918debf1a..73165b75ae2 100644 --- a/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryClosingByReconstructionImageFilter.hxx +++ b/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryClosingByReconstructionImageFilter.hxx @@ -44,7 +44,7 @@ BinaryClosingByReconstructionImageFilter::GenerateInputReq Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryDilateImageFilter.hxx b/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryDilateImageFilter.hxx index b98b58deee4..371a9e7484b 100644 --- a/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryDilateImageFilter.hxx +++ b/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryDilateImageFilter.hxx @@ -42,15 +42,15 @@ BinaryDilateImageFilter::GenerateData() this->AllocateOutputs(); // Retrieve input and output pointers - typename OutputImageType::Pointer output = this->GetOutput(); - typename InputImageType::ConstPointer input = this->GetInput(); + const typename OutputImageType::Pointer output = this->GetOutput(); + const typename InputImageType::ConstPointer input = this->GetInput(); // Get values from superclass - InputPixelType foregroundValue = this->GetForegroundValue(); - InputPixelType backgroundValue = this->GetBackgroundValue(); - KernelType kernel = this->GetKernel(); - auto radius = InputSizeType::Filled(1); - typename TOutputImage::RegionType outputRegion = output->GetBufferedRegion(); + const InputPixelType foregroundValue = this->GetForegroundValue(); + const InputPixelType backgroundValue = this->GetBackgroundValue(); + const KernelType kernel = this->GetKernel(); + auto radius = InputSizeType::Filled(1); + const typename TOutputImage::RegionType outputRegion = output->GetBufferedRegion(); // compute the size of the temp image. It is needed to create the progress // reporter. @@ -88,7 +88,7 @@ BinaryDilateImageFilter::GenerateData() for (inIt.GoToBegin(), outIt.GoToBegin(); !outIt.IsAtEnd(); ++outIt, ++inIt) { - InputPixelType value = inIt.Get(); + const InputPixelType value = inIt.Get(); // replace foreground pixels with the default background if (Math::ExactlyEquals(value, foregroundValue)) { @@ -146,7 +146,7 @@ BinaryDilateImageFilter::GenerateData() for (iRegIt.GoToBegin(), tmpRegIt.GoToBegin(); !tmpRegIt.IsAtEnd(); ++iRegIt, ++tmpRegIt) { - OutputPixelType pxl = iRegIt.Get(); + const OutputPixelType pxl = iRegIt.Get(); if (Math::ExactlyEquals(pxl, foregroundValue)) { tmpRegIt.Set(onTag); @@ -178,8 +178,8 @@ BinaryDilateImageFilter::GenerateData() cbc.SetConstant(backgroundTag); oNeighbIt.OverrideBoundaryCondition(&cbc); - unsigned int neighborhoodSize = oNeighbIt.Size(); - unsigned int centerPixelCode = neighborhoodSize / 2; + const unsigned int neighborhoodSize = oNeighbIt.Size(); + const unsigned int centerPixelCode = neighborhoodSize / 2; std::queue propagQueue; @@ -241,7 +241,7 @@ BinaryDilateImageFilter::GenerateData() NeighborIndexContainer & idxDifferenceSet = this->GetDifferenceSet(centerPixelCode); for (itIdx = idxDifferenceSet.begin(); itIdx != idxDifferenceSet.end(); ++itIdx) { - IndexType idx = tmpRegIndexIt.GetIndex() + *itIdx; + const IndexType idx = tmpRegIndexIt.GetIndex() + *itIdx; if (outputRegion.IsInside(idx)) { output->SetPixel(idx, static_cast(foregroundValue)); @@ -255,7 +255,7 @@ BinaryDilateImageFilter::GenerateData() while (!propagQueue.empty()) { // Extract pixel index from queue - IndexType currentIndex = propagQueue.front(); + const IndexType currentIndex = propagQueue.front(); propagQueue.pop(); nit += currentIndex - nit.GetIndex(); @@ -406,11 +406,11 @@ BinaryDilateImageFilter::GenerateData() while (!ouRegIndexIt.IsAtEnd()) { // Retrieve index of current output pixel - IndexType currentIndex = ouRegIndexIt.GetIndex(); + const IndexType currentIndex = ouRegIndexIt.GetIndex(); for (vecIt = vecBeginIt; vecIt != vecEndIt; ++vecIt) { // Translate - IndexType translatedIndex = currentIndex - *vecIt; + const IndexType translatedIndex = currentIndex - *vecIt; // translated index now is an index in input image in the // output requested region padded. Theoretically, this translated @@ -435,10 +435,10 @@ BinaryDilateImageFilter::GenerateData() { while (!ouRegIndexIt.IsAtEnd()) { - IndexType currentIndex = ouRegIndexIt.GetIndex(); + const IndexType currentIndex = ouRegIndexIt.GetIndex(); for (vecIt = vecBeginIt; vecIt != vecEndIt; ++vecIt) { - IndexType translatedIndex = currentIndex - *vecIt; + const IndexType translatedIndex = currentIndex - *vecIt; if (inputRegionForThread.IsInside(translatedIndex) && Math::ExactlyEquals(input->GetPixel(translatedIndex), foregroundValue)) diff --git a/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryErodeImageFilter.hxx b/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryErodeImageFilter.hxx index d137383e2a2..e07bfd5c498 100644 --- a/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryErodeImageFilter.hxx +++ b/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryErodeImageFilter.hxx @@ -42,15 +42,15 @@ BinaryErodeImageFilter::GenerateData() this->AllocateOutputs(); // Retrieve input and output pointers - typename OutputImageType::Pointer output = this->GetOutput(); - typename InputImageType::ConstPointer input = this->GetInput(); + const typename OutputImageType::Pointer output = this->GetOutput(); + const typename InputImageType::ConstPointer input = this->GetInput(); // Get values from superclass - InputPixelType foregroundValue = this->GetForegroundValue(); - InputPixelType backgroundValue = this->GetBackgroundValue(); - KernelType kernel = this->GetKernel(); - auto radius = InputSizeType::Filled(1); - typename TOutputImage::RegionType outputRegion = output->GetBufferedRegion(); + const InputPixelType foregroundValue = this->GetForegroundValue(); + const InputPixelType backgroundValue = this->GetBackgroundValue(); + const KernelType kernel = this->GetKernel(); + auto radius = InputSizeType::Filled(1); + const typename TOutputImage::RegionType outputRegion = output->GetBufferedRegion(); // compute the size of the temp image. It is needed to create the progress // reporter. @@ -136,7 +136,7 @@ BinaryErodeImageFilter::GenerateData() for (iRegIt.GoToBegin(), tmpRegIt.GoToBegin(); !tmpRegIt.IsAtEnd(); ++iRegIt, ++tmpRegIt) { - OutputPixelType pxl = iRegIt.Get(); + const OutputPixelType pxl = iRegIt.Get(); if (Math::NotExactlyEquals(pxl, foregroundValue)) { tmpRegIt.Set(onTag); @@ -168,8 +168,8 @@ BinaryErodeImageFilter::GenerateData() cbc.SetConstant(backgroundTag); oNeighbIt.OverrideBoundaryCondition(&cbc); - unsigned int neighborhoodSize = oNeighbIt.Size(); - unsigned int centerPixelCode = neighborhoodSize / 2; + const unsigned int neighborhoodSize = oNeighbIt.Size(); + const unsigned int centerPixelCode = neighborhoodSize / 2; std::queue propagQueue; @@ -192,7 +192,7 @@ BinaryErodeImageFilter::GenerateData() for (tmpRegIndexIt.GoToBegin(), oNeighbIt.GoToBegin(); !tmpRegIndexIt.IsAtEnd(); ++tmpRegIndexIt, ++oNeighbIt) { - unsigned char tmpValue = tmpRegIndexIt.Get(); + const unsigned char tmpValue = tmpRegIndexIt.Get(); // Test current pixel: it is active ( on ) or not? if (tmpValue == onTag) @@ -233,7 +233,7 @@ BinaryErodeImageFilter::GenerateData() NeighborIndexContainer & idxDifferenceSet = this->GetDifferenceSet(centerPixelCode); for (itIdx = idxDifferenceSet.begin(); itIdx != idxDifferenceSet.end(); ++itIdx) { - IndexType idx = tmpRegIndexIt.GetIndex() + *itIdx; + const IndexType idx = tmpRegIndexIt.GetIndex() + *itIdx; if (outputRegion.IsInside(idx)) { output->SetPixel(idx, backgroundValue); @@ -247,7 +247,7 @@ BinaryErodeImageFilter::GenerateData() while (!propagQueue.empty()) { // Extract pixel index from queue - IndexType currentIndex = propagQueue.front(); + const IndexType currentIndex = propagQueue.front(); propagQueue.pop(); nit += currentIndex - nit.GetIndex(); @@ -400,11 +400,11 @@ BinaryErodeImageFilter::GenerateData() while (!ouRegIndexIt.IsAtEnd()) { // Retrieve index of current output pixel - IndexType currentIndex = ouRegIndexIt.GetIndex(); + const IndexType currentIndex = ouRegIndexIt.GetIndex(); for (vecIt = vecBeginIt; vecIt != vecEndIt; ++vecIt) { // Translate - IndexType translatedIndex = currentIndex - *vecIt; + const IndexType translatedIndex = currentIndex - *vecIt; // translated index now is an index in input image in the // output requested region padded. Theoretically, this translated @@ -429,10 +429,10 @@ BinaryErodeImageFilter::GenerateData() { while (!ouRegIndexIt.IsAtEnd()) { - IndexType currentIndex = ouRegIndexIt.GetIndex(); + const IndexType currentIndex = ouRegIndexIt.GetIndex(); for (vecIt = vecBeginIt; vecIt != vecEndIt; ++vecIt) { - IndexType translatedIndex = currentIndex - *vecIt; + const IndexType translatedIndex = currentIndex - *vecIt; if (inputRegionForThread.IsInside(translatedIndex) && Math::NotExactlyEquals(input->GetPixel(translatedIndex), foregroundValue)) @@ -452,8 +452,8 @@ BinaryErodeImageFilter::GenerateData() for (inIt.GoToBegin(), outIt.GoToBegin(); !outIt.IsAtEnd(); ++outIt, ++inIt) { - InputPixelType inValue = inIt.Get(); - OutputPixelType outValue = outIt.Get(); + const InputPixelType inValue = inIt.Get(); + const OutputPixelType outValue = outIt.Get(); if (Math::ExactlyEquals(outValue, backgroundValue) && Math::NotExactlyEquals(inValue, foregroundValue)) { outIt.Set(static_cast(inValue)); diff --git a/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryMorphologyImageFilter.hxx b/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryMorphologyImageFilter.hxx index fb77d762d21..717de939f18 100644 --- a/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryMorphologyImageFilter.hxx +++ b/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryMorphologyImageFilter.hxx @@ -139,7 +139,7 @@ BinaryMorphologyImageFilter::AnalyzeKernel() auto padBy = InputSizeType::Filled(1); NeighborhoodIterator SEoNeighbIt(padBy, tmpSEImage, tmpSEImage->GetRequestedRegion()); SEoNeighbIt.OverrideBoundaryCondition(&cbc); - SizeValueType neighborhoodSize = SEoNeighbIt.Size(); + const SizeValueType neighborhoodSize = SEoNeighbIt.Size(); // Use a FIFO queue in order to perform the burning process // which allows to identify the connected components of SE @@ -165,14 +165,14 @@ BinaryMorphologyImageFilter::AnalyzeKernel() // We know also that we start a new CC, so we store the position of this // element relatively to center of kernel ( i.e a vector ). - OffsetType offset = this->GetKernel().GetOffset(kernel_it - KernelBegin); + const OffsetType offset = this->GetKernel().GetOffset(kernel_it - KernelBegin); m_KernelCCVector.push_back(offset); // Process while FIFO queue is not empty while (!propagQueue.empty()) { // Extract pixel index from queue - IndexType currentIndex = propagQueue.front(); + const IndexType currentIndex = propagQueue.front(); propagQueue.pop(); // Now look for neighbours that are also ON pixels @@ -232,14 +232,14 @@ BinaryMorphologyImageFilter::AnalyzeKernel() ++kernelOnElementsIt) { // Get the index in the SE neighb - IndexValueType k = *kernelOnElementsIt; + const IndexValueType k = *kernelOnElementsIt; // Get the Nd position of current SE element. In order to do // that, we have not a "GetIndex" function. So first we get the // offset relatively to the center SE element and add it to the // index of this center SE element: - OffsetType currentOffset = this->GetKernel().GetOffset(k); - IndexType currentShiftedPosition = centerElementPosition + currentOffset; + const OffsetType currentOffset = this->GetKernel().GetOffset(k); + IndexType currentShiftedPosition = centerElementPosition + currentOffset; // Add to current element position the offset corresponding the // current adj direction @@ -279,12 +279,12 @@ BinaryMorphologyImageFilter::AnalyzeKernel() // retrieve the index offset relatively to the current NOT // shifted SE element - unsigned int currentRelativeIndexOffset = this->GetKernel().GetNeighborhoodIndex(adjNeigh.GetOffset(ii)) - - this->GetKernel().GetCenterNeighborhoodIndex(); + const unsigned int currentRelativeIndexOffset = this->GetKernel().GetNeighborhoodIndex(adjNeigh.GetOffset(ii)) - + this->GetKernel().GetCenterNeighborhoodIndex(); // Now thanks to this relative offset, we can get the absolute // neigh index of the current shifted SE element. - unsigned int currentShiftedIndex = k /*NOT shifted position*/ + currentRelativeIndexOffset; + const unsigned int currentShiftedIndex = k /*NOT shifted position*/ + currentRelativeIndexOffset; // Test if shifted element is OFF: in fact diff(dir) = all the // elements of SE + dir where elements of SE is ON and @@ -302,13 +302,13 @@ BinaryMorphologyImageFilter::AnalyzeKernel() // center of the kernel ( the difference set is theoretically empty // in this case because there is no shift ) we put the kernel set // itself, useful for the rest of the process. - unsigned int centerKernelIndex = adjNeigh.Size() / 2; + const unsigned int centerKernelIndex = adjNeigh.Size() / 2; kernel_it = KernelBegin; for (IndexValueType k = 0; kernel_it != KernelEnd; ++kernel_it, ++k) { if (*kernel_it) { - OffsetType currentOffset = this->GetKernel().GetOffset(k); + const OffsetType currentOffset = this->GetKernel().GetOffset(k); m_KernelDifferenceSets[centerKernelIndex].push_back(currentOffset); } } diff --git a/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryOpeningByReconstructionImageFilter.hxx b/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryOpeningByReconstructionImageFilter.hxx index dd17d8e691d..c7d0b05c4d5 100644 --- a/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryOpeningByReconstructionImageFilter.hxx +++ b/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryOpeningByReconstructionImageFilter.hxx @@ -41,7 +41,7 @@ BinaryOpeningByReconstructionImageFilter::GenerateInputReq Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryPruningImageFilter.hxx b/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryPruningImageFilter.hxx index 59b1f86ddbb..f1497cd0a50 100644 --- a/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryPruningImageFilter.hxx +++ b/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryPruningImageFilter.hxx @@ -32,7 +32,7 @@ BinaryPruningImageFilter::BinaryPruningImageFilter() { this->SetNumberOfRequiredOutputs(1); - OutputImagePointer pruneImage = OutputImageType::New(); + const OutputImagePointer pruneImage = OutputImageType::New(); this->SetNthOutput(0, pruneImage.GetPointer()); m_Iteration = 3; @@ -56,14 +56,14 @@ void BinaryPruningImageFilter::PrepareData() { itkDebugMacro("PrepareData Start"); - OutputImagePointer pruneImage = GetPruning(); + const OutputImagePointer pruneImage = GetPruning(); - InputImagePointer inputImage = dynamic_cast(ProcessObject::GetInput(0)); + const InputImagePointer inputImage = dynamic_cast(ProcessObject::GetInput(0)); pruneImage->SetBufferedRegion(pruneImage->GetRequestedRegion()); pruneImage->Allocate(); - typename OutputImageType::RegionType region = pruneImage->GetRequestedRegion(); + const typename OutputImageType::RegionType region = pruneImage->GetRequestedRegion(); ImageRegionConstIterator it(inputImage, region); ImageRegionIterator ot(pruneImage, region); @@ -87,21 +87,21 @@ void BinaryPruningImageFilter::ComputePruneImage() { itkDebugMacro("ComputeThinImage Start"); - OutputImagePointer pruneImage = GetPruning(); + const OutputImagePointer pruneImage = GetPruning(); - typename OutputImageType::RegionType region = pruneImage->GetRequestedRegion(); + const typename OutputImageType::RegionType region = pruneImage->GetRequestedRegion(); auto radius = MakeFilled(1); NeighborhoodIteratorType ot(radius, pruneImage, region); - typename NeighborhoodIteratorType::OffsetType offset1 = { { -1, -1 } }; - typename NeighborhoodIteratorType::OffsetType offset2 = { { -1, 0 } }; - typename NeighborhoodIteratorType::OffsetType offset3 = { { -1, 1 } }; - typename NeighborhoodIteratorType::OffsetType offset4 = { { 0, 1 } }; - typename NeighborhoodIteratorType::OffsetType offset5 = { { 1, 1 } }; - typename NeighborhoodIteratorType::OffsetType offset6 = { { 1, 0 } }; - typename NeighborhoodIteratorType::OffsetType offset7 = { { 1, -1 } }; - typename NeighborhoodIteratorType::OffsetType offset8 = { { 0, -1 } }; + const typename NeighborhoodIteratorType::OffsetType offset1 = { { -1, -1 } }; + const typename NeighborhoodIteratorType::OffsetType offset2 = { { -1, 0 } }; + const typename NeighborhoodIteratorType::OffsetType offset3 = { { -1, 1 } }; + const typename NeighborhoodIteratorType::OffsetType offset4 = { { 0, 1 } }; + const typename NeighborhoodIteratorType::OffsetType offset5 = { { 1, 1 } }; + const typename NeighborhoodIteratorType::OffsetType offset6 = { { 1, 0 } }; + const typename NeighborhoodIteratorType::OffsetType offset7 = { { 1, -1 } }; + const typename NeighborhoodIteratorType::OffsetType offset8 = { { 0, -1 } }; unsigned int count = 0; while (count < m_Iteration) diff --git a/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryThinningImageFilter.hxx b/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryThinningImageFilter.hxx index 8dc636a2860..1cdca586802 100644 --- a/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryThinningImageFilter.hxx +++ b/Modules/Filtering/BinaryMathematicalMorphology/include/itkBinaryThinningImageFilter.hxx @@ -33,7 +33,7 @@ BinaryThinningImageFilter::BinaryThinningImageFilter( { this->SetNumberOfRequiredOutputs(1); - OutputImagePointer thinImage = OutputImageType::New(); + const OutputImagePointer thinImage = OutputImageType::New(); this->SetNthOutput(0, thinImage.GetPointer()); } @@ -57,14 +57,14 @@ void BinaryThinningImageFilter::PrepareData() { itkDebugMacro("PrepareData Start"); - OutputImagePointer thinImage = GetThinning(); + const OutputImagePointer thinImage = GetThinning(); - InputImagePointer inputImage = dynamic_cast(ProcessObject::GetInput(0)); + const InputImagePointer inputImage = dynamic_cast(ProcessObject::GetInput(0)); thinImage->SetBufferedRegion(thinImage->GetRequestedRegion()); thinImage->Allocate(); - typename OutputImageType::RegionType region = thinImage->GetRequestedRegion(); + const typename OutputImageType::RegionType region = thinImage->GetRequestedRegion(); ImageRegionConstIterator it(inputImage, region); ImageRegionIterator ot(thinImage, region); @@ -97,9 +97,9 @@ void BinaryThinningImageFilter::ComputeThinImage() { itkDebugMacro("ComputeThinImage Start"); - OutputImagePointer thinImage = GetThinning(); + const OutputImagePointer thinImage = GetThinning(); - typename OutputImageType::RegionType region = thinImage->GetRequestedRegion(); + const typename OutputImageType::RegionType region = thinImage->GetRequestedRegion(); auto radius = MakeFilled(1); NeighborhoodIteratorType ot(radius, thinImage, region); @@ -107,14 +107,14 @@ BinaryThinningImageFilter::ComputeThinImage() // Create a set of offsets from the center. // This numbering follows that of Gonzalez and Woods. using OffsetType = typename NeighborhoodIteratorType::OffsetType; - OffsetType o2 = { { 0, -1 } }; - OffsetType o3 = { { 1, -1 } }; - OffsetType o4 = { { 1, 0 } }; - OffsetType o5 = { { 1, 1 } }; - OffsetType o6 = { { 0, 1 } }; - OffsetType o7 = { { -1, 1 } }; - OffsetType o8 = { { -1, 0 } }; - OffsetType o9 = { { -1, -1 } }; + const OffsetType o2 = { { 0, -1 } }; + const OffsetType o3 = { { 1, -1 } }; + const OffsetType o4 = { { 1, 0 } }; + const OffsetType o5 = { { 1, 1 } }; + const OffsetType o6 = { { 0, 1 } }; + const OffsetType o7 = { { -1, 1 } }; + const OffsetType o8 = { { -1, 0 } }; + const OffsetType o9 = { { -1, -1 } }; PixelType p2; PixelType p3; @@ -172,7 +172,7 @@ BinaryThinningImageFilter::ComputeThinImage() // neighbor implies that p1 is the end point of a skeleton // stroke and obviously should not be deleted. Deleting p1 // if it has seven such neighbors would cause erosion into a region. - PixelType numberOfOnNeighbors = p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9; + const PixelType numberOfOnNeighbors = p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9; if (numberOfOnNeighbors > 1 && numberOfOnNeighbors < 7) { diff --git a/Modules/Filtering/BinaryMathematicalMorphology/include/itkObjectMorphologyImageFilter.hxx b/Modules/Filtering/BinaryMathematicalMorphology/include/itkObjectMorphologyImageFilter.hxx index 470de27d546..1f7ed59d2ca 100644 --- a/Modules/Filtering/BinaryMathematicalMorphology/include/itkObjectMorphologyImageFilter.hxx +++ b/Modules/Filtering/BinaryMathematicalMorphology/include/itkObjectMorphologyImageFilter.hxx @@ -50,7 +50,7 @@ ObjectMorphologyImageFilter::GenerateInputRe Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); + const typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); if (!inputPtr) { @@ -100,7 +100,7 @@ ObjectMorphologyImageFilter::BeforeThreadedG this->GetOutput()->FillBuffer(0); } - RegionType requestedRegion = this->GetOutput()->GetRequestedRegion(); + const RegionType requestedRegion = this->GetOutput()->GetRequestedRegion(); auto iRegIter = ImageRegionConstIterator(this->GetInput(), requestedRegion); auto oRegIter = ImageRegionIterator(this->GetOutput(), requestedRegion); @@ -124,8 +124,8 @@ ObjectMorphologyImageFilter::DynamicThreaded const OutputImageRegionType & outputRegionForThread) { // Find the boundary "faces" - NeighborhoodAlgorithm::ImageBoundaryFacesCalculator fC; - typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = + NeighborhoodAlgorithm::ImageBoundaryFacesCalculator fC; + const typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = fC(this->GetInput(), outputRegionForThread, m_Kernel.GetRadius()); diff --git a/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryClosingByReconstructionImageFilterTest.cxx b/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryClosingByReconstructionImageFilterTest.cxx index 3ef90f82f25..fa3189c9a13 100644 --- a/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryClosingByReconstructionImageFilterTest.cxx +++ b/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryClosingByReconstructionImageFilterTest.cxx @@ -61,12 +61,12 @@ itkBinaryClosingByReconstructionImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(reconstructionFilter, BinaryClosingByReconstructionImageFilter, KernelImageFilter); - itk::SimpleFilterWatcher watcher(reconstructionFilter, "filter"); + const itk::SimpleFilterWatcher watcher(reconstructionFilter, "filter"); auto fullyConnected = static_cast(std::stoi(argv[3])); ITK_TEST_SET_GET_BOOLEAN(reconstructionFilter, FullyConnected, fullyConnected); - typename FilterType::InputImagePixelType foregroundValue = std::stoi(argv[4]); + const typename FilterType::InputImagePixelType foregroundValue = std::stoi(argv[4]); reconstructionFilter->SetForegroundValue(foregroundValue); ITK_TEST_SET_GET_VALUE(foregroundValue, reconstructionFilter->GetForegroundValue()); diff --git a/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryDilateImageFilterTest.cxx b/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryDilateImageFilterTest.cxx index 62aba34a254..cc42fc676d7 100644 --- a/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryDilateImageFilterTest.cxx +++ b/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryDilateImageFilterTest.cxx @@ -56,7 +56,7 @@ itkBinaryDilateImageFilterTest(int, char *[]) start[0] = 0; start[1] = 0; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; // Initialize Image inputImage->SetRegions(region); @@ -121,7 +121,7 @@ itkBinaryDilateImageFilterTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, BinaryDilateImageFilter, BinaryMorphologyImageFilter); - itk::SimpleFilterWatcher filterWatcher(filter); + const itk::SimpleFilterWatcher filterWatcher(filter); // Create the structuring element myKernelType ball; @@ -140,7 +140,7 @@ itkBinaryDilateImageFilterTest(int, char *[]) // Get the Smart Pointer to the Filter Output - myImageType::Pointer outputImage = filter->GetOutput(); + const myImageType::Pointer outputImage = filter->GetOutput(); // Execute the filter ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); diff --git a/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryDilateImageFilterTest3.cxx b/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryDilateImageFilterTest3.cxx index 9d5f7c4f2f4..7834b3ae020 100644 --- a/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryDilateImageFilterTest3.cxx +++ b/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryDilateImageFilterTest3.cxx @@ -104,7 +104,7 @@ itkBinaryDilateImageFilterTest3(int argc, char * argv[]) return EXIT_FAILURE; } - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryErodeImageFilterTest.cxx b/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryErodeImageFilterTest.cxx index 4f885d7898c..dd8ab3a75d8 100644 --- a/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryErodeImageFilterTest.cxx +++ b/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryErodeImageFilterTest.cxx @@ -56,7 +56,7 @@ itkBinaryErodeImageFilterTest(int, char *[]) start[0] = 0; start[1] = 0; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; // Initialize Image inputImage->SetRegions(region); @@ -121,7 +121,7 @@ itkBinaryErodeImageFilterTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, BinaryErodeImageFilter, BinaryMorphologyImageFilter); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); // Create the structuring element myKernelType ball; @@ -139,7 +139,7 @@ itkBinaryErodeImageFilterTest(int, char *[]) ITK_TEST_SET_GET_VALUE(fgValue, filter->GetErodeValue()); // Get the Smart Pointer to the Filter Output - myImageType::Pointer outputImage = filter->GetOutput(); + const myImageType::Pointer outputImage = filter->GetOutput(); // Execute the filter diff --git a/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryErodeImageFilterTest3.cxx b/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryErodeImageFilterTest3.cxx index 2fdc3ccc50b..bf0dcd21948 100644 --- a/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryErodeImageFilterTest3.cxx +++ b/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryErodeImageFilterTest3.cxx @@ -104,7 +104,7 @@ itkBinaryErodeImageFilterTest3(int argc, char * argv[]) return EXIT_FAILURE; } - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryMorphologicalClosingImageFilterTest.cxx b/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryMorphologicalClosingImageFilterTest.cxx index c8ef3981191..4b190efaa23 100644 --- a/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryMorphologicalClosingImageFilterTest.cxx +++ b/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryMorphologicalClosingImageFilterTest.cxx @@ -74,7 +74,7 @@ itkBinaryMorphologicalClosingImageFilterTest(int argc, char * argv[]) } filter->SetForegroundValue(std::stoi(argv[5])); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryMorphologicalOpeningImageFilterTest.cxx b/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryMorphologicalOpeningImageFilterTest.cxx index bd9ead8fe4b..1039990eb48 100644 --- a/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryMorphologicalOpeningImageFilterTest.cxx +++ b/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryMorphologicalOpeningImageFilterTest.cxx @@ -71,7 +71,7 @@ itkBinaryMorphologicalOpeningImageFilterTest(int argc, char * argv[]) } filter->SetForegroundValue(std::stoi(argv[5])); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryOpeningByReconstructionImageFilterTest.cxx b/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryOpeningByReconstructionImageFilterTest.cxx index 8c69651272a..294cf34d9f2 100644 --- a/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryOpeningByReconstructionImageFilterTest.cxx +++ b/Modules/Filtering/BinaryMathematicalMorphology/test/itkBinaryOpeningByReconstructionImageFilterTest.cxx @@ -72,7 +72,7 @@ itkBinaryOpeningByReconstructionImageFilterTest(int argc, char * argv[]) reconstruction->SetBackgroundValue(backgroundValue); ITK_TEST_SET_GET_VALUE(backgroundValue, reconstruction->GetBackgroundValue()); - itk::SimpleFilterWatcher watcher(reconstruction, "filter"); + const itk::SimpleFilterWatcher watcher(reconstruction, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/BinaryMathematicalMorphology/test/itkErodeObjectMorphologyImageFilterTest.cxx b/Modules/Filtering/BinaryMathematicalMorphology/test/itkErodeObjectMorphologyImageFilterTest.cxx index da939d72145..c5523f6e7f3 100644 --- a/Modules/Filtering/BinaryMathematicalMorphology/test/itkErodeObjectMorphologyImageFilterTest.cxx +++ b/Modules/Filtering/BinaryMathematicalMorphology/test/itkErodeObjectMorphologyImageFilterTest.cxx @@ -58,7 +58,7 @@ itkErodeObjectMorphologyImageFilterTest(int, char *[]) start[0] = 0; start[1] = 0; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; // Initialize Image inputImage->SetRegions(region); @@ -123,8 +123,8 @@ itkErodeObjectMorphologyImageFilterTest(int, char *[]) using myFilterType = itk::ErodeObjectMorphologyImageFilter; // Create the filter - auto filter = myFilterType::New(); - itk::SimpleFilterWatcher watcher(filter, "filter"); + auto filter = myFilterType::New(); + const itk::SimpleFilterWatcher watcher(filter, "filter"); // Create the structuring element myKernelType ball; @@ -144,14 +144,14 @@ itkErodeObjectMorphologyImageFilterTest(int, char *[]) filter->SetErodeValue(fgValue); ITK_TEST_SET_GET_VALUE(fgValue, filter->GetErodeValue()); - unsigned short backgroundValue = 5; + const unsigned short backgroundValue = 5; filter->SetBackgroundValue(backgroundValue); ITK_TEST_SET_GET_VALUE(backgroundValue, filter->GetBackgroundValue()); std::cout << "BoundaryCondition: " << filter->GetBoundaryCondition() << std::endl; // Get the Smart Pointer to the Filter Output - myImageType::Pointer outputImage = filter->GetOutput(); + const myImageType::Pointer outputImage = filter->GetOutput(); // Execute the filter ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); diff --git a/Modules/Filtering/BinaryMathematicalMorphology/test/itkFastIncrementalBinaryDilateImageFilterTest.cxx b/Modules/Filtering/BinaryMathematicalMorphology/test/itkFastIncrementalBinaryDilateImageFilterTest.cxx index 43a5ffec8fd..e1fb0762708 100644 --- a/Modules/Filtering/BinaryMathematicalMorphology/test/itkFastIncrementalBinaryDilateImageFilterTest.cxx +++ b/Modules/Filtering/BinaryMathematicalMorphology/test/itkFastIncrementalBinaryDilateImageFilterTest.cxx @@ -56,7 +56,7 @@ itkFastIncrementalBinaryDilateImageFilterTest(int, char *[]) start[0] = 0; start[1] = 0; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; // Initialize Image inputImage->SetRegions(region); @@ -142,7 +142,7 @@ itkFastIncrementalBinaryDilateImageFilterTest(int, char *[]) ITK_TEST_SET_GET_VALUE(fgValue, filter->GetDilateValue()); // Get the Smart Pointer to the Filter Output - myImageType::Pointer outputImage = filter->GetOutput(); + const myImageType::Pointer outputImage = filter->GetOutput(); // Execute the filter ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); diff --git a/Modules/Filtering/Colormap/include/itkAutumnColormapFunction.hxx b/Modules/Filtering/Colormap/include/itkAutumnColormapFunction.hxx index c7ce6a8569a..ef408430dc9 100644 --- a/Modules/Filtering/Colormap/include/itkAutumnColormapFunction.hxx +++ b/Modules/Filtering/Colormap/include/itkAutumnColormapFunction.hxx @@ -28,14 +28,14 @@ auto AutumnColormapFunction::operator()(const TScalar & v) const -> RGBPixelType { // Map the input scalar between [0, 1]. - RealType value = this->RescaleInputValue(v); + const RealType value = this->RescaleInputValue(v); // Apply the color mapping. - RealType red = 1.0; + const RealType red = 1.0; - RealType green = value; + const RealType green = value; - RealType blue = 0.0; + const RealType blue = 0.0; // Set the rgb components after rescaling the values. RGBPixelType pixel; diff --git a/Modules/Filtering/Colormap/include/itkBlueColormapFunction.hxx b/Modules/Filtering/Colormap/include/itkBlueColormapFunction.hxx index 4f2a7b747eb..4b294003f65 100644 --- a/Modules/Filtering/Colormap/include/itkBlueColormapFunction.hxx +++ b/Modules/Filtering/Colormap/include/itkBlueColormapFunction.hxx @@ -28,7 +28,7 @@ auto BlueColormapFunction::operator()(const TScalar & v) const -> RGBPixelType { // Map the input scalar between [0, 1]. - RealType value = this->RescaleInputValue(v); + const RealType value = this->RescaleInputValue(v); // Set the rgb components after rescaling the values. RGBPixelType pixel; diff --git a/Modules/Filtering/Colormap/include/itkCoolColormapFunction.hxx b/Modules/Filtering/Colormap/include/itkCoolColormapFunction.hxx index d8d64ff20a7..7000bbbcde7 100644 --- a/Modules/Filtering/Colormap/include/itkCoolColormapFunction.hxx +++ b/Modules/Filtering/Colormap/include/itkCoolColormapFunction.hxx @@ -28,14 +28,14 @@ auto CoolColormapFunction::operator()(const TScalar & v) const -> RGBPixelType { // Map the input scalar between [0, 1]. - RealType value = this->RescaleInputValue(v); + const RealType value = this->RescaleInputValue(v); // Apply the color mapping. - RealType red = value; + const RealType red = value; - RealType green = 1.0 - value; + const RealType green = 1.0 - value; - RealType blue = 1.0; + const RealType blue = 1.0; // Set the rgb components after rescaling the values. RGBPixelType pixel; diff --git a/Modules/Filtering/Colormap/include/itkCopperColormapFunction.hxx b/Modules/Filtering/Colormap/include/itkCopperColormapFunction.hxx index eb9cb2132a6..5b05ba3b2e9 100644 --- a/Modules/Filtering/Colormap/include/itkCopperColormapFunction.hxx +++ b/Modules/Filtering/Colormap/include/itkCopperColormapFunction.hxx @@ -28,16 +28,16 @@ auto CopperColormapFunction::operator()(const TScalar & v) const -> RGBPixelType { // Map the input scalar between [0, 1]. - RealType value = this->RescaleInputValue(v); + const RealType value = this->RescaleInputValue(v); // Apply the color map. RealType red = 1.2 * value; red = std::min(1.0, red); - RealType green = 0.8 * value; + const RealType green = 0.8 * value; - RealType blue = 0.5 * value; + const RealType blue = 0.5 * value; // Set the rgb components after rescaling the values. RGBPixelType pixel; diff --git a/Modules/Filtering/Colormap/include/itkCustomColormapFunction.hxx b/Modules/Filtering/Colormap/include/itkCustomColormapFunction.hxx index 05ee95555b4..06fe497b8c0 100644 --- a/Modules/Filtering/Colormap/include/itkCustomColormapFunction.hxx +++ b/Modules/Filtering/Colormap/include/itkCustomColormapFunction.hxx @@ -28,7 +28,7 @@ auto CustomColormapFunction::operator()(const TScalar & v) const -> RGBPixelType { // Map the input scalar between [0, 1]. - RealType value = this->RescaleInputValue(v); + const RealType value = this->RescaleInputValue(v); // Setup some arrays and apply color mapping enum ColorNames @@ -42,8 +42,8 @@ CustomColormapFunction::operator()(const TScalar & v) const for (size_t color = RED; color <= BLUE; ++color) // Go through all the colors { - size_t size = ColorChannel[color]->size(); - auto index = Math::Ceil(value * static_cast(size - 1)); + const size_t size = ColorChannel[color]->size(); + auto index = Math::Ceil(value * static_cast(size - 1)); if (size == 1 || index < 1) { @@ -51,9 +51,9 @@ CustomColormapFunction::operator()(const TScalar & v) const } else if (size > 1) { - RealType p1 = (*ColorChannel[color])[index]; - RealType m1 = (*ColorChannel[color])[index - 1u]; - RealType d = p1 - m1; + const RealType p1 = (*ColorChannel[color])[index]; + const RealType m1 = (*ColorChannel[color])[index - 1u]; + const RealType d = p1 - m1; RGBValue[color] = d * (size - 1) * (value - (index - 1) / static_cast(size - 1)) + m1; } } diff --git a/Modules/Filtering/Colormap/include/itkGreenColormapFunction.hxx b/Modules/Filtering/Colormap/include/itkGreenColormapFunction.hxx index 702a7fbe9d8..2c2a8867dd9 100644 --- a/Modules/Filtering/Colormap/include/itkGreenColormapFunction.hxx +++ b/Modules/Filtering/Colormap/include/itkGreenColormapFunction.hxx @@ -28,7 +28,7 @@ auto GreenColormapFunction::operator()(const TScalar & v) const -> RGBPixelType { // Map the input scalar between [0, 1]. - RealType value = this->RescaleInputValue(v); + const RealType value = this->RescaleInputValue(v); // Set the rgb components after rescaling the values. RGBPixelType pixel; diff --git a/Modules/Filtering/Colormap/include/itkGreyColormapFunction.hxx b/Modules/Filtering/Colormap/include/itkGreyColormapFunction.hxx index 604a3eb92f7..bee0ace6553 100644 --- a/Modules/Filtering/Colormap/include/itkGreyColormapFunction.hxx +++ b/Modules/Filtering/Colormap/include/itkGreyColormapFunction.hxx @@ -28,7 +28,7 @@ auto GreyColormapFunction::operator()(const TScalar & v) const -> RGBPixelType { // Map the input scalar between [0, 1]. - RealType value = this->RescaleInputValue(v); + const RealType value = this->RescaleInputValue(v); // Set the rgb components after rescaling the values. RGBPixelType pixel; diff --git a/Modules/Filtering/Colormap/include/itkHSVColormapFunction.hxx b/Modules/Filtering/Colormap/include/itkHSVColormapFunction.hxx index cbf3d7e4b8a..f1bb4abbe98 100644 --- a/Modules/Filtering/Colormap/include/itkHSVColormapFunction.hxx +++ b/Modules/Filtering/Colormap/include/itkHSVColormapFunction.hxx @@ -28,7 +28,7 @@ auto HSVColormapFunction::operator()(const TScalar & v) const -> RGBPixelType { // Map the input scalar between [0, 1]. - RealType value = this->RescaleInputValue(v); + const RealType value = this->RescaleInputValue(v); // Apply the color mapping. // Apply the color mapping. diff --git a/Modules/Filtering/Colormap/include/itkHotColormapFunction.hxx b/Modules/Filtering/Colormap/include/itkHotColormapFunction.hxx index 530bfd5d565..14befa162b3 100644 --- a/Modules/Filtering/Colormap/include/itkHotColormapFunction.hxx +++ b/Modules/Filtering/Colormap/include/itkHotColormapFunction.hxx @@ -28,7 +28,7 @@ auto HotColormapFunction::operator()(const TScalar & v) const -> RGBPixelType { // Map the input scalar between [0, 1]. - RealType value = this->RescaleInputValue(v); + const RealType value = this->RescaleInputValue(v); // Apply the color mapping. RealType red = 63.0 / 26.0 * value - 1.0 / 13.0; diff --git a/Modules/Filtering/Colormap/include/itkJetColormapFunction.hxx b/Modules/Filtering/Colormap/include/itkJetColormapFunction.hxx index 882430985ee..13e0e969ebb 100644 --- a/Modules/Filtering/Colormap/include/itkJetColormapFunction.hxx +++ b/Modules/Filtering/Colormap/include/itkJetColormapFunction.hxx @@ -28,7 +28,7 @@ auto JetColormapFunction::operator()(const TScalar & v) const -> RGBPixelType { // Map the input scalar between [0, 1]. - RealType value = this->RescaleInputValue(v); + const RealType value = this->RescaleInputValue(v); // Apply the color mapping. RealType red = -itk::Math::abs(3.95 * (value - 0.7460)) + 1.5; diff --git a/Modules/Filtering/Colormap/include/itkOverUnderColormapFunction.hxx b/Modules/Filtering/Colormap/include/itkOverUnderColormapFunction.hxx index 60e6f8c568a..4e7c9f8f173 100644 --- a/Modules/Filtering/Colormap/include/itkOverUnderColormapFunction.hxx +++ b/Modules/Filtering/Colormap/include/itkOverUnderColormapFunction.hxx @@ -28,7 +28,7 @@ auto OverUnderColormapFunction::operator()(const TScalar & v) const -> RGBPixelType { // Map the input scalar between [0, 1]. - RealType value = this->RescaleInputValue(v); + const RealType value = this->RescaleInputValue(v); // Apply the color mapping. RealType red = value; diff --git a/Modules/Filtering/Colormap/include/itkRedColormapFunction.hxx b/Modules/Filtering/Colormap/include/itkRedColormapFunction.hxx index 456329f2ab6..307ce648331 100644 --- a/Modules/Filtering/Colormap/include/itkRedColormapFunction.hxx +++ b/Modules/Filtering/Colormap/include/itkRedColormapFunction.hxx @@ -28,7 +28,7 @@ auto RedColormapFunction::operator()(const TScalar & v) const -> RGBPixelType { // Map the input scalar between [0, 1]. - RealType value = this->RescaleInputValue(v); + const RealType value = this->RescaleInputValue(v); // Set the rgb components after rescaling the values. RGBPixelType pixel; diff --git a/Modules/Filtering/Colormap/include/itkScalarToRGBColormapImageFilter.hxx b/Modules/Filtering/Colormap/include/itkScalarToRGBColormapImageFilter.hxx index 041f48d1b51..97049bc5ed0 100644 --- a/Modules/Filtering/Colormap/include/itkScalarToRGBColormapImageFilter.hxx +++ b/Modules/Filtering/Colormap/include/itkScalarToRGBColormapImageFilter.hxx @@ -77,7 +77,7 @@ ScalarToRGBColormapImageFilter::BeforeThreadedGenerat for (It.GoToBegin(); !It.IsAtEnd(); ++It) { - InputImagePixelType value = It.Get(); + const InputImagePixelType value = It.Get(); if (value < minimumValue) { minimumValue = value; @@ -98,8 +98,8 @@ void ScalarToRGBColormapImageFilter::DynamicThreadedGenerateData( const OutputImageRegionType & outputRegionForThread) { - InputImagePointer inputPtr = this->GetInput(); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImagePointer inputPtr = this->GetInput(); + const OutputImagePointer outputPtr = this->GetOutput(); TotalProgressReporter progressReporter(this, this->GetOutput()->GetRequestedRegion().GetNumberOfPixels()); diff --git a/Modules/Filtering/Colormap/include/itkSpringColormapFunction.hxx b/Modules/Filtering/Colormap/include/itkSpringColormapFunction.hxx index f7a5163c3ad..47479546d5b 100644 --- a/Modules/Filtering/Colormap/include/itkSpringColormapFunction.hxx +++ b/Modules/Filtering/Colormap/include/itkSpringColormapFunction.hxx @@ -28,14 +28,14 @@ auto SpringColormapFunction::operator()(const TScalar & v) const -> RGBPixelType { // Map the input scalar between [0, 1]. - RealType value = this->RescaleInputValue(v); + const RealType value = this->RescaleInputValue(v); // Apply the color mapping. - RealType red = 1.0; + const RealType red = 1.0; - RealType green = value; + const RealType green = value; - RealType blue = 1.0 - value; + const RealType blue = 1.0 - value; // Set the rgb components after rescaling the values. RGBPixelType pixel; diff --git a/Modules/Filtering/Colormap/include/itkSummerColormapFunction.hxx b/Modules/Filtering/Colormap/include/itkSummerColormapFunction.hxx index 948a28868f1..996b5664ab4 100644 --- a/Modules/Filtering/Colormap/include/itkSummerColormapFunction.hxx +++ b/Modules/Filtering/Colormap/include/itkSummerColormapFunction.hxx @@ -28,14 +28,14 @@ auto SummerColormapFunction::operator()(const TScalar & v) const -> RGBPixelType { // Map the input scalar between [0, 1]. - RealType value = this->RescaleInputValue(v); + const RealType value = this->RescaleInputValue(v); // Apply the color mapping. - RealType red = value; + const RealType red = value; - RealType green = 0.5 * value + 0.5; + const RealType green = 0.5 * value + 0.5; - RealType blue = 0.4; + const RealType blue = 0.4; // Set the rgb components after rescaling the values. RGBPixelType pixel; diff --git a/Modules/Filtering/Colormap/include/itkWinterColormapFunction.hxx b/Modules/Filtering/Colormap/include/itkWinterColormapFunction.hxx index 64a60fd9671..bb7a48dec72 100644 --- a/Modules/Filtering/Colormap/include/itkWinterColormapFunction.hxx +++ b/Modules/Filtering/Colormap/include/itkWinterColormapFunction.hxx @@ -28,14 +28,14 @@ auto WinterColormapFunction::operator()(const TScalar & v) const -> RGBPixelType { // Map the input scalar between [0, 1]. - RealType value = this->RescaleInputValue(v); + const RealType value = this->RescaleInputValue(v); // Apply the color map. - RealType red = 0.0; + const RealType red = 0.0; - RealType green = value; + const RealType green = value; - RealType blue = 1.0 - 0.5 * value; + const RealType blue = 1.0 - 0.5 * value; // Set the rgb components after rescaling the values. RGBPixelType pixel; diff --git a/Modules/Filtering/Colormap/test/itkCustomColormapFunctionTest.cxx b/Modules/Filtering/Colormap/test/itkCustomColormapFunctionTest.cxx index d2601ea7be3..7a84a2335b8 100644 --- a/Modules/Filtering/Colormap/test/itkCustomColormapFunctionTest.cxx +++ b/Modules/Filtering/Colormap/test/itkCustomColormapFunctionTest.cxx @@ -149,7 +149,7 @@ itkCustomColormapFunctionTest(int argc, char * argv[]) } // The scalar valur to be mapped into an RGB colormap value - int scalarValue = std::stoi(argv[2]); + const int scalarValue = std::stoi(argv[2]); // Test for all possible scalar pixel types itk::Function::CustomColormapFunctionHelper::Exercise( diff --git a/Modules/Filtering/Colormap/test/itkScalarToRGBColormapImageFilterTest.cxx b/Modules/Filtering/Colormap/test/itkScalarToRGBColormapImageFilterTest.cxx index 2b4583de006..22373e614f8 100644 --- a/Modules/Filtering/Colormap/test/itkScalarToRGBColormapImageFilterTest.cxx +++ b/Modules/Filtering/Colormap/test/itkScalarToRGBColormapImageFilterTest.cxx @@ -53,7 +53,7 @@ itkScalarToRGBColormapImageFilterTest(int argc, char * argv[]) reader->SetFileName(argv[1]); reader->Update(); - std::string colormapString(argv[3]); + const std::string colormapString(argv[3]); using VectorImageType = itk::VectorImage; using VectorFilterType = itk::ScalarToRGBColormapImageFilter; diff --git a/Modules/Filtering/Convolution/include/itkConvolutionImageFilter.hxx b/Modules/Filtering/Convolution/include/itkConvolutionImageFilter.hxx index fdbcefa7935..9abddcb136d 100644 --- a/Modules/Filtering/Convolution/include/itkConvolutionImageFilter.hxx +++ b/Modules/Filtering/Convolution/include/itkConvolutionImageFilter.hxx @@ -77,7 +77,7 @@ ConvolutionImageFilter::ComputeConvolut using KernelOperatorType = ImageKernelOperator; KernelOperatorType kernelOperator; - bool kernelNeedsPadding = this->GetKernelNeedsPadding(); + const bool kernelNeedsPadding = this->GetKernelNeedsPadding(); float optionalFilterWeights = 0.0f; if (this->GetNormalize()) @@ -121,7 +121,7 @@ ConvolutionImageFilter::ComputeConvolut kernelOperator.SetImageKernel(flipper->GetOutput()); } - KernelSizeType radius = this->GetKernelRadius(kernelImage); + const KernelSizeType radius = this->GetKernelRadius(kernelImage); kernelOperator.CreateToRadius(radius); auto localInput = InputImageType::New(); @@ -155,8 +155,8 @@ ConvolutionImageFilter::ComputeConvolut using CropSizeType = typename CropFilterType::SizeType; // Set up the crop sizes. - CropSizeType upperCropSize(radius); - CropSizeType lowerCropSize(radius); + const CropSizeType upperCropSize(radius); + CropSizeType lowerCropSize(radius); convolutionFilter->GraftOutput(this->GetOutput()); @@ -165,7 +165,7 @@ ConvolutionImageFilter::ComputeConvolut lowerCropSize -= this->GetKernelPadSize(); // Set up the crop filter. - CropFilterPointer cropFilter = CropFilterType::New(); + const CropFilterPointer cropFilter = CropFilterType::New(); cropFilter->SetLowerBoundaryCropSize(lowerCropSize); cropFilter->SetUpperBoundaryCropSize(upperCropSize); cropFilter->SetNumberOfWorkUnits(this->GetNumberOfWorkUnits()); @@ -191,7 +191,7 @@ bool ConvolutionImageFilter::GetKernelNeedsPadding() const { const KernelImageType * kernel = this->GetKernelImage(); - InputRegionType kernelRegion = kernel->GetLargestPossibleRegion(); + const InputRegionType kernelRegion = kernel->GetLargestPossibleRegion(); InputSizeType kernelSize = kernelRegion.GetSize(); for (unsigned int i = 0; i < ImageDimension; ++i) @@ -210,7 +210,7 @@ auto ConvolutionImageFilter::GetKernelPadSize() const -> KernelSizeType { const KernelImageType * kernel = this->GetKernelImage(); - KernelRegionType kernelRegion = kernel->GetLargestPossibleRegion(); + const KernelRegionType kernelRegion = kernel->GetLargestPossibleRegion(); KernelSizeType kernelSize = kernelRegion.GetSize(); KernelSizeType padSize; @@ -249,13 +249,13 @@ ConvolutionImageFilter::GenerateInputRe InputRegionType inputRegion = this->GetOutput()->GetRequestedRegion(); // Pad the output request region by the kernel radius. - KernelSizeType radius = this->GetKernelRadius(this->GetKernelImage()); + const KernelSizeType radius = this->GetKernelRadius(this->GetKernelImage()); inputRegion.PadByRadius(radius); // Crop the output request region to fit within the largest // possible region. - typename InputImageType::Pointer inputPtr = const_cast(this->GetInput()); - bool cropped = inputRegion.Crop(inputPtr->GetLargestPossibleRegion()); + const typename InputImageType::Pointer inputPtr = const_cast(this->GetInput()); + const bool cropped = inputRegion.Crop(inputPtr->GetLargestPossibleRegion()); if (!cropped) { InvalidRequestedRegionError e(__FILE__, __LINE__); @@ -275,7 +275,7 @@ ConvolutionImageFilter::GenerateInputRe { // Input kernel is an image, cast away the constness so we can set // the requested region. - typename KernelImageType::Pointer kernelPtr = const_cast(this->GetKernelImage()); + const typename KernelImageType::Pointer kernelPtr = const_cast(this->GetKernelImage()); kernelPtr->SetRequestedRegionToLargestPossibleRegion(); } } diff --git a/Modules/Filtering/Convolution/include/itkConvolutionImageFilterBase.hxx b/Modules/Filtering/Convolution/include/itkConvolutionImageFilterBase.hxx index 6f03d1618b2..41a678ec6e2 100644 --- a/Modules/Filtering/Convolution/include/itkConvolutionImageFilterBase.hxx +++ b/Modules/Filtering/Convolution/include/itkConvolutionImageFilterBase.hxx @@ -39,9 +39,9 @@ ConvolutionImageFilterBase::GenerateOut if (m_OutputRegionMode == ConvolutionImageFilterBaseEnums::ConvolutionImageFilterOutputRegion::VALID) { - OutputRegionType validRegion = this->GetValidRegion(); + const OutputRegionType validRegion = this->GetValidRegion(); - typename OutputImageType::Pointer outputPtr = this->GetOutput(); + const typename OutputImageType::Pointer outputPtr = this->GetOutput(); outputPtr->SetLargestPossibleRegion(validRegion); } } @@ -50,9 +50,9 @@ template auto ConvolutionImageFilterBase::GetValidRegion() const -> OutputRegionType { - typename InputImageType::ConstPointer inputPtr = this->GetInput(); + const typename InputImageType::ConstPointer inputPtr = this->GetInput(); - InputRegionType inputLargestPossibleRegion = inputPtr->GetLargestPossibleRegion(); + const InputRegionType inputLargestPossibleRegion = inputPtr->GetLargestPossibleRegion(); OutputIndexType validIndex = inputLargestPossibleRegion.GetIndex(); OutputSizeType validSize = inputLargestPossibleRegion.GetSize(); @@ -85,7 +85,7 @@ ConvolutionImageFilterBase::GetValidReg } } - OutputRegionType validRegion(validIndex, validSize); + const OutputRegionType validRegion(validIndex, validSize); return validRegion; } diff --git a/Modules/Filtering/Convolution/include/itkFFTConvolutionImageFilter.hxx b/Modules/Filtering/Convolution/include/itkFFTConvolutionImageFilter.hxx index f49531860ed..f993fa19943 100644 --- a/Modules/Filtering/Convolution/include/itkFFTConvolutionImageFilter.hxx +++ b/Modules/Filtering/Convolution/include/itkFFTConvolutionImageFilter.hxx @@ -58,7 +58,7 @@ FFTConvolutionImageFilter(this->GetPrimaryInput()); - bool wasPartiallyInside = inputRegion.Crop(inputPtr->GetLargestPossibleRegion()); + const bool wasPartiallyInside = inputRegion.Crop(inputPtr->GetLargestPossibleRegion()); if (!wasPartiallyInside) { itkExceptionMacro("Requested region is outside the largest possible region."); @@ -73,7 +73,7 @@ FFTConvolutionImageFilter(this->GetKernelImage()); + const typename KernelImageType::Pointer kernelPtr = const_cast(this->GetKernelImage()); kernelPtr->SetRequestedRegionToLargestPossibleRegion(); } } @@ -149,15 +149,15 @@ FFTConvolutionImageFilterGetLargestPossibleRegion(); - InputSizeType inputLargestSize = inputLargestRegion.GetSize(); - InputIndexType inputLargestIndex = inputLargestRegion.GetIndex(); - InputRegionType inputRequestedRegion = input->GetRequestedRegion(); - InputSizeType inputRequestedSize = inputRequestedRegion.GetSize(); - InputIndexType inputRequestedIndex = inputRequestedRegion.GetIndex(); - OutputRegionType outputRequestedRegion = this->GetOutput()->GetRequestedRegion(); - OutputSizeType outputRequestedSize = outputRequestedRegion.GetSize(); - OutputIndexType outputRequestedIndex = outputRequestedRegion.GetIndex(); + const InputRegionType inputLargestRegion = input->GetLargestPossibleRegion(); + InputSizeType inputLargestSize = inputLargestRegion.GetSize(); + InputIndexType inputLargestIndex = inputLargestRegion.GetIndex(); + const InputRegionType inputRequestedRegion = input->GetRequestedRegion(); + InputSizeType inputRequestedSize = inputRequestedRegion.GetSize(); + InputIndexType inputRequestedIndex = inputRequestedRegion.GetIndex(); + const OutputRegionType outputRequestedRegion = this->GetOutput()->GetRequestedRegion(); + OutputSizeType outputRequestedSize = outputRequestedRegion.GetSize(); + OutputIndexType outputRequestedIndex = outputRequestedRegion.GetIndex(); // Pad the input image such that the requested region, expanded by // twice the kernel radius, lies entirely within the buffered region. @@ -174,16 +174,16 @@ FFTConvolutionImageFilter(kernelRadius[dim]) - (requestedLowerCorner - largestLowerCorner); + const int lower = static_cast(kernelRadius[dim]) - (requestedLowerCorner - largestLowerCorner); // Pad for difference between upper corner of largest vs requested region - int upper = static_cast(kernelRadius[dim]) - (largestUpperCorner - requestedUpperCorner); + const int upper = static_cast(kernelRadius[dim]) - (largestUpperCorner - requestedUpperCorner); lowerPad[dim] = (lower > 0 ? lower : 0); upperPad[dim] = (upper > 0 ? upper : 0); @@ -223,7 +223,7 @@ FFTConvolutionImageFilterGetLargestPossibleRegion(); - KernelSizeType kernelSize = kernelRegion.GetSize(); + const KernelRegionType kernelRegion = kernel->GetLargestPossibleRegion(); + KernelSizeType kernelSize = kernelRegion.GetSize(); InputSizeType inputPadSize = m_PaddedInputRegion.GetSize(); typename KernelImageType::SizeType kernelUpperBound; @@ -347,7 +347,7 @@ FFTConvolutionImageFilterGetNormalize()) { using NormalizeFilterType = NormalizeToConstantImageFilter; @@ -361,7 +361,7 @@ FFTConvolutionImageFilter; using KernelPadPointer = typename KernelPadType::Pointer; - KernelPadPointer kernelPadder = KernelPadType::New(); + const KernelPadPointer kernelPadder = KernelPadType::New(); kernelPadder->SetConstant(TInternalPrecision{}); kernelPadder->SetPadUpperBound(kernelUpperBound); kernelPadder->SetNumberOfWorkUnits(this->GetNumberOfWorkUnits()); @@ -376,7 +376,7 @@ FFTConvolutionImageFilter; using KernelPadPointer = typename KernelPadType::Pointer; - KernelPadPointer kernelPadder = KernelPadType::New(); + const KernelPadPointer kernelPadder = KernelPadType::New(); kernelPadder->SetConstant(TInternalPrecision{}); kernelPadder->SetPadUpperBound(kernelUpperBound); kernelPadder->SetNumberOfWorkUnits(this->GetNumberOfWorkUnits()); @@ -474,8 +474,8 @@ FFTConvolutionImageFilterGetOutput()->GetRequestedRegion().GetSize(); - InternalRegionType extractionRegion(extractionIndex, requestedRegionSize); + auto requestedRegionSize = this->GetOutput()->GetRequestedRegion().GetSize(); + const InternalRegionType extractionRegion(extractionIndex, requestedRegionSize); extractFilter->SetExtractionRegion(extractionRegion); // Graft the minipipeline output to this filter. diff --git a/Modules/Filtering/Convolution/include/itkMaskedFFTNormalizedCorrelationImageFilter.hxx b/Modules/Filtering/Convolution/include/itkMaskedFFTNormalizedCorrelationImageFilter.hxx index aa447a6c8e1..8811dfede9e 100644 --- a/Modules/Filtering/Convolution/include/itkMaskedFFTNormalizedCorrelationImageFilter.hxx +++ b/Modules/Filtering/Convolution/include/itkMaskedFFTNormalizedCorrelationImageFilter.hxx @@ -132,7 +132,7 @@ MaskedFFTNormalizedCorrelationImageFilter } this->UpdateProgress(m_AccumulatedProgress); - OutputImagePointer outputImage = this->GetOutput(); + const OutputImagePointer outputImage = this->GetOutput(); fixedMask = this->PreProcessMask(fixedImage, fixedMask); movingMask = this->PreProcessMask(movingImage, movingMask); @@ -233,14 +233,14 @@ MaskedFFTNormalizedCorrelationImageFilter auto sqrtFilter = SqrtType::New(); sqrtFilter->SetInput(this->ElementProduct(fixedDenom, rotatedMovingDenom)); sqrtFilter->Update(); - RealImagePointer denominator = sqrtFilter->GetOutput(); + const RealImagePointer denominator = sqrtFilter->GetOutput(); fixedDenom = nullptr; // No longer needed rotatedMovingDenom = nullptr; // No longer needed // Determine a tolerance on the precision of the denominator values. const double precisionTolerance = CalculatePrecisionTolerance(denominator); - RealImagePointer NCC = this->ElementQuotient(numerator, denominator); + const RealImagePointer NCC = this->ElementQuotient(numerator, denominator); numerator = nullptr; // No longer needed // Given the numberOfOverlapPixels, we can check that the m_RequiredNumberOfOverlappingPixels is not set higher than @@ -259,7 +259,7 @@ MaskedFFTNormalizedCorrelationImageFilter // pixels (or both). Here, we calculate the number of required pixels resulting from both of these methods and choose // the one that gives the largest number of pixels. These both default to 0 so that if a user only sets one, the other // is ignored. - SizeValueType requiredNumberOfOverlappingPixels = + const SizeValueType requiredNumberOfOverlappingPixels = std::max((SizeValueType)(m_RequiredFractionOfOverlappingPixels * m_MaximumNumberOfOverlappingPixels), m_RequiredNumberOfOverlappingPixels); @@ -283,7 +283,7 @@ MaskedFFTNormalizedCorrelationImageFilter postProcessor->Update(); // Store the output origin computed in GenerateOutputInformation so that it can be reset after the Graft. - RealPointType outputOrigin = this->GetOutput()->GetOrigin(); + const RealPointType outputOrigin = this->GetOutput()->GetOrigin(); outputImage->Graft(postProcessor->GetOutput()); outputImage->SetOrigin(outputOrigin); } @@ -295,7 +295,7 @@ MaskedFFTNormalizedCorrelationImageFilter LocalInputImageType * inputImage) { // Store the original origin of the image. - typename LocalInputImageType::PointType inputOrigin = inputImage->GetOrigin(); + const typename LocalInputImageType::PointType inputOrigin = inputImage->GetOrigin(); // Flip the moving images along all dimensions so that the correlation can be more easily handled. using FlipperType = itk::FlipImageFilter; @@ -376,8 +376,9 @@ MaskedFFTNormalizedCorrelationImageFilter LocalInputImageType * inputImage, InputSizeType & FFTImageSize) { - typename LocalInputImageType::PixelType constantPixel = 0; - typename LocalInputImageType::SizeType upperPad = FFTImageSize - inputImage->GetLargestPossibleRegion().GetSize(); + const typename LocalInputImageType::PixelType constantPixel = 0; + const typename LocalInputImageType::SizeType upperPad = + FFTImageSize - inputImage->GetLargestPossibleRegion().GetSize(); using PadType = itk::ConstantPadImageFilter; auto padder = PadType::New(); @@ -674,9 +675,9 @@ MaskedFFTNormalizedCorrelationImageFilter Superclass::GenerateOutputInformation(); // get pointers to the input and output - InputImageConstPointer fixedImage = this->GetFixedImage(); - InputImageConstPointer movingImage = this->GetMovingImage(); - OutputImagePointer output = this->GetOutput(); + const InputImageConstPointer fixedImage = this->GetFixedImage(); + const InputImageConstPointer movingImage = this->GetMovingImage(); + const OutputImagePointer output = this->GetOutput(); // Compute the size of the output image. typename OutputImageType::SizeType size; @@ -715,8 +716,8 @@ MaskedFFTNormalizedCorrelationImageFilter Superclass::EnlargeOutputRequestedRegion(output); // get pointers to the input and output - InputImageConstPointer fixedImage = this->GetFixedImage(); - InputImageConstPointer movingImage = this->GetMovingImage(); + const InputImageConstPointer fixedImage = this->GetFixedImage(); + const InputImageConstPointer movingImage = this->GetMovingImage(); // Compute the size of the output image. typename OutputImageType::SizeType size; diff --git a/Modules/Filtering/Convolution/include/itkNormalizedCorrelationImageFilter.hxx b/Modules/Filtering/Convolution/include/itkNormalizedCorrelationImageFilter.hxx index cdd93a30b08..f7c2a5defdc 100644 --- a/Modules/Filtering/Convolution/include/itkNormalizedCorrelationImageFilter.hxx +++ b/Modules/Filtering/Convolution/include/itkNormalizedCorrelationImageFilter.hxx @@ -52,8 +52,8 @@ NormalizedCorrelationImageFilter(this->GetInput()); - MaskImagePointer maskPtr = const_cast(this->GetMaskImage()); + const InputImagePointer inputPtr = const_cast(this->GetInput()); + const MaskImagePointer maskPtr = const_cast(this->GetMaskImage()); if (!inputPtr || !maskPtr) { @@ -62,7 +62,7 @@ NormalizedCorrelationImageFilterGetRequestedRegion(); + const typename TInputImage::RegionType inputRequestedRegion = inputPtr->GetRequestedRegion(); // set the mask requested region to match the input requested region if (maskPtr->GetLargestPossibleRegion().IsInside(inputRequestedRegion)) @@ -109,16 +109,16 @@ NormalizedCorrelationImageFilter(this->GetOperator().Size()); - OutputPixelRealType mean = sum / num; - OutputPixelRealType var = (sumOfSquares - (sum * sum / num)) / (num - 1.0); - OutputPixelRealType std = std::sqrt(var); + auto num = static_cast(this->GetOperator().Size()); + const OutputPixelRealType mean = sum / num; + const OutputPixelRealType var = (sumOfSquares - (sum * sum / num)) / (num - 1.0); + const OutputPixelRealType std = std::sqrt(var); // convert std to a scaling factor k such that // // || (coeff - mean) / k || = 1.0 // - double k = std * std::sqrt(num - 1.0); + const double k = std * std::sqrt(num - 1.0); // normalize the template for (ntIt = normalizedTemplate.Begin(), tIt = this->GetOperator().Begin(); ntIt < normalizedTemplate.End(); @@ -140,8 +140,8 @@ NormalizedCorrelationImageFilter; using FaceListType = typename BFC::FaceListType; - BFC faceCalculator; - FaceListType faceList = faceCalculator(input, outputRegionForThread, this->GetOperator().GetRadius()); + BFC faceCalculator; + const FaceListType faceList = faceCalculator(input, outputRegionForThread, this->GetOperator().GetRadius()); TotalProgressReporter progress(this, output->GetRequestedRegion().GetNumberOfPixels()); @@ -151,12 +151,12 @@ NormalizedCorrelationImageFilter it; ImageRegionConstIterator mit; unsigned int i; - unsigned int templateSize = normalizedTemplate.Size(); + const unsigned int templateSize = normalizedTemplate.Size(); OutputPixelRealType realTemplateSize; OutputPixelRealType value; OutputPixelRealType numerator; OutputPixelRealType denominator; - OutputPixelRealType zero = OutputPixelType{}; + const OutputPixelRealType zero = OutputPixelType{}; realTemplateSize = static_cast(templateSize); for (const auto & face : faceList) diff --git a/Modules/Filtering/Convolution/test/itkConvolutionImageFilterDeltaFunctionTest.cxx b/Modules/Filtering/Convolution/test/itkConvolutionImageFilterDeltaFunctionTest.cxx index f69a88e6621..70e55a7f4a1 100644 --- a/Modules/Filtering/Convolution/test/itkConvolutionImageFilterDeltaFunctionTest.cxx +++ b/Modules/Filtering/Convolution/test/itkConvolutionImageFilterDeltaFunctionTest.cxx @@ -42,8 +42,8 @@ itkConvolutionImageFilterDeltaFunctionTest(int argc, char * argv[]) reader->Update(); // Set up delta function image. - ImageType::RegionType region = reader->GetOutput()->GetLargestPossibleRegion(); - auto deltaFunctionImage = ImageType::New(); + const ImageType::RegionType region = reader->GetOutput()->GetLargestPossibleRegion(); + auto deltaFunctionImage = ImageType::New(); deltaFunctionImage->SetRegions(region); deltaFunctionImage->AllocateInitialized(); @@ -51,7 +51,7 @@ itkConvolutionImageFilterDeltaFunctionTest(int argc, char * argv[]) ImageType::IndexType middleIndex; for (unsigned int i = 0; i < ImageDimension; ++i) { - ImageType::SizeValueType sizeInDimension = region.GetSize()[i]; + const ImageType::SizeValueType sizeInDimension = region.GetSize()[i]; middleIndex[i] = itk::Math::Floor(0.5 * sizeInDimension); } deltaFunctionImage->SetPixel(middleIndex, 1); diff --git a/Modules/Filtering/Convolution/test/itkConvolutionImageFilterStreamingTest.cxx b/Modules/Filtering/Convolution/test/itkConvolutionImageFilterStreamingTest.cxx index c8bb6b33d9f..ce280b800ad 100644 --- a/Modules/Filtering/Convolution/test/itkConvolutionImageFilterStreamingTest.cxx +++ b/Modules/Filtering/Convolution/test/itkConvolutionImageFilterStreamingTest.cxx @@ -33,8 +33,8 @@ GenerateKernelForStreamingTest() { using SourceType = itk::GaussianImageSource; using KernelSizeType = typename SourceType::SizeType; - auto source = SourceType::New(); - KernelSizeType kernelSize{ { 3, 5 } }; + auto source = SourceType::New(); + const KernelSizeType kernelSize{ { 3, 5 } }; source->SetSize(kernelSize); source->SetMean(2); source->SetSigma(3.0); @@ -63,7 +63,7 @@ doConvolutionImageFilterStreamingTest(int argc, char * argv[]) SizeType requestedSize; requestedSize[0] = std::atoi(argv[6]); requestedSize[1] = std::atoi(argv[7]); - RegionType requestedRegion(requestedIndex, requestedSize); + const RegionType requestedRegion(requestedIndex, requestedSize); auto regionMode = (argc > 9 && std::string("valid").compare(argv[8]) == 0 ? itk::ConvolutionImageFilterBaseEnums::ConvolutionImageFilterOutputRegion::VALID @@ -82,14 +82,14 @@ doConvolutionImageFilterStreamingTest(int argc, char * argv[]) auto inputMonitor = PipelineMonitorType::New(); inputMonitor->SetInput(reader1->GetOutput()); - KernelImageType::Pointer kernelImage = GenerateKernelForStreamingTest(); + const KernelImageType::Pointer kernelImage = GenerateKernelForStreamingTest(); auto convoluter = ConvolutionFilterType::New(); convoluter->SetInput(inputMonitor->GetOutput()); convoluter->SetKernelImage(kernelImage); convoluter->SetOutputRegionMode(regionMode); convoluter->SetReleaseDataFlag(true); - itk::SimpleFilterWatcher watcher(convoluter, "filter"); + const itk::SimpleFilterWatcher watcher(convoluter, "filter"); using PipelineMonitorType = itk::PipelineMonitorImageFilter; auto outputMonitor = PipelineMonitorType::New(); diff --git a/Modules/Filtering/Convolution/test/itkConvolutionImageFilterSubregionTest.cxx b/Modules/Filtering/Convolution/test/itkConvolutionImageFilterSubregionTest.cxx index 97a409d9456..58937583609 100644 --- a/Modules/Filtering/Convolution/test/itkConvolutionImageFilterSubregionTest.cxx +++ b/Modules/Filtering/Convolution/test/itkConvolutionImageFilterSubregionTest.cxx @@ -31,8 +31,8 @@ GenerateGaussianKernelForSubregionTest() { using SourceType = itk::GaussianImageSource; using KernelSizeType = typename SourceType::SizeType; - auto source = SourceType::New(); - KernelSizeType kernelSize{ { 3, 5 } }; + auto source = SourceType::New(); + const KernelSizeType kernelSize{ { 3, 5 } }; source->SetSize(kernelSize); source->SetMean(2); source->SetSigma(3.0); @@ -62,12 +62,12 @@ doConvolutionImageFilterSubregionTest(int argc, char * argv[]) SizeType requestedSize; requestedSize[0] = std::atoi(argv[6]); requestedSize[1] = std::atoi(argv[7]); - RegionType requestedRegion(requestedIndex, requestedSize); + const RegionType requestedRegion(requestedIndex, requestedSize); - bool normalize = (argc > 8 ? atoi(argv[8]) == 1 : false); - auto regionMode = (argc > 9 && std::string("valid").compare(argv[9]) == 0 - ? itk::ConvolutionImageFilterBaseEnums::ConvolutionImageFilterOutputRegion::VALID - : itk::ConvolutionImageFilterBaseEnums::ConvolutionImageFilterOutputRegion::SAME); + const bool normalize = (argc > 8 ? atoi(argv[8]) == 1 : false); + auto regionMode = (argc > 9 && std::string("valid").compare(argv[9]) == 0 + ? itk::ConvolutionImageFilterBaseEnums::ConvolutionImageFilterOutputRegion::VALID + : itk::ConvolutionImageFilterBaseEnums::ConvolutionImageFilterOutputRegion::SAME); using ReaderType = itk::ImageFileReader; @@ -100,7 +100,7 @@ doConvolutionImageFilterSubregionTest(int argc, char * argv[]) convoluter->SetNormalize(normalize); convoluter->SetOutputRegionMode(regionMode); convoluter->SetReleaseDataFlag(true); - itk::SimpleFilterWatcher watcher(convoluter, "filter"); + const itk::SimpleFilterWatcher watcher(convoluter, "filter"); ITK_TRY_EXPECT_NO_EXCEPTION(convoluter->Update()); ITK_TEST_EXPECT_EQUAL(convoluter->GetOutput()->GetBufferedRegion(), requestedRegion); diff --git a/Modules/Filtering/Convolution/test/itkConvolutionImageFilterTest.cxx b/Modules/Filtering/Convolution/test/itkConvolutionImageFilterTest.cxx index b7dc0688c98..a9c994a2284 100644 --- a/Modules/Filtering/Convolution/test/itkConvolutionImageFilterTest.cxx +++ b/Modules/Filtering/Convolution/test/itkConvolutionImageFilterTest.cxx @@ -53,7 +53,7 @@ itkConvolutionImageFilterTest(int argc, char * argv[]) convoluter->SetInput(reader1->GetOutput()); convoluter->SetKernelImage(reader2->GetOutput()); - itk::SimpleFilterWatcher watcher(convoluter, "filter"); + const itk::SimpleFilterWatcher watcher(convoluter, "filter"); if (argc >= 5) { @@ -188,9 +188,9 @@ itkConvolutionImageFilterTest(int argc, char * argv[]) } // Test for invalid request region. - auto invalidIndex = ImageType::IndexType::Filled(1000); - auto invalidSize = ImageType::SizeType::Filled(1000); - ImageType::RegionType invalidRequestRegion(invalidIndex, invalidSize); + auto invalidIndex = ImageType::IndexType::Filled(1000); + auto invalidSize = ImageType::SizeType::Filled(1000); + const ImageType::RegionType invalidRequestRegion(invalidIndex, invalidSize); convoluter->GetOutput()->SetRequestedRegion(invalidRequestRegion); try { diff --git a/Modules/Filtering/Convolution/test/itkConvolutionImageFilterTestInt.cxx b/Modules/Filtering/Convolution/test/itkConvolutionImageFilterTestInt.cxx index f684160fb30..c04fa7db791 100644 --- a/Modules/Filtering/Convolution/test/itkConvolutionImageFilterTestInt.cxx +++ b/Modules/Filtering/Convolution/test/itkConvolutionImageFilterTestInt.cxx @@ -53,7 +53,7 @@ itkConvolutionImageFilterTestInt(int argc, char * argv[]) convolver->SetInput(reader1->GetOutput()); convolver->SetKernelImage(reader2->GetOutput()); - itk::SimpleFilterWatcher watcher(convolver, "filter"); + const itk::SimpleFilterWatcher watcher(convolver, "filter"); if (argc >= 5) { @@ -62,7 +62,7 @@ itkConvolutionImageFilterTestInt(int argc, char * argv[]) if (argc >= 6) { - std::string outputRegionMode(argv[5]); + const std::string outputRegionMode(argv[5]); if (outputRegionMode == "SAME") { convolver->SetOutputRegionModeToSame(); @@ -86,8 +86,8 @@ itkConvolutionImageFilterTestInt(int argc, char * argv[]) auto monitor = MonitorFilter::New(); monitor->SetInput(convolver->GetOutput()); - constexpr unsigned int numberOfStreamDivisions = 4; - itk::StreamingImageFilter::Pointer streamingFilter = + constexpr unsigned int numberOfStreamDivisions = 4; + const itk::StreamingImageFilter::Pointer streamingFilter = itk::StreamingImageFilter::New(); streamingFilter->SetNumberOfStreamDivisions(numberOfStreamDivisions); streamingFilter->SetInput(monitor->GetOutput()); diff --git a/Modules/Filtering/Convolution/test/itkFFTConvolutionImageFilterDeltaFunctionTest.cxx b/Modules/Filtering/Convolution/test/itkFFTConvolutionImageFilterDeltaFunctionTest.cxx index f1dbcaccdba..0bbb76933f3 100644 --- a/Modules/Filtering/Convolution/test/itkFFTConvolutionImageFilterDeltaFunctionTest.cxx +++ b/Modules/Filtering/Convolution/test/itkFFTConvolutionImageFilterDeltaFunctionTest.cxx @@ -53,8 +53,8 @@ itkFFTConvolutionImageFilterDeltaFunctionTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); // Set up delta function image - ImageType::RegionType region = reader->GetOutput()->GetLargestPossibleRegion(); - auto deltaFunctionImage = ImageType::New(); + const ImageType::RegionType region = reader->GetOutput()->GetLargestPossibleRegion(); + auto deltaFunctionImage = ImageType::New(); deltaFunctionImage->SetRegions(region); deltaFunctionImage->AllocateInitialized(); @@ -62,7 +62,7 @@ itkFFTConvolutionImageFilterDeltaFunctionTest(int argc, char * argv[]) ImageType::IndexType middleIndex; for (unsigned int i = 0; i < ImageDimension; ++i) { - ImageType::SizeValueType sizeInDimension = region.GetSize()[i]; + const ImageType::SizeValueType sizeInDimension = region.GetSize()[i]; middleIndex[i] = itk::Math::Floor(0.5 * sizeInDimension); } deltaFunctionImage->SetPixel(middleIndex, 1); @@ -75,7 +75,7 @@ itkFFTConvolutionImageFilterDeltaFunctionTest(int argc, char * argv[]) convolver->SetInput(deltaFunctionImage); convolver->SetKernelImage(reader->GetOutput()); - ConvolutionFilterType::SizeValueType sizeGreatestPrimeFactor = std::stoi(argv[3]); + const ConvolutionFilterType::SizeValueType sizeGreatestPrimeFactor = std::stoi(argv[3]); if (!itk::Math::IsPrime(sizeGreatestPrimeFactor)) { std::cerr << "A prime number is expected for the greatest prime factor size!" << std::endl; diff --git a/Modules/Filtering/Convolution/test/itkFFTConvolutionImageFilterTest.cxx b/Modules/Filtering/Convolution/test/itkFFTConvolutionImageFilterTest.cxx index 819fef34503..5d822e8a3a3 100644 --- a/Modules/Filtering/Convolution/test/itkFFTConvolutionImageFilterTest.cxx +++ b/Modules/Filtering/Convolution/test/itkFFTConvolutionImageFilterTest.cxx @@ -90,7 +90,7 @@ itkFFTConvolutionImageFilterTest(int argc, char * argv[]) using ChangeInformationFilterType = itk::ChangeInformationImageFilter; auto inputChanger = ChangeInformationFilterType::New(); inputChanger->ChangeRegionOn(); - ImageType::OffsetType inputOffset = { { -2, 3 } }; + const ImageType::OffsetType inputOffset = { { -2, 3 } }; inputChanger->SetOutputOffset(inputOffset); inputChanger->SetInput(reader1->GetOutput()); @@ -99,7 +99,7 @@ itkFFTConvolutionImageFilterTest(int argc, char * argv[]) // Test generality of filter by changing the kernel index auto kernelChanger = ChangeInformationFilterType::New(); kernelChanger->ChangeRegionOn(); - ImageType::OffsetType kernelOffset = { { 3, -5 } }; + const ImageType::OffsetType kernelOffset = { { 3, -5 } }; kernelChanger->SetOutputOffset(kernelOffset); kernelChanger->SetInput(reader2->GetOutput()); @@ -107,7 +107,7 @@ itkFFTConvolutionImageFilterTest(int argc, char * argv[]) if (argc >= 5) { - ConvolutionFilterType::SizeValueType sizeGreatestPrimeFactor = std::stoi(argv[4]); + const ConvolutionFilterType::SizeValueType sizeGreatestPrimeFactor = std::stoi(argv[4]); if (!itk::Math::IsPrime(sizeGreatestPrimeFactor)) { std::cerr << "A prime number is expected for the greatest prime factor size!" << std::endl; @@ -137,7 +137,7 @@ itkFFTConvolutionImageFilterTest(int argc, char * argv[]) if (argc >= 7) { - std::string outputRegionMode(argv[6]); + const std::string outputRegionMode(argv[6]); if (outputRegionMode == "SAME") { convoluter->SetOutputRegionMode(itk::ConvolutionImageFilterBaseEnums::ConvolutionImageFilterOutputRegion::SAME); @@ -175,7 +175,7 @@ itkFFTConvolutionImageFilterTest(int argc, char * argv[]) itk::ZeroFluxNeumannBoundaryCondition zeroFluxNeumannBoundaryCondition; if (argc >= 7) { - std::string boundaryCondition(argv[7]); + const std::string boundaryCondition(argv[7]); if (boundaryCondition == "CONSTANT") { convoluter->SetBoundaryCondition(&constantBoundaryCondition); @@ -199,7 +199,7 @@ itkFFTConvolutionImageFilterTest(int argc, char * argv[]) } } - itk::SimpleFilterWatcher watcher(convoluter, "filter"); + const itk::SimpleFilterWatcher watcher(convoluter, "filter"); ITK_TRY_EXPECT_NO_EXCEPTION(convoluter->Update()); @@ -226,9 +226,9 @@ itkFFTConvolutionImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_EXCEPTION(convoluter->Update()); // Test for invalid request region. - auto invalidIndex = ImageType::IndexType::Filled(1000); - auto invalidSize = ImageType::SizeType::Filled(1000); - ImageType::RegionType invalidRequestRegion(invalidIndex, invalidSize); + auto invalidIndex = ImageType::IndexType::Filled(1000); + auto invalidSize = ImageType::SizeType::Filled(1000); + const ImageType::RegionType invalidRequestRegion(invalidIndex, invalidSize); convoluter->GetOutput()->SetRequestedRegion(invalidRequestRegion); ITK_TRY_EXPECT_EXCEPTION(convoluter->Update()); diff --git a/Modules/Filtering/Convolution/test/itkFFTConvolutionImageFilterTestInt.cxx b/Modules/Filtering/Convolution/test/itkFFTConvolutionImageFilterTestInt.cxx index 466410cab73..c8d4bf9f3f8 100644 --- a/Modules/Filtering/Convolution/test/itkFFTConvolutionImageFilterTestInt.cxx +++ b/Modules/Filtering/Convolution/test/itkFFTConvolutionImageFilterTestInt.cxx @@ -66,11 +66,11 @@ itkFFTConvolutionImageFilterTestInt(int argc, char * argv[]) convolver->SetInput(reader1->GetOutput()); convolver->SetKernelImage(reader2->GetOutput()); - ConvolutionFilterType::SizeValueType sizeGreatestPrimeFactor = 2; + const ConvolutionFilterType::SizeValueType sizeGreatestPrimeFactor = 2; convolver->SetSizeGreatestPrimeFactor(sizeGreatestPrimeFactor); ITK_TEST_SET_GET_VALUE(sizeGreatestPrimeFactor, convolver->GetSizeGreatestPrimeFactor()); - itk::SimpleFilterWatcher watcher(convolver, "filter"); + const itk::SimpleFilterWatcher watcher(convolver, "filter"); if (argc >= 5) { @@ -79,7 +79,7 @@ itkFFTConvolutionImageFilterTestInt(int argc, char * argv[]) if (argc >= 6) { - std::string outputRegionMode(argv[5]); + const std::string outputRegionMode(argv[5]); if (outputRegionMode == "SAME") { convolver->SetOutputRegionModeToSame(); diff --git a/Modules/Filtering/Convolution/test/itkFFTNormalizedCorrelationImageFilterTest.cxx b/Modules/Filtering/Convolution/test/itkFFTNormalizedCorrelationImageFilterTest.cxx index 51b6b306a2b..f77bad2ffbe 100644 --- a/Modules/Filtering/Convolution/test/itkFFTNormalizedCorrelationImageFilterTest.cxx +++ b/Modules/Filtering/Convolution/test/itkFFTNormalizedCorrelationImageFilterTest.cxx @@ -53,11 +53,11 @@ itkFFTNormalizedCorrelationImageFilterTest(int argc, char * argv[]) using RealImageType = itk::Image; using FilterType = itk::FFTNormalizedCorrelationImageFilter; - char * fixedImageFileName = argv[1]; - char * movingImageFileName = argv[2]; - const char * outputImageFileName = argv[3]; - FilterType::SizeValueType requiredNumberOfOverlappingPixels = 0; - FilterType::RealPixelType requiredFractionOfOverlappingPixels = 0; + char * fixedImageFileName = argv[1]; + char * movingImageFileName = argv[2]; + const char * outputImageFileName = argv[3]; + const FilterType::SizeValueType requiredNumberOfOverlappingPixels = 0; + FilterType::RealPixelType requiredFractionOfOverlappingPixels = 0; if (argc > 4) { requiredFractionOfOverlappingPixels = std::stod(argv[4]); @@ -78,7 +78,7 @@ itkFFTNormalizedCorrelationImageFilterTest(int argc, char * argv[]) filter->SetRequiredNumberOfOverlappingPixels(requiredNumberOfOverlappingPixels); filter->SetRequiredFractionOfOverlappingPixels(requiredFractionOfOverlappingPixels); - itk::SimpleFilterWatcher watcher(filter, "FFTNormalizedCorrelation"); + const itk::SimpleFilterWatcher watcher(filter, "FFTNormalizedCorrelation"); // Shift the correlation values so they can be written out as a png. // The original range is [-1,1], and the new range is [0,255]. diff --git a/Modules/Filtering/Convolution/test/itkMaskedFFTNormalizedCorrelationImageFilterTest.cxx b/Modules/Filtering/Convolution/test/itkMaskedFFTNormalizedCorrelationImageFilterTest.cxx index 45f315736a7..d1791c3137f 100644 --- a/Modules/Filtering/Convolution/test/itkMaskedFFTNormalizedCorrelationImageFilterTest.cxx +++ b/Modules/Filtering/Convolution/test/itkMaskedFFTNormalizedCorrelationImageFilterTest.cxx @@ -47,11 +47,11 @@ itkMaskedFFTNormalizedCorrelationImageFilterTest(int argc, char * argv[]) using RealImageType = itk::Image; using FilterType = itk::MaskedFFTNormalizedCorrelationImageFilter; - char * fixedImageFileName = argv[1]; - char * movingImageFileName = argv[2]; - const char * outputImageFileName = argv[3]; - FilterType::SizeValueType requiredNumberOfOverlappingPixels = 0; - FilterType::RealPixelType requiredFractionOfOverlappingPixels = 0; + char * fixedImageFileName = argv[1]; + char * movingImageFileName = argv[2]; + const char * outputImageFileName = argv[3]; + const FilterType::SizeValueType requiredNumberOfOverlappingPixels = 0; + FilterType::RealPixelType requiredFractionOfOverlappingPixels = 0; if (argc > 4) { requiredFractionOfOverlappingPixels = std::stod(argv[4]); @@ -89,7 +89,7 @@ itkMaskedFFTNormalizedCorrelationImageFilterTest(int argc, char * argv[]) filter->SetMovingImageMask(movingMaskReader->GetOutput()); } - itk::SimpleFilterWatcher watcher(filter, "MaskedFFTNormalizedCorrelation"); + const itk::SimpleFilterWatcher watcher(filter, "MaskedFFTNormalizedCorrelation"); // Shift the correlation values so they can be written out as a png. // The original range is [-1,1], and the new range is [0,255]. diff --git a/Modules/Filtering/Convolution/test/itkNormalizedCorrelationImageFilterTest.cxx b/Modules/Filtering/Convolution/test/itkNormalizedCorrelationImageFilterTest.cxx index 754ff92549e..9528a99ca87 100644 --- a/Modules/Filtering/Convolution/test/itkNormalizedCorrelationImageFilterTest.cxx +++ b/Modules/Filtering/Convolution/test/itkNormalizedCorrelationImageFilterTest.cxx @@ -43,7 +43,7 @@ itkNormalizedCorrelationImageFilterTest(int argc, char * argv[]) using InputImageType = itk::Image; using CorrelationImageType = itk::Image; - itk::ImageFileReader::Pointer input = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer input = itk::ImageFileReader::New(); input->SetFileName(argv[1]); input->Update(); @@ -57,7 +57,7 @@ itkNormalizedCorrelationImageFilterTest(int argc, char * argv[]) annulus.CreateOperator(); // create a mask - itk::ImageFileReader::Pointer mask = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer mask = itk::ImageFileReader::New(); mask->SetFileName(argv[2]); // resample the mask to be the size of the input @@ -77,8 +77,8 @@ itkNormalizedCorrelationImageFilterTest(int argc, char * argv[]) // Create a filter using FilterType = itk::NormalizedCorrelationImageFilter; - auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter, "Normalized correlation"); + auto filter = FilterType::New(); + const itk::SimpleFilterWatcher watcher(filter, "Normalized correlation"); filter->SetInput(input->GetOutput()); filter->SetTemplate(annulus); diff --git a/Modules/Filtering/CurvatureFlow/include/itkBinaryMinMaxCurvatureFlowFunction.hxx b/Modules/Filtering/CurvatureFlow/include/itkBinaryMinMaxCurvatureFlowFunction.hxx index 7579f1e1c90..93278a4875d 100644 --- a/Modules/Filtering/CurvatureFlow/include/itkBinaryMinMaxCurvatureFlowFunction.hxx +++ b/Modules/Filtering/CurvatureFlow/include/itkBinaryMinMaxCurvatureFlowFunction.hxx @@ -37,15 +37,15 @@ BinaryMinMaxCurvatureFlowFunction::ComputeUpdate(const NeighborhoodType const FloatOffsetType & offset) -> PixelType { using CurvatureFlowFunctionType = CurvatureFlowFunction; - PixelType update = this->CurvatureFlowFunctionType::ComputeUpdate(it, globalData, offset); + const PixelType update = this->CurvatureFlowFunctionType::ComputeUpdate(it, globalData, offset); if (update == 0.0) { return update; } - NeighborhoodInnerProduct innerProduct; - PixelType avgValue = innerProduct(it, this->m_StencilOperator); + const NeighborhoodInnerProduct innerProduct; + const PixelType avgValue = innerProduct(it, this->m_StencilOperator); if (avgValue < m_Threshold) { diff --git a/Modules/Filtering/CurvatureFlow/include/itkCurvatureFlowFunction.hxx b/Modules/Filtering/CurvatureFlow/include/itkCurvatureFlowFunction.hxx index 264fe23311b..570efe96065 100644 --- a/Modules/Filtering/CurvatureFlow/include/itkCurvatureFlowFunction.hxx +++ b/Modules/Filtering/CurvatureFlow/include/itkCurvatureFlowFunction.hxx @@ -60,7 +60,7 @@ CurvatureFlowFunction::ComputeUpdate(const NeighborhoodType & it, } // get the center pixel position - IdentifierType center = it.Size() / 2; + const IdentifierType center = it.Size() / 2; const NeighborhoodScalesType neighborhoodScales = this->ComputeNeighborhoodScales(); PixelRealType magnitudeSqr = 0.0; diff --git a/Modules/Filtering/CurvatureFlow/include/itkCurvatureFlowImageFilter.hxx b/Modules/Filtering/CurvatureFlow/include/itkCurvatureFlowImageFilter.hxx index 9a1522b1fff..abcb2205f74 100644 --- a/Modules/Filtering/CurvatureFlow/include/itkCurvatureFlowImageFilter.hxx +++ b/Modules/Filtering/CurvatureFlow/include/itkCurvatureFlowImageFilter.hxx @@ -76,8 +76,8 @@ CurvatureFlowImageFilter::GenerateInputRequestedRegio Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); - OutputImagePointer outputPtr = this->GetOutput(); + const typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); + const OutputImagePointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -97,7 +97,7 @@ CurvatureFlowImageFilter::EnlargeOutputRequestedRegio auto * outputPtr = dynamic_cast(ptr); // get input image pointer - typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); + const typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); if (!inputPtr || !outputPtr) { return; diff --git a/Modules/Filtering/CurvatureFlow/include/itkMinMaxCurvatureFlowFunction.hxx b/Modules/Filtering/CurvatureFlow/include/itkMinMaxCurvatureFlowFunction.hxx index 8b96174608a..c83283880bf 100644 --- a/Modules/Filtering/CurvatureFlow/include/itkMinMaxCurvatureFlowFunction.hxx +++ b/Modules/Filtering/CurvatureFlow/include/itkMinMaxCurvatureFlowFunction.hxx @@ -61,10 +61,10 @@ MinMaxCurvatureFlowFunction::InitializeStencilOperator() m_StencilOperator.SetRadius(m_StencilRadius); - RadiusValueType counter[ImageDimension]; - unsigned int j; - RadiusValueType span = 2 * m_StencilRadius + 1; - RadiusValueType sqrRadius = m_StencilRadius * m_StencilRadius; + RadiusValueType counter[ImageDimension]; + unsigned int j; + const RadiusValueType span = 2 * m_StencilRadius + 1; + const RadiusValueType sqrRadius = m_StencilRadius * m_StencilRadius; for (j = 0; j < ImageDimension; ++j) { counter[j] = 0; @@ -151,8 +151,8 @@ MinMaxCurvatureFlowFunction::ComputeThreshold(const DispatchBase &, cons // Search for all position in the neighborhood perpendicular to // the gradient and at a distance of StencilRadius from center. - RadiusValueType counter[ImageDimension]; - RadiusValueType span = 2 * m_StencilRadius + 1; + RadiusValueType counter[ImageDimension]; + const RadiusValueType span = 2 * m_StencilRadius + 1; for (j = 0; j < ImageDimension; ++j) { counter[j] = 0; @@ -172,7 +172,8 @@ MinMaxCurvatureFlowFunction::ComputeThreshold(const DispatchBase &, cons for (j = 0; j < ImageDimension; ++j) { - IndexValueType diff = static_cast(counter[j]) - static_cast(m_StencilRadius); + const IndexValueType diff = + static_cast(counter[j]) - static_cast(m_StencilRadius); dotProduct += static_cast(diff) * gradient[j]; vectorMagnitude += static_cast(itk::Math::sqr(diff)); @@ -348,16 +349,16 @@ MinMaxCurvatureFlowFunction::ComputeThreshold(const Dispatch<3> &, const phi = std::atan(gradient[1] / gradient[0]); } - double cosTheta = std::cos(theta); - double sinTheta = std::sin(theta); - double cosPhi = std::cos(phi); - double sinPhi = std::sin(phi); + const double cosTheta = std::cos(theta); + const double sinTheta = std::sin(theta); + const double cosPhi = std::cos(phi); + const double sinPhi = std::sin(phi); - double rSinTheta = m_StencilRadius * sinTheta; - double rCosThetaCosPhi = m_StencilRadius * cosTheta * cosPhi; - double rCosThetaSinPhi = m_StencilRadius * cosTheta * sinPhi; - double rSinPhi = m_StencilRadius * sinPhi; - double rCosPhi = m_StencilRadius * cosPhi; + const double rSinTheta = m_StencilRadius * sinTheta; + const double rCosThetaCosPhi = m_StencilRadius * cosTheta * cosPhi; + const double rCosThetaSinPhi = m_StencilRadius * cosTheta * sinPhi; + const double rSinPhi = m_StencilRadius * sinPhi; + const double rCosPhi = m_StencilRadius * cosPhi; // Point 1: angle = 0; position[0] = Math::Round(m_StencilRadius + rCosThetaCosPhi); @@ -397,17 +398,17 @@ MinMaxCurvatureFlowFunction::ComputeUpdate(const NeighborhoodType & it, void * globalData, const FloatOffsetType & offset) -> PixelType { - PixelType update = this->Superclass::ComputeUpdate(it, globalData, offset); + const PixelType update = this->Superclass::ComputeUpdate(it, globalData, offset); if (update == 0.0) { return update; } - PixelType threshold = this->ComputeThreshold(Dispatch(), it); + const PixelType threshold = this->ComputeThreshold(Dispatch(), it); - NeighborhoodInnerProduct innerProduct; - PixelType avgValue = innerProduct(it, m_StencilOperator); + const NeighborhoodInnerProduct innerProduct; + const PixelType avgValue = innerProduct(it, m_StencilOperator); if (avgValue < threshold) { diff --git a/Modules/Filtering/CurvatureFlow/test/itkBinaryMinMaxCurvatureFlowImageFilterTest.cxx b/Modules/Filtering/CurvatureFlow/test/itkBinaryMinMaxCurvatureFlowImageFilterTest.cxx index d9796d2e869..eb2b8f56972 100644 --- a/Modules/Filtering/CurvatureFlow/test/itkBinaryMinMaxCurvatureFlowImageFilterTest.cxx +++ b/Modules/Filtering/CurvatureFlow/test/itkBinaryMinMaxCurvatureFlowImageFilterTest.cxx @@ -118,10 +118,10 @@ testBinaryMinMaxCurvatureFlow(itk::Size & size, // ND image siz * Create an image containing a circle/sphere with intensity of 0 * and background of 255 with added salt and pepper noise. */ - double sqrRadius = itk::Math::sqr(radius); // radius of the circle/sphere - double fractionNoise = 0.30; // salt & pepper noise fraction - PixelType foreground = 0.0; // intensity value of the foreground - PixelType background = 255.0; // intensity value of the background + const double sqrRadius = itk::Math::sqr(radius); // radius of the circle/sphere + const double fractionNoise = 0.30; // salt & pepper noise fraction + const PixelType foreground = 0.0; // intensity value of the foreground + const PixelType background = 255.0; // intensity value of the background std::cout << "Create an image of circle/sphere with noise" << std::endl; auto circleImage = ImageType::New(); @@ -218,7 +218,7 @@ testBinaryMinMaxCurvatureFlow(itk::Size & size, // ND image siz for (IteratorType outIter(swapPointer, swapPointer->GetBufferedRegion()); !outIter.IsAtEnd(); ++outIter) { typename ImageType::IndexType index = outIter.GetIndex(); - PixelType value = outIter.Get(); + const PixelType value = outIter.Get(); double lhs = 0.0; for (j = 0; j < ImageDimension; ++j) diff --git a/Modules/Filtering/CurvatureFlow/test/itkCurvatureFlowTest.cxx b/Modules/Filtering/CurvatureFlow/test/itkCurvatureFlowTest.cxx index 0a83a8b95fb..d76014baa0d 100644 --- a/Modules/Filtering/CurvatureFlow/test/itkCurvatureFlowTest.cxx +++ b/Modules/Filtering/CurvatureFlow/test/itkCurvatureFlowTest.cxx @@ -148,10 +148,10 @@ itkCurvatureFlowTest(int argc, char * argv[]) std::cout << "Test when wrong function type." << std::endl; using FunctionType = itk::DummyFunction; filter = FilterType::New(); - auto function = FunctionType::New(); - auto dummy = ImageType::New(); - auto size = ImageType::SizeType::Filled(3); - ImageType::RegionType region(size); + auto function = FunctionType::New(); + auto dummy = ImageType::New(); + auto size = ImageType::SizeType::Filled(3); + const ImageType::RegionType region(size); dummy->SetRegions(region); dummy->Allocate(); dummy->FillBuffer(0.2); diff --git a/Modules/Filtering/Deconvolution/include/itkIterativeDeconvolutionImageFilter.hxx b/Modules/Filtering/Deconvolution/include/itkIterativeDeconvolutionImageFilter.hxx index 2f93b0a9fca..1cb34372c35 100644 --- a/Modules/Filtering/Deconvolution/include/itkIterativeDeconvolutionImageFilter.hxx +++ b/Modules/Filtering/Deconvolution/include/itkIterativeDeconvolutionImageFilter.hxx @@ -91,7 +91,7 @@ IterativeDeconvolutionImageFilterGetInput()) { - typename InputImageType::Pointer imagePtr = const_cast(this->GetInput()); + const typename InputImageType::Pointer imagePtr = const_cast(this->GetInput()); imagePtr->SetRequestedRegionToLargestPossibleRegion(); } @@ -99,7 +99,7 @@ IterativeDeconvolutionImageFilter(this->GetKernelImage()); + const typename KernelImageType::Pointer kernelPtr = const_cast(this->GetKernelImage()); kernelPtr->SetRequestedRegionToLargestPossibleRegion(); } } @@ -112,8 +112,8 @@ IterativeDeconvolutionImageFilterSetMiniPipelineFilter(this); - typename Superclass::InputImageConstPointer inputPtr = this->GetInput(); - typename Superclass::OutputImagePointer outputPtr = this->GetOutput(0); + const typename Superclass::InputImageConstPointer inputPtr = this->GetInput(); + const typename Superclass::OutputImagePointer outputPtr = this->GetOutput(0); outputPtr->SetRequestedRegion(inputPtr->GetRequestedRegion()); outputPtr->SetBufferedRegion(inputPtr->GetBufferedRegion()); @@ -121,7 +121,7 @@ IterativeDeconvolutionImageFilterAllocate(); // Set up progress tracking - float iterationWeight = 0.8f / static_cast(m_NumberOfIterations); + const float iterationWeight = 0.8f / static_cast(m_NumberOfIterations); this->Initialize(progress, 0.1f, iterationWeight); for (m_Iteration = 0; m_Iteration < m_NumberOfIterations; ++m_Iteration) diff --git a/Modules/Filtering/Deconvolution/include/itkParametricBlindLeastSquaresDeconvolutionImageFilter.hxx b/Modules/Filtering/Deconvolution/include/itkParametricBlindLeastSquaresDeconvolutionImageFilter.hxx index b350427d901..a09c3034e49 100644 --- a/Modules/Filtering/Deconvolution/include/itkParametricBlindLeastSquaresDeconvolutionImageFilter.hxx +++ b/Modules/Filtering/Deconvolution/include/itkParametricBlindLeastSquaresDeconvolutionImageFilter.hxx @@ -196,37 +196,37 @@ ParametricBlindLeastSquaresDeconvolutionImageFilterSetParameters(parameters); m_KernelSource->UpdateLargestPossibleRegion(); - InternalKernelImagePointer plusImage = m_KernelSource->GetOutput(); + const InternalKernelImagePointer plusImage = m_KernelSource->GetOutput(); plusImage->DisconnectPipeline(); // Generate the minus image parameters[i] = thetaMinus; m_KernelSource->SetParameters(parameters); m_KernelSource->UpdateLargestPossibleRegion(); - InternalKernelImagePointer minusImage = m_KernelSource->GetOutput(); + const InternalKernelImagePointer minusImage = m_KernelSource->GetOutput(); minusImage->DisconnectPipeline(); // Subtract the two and divide by deltaTheta * 2 to get the // partial derivative image estimate, then multiply the result by // the Jacobian. We'll do this all in one loop to simplify things. - typename InternalKernelImageType::RegionType region(plusImage->GetLargestPossibleRegion()); - ImageRegionConstIterator plusImageIter(plusImage, region); - ImageRegionConstIterator minusImageIter(minusImage, region); - ImageRegionConstIterator jacobianImageIter(jacobianIFFT->GetOutput(), region); + const typename InternalKernelImageType::RegionType region(plusImage->GetLargestPossibleRegion()); + ImageRegionConstIterator plusImageIter(plusImage, region); + ImageRegionConstIterator minusImageIter(minusImage, region); + ImageRegionConstIterator jacobianImageIter(jacobianIFFT->GetOutput(), region); double sum = 0.0; while (!plusImageIter.IsAtEnd()) { - double dhdTheta = (plusImageIter.Get() - minusImageIter.Get()) / (2.0 * deltaTheta); + const double dhdTheta = (plusImageIter.Get() - minusImageIter.Get()) / (2.0 * deltaTheta); sum += dhdTheta * jacobianImageIter.Get(); ++plusImageIter; diff --git a/Modules/Filtering/Deconvolution/include/itkProjectedIterativeDeconvolutionImageFilter.hxx b/Modules/Filtering/Deconvolution/include/itkProjectedIterativeDeconvolutionImageFilter.hxx index 38e7fd49bbc..4d3f0acbbed 100644 --- a/Modules/Filtering/Deconvolution/include/itkProjectedIterativeDeconvolutionImageFilter.hxx +++ b/Modules/Filtering/Deconvolution/include/itkProjectedIterativeDeconvolutionImageFilter.hxx @@ -43,7 +43,7 @@ ProjectedIterativeDeconvolutionImageFilter::Initialize(ProgressAccu this->Superclass::Initialize(progress, progressWeight, iterationProgressWeight); m_ProjectionFilter = ProjectionFilterType::New(); - typename InternalImageType::PixelType zero{}; + const typename InternalImageType::PixelType zero{}; m_ProjectionFilter->ThresholdBelow(zero); } diff --git a/Modules/Filtering/Deconvolution/include/itkTikhonovDeconvolutionImageFilter.h b/Modules/Filtering/Deconvolution/include/itkTikhonovDeconvolutionImageFilter.h index 884343e100b..2e51062fcc0 100644 --- a/Modules/Filtering/Deconvolution/include/itkTikhonovDeconvolutionImageFilter.h +++ b/Modules/Filtering/Deconvolution/include/itkTikhonovDeconvolutionImageFilter.h @@ -141,9 +141,9 @@ class ITK_TEMPLATE_EXPORT TikhonovDeconvolutionFunctor inline TOutput operator()(const TInput1 & I, const TInput2 & H) const { - typename TOutput::value_type normH = std::norm(H); - typename TOutput::value_type denominator = normH + m_RegularizationConstant; - TOutput value{}; + const typename TOutput::value_type normH = std::norm(H); + const typename TOutput::value_type denominator = normH + m_RegularizationConstant; + TOutput value{}; if (denominator >= m_KernelZeroMagnitudeThreshold) { value = static_cast(I * (std::conj(H) / denominator)); diff --git a/Modules/Filtering/Deconvolution/test/itkInverseDeconvolutionImageFilterTest.cxx b/Modules/Filtering/Deconvolution/test/itkInverseDeconvolutionImageFilterTest.cxx index 1bcca9d1873..3b6ea8ae758 100644 --- a/Modules/Filtering/Deconvolution/test/itkInverseDeconvolutionImageFilterTest.cxx +++ b/Modules/Filtering/Deconvolution/test/itkInverseDeconvolutionImageFilterTest.cxx @@ -79,7 +79,7 @@ itkInverseDeconvolutionImageFilterTest(int argc, char * argv[]) // Check default KernelZeroMagnitudeThreshold value ITK_TEST_SET_GET_VALUE(1.0e-4, deconvolutionFilter->GetKernelZeroMagnitudeThreshold()); - double zeroMagnitudeThreshold = 1.0e-2; + const double zeroMagnitudeThreshold = 1.0e-2; deconvolutionFilter->SetKernelZeroMagnitudeThreshold(zeroMagnitudeThreshold); ITK_TEST_SET_GET_VALUE(zeroMagnitudeThreshold, deconvolutionFilter->GetKernelZeroMagnitudeThreshold()); diff --git a/Modules/Filtering/Deconvolution/test/itkLandweberDeconvolutionImageFilterTest.cxx b/Modules/Filtering/Deconvolution/test/itkLandweberDeconvolutionImageFilterTest.cxx index 727e561de7a..2ed9831c3f5 100644 --- a/Modules/Filtering/Deconvolution/test/itkLandweberDeconvolutionImageFilterTest.cxx +++ b/Modules/Filtering/Deconvolution/test/itkLandweberDeconvolutionImageFilterTest.cxx @@ -78,7 +78,7 @@ itkLandweberDeconvolutionImageFilterTest(int argc, char * argv[]) auto observer = IterationCommandType::New(); deconvolutionFilter->AddObserver(itk::IterationEvent(), observer); - itk::SimpleFilterWatcher watcher(deconvolutionFilter); + const itk::SimpleFilterWatcher watcher(deconvolutionFilter); // Write the deconvolution result try diff --git a/Modules/Filtering/Deconvolution/test/itkParametricBlindLeastSquaresDeconvolutionImageFilterTest.cxx b/Modules/Filtering/Deconvolution/test/itkParametricBlindLeastSquaresDeconvolutionImageFilterTest.cxx index 9466723f36c..48546b87c18 100644 --- a/Modules/Filtering/Deconvolution/test/itkParametricBlindLeastSquaresDeconvolutionImageFilterTest.cxx +++ b/Modules/Filtering/Deconvolution/test/itkParametricBlindLeastSquaresDeconvolutionImageFilterTest.cxx @@ -190,8 +190,8 @@ itkParametricBlindLeastSquaresDeconvolutionImageFilterTest(int argc, char * argv kernelSource->SetParameters(parameters); deconvolutionFilter->NormalizeOn(); - double alpha = std::stod(argv[4]); - double beta = std::stod(argv[5]); + const double alpha = std::stod(argv[4]); + const double beta = std::stod(argv[5]); deconvolutionFilter->SetAlpha(alpha); deconvolutionFilter->SetBeta(beta); deconvolutionFilter->SetInput(convolutionFilter->GetOutput()); @@ -212,7 +212,7 @@ itkParametricBlindLeastSquaresDeconvolutionImageFilterTest(int argc, char * argv return EXIT_FAILURE; } - KernelSourceType::ParametersValueType expectedSigmaX = 2.90243; + const KernelSourceType::ParametersValueType expectedSigmaX = 2.90243; if (itk::Math::abs(kernelSource->GetParameters()[0] - expectedSigmaX) > 1e-5) { std::cerr << "Kernel parameter[0] should have been " << expectedSigmaX << ", was " @@ -220,7 +220,7 @@ itkParametricBlindLeastSquaresDeconvolutionImageFilterTest(int argc, char * argv return EXIT_FAILURE; } - KernelSourceType::ParametersValueType expectedSigmaY = 2.90597; + const KernelSourceType::ParametersValueType expectedSigmaY = 2.90597; if (itk::Math::abs(kernelSource->GetParameters()[1] - expectedSigmaY) > 1e-5) { std::cerr << "Kernel parameter[1] should have been " << expectedSigmaY << ", was " diff --git a/Modules/Filtering/Deconvolution/test/itkProjectedIterativeDeconvolutionImageFilterTest.cxx b/Modules/Filtering/Deconvolution/test/itkProjectedIterativeDeconvolutionImageFilterTest.cxx index 1a3ec629a9b..bac895af7e7 100644 --- a/Modules/Filtering/Deconvolution/test/itkProjectedIterativeDeconvolutionImageFilterTest.cxx +++ b/Modules/Filtering/Deconvolution/test/itkProjectedIterativeDeconvolutionImageFilterTest.cxx @@ -37,7 +37,7 @@ itkProjectedIterativeDeconvolutionImageFilterTest(int, char *[]) auto deconvolutionFilter = ProjectedDeconvolutionFilterType::New(); deconvolutionFilter->Print(std::cout); - itk::SimpleFilterWatcher watcher(deconvolutionFilter); + const itk::SimpleFilterWatcher watcher(deconvolutionFilter); return EXIT_SUCCESS; } diff --git a/Modules/Filtering/Deconvolution/test/itkRichardsonLucyDeconvolutionImageFilterTest.cxx b/Modules/Filtering/Deconvolution/test/itkRichardsonLucyDeconvolutionImageFilterTest.cxx index 6cbc2ce1c02..c523cbab30d 100644 --- a/Modules/Filtering/Deconvolution/test/itkRichardsonLucyDeconvolutionImageFilterTest.cxx +++ b/Modules/Filtering/Deconvolution/test/itkRichardsonLucyDeconvolutionImageFilterTest.cxx @@ -86,7 +86,7 @@ itkRichardsonLucyDeconvolutionImageFilterTest(int argc, char * argv[]) auto observer = IterationCommandType::New(); deconvolutionFilter->AddObserver(itk::IterationEvent(), observer); - itk::SimpleFilterWatcher watcher(deconvolutionFilter); + const itk::SimpleFilterWatcher watcher(deconvolutionFilter); // Write the deconvolution result try @@ -118,7 +118,7 @@ itkRichardsonLucyDeconvolutionImageFilterTest(int argc, char * argv[]) return EXIT_FAILURE; } - unsigned int numIterations = 5; + const unsigned int numIterations = 5; deconvolutionFilter->SetNumberOfIterations(numIterations); if (deconvolutionFilter->GetNumberOfIterations() != numIterations) { @@ -134,7 +134,7 @@ itkRichardsonLucyDeconvolutionImageFilterTest(int argc, char * argv[]) return EXIT_FAILURE; } - unsigned int iteration = deconvolutionFilter->GetIteration(); + const unsigned int iteration = deconvolutionFilter->GetIteration(); std::cout << "Iteration: " << iteration << std::endl; std::cout << deconvolutionFilter->DeconvolutionFilterType::Superclass::GetNameOfClass() << std::endl; diff --git a/Modules/Filtering/Deconvolution/test/itkTikhonovDeconvolutionImageFilterTest.cxx b/Modules/Filtering/Deconvolution/test/itkTikhonovDeconvolutionImageFilterTest.cxx index fd86e2e6fba..6f03436775c 100644 --- a/Modules/Filtering/Deconvolution/test/itkTikhonovDeconvolutionImageFilterTest.cxx +++ b/Modules/Filtering/Deconvolution/test/itkTikhonovDeconvolutionImageFilterTest.cxx @@ -80,7 +80,7 @@ itkTikhonovDeconvolutionImageFilterTest(int argc, char * argv[]) // Check default RegularizationConstant value ITK_TEST_SET_GET_VALUE(0.0, deconvolutionFilter->GetRegularizationConstant()); - double regularizationConstant = 1.0e-4; + const double regularizationConstant = 1.0e-4; deconvolutionFilter->SetRegularizationConstant(regularizationConstant); ITK_TEST_SET_GET_VALUE(regularizationConstant, deconvolutionFilter->GetRegularizationConstant()); diff --git a/Modules/Filtering/Deconvolution/test/itkWienerDeconvolutionImageFilterTest.cxx b/Modules/Filtering/Deconvolution/test/itkWienerDeconvolutionImageFilterTest.cxx index f60089582af..4b7a6e272ab 100644 --- a/Modules/Filtering/Deconvolution/test/itkWienerDeconvolutionImageFilterTest.cxx +++ b/Modules/Filtering/Deconvolution/test/itkWienerDeconvolutionImageFilterTest.cxx @@ -86,7 +86,7 @@ itkWienerDeconvolutionImageFilterTest(int argc, char * argv[]) // Check default NoiseVariance value ITK_TEST_SET_GET_VALUE(0.0, deconvolutionFilter->GetNoiseVariance()); - double noiseVariance = 1.0; + const double noiseVariance = 1.0; deconvolutionFilter->SetNoiseVariance(noiseVariance); ITK_TEST_SET_GET_VALUE(noiseVariance, deconvolutionFilter->GetNoiseVariance()); diff --git a/Modules/Filtering/Denoising/include/itkPatchBasedDenoisingImageFilter.hxx b/Modules/Filtering/Denoising/include/itkPatchBasedDenoisingImageFilter.hxx index 6162a3a0a2e..3fa6361a228 100644 --- a/Modules/Filtering/Denoising/include/itkPatchBasedDenoisingImageFilter.hxx +++ b/Modules/Filtering/Denoising/include/itkPatchBasedDenoisingImageFilter.hxx @@ -362,7 +362,7 @@ PatchBasedDenoisingImageFilter::Initialize() { invFactor = m_IntensityRescaleInvFactor[0]; } - RealValueType sigma = 5.0 / invFactor; + const RealValueType sigma = 5.0 / invFactor; this->SetComponent(m_NoiseSigma, pc, sigma); this->SetComponent(m_NoiseSigmaSquared, pc, sigma * sigma); } @@ -470,9 +470,9 @@ PatchBasedDenoisingImageFilter::InitializePatchWeight // Allocate the patch weights (mask) as an image. // Done in physical space. - auto physicalSize = WeightsImageType::SizeType::Filled(physicalDiameter); - typename WeightsImageType::RegionType physicalRegion(physicalSize); - auto physicalWeightsImage = WeightsImageType::New(); + auto physicalSize = WeightsImageType::SizeType::Filled(physicalDiameter); + const typename WeightsImageType::RegionType physicalRegion(physicalSize); + auto physicalWeightsImage = WeightsImageType::New(); physicalWeightsImage->SetRegions(physicalRegion); physicalWeightsImage->SetSpacing(physicalSpacing); physicalWeightsImage->Allocate(); @@ -558,7 +558,7 @@ PatchBasedDenoisingImageFilter::InitializePatchWeight } // end for each element in the patch - typename PatchWeightsType::ValueType centerWeight = patchWeights[(this->GetPatchLengthInVoxels() - 1) / 2]; + const typename PatchWeightsType::ValueType centerWeight = patchWeights[(this->GetPatchLengthInVoxels() - 1) / 2]; if (centerWeight != 1.0) { if (centerWeight <= 0.0) @@ -568,7 +568,7 @@ PatchBasedDenoisingImageFilter::InitializePatchWeight } // Normalize to the center weight to guarantee that the center weight == 1.0 - typename PatchWeightsType::SizeValueType pSize = patchWeights.Size(); + const typename PatchWeightsType::SizeValueType pSize = patchWeights.Size(); for (pos = 0; pos < pSize; ++pos) { patchWeights[pos] = patchWeights[pos] / centerWeight; @@ -710,7 +710,7 @@ typename PatchBasedDenoisingImageFilter::ThreadDataSt } // Only evaluating each pixel once, so nothing to cache - bool useCachedComputations = false; + const bool useCachedComputations = false; InputImageRegionConstIteratorType imgIt(img, *fIt); imgIt.GoToBegin(); for (imgIt.GoToBegin(); !imgIt.IsAtEnd(); ++imgIt) @@ -799,8 +799,8 @@ PatchBasedDenoisingImageFilter::ComputeSignedEuclidea { for (unsigned int pc = 0; pc < m_NumPixelComponents; ++pc) { - RealValueType tmpDiff = this->GetComponent(b, pc) - this->GetComponent(a, pc); - RealValueType tmpWeight = weight[pc]; + const RealValueType tmpDiff = this->GetComponent(b, pc) - this->GetComponent(a, pc); + const RealValueType tmpWeight = weight[pc]; this->SetComponent(diff, pc, tmpDiff); norm[pc] = tmpWeight * tmpWeight * tmpDiff * tmpDiff; } @@ -850,10 +850,10 @@ PatchBasedDenoisingImageFilter::Compute3x3EigenAnalys // I3 = det(D) = DxxDyyDzz + 2DxyDxzDyz - (Dzz(Dxy)^2 + Dyy(Dxz)^2 + // Dxx(Dyz)^2) - RealTensorValueT I1 = D0 + D3 + D5; - RealTensorValueT I2 = D0 * D3 + D0 * D5 + D3 * D5 - (DSq1 + DSq2 + DSq4); - RealTensorValueT I3 = D0 * D3 * D5 + 2 * D1 * D2 * D4 - (D5 * DSq1 + D3 * DSq2 + D0 * DSq4); - RealTensorValueT I1div3 = I1 / 3; + const RealTensorValueT I1 = D0 + D3 + D5; + const RealTensorValueT I2 = D0 * D3 + D0 * D5 + D3 * D5 - (DSq1 + DSq2 + DSq4); + const RealTensorValueT I3 = D0 * D3 * D5 + 2 * D1 * D2 * D4 - (D5 * DSq1 + D3 * DSq2 + D0 * DSq4); + const RealTensorValueT I1div3 = I1 / 3; // Compute rotationally-invariant variables n and s // n = (I1/3)^2 - I2/3 @@ -879,13 +879,13 @@ PatchBasedDenoisingImageFilter::Compute3x3EigenAnalys } - double acos_arg = (s / n) * 1 / sqrtn; + const double acos_arg = (s / n) * 1 / sqrtn; // When floating point exceptions are enabled, std::acos generates // NaNs (domain errors) if itk::Math::abs(acos_arg) > 1.0 // We treat those out of domain arguments as 1.0 (the max allowed value // of the std::acos domain), in such case phi = acos(1.0) = acos(-1.0) = 0.0 // Compute phi = (acos((s/n) * sqrt(1/n)) / 3) - RealTensorValueT phi = (itk::Math::abs(acos_arg) <= 1.0) ? std::acos(acos_arg) / 3 : 0.0; + const RealTensorValueT phi = (itk::Math::abs(acos_arg) <= 1.0) ? std::acos(acos_arg) / 3 : 0.0; // Now compute the eigenvalues // lambda1 = I1/3 + 2*sqrt(n)*cos(phi) @@ -894,9 +894,9 @@ PatchBasedDenoisingImageFilter::Compute3x3EigenAnalys // Due to trace invariance, // lambda3 also = I1 - lambda1 - lambda2 - RealTensorValueT lambda1 = I1div3 + 2 * sqrtn * std::cos(phi); - RealTensorValueT lambda2 = I1div3 - 2 * sqrtn * std::cos(itk::Math::pi / 3 + phi); - RealTensorValueT lambda3 = I1 - lambda1 - lambda2; + const RealTensorValueT lambda1 = I1div3 + 2 * sqrtn * std::cos(phi); + const RealTensorValueT lambda2 = I1div3 - 2 * sqrtn * std::cos(itk::Math::pi / 3 + phi); + const RealTensorValueT lambda3 = I1 - lambda1 - lambda2; eigenVals[0] = lambda1; eigenVals[1] = lambda2; @@ -916,9 +916,9 @@ PatchBasedDenoisingImageFilter::Compute3x3EigenAnalys // Ai = Dxx - eigenVals[i] // Bi = Dyy - eigenVals[i] // Ci = Dzz - eigenVals[i] - RealTensorValueT A = D0 - eigenVals[i]; - RealTensorValueT B = D3 - eigenVals[i]; - RealTensorValueT C = D5 - eigenVals[i]; + const RealTensorValueT A = D0 - eigenVals[i]; + const RealTensorValueT B = D3 - eigenVals[i]; + const RealTensorValueT C = D5 - eigenVals[i]; // Compute eigenvec components x, y and z // eix = (DxyDyz - BiDxz)(DxzDyz - CiDxy) @@ -928,18 +928,18 @@ PatchBasedDenoisingImageFilter::Compute3x3EigenAnalys // eix = term1 * term2 // eiy = term2 * term3 // eiz = term1 * term3 - RealTensorValueT term1 = D1 * D4 - B * D2; - RealTensorValueT term2 = D2 * D4 - C * D1; - RealTensorValueT term3 = D2 * D1 - A * D4; - RealTensorValueT ex = term1 * term2; - RealTensorValueT ey = term2 * term3; - RealTensorValueT ez = term1 * term3; + const RealTensorValueT term1 = D1 * D4 - B * D2; + const RealTensorValueT term2 = D2 * D4 - C * D1; + const RealTensorValueT term3 = D2 * D1 - A * D4; + const RealTensorValueT ex = term1 * term2; + const RealTensorValueT ey = term2 * term3; + const RealTensorValueT ez = term1 * term3; // Now normalize the vector // e = [ex ey ez] // eigenVec = e / sqrt(e'e) - RealTensorValueT norm = ex * ex + ey * ey + ez * ez; - RealTensorValueT sqrtnorm = std::sqrt(norm); + const RealTensorValueT norm = ex * ex + ey * ey + ez * ez; + const RealTensorValueT sqrtnorm = std::sqrt(norm); eigenVecs(i, 0) = ex / sqrtnorm; eigenVecs(i, 1) = ey / sqrtnorm; eigenVecs(i, 2) = ez / sqrtnorm; @@ -1114,7 +1114,7 @@ PatchBasedDenoisingImageFilter::ComputeLogMapAndWeigh symMatrixLogMap[5] = YEigVal0 * temp20 * temp20 + YEigVal1 * temp21 * temp21 + YEigVal2 * temp22 * temp22; - RealValueType wt = weight[0]; + const RealValueType wt = weight[0]; geodesicDist[0] = wt * wt * (YEigVal0 * YEigVal0 + YEigVal1 * YEigVal1 + YEigVal2 * YEigVal2); } @@ -1512,7 +1512,7 @@ PatchBasedDenoisingImageFilter::ThreadedComputeSigmaU inList->SetImage(output); inList->SetRadius(radius); - BaseSamplerPointer sampler = threadData.sampler; + const BaseSamplerPointer sampler = threadData.sampler; // Break the input into a series of regions. The first region is free // of boundary conditions, the rest with boundary conditions. We operate @@ -1536,7 +1536,7 @@ PatchBasedDenoisingImageFilter::ThreadedComputeSigmaU // Only use pixels whose patch is entirely in bounds // for the sigma calculation - typename FaceListType::iterator fIt = faceList.begin(); + const typename FaceListType::iterator fIt = faceList.begin(); if (!(fIt->GetNumberOfPixels())) { // Empty region, don't use. @@ -1552,9 +1552,9 @@ PatchBasedDenoisingImageFilter::ThreadedComputeSigmaU // Skip this sample continue; } - InputImagePatchIterator currentPatch = sampleIt.GetMeasurementVector()[0]; - IndexType nIndex = currentPatch.GetIndex(); - InstanceIdentifier currentPatchId = inList->GetImage()->ComputeOffset(nIndex); + const InputImagePatchIterator currentPatch = sampleIt.GetMeasurementVector()[0]; + IndexType nIndex = currentPatch.GetIndex(); + const InstanceIdentifier currentPatchId = inList->GetImage()->ComputeOffset(nIndex); // Select a set of patches from the full image, excluding points that have // neighbors outside the boundary at locations different than that of the @@ -1620,7 +1620,7 @@ PatchBasedDenoisingImageFilter::ThreadedComputeSigmaU } else { - InputImagePatchIterator queryIt = sampler->GetSample()->GetMeasurementVector(currentPatchId)[0]; + const InputImagePatchIterator queryIt = sampler->GetSample()->GetMeasurementVector(currentPatchId)[0]; itkDebugMacro("unexpected index for current patch, search results are empty." << "\ncurrent patch id: " << currentPatchId << "\ncurrent patch index: " << nIndex << "\nindex calculated by searcher: " << queryIt.GetIndex(queryIt.GetCenterNeighborhoodIndex()) @@ -1637,7 +1637,7 @@ PatchBasedDenoisingImageFilter::ThreadedComputeSigmaU selectedIt != selectedPatches->End(); ++selectedIt) { - IndexType currSelectedIdx = selectedIt.GetMeasurementVector()[0].GetIndex(); + const IndexType currSelectedIdx = selectedIt.GetMeasurementVector()[0].GetIndex(); selectedPatch += currSelectedIdx - lastSelectedIdx; lastSelectedIdx = currSelectedIdx; // Since we make sure that the search query can only take place in a @@ -2310,7 +2310,7 @@ PatchBasedDenoisingImageFilter::ComputeGradientJointE RealValueType gaussianJointEntropy{}; for (unsigned int ic = 0; ic < m_NumIndependentComponents; ++ic) { - RealValueType kernelSigma = m_KernelBandwidthSigma[ic]; + const RealValueType kernelSigma = m_KernelBandwidthSigma[ic]; distanceJointEntropy += squaredNorm[ic] / itk::Math::sqr(kernelSigma); diff --git a/Modules/Filtering/Denoising/test/itkPatchBasedDenoisingImageFilterTest.cxx b/Modules/Filtering/Denoising/test/itkPatchBasedDenoisingImageFilterTest.cxx index 9f93903054a..e8b2ab61585 100644 --- a/Modules/Filtering/Denoising/test/itkPatchBasedDenoisingImageFilterTest.cxx +++ b/Modules/Filtering/Denoising/test/itkPatchBasedDenoisingImageFilterTest.cxx @@ -102,7 +102,7 @@ doDenoising(const std::string & inputFileName, // Create filter and initialize auto filter = FilterType::New(); - typename FilterType::InputImageType::Pointer inputImage = reader->GetOutput(); + const typename FilterType::InputImageType::Pointer inputImage = reader->GetOutput(); filter->SetInput(inputImage); // Set whether conditional derivatives should be used estimating sigma @@ -114,9 +114,9 @@ doDenoising(const std::string & inputFileName, ITK_TEST_SET_GET_VALUE(patchRadius, filter->GetPatchRadius()); // Instead of directly setting the weights, could also specify type - bool useSmoothDiscPatchWeights = true; + const bool useSmoothDiscPatchWeights = true; ITK_TEST_SET_GET_BOOLEAN(filter, UseSmoothDiscPatchWeights, useSmoothDiscPatchWeights); - bool useFastTensorComputations = true; + const bool useFastTensorComputations = true; ITK_TEST_SET_GET_BOOLEAN(filter, UseFastTensorComputations, useFastTensorComputations); // Noise model to use @@ -141,7 +141,7 @@ doDenoising(const std::string & inputFileName, ITK_TEST_SET_GET_VALUE(noiseModel, filter->GetNoiseModel()); // Stepsize or weight for smoothing term - double smoothingWeight = 1.0; + const double smoothingWeight = 1.0; filter->SetSmoothingWeight(smoothingWeight); ITK_TEST_SET_GET_VALUE(smoothingWeight, filter->GetSmoothingWeight()); @@ -178,16 +178,16 @@ doDenoising(const std::string & inputFileName, ITK_TEST_SET_GET_VALUE(sampler, filter->GetSampler()); // Automatic estimation of the kernel bandwidth - bool kernelBandwidthEstimation = true; + const bool kernelBandwidthEstimation = true; ITK_TEST_SET_GET_BOOLEAN(filter, KernelBandwidthEstimation, kernelBandwidthEstimation); // Update bandwidth every 'n' iterations - unsigned int kernelBandwidthUpdateFrequency = 3; + const unsigned int kernelBandwidthUpdateFrequency = 3; filter->SetKernelBandwidthUpdateFrequency(kernelBandwidthUpdateFrequency); ITK_TEST_SET_GET_VALUE(kernelBandwidthUpdateFrequency, filter->GetKernelBandwidthUpdateFrequency()); // Use 20% of the pixels for the sigma update calculation - double kernelBandwidthFractionPixelsForEstimation = 0.20; + const double kernelBandwidthFractionPixelsForEstimation = 0.20; filter->SetKernelBandwidthFractionPixelsForEstimation(kernelBandwidthFractionPixelsForEstimation); ITK_TEST_SET_GET_VALUE(kernelBandwidthFractionPixelsForEstimation, filter->GetKernelBandwidthFractionPixelsForEstimation()); @@ -206,12 +206,13 @@ doDenoising(const std::string & inputFileName, if (filter->GetNoiseModel() == FilterType::NoiseModelEnum::RICIAN || filter->GetNoiseModel() == FilterType::NoiseModelEnum::POISSON) { - typename ImageT::IndexType::IndexValueType indexValue = 0; - auto pixelIndex = ImageT::IndexType::Filled(indexValue); + const typename ImageT::IndexType::IndexValueType indexValue = 0; + auto pixelIndex = ImageT::IndexType::Filled(indexValue); - typename ImageT::PixelType originalPixelValue = inputImage->GetPixel(pixelIndex); + const typename ImageT::PixelType originalPixelValue = inputImage->GetPixel(pixelIndex); - typename ImageT::PixelType nonpositivePixelValue = itk::NumericTraits::NonpositiveMin(); + const typename ImageT::PixelType nonpositivePixelValue = + itk::NumericTraits::NonpositiveMin(); inputImage->SetPixel(pixelIndex, nonpositivePixelValue); @@ -261,9 +262,9 @@ doDenoising(const std::string & inputFileName, while (expectedKernelBandwidthSigmaIt != expectedKernelBandwidthSigma.end() && resultKernelBandwidthSigmaIt != resultKernelBandwidthSigma.end()) { - typename FilterType::RealArrayType::ValueType expectedValue = *expectedKernelBandwidthSigmaIt; - typename FilterType::RealArrayType::ValueType resultValue = *resultKernelBandwidthSigmaIt; - double tolerance = 1e-2 * expectedValue; + const typename FilterType::RealArrayType::ValueType expectedValue = *expectedKernelBandwidthSigmaIt; + const typename FilterType::RealArrayType::ValueType resultValue = *resultKernelBandwidthSigmaIt; + const double tolerance = 1e-2 * expectedValue; if (!itk::Math::FloatAlmostEqual(expectedValue, resultValue, 10, tolerance)) { std::cout.precision(static_cast(itk::Math::abs(std::log10(tolerance)))); diff --git a/Modules/Filtering/DiffusionTensorImage/include/itkDiffusionTensor3DReconstructionImageFilter.hxx b/Modules/Filtering/DiffusionTensorImage/include/itkDiffusionTensor3DReconstructionImageFilter.hxx index 94d49ff0b24..f104e1c76db 100644 --- a/Modules/Filtering/DiffusionTensorImage/include/itkDiffusionTensor3DReconstructionImageFilter.hxx +++ b/Modules/Filtering/DiffusionTensorImage/include/itkDiffusionTensor3DReconstructionImageFilter.hxx @@ -75,7 +75,7 @@ DiffusionTensor3DReconstructionImageFilterProcessObject::GetInput(0)->GetNameOfClass()); + const std::string gradientImageClassName(this->ProcessObject::GetInput(0)->GetNameOfClass()); if (strcmp(gradientImageClassName.c_str(), "VectorImage") != 0) { itkExceptionMacro("There is only one Gradient image. I expect that to be a VectorImage. " @@ -91,25 +91,25 @@ DiffusionTensor3DReconstructionImageFilter::Pointer maskSpatialObject = + const typename ImageMaskSpatialObject<3>::Pointer maskSpatialObject = dynamic_cast *>(this->ProcessObject::GetInput(1)); if (maskSpatialObject.IsNull()) { return; // not a mask image } - typename MaskImageType::ConstPointer maskImage = maskSpatialObject->GetImage(); + const typename MaskImageType::ConstPointer maskImage = maskSpatialObject->GetImage(); - typename MaskImageType::SizeType maskSize = maskImage->GetLargestPossibleRegion().GetSize(); - typename MaskImageType::SizeType refSize; + const typename MaskImageType::SizeType maskSize = maskImage->GetLargestPossibleRegion().GetSize(); + typename MaskImageType::SizeType refSize; - typename MaskImageType::PointType maskOrigin = maskImage->GetOrigin(); - typename MaskImageType::PointType refOrigin; + const typename MaskImageType::PointType maskOrigin = maskImage->GetOrigin(); + typename MaskImageType::PointType refOrigin; - typename MaskImageType::SpacingType maskSpacing = maskImage->GetSpacing(); - typename MaskImageType::SpacingType refSpacing; + const typename MaskImageType::SpacingType maskSpacing = maskImage->GetSpacing(); + typename MaskImageType::SpacingType refSpacing; - typename MaskImageType::DirectionType maskDirection = maskImage->GetDirection(); - typename MaskImageType::DirectionType refDirection; + const typename MaskImageType::DirectionType maskDirection = maskImage->GetDirection(); + typename MaskImageType::DirectionType refDirection; if (m_GradientImageTypeEnumeration == DiffusionTensor3DReconstructionImageFilterEnums::GradientImageFormat::GradientIsInManyImages) @@ -169,7 +169,8 @@ DiffusionTensor3DReconstructionImageFilter::DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) { - typename OutputImageType::Pointer outputImage = static_cast(this->ProcessObject::GetOutput(0)); + const typename OutputImageType::Pointer outputImage = + static_cast(this->ProcessObject::GetOutput(0)); ImageRegionIterator oit(outputImage, outputRegionForThread); @@ -182,7 +183,7 @@ DiffusionTensor3DReconstructionImageFilter(this->ProcessObject::GetInput(1)); } - bool useMask(maskSpatialObject.IsNotNull()); + const bool useMask(maskSpatialObject.IsNotNull()); // Two cases here . // 1. If the Gradients have been specified in multiple images, we will create @@ -196,7 +197,8 @@ DiffusionTensor3DReconstructionImageFilter(this->ProcessObject::GetInput(0)); + const typename ReferenceImageType::Pointer refImage = + static_cast(this->ProcessObject::GetInput(0)); ImageRegionConstIteratorWithIndex it(refImage, outputRegionForThread); it.GoToBegin(); @@ -206,7 +208,7 @@ DiffusionTensor3DReconstructionImageFilter(this->ProcessObject::GetInput(i + 1)); if (gradientImagePointer.IsNull()) { @@ -227,7 +229,7 @@ DiffusionTensor3DReconstructionImageFilter::IndexType index = it.GetIndex(); - typename ReferenceImageType::PointType point; + const typename ImageRegionConstIteratorWithIndex::IndexType index = it.GetIndex(); + typename ReferenceImageType::PointType point; refImage->TransformIndexToPhysicalPoint(index, point); unmaskedPixel = maskSpatialObject->IsInsideInWorldSpace(point); } @@ -248,7 +250,7 @@ DiffusionTensor3DReconstructionImageFilterGet(); + const GradientPixelType b = gradientItContainer[i]->Get(); if (Math::AlmostEquals(b, GradientPixelType{})) { @@ -262,7 +264,7 @@ DiffusionTensor3DReconstructionImageFilter pseudoInverseSolver{ m_TensorBasis.as_matrix() }; + const vnl_svd pseudoInverseSolver{ m_TensorBasis.as_matrix() }; if (m_NumberOfGradientDirections > 6) { D = pseudoInverseSolver.solve(m_BMatrix * B); @@ -355,8 +357,8 @@ DiffusionTensor3DReconstructionImageFilter::IndexType index = git.GetIndex(); - typename ReferenceImageType::PointType point; + const typename ImageRegionConstIteratorWithIndex::IndexType index = git.GetIndex(); + typename ReferenceImageType::PointType point; gradientImagePointer->TransformIndexToPhysicalPoint(index, point); unmaskedPixel = maskSpatialObject->IsInsideInWorldSpace(point); @@ -376,7 +378,7 @@ DiffusionTensor3DReconstructionImageFilter pseudoInverseSolver{ m_TensorBasis.as_matrix() }; + const vnl_svd pseudoInverseSolver{ m_TensorBasis.as_matrix() }; if (m_NumberOfGradientDirections > 6) { D = pseudoInverseSolver.solve(m_BMatrix * B); @@ -533,7 +535,7 @@ DiffusionTensor3DReconstructionImageFilterm_GradientDirectionContainer = gradientDirection; - unsigned int numImages = gradientDirection->Size(); + const unsigned int numImages = gradientDirection->Size(); this->m_NumberOfBaselineImages = 0; for (GradientDirectionContainerType::Iterator it = this->m_GradientDirectionContainer->Begin(); it != this->m_GradientDirectionContainer->End(); diff --git a/Modules/Filtering/DiffusionTensorImage/test/itkDiffusionTensor3DReconstructionImageFilterTest.cxx b/Modules/Filtering/DiffusionTensorImage/test/itkDiffusionTensor3DReconstructionImageFilterTest.cxx index 1851a7f96c3..30ed6a9a230 100644 --- a/Modules/Filtering/DiffusionTensorImage/test/itkDiffusionTensor3DReconstructionImageFilterTest.cxx +++ b/Modules/Filtering/DiffusionTensorImage/test/itkDiffusionTensor3DReconstructionImageFilterTest.cxx @@ -44,7 +44,7 @@ itkDiffusionTensor3DReconstructionImageFilterTest(int argc, char * argv[]) using TensorReconstructionImageFilterType = itk::DiffusionTensor3DReconstructionImageFilter; using GradientImageType = TensorReconstructionImageFilterType::GradientImageType; - TensorReconstructionImageFilterType::Pointer tensorReconstructionFilter = + const TensorReconstructionImageFilterType::Pointer tensorReconstructionFilter = TensorReconstructionImageFilterType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS( @@ -65,9 +65,9 @@ itkDiffusionTensor3DReconstructionImageFilterTest(int argc, char * argv[]) using ReferenceRegionType = ReferenceImageType::RegionType; using ReferenceIndexType = ReferenceRegionType::IndexType; using ReferenceSizeType = ReferenceRegionType::SizeType; - ReferenceSizeType sizeReferenceImage = { { 4, 4, 4 } }; - ReferenceIndexType indexReferenceImage = { { 0, 0, 0 } }; - ReferenceRegionType regionReferenceImage{ indexReferenceImage, sizeReferenceImage }; + const ReferenceSizeType sizeReferenceImage = { { 4, 4, 4 } }; + const ReferenceIndexType indexReferenceImage = { { 0, 0, 0 } }; + const ReferenceRegionType regionReferenceImage{ indexReferenceImage, sizeReferenceImage }; referenceImage->SetRegions(regionReferenceImage); referenceImage->Allocate(); referenceImage->FillBuffer(100); @@ -77,9 +77,9 @@ itkDiffusionTensor3DReconstructionImageFilterTest(int argc, char * argv[]) // Assign gradient directions // - double gradientDirections[6][3] = { { -1.000000, 0.000000, 0.000000 }, { -0.166000, 0.986000, 0.000000 }, - { 0.110000, 0.664000, 0.740000 }, { -0.901000, -0.419000, -0.110000 }, - { 0.169000, -0.601000, 0.781000 }, { 0.815000, -0.386000, 0.433000 } }; + const double gradientDirections[6][3] = { { -1.000000, 0.000000, 0.000000 }, { -0.166000, 0.986000, 0.000000 }, + { 0.110000, 0.664000, 0.740000 }, { -0.901000, -0.419000, -0.110000 }, + { 0.169000, -0.601000, 0.781000 }, { 0.815000, -0.386000, 0.433000 } }; // Create gradient images @@ -92,10 +92,10 @@ itkDiffusionTensor3DReconstructionImageFilterTest(int argc, char * argv[]) for (unsigned int i = 0; i < numberOfGradientImages; ++i) { - auto gradientImage = GradientImageType::New(); - GradientSizeType sizeGradientImage = { { 4, 4, 4 } }; - GradientIndexType indexGradientImage = { { 0, 0, 0 } }; - GradientRegionType regionGradientImage{ indexGradientImage, sizeGradientImage }; + auto gradientImage = GradientImageType::New(); + const GradientSizeType sizeGradientImage = { { 4, 4, 4 } }; + const GradientIndexType indexGradientImage = { { 0, 0, 0 } }; + const GradientRegionType regionGradientImage{ indexGradientImage, sizeGradientImage }; gradientImage->SetRegions(regionGradientImage); gradientImage->Allocate(); @@ -120,9 +120,9 @@ itkDiffusionTensor3DReconstructionImageFilterTest(int argc, char * argv[]) tensorReconstructionFilter->GetGradientDirection(i); for (unsigned int j = 0; j < gradientDirection.size(); ++j) { - TensorReconstructionImageFilterType::GradientDirectionType::element_type gradientDirectionComponent = + const TensorReconstructionImageFilterType::GradientDirectionType::element_type gradientDirectionComponent = gradientDirection[j]; - TensorReconstructionImageFilterType::GradientDirectionType::element_type outputComponent = output[j]; + const TensorReconstructionImageFilterType::GradientDirectionType::element_type outputComponent = output[j]; if (!itk::Math::FloatAlmostEqual(gradientDirectionComponent, outputComponent, 10, epsilon)) { std::cerr.precision(static_cast(itk::Math::abs(std::log10(epsilon)))); @@ -137,7 +137,7 @@ itkDiffusionTensor3DReconstructionImageFilterTest(int argc, char * argv[]) } // Test gradient direction index exception - unsigned int idx = numberOfGradientImages + 1; + const unsigned int idx = numberOfGradientImages + 1; ITK_TRY_EXPECT_EXCEPTION(tensorReconstructionFilter->GetGradientDirection(idx)); // @@ -155,7 +155,7 @@ itkDiffusionTensor3DReconstructionImageFilterTest(int argc, char * argv[]) tensorReconstructionFilter->SetMaskImage(maskImage); // // just for coverage, use the Spatial Object input type as well. - itk::ImageMaskSpatialObject<3>::Pointer maskSpatialObject = itk::ImageMaskSpatialObject<3>::New(); + const itk::ImageMaskSpatialObject<3>::Pointer maskSpatialObject = itk::ImageMaskSpatialObject<3>::New(); maskSpatialObject->SetImage(maskImage); maskSpatialObject->Update(); tensorReconstructionFilter->SetMaskSpatialObject(maskSpatialObject); @@ -171,17 +171,17 @@ itkDiffusionTensor3DReconstructionImageFilterTest(int argc, char * argv[]) << "This filter is using " << tensorReconstructionFilter->GetNumberOfWorkUnits() << " work units " << std::endl; - itk::SimpleFilterWatcher watcher(tensorReconstructionFilter, "Tensor Reconstruction"); + const itk::SimpleFilterWatcher watcher(tensorReconstructionFilter, "Tensor Reconstruction"); tensorReconstructionFilter->Update(); using TensorImageType = TensorReconstructionImageFilterType::TensorImageType; - TensorImageType::Pointer tensorImage = tensorReconstructionFilter->GetOutput(); + const TensorImageType::Pointer tensorImage = tensorReconstructionFilter->GetOutput(); using TensorImageIndexType = TensorImageType::IndexType; - TensorImageIndexType tensorImageIndex = { { 3, 3, 3 } }; - GradientIndexType gradientImageIndex = { { 3, 3, 3 } }; - ReferenceIndexType referenceImageIndex = { { 3, 3, 3 } }; + const TensorImageIndexType tensorImageIndex = { { 3, 3, 3 } }; + const GradientIndexType gradientImageIndex = { { 3, 3, 3 } }; + const ReferenceIndexType referenceImageIndex = { { 3, 3, 3 } }; std::cout << std::endl << "Pixels at index: " << tensorImageIndex << std::endl; std::cout << "Reference pixel " << referenceImage->GetPixel(referenceImageIndex) << std::endl; @@ -197,8 +197,8 @@ itkDiffusionTensor3DReconstructionImageFilterTest(int argc, char * argv[]) { -8.4079, 0.900034, 2.62504 } }; std::cout << std::endl << "Reconstructed tensor : " << std::endl; - bool passed = true; - double precision = 0.0001; + bool passed = true; + const double precision = 0.0001; for (unsigned int i = 0; i < 3; ++i) { std::cout << '\t'; @@ -221,7 +221,7 @@ itkDiffusionTensor3DReconstructionImageFilterTest(int argc, char * argv[]) for (const auto & i : expectedResult) { std::cout << '\t'; - for (double j : i) + for (const double j : i) { std::cout << j << ' '; } diff --git a/Modules/Filtering/DiffusionTensorImage/test/itkDiffusionTensor3DTest.cxx b/Modules/Filtering/DiffusionTensorImage/test/itkDiffusionTensor3DTest.cxx index bf6491f89f3..4fb668d2363 100644 --- a/Modules/Filtering/DiffusionTensorImage/test/itkDiffusionTensor3DTest.cxx +++ b/Modules/Filtering/DiffusionTensorImage/test/itkDiffusionTensor3DTest.cxx @@ -368,7 +368,7 @@ itkDiffusionTensor3DTest(int, char *[]) const double tolerance = 1e-4; - AccumulateValueType computedTrace = tensor3.GetTrace(); + const AccumulateValueType computedTrace = tensor3.GetTrace(); if (itk::Math::abs(computedTrace - expectedTrace) > tolerance) { std::cerr << "Error computing the Trace" << std::endl; @@ -380,7 +380,7 @@ itkDiffusionTensor3DTest(int, char *[]) // Test the value of internal scalar product constexpr RealValueType expectedInternalScalarProduct = 1829; - RealValueType computedInternalScalarProduct = tensor3.GetInnerScalarProduct(); + const RealValueType computedInternalScalarProduct = tensor3.GetInnerScalarProduct(); if (itk::Math::abs(computedInternalScalarProduct - expectedInternalScalarProduct) > tolerance) { std::cerr << "Error computing Internal Scalar Product" << std::endl; @@ -393,7 +393,7 @@ itkDiffusionTensor3DTest(int, char *[]) // Test the value of Fractional Anisotropy constexpr RealValueType expectedFractionalAnisotropy = 0.349177; - RealValueType computedFractionalAnisotropy = tensor3.GetFractionalAnisotropy(); + const RealValueType computedFractionalAnisotropy = tensor3.GetFractionalAnisotropy(); if (itk::Math::abs(computedFractionalAnisotropy - expectedFractionalAnisotropy) > tolerance) { std::cerr << "Error computing Fractional Anisotropy" << std::endl; @@ -405,7 +405,7 @@ itkDiffusionTensor3DTest(int, char *[]) // Test the value of Relative Anisotropy constexpr RealValueType expectedRelativeAnisotropy = 1.9044; - RealValueType computedRelativeAnisotropy = tensor3.GetRelativeAnisotropy(); + const RealValueType computedRelativeAnisotropy = tensor3.GetRelativeAnisotropy(); if (itk::Math::abs(computedRelativeAnisotropy - expectedRelativeAnisotropy) > tolerance) { std::cerr << "Error computing Relative Anisotropy" << std::endl; @@ -421,25 +421,25 @@ itkDiffusionTensor3DTest(int, char *[]) { using TensorType = itk::DiffusionTensor3D; - TensorType maxTensor = itk::NumericTraits::max(); + const TensorType maxTensor = itk::NumericTraits::max(); std::cout << maxTensor << std::endl; - TensorType minTensor = itk::NumericTraits::min(); + const TensorType minTensor = itk::NumericTraits::min(); std::cout << minTensor << std::endl; - TensorType nonpositiveMinTensor = itk::NumericTraits::NonpositiveMin(); + const TensorType nonpositiveMinTensor = itk::NumericTraits::NonpositiveMin(); std::cout << nonpositiveMinTensor << std::endl; - TensorType zeroValue{}; + const TensorType zeroValue{}; std::cout << zeroValue << std::endl; - TensorType oneValue = itk::NumericTraits::OneValue(); + const TensorType oneValue = itk::NumericTraits::OneValue(); std::cout << oneValue << std::endl; - TensorType zero{}; + const TensorType zero{}; std::cout << zero << std::endl; - TensorType one = itk::NumericTraits::OneValue(); + const TensorType one = itk::NumericTraits::OneValue(); std::cout << one << std::endl; } @@ -465,7 +465,7 @@ itkDiffusionTensor3DTest(int, char *[]) Float3DTensorType floatTensor3 = static_cast(intTensor); // Check that all floatTensors have are the same - float precision = 1e-6; + const float precision = 1e-6; for (unsigned int i = 0; i < Float3DTensorType::InternalDimension; ++i) { auto intVal = static_cast(intTensor[i]); diff --git a/Modules/Filtering/DiffusionTensorImage/test/itkTensorFractionalAnisotropyImageFilterTest.cxx b/Modules/Filtering/DiffusionTensorImage/test/itkTensorFractionalAnisotropyImageFilterTest.cxx index e339647f2f9..5a85678f10e 100644 --- a/Modules/Filtering/DiffusionTensorImage/test/itkTensorFractionalAnisotropyImageFilterTest.cxx +++ b/Modules/Filtering/DiffusionTensorImage/test/itkTensorFractionalAnisotropyImageFilterTest.cxx @@ -131,7 +131,7 @@ itkTensorFractionalAnisotropyImageFilterTest(int, char *[]) // It is important to do it AFTER the filter is Updated // Because the object connected to the output may be changed // by another during GenerateData() call - myFaImageType::Pointer outputImage = fractionalAnisotropyFilter->GetOutput(); + const myFaImageType::Pointer outputImage = fractionalAnisotropyFilter->GetOutput(); // Declare Iterator type for the output image using myOutputIteratorType = itk::ImageRegionIteratorWithIndex; diff --git a/Modules/Filtering/DiffusionTensorImage/test/itkTensorRelativeAnisotropyImageFilterTest.cxx b/Modules/Filtering/DiffusionTensorImage/test/itkTensorRelativeAnisotropyImageFilterTest.cxx index 9e105c9f6fa..4fa31ef8e0d 100644 --- a/Modules/Filtering/DiffusionTensorImage/test/itkTensorRelativeAnisotropyImageFilterTest.cxx +++ b/Modules/Filtering/DiffusionTensorImage/test/itkTensorRelativeAnisotropyImageFilterTest.cxx @@ -131,7 +131,7 @@ itkTensorRelativeAnisotropyImageFilterTest(int, char *[]) // It is important to do it AFTER the filter is Updated // Because the object connected to the output may be changed // by another during GenerateData() call - myFaImageType::Pointer outputImage = relativeAnisotropyFilter->GetOutput(); + const myFaImageType::Pointer outputImage = relativeAnisotropyFilter->GetOutput(); // Declare Iterator type for the output image using myOutputIteratorType = itk::ImageRegionIteratorWithIndex; diff --git a/Modules/Filtering/DisplacementField/include/itkBSplineExponentialDiffeomorphicTransform.hxx b/Modules/Filtering/DisplacementField/include/itkBSplineExponentialDiffeomorphicTransform.hxx index 134eefa8a82..1e8f915bdd5 100644 --- a/Modules/Filtering/DisplacementField/include/itkBSplineExponentialDiffeomorphicTransform.hxx +++ b/Modules/Filtering/DisplacementField/include/itkBSplineExponentialDiffeomorphicTransform.hxx @@ -81,7 +81,7 @@ BSplineExponentialDiffeomorphicTransform::Upda } } - ConstantVelocityFieldPointer velocityField = this->GetModifiableConstantVelocityField(); + const ConstantVelocityFieldPointer velocityField = this->GetModifiableConstantVelocityField(); if (!velocityField) { itkExceptionMacro("The velocity field has not been set."); @@ -111,7 +111,7 @@ BSplineExponentialDiffeomorphicTransform::Upda { itkDebugMacro("Smoothing the update field."); - ConstantVelocityFieldPointer updateSmoothField = + const ConstantVelocityFieldPointer updateSmoothField = this->BSplineSmoothConstantVelocityField(updateField, this->GetNumberOfControlPointsForTheUpdateField()); updateField = updateSmoothField; @@ -130,7 +130,7 @@ BSplineExponentialDiffeomorphicTransform::Upda adder->SetInput1(velocityField); adder->SetInput2(multiplier->GetOutput()); - ConstantVelocityFieldPointer updatedVelocityField = adder->GetOutput(); + const ConstantVelocityFieldPointer updatedVelocityField = adder->GetOutput(); updatedVelocityField->Update(); updatedVelocityField->DisconnectPipeline(); @@ -150,7 +150,7 @@ BSplineExponentialDiffeomorphicTransform::Upda { itkDebugMacro("Smoothing the velocity field."); - ConstantVelocityFieldPointer velocitySmoothField = this->BSplineSmoothConstantVelocityField( + const ConstantVelocityFieldPointer velocitySmoothField = this->BSplineSmoothConstantVelocityField( updatedVelocityField, this->GetNumberOfControlPointsForTheConstantVelocityField()); this->SetConstantVelocityField(velocitySmoothField); diff --git a/Modules/Filtering/DisplacementField/include/itkBSplineSmoothingOnUpdateDisplacementFieldTransform.hxx b/Modules/Filtering/DisplacementField/include/itkBSplineSmoothingOnUpdateDisplacementFieldTransform.hxx index 7a00af6ad55..81f1d63b569 100644 --- a/Modules/Filtering/DisplacementField/include/itkBSplineSmoothingOnUpdateDisplacementFieldTransform.hxx +++ b/Modules/Filtering/DisplacementField/include/itkBSplineSmoothingOnUpdateDisplacementFieldTransform.hxx @@ -68,7 +68,7 @@ BSplineSmoothingOnUpdateDisplacementFieldTransformGetModifiableDisplacementField(); + const DisplacementFieldPointer displacementField = this->GetModifiableDisplacementField(); const typename DisplacementFieldType::RegionType & bufferedRegion = displacementField->GetBufferedRegion(); const SizeValueType numberOfPixels = bufferedRegion.GetNumberOfPixels(); @@ -103,19 +103,19 @@ BSplineSmoothingOnUpdateDisplacementFieldTransformSetSpacing(displacementField->GetSpacing()); importer->SetDirection(displacementField->GetDirection()); - DisplacementFieldPointer updateField = importer->GetOutput(); + const DisplacementFieldPointer updateField = importer->GetOutput(); updateField->Update(); updateField->DisconnectPipeline(); - DisplacementFieldPointer updateSmoothField = + const DisplacementFieldPointer updateSmoothField = this->BSplineSmoothDisplacementField(updateField, this->m_NumberOfControlPointsForTheUpdateField); auto * updatePointer = reinterpret_cast(updateSmoothField->GetBufferPointer()); // Add the update field to the current total field - bool letArrayManageMemory = false; + const bool letArrayManageMemory = false; // Pass data pointer to required container. No copying is done. - DerivativeType smoothedUpdate(updatePointer, update.GetSize(), letArrayManageMemory); + const DerivativeType smoothedUpdate(updatePointer, update.GetSize(), letArrayManageMemory); Superclass::UpdateTransformParameters(smoothedUpdate, factor); } else @@ -148,11 +148,11 @@ BSplineSmoothingOnUpdateDisplacementFieldTransformSetSpacing(displacementField->GetSpacing()); importer->SetDirection(displacementField->GetDirection()); - DisplacementFieldPointer totalField = importer->GetOutput(); + const DisplacementFieldPointer totalField = importer->GetOutput(); totalField->Update(); totalField->DisconnectPipeline(); - DisplacementFieldPointer totalSmoothField = + const DisplacementFieldPointer totalSmoothField = this->BSplineSmoothDisplacementField(totalField, this->m_NumberOfControlPointsForTheTotalField); ImageAlgorithm::Copy( @@ -187,7 +187,7 @@ BSplineSmoothingOnUpdateDisplacementFieldTransform(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Filtering/DisplacementField/include/itkComposeDisplacementFieldsImageFilter.hxx b/Modules/Filtering/DisplacementField/include/itkComposeDisplacementFieldsImageFilter.hxx index e74a0c5b32e..58824232fa7 100644 --- a/Modules/Filtering/DisplacementField/include/itkComposeDisplacementFieldsImageFilter.hxx +++ b/Modules/Filtering/DisplacementField/include/itkComposeDisplacementFieldsImageFilter.hxx @@ -74,8 +74,8 @@ template void ComposeDisplacementFieldsImageFilter::DynamicThreadedGenerateData(const RegionType & region) { - typename OutputFieldType::Pointer output = this->GetOutput(); - typename InputFieldType::ConstPointer warpingField = this->GetWarpingField(); + const typename OutputFieldType::Pointer output = this->GetOutput(); + const typename InputFieldType::ConstPointer warpingField = this->GetWarpingField(); ImageRegionConstIteratorWithIndex ItW(warpingField, region); ImageRegionIterator ItF(output, region); diff --git a/Modules/Filtering/DisplacementField/include/itkConstantVelocityFieldTransform.hxx b/Modules/Filtering/DisplacementField/include/itkConstantVelocityFieldTransform.hxx index b2cc63636b7..d8420365117 100644 --- a/Modules/Filtering/DisplacementField/include/itkConstantVelocityFieldTransform.hxx +++ b/Modules/Filtering/DisplacementField/include/itkConstantVelocityFieldTransform.hxx @@ -236,7 +236,7 @@ ConstantVelocityFieldTransform::IntegrateVeloc using ExponentiatorType = ExponentialDisplacementFieldImageFilter; - ConstantVelocityFieldPointer constantVelocityField = this->GetModifiableConstantVelocityField(); + const ConstantVelocityFieldPointer constantVelocityField = this->GetModifiableConstantVelocityField(); auto exponentiator = ExponentiatorType::New(); exponentiator->SetInput(constantVelocityField); @@ -321,8 +321,8 @@ typename LightObject::Pointer ConstantVelocityFieldTransform::InternalClone() const { // create a new instance - LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + LightObject::Pointer loPtr = Superclass::InternalClone(); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); @@ -334,15 +334,15 @@ ConstantVelocityFieldTransform::InternalClone( rval->SetParameters(this->GetParameters()); // need the displacement field but GetDisplacementField is non-const. - auto * nonConstThis = const_cast(this); - typename DisplacementFieldType::ConstPointer dispField = nonConstThis->GetDisplacementField(); - typename DisplacementFieldType::Pointer cloneDispField = this->CopyDisplacementField(dispField); + auto * nonConstThis = const_cast(this); + const typename DisplacementFieldType::ConstPointer dispField = nonConstThis->GetDisplacementField(); + const typename DisplacementFieldType::Pointer cloneDispField = this->CopyDisplacementField(dispField); rval->GetModifiableInterpolator()->SetInputImage(cloneDispField); rval->SetDisplacementField(cloneDispField); // now do the inverse -- it actually gets created as a side effect? - typename DisplacementFieldType::ConstPointer invDispField = nonConstThis->GetInverseDisplacementField(); - typename DisplacementFieldType::Pointer cloneInvDispField = this->CopyDisplacementField(invDispField); + const typename DisplacementFieldType::ConstPointer invDispField = nonConstThis->GetInverseDisplacementField(); + const typename DisplacementFieldType::Pointer cloneInvDispField = this->CopyDisplacementField(invDispField); rval->SetInverseDisplacementField(cloneInvDispField); // copy the VelocityField @@ -362,7 +362,7 @@ ConstantVelocityFieldTransform::InternalClone( rval->SetNumberOfIntegrationSteps(this->GetNumberOfIntegrationSteps()); // copy the interpolator - ConstantVelocityFieldInterpolatorPointer newInterp = dynamic_cast( + const ConstantVelocityFieldInterpolatorPointer newInterp = dynamic_cast( this->m_ConstantVelocityFieldInterpolator->CreateAnother().GetPointer()); // interpolator needs to know about the velocity field newInterp->SetInputImage(rval->GetConstantVelocityField()); diff --git a/Modules/Filtering/DisplacementField/include/itkDisplacementFieldJacobianDeterminantFilter.hxx b/Modules/Filtering/DisplacementField/include/itkDisplacementFieldJacobianDeterminantFilter.hxx index b913c7b7c21..e0ce4d724e9 100644 --- a/Modules/Filtering/DisplacementField/include/itkDisplacementFieldJacobianDeterminantFilter.hxx +++ b/Modules/Filtering/DisplacementField/include/itkDisplacementFieldJacobianDeterminantFilter.hxx @@ -96,8 +96,8 @@ DisplacementFieldJacobianDeterminantFilter Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - InputImagePointer inputPtr = const_cast(this->GetInput()); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImagePointer inputPtr = const_cast(this->GetInput()); + const OutputImagePointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -176,8 +176,8 @@ DisplacementFieldJacobianDeterminantFilter ImageRegionIterator it; // Find the data-set boundary "faces" - NeighborhoodAlgorithm::ImageBoundaryFacesCalculator bC; - typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = + NeighborhoodAlgorithm::ImageBoundaryFacesCalculator bC; + const typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = bC(dynamic_cast(m_RealValuedInputImage.GetPointer()), outputRegionForThread, m_NeighborhoodRadius); diff --git a/Modules/Filtering/DisplacementField/include/itkDisplacementFieldToBSplineImageFilter.hxx b/Modules/Filtering/DisplacementField/include/itkDisplacementFieldToBSplineImageFilter.hxx index 59ffad80f30..8a1a32bd82b 100644 --- a/Modules/Filtering/DisplacementField/include/itkDisplacementFieldToBSplineImageFilter.hxx +++ b/Modules/Filtering/DisplacementField/include/itkDisplacementFieldToBSplineImageFilter.hxx @@ -183,7 +183,7 @@ DisplacementFieldToBSplineImageFilter } if (isOnStationaryBoundary) { - VectorType data{}; + const VectorType data{}; typename InputPointSetType::PointType point; bsplineParametricDomainField->TransformIndexToPhysicalPoint(index, point); diff --git a/Modules/Filtering/DisplacementField/include/itkDisplacementFieldTransform.hxx b/Modules/Filtering/DisplacementField/include/itkDisplacementFieldTransform.hxx index b4a7ba6ba01..e26d6426896 100644 --- a/Modules/Filtering/DisplacementField/include/itkDisplacementFieldTransform.hxx +++ b/Modules/Filtering/DisplacementField/include/itkDisplacementFieldTransform.hxx @@ -192,7 +192,7 @@ DisplacementFieldTransform::GetInverseJacobian if (useSVD) { this->ComputeJacobianWithRespectToPositionInternal(index, jacobian, false); - vnl_svd svd{ jacobian.as_ref() }; + const vnl_svd svd{ jacobian.as_ref() }; for (unsigned int i = 0; i < jacobian.rows(); ++i) { for (unsigned int j = 0; j < jacobian.cols(); ++j) @@ -277,8 +277,8 @@ DisplacementFieldTransform::ComputeJacobianWit for (unsigned int row = 0; row < VDimension; ++row) { - FixedArray localComponentGrad(jacobian[row]); - FixedArray physicalComponentGrad = + const FixedArray localComponentGrad(jacobian[row]); + FixedArray physicalComponentGrad = m_DisplacementField->TransformLocalVectorToPhysicalVector(localComponentGrad); jacobian.set_row(row, physicalComponentGrad.data()); jacobian(row, row) += 1.; @@ -370,25 +370,25 @@ DisplacementFieldTransform::VerifyFixedParamet // Check to see if the candidate inverse displacement field has the // same fixed parameters as the displacement field. - SizeType inverseFieldSize = this->m_InverseDisplacementField->GetLargestPossibleRegion().GetSize(); - PointType inverseFieldOrigin = this->m_InverseDisplacementField->GetOrigin(); - SpacingType inverseFieldSpacing = this->m_InverseDisplacementField->GetSpacing(); - DirectionType inverseFieldDirection = this->m_InverseDisplacementField->GetDirection(); + const SizeType inverseFieldSize = this->m_InverseDisplacementField->GetLargestPossibleRegion().GetSize(); + PointType inverseFieldOrigin = this->m_InverseDisplacementField->GetOrigin(); + SpacingType inverseFieldSpacing = this->m_InverseDisplacementField->GetSpacing(); + DirectionType inverseFieldDirection = this->m_InverseDisplacementField->GetDirection(); - SizeType fieldSize = this->m_DisplacementField->GetLargestPossibleRegion().GetSize(); - PointType fieldOrigin = this->m_DisplacementField->GetOrigin(); - SpacingType fieldSpacing = this->m_DisplacementField->GetSpacing(); - DirectionType fieldDirection = this->m_DisplacementField->GetDirection(); + const SizeType fieldSize = this->m_DisplacementField->GetLargestPossibleRegion().GetSize(); + PointType fieldOrigin = this->m_DisplacementField->GetOrigin(); + SpacingType fieldSpacing = this->m_DisplacementField->GetSpacing(); + DirectionType fieldDirection = this->m_DisplacementField->GetDirection(); // Tolerance for origin and spacing depends on the size of pixel // tolerance for directions a fraction of the unit cube. const double coordinateTolerance = m_CoordinateTolerance * fieldSpacing[0]; const double directionTolerance = m_DirectionTolerance; - std::ostringstream sizeString; - std::ostringstream originString; - std::ostringstream spacingString; - std::ostringstream directionString; + std::ostringstream sizeString; + std::ostringstream originString; + const std::ostringstream spacingString; + const std::ostringstream directionString; bool unequalSizes = false; bool unequalOrigins = false; diff --git a/Modules/Filtering/DisplacementField/include/itkExponentialDisplacementFieldImageFilter.hxx b/Modules/Filtering/DisplacementField/include/itkExponentialDisplacementFieldImageFilter.hxx index 60d4319e74d..69755f853fa 100644 --- a/Modules/Filtering/DisplacementField/include/itkExponentialDisplacementFieldImageFilter.hxx +++ b/Modules/Filtering/DisplacementField/include/itkExponentialDisplacementFieldImageFilter.hxx @@ -36,7 +36,7 @@ ExponentialDisplacementFieldImageFilter::ExponentialD m_Caster = CasterType::New(); m_Warper = VectorWarperType::New(); - FieldInterpolatorPointer VectorInterpolator = FieldInterpolatorType::New(); + const FieldInterpolatorPointer VectorInterpolator = FieldInterpolatorType::New(); m_Warper->SetInterpolator(VectorInterpolator); m_Adder = AdderType::New(); @@ -68,7 +68,7 @@ ExponentialDisplacementFieldImageFilter::GenerateData { itkDebugMacro("Actually executing"); - InputImageConstPointer inputPtr = this->GetInput(); + const InputImageConstPointer inputPtr = this->GetInput(); unsigned int numiter = 0; @@ -96,7 +96,7 @@ ExponentialDisplacementFieldImageFilter::GenerateData for (InputIt.GoToBegin(); !InputIt.IsAtEnd(); ++InputIt) { - InputPixelRealValueType norm2 = InputIt.Get().GetSquaredNorm(); + const InputPixelRealValueType norm2 = InputIt.Get().GetSquaredNorm(); if (norm2 > maxnorm2) { maxnorm2 = norm2; @@ -107,8 +107,8 @@ ExponentialDisplacementFieldImageFilter::GenerateData maxnorm2 /= itk::Math::sqr(minpixelspacing); // Protect against maxnorm2 being zero. - InputPixelRealValueType numiterfloat = (maxnorm2 > 0) ? 2.0 + 0.5 * std::log(maxnorm2) / itk::Math::ln2 - : itk::NumericTraits::min(); + const InputPixelRealValueType numiterfloat = (maxnorm2 > 0) ? 2.0 + 0.5 * std::log(maxnorm2) / itk::Math::ln2 + : itk::NumericTraits::min(); if (numiterfloat >= 0.0) { @@ -190,7 +190,7 @@ ExponentialDisplacementFieldImageFilter::GenerateData m_Warper->Update(); - OutputImagePointer warpedIm = m_Warper->GetOutput(); + const OutputImagePointer warpedIm = m_Warper->GetOutput(); warpedIm->DisconnectPipeline(); // Remember we chose to use an inplace adder diff --git a/Modules/Filtering/DisplacementField/include/itkGaussianExponentialDiffeomorphicTransform.hxx b/Modules/Filtering/DisplacementField/include/itkGaussianExponentialDiffeomorphicTransform.hxx index 206d6929d16..2253aef2b2b 100644 --- a/Modules/Filtering/DisplacementField/include/itkGaussianExponentialDiffeomorphicTransform.hxx +++ b/Modules/Filtering/DisplacementField/include/itkGaussianExponentialDiffeomorphicTransform.hxx @@ -49,7 +49,7 @@ GaussianExponentialDiffeomorphicTransform::Upd smoothUpdateField = false; } - ConstantVelocityFieldPointer velocityField = this->GetModifiableConstantVelocityField(); + const ConstantVelocityFieldPointer velocityField = this->GetModifiableConstantVelocityField(); if (!velocityField) { itkExceptionMacro("The velocity field has not been set."); @@ -79,7 +79,7 @@ GaussianExponentialDiffeomorphicTransform::Upd { itkDebugMacro("Smoothing the update field."); - ConstantVelocityFieldPointer updateSmoothField = + const ConstantVelocityFieldPointer updateSmoothField = this->GaussianSmoothConstantVelocityField(updateField, this->m_GaussianSmoothingVarianceForTheUpdateField); updateField = updateSmoothField; @@ -98,7 +98,7 @@ GaussianExponentialDiffeomorphicTransform::Upd adder->SetInput1(velocityField); adder->SetInput2(multiplier->GetOutput()); - ConstantVelocityFieldPointer updatedVelocityField = adder->GetOutput(); + const ConstantVelocityFieldPointer updatedVelocityField = adder->GetOutput(); updatedVelocityField->Update(); updatedVelocityField->DisconnectPipeline(); @@ -119,7 +119,7 @@ GaussianExponentialDiffeomorphicTransform::Upd // The update field is the velocity field but since it's constant // we smooth it using the parent class smoothing functionality - ConstantVelocityFieldPointer velocitySmoothField = this->GaussianSmoothConstantVelocityField( + const ConstantVelocityFieldPointer velocitySmoothField = this->GaussianSmoothConstantVelocityField( updatedVelocityField, this->m_GaussianSmoothingVarianceForTheConstantVelocityField); this->SetConstantVelocityField(velocitySmoothField); @@ -188,7 +188,7 @@ GaussianExponentialDiffeomorphicTransform::Gau { weight1 = 1.0 - 1.0 * (variance / 0.5); } - ScalarType weight2 = 1.0 - weight1; + const ScalarType weight2 = 1.0 - weight1; const typename ConstantVelocityFieldType::RegionType region = field->GetLargestPossibleRegion(); const typename ConstantVelocityFieldType::SizeType size = region.GetSize(); diff --git a/Modules/Filtering/DisplacementField/include/itkGaussianSmoothingOnUpdateDisplacementFieldTransform.hxx b/Modules/Filtering/DisplacementField/include/itkGaussianSmoothingOnUpdateDisplacementFieldTransform.hxx index f10ff333fe8..16e62513ce5 100644 --- a/Modules/Filtering/DisplacementField/include/itkGaussianSmoothingOnUpdateDisplacementFieldTransform.hxx +++ b/Modules/Filtering/DisplacementField/include/itkGaussianSmoothingOnUpdateDisplacementFieldTransform.hxx @@ -45,7 +45,7 @@ GaussianSmoothingOnUpdateDisplacementFieldTransformGetModifiableDisplacementField(); + const DisplacementFieldPointer displacementField = this->GetModifiableDisplacementField(); const typename DisplacementFieldType::RegionType & bufferedRegion = displacementField->GetBufferedRegion(); const SizeValueType numberOfPixels = bufferedRegion.GetNumberOfPixels(); @@ -76,11 +76,11 @@ GaussianSmoothingOnUpdateDisplacementFieldTransformSetSpacing(displacementField->GetSpacing()); importer->SetDirection(displacementField->GetDirection()); - DisplacementFieldPointer updateField = importer->GetOutput(); + const DisplacementFieldPointer updateField = importer->GetOutput(); updateField->Update(); updateField->DisconnectPipeline(); - DisplacementFieldPointer smoothedField = + const DisplacementFieldPointer smoothedField = this->GaussianSmoothDisplacementField(updateField, this->m_GaussianSmoothingVarianceForTheUpdateField); ImageAlgorithm::Copy( @@ -113,11 +113,11 @@ GaussianSmoothingOnUpdateDisplacementFieldTransformSetSpacing(displacementField->GetSpacing()); importer->SetDirection(displacementField->GetDirection()); - DisplacementFieldPointer totalField = importer->GetOutput(); + const DisplacementFieldPointer totalField = importer->GetOutput(); totalField->Update(); totalField->DisconnectPipeline(); - DisplacementFieldPointer totalSmoothField = + const DisplacementFieldPointer totalSmoothField = this->GaussianSmoothDisplacementField(totalField, this->m_GaussianSmoothingVarianceForTheTotalField); ImageAlgorithm::Copy( @@ -181,7 +181,7 @@ GaussianSmoothingOnUpdateDisplacementFieldTransformGetLargestPossibleRegion(); const typename DisplacementFieldType::SizeType size = region.GetSize(); @@ -222,7 +222,7 @@ GaussianSmoothingOnUpdateDisplacementFieldTransform(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Filtering/DisplacementField/include/itkGaussianSmoothingOnUpdateTimeVaryingVelocityFieldTransform.hxx b/Modules/Filtering/DisplacementField/include/itkGaussianSmoothingOnUpdateTimeVaryingVelocityFieldTransform.hxx index 43ab1747737..6fa34f78725 100644 --- a/Modules/Filtering/DisplacementField/include/itkGaussianSmoothingOnUpdateTimeVaryingVelocityFieldTransform.hxx +++ b/Modules/Filtering/DisplacementField/include/itkGaussianSmoothingOnUpdateTimeVaryingVelocityFieldTransform.hxx @@ -45,7 +45,7 @@ GaussianSmoothingOnUpdateTimeVaryingVelocityFieldTransformGetModifiableVelocityField(); + const TimeVaryingVelocityFieldPointer velocityField = this->GetModifiableVelocityField(); const typename VelocityFieldType::RegionType & bufferedRegion = velocityField->GetBufferedRegion(); const SizeValueType numberOfPixels = bufferedRegion.GetNumberOfPixels(); @@ -77,11 +77,11 @@ GaussianSmoothingOnUpdateTimeVaryingVelocityFieldTransformSetSpacing(velocityField->GetSpacing()); importer->SetDirection(velocityField->GetDirection()); - TimeVaryingVelocityFieldPointer updateField = importer->GetOutput(); + const TimeVaryingVelocityFieldPointer updateField = importer->GetOutput(); updateField->Update(); updateField->DisconnectPipeline(); - TimeVaryingVelocityFieldPointer updateSmoothField = + const TimeVaryingVelocityFieldPointer updateSmoothField = this->GaussianSmoothTimeVaryingVelocityField(updateField, this->m_GaussianSpatialSmoothingVarianceForTheUpdateField, this->m_GaussianTemporalSmoothingVarianceForTheUpdateField); @@ -117,11 +117,11 @@ GaussianSmoothingOnUpdateTimeVaryingVelocityFieldTransformSetSpacing(velocityField->GetSpacing()); importer->SetDirection(velocityField->GetDirection()); - TimeVaryingVelocityFieldPointer totalField = importer->GetOutput(); + const TimeVaryingVelocityFieldPointer totalField = importer->GetOutput(); totalField->Update(); totalField->DisconnectPipeline(); - TimeVaryingVelocityFieldPointer totalSmoothField = + const TimeVaryingVelocityFieldPointer totalSmoothField = this->GaussianSmoothTimeVaryingVelocityField(totalField, this->m_GaussianSpatialSmoothingVarianceForTheTotalField, this->m_GaussianTemporalSmoothingVarianceForTheTotalField); @@ -194,7 +194,7 @@ GaussianSmoothingOnUpdateTimeVaryingVelocityFieldTransform::PrepareKernelBas // Source contains points with physical coordinates of the // destination displacement fields (the inverse field) - LandmarkContainerPointer source = LandmarkContainer::New(); + const LandmarkContainerPointer source = LandmarkContainer::New(); // Target contains vectors (stored as points) indicating // displacement in the inverse direction. - LandmarkContainerPointer target = LandmarkContainer::New(); + const LandmarkContainerPointer target = LandmarkContainer::New(); using ResamplerType = itk::ResampleImageFilter; @@ -124,7 +124,7 @@ InverseDisplacementFieldImageFilter::PrepareKernelBas using InputRegionType = typename InputImageType::RegionType; using InputSizeType = typename InputImageType::SizeType; - InputRegionType region = inputImage->GetLargestPossibleRegion(); + const InputRegionType region = inputImage->GetLargestPossibleRegion(); InputSizeType size = region.GetSize(); @@ -215,7 +215,7 @@ InverseDisplacementFieldImageFilter::GenerateData() // Create an iterator that will walk the output region for this thread. using OutputIterator = ImageRegionIteratorWithIndex; - OutputImageRegionType region = outputPtr->GetRequestedRegion(); + const OutputImageRegionType region = outputPtr->GetRequestedRegion(); // Define a few indices that will be used to translate from an input pixel // to an output pixel @@ -271,7 +271,7 @@ InverseDisplacementFieldImageFilter::GenerateInputReq } // get pointers to the input and output - InputImagePointer inputPtr = const_cast(this->GetInput()); + const InputImagePointer inputPtr = const_cast(this->GetInput()); // Request the entire input image const InputImageRegionType inputRegion = inputPtr->GetLargestPossibleRegion(); @@ -289,7 +289,7 @@ InverseDisplacementFieldImageFilter::GenerateOutputIn Superclass::GenerateOutputInformation(); // get pointers to the input and output - OutputImagePointer outputPtr = this->GetOutput(); + const OutputImagePointer outputPtr = this->GetOutput(); if (!outputPtr) { return; diff --git a/Modules/Filtering/DisplacementField/include/itkInvertDisplacementFieldImageFilter.hxx b/Modules/Filtering/DisplacementField/include/itkInvertDisplacementFieldImageFilter.hxx index f3a34b63f7a..fdaadae6228 100644 --- a/Modules/Filtering/DisplacementField/include/itkInvertDisplacementFieldImageFilter.hxx +++ b/Modules/Filtering/DisplacementField/include/itkInvertDisplacementFieldImageFilter.hxx @@ -72,7 +72,7 @@ InvertDisplacementFieldImageFilter::GenerateData() constexpr VectorType zeroVector{}; - typename DisplacementFieldType::ConstPointer displacementField = this->GetInput(); + const typename DisplacementFieldType::ConstPointer displacementField = this->GetInput(); typename InverseDisplacementFieldType::Pointer inverseDisplacementField; @@ -102,7 +102,7 @@ InvertDisplacementFieldImageFilter::GenerateData() this->m_ScaledNormImage->SetRegions(displacementField->GetRequestedRegion()); this->m_ScaledNormImage->AllocateInitialized(); - SizeValueType numberOfPixelsInRegion = (displacementField->GetRequestedRegion()).GetNumberOfPixels(); + const SizeValueType numberOfPixelsInRegion = (displacementField->GetRequestedRegion()).GetNumberOfPixels(); this->m_MaxErrorNorm = NumericTraits::max(); this->m_MeanErrorNorm = NumericTraits::max(); unsigned int iteration = 0; @@ -183,8 +183,8 @@ InvertDisplacementFieldImageFilter::DynamicThreadedGe for (ItI.GoToBegin(), ItE.GoToBegin(), ItS.GoToBegin(); !ItI.IsAtEnd(); ++ItI, ++ItE, ++ItS) { - VectorType update = ItE.Get(); - RealType scaledNorm = ItS.Get(); + VectorType update = ItE.Get(); + const RealType scaledNorm = ItS.Get(); if (scaledNorm > this->m_Epsilon * this->m_MaxErrorNorm) { diff --git a/Modules/Filtering/DisplacementField/include/itkIterativeInverseDisplacementFieldImageFilter.hxx b/Modules/Filtering/DisplacementField/include/itkIterativeInverseDisplacementFieldImageFilter.hxx index aeb5f6187fa..0851f4b85fb 100644 --- a/Modules/Filtering/DisplacementField/include/itkIterativeInverseDisplacementFieldImageFilter.hxx +++ b/Modules/Filtering/DisplacementField/include/itkIterativeInverseDisplacementFieldImageFilter.hxx @@ -43,8 +43,8 @@ IterativeInverseDisplacementFieldImageFilter::Generat time.Start(); // time measurement - InputImageConstPointer inputPtr = this->GetInput(0); - OutputImagePointer outputPtr = this->GetOutput(0); + const InputImageConstPointer inputPtr = this->GetInput(0); + const OutputImagePointer outputPtr = this->GetOutput(0); // some checks if (inputPtr.IsNull()) @@ -54,7 +54,7 @@ IterativeInverseDisplacementFieldImageFilter::Generat // calculate a first guess // (calculate negative displacement field and apply it to itself) - InputImagePointer negField = InputImageType::New(); + const InputImagePointer negField = InputImageType::New(); negField->SetRegions(inputPtr->GetLargestPossibleRegion()); negField->SetOrigin(inputPtr->GetOrigin()); negField->SetSpacing(inputPtr->GetSpacing()); @@ -95,19 +95,19 @@ IterativeInverseDisplacementFieldImageFilter::Generat else { // calculate the inverted field - double spacing = inputPtr->GetSpacing()[0]; + const double spacing = inputPtr->GetSpacing()[0]; - InputImageRegionType region = inputPtr->GetLargestPossibleRegion(); - unsigned int numberOfPoints = 1; + const InputImageRegionType region = inputPtr->GetLargestPossibleRegion(); + unsigned int numberOfPoints = 1; for (unsigned int i = 0; i < ImageDimension; ++i) { numberOfPoints *= region.GetSize()[i]; } - ProgressReporter progress(this, 0, inputPtr->GetLargestPossibleRegion().GetNumberOfPixels()); - OutputIterator OutputIt(outputPtr, outputPtr->GetRequestedRegion()); - FieldInterpolatorPointer inputFieldInterpolator = FieldInterpolatorType::New(); + ProgressReporter progress(this, 0, inputPtr->GetLargestPossibleRegion().GetNumberOfPixels()); + OutputIterator OutputIt(outputPtr, outputPtr->GetRequestedRegion()); + const FieldInterpolatorPointer inputFieldInterpolator = FieldInterpolatorType::New(); inputFieldInterpolator->SetInputImage(inputPtr); double smallestError = 0; @@ -116,8 +116,8 @@ IterativeInverseDisplacementFieldImageFilter::Generat while (!OutputIt.IsAtEnd()) { // get the output image index - OutputImageIndexType index = OutputIt.GetIndex(); - OutputImagePointType originalPoint; + const OutputImageIndexType index = OutputIt.GetIndex(); + OutputImagePointType originalPoint; outputPtr->TransformIndexToPhysicalPoint(index, originalPoint); int stillSamePoint = 0; diff --git a/Modules/Filtering/DisplacementField/include/itkLandmarkDisplacementFieldSource.hxx b/Modules/Filtering/DisplacementField/include/itkLandmarkDisplacementFieldSource.hxx index f2019d7ab40..c50843dc37d 100644 --- a/Modules/Filtering/DisplacementField/include/itkLandmarkDisplacementFieldSource.hxx +++ b/Modules/Filtering/DisplacementField/include/itkLandmarkDisplacementFieldSource.hxx @@ -119,7 +119,7 @@ LandmarkDisplacementFieldSource::GenerateData() // Create an iterator that will walk the output region for this thread. using OutputIterator = ImageRegionIteratorWithIndex; - OutputImageRegionType region = outputPtr->GetRequestedRegion(); + const OutputImageRegionType region = outputPtr->GetRequestedRegion(); // Define a few indices that will be used to translate from an input pixel // to an output pixel @@ -165,7 +165,7 @@ LandmarkDisplacementFieldSource::GenerateOutputInformation() Superclass::GenerateOutputInformation(); // get pointers to the input and output - OutputImagePointer outputPtr = this->GetOutput(); + const OutputImagePointer outputPtr = this->GetOutput(); if (!outputPtr) { return; diff --git a/Modules/Filtering/DisplacementField/include/itkTimeVaryingBSplineVelocityFieldTransform.hxx b/Modules/Filtering/DisplacementField/include/itkTimeVaryingBSplineVelocityFieldTransform.hxx index 72f048c21ac..f6a2e972a81 100644 --- a/Modules/Filtering/DisplacementField/include/itkTimeVaryingBSplineVelocityFieldTransform.hxx +++ b/Modules/Filtering/DisplacementField/include/itkTimeVaryingBSplineVelocityFieldTransform.hxx @@ -68,7 +68,7 @@ TimeVaryingBSplineVelocityFieldTransform::Inte bspliner->SetCloseDimension(closeDimensions); bspliner->Update(); - typename VelocityFieldType::Pointer bsplinerOutput = bspliner->GetOutput(); + const typename VelocityFieldType::Pointer bsplinerOutput = bspliner->GetOutput(); bsplinerOutput->DisconnectPipeline(); using IntegratorType = TimeVaryingVelocityFieldIntegrationImageFilter; @@ -86,7 +86,7 @@ TimeVaryingBSplineVelocityFieldTransform::Inte integrator->SetNumberOfIntegrationSteps(this->GetNumberOfIntegrationSteps()); integrator->Update(); - typename DisplacementFieldType::Pointer displacementField = integrator->GetOutput(); + const typename DisplacementFieldType::Pointer displacementField = integrator->GetOutput(); displacementField->DisconnectPipeline(); this->SetDisplacementField(displacementField); @@ -105,7 +105,7 @@ TimeVaryingBSplineVelocityFieldTransform::Inte inverseIntegrator->SetNumberOfIntegrationSteps(this->GetNumberOfIntegrationSteps()); inverseIntegrator->Update(); - typename DisplacementFieldType::Pointer inverseDisplacementField = inverseIntegrator->GetOutput(); + const typename DisplacementFieldType::Pointer inverseDisplacementField = inverseIntegrator->GetOutput(); inverseDisplacementField->DisconnectPipeline(); this->SetInverseDisplacementField(inverseDisplacementField); @@ -117,7 +117,7 @@ TimeVaryingBSplineVelocityFieldTransform::Upda const DerivativeType & update, ScalarType factor) { - NumberOfParametersType numberOfParameters = this->GetNumberOfParameters(); + const NumberOfParametersType numberOfParameters = this->GetNumberOfParameters(); if (update.Size() != numberOfParameters) { @@ -147,7 +147,7 @@ TimeVaryingBSplineVelocityFieldTransform::Upda adder->SetInput1(this->GetVelocityField()); adder->SetInput2(importer->GetOutput()); - typename VelocityFieldType::Pointer totalFieldLattice = adder->GetOutput(); + const typename VelocityFieldType::Pointer totalFieldLattice = adder->GetOutput(); totalFieldLattice->Update(); this->SetTimeVaryingVelocityFieldControlPointLattice(totalFieldLattice); diff --git a/Modules/Filtering/DisplacementField/include/itkTimeVaryingVelocityFieldIntegrationImageFilter.hxx b/Modules/Filtering/DisplacementField/include/itkTimeVaryingVelocityFieldIntegrationImageFilter.hxx index b6413581603..a5a74c30ae2 100644 --- a/Modules/Filtering/DisplacementField/include/itkTimeVaryingVelocityFieldIntegrationImageFilter.hxx +++ b/Modules/Filtering/DisplacementField/include/itkTimeVaryingVelocityFieldIntegrationImageFilter.hxx @@ -141,13 +141,13 @@ TimeVaryingVelocityFieldIntegrationImageFilterGetInput(); - typename DisplacementFieldType::Pointer outputField = this->GetOutput(); + const typename DisplacementFieldType::Pointer outputField = this->GetOutput(); for (ImageRegionIteratorWithIndex It(outputField, region); !It.IsAtEnd(); ++It) { PointType point; outputField->TransformIndexToPhysicalPoint(It.GetIndex(), point); - VectorType displacement = this->IntegrateVelocityAtPoint(point, inputField); + const VectorType displacement = this->IntegrateVelocityAtPoint(point, inputField); It.Set(displacement); } } @@ -161,7 +161,7 @@ TimeVaryingVelocityFieldIntegrationImageFilterGetOrigin(); using RegionType = typename TimeVaryingVelocityFieldType::RegionType; - RegionType region = inputField->GetLargestPossibleRegion(); + const RegionType region = inputField->GetLargestPossibleRegion(); typename RegionType::IndexType lastIndex = region.GetIndex(); typename RegionType::SizeType size = region.GetSize(); diff --git a/Modules/Filtering/DisplacementField/include/itkTimeVaryingVelocityFieldTransform.hxx b/Modules/Filtering/DisplacementField/include/itkTimeVaryingVelocityFieldTransform.hxx index 91f94eb58b2..be11c0bd496 100644 --- a/Modules/Filtering/DisplacementField/include/itkTimeVaryingVelocityFieldTransform.hxx +++ b/Modules/Filtering/DisplacementField/include/itkTimeVaryingVelocityFieldTransform.hxx @@ -45,7 +45,7 @@ TimeVaryingVelocityFieldTransform::IntegrateVe integrator->SetNumberOfIntegrationSteps(this->GetNumberOfIntegrationSteps()); integrator->Update(); - typename DisplacementFieldType::Pointer displacementField = integrator->GetOutput(); + const typename DisplacementFieldType::Pointer displacementField = integrator->GetOutput(); displacementField->DisconnectPipeline(); this->SetDisplacementField(displacementField); @@ -63,7 +63,7 @@ TimeVaryingVelocityFieldTransform::IntegrateVe inverseIntegrator->SetNumberOfIntegrationSteps(this->GetNumberOfIntegrationSteps()); inverseIntegrator->Update(); - typename DisplacementFieldType::Pointer inverseDisplacementField = inverseIntegrator->GetOutput(); + const typename DisplacementFieldType::Pointer inverseDisplacementField = inverseIntegrator->GetOutput(); inverseDisplacementField->DisconnectPipeline(); this->SetInverseDisplacementField(inverseDisplacementField); diff --git a/Modules/Filtering/DisplacementField/include/itkVelocityFieldTransform.hxx b/Modules/Filtering/DisplacementField/include/itkVelocityFieldTransform.hxx index 2038aad7bfd..107b19883e6 100644 --- a/Modules/Filtering/DisplacementField/include/itkVelocityFieldTransform.hxx +++ b/Modules/Filtering/DisplacementField/include/itkVelocityFieldTransform.hxx @@ -249,8 +249,8 @@ typename LightObject::Pointer VelocityFieldTransform::InternalClone() const { // create a new instance - LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + LightObject::Pointer loPtr = Superclass::InternalClone(); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); @@ -262,15 +262,15 @@ VelocityFieldTransform::InternalClone() const rval->SetParameters(this->GetParameters()); // need the displacement field but GetDisplacementField is non-const. - auto * nonConstThis = const_cast(this); - typename DisplacementFieldType::ConstPointer dispField = nonConstThis->GetDisplacementField(); - typename DisplacementFieldType::Pointer cloneDispField = this->CopyDisplacementField(dispField); + auto * nonConstThis = const_cast(this); + const typename DisplacementFieldType::ConstPointer dispField = nonConstThis->GetDisplacementField(); + const typename DisplacementFieldType::Pointer cloneDispField = this->CopyDisplacementField(dispField); rval->GetModifiableInterpolator()->SetInputImage(cloneDispField); rval->SetDisplacementField(cloneDispField); // now do the inverse -- it actually gets created as a side effect? - typename DisplacementFieldType::ConstPointer invDispField = nonConstThis->GetInverseDisplacementField(); - typename DisplacementFieldType::Pointer cloneInvDispField = this->CopyDisplacementField(invDispField); + const typename DisplacementFieldType::ConstPointer invDispField = nonConstThis->GetInverseDisplacementField(); + const typename DisplacementFieldType::Pointer cloneInvDispField = this->CopyDisplacementField(invDispField); rval->SetInverseDisplacementField(cloneInvDispField); // copy the VelocityField @@ -290,7 +290,7 @@ VelocityFieldTransform::InternalClone() const rval->SetNumberOfIntegrationSteps(this->GetNumberOfIntegrationSteps()); // copy the interpolator - VelocityFieldInterpolatorPointer newInterp = + const VelocityFieldInterpolatorPointer newInterp = dynamic_cast(this->m_VelocityFieldInterpolator->CreateAnother().GetPointer()); if (newInterp.IsNull()) { diff --git a/Modules/Filtering/DisplacementField/test/itkBSplineExponentialDiffeomorphicTransformTest.cxx b/Modules/Filtering/DisplacementField/test/itkBSplineExponentialDiffeomorphicTransformTest.cxx index d21ae0c20fd..72fc623979e 100644 --- a/Modules/Filtering/DisplacementField/test/itkBSplineExponentialDiffeomorphicTransformTest.cxx +++ b/Modules/Filtering/DisplacementField/test/itkBSplineExponentialDiffeomorphicTransformTest.cxx @@ -48,7 +48,7 @@ itkBSplineExponentialDiffeomorphicTransformTest(int, char *[]) FieldType::SizeType size; FieldType::IndexType start; FieldType::RegionType region; - int dimLength = 20; + const int dimLength = 20; size.Fill(dimLength); start.Fill(0); region.SetSize(size); @@ -56,7 +56,7 @@ itkBSplineExponentialDiffeomorphicTransformTest(int, char *[]) field->SetRegions(region); field->Allocate(); - DisplacementTransformType::OutputVectorType zeroVector{}; + const DisplacementTransformType::OutputVectorType zeroVector{}; field->FillBuffer(zeroVector); displacementTransform->SetConstantVelocityField(field); @@ -64,12 +64,12 @@ itkBSplineExponentialDiffeomorphicTransformTest(int, char *[]) /* Test SmoothDisplacementFieldBSpline */ std::cout << "Test SmoothDisplacementFieldBSpline" << std::endl; - DisplacementTransformType::ParametersType params; - DisplacementTransformType::ParametersType paramsFill(displacementTransform->GetNumberOfParameters()); - DisplacementTransformType::ParametersValueType paramsFillValue = 0.0; + DisplacementTransformType::ParametersType params; + DisplacementTransformType::ParametersType paramsFill(displacementTransform->GetNumberOfParameters()); + const DisplacementTransformType::ParametersValueType paramsFillValue = 0.0; paramsFill.Fill(paramsFillValue); // Add an outlier to visually see that some smoothing is taking place. - unsigned int outlier = dimLength * dimensions * 4 + dimLength * dimensions / 2; + const unsigned int outlier = dimLength * dimensions * 4 + dimLength * dimensions / 2; paramsFill(outlier) = 99.0; paramsFill(outlier + 1) = 99.0; @@ -80,7 +80,8 @@ itkBSplineExponentialDiffeomorphicTransformTest(int, char *[]) displacementTransform->SetSplineOrder(3); displacementTransform->SetParameters(paramsFill); - DisplacementTransformType::NumberOfParametersType numberOfParameters = displacementTransform->GetNumberOfParameters(); + const DisplacementTransformType::NumberOfParametersType numberOfParameters = + displacementTransform->GetNumberOfParameters(); DisplacementTransformType::DerivativeType update1(numberOfParameters); update1.Fill(1.2); @@ -126,7 +127,7 @@ itkBSplineExponentialDiffeomorphicTransformTest(int, char *[]) { for (int j = -2; j < 3; ++j) { - unsigned int index = outlier + static_cast(i * (int)(dimLength * dimensions) + j); + const unsigned int index = outlier + static_cast(i * (int)(dimLength * dimensions) + j); std::cout << params(index) << ' '; if (itk::Math::AlmostEquals(params(index), paramsFillValue)) { @@ -199,7 +200,7 @@ itkBSplineExponentialDiffeomorphicTransformTest(int, char *[]) { for (int j = -2; j < 3; ++j) { - unsigned int index = outlier + static_cast(i * (int)(dimLength * dimensions) + j); + const unsigned int index = outlier + static_cast(i * (int)(dimLength * dimensions) + j); std::cout << params(index) << ' '; if (itk::Math::AlmostEquals(params(index), paramsFillValue)) { diff --git a/Modules/Filtering/DisplacementField/test/itkBSplineSmoothingOnUpdateDisplacementFieldTransformTest.cxx b/Modules/Filtering/DisplacementField/test/itkBSplineSmoothingOnUpdateDisplacementFieldTransformTest.cxx index af0b906aa34..d6607d130fb 100644 --- a/Modules/Filtering/DisplacementField/test/itkBSplineSmoothingOnUpdateDisplacementFieldTransformTest.cxx +++ b/Modules/Filtering/DisplacementField/test/itkBSplineSmoothingOnUpdateDisplacementFieldTransformTest.cxx @@ -42,13 +42,13 @@ itkBSplineSmoothingOnUpdateDisplacementFieldTransformTest(int, char *[]) displacementTransform, BSplineSmoothingOnUpdateDisplacementFieldTransform, DisplacementFieldTransform); - typename DisplacementTransformType::ArrayType::ValueType controlPointsUpdateFieldVal = 4; - auto controlPointsUpdateField = + const typename DisplacementTransformType::ArrayType::ValueType controlPointsUpdateFieldVal = 4; + auto controlPointsUpdateField = itk::MakeFilled(controlPointsUpdateFieldVal); ITK_TEST_SET_GET_VALUE(controlPointsUpdateField, displacementTransform->GetNumberOfControlPointsForTheUpdateField()); - typename DisplacementTransformType::ArrayType::ValueType controlPointsTotalFieldVal = 0; - auto controlPointsTotalField = + const typename DisplacementTransformType::ArrayType::ValueType controlPointsTotalFieldVal = 0; + auto controlPointsTotalField = itk::MakeFilled(controlPointsTotalFieldVal); ITK_TEST_SET_GET_VALUE(controlPointsTotalField, displacementTransform->GetNumberOfControlPointsForTheTotalField()); @@ -58,7 +58,7 @@ itkBSplineSmoothingOnUpdateDisplacementFieldTransformTest(int, char *[]) FieldType::SizeType size; FieldType::IndexType start; FieldType::RegionType region; - int dimLength = 20; + const int dimLength = 20; size.Fill(dimLength); start.Fill(0); region.SetSize(size); @@ -66,19 +66,19 @@ itkBSplineSmoothingOnUpdateDisplacementFieldTransformTest(int, char *[]) field->SetRegions(region); field->Allocate(); - DisplacementTransformType::OutputVectorType zeroVector{}; + const DisplacementTransformType::OutputVectorType zeroVector{}; field->FillBuffer(zeroVector); displacementTransform->SetDisplacementField(field); /* Test SmoothDisplacementFieldBSpline */ std::cout << "Test SmoothDisplacementFieldBSpline" << std::endl; - DisplacementTransformType::ParametersType params; - DisplacementTransformType::ParametersType paramsFill(displacementTransform->GetNumberOfParameters()); - DisplacementTransformType::ParametersValueType paramsFillValue = 0.0; + DisplacementTransformType::ParametersType params; + DisplacementTransformType::ParametersType paramsFill(displacementTransform->GetNumberOfParameters()); + const DisplacementTransformType::ParametersValueType paramsFillValue = 0.0; paramsFill.Fill(paramsFillValue); // Add an outlier to visually see that some smoothing is taking place. - unsigned int outlier = dimLength * dimensions * 4 + dimLength * dimensions / 2; + const unsigned int outlier = dimLength * dimensions * 4 + dimLength * dimensions / 2; paramsFill(outlier) = 99.0; paramsFill(outlier + 1) = 99.0; @@ -88,7 +88,7 @@ itkBSplineSmoothingOnUpdateDisplacementFieldTransformTest(int, char *[]) auto meshSizeForTotalField = itk::MakeFilled(30); displacementTransform->SetMeshSizeForTheTotalField(meshSizeForTotalField); - typename DisplacementTransformType::SplineOrderType splineOrder = 3; + const typename DisplacementTransformType::SplineOrderType splineOrder = 3; displacementTransform->SetSplineOrder(splineOrder); ITK_TEST_SET_GET_VALUE(splineOrder, displacementTransform->GetSplineOrder()); @@ -97,7 +97,8 @@ itkBSplineSmoothingOnUpdateDisplacementFieldTransformTest(int, char *[]) displacementTransform->SetParameters(paramsFill); - DisplacementTransformType::NumberOfParametersType numberOfParameters = displacementTransform->GetNumberOfParameters(); + const DisplacementTransformType::NumberOfParametersType numberOfParameters = + displacementTransform->GetNumberOfParameters(); DisplacementTransformType::DerivativeType update1(numberOfParameters); update1.Fill(1.2); @@ -143,7 +144,7 @@ itkBSplineSmoothingOnUpdateDisplacementFieldTransformTest(int, char *[]) { for (int j = -2; j < 3; ++j) { - unsigned int index = outlier + static_cast(i * (int)(dimLength * dimensions) + j); + const unsigned int index = outlier + static_cast(i * (int)(dimLength * dimensions) + j); std::cout << params(index) << ' '; if (itk::Math::AlmostEquals(params(index), paramsFillValue)) { @@ -216,7 +217,7 @@ itkBSplineSmoothingOnUpdateDisplacementFieldTransformTest(int, char *[]) { for (int j = -2; j < 3; ++j) { - unsigned int index = outlier + static_cast(i * (int)(dimLength * dimensions) + j); + const unsigned int index = outlier + static_cast(i * (int)(dimLength * dimensions) + j); std::cout << params(index) << ' '; if (itk::Math::AlmostEquals(params(index), paramsFillValue)) { diff --git a/Modules/Filtering/DisplacementField/test/itkDisplacementFieldJacobianDeterminantFilterTest.cxx b/Modules/Filtering/DisplacementField/test/itkDisplacementFieldJacobianDeterminantFilterTest.cxx index 952e100124b..27d19fe4983 100644 --- a/Modules/Filtering/DisplacementField/test/itkDisplacementFieldJacobianDeterminantFilterTest.cxx +++ b/Modules/Filtering/DisplacementField/test/itkDisplacementFieldJacobianDeterminantFilterTest.cxx @@ -40,7 +40,7 @@ TestDisplacementJacobianDeterminantValue() VectorImageType::RegionType region; // NOTE: Making the image size much larger than necessary in order to get // some meaningful time measurements. Simulate a 256x256x256 image. - VectorImageType::SizeType size = { { 4096, 4096 } }; + const VectorImageType::SizeType size = { { 4096, 4096 } }; region.SetSize(size); auto dispacementfield = VectorImageType::New(); @@ -81,7 +81,7 @@ TestDisplacementJacobianDeterminantValue() ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, DisplacementFieldJacobianDeterminantFilter, ImageToImageFilter); - bool useImageSpacing = true; + const bool useImageSpacing = true; #if !defined(ITK_FUTURE_LEGACY_REMOVE) if (useImageSpacing) { @@ -98,14 +98,14 @@ TestDisplacementJacobianDeterminantValue() filter->Update(); - itk::Image::Pointer output = filter->GetOutput(); + const itk::Image::Pointer output = filter->GetOutput(); VectorImageType::IndexType index; index[0] = 1; index[1] = 1; - float jacobianDeterminant = output->GetPixel(index); + const float jacobianDeterminant = output->GetPixel(index); // std::cout << "Output " << output->GetPixel(index) << std::endl; - double epsilon = 1e-13; + const double epsilon = 1e-13; if (itk::Math::abs(jacobianDeterminant - expectedJacobianDeterminant) > epsilon) { std::cerr.precision(static_cast(itk::Math::abs(std::log10(epsilon)))); @@ -130,9 +130,9 @@ itkDisplacementFieldJacobianDeterminantFilterTest(int, char *[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope // scope. - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); - bool ValueTestPassed = TestDisplacementJacobianDeterminantValue(); + const bool ValueTestPassed = TestDisplacementJacobianDeterminantValue(); try { using VectorType = itk::Vector; @@ -159,7 +159,7 @@ itkDisplacementFieldJacobianDeterminantFilterTest(int, char *[]) filter->Print(std::cout); // Run the test again with ImageSpacingOn - bool useImageSpacing = true; + const bool useImageSpacing = true; ITK_TEST_SET_GET_BOOLEAN(filter, UseImageSpacing, useImageSpacing); @@ -167,7 +167,7 @@ itkDisplacementFieldJacobianDeterminantFilterTest(int, char *[]) filter->Print(std::cout); // Run the test again with specified weights - typename FilterType::WeightsType weights{ { { 1.0, 2.0, 3.0 } } }; + const typename FilterType::WeightsType weights{ { { 1.0, 2.0, 3.0 } } }; filter->SetDerivativeWeights(weights); ITK_TEST_SET_GET_VALUE(weights, filter->GetDerivativeWeights()); diff --git a/Modules/Filtering/DisplacementField/test/itkDisplacementFieldToBSplineImageFilterTest.cxx b/Modules/Filtering/DisplacementField/test/itkDisplacementFieldToBSplineImageFilterTest.cxx index 683065414a2..9806d801141 100644 --- a/Modules/Filtering/DisplacementField/test/itkDisplacementFieldToBSplineImageFilterTest.cxx +++ b/Modules/Filtering/DisplacementField/test/itkDisplacementFieldToBSplineImageFilterTest.cxx @@ -102,7 +102,7 @@ itkDisplacementFieldToBSplineImageFilterTest(int, char *[]) bspliner->SetNumberOfControlPoints(numberOfControlPoints); ITK_TEST_SET_GET_VALUE(numberOfControlPoints, bspliner->GetNumberOfControlPoints()); - unsigned int splineOrder = 3; + const unsigned int splineOrder = 3; bspliner->SetSplineOrder(splineOrder); ITK_TEST_SET_GET_VALUE(splineOrder, bspliner->GetSplineOrder()); @@ -118,15 +118,15 @@ itkDisplacementFieldToBSplineImageFilterTest(int, char *[]) ITK_TEST_SET_GET_BOOLEAN(bspliner, EstimateInverse, false); - typename BSplineFilterType::OriginType::ValueType bSplineDomainOriginVal = 0.0; + const typename BSplineFilterType::OriginType::ValueType bSplineDomainOriginVal = 0.0; auto bSplineDomainOrigin = itk::MakeFilled(bSplineDomainOriginVal); ITK_TEST_EXPECT_EQUAL(bSplineDomainOrigin, bspliner->GetBSplineDomainOrigin()); - typename BSplineFilterType::SpacingType::ValueType bSplineDomainSpacingVal = 1.0; + const typename BSplineFilterType::SpacingType::ValueType bSplineDomainSpacingVal = 1.0; auto bSplineDomainSpacing = itk::MakeFilled(bSplineDomainSpacingVal); ITK_TEST_EXPECT_EQUAL(bSplineDomainSpacing, bspliner->GetBSplineDomainSpacing()); - typename BSplineFilterType::SizeType::value_type bSplineDomainSizeVal = 0; + const typename BSplineFilterType::SizeType::value_type bSplineDomainSizeVal = 0; auto bSplineDomainSize = BSplineFilterType::SizeType::Filled(bSplineDomainSizeVal); ITK_TEST_EXPECT_EQUAL(bSplineDomainSize, bspliner->GetBSplineDomainSize()); diff --git a/Modules/Filtering/DisplacementField/test/itkDisplacementFieldTransformCloneTest.cxx b/Modules/Filtering/DisplacementField/test/itkDisplacementFieldTransformCloneTest.cxx index 9132d266a74..55ba9982413 100644 --- a/Modules/Filtering/DisplacementField/test/itkDisplacementFieldTransformCloneTest.cxx +++ b/Modules/Filtering/DisplacementField/test/itkDisplacementFieldTransformCloneTest.cxx @@ -58,7 +58,7 @@ itkDisplacementFieldTransformCloneTest(int, char *[]) FieldType::SizeType size; FieldType::IndexType start; FieldType::RegionType region; - int dimLength = 20; + const int dimLength = 20; size.Fill(dimLength); start.Fill(0); region.SetSize(size); @@ -70,7 +70,7 @@ itkDisplacementFieldTransformCloneTest(int, char *[]) field->FillBuffer(zeroVector); displacementTransform->SetDisplacementField(field); - DisplacementTransformType::Pointer displacementTransformClone = displacementTransform->Clone(); + const DisplacementTransformType::Pointer displacementTransformClone = displacementTransform->Clone(); ITK_EXERCISE_BASIC_OBJECT_METHODS(displacementTransformClone, DisplacementFieldTransform, Transform); @@ -89,8 +89,8 @@ itkDisplacementFieldTransformCloneTest(int, char *[]) return EXIT_FAILURE; } - FieldType::ConstPointer originalField = displacementTransform->GetDisplacementField(); - FieldType::ConstPointer cloneField = displacementTransformClone->GetDisplacementField(); + const FieldType::ConstPointer originalField = displacementTransform->GetDisplacementField(); + const FieldType::ConstPointer cloneField = displacementTransformClone->GetDisplacementField(); itk::ImageRegionConstIterator originalIt(originalField, originalField->GetLargestPossibleRegion()); itk::ImageRegionConstIterator cloneIt(cloneField, cloneField->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/DisplacementField/test/itkDisplacementFieldTransformTest.cxx b/Modules/Filtering/DisplacementField/test/itkDisplacementFieldTransformTest.cxx index bde36b9f4ae..9237d42eadd 100644 --- a/Modules/Filtering/DisplacementField/test/itkDisplacementFieldTransformTest.cxx +++ b/Modules/Filtering/DisplacementField/test/itkDisplacementFieldTransformTest.cxx @@ -187,7 +187,7 @@ itkDisplacementFieldTransformTest(int argc, char * argv[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope. - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); // Create a displacement field transform auto displacementTransform = DisplacementTransformType::New(); @@ -196,21 +196,21 @@ itkDisplacementFieldTransformTest(int argc, char * argv[]) // Test exceptions - DisplacementTransformType::InputVnlVectorType::element_type vectorValue = 1.0; - DisplacementTransformType::InputVnlVectorType vector; + const DisplacementTransformType::InputVnlVectorType::element_type vectorValue = 1.0; + DisplacementTransformType::InputVnlVectorType vector; vector.fill(vectorValue); ITK_TRY_EXPECT_EXCEPTION(displacementTransform->TransformVector(vector)); - DisplacementTransformType::DisplacementFieldType::Pointer displacementField = + const DisplacementTransformType::DisplacementFieldType::Pointer displacementField = DisplacementTransformType::DisplacementFieldType::New(); displacementTransform->SetDisplacementField(displacementField); ITK_TEST_SET_GET_VALUE(displacementField, displacementTransform->GetDisplacementField()); - DisplacementTransformType::VectorImageDisplacementFieldType::Pointer vectorImageDisplacementField = + const DisplacementTransformType::VectorImageDisplacementFieldType::Pointer vectorImageDisplacementField = DisplacementTransformType::VectorImageDisplacementFieldType::New(); displacementTransform->SetDisplacementField(vectorImageDisplacementField); - DisplacementTransformType::DisplacementFieldType::Pointer inverseDisplacementField = + const DisplacementTransformType::DisplacementFieldType::Pointer inverseDisplacementField = DisplacementTransformType::DisplacementFieldType::New(); displacementTransform->SetInverseDisplacementField(inverseDisplacementField); ITK_TEST_SET_GET_VALUE(inverseDisplacementField, displacementTransform->GetInverseDisplacementField()); @@ -226,27 +226,27 @@ itkDisplacementFieldTransformTest(int argc, char * argv[]) displacementTransform->SetInverseInterpolator(inverseInterpolator); ITK_TEST_SET_GET_VALUE(inverseInterpolator, displacementTransform->GetInverseInterpolator()); - double coordinateTolerance = std::stod(argv[1]); + const double coordinateTolerance = std::stod(argv[1]); displacementTransform->SetCoordinateTolerance(coordinateTolerance); ITK_TEST_SET_GET_VALUE(coordinateTolerance, displacementTransform->GetCoordinateTolerance()); - double directionTolerance = std::stod(argv[2]); + const double directionTolerance = std::stod(argv[2]); displacementTransform->SetDirectionTolerance(directionTolerance); ITK_TEST_SET_GET_VALUE(directionTolerance, displacementTransform->GetDirectionTolerance()); auto field = FieldType::New(); - int dimLength = 20; - auto size = itk::MakeFilled(dimLength); - FieldType::IndexType start{}; - FieldType::RegionType region; + const int dimLength = 20; + auto size = itk::MakeFilled(dimLength); + const FieldType::IndexType start{}; + FieldType::RegionType region; region.SetSize(size); region.SetIndex(start); field->SetRegions(region); field->Allocate(); - DisplacementTransformType::OutputVectorType zeroVector{}; + const DisplacementTransformType::OutputVectorType zeroVector{}; field->FillBuffer(zeroVector); displacementTransform->SetDisplacementField(field); @@ -259,16 +259,16 @@ itkDisplacementFieldTransformTest(int argc, char * argv[]) displacementTransform->SetFixedParameters(fixedParameters); ITK_TEST_SET_GET_VALUE(fixedParameters, displacementTransform->GetFixedParameters()); - DisplacementFieldType::SizeType size2 = + const DisplacementFieldType::SizeType size2 = displacementTransform->GetDisplacementField()->GetLargestPossibleRegion().GetSize(); - DisplacementFieldType::PointType origin2 = displacementTransform->GetDisplacementField()->GetOrigin(); - DisplacementFieldType::DirectionType direction2 = displacementTransform->GetDisplacementField()->GetDirection(); - DisplacementFieldType::SpacingType spacing2 = displacementTransform->GetDisplacementField()->GetSpacing(); + const DisplacementFieldType::PointType origin2 = displacementTransform->GetDisplacementField()->GetOrigin(); + const DisplacementFieldType::DirectionType direction2 = displacementTransform->GetDisplacementField()->GetDirection(); + const DisplacementFieldType::SpacingType spacing2 = displacementTransform->GetDisplacementField()->GetSpacing(); size = field->GetLargestPossibleRegion().GetSize(); - DisplacementFieldType::PointType origin = field->GetOrigin(); - DisplacementFieldType::DirectionType direction = field->GetDirection(); - DisplacementFieldType::SpacingType spacing = field->GetSpacing(); + const DisplacementFieldType::PointType origin = field->GetOrigin(); + const DisplacementFieldType::DirectionType direction = field->GetDirection(); + const DisplacementFieldType::SpacingType spacing = field->GetSpacing(); ITK_TEST_EXPECT_EQUAL(size, size2); ITK_TEST_EXPECT_EQUAL(origin, origin2); @@ -317,7 +317,7 @@ itkDisplacementFieldTransformTest(int argc, char * argv[]) { FieldType::PointType pt; field->TransformIndexToPhysicalPoint(it.GetIndex(), pt); - FieldType::PointType pt2 = affineTransform->TransformPoint(pt); + const FieldType::PointType pt2 = affineTransform->TransformPoint(pt); FieldType::PointType::VectorType vec = pt2 - pt; FieldType::PixelType v; v[0] = vec[0]; @@ -398,8 +398,8 @@ itkDisplacementFieldTransformTest(int argc, char * argv[]) return EXIT_FAILURE; } - DisplacementTransformType::IndexType testIndex; testIdentity.SetSize(1, 1); // make sure it gets resized properly + const DisplacementTransformType::IndexType testIndex{}; displacementTransform->ComputeJacobianWithRespectToParameters(testIndex, testIdentity); if (!sameArray2D(identity, testIdentity, tolerance)) @@ -413,10 +413,10 @@ itkDisplacementFieldTransformTest(int argc, char * argv[]) // Test transforming of points // // Test a point with non-zero displacement - FieldType::IndexType idx = field->TransformPhysicalPointToIndex(testPoint); - DisplacementTransformType::OutputPointType deformTruth = testPoint + field->GetPixel(idx); + const FieldType::IndexType idx = field->TransformPhysicalPointToIndex(testPoint); + const DisplacementTransformType::OutputPointType deformTruth = testPoint + field->GetPixel(idx); - DisplacementTransformType::OutputPointType deformOutput = displacementTransform->TransformPoint(testPoint); + const DisplacementTransformType::OutputPointType deformOutput = displacementTransform->TransformPoint(testPoint); if (!samePoint(deformOutput, deformTruth)) { @@ -429,8 +429,8 @@ itkDisplacementFieldTransformTest(int argc, char * argv[]) testVector[0] = 0.5; testVector[1] = 0.5; - DisplacementTransformType::OutputVectorType deformVectorTruth = affineTransform->TransformVector(testVector); - DisplacementTransformType::OutputVectorType deformVector = + const DisplacementTransformType::OutputVectorType deformVectorTruth = affineTransform->TransformVector(testVector); + DisplacementTransformType::OutputVectorType deformVector = displacementTransform->TransformVector(testVector, testPoint); tolerance = 1e-4; @@ -448,7 +448,8 @@ itkDisplacementFieldTransformTest(int argc, char * argv[]) DisplacementTransformType::InputVectorPixelType testVVector(DisplacementTransformType::Dimension); testVVector[0] = 0.5; testVVector[1] = 0.5; - DisplacementTransformType::OutputVectorPixelType deformVVectorTruth = affineTransform->TransformVector(testVVector); + const DisplacementTransformType::OutputVectorPixelType deformVVectorTruth = + affineTransform->TransformVector(testVVector); DisplacementTransformType::OutputVectorPixelType deformVVector = displacementTransform->TransformVector(testVVector, testPoint); @@ -468,7 +469,7 @@ itkDisplacementFieldTransformTest(int argc, char * argv[]) testcVector[0] = 0.5; testcVector[1] = 0.5; - DisplacementTransformType::OutputCovariantVectorType deformcVectorTruth = + const DisplacementTransformType::OutputCovariantVectorType deformcVectorTruth = affineTransform->TransformCovariantVector(testcVector); DisplacementTransformType::OutputCovariantVectorType deformcVector = displacementTransform->TransformCovariantVector(testcVector, testPoint); @@ -490,7 +491,7 @@ itkDisplacementFieldTransformTest(int argc, char * argv[]) testcVVector[0] = 0.5; testcVVector[1] = 0.5; - DisplacementTransformType::OutputVectorPixelType deformcVVectorTruth = + const DisplacementTransformType::OutputVectorPixelType deformcVVectorTruth = affineTransform->TransformCovariantVector(testcVVector); DisplacementTransformType::OutputVectorPixelType deformcVVector = displacementTransform->TransformCovariantVector(testcVVector, testPoint); @@ -516,7 +517,7 @@ itkDisplacementFieldTransformTest(int argc, char * argv[]) testTensor[5] = 1; // Pass thru functionality only for now - DisplacementTransformType::OutputDiffusionTensor3DType deformTensorTruth = + const DisplacementTransformType::OutputDiffusionTensor3DType deformTensorTruth = affineTransform->TransformDiffusionTensor3D(testTensor); DisplacementTransformType::OutputDiffusionTensor3DType deformTensor = displacementTransform->TransformDiffusionTensor3D(testTensor, testPoint); @@ -554,7 +555,7 @@ itkDisplacementFieldTransformTest(int argc, char * argv[]) derivative.Fill(1.2); - ScalarType testFactor = 1.5; + const ScalarType testFactor = 1.5; for (unsigned int i = 0; i < displacementTransform->GetNumberOfParameters(); ++i) { diff --git a/Modules/Filtering/DisplacementField/test/itkExponentialDisplacementFieldImageFilterTest.cxx b/Modules/Filtering/DisplacementField/test/itkExponentialDisplacementFieldImageFilterTest.cxx index 87b4e4da182..e2bcc423b2d 100644 --- a/Modules/Filtering/DisplacementField/test/itkExponentialDisplacementFieldImageFilterTest.cxx +++ b/Modules/Filtering/DisplacementField/test/itkExponentialDisplacementFieldImageFilterTest.cxx @@ -104,7 +104,7 @@ itkExponentialDisplacementFieldImageFilterTest(int, char *[]) filter->Update(); // Get the Smart Pointer to the Filter Output - ImageType::Pointer outputImage = filter->GetOutput(); + const ImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output IteratorType ot(outputImage, outputImage->GetRequestedRegion()); @@ -119,8 +119,8 @@ itkExponentialDisplacementFieldImageFilterTest(int, char *[]) it.GoToBegin(); while (!ot.IsAtEnd()) { - PixelType input = it.Get(); - PixelType output = ot.Get(); + const PixelType input = it.Get(); + const PixelType output = ot.Get(); // The input is a constant field, its exponential // should be exactly equal testpassed &= ((input - output).GetNorm() < epsilon); @@ -139,7 +139,7 @@ itkExponentialDisplacementFieldImageFilterTest(int, char *[]) filter->Update(); // Get the Smart Pointer to the Filter Output - ImageType::Pointer outputImage2 = filter->GetOutput(); + const ImageType::Pointer outputImage2 = filter->GetOutput(); // Create an iterator for going through the image output IteratorType ot2(outputImage2, outputImage2->GetRequestedRegion()); @@ -151,8 +151,8 @@ itkExponentialDisplacementFieldImageFilterTest(int, char *[]) it.GoToBegin(); while (!ot2.IsAtEnd()) { - PixelType input = it.Get(); - PixelType output = ot2.Get(); + const PixelType input = it.Get(); + const PixelType output = ot2.Get(); // The input is a constant field, its inverse exponential // should be exactly equal to its opposite testpassed &= ((input + output).GetNorm() < epsilon); @@ -173,7 +173,7 @@ itkExponentialDisplacementFieldImageFilterTest(int, char *[]) filter->Update(); // Get the Smart Pointer to the Filter Output - ImageType::Pointer outputImage3 = filter->GetOutput(); + const ImageType::Pointer outputImage3 = filter->GetOutput(); // Create an iterator for going through the image output IteratorType ot3(outputImage3, outputImage3->GetRequestedRegion()); @@ -185,8 +185,8 @@ itkExponentialDisplacementFieldImageFilterTest(int, char *[]) it.GoToBegin(); while (!ot3.IsAtEnd()) { - PixelType input = it.Get(); - PixelType output = ot3.Get(); + const PixelType input = it.Get(); + const PixelType output = ot3.Get(); // The input is a constant field, its inverse exponential // should be exactly equal to its opposite testpassed &= ((input - output).GetNorm() < epsilon); @@ -206,7 +206,7 @@ itkExponentialDisplacementFieldImageFilterTest(int, char *[]) filter->Update(); // Get the Smart Pointer to the Filter Output - ImageType::Pointer outputImage4 = filter->GetOutput(); + const ImageType::Pointer outputImage4 = filter->GetOutput(); // Create an iterator for going through the image output IteratorType ot4(outputImage4, outputImage4->GetRequestedRegion()); @@ -218,8 +218,8 @@ itkExponentialDisplacementFieldImageFilterTest(int, char *[]) it.GoToBegin(); while (!ot4.IsAtEnd()) { - PixelType input = it.Get(); - PixelType output = ot4.Get(); + const PixelType input = it.Get(); + const PixelType output = ot4.Get(); // The input is a constant field, its inverse exponential // should be exactly equal to its opposite testpassed &= ((input + output).GetNorm() < epsilon); @@ -261,7 +261,7 @@ itkExponentialDisplacementFieldImageFilterTest(int, char *[]) } filter->Update(); - ImageType::Pointer outputImage5 = filter->GetOutput(); + const ImageType::Pointer outputImage5 = filter->GetOutput(); outputImage5->DisconnectPipeline(); // Change the spacing @@ -274,7 +274,7 @@ itkExponentialDisplacementFieldImageFilterTest(int, char *[]) } filter->Update(); - ImageType::Pointer outputImage6 = filter->GetOutput(); + const ImageType::Pointer outputImage6 = filter->GetOutput(); IteratorType ot5(outputImage5, outputImage5->GetRequestedRegion()); IteratorType ot6(outputImage6, outputImage6->GetRequestedRegion()); diff --git a/Modules/Filtering/DisplacementField/test/itkGaussianExponentialDiffeomorphicTransformTest.cxx b/Modules/Filtering/DisplacementField/test/itkGaussianExponentialDiffeomorphicTransformTest.cxx index b793bf993a9..4c67826f6a6 100644 --- a/Modules/Filtering/DisplacementField/test/itkGaussianExponentialDiffeomorphicTransformTest.cxx +++ b/Modules/Filtering/DisplacementField/test/itkGaussianExponentialDiffeomorphicTransformTest.cxx @@ -49,7 +49,7 @@ itkGaussianExponentialDiffeomorphicTransformTest(int, char *[]) FieldType::SizeType size; FieldType::IndexType start; FieldType::RegionType region; - int dimLength = 20; + const int dimLength = 20; size.Fill(dimLength); start.Fill(0); region.SetSize(size); @@ -57,7 +57,7 @@ itkGaussianExponentialDiffeomorphicTransformTest(int, char *[]) field->SetRegions(region); field->Allocate(); - FieldType::PixelType zeroVector{}; + const FieldType::PixelType zeroVector{}; field->FillBuffer(zeroVector); displacementTransform->SetConstantVelocityField(field); @@ -67,12 +67,12 @@ itkGaussianExponentialDiffeomorphicTransformTest(int, char *[]) std::cout << "Test SmoothDisplacementFieldGauss" << std::endl; DisplacementTransformType::ParametersType params; using ParametersValueType = DisplacementTransformType::ParametersValueType; - ParametersValueType paramsZero{}; - DisplacementTransformType::ParametersType paramsFill(displacementTransform->GetNumberOfParameters()); - DisplacementTransformType::ParametersValueType paramsFillValue = 0.0; + const ParametersValueType paramsZero{}; + DisplacementTransformType::ParametersType paramsFill(displacementTransform->GetNumberOfParameters()); + const DisplacementTransformType::ParametersValueType paramsFillValue = 0.0; paramsFill.Fill(paramsFillValue); // Add an outlier to visually see that some smoothing is taking place. - unsigned int outlier = dimLength * dimensions * 4 + dimLength * dimensions / 2; + const unsigned int outlier = dimLength * dimensions * 4 + dimLength * dimensions / 2; paramsFill(outlier) = 99.0; paramsFill(outlier + 1) = 99.0; displacementTransform->SetGaussianSmoothingVarianceForTheUpdateField(3); @@ -118,7 +118,7 @@ itkGaussianExponentialDiffeomorphicTransformTest(int, char *[]) { for (int j = -2; j < 3; ++j) { - unsigned int index = outlier + static_cast(i * (int)(dimLength * dimensions) + j); + const unsigned int index = outlier + static_cast(i * (int)(dimLength * dimensions) + j); std::cout << params(index) << ' '; } std::cout << std::endl; @@ -182,7 +182,7 @@ itkGaussianExponentialDiffeomorphicTransformTest(int, char *[]) { for (int j = -2; j < 3; ++j) { - unsigned int index = outlier + static_cast(i * (int)(dimLength * dimensions) + j); + const unsigned int index = outlier + static_cast(i * (int)(dimLength * dimensions) + j); std::cout << params(index) << ' '; if (itk::Math::AlmostEquals(params(index), paramsFillValue)) { diff --git a/Modules/Filtering/DisplacementField/test/itkGaussianSmoothingOnUpdateDisplacementFieldTransformTest.cxx b/Modules/Filtering/DisplacementField/test/itkGaussianSmoothingOnUpdateDisplacementFieldTransformTest.cxx index d1b6ee5c508..afda649d46e 100644 --- a/Modules/Filtering/DisplacementField/test/itkGaussianSmoothingOnUpdateDisplacementFieldTransformTest.cxx +++ b/Modules/Filtering/DisplacementField/test/itkGaussianSmoothingOnUpdateDisplacementFieldTransformTest.cxx @@ -44,7 +44,7 @@ itkGaussianSmoothingOnUpdateDisplacementFieldTransformTest(int, char *[]) FieldType::SizeType size; FieldType::IndexType start; FieldType::RegionType region; - int dimLength = 20; + const int dimLength = 20; size.Fill(dimLength); start.Fill(0); region.SetSize(size); @@ -52,7 +52,7 @@ itkGaussianSmoothingOnUpdateDisplacementFieldTransformTest(int, char *[]) field->SetRegions(region); field->Allocate(); - DisplacementTransformType::OutputVectorType zeroVector{}; + const DisplacementTransformType::OutputVectorType zeroVector{}; field->FillBuffer(zeroVector); displacementTransform->SetDisplacementField(field); @@ -60,13 +60,13 @@ itkGaussianSmoothingOnUpdateDisplacementFieldTransformTest(int, char *[]) /* Test SmoothDisplacementFieldGauss */ std::cout << "Test SmoothDisplacementFieldGauss" << std::endl; using ParametersValueType = DisplacementTransformType::ParametersValueType; - ParametersValueType paramsZero{}; - DisplacementTransformType::ParametersType params; - DisplacementTransformType::ParametersType paramsFill(displacementTransform->GetNumberOfParameters()); - DisplacementTransformType::ParametersValueType paramsFillValue = 0.0; + const ParametersValueType paramsZero{}; + DisplacementTransformType::ParametersType params; + DisplacementTransformType::ParametersType paramsFill(displacementTransform->GetNumberOfParameters()); + const DisplacementTransformType::ParametersValueType paramsFillValue = 0.0; paramsFill.Fill(paramsFillValue); // Add an outlier to visually see that some smoothing is taking place. - unsigned int outlier = dimLength * dimensions * 4 + dimLength * dimensions / 2; + const unsigned int outlier = dimLength * dimensions * 4 + dimLength * dimensions / 2; paramsFill(outlier) = 99.0; paramsFill(outlier + 1) = 99.0; displacementTransform->SetGaussianSmoothingVarianceForTheTotalField(0.25); @@ -110,7 +110,7 @@ itkGaussianSmoothingOnUpdateDisplacementFieldTransformTest(int, char *[]) { for (int j = -2; j < 3; ++j) { - unsigned int index = outlier + static_cast(i * (int)(dimLength * dimensions) + j); + const unsigned int index = outlier + static_cast(i * (int)(dimLength * dimensions) + j); std::cout << params(index) << ' '; } std::cout << std::endl; @@ -171,7 +171,7 @@ itkGaussianSmoothingOnUpdateDisplacementFieldTransformTest(int, char *[]) { for (int j = -2; j < 3; ++j) { - unsigned int index = outlier + static_cast(i * (int)(dimLength * dimensions) + j); + const unsigned int index = outlier + static_cast(i * (int)(dimLength * dimensions) + j); std::cout << params(index) << ' '; if (itk::Math::AlmostEquals(params(index), paramsFillValue)) { diff --git a/Modules/Filtering/DisplacementField/test/itkInverseDisplacementFieldImageFilterTest.cxx b/Modules/Filtering/DisplacementField/test/itkInverseDisplacementFieldImageFilterTest.cxx index 28910c7a3dd..227afb3727f 100644 --- a/Modules/Filtering/DisplacementField/test/itkInverseDisplacementFieldImageFilterTest.cxx +++ b/Modules/Filtering/DisplacementField/test/itkInverseDisplacementFieldImageFilterTest.cxx @@ -48,7 +48,7 @@ itkInverseDisplacementFieldImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, InverseDisplacementFieldImageFilter, ImageToImageFilter); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); auto kernelTransform = itk::ThinPlateSplineKernelTransform::New(); @@ -60,7 +60,7 @@ itkInverseDisplacementFieldImageFilterTest(int argc, char * argv[]) auto spacing = itk::MakeFilled(1.0); - DisplacementFieldType::PointType origin{}; + const DisplacementFieldType::PointType origin{}; DisplacementFieldType::RegionType region; DisplacementFieldType::SizeType size; @@ -115,7 +115,7 @@ itkInverseDisplacementFieldImageFilterTest(int argc, char * argv[]) filter->SetInput(field); - unsigned int subsamplingFactor = 16; + const unsigned int subsamplingFactor = 16; filter->SetSubsamplingFactor(subsamplingFactor); ITK_TEST_SET_GET_VALUE(subsamplingFactor, filter->GetSubsamplingFactor()); @@ -146,8 +146,8 @@ itkInverseDisplacementFieldImageFilterTest(int argc, char * argv[]) p2[0] = p1[0] + fp1[0]; p2[1] = p1[1] + fp1[1]; - DisplacementFieldType::IndexType id2 = filter->GetOutput()->TransformPhysicalPointToIndex(p2); - DisplacementFieldType::PixelType fp2 = filter->GetOutput()->GetPixel(id2); + const DisplacementFieldType::IndexType id2 = filter->GetOutput()->TransformPhysicalPointToIndex(p2); + DisplacementFieldType::PixelType fp2 = filter->GetOutput()->GetPixel(id2); if (itk::Math::abs(fp2[0] + fp1[0]) > 0.001 || itk::Math::abs(fp2[1] + fp1[1]) > 0.001) { diff --git a/Modules/Filtering/DisplacementField/test/itkInvertDisplacementFieldImageFilterTest.cxx b/Modules/Filtering/DisplacementField/test/itkInvertDisplacementFieldImageFilterTest.cxx index e779914a467..96e3066c82f 100644 --- a/Modules/Filtering/DisplacementField/test/itkInvertDisplacementFieldImageFilterTest.cxx +++ b/Modules/Filtering/DisplacementField/test/itkInvertDisplacementFieldImageFilterTest.cxx @@ -60,7 +60,7 @@ itkInvertDisplacementFieldImageFilterTest(int argc, char * argv[]) constexpr VectorType zeroVector{}; // make sure boundary does not move - float weight1 = 1.0; + const float weight1 = 1.0; const DisplacementFieldType::RegionType region = field->GetLargestPossibleRegion(); const DisplacementFieldType::IndexType startIndex = region.GetIndex(); @@ -118,7 +118,7 @@ itkInvertDisplacementFieldImageFilterTest(int argc, char * argv[]) inverter->SetDisplacementField(field); ITK_TEST_SET_GET_VALUE(field, inverter->GetDisplacementField()); - typename InverterType::RealType maxErrorNorm = 0.0; + const typename InverterType::RealType maxErrorNorm = 0.0; ITK_TEST_EXPECT_EQUAL(maxErrorNorm, inverter->GetMaxErrorNorm()); try @@ -135,8 +135,8 @@ itkInvertDisplacementFieldImageFilterTest(int argc, char * argv[]) index[0] = 30; index[1] = 30; - VectorType v = inverter->GetOutput()->GetPixel(index); - VectorType delta = v + ones; + const VectorType v = inverter->GetOutput()->GetPixel(index); + const VectorType delta = v + ones; if (delta.GetNorm() > 0.05) { std::cerr << "Failed to find proper inverse." << std::endl; diff --git a/Modules/Filtering/DisplacementField/test/itkIterativeInverseDisplacementFieldImageFilterTest.cxx b/Modules/Filtering/DisplacementField/test/itkIterativeInverseDisplacementFieldImageFilterTest.cxx index 44d951d0d3b..f90f5bf7e44 100644 --- a/Modules/Filtering/DisplacementField/test/itkIterativeInverseDisplacementFieldImageFilterTest.cxx +++ b/Modules/Filtering/DisplacementField/test/itkIterativeInverseDisplacementFieldImageFilterTest.cxx @@ -48,7 +48,7 @@ itkIterativeInverseDisplacementFieldImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, IterativeInverseDisplacementFieldImageFilter, ImageToImageFilter); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); auto numberOfIterations = static_cast(std::stoi(argv[2])); filter->SetNumberOfIterations(numberOfIterations); @@ -64,7 +64,7 @@ itkIterativeInverseDisplacementFieldImageFilterTest(int argc, char * argv[]) auto spacing = itk::MakeFilled(1.0); - DisplacementFieldType::PointType origin{}; + const DisplacementFieldType::PointType origin{}; DisplacementFieldType::RegionType region; DisplacementFieldType::SizeType size; diff --git a/Modules/Filtering/DisplacementField/test/itkLandmarkDisplacementFieldSourceTest.cxx b/Modules/Filtering/DisplacementField/test/itkLandmarkDisplacementFieldSourceTest.cxx index 4e905ab6fd3..12b9f56b7ce 100644 --- a/Modules/Filtering/DisplacementField/test/itkLandmarkDisplacementFieldSourceTest.cxx +++ b/Modules/Filtering/DisplacementField/test/itkLandmarkDisplacementFieldSourceTest.cxx @@ -51,11 +51,11 @@ itkLandmarkDisplacementFieldSourceTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, LandmarkDisplacementFieldSource, ImageSource); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); auto spacing = itk::MakeFilled(1.0); - DisplacementFieldType::PointType origin{}; + const DisplacementFieldType::PointType origin{}; DisplacementFieldType::RegionType region; DisplacementFieldType::SizeType size; diff --git a/Modules/Filtering/DisplacementField/test/itkTimeVaryingBSplineVelocityFieldTransformTest.cxx b/Modules/Filtering/DisplacementField/test/itkTimeVaryingBSplineVelocityFieldTransformTest.cxx index 593ae412ce1..203334841e3 100644 --- a/Modules/Filtering/DisplacementField/test/itkTimeVaryingBSplineVelocityFieldTransformTest.cxx +++ b/Modules/Filtering/DisplacementField/test/itkTimeVaryingBSplineVelocityFieldTransformTest.cxx @@ -37,7 +37,7 @@ itkTimeVaryingBSplineVelocityFieldTransformTest(int, char *[]) auto displacement1 = itk::MakeFilled(0.1); - TimeVaryingVelocityFieldControlPointLatticeType::Pointer timeVaryingVelocityFieldControlPointLattice = + const TimeVaryingVelocityFieldControlPointLatticeType::Pointer timeVaryingVelocityFieldControlPointLattice = TimeVaryingVelocityFieldControlPointLatticeType::New(); timeVaryingVelocityFieldControlPointLattice->SetOrigin(origin); @@ -56,8 +56,8 @@ itkTimeVaryingBSplineVelocityFieldTransformTest(int, char *[]) integrator->SetUpperTimeBound(0.75); integrator->Update(); - DisplacementFieldType::IndexType index{}; - VectorType displacementPixel; + const DisplacementFieldType::IndexType index{}; + VectorType displacementPixel; // This integration should result in a constant image of value // 0.75 * 0.1 - 0.3 * 0.1 = 0.045 with ~epsilon deviation @@ -101,7 +101,7 @@ itkTimeVaryingBSplineVelocityFieldTransformTest(int, char *[]) timeVaryingVelocityFieldSpacing.Fill(1.0); for (unsigned int d = 0; d < 4; ++d) { - float physicalDimensions = (size[d] - splineOrder) * spacing[d]; + const float physicalDimensions = (size[d] - splineOrder) * spacing[d]; timeVaryingVelocityFieldSize[d] = static_cast(physicalDimensions / timeVaryingVelocityFieldSpacing[d] + 1); timeVaryingVelocityFieldSpacing[d] = physicalDimensions / (timeVaryingVelocityFieldSize[d] - 1); @@ -162,7 +162,7 @@ itkTimeVaryingBSplineVelocityFieldTransformTest(int, char *[]) point2.CastFrom(transformedPoint); using InverseTransformBasePointer = TransformType::InverseTransformBasePointer; - InverseTransformBasePointer inverseTransform = transform->GetInverseTransform(); + const InverseTransformBasePointer inverseTransform = transform->GetInverseTransform(); transformedPoint = inverseTransform->TransformPoint(point2); diff --git a/Modules/Filtering/DisplacementField/test/itkTimeVaryingVelocityFieldIntegrationImageFilterTest.cxx b/Modules/Filtering/DisplacementField/test/itkTimeVaryingVelocityFieldIntegrationImageFilterTest.cxx index b6eea0f055b..16634093785 100644 --- a/Modules/Filtering/DisplacementField/test/itkTimeVaryingVelocityFieldIntegrationImageFilterTest.cxx +++ b/Modules/Filtering/DisplacementField/test/itkTimeVaryingVelocityFieldIntegrationImageFilterTest.cxx @@ -173,16 +173,16 @@ itkTimeVaryingVelocityFieldIntegrationImageFilterTest(int argc, char * argv[]) size[1] = 3; size[2] = 401; size[3] = 61; - ImportFilterType::IndexType start{}; + const ImportFilterType::IndexType start{}; - ImportFilterType::RegionType region{ start, size }; + const ImportFilterType::RegionType region{ start, size }; importFilter->SetRegion(region); origin.Fill(0.); importFilter->SetOrigin(origin); - double spaceTimeSpan[4] = { 20., 20., 20., 1.5 }; + const double spaceTimeSpan[4] = { 20., 20., 20., 1.5 }; for (unsigned int i = 0; i < 4; i++) { spacing[i] = spaceTimeSpan[i] / (size[i] - 1); @@ -214,7 +214,7 @@ itkTimeVaryingVelocityFieldIntegrationImageFilterTest(int argc, char * argv[]) const bool importImageFilterWillOwnTheBuffer = true; importFilter->SetImportPointer(localBuffer, numberOfPixels, importImageFilterWillOwnTheBuffer); - TimeVaryingVelocityFieldType::Pointer timeVaryingVelocityField = importFilter->GetOutput(); + const TimeVaryingVelocityFieldType::Pointer timeVaryingVelocityField = importFilter->GetOutput(); lowerTimeBound = static_cast(std::stod(argv[4])); integrator->SetLowerTimeBound(lowerTimeBound); diff --git a/Modules/Filtering/DisplacementField/test/itkTimeVaryingVelocityFieldTransformTest.cxx b/Modules/Filtering/DisplacementField/test/itkTimeVaryingVelocityFieldTransformTest.cxx index 71f0d65a3af..f26a89899d9 100644 --- a/Modules/Filtering/DisplacementField/test/itkTimeVaryingVelocityFieldTransformTest.cxx +++ b/Modules/Filtering/DisplacementField/test/itkTimeVaryingVelocityFieldTransformTest.cxx @@ -32,7 +32,7 @@ itkTimeVaryingVelocityFieldTransformTest(int, char *[]) using DisplacementFieldType = itk::Image; using TimeVaryingVelocityFieldType = itk::Image; - TimeVaryingVelocityFieldType::PointType origin{}; + const TimeVaryingVelocityFieldType::PointType origin{}; auto spacing = itk::MakeFilled(2.0); @@ -60,8 +60,8 @@ itkTimeVaryingVelocityFieldTransformTest(int, char *[]) integrator->Print(std::cout, 3); - DisplacementFieldType::IndexType index{}; - VectorType displacementPixel; + const DisplacementFieldType::IndexType index{}; + VectorType displacementPixel; // This integration should result in a constant image of value // 0.75 * 0.1 - 0.3 * 0.1 = 0.045 with ~epsilon deviation @@ -116,7 +116,7 @@ itkTimeVaryingVelocityFieldTransformTest(int, char *[]) // Now Clone the Transform and test transform again - TransformType::Pointer clone = transform->Clone(); + const TransformType::Pointer clone = transform->Clone(); auto point = itk::MakeFilled(1.3); @@ -147,8 +147,8 @@ itkTimeVaryingVelocityFieldTransformTest(int, char *[]) clonePoint2.CastFrom(cloneTransformedPoint); using InverseTransformBasePointer = TransformType::InverseTransformBasePointer; - InverseTransformBasePointer inverseTransform = transform->GetInverseTransform(); - InverseTransformBasePointer cloneInverseTransform = clone->GetInverseTransform(); + const InverseTransformBasePointer inverseTransform = transform->GetInverseTransform(); + const InverseTransformBasePointer cloneInverseTransform = clone->GetInverseTransform(); transformedPoint = inverseTransform->TransformPoint(point2); cloneTransformedPoint = cloneInverseTransform->TransformPoint(clonePoint2); diff --git a/Modules/Filtering/DisplacementField/test/itkTransformToDisplacementFieldFilterTest.cxx b/Modules/Filtering/DisplacementField/test/itkTransformToDisplacementFieldFilterTest.cxx index 764c0b7c679..31d79196651 100644 --- a/Modules/Filtering/DisplacementField/test/itkTransformToDisplacementFieldFilterTest.cxx +++ b/Modules/Filtering/DisplacementField/test/itkTransformToDisplacementFieldFilterTest.cxx @@ -35,9 +35,9 @@ itkTransformToDisplacementFieldFilterTest(int argc, char * argv[]) return EXIT_FAILURE; } - std::string transformName = argv[1]; - std::string fileName = argv[2]; - std::string bSplineParametersFile; + const std::string transformName = argv[1]; + const std::string fileName = argv[2]; + std::string bSplineParametersFile; if (argc > 3) { bSplineParametersFile = argv[3]; @@ -71,10 +71,10 @@ itkTransformToDisplacementFieldFilterTest(int argc, char * argv[]) using WriterType = itk::ImageFileWriter; // Create output information. - auto size = SizeType::Filled(20); - IndexType index{}; - auto spacing = itk::MakeFilled(0.7); - auto origin = itk::MakeFilled(-10.0); + auto size = SizeType::Filled(20); + const IndexType index{}; + auto spacing = itk::MakeFilled(0.7); + auto origin = itk::MakeFilled(-10.0); // Create transforms. auto affineTransform = AffineTransformType::New(); diff --git a/Modules/Filtering/DisplacementField/test/itkTransformToDisplacementFieldFilterTest1.cxx b/Modules/Filtering/DisplacementField/test/itkTransformToDisplacementFieldFilterTest1.cxx index b2b58efe0cb..e1f97c9d727 100644 --- a/Modules/Filtering/DisplacementField/test/itkTransformToDisplacementFieldFilterTest1.cxx +++ b/Modules/Filtering/DisplacementField/test/itkTransformToDisplacementFieldFilterTest1.cxx @@ -72,9 +72,9 @@ itkTransformToDisplacementFieldFilterTest1(int argc, char * argv[]) // Create input image. - auto size = SizeType::Filled(24); - IndexType index{}; - SpacingType spacing; + auto size = SizeType::Filled(24); + const IndexType index{}; + SpacingType spacing; spacing[0] = 1.1; spacing[1] = 2.2; spacing[2] = 3.3; @@ -95,8 +95,8 @@ itkTransformToDisplacementFieldFilterTest1(int argc, char * argv[]) inputDirection[2][1] = -1; inputDirection[2][2] = 0; - RegionType region{ index, size }; - auto image = ImageType::New(); + const RegionType region{ index, size }; + auto image = ImageType::New(); image->SetRegions(region); image->Allocate(); image->SetSpacing(spacing); @@ -132,10 +132,10 @@ itkTransformToDisplacementFieldFilterTest1(int argc, char * argv[]) } // Set Output information. - IndexType outputIndex{}; - SpacingType outputSpacing; - auto outputSize = SizeType::Filled(24); - RegionType outputRegion{ outputIndex, outputSize }; + const IndexType outputIndex{}; + SpacingType outputSpacing; + auto outputSize = SizeType::Filled(24); + const RegionType outputRegion{ outputIndex, outputSize }; outputSpacing[0] = 1.0; outputSpacing[1] = 2.0; outputSpacing[2] = 3.0; @@ -143,7 +143,7 @@ itkTransformToDisplacementFieldFilterTest1(int argc, char * argv[]) outputOrigin[0] = 50; outputOrigin[1] = 30; outputOrigin[2] = -60; - DirectionType outputDirection = inputDirection; + const DirectionType outputDirection = inputDirection; // Create transforms. auto eulerTransform = TransformType::New(); diff --git a/Modules/Filtering/DistanceMap/include/itkApproximateSignedDistanceMapImageFilter.hxx b/Modules/Filtering/DistanceMap/include/itkApproximateSignedDistanceMapImageFilter.hxx index a8ba2254998..6e3aa6f9b4a 100644 --- a/Modules/Filtering/DistanceMap/include/itkApproximateSignedDistanceMapImageFilter.hxx +++ b/Modules/Filtering/DistanceMap/include/itkApproximateSignedDistanceMapImageFilter.hxx @@ -38,12 +38,12 @@ template void ApproximateSignedDistanceMapImageFilter::GenerateData() { - ThreadIdType numberOfWorkUnits = this->GetNumberOfWorkUnits(); + const ThreadIdType numberOfWorkUnits = this->GetNumberOfWorkUnits(); - OutputImagePointer output = this->GetOutput(); + const OutputImagePointer output = this->GetOutput(); using OutputRegionType = typename OutputImageType::RegionType; - OutputRegionType oRegion = output->GetRequestedRegion(); + const OutputRegionType oRegion = output->GetRequestedRegion(); // Calculate the largest possible distance in the output image. // this maximum is the distance from one corner of the image to the other. @@ -72,7 +72,7 @@ ApproximateSignedDistanceMapImageFilter::GenerateData m_IsoContourFilter->SetInput(this->GetInput()); m_IsoContourFilter->SetFarValue(maximumDistance + 1); m_IsoContourFilter->SetNumberOfWorkUnits(numberOfWorkUnits); - typename IsoContourType::PixelRealType levelSetValue = + const typename IsoContourType::PixelRealType levelSetValue = (static_cast(m_InsideValue) + static_cast(m_OutsideValue)) / 2.0; diff --git a/Modules/Filtering/DistanceMap/include/itkContourDirectedMeanDistanceImageFilter.hxx b/Modules/Filtering/DistanceMap/include/itkContourDirectedMeanDistanceImageFilter.hxx index eedc91a9eb3..845712e5a55 100644 --- a/Modules/Filtering/DistanceMap/include/itkContourDirectedMeanDistanceImageFilter.hxx +++ b/Modules/Filtering/DistanceMap/include/itkContourDirectedMeanDistanceImageFilter.hxx @@ -83,12 +83,12 @@ ContourDirectedMeanDistanceImageFilter::GenerateInpu // - the corresponding region of the second image if (this->GetInput1()) { - InputImage1Pointer image1 = const_cast(this->GetInput1()); + const InputImage1Pointer image1 = const_cast(this->GetInput1()); image1->SetRequestedRegionToLargestPossibleRegion(); if (this->GetInput2()) { - InputImage2Pointer image2 = const_cast(this->GetInput2()); + const InputImage2Pointer image2 = const_cast(this->GetInput2()); image2->SetRequestedRegion(this->GetInput1()->GetRequestedRegion()); } } @@ -107,7 +107,7 @@ void ContourDirectedMeanDistanceImageFilter::AllocateOutputs() { // Pass the first input through as the output - InputImage1Pointer image = const_cast(this->GetInput1()); + const InputImage1Pointer image = const_cast(this->GetInput1()); this->GraftOutput(image); } @@ -116,7 +116,7 @@ template void ContourDirectedMeanDistanceImageFilter::BeforeThreadedGenerateData() { - ThreadIdType numberOfWorkUnits = this->GetNumberOfWorkUnits(); + const ThreadIdType numberOfWorkUnits = this->GetNumberOfWorkUnits(); // Resize the thread temporaries m_MeanDistance.SetSize(numberOfWorkUnits); @@ -143,7 +143,7 @@ template void ContourDirectedMeanDistanceImageFilter::AfterThreadedGenerateData() { - ThreadIdType numberOfWorkUnits = this->GetNumberOfWorkUnits(); + const ThreadIdType numberOfWorkUnits = this->GetNumberOfWorkUnits(); // Find mean over all threads IdentifierType count = 0; @@ -174,7 +174,7 @@ ContourDirectedMeanDistanceImageFilter::ThreadedGene ConstNeighborhoodIterator bit; - InputImage1ConstPointer input = this->GetInput(); + const InputImage1ConstPointer input = this->GetInput(); // Find the data-set boundary "faces" constexpr auto radius = SizeType::Filled(1); @@ -182,7 +182,7 @@ ContourDirectedMeanDistanceImageFilter::ThreadedGene using FaceListType = typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType; NeighborhoodAlgorithm::ImageBoundaryFacesCalculator bC; - FaceListType faceList = bC(input, outputRegionForThread, radius); + const FaceListType faceList = bC(input, outputRegionForThread, radius); // Support progress methods/callbacks ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels()); @@ -193,7 +193,7 @@ ContourDirectedMeanDistanceImageFilter::ThreadedGene { ImageRegionConstIterator it2(m_DistanceMap, face); bit = ConstNeighborhoodIterator(radius, input, face); - unsigned int neighborhoodSize = bit.Size(); + const unsigned int neighborhoodSize = bit.Size(); bit.OverrideBoundaryCondition(&nbc); bit.GoToBegin(); diff --git a/Modules/Filtering/DistanceMap/include/itkContourMeanDistanceImageFilter.hxx b/Modules/Filtering/DistanceMap/include/itkContourMeanDistanceImageFilter.hxx index cd6601df4b2..39d99c595ba 100644 --- a/Modules/Filtering/DistanceMap/include/itkContourMeanDistanceImageFilter.hxx +++ b/Modules/Filtering/DistanceMap/include/itkContourMeanDistanceImageFilter.hxx @@ -74,12 +74,12 @@ ContourMeanDistanceImageFilter::GenerateInputRequest // - the corresponding region of the second image if (this->GetInput1()) { - InputImage1Pointer image1 = const_cast(this->GetInput1()); + const InputImage1Pointer image1 = const_cast(this->GetInput1()); image1->SetRequestedRegionToLargestPossibleRegion(); if (this->GetInput2()) { - InputImage2Pointer image2 = const_cast(this->GetInput2()); + const InputImage2Pointer image2 = const_cast(this->GetInput2()); image2->SetRequestedRegion(this->GetInput1()->GetRequestedRegion()); } } @@ -98,7 +98,7 @@ void ContourMeanDistanceImageFilter::GenerateData() { // Pass the first input through as the output - InputImage1Pointer image = const_cast(this->GetInput1()); + const InputImage1Pointer image = const_cast(this->GetInput1()); this->GraftOutput(image); @@ -130,9 +130,9 @@ ContourMeanDistanceImageFilter::GenerateData() progress->RegisterInternalFilter(filter21, .5f); filter12->Update(); - RealType distance12 = filter12->GetContourDirectedMeanDistance(); + const RealType distance12 = filter12->GetContourDirectedMeanDistance(); filter21->Update(); - RealType distance21 = filter21->GetContourDirectedMeanDistance(); + const RealType distance21 = filter21->GetContourDirectedMeanDistance(); if (distance12 > distance21) { diff --git a/Modules/Filtering/DistanceMap/include/itkDanielssonDistanceMapImageFilter.hxx b/Modules/Filtering/DistanceMap/include/itkDanielssonDistanceMapImageFilter.hxx index fc2e3cdb868..f9f08898b65 100644 --- a/Modules/Filtering/DistanceMap/include/itkDanielssonDistanceMapImageFilter.hxx +++ b/Modules/Filtering/DistanceMap/include/itkDanielssonDistanceMapImageFilter.hxx @@ -82,9 +82,9 @@ void DanielssonDistanceMapImageFilter::PrepareData() { itkDebugMacro("PrepareData Start"); - VoronoiImagePointer voronoiMap = this->GetVoronoiMap(); + const VoronoiImagePointer voronoiMap = this->GetVoronoiMap(); - InputImagePointer inputImage = dynamic_cast(ProcessObject::GetInput(0)); + const InputImagePointer inputImage = dynamic_cast(ProcessObject::GetInput(0)); voronoiMap->SetLargestPossibleRegion(inputImage->GetLargestPossibleRegion()); @@ -94,7 +94,7 @@ DanielssonDistanceMapImageFilter::Prep voronoiMap->Allocate(); - OutputImagePointer distanceMap = this->GetDistanceMap(); + const OutputImagePointer distanceMap = this->GetDistanceMap(); distanceMap->SetLargestPossibleRegion(inputImage->GetLargestPossibleRegion()); @@ -104,7 +104,7 @@ DanielssonDistanceMapImageFilter::Prep distanceMap->Allocate(); - typename OutputImageType::RegionType region = voronoiMap->GetRequestedRegion(); + const typename OutputImageType::RegionType region = voronoiMap->GetRequestedRegion(); // find the largest of the image dimensions SizeType size = region.GetSize(); @@ -121,7 +121,7 @@ DanielssonDistanceMapImageFilter::Prep itkDebugMacro("PrepareData: Copy input to output"); if (m_InputIsBinary) { - VoronoiPixelType npt = 1; + const VoronoiPixelType npt = 1; while (!ot.IsAtEnd()) { if (it.Get()) @@ -146,7 +146,7 @@ DanielssonDistanceMapImageFilter::Prep } } - VectorImagePointer distanceComponents = GetVectorDistanceMap(); + const VectorImagePointer distanceComponents = GetVectorDistanceMap(); distanceComponents->SetLargestPossibleRegion(inputImage->GetLargestPossibleRegion()); @@ -194,11 +194,11 @@ void DanielssonDistanceMapImageFilter::ComputeVoronoiMap() { itkDebugMacro("ComputeVoronoiMap Start"); - VoronoiImagePointer voronoiMap = this->GetVoronoiMap(); - OutputImagePointer distanceMap = this->GetDistanceMap(); - VectorImagePointer distanceComponents = this->GetVectorDistanceMap(); + const VoronoiImagePointer voronoiMap = this->GetVoronoiMap(); + const OutputImagePointer distanceMap = this->GetDistanceMap(); + const VectorImagePointer distanceComponents = this->GetVectorDistanceMap(); - typename OutputImageType::RegionType region = voronoiMap->GetRequestedRegion(); + const typename OutputImageType::RegionType region = voronoiMap->GetRequestedRegion(); ImageRegionIteratorWithIndex ot(voronoiMap, region); ImageRegionIteratorWithIndex ct(distanceComponents, region); @@ -207,7 +207,7 @@ DanielssonDistanceMapImageFilter::Comp itkDebugMacro("ComputeVoronoiMap Region: " << region); while (!ot.IsAtEnd()) { - IndexType index = ct.GetIndex() + ct.Get(); + const IndexType index = ct.GetIndex() + ct.Get(); if (region.IsInside(index)) { ot.Set(voronoiMap->GetPixel(index)); @@ -219,7 +219,7 @@ DanielssonDistanceMapImageFilter::Comp { for (unsigned int i = 0; i < InputImageDimension; ++i) { - double component = distanceVector[i] * static_cast(m_InputSpacingCache[i]); + const double component = distanceVector[i] * static_cast(m_InputSpacingCache[i]); distance += component * component; } } @@ -253,9 +253,9 @@ DanielssonDistanceMapImageFilter::Upda const IndexType & here, const OffsetType & offset) { - IndexType there = here + offset; - OffsetType offsetValueHere = components->GetPixel(here); - OffsetType offsetValueThere = components->GetPixel(there) + offset; + const IndexType there = here + offset; + OffsetType offsetValueHere = components->GetPixel(here); + OffsetType offsetValueThere = components->GetPixel(there) + offset; double norm1 = 0.0; double norm2 = 0.0; @@ -291,10 +291,10 @@ DanielssonDistanceMapImageFilter::Gene // Specify images and regions. - VoronoiImagePointer voronoiMap = this->GetVoronoiMap(); - VectorImagePointer distanceComponents = this->GetVectorDistanceMap(); + const VoronoiImagePointer voronoiMap = this->GetVoronoiMap(); + const VectorImagePointer distanceComponents = this->GetVectorDistanceMap(); - RegionType region = voronoiMap->GetRequestedRegion(); + const RegionType region = voronoiMap->GetRequestedRegion(); itkDebugMacro("Region to process: " << region); @@ -323,7 +323,7 @@ DanielssonDistanceMapImageFilter::Gene // The foreground values are where the distance map should be solved. // We iterate over this input image so that all background (non-zero) values are ignored in the // distance map computation. - InputImagePointer inputImage = dynamic_cast(ProcessObject::GetInput(0)); + const InputImagePointer inputImage = dynamic_cast(ProcessObject::GetInput(0)); ReflectiveImageRegionConstIterator inputIt(inputImage, region); inputIt.SetBeginOffset(voffset); inputIt.SetEndOffset(voffset); @@ -333,8 +333,8 @@ DanielssonDistanceMapImageFilter::Gene // Each pixel is visited 2^InputImageDimension times, and the number // of visits per pixel needs to be computed for progress reporting. - SizeValueType visitsPerPixel = (1 << InputImageDimension); - SizeValueType updateVisits = region.GetNumberOfPixels() * visitsPerPixel / 10; + const SizeValueType visitsPerPixel = (1 << InputImageDimension); + SizeValueType updateVisits = region.GetNumberOfPixels() * visitsPerPixel / 10; if (updateVisits < 1) { updateVisits = 1; @@ -361,7 +361,7 @@ DanielssonDistanceMapImageFilter::Gene // We can ignore these pixels in the update step. if (!inputIt.Get()) { - IndexType here = it.GetIndex(); + const IndexType here = it.GetIndex(); for (unsigned int dim = 0; dim < InputImageDimension; ++dim) { if (region.GetSize()[dim] <= 1) diff --git a/Modules/Filtering/DistanceMap/include/itkDirectedHausdorffDistanceImageFilter.hxx b/Modules/Filtering/DistanceMap/include/itkDirectedHausdorffDistanceImageFilter.hxx index 94d7adb44a9..ef3f229c88d 100644 --- a/Modules/Filtering/DistanceMap/include/itkDirectedHausdorffDistanceImageFilter.hxx +++ b/Modules/Filtering/DistanceMap/include/itkDirectedHausdorffDistanceImageFilter.hxx @@ -76,13 +76,13 @@ DirectedHausdorffDistanceImageFilter::GenerateInputR // - the corresponding region of the second image if (this->GetInput1()) { - InputImage1Pointer image1 = const_cast(this->GetInput1()); + const InputImage1Pointer image1 = const_cast(this->GetInput1()); image1->SetRequestedRegionToLargestPossibleRegion(); if (this->GetInput2()) { - InputImage2Pointer image2 = const_cast(this->GetInput2()); - RegionType region = image1->GetRequestedRegion(); + const InputImage2Pointer image2 = const_cast(this->GetInput2()); + const RegionType region = image1->GetRequestedRegion(); image2->SetRequestedRegion(region); } } @@ -101,7 +101,7 @@ void DirectedHausdorffDistanceImageFilter::AllocateOutputs() { // Pass the first input through as the output - InputImage1Pointer image = const_cast(this->GetInput1()); + const InputImage1Pointer image = const_cast(this->GetInput1()); this->GraftOutput(image); } diff --git a/Modules/Filtering/DistanceMap/include/itkFastChamferDistanceImageFilter.hxx b/Modules/Filtering/DistanceMap/include/itkFastChamferDistanceImageFilter.hxx index 2d7e67133cb..50ea481e038 100644 --- a/Modules/Filtering/DistanceMap/include/itkFastChamferDistanceImageFilter.hxx +++ b/Modules/Filtering/DistanceMap/include/itkFastChamferDistanceImageFilter.hxx @@ -121,7 +121,7 @@ FastChamferDistanceImageFilter::GenerateDataND() /** Scan the image */ for (it.GoToBegin(); !it.IsAtEnd(); ++it) { - PixelType center_value = it.GetPixel(center_voxel); + const PixelType center_value = it.GetPixel(center_voxel); if (center_value >= m_MaximumDistance) { continue; @@ -193,7 +193,7 @@ FastChamferDistanceImageFilter::GenerateDataND() /** Scan the image */ for (it.GoToEnd(), --it; !it.IsAtBegin(); --it) { - PixelType center_value = it.GetPixel(center_voxel); + const PixelType center_value = it.GetPixel(center_voxel); if (center_value >= m_MaximumDistance) { continue; @@ -270,7 +270,7 @@ void FastChamferDistanceImageFilter::GenerateData() { // Allocate the output image. - typename TOutputImage::Pointer output = this->GetOutput(); + const typename TOutputImage::Pointer output = this->GetOutput(); output->SetBufferedRegion(output->GetRequestedRegion()); output->Allocate(); diff --git a/Modules/Filtering/DistanceMap/include/itkHausdorffDistanceImageFilter.hxx b/Modules/Filtering/DistanceMap/include/itkHausdorffDistanceImageFilter.hxx index 197e3ce1192..897b7522ffb 100644 --- a/Modules/Filtering/DistanceMap/include/itkHausdorffDistanceImageFilter.hxx +++ b/Modules/Filtering/DistanceMap/include/itkHausdorffDistanceImageFilter.hxx @@ -73,12 +73,12 @@ HausdorffDistanceImageFilter::GenerateInputRequested // - the corresponding region of the second image if (this->GetInput1()) { - InputImage1Pointer image1 = const_cast(this->GetInput1()); + const InputImage1Pointer image1 = const_cast(this->GetInput1()); image1->SetRequestedRegionToLargestPossibleRegion(); if (this->GetInput2()) { - InputImage2Pointer image2 = const_cast(this->GetInput2()); + const InputImage2Pointer image2 = const_cast(this->GetInput2()); image2->SetRequestedRegion(this->GetInput1()->GetRequestedRegion()); } } @@ -96,10 +96,10 @@ template void HausdorffDistanceImageFilter::GenerateData() { - ThreadIdType numberOfWorkUnits = this->GetNumberOfWorkUnits(); + const ThreadIdType numberOfWorkUnits = this->GetNumberOfWorkUnits(); // Pass the first input through as the output - InputImage1Pointer image = const_cast(this->GetInput1()); + const InputImage1Pointer image = const_cast(this->GetInput1()); this->GraftOutput(image); diff --git a/Modules/Filtering/DistanceMap/include/itkIsoContourDistanceImageFilter.hxx b/Modules/Filtering/DistanceMap/include/itkIsoContourDistanceImageFilter.hxx index a9113255955..3d7c21696ce 100644 --- a/Modules/Filtering/DistanceMap/include/itkIsoContourDistanceImageFilter.hxx +++ b/Modules/Filtering/DistanceMap/include/itkIsoContourDistanceImageFilter.hxx @@ -121,9 +121,9 @@ ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION IsoContourDistanceImageFilter::ThreaderFullCallback(void * arg) { using WorkUnitInfo = MultiThreaderBase::WorkUnitInfo; - auto * workUnitInfo = static_cast(arg); - ThreadIdType workUnitID = workUnitInfo->WorkUnitID; - ThreadIdType workUnitCount = workUnitInfo->NumberOfWorkUnits; + auto * workUnitInfo = static_cast(arg); + const ThreadIdType workUnitID = workUnitInfo->WorkUnitID; + const ThreadIdType workUnitCount = workUnitInfo->NumberOfWorkUnits; using FilterStruct = typename ImageSource::ThreadStruct; auto * str = (FilterStruct *)(workUnitInfo->UserData); auto * filter = static_cast(str->Filter.GetPointer()); @@ -131,7 +131,7 @@ IsoContourDistanceImageFilter::ThreaderFullCallback(v // execute the actual method with appropriate output region // first find out how many pieces extent can be split into. typename TOutputImage::RegionType splitRegion; - ThreadIdType total = filter->SplitRequestedRegion(workUnitID, workUnitCount, splitRegion); + const ThreadIdType total = filter->SplitRequestedRegion(workUnitID, workUnitCount, splitRegion); if (workUnitID < total) { @@ -158,7 +158,7 @@ IsoContourDistanceImageFilter::BeforeThreadedGenerate // itkImageSource::SplitRequestedRegion. Sometimes this number is less than // the number of threads requested. OutputImageRegionType dummy; - unsigned int actualThreads = this->SplitRequestedRegion(0, this->GetNumberOfWorkUnits(), dummy); + const unsigned int actualThreads = this->SplitRequestedRegion(0, this->GetNumberOfWorkUnits(), dummy); m_Spacing = this->GetInput()->GetSpacing(); @@ -178,15 +178,15 @@ IsoContourDistanceImageFilter::ThreadedGenerateData( using ImageConstPointer = typename InputImageType::ConstPointer; using OutputPointer = typename OutputImageType::Pointer; - ImageConstPointer inputPtr = this->GetInput(); - OutputPointer outputPtr = this->GetOutput(); + const ImageConstPointer inputPtr = this->GetInput(); + const OutputPointer outputPtr = this->GetOutput(); using ConstIteratorType = ImageRegionConstIterator; using IteratorType = ImageRegionIterator; ConstIteratorType inIt(inputPtr, outputRegionForThread); IteratorType outIt(outputPtr, outputRegionForThread); - PixelType negFarValue = -m_FarValue; + const PixelType negFarValue = -m_FarValue; // Initialize output image. This needs to be done regardless of the // NarrowBanding or Full implementation @@ -218,8 +218,8 @@ IsoContourDistanceImageFilter::ThreadedGenerateDataFu using ImageConstPointer = typename InputImageType::ConstPointer; using OutputPointer = typename OutputImageType::Pointer; - ImageConstPointer inputPtr = this->GetInput(); - OutputPointer outputPtr = this->GetOutput(); + const ImageConstPointer inputPtr = this->GetInput(); + const OutputPointer outputPtr = this->GetOutput(); InputSizeType radiusIn; SizeType radiusOut; @@ -243,7 +243,7 @@ IsoContourDistanceImageFilter::ThreadedGenerateDataFu stride[n] = inNeigIt.GetStride(n); } - unsigned int center = inNeigIt.Size() / 2; + const unsigned int center = inNeigIt.Size() / 2; for (inNeigIt.GoToBegin(); !inNeigIt.IsAtEnd(); ++inNeigIt, ++outNeigIt) { @@ -257,15 +257,15 @@ IsoContourDistanceImageFilter::ThreadedGenerateDataBa const OutputImageRegionType & itkNotUsed(outputRegionForThread), ThreadIdType threadId) { - typename InputImageType::ConstPointer inputPtr = this->GetInput(); - typename OutputImageType::Pointer outputPtr = this->GetOutput(); + const typename InputImageType::ConstPointer inputPtr = this->GetInput(); + const typename OutputImageType::Pointer outputPtr = this->GetOutput(); // Tasks: // 1. Initialize whole output image (done in ThreadedGenerateData) // 2. Wait for threads (done in ThreadedGenerateData) // 3. Computation over the narrowband - ConstBandIterator bandIt = m_NarrowBandRegion[threadId].Begin; - ConstBandIterator bandEnd = m_NarrowBandRegion[threadId].End; + ConstBandIterator bandIt = m_NarrowBandRegion[threadId].Begin; + const ConstBandIterator bandEnd = m_NarrowBandRegion[threadId].End; unsigned int n; @@ -288,7 +288,7 @@ IsoContourDistanceImageFilter::ThreadedGenerateDataBa { stride[n] = inNeigIt.GetStride(n); } - unsigned int center = inNeigIt.Size() / 2; + const unsigned int center = inNeigIt.Size() / 2; while (bandIt != bandEnd) { @@ -308,8 +308,8 @@ IsoContourDistanceImageFilter::ComputeValue(const Inp unsigned int center, const std::vector & stride) { - PixelRealType val0 = static_cast(inNeigIt.GetPixel(center)) - m_LevelSetValue; - bool sign = (val0 > 0); + const PixelRealType val0 = static_cast(inNeigIt.GetPixel(center)) - m_LevelSetValue; + const bool sign = (val0 > 0); PixelRealType grad0[ImageDimension]; @@ -322,9 +322,9 @@ IsoContourDistanceImageFilter::ComputeValue(const Inp for (unsigned int n = 0; n < ImageDimension; ++n) { - PixelRealType val1 = static_cast(inNeigIt.GetPixel(center + stride[n])) - m_LevelSetValue; + const PixelRealType val1 = static_cast(inNeigIt.GetPixel(center + stride[n])) - m_LevelSetValue; - bool neighSign = (val1 > 0); + const bool neighSign = (val1 > 0); if (sign != neighSign) { @@ -353,8 +353,8 @@ IsoContourDistanceImageFilter::ComputeValue(const Inp // Interpolate values PixelRealType grad[ImageDimension]; - PixelRealType alpha0 = 0.5; // Interpolation factor - PixelRealType alpha1 = 0.5; // Interpolation factor + const PixelRealType alpha0 = 0.5; // Interpolation factor + const PixelRealType alpha1 = 0.5; // Interpolation factor PixelRealType norm = 0.; @@ -367,10 +367,10 @@ IsoContourDistanceImageFilter::ComputeValue(const Inp if (norm > NumericTraits::min()) { - PixelRealType val = itk::Math::abs(grad[n]) * m_Spacing[n] / norm / diff; + const PixelRealType val = itk::Math::abs(grad[n]) * m_Spacing[n] / norm / diff; - PixelRealType valNew0 = val0 * val; - PixelRealType valNew1 = val1 * val; + const PixelRealType valNew0 = val0 * val; + const PixelRealType valNew1 = val1 * val; const std::lock_guard lockGuard(m_Mutex); if (itk::Math::abs(static_cast(valNew0)) < itk::Math::abs(static_cast(outNeigIt.GetNext(n, 0)))) { diff --git a/Modules/Filtering/DistanceMap/include/itkReflectiveImageRegionConstIterator.hxx b/Modules/Filtering/DistanceMap/include/itkReflectiveImageRegionConstIterator.hxx index 851b87e8adc..1c142474197 100644 --- a/Modules/Filtering/DistanceMap/include/itkReflectiveImageRegionConstIterator.hxx +++ b/Modules/Filtering/DistanceMap/include/itkReflectiveImageRegionConstIterator.hxx @@ -96,7 +96,7 @@ ReflectiveImageRegionConstIterator::GoToBegin() { m_IsFirstPass[i] = true; - SizeValueType tempSize = size[i]; + const SizeValueType tempSize = size[i]; if (tempSize > 0) { this->m_Remaining = true; diff --git a/Modules/Filtering/DistanceMap/include/itkSignedMaurerDistanceMapImageFilter.hxx b/Modules/Filtering/DistanceMap/include/itkSignedMaurerDistanceMapImageFilter.hxx index d8104c05c1f..81d97432a3b 100644 --- a/Modules/Filtering/DistanceMap/include/itkSignedMaurerDistanceMapImageFilter.hxx +++ b/Modules/Filtering/DistanceMap/include/itkSignedMaurerDistanceMapImageFilter.hxx @@ -71,8 +71,9 @@ SignedMaurerDistanceMapImageFilter::SplitRequestedReg // determine the actual number of pieces that will be generated auto range = static_cast(requestedRegionSize[splitAxis]); - auto valuesPerThread = static_cast(std::ceil(range / static_cast(num))); - unsigned int maxThreadIdUsed = static_cast(std::ceil(range / static_cast(valuesPerThread))) - 1; + auto valuesPerThread = static_cast(std::ceil(range / static_cast(num))); + const unsigned int maxThreadIdUsed = + static_cast(std::ceil(range / static_cast(valuesPerThread))) - 1; // Split the region if (i < maxThreadIdUsed) @@ -100,7 +101,7 @@ template void SignedMaurerDistanceMapImageFilter::GenerateData() { - ThreadIdType numberOfWorkUnits = this->GetNumberOfWorkUnits(); + const ThreadIdType numberOfWorkUnits = this->GetNumberOfWorkUnits(); OutputImageType * outputPtr = this->GetOutput(); const InputImageType * inputPtr = this->GetInput(); @@ -170,9 +171,9 @@ SignedMaurerDistanceMapImageFilter::ThreadedGenerateD { OutputImageType * outputImage = this->GetOutput(); - InputRegionType region = outputRegionForThread; - InputSizeType size = region.GetSize(); - InputIndexType startIndex = outputRegionForThread.GetIndex(); + const InputRegionType region = outputRegionForThread; + InputSizeType size = region.GetSize(); + InputIndexType startIndex = outputRegionForThread.GetIndex(); OutputImageType * outputPtr = this->GetOutput(); @@ -222,10 +223,10 @@ SignedMaurerDistanceMapImageFilter::ThreadedGenerateD // It must be divided by each dimension size in order to get the index for that dimension. // The result of this division is the offsetIndex, which is the index offset relative to the region of this thread. // The true pixel location (idx) is provided by the sum of the offsetIndex and the startIndex. - InputSizeValueType index; - OutputIndexType offsetIndex{}; - InputSizeValueType tempRow = NumberOfRows[m_CurrentDimension]; - OutputIndexType idx{}; + InputSizeValueType index; + OutputIndexType offsetIndex{}; + const InputSizeValueType tempRow = NumberOfRows[m_CurrentDimension]; + OutputIndexType idx{}; for (InputSizeValueType n = 0; n < tempRow; ++n) { @@ -251,7 +252,7 @@ SignedMaurerDistanceMapImageFilter::ThreadedGenerateD using OutputIterator = ImageRegionIterator; using InputIterator = ImageRegionConstIterator; - typename OutputImageType::RegionType outputRegion = outputRegionForThread; + const typename OutputImageType::RegionType outputRegion = outputRegionForThread; OutputIterator Ot(outputPtr, outputRegion); InputIterator It(m_InputCache, outputRegion); @@ -310,15 +311,15 @@ SignedMaurerDistanceMapImageFilter::Voronoi(unsigned OutputIndexType idx, OutputImageType * output) { - OutputRegionType oRegion = output->GetRequestedRegion(); - OutputSizeValueType nd = oRegion.GetSize()[d]; + const OutputRegionType oRegion = output->GetRequestedRegion(); + const OutputSizeValueType nd = oRegion.GetSize()[d]; vnl_vector g(nd, 0); vnl_vector h(nd, 0); - InputRegionType iRegion = m_InputCache->GetRequestedRegion(); - InputIndexType startIndex = iRegion.GetIndex(); + const InputRegionType iRegion = m_InputCache->GetRequestedRegion(); + InputIndexType startIndex = iRegion.GetIndex(); OutputPixelType di; @@ -367,7 +368,7 @@ SignedMaurerDistanceMapImageFilter::Voronoi(unsigned return; } - int ns = l; + const int ns = l; l = 0; @@ -389,7 +390,7 @@ SignedMaurerDistanceMapImageFilter::Voronoi(unsigned while (l < ns) { // be sure to compute d2 *only* if l < ns - OutputPixelType d2 = itk::Math::abs(g(l + 1)) + (h(l + 1) - iw) * (h(l + 1) - iw); + const OutputPixelType d2 = itk::Math::abs(g(l + 1)) + (h(l + 1) - iw) * (h(l + 1) - iw); // then compare d1 and d2 if (d1 <= d2) { @@ -434,11 +435,11 @@ SignedMaurerDistanceMapImageFilter::Remove(OutputPixe OutputPixelType x2, OutputPixelType xf) { - OutputPixelType a = x2 - x1; - OutputPixelType b = xf - x2; - OutputPixelType c = xf - x1; + const OutputPixelType a = x2 - x1; + const OutputPixelType b = xf - x2; + const OutputPixelType c = xf - x1; - OutputPixelType value = (c * itk::Math::abs(d2) - b * itk::Math::abs(d1) - a * itk::Math::abs(df) - a * b * c); + const OutputPixelType value = (c * itk::Math::abs(d2) - b * itk::Math::abs(d1) - a * itk::Math::abs(df) - a * b * c); return (value > 0); } diff --git a/Modules/Filtering/DistanceMap/test/itkApproximateSignedDistanceMapImageFilterTest.cxx b/Modules/Filtering/DistanceMap/test/itkApproximateSignedDistanceMapImageFilterTest.cxx index c16ced70412..61aef911a13 100644 --- a/Modules/Filtering/DistanceMap/test/itkApproximateSignedDistanceMapImageFilterTest.cxx +++ b/Modules/Filtering/DistanceMap/test/itkApproximateSignedDistanceMapImageFilterTest.cxx @@ -32,8 +32,8 @@ template double SimpleSignedDistance(const TPoint & p) { - auto center = itk::MakeFilled(32); - double radius = 16; + auto center = itk::MakeFilled(32); + const double radius = 16; double accum = 0.0; for (unsigned int j = 0; j < TPoint::PointDimension; ++j) @@ -73,9 +73,9 @@ itkApproximateSignedDistanceMapImageFilterTest(int argc, char * argv[]) const InputPixelType insideValue = std::stoi(argv[1]); constexpr InputPixelType outsideValue = 0; - auto image = InputImageType::New(); - auto size = InputImageType::SizeType::Filled(64); - InputImageType::RegionType region(size); + auto image = InputImageType::New(); + auto size = InputImageType::SizeType::Filled(64); + const InputImageType::RegionType region(size); image->SetRegions(region); image->Allocate(); @@ -149,7 +149,7 @@ itkApproximateSignedDistanceMapImageFilterTest(int argc, char * argv[]) { PointType point; image->TransformIndexToPhysicalPoint(oIt.GetIndex(), point); - OutputPixelType distance = itk::Math::abs(oIt.Get() - SimpleSignedDistance(point)); + const OutputPixelType distance = itk::Math::abs(oIt.Get() - SimpleSignedDistance(point)); if (distance > maxDistance) { maxDistance = distance; @@ -158,7 +158,7 @@ itkApproximateSignedDistanceMapImageFilterTest(int argc, char * argv[]) } // Regression test - OutputPixelType maxAllowedDistance = 2; + const OutputPixelType maxAllowedDistance = 2; if (maxDistance > maxAllowedDistance) { std::cout << "Test failed!" << std::endl; diff --git a/Modules/Filtering/DistanceMap/test/itkContourDirectedMeanDistanceImageFilterTest.cxx b/Modules/Filtering/DistanceMap/test/itkContourDirectedMeanDistanceImageFilterTest.cxx index 9491f97c4cb..f088e6b8c06 100644 --- a/Modules/Filtering/DistanceMap/test/itkContourDirectedMeanDistanceImageFilterTest.cxx +++ b/Modules/Filtering/DistanceMap/test/itkContourDirectedMeanDistanceImageFilterTest.cxx @@ -87,7 +87,7 @@ itkContourDirectedMeanDistanceImageFilterTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, ContourDirectedMeanDistanceImageFilter, ImageToImageFilter); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); ITK_TEST_SET_GET_BOOLEAN(filter, UseImageSpacing, useImageSpacing); @@ -98,8 +98,8 @@ itkContourDirectedMeanDistanceImageFilterTest(int, char *[]) // Check results - FilterType::RealType trueDistance = 8.37831; - FilterType::RealType distance = filter->GetContourDirectedMeanDistance(); + const FilterType::RealType trueDistance = 8.37831; + const FilterType::RealType distance = filter->GetContourDirectedMeanDistance(); std::cout << " True distance: " << trueDistance << std::endl; std::cout << " Computed distance: " << distance << std::endl; @@ -127,8 +127,8 @@ itkContourDirectedMeanDistanceImageFilterTest(int, char *[]) // Check results - FilterType::RealType trueDistance = 4.2053; - FilterType::RealType distance = filter->GetContourDirectedMeanDistance(); + const FilterType::RealType trueDistance = 4.2053; + const FilterType::RealType distance = filter->GetContourDirectedMeanDistance(); std::cout << " True distance: " << trueDistance << std::endl; std::cout << " Computed distance: " << distance << std::endl; diff --git a/Modules/Filtering/DistanceMap/test/itkContourMeanDistanceImageFilterTest.cxx b/Modules/Filtering/DistanceMap/test/itkContourMeanDistanceImageFilterTest.cxx index b796221bddb..a5fac8b5c5c 100644 --- a/Modules/Filtering/DistanceMap/test/itkContourMeanDistanceImageFilterTest.cxx +++ b/Modules/Filtering/DistanceMap/test/itkContourMeanDistanceImageFilterTest.cxx @@ -95,7 +95,7 @@ itkContourMeanDistanceImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, ContourMeanDistanceImageFilter, ImageToImageFilter); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); filter->SetInput1(image1); filter->SetInput2(image2); @@ -104,9 +104,9 @@ itkContourMeanDistanceImageFilterTest(int argc, char * argv[]) // check results - FilterType::RealType trueDistance = 8.07158; + const FilterType::RealType trueDistance = 8.07158; // std::sqrt( static_cast(ImageDimension) ); - FilterType::RealType distance = filter->GetMeanDistance(); + const FilterType::RealType distance = filter->GetMeanDistance(); std::cout << " True distance: " << trueDistance << std::endl; std::cout << " Computed distance: " << distance << std::endl; @@ -129,8 +129,8 @@ itkContourMeanDistanceImageFilterTest(int argc, char * argv[]) // check results - FilterType::RealType trueDistance = 8.07158; - FilterType::RealType distance = filter->GetMeanDistance(); + const FilterType::RealType trueDistance = 8.07158; + const FilterType::RealType distance = filter->GetMeanDistance(); std::cout << " True distance: " << trueDistance << std::endl; std::cout << " Computed distance: " << distance << std::endl; @@ -167,8 +167,8 @@ itkContourMeanDistanceImageFilterTest(int argc, char * argv[]) filter->Update(); // check results - FilterType::RealType trueDistance = 8.07158 / 2; - FilterType::RealType distance = filter->GetMeanDistance(); + const FilterType::RealType trueDistance = 8.07158 / 2; + const FilterType::RealType distance = filter->GetMeanDistance(); std::cout << " True distance: " << trueDistance << std::endl; std::cout << " Computed distance: " << distance << std::endl; if (itk::Math::abs(trueDistance - distance) > 0.5) diff --git a/Modules/Filtering/DistanceMap/test/itkDanielssonDistanceMapImageFilterTest.cxx b/Modules/Filtering/DistanceMap/test/itkDanielssonDistanceMapImageFilterTest.cxx index 28a86fb1cf1..f7e6cf4d0e9 100644 --- a/Modules/Filtering/DistanceMap/test/itkDanielssonDistanceMapImageFilterTest.cxx +++ b/Modules/Filtering/DistanceMap/test/itkDanielssonDistanceMapImageFilterTest.cxx @@ -26,7 +26,7 @@ itkDanielssonDistanceMapImageFilterTest(int, char *[]) { // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); std::cout << "Test ITK Danielsson Distance Map" << std::endl << std::endl; std::cout << "Compute the distance map of a 9x9 image" << std::endl; @@ -38,9 +38,9 @@ itkDanielssonDistanceMapImageFilterTest(int, char *[]) using myImageType2D2 = itk::Image; /* Allocate the 2D image */ - myImageType2D1::SizeType size2D = { { 9, 9 } }; - myImageType2D1::IndexType index2D = { { 0, 0 } }; - myImageType2D1::RegionType region2D{ index2D, size2D }; + const myImageType2D1::SizeType size2D = { { 9, 9 } }; + myImageType2D1::IndexType index2D = { { 0, 0 } }; + const myImageType2D1::RegionType region2D{ index2D, size2D }; auto inputImage2D = myImageType2D1::New(); inputImage2D->SetRegions(region2D); @@ -68,13 +68,13 @@ itkDanielssonDistanceMapImageFilterTest(int, char *[]) filter2D->SetInput(inputImage2D); - myImageType2D2::Pointer outputDistance2D = filter2D->GetOutput(); + const myImageType2D2::Pointer outputDistance2D = filter2D->GetOutput(); using VoronoiImageType = myFilterType2D::VoronoiImageType; - VoronoiImageType::Pointer outputVoronoi2D = filter2D->GetVoronoiMap(); + const VoronoiImageType::Pointer outputVoronoi2D = filter2D->GetVoronoiMap(); - myFilterType2D::VectorImagePointer outputComponents = filter2D->GetVectorDistanceMap(); + const myFilterType2D::VectorImagePointer outputComponents = filter2D->GetVectorDistanceMap(); ITK_TRY_EXPECT_NO_EXCEPTION(filter2D->Update()); @@ -125,7 +125,7 @@ itkDanielssonDistanceMapImageFilterTest(int, char *[]) index[1] = 0; const double distance1 = outputDistance2D->GetPixel(index); - bool squaredDistance = true; + const bool squaredDistance = true; ITK_TEST_SET_GET_BOOLEAN(filter2D, SquaredDistance, squaredDistance); ITK_TRY_EXPECT_NO_EXCEPTION(filter2D->Update()); @@ -159,10 +159,10 @@ itkDanielssonDistanceMapImageFilterTest(int, char *[]) filter2D->SetInput(inputImage2D); - bool inputIsBinary = true; + const bool inputIsBinary = true; ITK_TEST_SET_GET_BOOLEAN(filter2D, InputIsBinary, inputIsBinary); - bool useImageSpacing = true; + const bool useImageSpacing = true; ITK_TEST_SET_GET_BOOLEAN(filter2D, UseImageSpacing, useImageSpacing); ITK_TRY_EXPECT_NO_EXCEPTION(filter2D->Update()); @@ -170,7 +170,7 @@ itkDanielssonDistanceMapImageFilterTest(int, char *[]) index2D[1] = 5; auto expectedValue = static_cast(anisotropicSpacing[1]); expectedValue *= expectedValue; - myImageType2D2::PixelType pixelValue = filter2D->GetOutput()->GetPixel(index2D); + const myImageType2D2::PixelType pixelValue = filter2D->GetOutput()->GetPixel(index2D); if (itk::Math::abs(expectedValue - pixelValue) > epsilon) { std::cerr << "Error when image spacing is anisotropic." << std::endl; @@ -186,10 +186,10 @@ itkDanielssonDistanceMapImageFilterTest(int, char *[]) // Allocate the 3D image using ImageType3D = itk::Image; - ImageType3D::SizeType size3D = { { 200, 200, 200 } }; - ImageType3D::IndexType index3D = { { 0, 0 } }; - ImageType3D::RegionType region3D{ index3D, size3D }; - auto inputImage3D = ImageType3D::New(); + ImageType3D::SizeType size3D = { { 200, 200, 200 } }; + const ImageType3D::IndexType index3D = { { 0, 0 } }; + const ImageType3D::RegionType region3D{ index3D, size3D }; + auto inputImage3D = ImageType3D::New(); inputImage3D->SetRegions(region3D); inputImage3D->Allocate(); inputImage3D->FillBuffer(1); @@ -203,7 +203,7 @@ itkDanielssonDistanceMapImageFilterTest(int, char *[]) foregroundSize[i] = 5; foregroundIndex[i] = (size3D[i] / 2) - foregroundSize[i] / 2; } - ImageType3D::RegionType foregroundRegion{ foregroundIndex, foregroundSize }; + const ImageType3D::RegionType foregroundRegion{ foregroundIndex, foregroundSize }; itk::ImageRegionIteratorWithIndex it3D(inputImage3D, foregroundRegion); for (it3D.GoToBegin(); !it3D.IsAtEnd(); ++it3D) diff --git a/Modules/Filtering/DistanceMap/test/itkDirectedHausdorffDistanceImageFilterTest1.cxx b/Modules/Filtering/DistanceMap/test/itkDirectedHausdorffDistanceImageFilterTest1.cxx index 5efd716c666..57546d8d7c3 100644 --- a/Modules/Filtering/DistanceMap/test/itkDirectedHausdorffDistanceImageFilterTest1.cxx +++ b/Modules/Filtering/DistanceMap/test/itkDirectedHausdorffDistanceImageFilterTest1.cxx @@ -84,8 +84,8 @@ itkDirectedHausdorffDistanceImageFilterTest1(int, char *[]) // Compute the directed Hausdorff distance h(image1,image2) { using FilterType = itk::DirectedHausdorffDistanceImageFilter; - auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter, "filter"); + auto filter = FilterType::New(); + const itk::SimpleFilterWatcher watcher(filter, "filter"); filter->SetInput1(image1); filter->SetInput2(image2); diff --git a/Modules/Filtering/DistanceMap/test/itkDirectedHausdorffDistanceImageFilterTest2.cxx b/Modules/Filtering/DistanceMap/test/itkDirectedHausdorffDistanceImageFilterTest2.cxx index 25ea1a77faa..67db67007fb 100644 --- a/Modules/Filtering/DistanceMap/test/itkDirectedHausdorffDistanceImageFilterTest2.cxx +++ b/Modules/Filtering/DistanceMap/test/itkDirectedHausdorffDistanceImageFilterTest2.cxx @@ -59,11 +59,11 @@ itkDirectedHausdorffDistanceImageFilterTest2(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, DirectedHausdorffDistanceImageFilter, ImageToImageFilter); - typename ImageType::Pointer image1 = reader1->GetOutput(); + const typename ImageType::Pointer image1 = reader1->GetOutput(); filter->SetInput1(image1); ITK_TEST_SET_GET_VALUE(image1, filter->GetInput1()); - typename ImageType::Pointer image2 = reader2->GetOutput(); + const typename ImageType::Pointer image2 = reader2->GetOutput(); filter->SetInput2(image2); ITK_TEST_SET_GET_VALUE(image2, filter->GetInput2()); @@ -72,10 +72,10 @@ itkDirectedHausdorffDistanceImageFilterTest2(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); - double expecteDirectedHausdorffDistance = 0; + const double expecteDirectedHausdorffDistance = 0; ITK_TEST_EXPECT_EQUAL(expecteDirectedHausdorffDistance, filter->GetDirectedHausdorffDistance()); - double expecteAverageHausdorffDistance = 0; + const double expecteAverageHausdorffDistance = 0; ITK_TEST_EXPECT_EQUAL(expecteAverageHausdorffDistance, filter->GetAverageHausdorffDistance()); diff --git a/Modules/Filtering/DistanceMap/test/itkFastChamferDistanceImageFilterTest.cxx b/Modules/Filtering/DistanceMap/test/itkFastChamferDistanceImageFilterTest.cxx index bd8a22c9b35..5f8af0a95f9 100644 --- a/Modules/Filtering/DistanceMap/test/itkFastChamferDistanceImageFilterTest.cxx +++ b/Modules/Filtering/DistanceMap/test/itkFastChamferDistanceImageFilterTest.cxx @@ -26,8 +26,8 @@ template double SimpleSignedDistance(const TPoint & p) { - auto center = itk::MakeFilled(16); - double radius = 10; + auto center = itk::MakeFilled(16); + const double radius = 10; double accum = 0.0; for (unsigned int j = 0; j < TPoint::PointDimension; ++j) @@ -66,9 +66,9 @@ FastChamferDistanceImageFilterTest(unsigned int iPositive, unsigned int iNegativ using ImageType = itk::Image; using PointType = itk::Point; - auto size = ImageType::SizeType::Filled(32); - typename ImageType::IndexType index{}; - typename ImageType::RegionType region{ index, size }; + auto size = ImageType::SizeType::Filled(32); + const typename ImageType::IndexType index{}; + const typename ImageType::RegionType region{ index, size }; auto inputImage = ImageType::New(); inputImage->SetRegions(region); @@ -92,7 +92,7 @@ FastChamferDistanceImageFilterTest(unsigned int iPositive, unsigned int iNegativ filter->SetInput(inputImage); - typename ImageType::Pointer outputImage = filter->GetOutput(); + const typename ImageType::Pointer outputImage = filter->GetOutput(); try { @@ -122,8 +122,8 @@ FastChamferDistanceImageFilterTest(unsigned int iPositive, unsigned int iNegativ // Loop through the band using itNBType = typename NarrowBandType::ConstIterator; - itNBType itNB = band->Begin(); - itNBType itNBend = band->End(); + itNBType itNB = band->Begin(); + const itNBType itNBend = band->End(); // BandNodeType *tmp; unsigned int innerpositive = 0; @@ -216,7 +216,7 @@ itkFastChamferDistanceImageFilterTest(int argc, char * argv[]) return EXIT_FAILURE; } - int Dimension = std::stoi(argv[1]); + const int Dimension = std::stoi(argv[1]); std::cout << "Dimension = " << Dimension << std::endl; if (Dimension == 1) diff --git a/Modules/Filtering/DistanceMap/test/itkIsoContourDistanceImageFilterTest.cxx b/Modules/Filtering/DistanceMap/test/itkIsoContourDistanceImageFilterTest.cxx index 63021f841fe..f7493961e0c 100644 --- a/Modules/Filtering/DistanceMap/test/itkIsoContourDistanceImageFilterTest.cxx +++ b/Modules/Filtering/DistanceMap/test/itkIsoContourDistanceImageFilterTest.cxx @@ -47,8 +47,8 @@ template double SimpleSignedDistance(const TPoint & p) { - auto center = itk::MakeFilled(50); - double radius = 19.5; + auto center = itk::MakeFilled(50); + const double radius = 19.5; double accum = 0.0; for (unsigned int j = 0; j < TPoint::PointDimension; ++j) @@ -72,9 +72,9 @@ itkIsoContourDistanceImageFilterTest(int, char *[]) using PointType = itk::Point; // Fill an input image with simple signed distance function - auto image = ImageType::New(); - auto size = ImageType::SizeType::Filled(128); - ImageType::RegionType region(size); + auto image = ImageType::New(); + auto size = ImageType::SizeType::Filled(128); + const ImageType::RegionType region(size); image->SetRegions(region); image->Allocate(); @@ -177,8 +177,8 @@ itkIsoContourDistanceImageFilterTest(int, char *[]) auto calculator = CalculatorType::New(); calculator->SetImage(checker->GetOutput()); calculator->Compute(); - double minValue = calculator->GetMinimum(); - double maxValue = calculator->GetMaximum(); + const double minValue = calculator->GetMinimum(); + const double maxValue = calculator->GetMaximum(); std::cout << "Min. product = " << minValue << std::endl; std::cout << "Max. product = " << maxValue << std::endl; diff --git a/Modules/Filtering/DistanceMap/test/itkReflectiveImageRegionIteratorTest.cxx b/Modules/Filtering/DistanceMap/test/itkReflectiveImageRegionIteratorTest.cxx index 1abb28cdea9..2cc4df10188 100644 --- a/Modules/Filtering/DistanceMap/test/itkReflectiveImageRegionIteratorTest.cxx +++ b/Modules/Filtering/DistanceMap/test/itkReflectiveImageRegionIteratorTest.cxx @@ -35,11 +35,11 @@ itkReflectiveImageRegionIteratorTest(int, char *[]) auto myImage = ImageType::New(); - ImageType::SizeType size = { { 4, 4, 4, 4 } }; + const ImageType::SizeType size = { { 4, 4, 4, 4 } }; - ImageType::IndexType start{}; + const ImageType::IndexType start{}; - ImageType::RegionType region{ start, size }; + const ImageType::RegionType region{ start, size }; myImage->SetRegions(region); myImage->Allocate(); @@ -81,8 +81,8 @@ itkReflectiveImageRegionIteratorTest(int, char *[]) rvt.GoToBegin(); while (!rit.IsAtEnd()) { - PixelType value = rit.Get(); - ImageType::IndexType index = rit.GetIndex(); + const PixelType value = rit.Get(); + const ImageType::IndexType index = rit.GetIndex(); rvt.Set(rvt.Get() + 1); if (value != index) { @@ -96,8 +96,8 @@ itkReflectiveImageRegionIteratorTest(int, char *[]) // Each element should be visited 2 ^ # of dimensions // each left shift = multiply by 2 - int visits = (1 << (ImageType::ImageDimension)); - int failed = 0; + const int visits = (1 << (ImageType::ImageDimension)); + int failed = 0; // Verify the number of visits vit.GoToBegin(); diff --git a/Modules/Filtering/DistanceMap/test/itkSignedDanielssonDistanceMapImageFilterTest.cxx b/Modules/Filtering/DistanceMap/test/itkSignedDanielssonDistanceMapImageFilterTest.cxx index 19f8ba6a51a..0afde14c9ac 100644 --- a/Modules/Filtering/DistanceMap/test/itkSignedDanielssonDistanceMapImageFilterTest.cxx +++ b/Modules/Filtering/DistanceMap/test/itkSignedDanielssonDistanceMapImageFilterTest.cxx @@ -40,7 +40,7 @@ test(int testIdx) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope // scope. - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); constexpr unsigned int Dimension = 2; using PixelType = float; @@ -56,7 +56,7 @@ test(int testIdx) myImageType2D1::IndexType index2D{}; - myImageType2D1::RegionType region2D{ index2D, size2D }; + const myImageType2D1::RegionType region2D{ index2D, size2D }; auto inputImage2D = myImageType2D1::New(); inputImage2D->SetRegions(region2D); @@ -104,13 +104,13 @@ test(int testIdx) auto filter2D = myFilterType2D::New(); filter2D->SetInput(inputImage2D); - myImageType2D2::Pointer outputDistance2D = filter2D->GetOutput(); + const myImageType2D2::Pointer outputDistance2D = filter2D->GetOutput(); using VoronoiImageType = myFilterType2D::VoronoiImageType; - VoronoiImageType::Pointer outputVoronoi2D = filter2D->GetVoronoiMap(); + const VoronoiImageType::Pointer outputVoronoi2D = filter2D->GetVoronoiMap(); - myFilterType2D::VectorImageType::Pointer outputComponents = filter2D->GetVectorDistanceMap(); + const myFilterType2D::VectorImageType::Pointer outputComponents = filter2D->GetVectorDistanceMap(); filter2D->Update(); diff --git a/Modules/Filtering/DistanceMap/test/itkSignedDanielssonDistanceMapImageFilterTest11.cxx b/Modules/Filtering/DistanceMap/test/itkSignedDanielssonDistanceMapImageFilterTest11.cxx index f2c8668b482..9b02d243b17 100644 --- a/Modules/Filtering/DistanceMap/test/itkSignedDanielssonDistanceMapImageFilterTest11.cxx +++ b/Modules/Filtering/DistanceMap/test/itkSignedDanielssonDistanceMapImageFilterTest11.cxx @@ -25,7 +25,7 @@ itkSignedDanielssonDistanceMapImageFilterTest11(int, char *[]) { // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); std::cout << "Test ITK Liza Signed Danielsson Distance Map" << std::endl << std::endl; std::cout << "Compute the distance map of a 5x5 image" << std::endl; @@ -35,9 +35,9 @@ itkSignedDanielssonDistanceMapImageFilterTest11(int, char *[]) using myImageType2D2 = itk::Image; /* Allocate the 2D image */ - myImageType2D1::SizeType size2D = { { 5, 5 } }; - myImageType2D1::IndexType index2D = { { 0, 0 } }; - myImageType2D1::RegionType region2D{ index2D, size2D }; + const myImageType2D1::SizeType size2D = { { 5, 5 } }; + myImageType2D1::IndexType index2D = { { 0, 0 } }; + const myImageType2D1::RegionType region2D{ index2D, size2D }; auto inputImage2D = myImageType2D1::New(); inputImage2D->SetRegions(region2D); @@ -59,7 +59,7 @@ itkSignedDanielssonDistanceMapImageFilterTest11(int, char *[]) filter2D->SetInput(inputImage2D); - myImageType2D2::Pointer outputDistance2D = filter2D->GetOutput(); + const myImageType2D2::Pointer outputDistance2D = filter2D->GetOutput(); filter2D->Update(); ShowDistanceMap(outputDistance2D); @@ -135,7 +135,7 @@ itkSignedDanielssonDistanceMapImageFilterTest11(int, char *[]) return EXIT_FAILURE; } filter2D->SetUseImageSpacing(true); - myImageType2D2::Pointer outputDistance2D2 = filter2D->GetOutput(); + const myImageType2D2::Pointer outputDistance2D2 = filter2D->GetOutput(); filter2D->Update(); std::cout << "Use ImageSpacing Distance Map with squared distance turned off" << std::endl; diff --git a/Modules/Filtering/DistanceMap/test/itkSignedMaurerDistanceMapImageFilterTest11.cxx b/Modules/Filtering/DistanceMap/test/itkSignedMaurerDistanceMapImageFilterTest11.cxx index 7eba7dbf63e..755bebdfb91 100644 --- a/Modules/Filtering/DistanceMap/test/itkSignedMaurerDistanceMapImageFilterTest11.cxx +++ b/Modules/Filtering/DistanceMap/test/itkSignedMaurerDistanceMapImageFilterTest11.cxx @@ -25,7 +25,7 @@ itkSignedMaurerDistanceMapImageFilterTest11(int, char *[]) { // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); std::cout << "Test ITK Liza Signed Maurer Distance Map" << std::endl << std::endl; std::cout << "Compute the distance map of a 5x5 image" << std::endl; @@ -35,9 +35,9 @@ itkSignedMaurerDistanceMapImageFilterTest11(int, char *[]) using myImageType2D2 = itk::Image; /* Allocate the 2D image */ - myImageType2D1::SizeType size2D = { { 5, 5 } }; - myImageType2D1::IndexType index2D = { { 0, 0 } }; - myImageType2D1::RegionType region2D; + const myImageType2D1::SizeType size2D = { { 5, 5 } }; + myImageType2D1::IndexType index2D = { { 0, 0 } }; + myImageType2D1::RegionType region2D; region2D.SetSize(size2D); region2D.SetIndex(index2D); @@ -61,7 +61,7 @@ itkSignedMaurerDistanceMapImageFilterTest11(int, char *[]) filter2D->SetInput(inputImage2D); - myImageType2D2::Pointer outputDistance2D = filter2D->GetOutput(); + const myImageType2D2::Pointer outputDistance2D = filter2D->GetOutput(); filter2D->Update(); ShowDistanceMap(outputDistance2D); @@ -143,7 +143,7 @@ itkSignedMaurerDistanceMapImageFilterTest11(int, char *[]) return EXIT_FAILURE; } filter2D->SetUseImageSpacing(true); - myImageType2D2::Pointer outputDistance2D2 = filter2D->GetOutput(); + const myImageType2D2::Pointer outputDistance2D2 = filter2D->GetOutput(); filter2D->Update(); /* Show ImageSpacing Distance map */ diff --git a/Modules/Filtering/FFT/include/itkComplexToComplex1DFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkComplexToComplex1DFFTImageFilter.hxx index 2ffc8d58065..50aeac6fe0b 100644 --- a/Modules/Filtering/FFT/include/itkComplexToComplex1DFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkComplexToComplex1DFFTImageFilter.hxx @@ -36,8 +36,8 @@ ComplexToComplex1DFFTImageFilter::GenerateInputReques Superclass::GenerateInputRequestedRegion(); // get pointers to the inputs - typename InputImageType::Pointer inputPtr = const_cast(this->GetInput()); - typename OutputImageType::Pointer outputPtr = this->GetOutput(); + const typename InputImageType::Pointer inputPtr = const_cast(this->GetInput()); + const typename OutputImageType::Pointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { diff --git a/Modules/Filtering/FFT/include/itkComplexToComplexFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkComplexToComplexFFTImageFilter.hxx index e6faadd8ec0..a298f4a43a8 100644 --- a/Modules/Filtering/FFT/include/itkComplexToComplexFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkComplexToComplexFFTImageFilter.hxx @@ -42,7 +42,7 @@ ComplexToComplexFFTImageFilter::GenerateInputRequeste { Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - typename InputImageType::Pointer input = const_cast(this->GetInput()); + const typename InputImageType::Pointer input = const_cast(this->GetInput()); input->SetRequestedRegionToLargestPossibleRegion(); } diff --git a/Modules/Filtering/FFT/include/itkFFTPadImageFilter.hxx b/Modules/Filtering/FFT/include/itkFFTPadImageFilter.hxx index 731f73ed516..c5bd1320fbe 100644 --- a/Modules/Filtering/FFT/include/itkFFTPadImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkFFTPadImageFilter.hxx @@ -49,9 +49,9 @@ FFTPadImageFilter::GenerateOutputInformation() const InputImageType * input0 = this->GetInput(); OutputImageType * output0 = this->GetOutput(); - RegionType region0 = input0->GetLargestPossibleRegion(); - SizeType size; - IndexType index; + const RegionType region0 = input0->GetLargestPossibleRegion(); + SizeType size; + IndexType index; for (unsigned int i = 0; i < ImageDimension; ++i) { SizeValueType padSize = 0; @@ -70,7 +70,7 @@ FFTPadImageFilter::GenerateOutputInformation() index[i] = region0.GetIndex()[i] - padSize / 2; size[i] = region0.GetSize()[i] + padSize; } - RegionType region(index, size); + const RegionType region(index, size); output0->SetLargestPossibleRegion(region); } diff --git a/Modules/Filtering/FFT/include/itkFFTWComplexToComplexFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkFFTWComplexToComplexFFTImageFilter.hxx index 1f15bbd5393..e89cc5b5013 100644 --- a/Modules/Filtering/FFT/include/itkFFTWComplexToComplexFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkFFTWComplexToComplexFFTImageFilter.hxx @@ -61,7 +61,7 @@ FFTWComplexToComplexFFTImageFilter::BeforeThreadedGen // we don't have a nice progress to report, but at least this simple line // reports the beginning and the end of the process - ProgressReporter progress(this, 0, 1); + const ProgressReporter progress(this, 0, 1); // allocate output buffer memory output->SetBufferedRegion(output->GetRequestedRegion()); @@ -110,8 +110,8 @@ FFTWComplexToComplexFFTImageFilter::DynamicThreadedGe if (this->GetTransformDirection() == Superclass::TransformDirectionEnum::INVERSE) { using IteratorType = ImageRegionIterator; - SizeValueType totalOutputSize = this->GetOutput()->GetRequestedRegion().GetNumberOfPixels(); - IteratorType it(this->GetOutput(), outputRegionForThread); + const SizeValueType totalOutputSize = this->GetOutput()->GetRequestedRegion().GetNumberOfPixels(); + IteratorType it(this->GetOutput(), outputRegionForThread); while (!it.IsAtEnd()) { PixelType val = it.Value(); diff --git a/Modules/Filtering/FFT/include/itkFFTWForwardFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkFFTWForwardFFTImageFilter.hxx index b9c2851d7c5..76f4d189eed 100644 --- a/Modules/Filtering/FFT/include/itkFFTWForwardFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkFFTWForwardFFTImageFilter.hxx @@ -46,8 +46,8 @@ void FFTWForwardFFTImageFilter::GenerateData() { // Get pointers to the input and output. - typename InputImageType::ConstPointer inputPtr = this->GetInput(); - typename OutputImageType::Pointer outputPtr = this->GetOutput(); + const typename InputImageType::ConstPointer inputPtr = this->GetInput(); + const typename OutputImageType::Pointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -56,7 +56,7 @@ FFTWForwardFFTImageFilter::GenerateData() // We don't have a nice progress to report, but at least this simple line // reports the beginning and the end of the process. - ProgressReporter progress(this, 0, 1); + const ProgressReporter progress(this, 0, 1); // allocate output buffer memory outputPtr->SetBufferedRegion(outputPtr->GetRequestedRegion()); diff --git a/Modules/Filtering/FFT/include/itkFFTWHalfHermitianToRealInverseFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkFFTWHalfHermitianToRealInverseFFTImageFilter.hxx index 864bd3e43c9..3e806a78b98 100644 --- a/Modules/Filtering/FFT/include/itkFFTWHalfHermitianToRealInverseFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkFFTWHalfHermitianToRealInverseFFTImageFilter.hxx @@ -39,8 +39,8 @@ void FFTWHalfHermitianToRealInverseFFTImageFilter::BeforeThreadedGenerateData() { // Get pointers to the input and output. - typename InputImageType::ConstPointer inputPtr = this->GetInput(); - typename OutputImageType::Pointer outputPtr = this->GetOutput(); + typename InputImageType::ConstPointer inputPtr = this->GetInput(); + const typename OutputImageType::Pointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -49,7 +49,7 @@ FFTWHalfHermitianToRealInverseFFTImageFilter::BeforeT // We don't have a nice progress to report, but at least this simple line // reports the beginning and the end of the process. - ProgressReporter progress(this, 0, 1); + const ProgressReporter progress(this, 0, 1); // Allocate output buffer memory. outputPtr->SetBufferedRegion(outputPtr->GetRequestedRegion()); @@ -127,8 +127,8 @@ FFTWHalfHermitianToRealInverseFFTImageFilter::Dynamic const OutputRegionType & outputRegionForThread) { using IteratorType = ImageRegionIterator; - unsigned long totalOutputSize = this->GetOutput()->GetRequestedRegion().GetNumberOfPixels(); - IteratorType it(this->GetOutput(), outputRegionForThread); + const unsigned long totalOutputSize = this->GetOutput()->GetRequestedRegion().GetNumberOfPixels(); + IteratorType it(this->GetOutput(), outputRegionForThread); while (!it.IsAtEnd()) { it.Set(it.Value() / totalOutputSize); diff --git a/Modules/Filtering/FFT/include/itkFFTWInverseFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkFFTWInverseFFTImageFilter.hxx index f6139deaa3e..b6773e0af59 100644 --- a/Modules/Filtering/FFT/include/itkFFTWInverseFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkFFTWInverseFFTImageFilter.hxx @@ -41,8 +41,8 @@ void FFTWInverseFFTImageFilter::BeforeThreadedGenerateData() { // Get pointers to the input and output. - typename InputImageType::ConstPointer inputPtr = this->GetInput(); - typename OutputImageType::Pointer outputPtr = this->GetOutput(); + const typename InputImageType::ConstPointer inputPtr = this->GetInput(); + const typename OutputImageType::Pointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -51,7 +51,7 @@ FFTWInverseFFTImageFilter::BeforeThreadedGenerateData // We don't have a nice progress to report, but at least this simple line // reports the beginning and the end of the process. - ProgressReporter progress(this, 0, 1); + const ProgressReporter progress(this, 0, 1); // Allocate output buffer memory. outputPtr->SetBufferedRegion(outputPtr->GetRequestedRegion()); @@ -105,8 +105,8 @@ FFTWInverseFFTImageFilter::DynamicThreadedGenerateDat const OutputImageRegionType & outputRegionForThread) { using IteratorType = ImageRegionIterator; - unsigned long totalOutputSize = this->GetOutput()->GetRequestedRegion().GetNumberOfPixels(); - IteratorType it(this->GetOutput(), outputRegionForThread); + const unsigned long totalOutputSize = this->GetOutput()->GetRequestedRegion().GetNumberOfPixels(); + IteratorType it(this->GetOutput(), outputRegionForThread); while (!it.IsAtEnd()) { it.Set(it.Value() / totalOutputSize); diff --git a/Modules/Filtering/FFT/include/itkFFTWRealToHalfHermitianForwardFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkFFTWRealToHalfHermitianForwardFFTImageFilter.hxx index c1a41f0ce16..a6a1fd22794 100644 --- a/Modules/Filtering/FFT/include/itkFFTWRealToHalfHermitianForwardFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkFFTWRealToHalfHermitianForwardFFTImageFilter.hxx @@ -41,8 +41,8 @@ void FFTWRealToHalfHermitianForwardFFTImageFilter::GenerateData() { // Get pointers to the input and output. - typename InputImageType::ConstPointer inputPtr = this->GetInput(); - typename OutputImageType::Pointer outputPtr = this->GetOutput(); + const typename InputImageType::ConstPointer inputPtr = this->GetInput(); + const typename OutputImageType::Pointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -51,7 +51,7 @@ FFTWRealToHalfHermitianForwardFFTImageFilter::Generat // We don't have a nice progress to report, but at least this simple line // reports the beginning and the end of the process. - ProgressReporter progress(this, 0, 1); + const ProgressReporter progress(this, 0, 1); // allocate output buffer memory outputPtr->SetBufferedRegion(outputPtr->GetRequestedRegion()); diff --git a/Modules/Filtering/FFT/include/itkForwardFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkForwardFFTImageFilter.hxx index b3c9c06a290..e42b55e6390 100644 --- a/Modules/Filtering/FFT/include/itkForwardFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkForwardFFTImageFilter.hxx @@ -30,7 +30,7 @@ ForwardFFTImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // Get pointer to the input. - typename InputImageType::Pointer input = const_cast(this->GetInput()); + const typename InputImageType::Pointer input = const_cast(this->GetInput()); if (!input) { diff --git a/Modules/Filtering/FFT/include/itkFullToHalfHermitianImageFilter.hxx b/Modules/Filtering/FFT/include/itkFullToHalfHermitianImageFilter.hxx index b74dbc372ab..8200112835f 100644 --- a/Modules/Filtering/FFT/include/itkFullToHalfHermitianImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkFullToHalfHermitianImageFilter.hxx @@ -40,8 +40,8 @@ FullToHalfHermitianImageFilter::GenerateOutputInformation() Superclass::GenerateOutputInformation(); // Get pointers to the input and output - typename InputImageType::ConstPointer inputPtr = this->GetInput(); - typename OutputImageType::Pointer outputPtr = this->GetOutput(); + const typename InputImageType::ConstPointer inputPtr = this->GetInput(); + const typename OutputImageType::Pointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -74,7 +74,7 @@ FullToHalfHermitianImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // Get pointers to the input and output - typename InputImageType::Pointer inputPtr = const_cast(this->GetInput()); + const typename InputImageType::Pointer inputPtr = const_cast(this->GetInput()); if (inputPtr) { inputPtr->SetRequestedRegionToLargestPossibleRegion(); @@ -86,8 +86,8 @@ void FullToHalfHermitianImageFilter::DynamicThreadedGenerateData( const OutputImageRegionType & outputRegionForThread) { - typename InputImageType::ConstPointer inputPtr = this->GetInput(); - typename OutputImageType::Pointer outputPtr = this->GetOutput(); + const typename InputImageType::ConstPointer inputPtr = this->GetInput(); + const typename OutputImageType::Pointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { diff --git a/Modules/Filtering/FFT/include/itkHalfHermitianToRealInverseFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkHalfHermitianToRealInverseFFTImageFilter.hxx index c0b08d2ddfa..a19e4f44b47 100644 --- a/Modules/Filtering/FFT/include/itkHalfHermitianToRealInverseFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkHalfHermitianToRealInverseFFTImageFilter.hxx @@ -35,8 +35,8 @@ HalfHermitianToRealInverseFFTImageFilter::GenerateOut Superclass::GenerateOutputInformation(); // get pointers to the input and output - typename InputImageType::ConstPointer inputPtr = this->GetInput(); - typename OutputImageType::Pointer outputPtr = this->GetOutput(); + const typename InputImageType::ConstPointer inputPtr = this->GetInput(); + const typename OutputImageType::Pointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -87,7 +87,7 @@ HalfHermitianToRealInverseFFTImageFilter::GenerateInp Superclass::GenerateInputRequestedRegion(); // Get pointers to the input and output - typename InputImageType::Pointer inputPtr = const_cast(this->GetInput()); + const typename InputImageType::Pointer inputPtr = const_cast(this->GetInput()); if (inputPtr) { inputPtr->SetRequestedRegionToLargestPossibleRegion(); diff --git a/Modules/Filtering/FFT/include/itkHalfToFullHermitianImageFilter.hxx b/Modules/Filtering/FFT/include/itkHalfToFullHermitianImageFilter.hxx index 772f359c295..bd54acd4e48 100644 --- a/Modules/Filtering/FFT/include/itkHalfToFullHermitianImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkHalfToFullHermitianImageFilter.hxx @@ -42,8 +42,8 @@ HalfToFullHermitianImageFilter::GenerateOutputInformation() Superclass::GenerateOutputInformation(); // Get pointers to the input and output - typename InputImageType::ConstPointer inputPtr = this->GetInput(); - typename OutputImageType::Pointer outputPtr = this->GetOutput(); + const typename InputImageType::ConstPointer inputPtr = this->GetInput(); + const typename OutputImageType::Pointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -79,7 +79,7 @@ HalfToFullHermitianImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // Get pointers to the input and output - typename InputImageType::Pointer inputPtr = const_cast(this->GetInput()); + const typename InputImageType::Pointer inputPtr = const_cast(this->GetInput()); if (inputPtr) { inputPtr->SetRequestedRegionToLargestPossibleRegion(); @@ -91,22 +91,22 @@ void HalfToFullHermitianImageFilter::DynamicThreadedGenerateData( const OutputImageRegionType & outputRegionForThread) { - typename InputImageType::ConstPointer inputPtr = this->GetInput(); - typename OutputImageType::Pointer outputPtr = this->GetOutput(); + const typename InputImageType::ConstPointer inputPtr = this->GetInput(); + const typename OutputImageType::Pointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { return; } - InputImageRegionType inputRegion = inputPtr->GetLargestPossibleRegion(); + const InputImageRegionType inputRegion = inputPtr->GetLargestPossibleRegion(); const InputImageIndexType & inputRegionIndex = inputRegion.GetIndex(); const InputImageSizeType & inputRegionSize = inputRegion.GetSize(); InputImageIndexType inputRegionMaximumIndex = inputRegionIndex + inputRegionSize; // Copy the non-reflected region. OutputImageRegionType copyRegion(outputRegionForThread); - bool copy = copyRegion.Crop(inputRegion); + const bool copy = copyRegion.Crop(inputRegion); // Set up the ProgressReporter. TotalProgressReporter progress(this, outputPtr->GetRequestedRegion().GetNumberOfPixels()); @@ -119,9 +119,9 @@ HalfToFullHermitianImageFilter::DynamicThreadedGenerateData( // Now copy the redundant complex conjugate region, if there is one // in this thread's output region. - OutputImageIndexType outputRegionIndex = outputRegionForThread.GetIndex(); - OutputImageSizeType outputRegionSize = outputRegionForThread.GetSize(); - OutputImageIndexType outputRegionMaximumIndex = outputRegionIndex + outputRegionSize; + OutputImageIndexType outputRegionIndex = outputRegionForThread.GetIndex(); + const OutputImageSizeType outputRegionSize = outputRegionForThread.GetSize(); + OutputImageIndexType outputRegionMaximumIndex = outputRegionIndex + outputRegionSize; if (outputRegionMaximumIndex[0] > inputRegionMaximumIndex[0]) { @@ -129,7 +129,7 @@ HalfToFullHermitianImageFilter::DynamicThreadedGenerateData( conjugateRegionIndex[0] = std::max(outputRegionIndex[0], inputRegionMaximumIndex[0]); OutputImageSizeType conjugateRegionSize(outputRegionSize); conjugateRegionSize[0] = outputRegionMaximumIndex[0] - conjugateRegionIndex[0]; - OutputImageRegionType conjugateRegion(conjugateRegionIndex, conjugateRegionSize); + const OutputImageRegionType conjugateRegion(conjugateRegionIndex, conjugateRegionSize); ImageRegionIteratorWithIndex oIt(outputPtr, conjugateRegion); for (oIt.GoToBegin(); !oIt.IsAtEnd(); ++oIt) @@ -140,9 +140,9 @@ HalfToFullHermitianImageFilter::DynamicThreadedGenerateData( OutputImageIndexType index(conjugateIndex); for (unsigned int i = 0; i < ImageDimension; ++i) { - OutputImageRegionType outputLargestPossibleRegion = outputPtr->GetLargestPossibleRegion(); - OutputImageIndexType outputLargestPossibleRegionIndex = outputLargestPossibleRegion.GetIndex(); - OutputImageSizeType outputLargestPossibleRegionSize = outputLargestPossibleRegion.GetSize(); + const OutputImageRegionType outputLargestPossibleRegion = outputPtr->GetLargestPossibleRegion(); + OutputImageIndexType outputLargestPossibleRegionIndex = outputLargestPossibleRegion.GetIndex(); + OutputImageSizeType outputLargestPossibleRegionSize = outputLargestPossibleRegion.GetSize(); if (conjugateIndex[i] != outputLargestPossibleRegionIndex[i]) { index[i] = outputLargestPossibleRegionSize[i] - conjugateIndex[i] + 2 * outputLargestPossibleRegionIndex[i]; diff --git a/Modules/Filtering/FFT/include/itkInverse1DFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkInverse1DFFTImageFilter.hxx index 2ac5b90b3e6..883eb6377e3 100644 --- a/Modules/Filtering/FFT/include/itkInverse1DFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkInverse1DFFTImageFilter.hxx @@ -38,8 +38,8 @@ Inverse1DFFTImageFilter::GenerateInputRequestedRegion Superclass::GenerateInputRequestedRegion(); // get pointers to the inputs - typename InputImageType::Pointer input = const_cast(this->GetInput()); - typename OutputImageType::Pointer output = this->GetOutput(); + const typename InputImageType::Pointer input = const_cast(this->GetInput()); + const typename OutputImageType::Pointer output = this->GetOutput(); if (!input || !output) { diff --git a/Modules/Filtering/FFT/include/itkInverseFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkInverseFFTImageFilter.hxx index 3303f3e0842..d45045fbf37 100644 --- a/Modules/Filtering/FFT/include/itkInverseFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkInverseFFTImageFilter.hxx @@ -28,7 +28,7 @@ InverseFFTImageFilter::GenerateInputRequestedRegion() { Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - typename InputImageType::Pointer inputPtr = const_cast(this->GetInput()); + const typename InputImageType::Pointer inputPtr = const_cast(this->GetInput()); if (inputPtr) { inputPtr->SetRequestedRegionToLargestPossibleRegion(); diff --git a/Modules/Filtering/FFT/include/itkRealToHalfHermitianForwardFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkRealToHalfHermitianForwardFFTImageFilter.hxx index 857e7a299f2..63f16651dcc 100644 --- a/Modules/Filtering/FFT/include/itkRealToHalfHermitianForwardFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkRealToHalfHermitianForwardFFTImageFilter.hxx @@ -32,8 +32,8 @@ void RealToHalfHermitianForwardFFTImageFilter::GenerateOutputInformation() { // Get pointers to the input and output. - typename InputImageType::ConstPointer inputPtr = this->GetInput(); - typename OutputImageType::Pointer outputPtr = this->GetOutput(); + const typename InputImageType::ConstPointer inputPtr = this->GetInput(); + const typename OutputImageType::Pointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -78,7 +78,7 @@ RealToHalfHermitianForwardFFTImageFilter::GenerateInp Superclass::GenerateInputRequestedRegion(); // Get pointer to the input. - typename InputImageType::Pointer input = const_cast(this->GetInput()); + const typename InputImageType::Pointer input = const_cast(this->GetInput()); if (!input) { diff --git a/Modules/Filtering/FFT/include/itkVnlComplexToComplexFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkVnlComplexToComplexFFTImageFilter.hxx index 0f52e4cd3cf..63f07db7735 100644 --- a/Modules/Filtering/FFT/include/itkVnlComplexToComplexFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkVnlComplexToComplexFFTImageFilter.hxx @@ -83,8 +83,8 @@ VnlComplexToComplexFFTImageFilter::DynamicThreadedGen if (this->GetTransformDirection() == Superclass::TransformDirectionEnum::INVERSE) { using IteratorType = ImageRegionIterator; - SizeValueType totalOutputSize = this->GetOutput()->GetRequestedRegion().GetNumberOfPixels(); - IteratorType it(this->GetOutput(), outputRegionForThread); + const SizeValueType totalOutputSize = this->GetOutput()->GetRequestedRegion().GetNumberOfPixels(); + IteratorType it(this->GetOutput(), outputRegionForThread); while (!it.IsAtEnd()) { PixelType val = it.Value(); diff --git a/Modules/Filtering/FFT/include/itkVnlForward1DFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkVnlForward1DFFTImageFilter.hxx index 2c653cbc78f..5f1c59ef59a 100644 --- a/Modules/Filtering/FFT/include/itkVnlForward1DFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkVnlForward1DFFTImageFilter.hxx @@ -45,7 +45,7 @@ VnlForward1DFFTImageFilter::GenerateData() const typename Superclass::InputImageType::SizeType & inputSize = input->GetRequestedRegion().GetSize(); const unsigned int direction = this->GetDirection(); - unsigned int vectorSize = inputSize[direction]; + const unsigned int vectorSize = inputSize[direction]; if (!VnlFFTCommon::IsDimensionSizeLegal(vectorSize)) { itkExceptionMacro("Illegal Array DIM for FFT"); diff --git a/Modules/Filtering/FFT/include/itkVnlForwardFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkVnlForwardFFTImageFilter.hxx index a822ca5ae11..d4dfa318010 100644 --- a/Modules/Filtering/FFT/include/itkVnlForwardFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkVnlForwardFFTImageFilter.hxx @@ -30,8 +30,8 @@ void VnlForwardFFTImageFilter::GenerateData() { // Get pointers to the input and output. - typename InputImageType::ConstPointer inputPtr = this->GetInput(); - typename OutputImageType::Pointer outputPtr = this->GetOutput(); + const typename InputImageType::ConstPointer inputPtr = this->GetInput(); + const typename OutputImageType::Pointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -40,7 +40,7 @@ VnlForwardFFTImageFilter::GenerateData() // We don't have a nice progress to report, but at least this simple line // reports the beginning and the end of the process. - ProgressReporter progress(this, 0, 1); + const ProgressReporter progress(this, 0, 1); const InputSizeType inputSize = inputPtr->GetLargestPossibleRegion().GetSize(); @@ -75,8 +75,8 @@ VnlForwardFFTImageFilter::GenerateData() for (ImageRegionIteratorWithIndex oIt(outputPtr, outputPtr->GetLargestPossibleRegion()); !oIt.IsAtEnd(); ++oIt) { - typename OutputImageType::IndexType index = oIt.GetIndex(); - typename OutputImageType::OffsetValueType offset = inputPtr->ComputeOffset(index); + const typename OutputImageType::IndexType index = oIt.GetIndex(); + const typename OutputImageType::OffsetValueType offset = inputPtr->ComputeOffset(index); oIt.Set(signal[offset]); } } diff --git a/Modules/Filtering/FFT/include/itkVnlHalfHermitianToRealInverseFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkVnlHalfHermitianToRealInverseFFTImageFilter.hxx index 80509d81ac9..1d9d86e0ddf 100644 --- a/Modules/Filtering/FFT/include/itkVnlHalfHermitianToRealInverseFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkVnlHalfHermitianToRealInverseFFTImageFilter.hxx @@ -29,8 +29,8 @@ void VnlHalfHermitianToRealInverseFFTImageFilter::GenerateData() { // Get pointers to the input and output. - typename InputImageType::ConstPointer inputPtr = this->GetInput(); - typename OutputImageType::Pointer outputPtr = this->GetOutput(); + const typename InputImageType::ConstPointer inputPtr = this->GetInput(); + const typename OutputImageType::Pointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -39,7 +39,7 @@ VnlHalfHermitianToRealInverseFFTImageFilter::Generate // We don't have a nice progress to report, but at least this simple line // reports the beginning and the end of the process. - ProgressReporter progress(this, 0, 1); + const ProgressReporter progress(this, 0, 1); const InputSizeType inputSize = inputPtr->GetLargestPossibleRegion().GetSize(); const InputIndexType inputIndex = inputPtr->GetLargestPossibleRegion().GetIndex(); @@ -67,8 +67,8 @@ VnlHalfHermitianToRealInverseFFTImageFilter::Generate // produce it here from the half complex image assumed when the output is real. SignalVectorType signal(vectorSize); - OutputIndexValueType maxXIndex = inputIndex[0] + static_cast(inputSize[0]); - unsigned int si = 0; + const OutputIndexValueType maxXIndex = inputIndex[0] + static_cast(inputSize[0]); + unsigned int si = 0; for (ImageRegionIteratorWithIndex oIt(outputPtr, outputPtr->GetLargestPossibleRegion()); !oIt.IsAtEnd(); ++oIt) diff --git a/Modules/Filtering/FFT/include/itkVnlInverse1DFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkVnlInverse1DFFTImageFilter.hxx index fe3a8ecdcf2..c9509f822f8 100644 --- a/Modules/Filtering/FFT/include/itkVnlInverse1DFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkVnlInverse1DFFTImageFilter.hxx @@ -44,7 +44,7 @@ VnlInverse1DFFTImageFilter::GenerateData() const typename Superclass::InputImageType::SizeType & inputSize = input->GetRequestedRegion().GetSize(); const unsigned int direction = this->GetDirection(); - unsigned int vectorSize = inputSize[direction]; + const unsigned int vectorSize = inputSize[direction]; MultiThreaderBase * multiThreader = this->GetMultiThreader(); multiThreader->SetNumberOfWorkUnits(this->GetNumberOfWorkUnits()); diff --git a/Modules/Filtering/FFT/include/itkVnlInverseFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkVnlInverseFFTImageFilter.hxx index ec44d6486a1..c0c463dff00 100644 --- a/Modules/Filtering/FFT/include/itkVnlInverseFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkVnlInverseFFTImageFilter.hxx @@ -29,8 +29,8 @@ void VnlInverseFFTImageFilter::GenerateData() { // Get pointers to the input and output. - typename InputImageType::ConstPointer inputPtr = this->GetInput(); - typename OutputImageType::Pointer outputPtr = this->GetOutput(); + const typename InputImageType::ConstPointer inputPtr = this->GetInput(); + const typename OutputImageType::Pointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -39,7 +39,7 @@ VnlInverseFFTImageFilter::GenerateData() // We don't have a nice progress to report, but at least this simple line // reports the beginning and the end of the process. - ProgressReporter progress(this, 0, 1); + const ProgressReporter progress(this, 0, 1); const OutputSizeType outputSize = outputPtr->GetLargestPossibleRegion().GetSize(); diff --git a/Modules/Filtering/FFT/include/itkVnlRealToHalfHermitianForwardFFTImageFilter.hxx b/Modules/Filtering/FFT/include/itkVnlRealToHalfHermitianForwardFFTImageFilter.hxx index f0b51503d0e..5c2a7ca02c6 100644 --- a/Modules/Filtering/FFT/include/itkVnlRealToHalfHermitianForwardFFTImageFilter.hxx +++ b/Modules/Filtering/FFT/include/itkVnlRealToHalfHermitianForwardFFTImageFilter.hxx @@ -29,8 +29,8 @@ void VnlRealToHalfHermitianForwardFFTImageFilter::GenerateData() { // Get pointers to the input and output. - typename InputImageType::ConstPointer inputPtr = this->GetInput(); - typename OutputImageType::Pointer outputPtr = this->GetOutput(); + const typename InputImageType::ConstPointer inputPtr = this->GetInput(); + const typename OutputImageType::Pointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -39,7 +39,7 @@ VnlRealToHalfHermitianForwardFFTImageFilter::Generate // We don't have a nice progress to report, but at least this simple line // reports the beginning and the end of the process. - ProgressReporter progress(this, 0, 1); + const ProgressReporter progress(this, 0, 1); const InputSizeType inputSize = inputPtr->GetLargestPossibleRegion().GetSize(); @@ -74,8 +74,8 @@ VnlRealToHalfHermitianForwardFFTImageFilter::Generate for (ImageRegionIteratorWithIndex oIt(outputPtr, outputPtr->GetLargestPossibleRegion()); !oIt.IsAtEnd(); ++oIt) { - typename OutputImageType::IndexType index = oIt.GetIndex(); - typename OutputImageType::OffsetValueType offset = inputPtr->ComputeOffset(index); + const typename OutputImageType::IndexType index = oIt.GetIndex(); + const typename OutputImageType::OffsetValueType offset = inputPtr->ComputeOffset(index); oIt.Set(signal[offset]); } } diff --git a/Modules/Filtering/FFT/src/itkFFTWGlobalConfiguration.cxx b/Modules/Filtering/FFT/src/itkFFTWGlobalConfiguration.cxx index d448a22a817..c22b04bf3a9 100644 --- a/Modules/Filtering/FFT/src/itkFFTWGlobalConfiguration.cxx +++ b/Modules/Filtering/FFT/src/itkFFTWGlobalConfiguration.cxx @@ -471,7 +471,7 @@ FFTWGlobalConfiguration::FFTWGlobalConfiguration() if (this->m_ReadWisdomCache) { - std::string cachePath = m_WisdomFilenameGenerator->GenerateWisdomFilename(m_WisdomCacheBase); + const std::string cachePath = m_WisdomFilenameGenerator->GenerateWisdomFilename(m_WisdomCacheBase); # if defined(ITK_USE_FFTWF) fftwf_import_system_wisdom(); ImportWisdomFileFloat(cachePath + "f"); @@ -487,7 +487,7 @@ FFTWGlobalConfiguration::~FFTWGlobalConfiguration() { if (this->m_WriteWisdomCache && this->m_NewWisdomAvailable) { - std::string cachePath = m_WisdomFilenameGenerator->GenerateWisdomFilename(m_WisdomCacheBase); + const std::string cachePath = m_WisdomFilenameGenerator->GenerateWisdomFilename(m_WisdomCacheBase); # if defined(ITK_USE_FFTWF) { // import the wisdom files again to be sure to not erase the wisdom saved in another process diff --git a/Modules/Filtering/FFT/test/itkComplexToComplexFFTImageFilterTest.cxx b/Modules/Filtering/FFT/test/itkComplexToComplexFFTImageFilterTest.cxx index 13f0ae60f01..d94db8c744a 100644 --- a/Modules/Filtering/FFT/test/itkComplexToComplexFFTImageFilterTest.cxx +++ b/Modules/Filtering/FFT/test/itkComplexToComplexFFTImageFilterTest.cxx @@ -112,7 +112,7 @@ itkComplexToComplexFFTImageFilterTest(int argc, char * argv[]) std::cout << "STREAMED ENUM VALUE ComplexToComplexFFTImageFilterEnums::TransformDirection: " << ee << std::endl; } - itk::ImageIOBase::Pointer imageIO = + const itk::ImageIOBase::Pointer imageIO = itk::ImageIOFactory::CreateImageIO(inputImageFileName, itk::ImageIOFactory::IOFileModeEnum::ReadMode); imageIO->SetFileName(inputImageFileName); imageIO->ReadImageInformation(); diff --git a/Modules/Filtering/FFT/test/itkFFTPadImageFilterTest.cxx b/Modules/Filtering/FFT/test/itkFFTPadImageFilterTest.cxx index ca08fa338ec..1a1f7b7d93d 100644 --- a/Modules/Filtering/FFT/test/itkFFTPadImageFilterTest.cxx +++ b/Modules/Filtering/FFT/test/itkFFTPadImageFilterTest.cxx @@ -72,13 +72,13 @@ itkFFTPadImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(fftpad, FFTPadImageFilter, PadImageFilterBase); - itk::SizeValueType sizeGreatestPrimeFactor = std::stoi(argv[3]); + const itk::SizeValueType sizeGreatestPrimeFactor = std::stoi(argv[3]); fftpad->SetSizeGreatestPrimeFactor(sizeGreatestPrimeFactor); ITK_TEST_SET_GET_VALUE(sizeGreatestPrimeFactor, fftpad->GetSizeGreatestPrimeFactor()); fftpad->SetInput(reader->GetOutput()); - std::string padMethod = argv[4]; + const std::string padMethod = argv[4]; if (padMethod == "Mirror") { // fftpad->SetBoundaryCondition( &mirrorCond ); @@ -95,7 +95,7 @@ itkFFTPadImageFilterTest(int argc, char * argv[]) { fftpad->SetBoundaryCondition(&wrapCond); } - itk::SimpleFilterWatcher watchFFTPad(fftpad, "fftpad"); + const itk::SimpleFilterWatcher watchFFTPad(fftpad, "fftpad"); auto writer = WriterType::New(); writer->SetInput(fftpad->GetOutput()); diff --git a/Modules/Filtering/FFT/test/itkFFTShiftImageFilterTest.cxx b/Modules/Filtering/FFT/test/itkFFTShiftImageFilterTest.cxx index fdbc4e44905..ed94886783d 100644 --- a/Modules/Filtering/FFT/test/itkFFTShiftImageFilterTest.cxx +++ b/Modules/Filtering/FFT/test/itkFFTShiftImageFilterTest.cxx @@ -64,7 +64,7 @@ itkFFTShiftImageFilterTest(int argc, char * argv[]) ITK_TEST_SET_GET_BOOLEAN(filter, Inverse, inverse); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/FFT/test/itkFFTTest.h b/Modules/Filtering/FFT/test/itkFFTTest.h index cce5667dbe7..d29e9de65a5 100644 --- a/Modules/Filtering/FFT/test/itkFFTTest.h +++ b/Modules/Filtering/FFT/test/itkFFTTest.h @@ -137,7 +137,7 @@ test_fft(unsigned int * SizeOfDimensions) } // Get the size and the pointer to the complex image. - typename ComplexImageType::Pointer complexImage = R2C->GetOutput(); + const typename ComplexImageType::Pointer complexImage = R2C->GetOutput(); std::complex * fftbuf = complexImage->GetBufferPointer(); const typename ComplexImageType::SizeType & complexImageSize = complexImage->GetLargestPossibleRegion().GetSize(); @@ -151,10 +151,10 @@ test_fft(unsigned int * SizeOfDimensions) std::cout << "Frequency domain data after forward transform:" << std::endl; for (unsigned int i = 0; i < sizes[2]; ++i) { - unsigned int zStride = i * sizes[1] * sizes[0]; + const unsigned int zStride = i * sizes[1] * sizes[0]; for (unsigned int j = 0; j < sizes[1]; ++j) { - unsigned int yStride = j * sizes[0]; + const unsigned int yStride = j * sizes[0]; for (unsigned int k = 0; k < sizes[0]; ++k) { std::cout << fftbuf[zStride + yStride + k] << ' '; @@ -195,7 +195,7 @@ test_fft(unsigned int * SizeOfDimensions) C2R->Print(std::cout); C2R->Update(); std::cerr << "C2R region: " << C2R->GetOutput()->GetLargestPossibleRegion() << std::endl; - typename RealImageType::Pointer imageAfterInverseFFT = C2R->GetOutput(); + const typename RealImageType::Pointer imageAfterInverseFFT = C2R->GetOutput(); // Check to see that the metadata has been copied if (imageAfterInverseFFT->GetOrigin() != origin) @@ -350,11 +350,11 @@ test_fft_rtc(unsigned int * SizeOfDimensions) R2Cb->Update(); // Get the size and the pointer to the complex image. - typename ComplexImageType::Pointer complexImageA = R2Ca->GetOutput(); + const typename ComplexImageType::Pointer complexImageA = R2Ca->GetOutput(); std::complex * fftbufA = complexImageA->GetBufferPointer(); const typename ComplexImageType::SizeType & complexImageSizeA = complexImageA->GetLargestPossibleRegion().GetSize(); - typename ComplexImageType::Pointer complexImageB = R2Cb->GetOutput(); + const typename ComplexImageType::Pointer complexImageB = R2Cb->GetOutput(); std::complex * fftbufB = complexImageB->GetBufferPointer(); const typename ComplexImageType::SizeType & complexImageSizeB = complexImageB->GetLargestPossibleRegion().GetSize(); @@ -374,10 +374,10 @@ test_fft_rtc(unsigned int * SizeOfDimensions) std::cout << "Frequency domain data after forward transform:" << std::endl; for (unsigned int i = 0; i < sizesA[2]; ++i) { - unsigned int zStride = i * sizesA[1] * sizesA[0]; + const unsigned int zStride = i * sizesA[1] * sizesA[0]; for (unsigned int j = 0; j < sizesA[1]; ++j) { - unsigned int yStride = j * sizesA[0]; + const unsigned int yStride = j * sizesA[0]; for (unsigned int k = 0; k < sizesA[0]; ++k) { std::cout << fftbufA[zStride + yStride + k] << ' '; @@ -389,10 +389,10 @@ test_fft_rtc(unsigned int * SizeOfDimensions) for (unsigned int i = 0; i < sizesB[2]; ++i) { - unsigned int zStride = i * sizesB[1] * sizesB[0]; + const unsigned int zStride = i * sizesB[1] * sizesB[0]; for (unsigned int j = 0; j < sizesB[1]; ++j) { - unsigned int yStride = j * sizesB[0]; + const unsigned int yStride = j * sizesB[0]; for (unsigned int k = 0; k < sizesB[0]; ++k) { std::cout << fftbufB[zStride + yStride + k] << ' '; @@ -408,16 +408,16 @@ test_fft_rtc(unsigned int * SizeOfDimensions) // failed. for (unsigned int i = 0; i < std::min(sizesA[2], sizesB[2]); ++i) { - unsigned int zStrideA = i * sizesA[1] * sizesA[0]; - unsigned int zStrideB = i * sizesB[1] * sizesB[0]; + const unsigned int zStrideA = i * sizesA[1] * sizesA[0]; + const unsigned int zStrideB = i * sizesB[1] * sizesB[0]; for (unsigned int j = 0; j < std::min(sizesA[1], sizesB[1]); ++j) { - unsigned int yStrideA = j * sizesA[0]; - unsigned int yStrideB = j * sizesB[0]; + const unsigned int yStrideA = j * sizesA[0]; + const unsigned int yStrideB = j * sizesB[0]; for (unsigned int k = 0; k < std::min(sizesA[0], sizesB[0]); ++k) { - double val = itk::Math::abs(fftbufA[zStrideA + yStrideA + k]); - double diff = itk::Math::abs(fftbufA[zStrideA + yStrideA + k] - fftbufB[zStrideB + yStrideB + k]); + const double val = itk::Math::abs(fftbufA[zStrideA + yStrideA + k]); + double diff = itk::Math::abs(fftbufA[zStrideA + yStrideA + k] - fftbufB[zStrideB + yStrideB + k]); if (itk::Math::NotAlmostEquals(val, 0.0)) { diff /= itk::Math::abs(val); diff --git a/Modules/Filtering/FFT/test/itkFFTWComplexToComplexFFTImageFilterTest.cxx b/Modules/Filtering/FFT/test/itkFFTWComplexToComplexFFTImageFilterTest.cxx index cf41e904e25..b9c59c6b1da 100644 --- a/Modules/Filtering/FFT/test/itkFFTWComplexToComplexFFTImageFilterTest.cxx +++ b/Modules/Filtering/FFT/test/itkFFTWComplexToComplexFFTImageFilterTest.cxx @@ -102,7 +102,7 @@ itkFFTWComplexToComplexFFTImageFilterTest(int argc, char * argv[]) const char * outputImageFileName = argv[2]; const std::string pixelTypeString(argv[3]); - itk::ImageIOBase::Pointer imageIO = + const itk::ImageIOBase::Pointer imageIO = itk::ImageIOFactory::CreateImageIO(inputImageFileName, itk::ImageIOFactory::IOFileModeEnum::ReadMode); imageIO->SetFileName(inputImageFileName); imageIO->ReadImageInformation(); diff --git a/Modules/Filtering/FFT/test/itkFFTWD_FFTTest.cxx b/Modules/Filtering/FFT/test/itkFFTWD_FFTTest.cxx index 691fdeb85c6..f8c61bc67b0 100644 --- a/Modules/Filtering/FFT/test/itkFFTWD_FFTTest.cxx +++ b/Modules/Filtering/FFT/test/itkFFTWD_FFTTest.cxx @@ -68,7 +68,7 @@ itkFFTWD_FFTTest(int, char *[]) rval++; // Exercise the plan rigor methods - itk::FFTWForwardFFTImageFilter::Pointer fft = itk::FFTWForwardFFTImageFilter::New(); + const itk::FFTWForwardFFTImageFilter::Pointer fft = itk::FFTWForwardFFTImageFilter::New(); fft->SetPlanRigor(FFTW_ESTIMATE); if (fft->GetPlanRigor() != FFTW_ESTIMATE) { @@ -77,7 +77,7 @@ itkFFTWD_FFTTest(int, char *[]) } fft->SetPlanRigor(FFTW_MEASURE); - itk::FFTWInverseFFTImageFilter::Pointer ifft = itk::FFTWInverseFFTImageFilter::New(); + const itk::FFTWInverseFFTImageFilter::Pointer ifft = itk::FFTWInverseFFTImageFilter::New(); ifft->SetPlanRigor(FFTW_ESTIMATE); if (ifft->GetPlanRigor() != FFTW_ESTIMATE) { diff --git a/Modules/Filtering/FFT/test/itkFFTWD_RealFFTTest.cxx b/Modules/Filtering/FFT/test/itkFFTWD_RealFFTTest.cxx index 58682fc9415..70ede61adfe 100644 --- a/Modules/Filtering/FFT/test/itkFFTWD_RealFFTTest.cxx +++ b/Modules/Filtering/FFT/test/itkFFTWD_RealFFTTest.cxx @@ -86,7 +86,7 @@ itkFFTWD_RealFFTTest(int, char *[]) rval++; // Exercise the plan rigor methods - itk::FFTWRealToHalfHermitianForwardFFTImageFilter::Pointer fft = + const itk::FFTWRealToHalfHermitianForwardFFTImageFilter::Pointer fft = itk::FFTWRealToHalfHermitianForwardFFTImageFilter::New(); fft->SetPlanRigor(FFTW_ESTIMATE); if (fft->GetPlanRigor() != FFTW_ESTIMATE) @@ -96,7 +96,7 @@ itkFFTWD_RealFFTTest(int, char *[]) } fft->SetPlanRigor(FFTW_MEASURE); - itk::FFTWHalfHermitianToRealInverseFFTImageFilter::Pointer ifft = + const itk::FFTWHalfHermitianToRealInverseFFTImageFilter::Pointer ifft = itk::FFTWHalfHermitianToRealInverseFFTImageFilter::New(); ifft->SetPlanRigor(FFTW_ESTIMATE); if (ifft->GetPlanRigor() != FFTW_ESTIMATE) diff --git a/Modules/Filtering/FFT/test/itkFFTWF_FFTTest.cxx b/Modules/Filtering/FFT/test/itkFFTWF_FFTTest.cxx index 6cb020c966c..87df0a49f0f 100644 --- a/Modules/Filtering/FFT/test/itkFFTWF_FFTTest.cxx +++ b/Modules/Filtering/FFT/test/itkFFTWF_FFTTest.cxx @@ -93,7 +93,7 @@ itkFFTWF_FFTTest( rval++; // Exercise the plan rigor methods - itk::FFTWForwardFFTImageFilter::Pointer fft = itk::FFTWForwardFFTImageFilter::New(); + const itk::FFTWForwardFFTImageFilter::Pointer fft = itk::FFTWForwardFFTImageFilter::New(); fft->SetPlanRigor(FFTW_ESTIMATE); if (fft->GetPlanRigor() != FFTW_ESTIMATE) { @@ -102,7 +102,7 @@ itkFFTWF_FFTTest( } fft->SetPlanRigor(FFTW_MEASURE); - itk::FFTWInverseFFTImageFilter::Pointer ifft = itk::FFTWInverseFFTImageFilter::New(); + const itk::FFTWInverseFFTImageFilter::Pointer ifft = itk::FFTWInverseFFTImageFilter::New(); ifft->SetPlanRigor(FFTW_ESTIMATE); if (ifft->GetPlanRigor() != FFTW_ESTIMATE) { diff --git a/Modules/Filtering/FFT/test/itkFFTWF_RealFFTTest.cxx b/Modules/Filtering/FFT/test/itkFFTWF_RealFFTTest.cxx index 121a12ea53d..8f2b923cb0f 100644 --- a/Modules/Filtering/FFT/test/itkFFTWF_RealFFTTest.cxx +++ b/Modules/Filtering/FFT/test/itkFFTWF_RealFFTTest.cxx @@ -103,7 +103,7 @@ itkFFTWF_RealFFTTest( rval++; // Exercise the plan rigor methods - itk::FFTWRealToHalfHermitianForwardFFTImageFilter::Pointer fft = + const itk::FFTWRealToHalfHermitianForwardFFTImageFilter::Pointer fft = itk::FFTWRealToHalfHermitianForwardFFTImageFilter::New(); fft->SetPlanRigor(FFTW_ESTIMATE); if (fft->GetPlanRigor() != FFTW_ESTIMATE) @@ -113,7 +113,7 @@ itkFFTWF_RealFFTTest( } fft->SetPlanRigor(FFTW_MEASURE); - itk::FFTWHalfHermitianToRealInverseFFTImageFilter::Pointer ifft = + const itk::FFTWHalfHermitianToRealInverseFFTImageFilter::Pointer ifft = itk::FFTWHalfHermitianToRealInverseFFTImageFilter::New(); ifft->SetPlanRigor(FFTW_ESTIMATE); if (ifft->GetPlanRigor() != FFTW_ESTIMATE) diff --git a/Modules/Filtering/FFT/test/itkForward1DFFTImageFilterTest.cxx b/Modules/Filtering/FFT/test/itkForward1DFFTImageFilterTest.cxx index 631da02e930..45dc1e933fa 100644 --- a/Modules/Filtering/FFT/test/itkForward1DFFTImageFilterTest.cxx +++ b/Modules/Filtering/FFT/test/itkForward1DFFTImageFilterTest.cxx @@ -104,7 +104,7 @@ itkForward1DFFTImageFilterTest(int argc, char * argv[]) auto fft = FFTForwardType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(fft, Forward1DFFTImageFilter, ImageToImageFilter); - itk::SizeValueType sizeGreatestPrimeFactor = 2; + const itk::SizeValueType sizeGreatestPrimeFactor = 2; ITK_TEST_SET_GET_VALUE(sizeGreatestPrimeFactor, fft->GetSizeGreatestPrimeFactor()); return doTest(argv[1], argv[2]); diff --git a/Modules/Filtering/FFT/test/itkForwardInverseFFTTest.h b/Modules/Filtering/FFT/test/itkForwardInverseFFTTest.h index dd62683e350..0d6581973aa 100644 --- a/Modules/Filtering/FFT/test/itkForwardInverseFFTTest.h +++ b/Modules/Filtering/FFT/test/itkForwardInverseFFTTest.h @@ -25,7 +25,7 @@ template bool ForwardInverseFullFFTTest(const char * inputFileName) { - double tolerance = 1.e-3; + const double tolerance = 1.e-3; using ImageType = typename TForwardFFT::InputImageType; using ReaderType = itk::ImageFileReader; auto reader = ReaderType::New(); @@ -66,7 +66,7 @@ template bool ForwardInverseHalfFFTTest(const char * inputFileName) { - double tolerance = 1.e-3; + const double tolerance = 1.e-3; using ImageType = typename TForwardFFT::InputImageType; using ReaderType = itk::ImageFileReader; auto reader = ReaderType::New(); @@ -76,8 +76,8 @@ ForwardInverseHalfFFTTest(const char * inputFileName) auto fft = TForwardFFT::New(); fft->SetInput(reader->GetOutput()); - auto ifft = TInverseFFT::New(); - bool xIsOdd = reader->GetOutput()->GetLargestPossibleRegion().GetSize()[0] % 2 == 1; + auto ifft = TInverseFFT::New(); + const bool xIsOdd = reader->GetOutput()->GetLargestPossibleRegion().GetSize()[0] % 2 == 1; ifft->SetActualXDimensionIsOdd(xIsOdd); ifft->SetInput(fft->GetOutput()); diff --git a/Modules/Filtering/FFT/test/itkFullToHalfHermitianImageFilterTest.cxx b/Modules/Filtering/FFT/test/itkFullToHalfHermitianImageFilterTest.cxx index 09e4883501e..e724f4856d9 100644 --- a/Modules/Filtering/FFT/test/itkFullToHalfHermitianImageFilterTest.cxx +++ b/Modules/Filtering/FFT/test/itkFullToHalfHermitianImageFilterTest.cxx @@ -86,7 +86,7 @@ itkFullToHalfHermitianImageFilterTest(int argc, char * argv[]) // Check that the output of the full-to-half filter has the same // size as the output of the FFT filter. - ComplexImageType::RegionType fftRegion = fft->GetOutput()->GetLargestPossibleRegion(); + const ComplexImageType::RegionType fftRegion = fft->GetOutput()->GetLargestPossibleRegion(); if (fullToHalfFilter->GetOutput()->GetLargestPossibleRegion() != fftRegion) { std::cerr << "Output size of full-to-half filter is not the same as the output size " diff --git a/Modules/Filtering/FFT/test/itkHalfToFullHermitianImageFilterTest.cxx b/Modules/Filtering/FFT/test/itkHalfToFullHermitianImageFilterTest.cxx index da69ce1182c..b9d035d83bd 100644 --- a/Modules/Filtering/FFT/test/itkHalfToFullHermitianImageFilterTest.cxx +++ b/Modules/Filtering/FFT/test/itkHalfToFullHermitianImageFilterTest.cxx @@ -77,8 +77,8 @@ itkHalfToFullHermitianImageFilterTest(int argc, char * argv[]) ComplexImageType::SizeType fftSize = fft->GetOutput()->GetLargestPossibleRegion().GetSize(); // Test that the output is the expected size. - ComplexImageType::RegionType halfToFullOutputRegion = halfToFullFilter->GetOutput()->GetLargestPossibleRegion(); - ComplexImageType::SizeType halfToFullOutputSize = halfToFullOutputRegion.GetSize(); + const ComplexImageType::RegionType halfToFullOutputRegion = halfToFullFilter->GetOutput()->GetLargestPossibleRegion(); + const ComplexImageType::SizeType halfToFullOutputSize = halfToFullOutputRegion.GetSize(); if (halfToFullOutputSize != size) { std::cerr << "HalfToFullHermitianImageFilter did not produce an image of the expected size. " << std::endl; @@ -92,7 +92,7 @@ itkHalfToFullHermitianImageFilterTest(int argc, char * argv[]) conjugateRegionIndex[1] = indexShift[1]; ComplexImageType::SizeType conjugateRegionSize(size); conjugateRegionSize[0] -= fftSize[0]; - itk::ImageRegion conjugateRegion(conjugateRegionIndex, conjugateRegionSize); + const itk::ImageRegion conjugateRegion(conjugateRegionIndex, conjugateRegionSize); using ComplexIteratorType = itk::ImageRegionConstIteratorWithIndex; ComplexIteratorType it(halfToFullFilter->GetOutput(), conjugateRegion); diff --git a/Modules/Filtering/FFT/test/itkInverse1DFFTImageFilterTest.cxx b/Modules/Filtering/FFT/test/itkInverse1DFFTImageFilterTest.cxx index 10ca9139331..711ce9115ef 100644 --- a/Modules/Filtering/FFT/test/itkInverse1DFFTImageFilterTest.cxx +++ b/Modules/Filtering/FFT/test/itkInverse1DFFTImageFilterTest.cxx @@ -100,7 +100,7 @@ itkInverse1DFFTImageFilterTest(int argc, char * argv[]) auto fft = FFTInverseType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(fft, Inverse1DFFTImageFilter, ImageToImageFilter); - itk::SizeValueType sizeGreatestPrimeFactor = 2; + const itk::SizeValueType sizeGreatestPrimeFactor = 2; ITK_TEST_SET_GET_VALUE(sizeGreatestPrimeFactor, fft->GetSizeGreatestPrimeFactor()); diff --git a/Modules/Filtering/FFT/test/itkRealFFTTest.h b/Modules/Filtering/FFT/test/itkRealFFTTest.h index 44a34c0fe37..a348a730a97 100644 --- a/Modules/Filtering/FFT/test/itkRealFFTTest.h +++ b/Modules/Filtering/FFT/test/itkRealFFTTest.h @@ -125,7 +125,7 @@ test_fft(unsigned int * SizeOfDimensions) } // Get the size and the pointer to the complex image. - typename ComplexImageType::Pointer complexImage = R2C->GetOutput(); + const typename ComplexImageType::Pointer complexImage = R2C->GetOutput(); std::complex * fftbuf = complexImage->GetBufferPointer(); const typename ComplexImageType::SizeType & complexImageSize = complexImage->GetLargestPossibleRegion().GetSize(); @@ -140,10 +140,10 @@ test_fft(unsigned int * SizeOfDimensions) std::cout << "Frequency domain data after forward transform:" << std::endl; for (unsigned int i = 0; i < sizes[2]; ++i) { - unsigned int zStride = i * sizes[1] * sizes[0]; + const unsigned int zStride = i * sizes[1] * sizes[0]; for (unsigned int j = 0; j < sizes[1]; ++j) { - unsigned int yStride = j * sizes[0]; + const unsigned int yStride = j * sizes[0]; for (unsigned int k = 0; k < sizes[0]; ++k) { std::cout << fftbuf[zStride + yStride + k] << ' '; @@ -166,7 +166,7 @@ test_fft(unsigned int * SizeOfDimensions) C2R->Print(std::cout); C2R->Update(); std::cerr << "C2R region: " << C2R->GetOutput()->GetLargestPossibleRegion() << std::endl; - typename RealImageType::Pointer imageAfterHalfHermitianToRealInverseFFT = C2R->GetOutput(); + const typename RealImageType::Pointer imageAfterHalfHermitianToRealInverseFFT = C2R->GetOutput(); // The HalfHermitianToRealInverse FFT image iterator is the resultant iterator after we // perform the FFT and HalfHermitianToRealInverse FFT on the Original Image. */ @@ -302,11 +302,11 @@ test_fft_rtc(unsigned int * SizeOfDimensions) R2Cb->Update(); // Get the size and the pointer to the complex image. - typename ComplexImageType::Pointer complexImageA = R2Ca->GetOutput(); + const typename ComplexImageType::Pointer complexImageA = R2Ca->GetOutput(); std::complex * fftbufA = complexImageA->GetBufferPointer(); const typename ComplexImageType::SizeType & complexImageSizeA = complexImageA->GetLargestPossibleRegion().GetSize(); - typename ComplexImageType::Pointer complexImageB = R2Cb->GetOutput(); + const typename ComplexImageType::Pointer complexImageB = R2Cb->GetOutput(); std::complex * fftbufB = complexImageB->GetBufferPointer(); const typename ComplexImageType::SizeType & complexImageSizeB = complexImageB->GetLargestPossibleRegion().GetSize(); @@ -326,10 +326,10 @@ test_fft_rtc(unsigned int * SizeOfDimensions) std::cout << "Frequency domain data after forward transform:" << std::endl; for (unsigned int i = 0; i < sizesA[2]; ++i) { - unsigned int zStride = i * sizesA[1] * sizesA[0]; + const unsigned int zStride = i * sizesA[1] * sizesA[0]; for (unsigned int j = 0; j < sizesA[1]; ++j) { - unsigned int yStride = j * sizesA[0]; + const unsigned int yStride = j * sizesA[0]; for (unsigned int k = 0; k < sizesA[0]; ++k) { std::cout << fftbufA[zStride + yStride + k] << ' '; @@ -341,10 +341,10 @@ test_fft_rtc(unsigned int * SizeOfDimensions) for (unsigned int i = 0; i < sizesB[2]; ++i) { - unsigned int zStride = i * sizesB[1] * sizesB[0]; + const unsigned int zStride = i * sizesB[1] * sizesB[0]; for (unsigned int j = 0; j < sizesB[1]; ++j) { - unsigned int yStride = j * sizesB[0]; + const unsigned int yStride = j * sizesB[0]; for (unsigned int k = 0; k < sizesB[0]; ++k) { std::cout << fftbufB[zStride + yStride + k] << ' '; @@ -360,16 +360,16 @@ test_fft_rtc(unsigned int * SizeOfDimensions) // failed. for (unsigned int i = 0; i < std::min(sizesA[2], sizesB[2]); ++i) { - unsigned int zStrideA = i * sizesA[1] * sizesA[0]; - unsigned int zStrideB = i * sizesB[1] * sizesB[0]; + const unsigned int zStrideA = i * sizesA[1] * sizesA[0]; + const unsigned int zStrideB = i * sizesB[1] * sizesB[0]; for (unsigned int j = 0; j < std::min(sizesA[1], sizesB[1]); ++j) { - unsigned int yStrideA = j * sizesA[0]; - unsigned int yStrideB = j * sizesB[0]; + const unsigned int yStrideA = j * sizesA[0]; + const unsigned int yStrideB = j * sizesB[0]; for (unsigned int k = 0; k < std::min(sizesA[0], sizesB[0]); ++k) { - double val = itk::Math::abs(fftbufA[zStrideA + yStrideA + k]); - double diff = itk::Math::abs(fftbufA[zStrideA + yStrideA + k] - fftbufB[zStrideB + yStrideB + k]); + const double val = itk::Math::abs(fftbufA[zStrideA + yStrideA + k]); + double diff = itk::Math::abs(fftbufA[zStrideA + yStrideA + k] - fftbufB[zStrideB + yStrideB + k]); if (itk::Math::NotAlmostEquals(val, 0.0)) { diff /= itk::Math::abs(val); diff --git a/Modules/Filtering/FFT/test/itkTestCircularDependency.cxx b/Modules/Filtering/FFT/test/itkTestCircularDependency.cxx index 3ab8ff95aef..a03cd4d8277 100644 --- a/Modules/Filtering/FFT/test/itkTestCircularDependency.cxx +++ b/Modules/Filtering/FFT/test/itkTestCircularDependency.cxx @@ -43,7 +43,7 @@ FFTW() using FFTWRealToHalfHermitianForwardFFTImageFilterType = itk::FFTWRealToHalfHermitianForwardFFTImageFilter; - typename FFTWRealToHalfHermitianForwardFFTImageFilterType::Pointer fRlToHlfHrmtnFwrdFFT = + const typename FFTWRealToHalfHermitianForwardFFTImageFilterType::Pointer fRlToHlfHrmtnFwrdFFT = FFTWRealToHalfHermitianForwardFFTImageFilterType::New(); using FFTWInverseFFTImageFilterType = itk::FFTWInverseFFTImageFilter; @@ -51,7 +51,7 @@ FFTW() using FFTWHalfHermitianToRealInverseFFTImageFilterType = itk::FFTWHalfHermitianToRealInverseFFTImageFilter; - typename FFTWHalfHermitianToRealInverseFFTImageFilterType::Pointer hlfHrmtnToRlnvrs = + const typename FFTWHalfHermitianToRealInverseFFTImageFilterType::Pointer hlfHrmtnToRlnvrs = FFTWHalfHermitianToRealInverseFFTImageFilterType::New(); using FFTWForwardFFTImageFilterType = itk::FFTWForwardFFTImageFilter; @@ -73,7 +73,7 @@ Vnl() using VnlRealToHalfHermitianForwardFFTImageFilterType = itk::VnlRealToHalfHermitianForwardFFTImageFilter; - typename VnlRealToHalfHermitianForwardFFTImageFilterType::Pointer vRlToHlfHrmtnFwrdFFT = + const typename VnlRealToHalfHermitianForwardFFTImageFilterType::Pointer vRlToHlfHrmtnFwrdFFT = VnlRealToHalfHermitianForwardFFTImageFilterType::New(); using VnlInverseFFTImageFilterType = itk::VnlInverseFFTImageFilter; @@ -81,7 +81,7 @@ Vnl() using VnlHalfHermitianToRealInverseFFTImageFilterType = itk::VnlHalfHermitianToRealInverseFFTImageFilter; - typename VnlHalfHermitianToRealInverseFFTImageFilterType::Pointer fHlfHrmtnToRlnvrs = + const typename VnlHalfHermitianToRealInverseFFTImageFilterType::Pointer fHlfHrmtnToRlnvrs = VnlHalfHermitianToRealInverseFFTImageFilterType::New(); using VnlForwardFFTImageFilterType = itk::VnlForwardFFTImageFilter; diff --git a/Modules/Filtering/FFT/test/itkVnlComplexToComplexFFTImageFilterTest.cxx b/Modules/Filtering/FFT/test/itkVnlComplexToComplexFFTImageFilterTest.cxx index 7cccbece723..66be90be373 100644 --- a/Modules/Filtering/FFT/test/itkVnlComplexToComplexFFTImageFilterTest.cxx +++ b/Modules/Filtering/FFT/test/itkVnlComplexToComplexFFTImageFilterTest.cxx @@ -89,7 +89,7 @@ itkVnlComplexToComplexFFTImageFilterTest(int argc, char * argv[]) const char * outputImageFileName = argv[2]; const std::string pixelTypeString(argv[3]); - itk::ImageIOBase::Pointer imageIO = + const itk::ImageIOBase::Pointer imageIO = itk::ImageIOFactory::CreateImageIO(inputImageFileName, itk::ImageIOFactory::IOFileModeEnum::ReadMode); imageIO->SetFileName(inputImageFileName); imageIO->ReadImageInformation(); diff --git a/Modules/Filtering/FastMarching/include/itkFastMarchingBase.hxx b/Modules/Filtering/FastMarching/include/itkFastMarchingBase.hxx index 91442ce67dc..5f12eceaf0c 100644 --- a/Modules/Filtering/FastMarching/include/itkFastMarchingBase.hxx +++ b/Modules/Filtering/FastMarching/include/itkFastMarchingBase.hxx @@ -140,7 +140,7 @@ FastMarchingBase::GenerateData() NodePairType current_node_pair = m_Heap.top(); m_Heap.pop(); - NodeType current_node = current_node_pair.GetNode(); + const NodeType current_node = current_node_pair.GetNode(); current_value = this->GetOutputValue(output, current_node); if (Math::ExactlyEquals(current_value, current_node_pair.GetValue())) diff --git a/Modules/Filtering/FastMarching/include/itkFastMarchingExtensionImageFilter.hxx b/Modules/Filtering/FastMarching/include/itkFastMarchingExtensionImageFilter.hxx index fd61280f597..b3529024246 100644 --- a/Modules/Filtering/FastMarching/include/itkFastMarchingExtensionImageFilter.hxx +++ b/Modules/Filtering/FastMarching/include/itkFastMarchingExtensionImageFilter.hxx @@ -78,7 +78,7 @@ FastMarchingExtensionImageFilterGetOutput(); + const typename Superclass::LevelSetPointer primaryOutput = this->GetOutput(); for (unsigned int k = 0; k < VAuxDimension; ++k) { AuxImageType * ptr = this->GetAuxiliaryImage(k); @@ -149,9 +149,9 @@ FastMarchingExtensionImageFilterBegin(); - typename Superclass::NodeContainer::ConstIterator pointsIter = (this->GetAlivePoints())->Begin(); - typename Superclass::NodeContainer::ConstIterator pointsEnd = (this->GetAlivePoints())->End(); + typename AuxValueContainer::ConstIterator auxIter = m_AuxAliveValues->Begin(); + typename Superclass::NodeContainer::ConstIterator pointsIter = (this->GetAlivePoints())->Begin(); + const typename Superclass::NodeContainer::ConstIterator pointsEnd = (this->GetAlivePoints())->End(); for (; pointsIter != pointsEnd; ++pointsIter, ++auxIter) { @@ -173,9 +173,9 @@ FastMarchingExtensionImageFilterBegin(); - typename Superclass::NodeContainer::ConstIterator pointsIter = (this->GetTrialPoints())->Begin(); - typename Superclass::NodeContainer::ConstIterator pointsEnd = (this->GetTrialPoints())->End(); + typename AuxValueContainer::ConstIterator auxIter = m_AuxTrialValues->Begin(); + typename Superclass::NodeContainer::ConstIterator pointsIter = (this->GetTrialPoints())->Begin(); + const typename Superclass::NodeContainer::ConstIterator pointsEnd = (this->GetTrialPoints())->End(); for (; pointsIter != pointsEnd; ++pointsIter, ++auxIter) { @@ -216,7 +216,7 @@ FastMarchingExtensionImageFilterSuperclass::UpdateValue(index, speed, output); + const double solution = this->Superclass::UpdateValue(index, speed, output); typename Superclass::NodeType node; diff --git a/Modules/Filtering/FastMarching/include/itkFastMarchingExtensionImageFilterBase.hxx b/Modules/Filtering/FastMarching/include/itkFastMarchingExtensionImageFilterBase.hxx index 51122c1428b..66c4475e8ac 100644 --- a/Modules/Filtering/FastMarching/include/itkFastMarchingExtensionImageFilterBase.hxx +++ b/Modules/Filtering/FastMarching/include/itkFastMarchingExtensionImageFilterBase.hxx @@ -146,9 +146,9 @@ FastMarchingExtensionImageFilterBase: if (m_AuxiliaryAliveValues) { - AuxValueContainerConstIterator auxIter = m_AuxiliaryAliveValues->Begin(); - NodePairContainerConstIterator pointsIter = this->m_AlivePoints->Begin(); - NodePairContainerConstIterator pointsEnd = this->m_AlivePoints->Begin(); + AuxValueContainerConstIterator auxIter = m_AuxiliaryAliveValues->Begin(); + NodePairContainerConstIterator pointsIter = this->m_AlivePoints->Begin(); + const NodePairContainerConstIterator pointsEnd = this->m_AlivePoints->Begin(); while (pointsIter != pointsEnd) { @@ -170,9 +170,9 @@ FastMarchingExtensionImageFilterBase: if (m_AuxiliaryTrialValues) { - AuxValueContainerConstIterator auxIter = m_AuxiliaryTrialValues->Begin(); - NodePairContainerConstIterator pointsIter = this->m_TrialPoints->Begin(); - NodePairContainerConstIterator pointsEnd = this->m_TrialPoints->End(); + AuxValueContainerConstIterator auxIter = m_AuxiliaryTrialValues->Begin(); + NodePairContainerConstIterator pointsIter = this->m_TrialPoints->Begin(); + const NodePairContainerConstIterator pointsEnd = this->m_TrialPoints->End(); while (pointsIter != pointsEnd) { diff --git a/Modules/Filtering/FastMarching/include/itkFastMarchingImageFilter.hxx b/Modules/Filtering/FastMarching/include/itkFastMarchingImageFilter.hxx index ad3cdc4973c..417da8bbbd8 100644 --- a/Modules/Filtering/FastMarching/include/itkFastMarchingImageFilter.hxx +++ b/Modules/Filtering/FastMarching/include/itkFastMarchingImageFilter.hxx @@ -85,7 +85,7 @@ FastMarchingImageFilter::GenerateOutputInformation() // use user-specified output information if (this->GetInput() == nullptr || m_OverrideOutputInformation) { - LevelSetPointer output = this->GetOutput(); + const LevelSetPointer output = this->GetOutput(); output->SetLargestPossibleRegion(m_OutputRegion); output->SetOrigin(m_OutputOrigin); output->SetSpacing(m_OutputSpacing); @@ -159,8 +159,8 @@ FastMarchingImageFilter::Initialize(LevelSetImageType * if (m_AlivePoints) { - typename NodeContainer::ConstIterator pointsIter = m_AlivePoints->Begin(); - typename NodeContainer::ConstIterator pointsEnd = m_AlivePoints->End(); + typename NodeContainer::ConstIterator pointsIter = m_AlivePoints->Begin(); + const typename NodeContainer::ConstIterator pointsEnd = m_AlivePoints->End(); while (pointsIter != pointsEnd) { @@ -184,8 +184,8 @@ FastMarchingImageFilter::Initialize(LevelSetImageType * if (m_OutsidePoints) { - typename NodeContainer::ConstIterator pointsIter = m_OutsidePoints->Begin(); - typename NodeContainer::ConstIterator pointsEnd = m_OutsidePoints->End(); + typename NodeContainer::ConstIterator pointsIter = m_OutsidePoints->Begin(); + const typename NodeContainer::ConstIterator pointsEnd = m_OutsidePoints->End(); while (pointsIter != pointsEnd) { @@ -216,8 +216,8 @@ FastMarchingImageFilter::Initialize(LevelSetImageType * // process the input trial points if (m_TrialPoints) { - typename NodeContainer::ConstIterator pointsIter = m_TrialPoints->Begin(); - typename NodeContainer::ConstIterator pointsEnd = m_TrialPoints->End(); + typename NodeContainer::ConstIterator pointsIter = m_TrialPoints->Begin(); + const typename NodeContainer::ConstIterator pointsEnd = m_TrialPoints->End(); while (pointsIter != pointsEnd) { @@ -253,8 +253,8 @@ FastMarchingImageFilter::GenerateData() throw err; } - LevelSetPointer output = this->GetOutput(); - SpeedImageConstPointer speedImage = this->GetInput(); + const LevelSetPointer output = this->GetOutput(); + const SpeedImageConstPointer speedImage = this->GetInput(); this->Initialize(output); diff --git a/Modules/Filtering/FastMarching/include/itkFastMarchingImageFilterBase.hxx b/Modules/Filtering/FastMarching/include/itkFastMarchingImageFilterBase.hxx index ad6fb99ae7c..7e0d15b0d66 100644 --- a/Modules/Filtering/FastMarching/include/itkFastMarchingImageFilterBase.hxx +++ b/Modules/Filtering/FastMarching/include/itkFastMarchingImageFilterBase.hxx @@ -55,7 +55,7 @@ FastMarchingImageFilterBase::FastMarchingImageFilterBase() constexpr auto outputSize = OutputSizeType::Filled(16); - NodeType outputIndex{}; + const NodeType outputIndex{}; m_OutputRegion.SetSize(outputSize); m_OutputRegion.SetIndex(outputIndex); @@ -77,7 +77,7 @@ FastMarchingImageFilterBase::GenerateOutputInformation() // Use user-specified output information if (!this->GetInput() || m_OverrideOutputInformation) { - OutputImagePointer output = this->GetOutput(); + const OutputImagePointer output = this->GetOutput(); output->SetLargestPossibleRegion(m_OutputRegion); output->SetOrigin(m_OutputOrigin); output->SetSpacing(m_OutputSpacing); @@ -149,9 +149,9 @@ FastMarchingImageFilterBase::UpdateNeighbors(OutputImageType * { for (unsigned int j = 0; j < ImageDimension; ++j) { - typename NodeType::IndexValueType v = iNode[j]; - typename NodeType::IndexValueType start = m_StartIndex[j]; - typename NodeType::IndexValueType last = m_LastIndex[j]; + const typename NodeType::IndexValueType v = iNode[j]; + const typename NodeType::IndexValueType start = m_StartIndex[j]; + const typename NodeType::IndexValueType last = m_LastIndex[j]; NodeType neighIndex = iNode; for (int s = -1; s < 2; s += 2) @@ -160,7 +160,7 @@ FastMarchingImageFilterBase::UpdateNeighbors(OutputImageType * { neighIndex[j] = v + s; } - unsigned char label = m_LabelImage->GetPixel(neighIndex); + const unsigned char label = m_LabelImage->GetPixel(neighIndex); if ((label != Traits::Alive) && (label != Traits::InitialTrial) && (label != Traits::Forbidden)) { @@ -209,14 +209,14 @@ FastMarchingImageFilterBase::GetInternalNodesUsed(OutputImageTy { temp_node.m_Value = this->m_LargeValue; - typename NodeType::IndexValueType v = iNode[j]; - typename NodeType::IndexValueType start = m_StartIndex[j]; - typename NodeType::IndexValueType last = m_LastIndex[j]; + const typename NodeType::IndexValueType v = iNode[j]; + const typename NodeType::IndexValueType start = m_StartIndex[j]; + const typename NodeType::IndexValueType last = m_LastIndex[j]; // Find smallest valued neighbor in this dimension for (int s = -1; s < 2; s = s + 2) { - typename NodeType::IndexValueType temp = v + s; + const typename NodeType::IndexValueType temp = v + s; // Make sure neighIndex is not outside from the image if ((temp <= last) && (temp >= start)) @@ -225,7 +225,7 @@ FastMarchingImageFilterBase::GetInternalNodesUsed(OutputImageTy if (this->GetLabelValueForGivenNode(neighbor_node) == Traits::Alive) { - OutputPixelType neighValue = this->GetOutputValue(oImage, neighbor_node); + const OutputPixelType neighValue = this->GetOutputValue(oImage, neighbor_node); // let's find the minimum value given a direction j if (temp_node.m_Value > neighValue) @@ -276,19 +276,19 @@ FastMarchingImageFilterBase::Solve(OutputImageType * for (const auto & neighbor : iNeighbors) { - double value = static_cast(neighbor.m_Value); + const double value = static_cast(neighbor.m_Value); if (oSolution >= value) { - unsigned int axis = neighbor.m_Axis; + const unsigned int axis = neighbor.m_Axis; // spaceFactor = \frac{1}{spacing[axis]^2} - double spaceFactor = itk::Math::sqr(1.0 / m_OutputSpacing[axis]); + const double spaceFactor = itk::Math::sqr(1.0 / m_OutputSpacing[axis]); aa += spaceFactor; bb += value * spaceFactor; cc += itk::Math::sqr(value) * spaceFactor; - double discrim = itk::Math::sqr(bb) - aa * cc; + const double discrim = itk::Math::sqr(bb) - aa * cc; if (discrim < itk::Math::eps) { // Discriminant of quadratic eqn. is negative @@ -314,9 +314,9 @@ FastMarchingImageFilterBase::CheckTopology(OutputImageType * oI { if ((ImageDimension == 2) || (ImageDimension == 3)) { - bool wellComposednessViolation = this->DoesVoxelChangeViolateWellComposedness(iNode); + const bool wellComposednessViolation = this->DoesVoxelChangeViolateWellComposedness(iNode); - bool strictTopologyViolation = this->DoesVoxelChangeViolateStrictTopology(iNode); + const bool strictTopologyViolation = this->DoesVoxelChangeViolateStrictTopology(iNode); if ((this->m_TopologyCheck == Superclass::TopologyCheckEnum::Strict) && (wellComposednessViolation || strictTopologyViolation)) @@ -439,13 +439,13 @@ FastMarchingImageFilterBase::InitializeOutput(OutputImageType * OutputPixelType outputPixel = this->m_LargeValue; if (this->m_AlivePoints) { - NodePairContainerConstIterator pointsIter = this->m_AlivePoints->Begin(); - NodePairContainerConstIterator pointsEnd = this->m_AlivePoints->End(); + NodePairContainerConstIterator pointsIter = this->m_AlivePoints->Begin(); + const NodePairContainerConstIterator pointsEnd = this->m_AlivePoints->End(); while (pointsIter != pointsEnd) { // Get node from alive points container - NodeType idx = pointsIter->Value().GetNode(); + const NodeType idx = pointsIter->Value().GetNode(); // Check if node index is within the output level set if (m_BufferedRegion.IsInside(idx)) @@ -468,14 +468,14 @@ FastMarchingImageFilterBase::InitializeOutput(OutputImageType * if (this->m_ForbiddenPoints) { - NodePairContainerConstIterator pointsIter = this->m_ForbiddenPoints->Begin(); - NodePairContainerConstIterator pointsEnd = this->m_ForbiddenPoints->End(); + NodePairContainerConstIterator pointsIter = this->m_ForbiddenPoints->Begin(); + const NodePairContainerConstIterator pointsEnd = this->m_ForbiddenPoints->End(); - OutputPixelType zero{}; + const OutputPixelType zero{}; while (pointsIter != pointsEnd) { - NodeType idx = pointsIter->Value().GetNode(); + const NodeType idx = pointsIter->Value().GetNode(); // Check if node index is within the output level set if (m_BufferedRegion.IsInside(idx)) @@ -517,13 +517,13 @@ FastMarchingImageFilterBase::InitializeOutput(OutputImageType * // Process the input trial points if (this->m_TrialPoints) { - NodePairContainerConstIterator pointsIter = this->m_TrialPoints->Begin(); - NodePairContainerConstIterator pointsEnd = this->m_TrialPoints->End(); + NodePairContainerConstIterator pointsIter = this->m_TrialPoints->Begin(); + const NodePairContainerConstIterator pointsEnd = this->m_TrialPoints->End(); while (pointsIter != pointsEnd) { // Get node from trial points container - NodeType idx = pointsIter->Value().GetNode(); + const NodeType idx = pointsIter->Value().GetNode(); // Check if node index is within the output level set if (m_BufferedRegion.IsInside(idx)) diff --git a/Modules/Filtering/FastMarching/include/itkFastMarchingImageToNodePairContainerAdaptor.hxx b/Modules/Filtering/FastMarching/include/itkFastMarchingImageToNodePairContainerAdaptor.hxx index 924e038789d..1d71c00b726 100644 --- a/Modules/Filtering/FastMarching/include/itkFastMarchingImageToNodePairContainerAdaptor.hxx +++ b/Modules/Filtering/FastMarching/include/itkFastMarchingImageToNodePairContainerAdaptor.hxx @@ -125,7 +125,7 @@ FastMarchingImageToNodePairContainerAdaptor::SetPointsF { if (iLabel == Traits::Alive || iLabel == Traits::InitialTrial || iLabel == Traits::Forbidden) { - NodePairContainerPointer nodes = NodePairContainerType::New(); + const NodePairContainerPointer nodes = NodePairContainerType::New(); using IteratorType = ImageRegionConstIteratorWithIndex; IteratorType it(image, image->GetBufferedRegion()); diff --git a/Modules/Filtering/FastMarching/include/itkFastMarchingQuadEdgeMeshFilterBase.hxx b/Modules/Filtering/FastMarching/include/itkFastMarchingQuadEdgeMeshFilterBase.hxx index 3627b96ec00..1a96cc8e176 100644 --- a/Modules/Filtering/FastMarching/include/itkFastMarchingQuadEdgeMeshFilterBase.hxx +++ b/Modules/Filtering/FastMarching/include/itkFastMarchingQuadEdgeMeshFilterBase.hxx @@ -101,7 +101,7 @@ FastMarchingQuadEdgeMeshFilterBase::UpdateNeighbors(OutputMeshT { if (qe_it) { - OutputPointIdentifierType neigh_id = qe_it->GetDestination(); + const OutputPointIdentifierType neigh_id = qe_it->GetDestination(); const char label = this->GetLabelValueForGivenNode(neigh_id); @@ -174,7 +174,7 @@ FastMarchingQuadEdgeMeshFilterBase::UpdateValue(OutputMeshType if (val1 > val2) { - OutputPointType temp_pt(q1); + const OutputPointType temp_pt(q1); q1 = q2; q2 = temp_pt; @@ -233,27 +233,27 @@ FastMarchingQuadEdgeMeshFilterBase::Solve(OutputMeshType * OutputVectorType Edge1 = iP1 - iCurrentPoint; OutputVectorType Edge2 = iP2 - iCurrentPoint; - OutputVectorRealType sq_norm1 = Edge1.GetSquaredNorm(); - OutputVectorRealType norm1 = 0.; + const OutputVectorRealType sq_norm1 = Edge1.GetSquaredNorm(); + OutputVectorRealType norm1 = 0.; - OutputVectorRealType epsilon = NumericTraits::epsilon(); + const OutputVectorRealType epsilon = NumericTraits::epsilon(); if (sq_norm1 > epsilon) { norm1 = std::sqrt(sq_norm1); - OutputVectorRealType inv_norm1 = 1. / norm1; + const OutputVectorRealType inv_norm1 = 1. / norm1; Edge1 *= inv_norm1; } - OutputVectorRealType sq_norm2 = Edge2.GetSquaredNorm(); - OutputVectorRealType norm2 = 0.; + const OutputVectorRealType sq_norm2 = Edge2.GetSquaredNorm(); + OutputVectorRealType norm2 = 0.; if (sq_norm2 > epsilon) { norm2 = std::sqrt(sq_norm2); - OutputVectorRealType inv_norm2 = 1. / norm2; + const OutputVectorRealType inv_norm2 = 1. / norm2; Edge2 *= inv_norm2; } @@ -284,16 +284,16 @@ FastMarchingQuadEdgeMeshFilterBase::Solve(OutputMeshType * OutputVectorRealType dot2; OutputPointIdentifierType new_id; - bool unfolded = + const bool unfolded = UnfoldTriangle(oMesh, iId, iCurrentPoint, iId1, iP1, iId2, iP2, norm3, sq_norm3, dot1, dot2, new_id); if (unfolded) { - OutputVectorRealType t_sq_norm3 = norm3 * norm3; + const OutputVectorRealType t_sq_norm3 = norm3 * norm3; - auto val3 = static_cast(this->GetOutputValue(oMesh, new_id)); - OutputVectorRealType t1 = ComputeUpdate(iVal1, val3, norm3, t_sq_norm3, norm1, sq_norm1, dot1, iF); - OutputVectorRealType t2 = ComputeUpdate(iVal2, val3, norm3, t_sq_norm3, norm2, sq_norm2, dot2, iF); + auto val3 = static_cast(this->GetOutputValue(oMesh, new_id)); + const OutputVectorRealType t1 = ComputeUpdate(iVal1, val3, norm3, t_sq_norm3, norm1, sq_norm1, dot1, iF); + const OutputVectorRealType t2 = ComputeUpdate(iVal2, val3, norm3, t_sq_norm3, norm2, sq_norm2, dot2, iF); return std::min(t1, t2); } @@ -322,19 +322,19 @@ FastMarchingQuadEdgeMeshFilterBase::ComputeUpdate(const OutputV OutputVectorRealType t = large_value; - OutputVectorRealType CosAngle = iDot; - OutputVectorRealType SinAngle = std::sqrt(1. - iDot * iDot); + const OutputVectorRealType CosAngle = iDot; + const OutputVectorRealType SinAngle = std::sqrt(1. - iDot * iDot); - OutputVectorRealType u = iVal2 - iVal1; + const OutputVectorRealType u = iVal2 - iVal1; - OutputVectorRealType sq_u = u * u; - OutputVectorRealType f2 = iSqNorm1 + iSqNorm2 - 2. * iNorm1 * iNorm2 * CosAngle; - OutputVectorRealType f1 = iNorm2 * u * (iNorm1 * CosAngle - iNorm2); - OutputVectorRealType f0 = iSqNorm2 * (sq_u - iF * iF * iSqNorm1 * SinAngle * SinAngle); + const OutputVectorRealType sq_u = u * u; + const OutputVectorRealType f2 = iSqNorm1 + iSqNorm2 - 2. * iNorm1 * iNorm2 * CosAngle; + const OutputVectorRealType f1 = iNorm2 * u * (iNorm1 * CosAngle - iNorm2); + const OutputVectorRealType f0 = iSqNorm2 * (sq_u - iF * iF * iSqNorm1 * SinAngle * SinAngle); - OutputVectorRealType delta = f1 * f1 - f0 * f2; + const OutputVectorRealType delta = f1 * f1 - f0 * f2; - OutputVectorRealType epsilon = NumericTraits::epsilon(); + const OutputVectorRealType epsilon = NumericTraits::epsilon(); if (delta >= 0.) { @@ -394,11 +394,11 @@ FastMarchingQuadEdgeMeshFilterBase::UnfoldTriangle(OutputMeshTy OutputVectorType Edge1 = iP1 - iP; OutputVectorRealType Norm1 = Edge1.GetNorm(); - OutputVectorRealType epsilon = NumericTraits::epsilon(); + const OutputVectorRealType epsilon = NumericTraits::epsilon(); if (Norm1 > epsilon) { - OutputVectorRealType inv_Norm = 1. / Norm1; + const OutputVectorRealType inv_Norm = 1. / Norm1; Edge1 *= inv_Norm; } @@ -406,7 +406,7 @@ FastMarchingQuadEdgeMeshFilterBase::UnfoldTriangle(OutputMeshTy OutputVectorRealType Norm2 = Edge2.GetNorm(); if (Norm2 > epsilon) { - OutputVectorRealType inv_Norm = 1. / Norm2; + const OutputVectorRealType inv_Norm = 1. / Norm2; Edge2 *= inv_Norm; } @@ -432,8 +432,8 @@ FastMarchingQuadEdgeMeshFilterBase::UnfoldTriangle(OutputMeshTy Vector2DType x2 = Norm2 * v1; // keep track of the starting point - Vector2DType x_start1(x1); - Vector2DType x_start2(x2); + const Vector2DType x_start1(x1); + const Vector2DType x_start2(x2); OutputPointIdentifierType id1 = iId1; OutputPointIdentifierType id2 = iId2; @@ -448,8 +448,8 @@ FastMarchingQuadEdgeMeshFilterBase::UnfoldTriangle(OutputMeshTy unsigned int nNum = 0; while (nNum < 50 && qe->GetLeft() != OutputMeshType::m_NoFace) { - OutputQEType * qe_Lnext = qe->GetLnext(); - OutputPointIdentifierType t_id = qe_Lnext->GetDestination(); + OutputQEType * qe_Lnext = qe->GetLnext(); + const OutputPointIdentifierType t_id = qe_Lnext->GetDestination(); oMesh->GetPoint(t_id, &t_pt); @@ -457,7 +457,7 @@ FastMarchingQuadEdgeMeshFilterBase::UnfoldTriangle(OutputMeshTy Norm1 = Edge1.GetNorm(); if (Norm1 > epsilon) { - OutputVectorRealType inv_Norm = 1. / Norm1; + const OutputVectorRealType inv_Norm = 1. / Norm1; Edge1 *= inv_Norm; } @@ -465,7 +465,7 @@ FastMarchingQuadEdgeMeshFilterBase::UnfoldTriangle(OutputMeshTy Norm2 = Edge2.GetNorm(); if (Norm2 > epsilon) { - OutputVectorRealType inv_Norm = 1. / Norm2; + const OutputVectorRealType inv_Norm = 1. / Norm2; Edge2 *= inv_Norm; } @@ -491,19 +491,19 @@ FastMarchingQuadEdgeMeshFilterBase::UnfoldTriangle(OutputMeshTy rotation[1][0] = -rotation[0][1]; rotation[1][1] = dot; - Vector2DType x = rotation * vv + x1; + const Vector2DType x = rotation * vv + x1; /* compute the intersection points. We look for x=x1+lambda*(x-x1) or x=x2+lambda*(x-x2) with =0, so */ - OutputVectorRealType lambda11 = -(x1 * v1) / ((x - x1) * v1); // left most - OutputVectorRealType lambda12 = -(x1 * v2) / ((x - x1) * v2); // right most - OutputVectorRealType lambda21 = -(x2 * v1) / ((x - x2) * v1); // left most - OutputVectorRealType lambda22 = -(x2 * v2) / ((x - x2) * v2); // right most - bool bIntersect11 = (lambda11 >= 0.) && (lambda11 <= 1.); - bool bIntersect12 = (lambda12 >= 0.) && (lambda12 <= 1.); - bool bIntersect21 = (lambda21 >= 0.) && (lambda21 <= 1.); - bool bIntersect22 = (lambda22 >= 0.) && (lambda22 <= 1.); + const OutputVectorRealType lambda11 = -(x1 * v1) / ((x - x1) * v1); // left most + const OutputVectorRealType lambda12 = -(x1 * v2) / ((x - x1) * v2); // right most + const OutputVectorRealType lambda21 = -(x2 * v1) / ((x - x2) * v1); // left most + const OutputVectorRealType lambda22 = -(x2 * v2) / ((x - x2) * v2); // right most + const bool bIntersect11 = (lambda11 >= 0.) && (lambda11 <= 1.); + const bool bIntersect12 = (lambda12 >= 0.) && (lambda12 <= 1.); + const bool bIntersect21 = (lambda21 >= 0.) && (lambda21 <= 1.); + const bool bIntersect22 = (lambda22 >= 0.) && (lambda22 <= 1.); if (bIntersect11 && bIntersect12) { @@ -584,9 +584,9 @@ FastMarchingQuadEdgeMeshFilterBase::InitializeOutput(OutputMesh // Check that the input mesh is made of triangles { - OutputCellsContainerPointer cells = oMesh->GetCells(); - OutputCellsContainerConstIterator c_it = cells->Begin(); - OutputCellsContainerConstIterator c_end = cells->End(); + const OutputCellsContainerPointer cells = oMesh->GetCells(); + OutputCellsContainerConstIterator c_it = cells->Begin(); + const OutputCellsContainerConstIterator c_end = cells->End(); while (c_it != c_end) { @@ -600,13 +600,13 @@ FastMarchingQuadEdgeMeshFilterBase::InitializeOutput(OutputMesh } } - OutputPointsContainerPointer points = oMesh->GetPoints(); + const OutputPointsContainerPointer points = oMesh->GetPoints(); - OutputPointDataContainerPointer pointdata = OutputPointDataContainer::New(); + const OutputPointDataContainerPointer pointdata = OutputPointDataContainer::New(); pointdata->Reserve(points->Size()); - OutputPointsContainerIterator p_it = points->Begin(); - OutputPointsContainerIterator p_end = points->End(); + OutputPointsContainerIterator p_it = points->Begin(); + const OutputPointsContainerIterator p_end = points->End(); while (p_it != p_end) { @@ -620,17 +620,17 @@ FastMarchingQuadEdgeMeshFilterBase::InitializeOutput(OutputMesh if (this->m_AlivePoints) { - NodePairContainerConstIterator pointsIter = this->m_AlivePoints->Begin(); - NodePairContainerConstIterator pointsEnd = this->m_AlivePoints->End(); + NodePairContainerConstIterator pointsIter = this->m_AlivePoints->Begin(); + const NodePairContainerConstIterator pointsEnd = this->m_AlivePoints->End(); while (pointsIter != pointsEnd) { // get node from alive points container - NodeType idx = pointsIter->Value().GetNode(); + const NodeType idx = pointsIter->Value().GetNode(); if (points->IndexExists(idx)) { - OutputPixelType outputPixel = pointsIter->Value().GetValue(); + const OutputPixelType outputPixel = pointsIter->Value().GetValue(); this->SetLabelValueForGivenNode(idx, Traits::Alive); this->SetOutputValue(oMesh, idx, outputPixel); @@ -641,14 +641,14 @@ FastMarchingQuadEdgeMeshFilterBase::InitializeOutput(OutputMesh } if (this->m_ForbiddenPoints) { - NodePairContainerConstIterator pointsIter = this->m_ForbiddenPoints->Begin(); - NodePairContainerConstIterator pointsEnd = this->m_ForbiddenPoints->End(); + NodePairContainerConstIterator pointsIter = this->m_ForbiddenPoints->Begin(); + const NodePairContainerConstIterator pointsEnd = this->m_ForbiddenPoints->End(); - OutputPixelType zero{}; + const OutputPixelType zero{}; while (pointsIter != pointsEnd) { - NodeType idx = pointsIter->Value().GetNode(); + const NodeType idx = pointsIter->Value().GetNode(); if (points->IndexExists(idx)) { @@ -661,16 +661,16 @@ FastMarchingQuadEdgeMeshFilterBase::InitializeOutput(OutputMesh } if (this->m_TrialPoints) { - NodePairContainerConstIterator pointsIter = this->m_TrialPoints->Begin(); - NodePairContainerConstIterator pointsEnd = this->m_TrialPoints->End(); + NodePairContainerConstIterator pointsIter = this->m_TrialPoints->Begin(); + const NodePairContainerConstIterator pointsEnd = this->m_TrialPoints->End(); while (pointsIter != pointsEnd) { - NodeType idx = pointsIter->Value().GetNode(); + const NodeType idx = pointsIter->Value().GetNode(); if (points->IndexExists(idx)) { - OutputPixelType outputPixel = pointsIter->Value().GetValue(); + const OutputPixelType outputPixel = pointsIter->Value().GetValue(); this->SetLabelValueForGivenNode(idx, Traits::InitialTrial); this->SetOutputValue(oMesh, idx, outputPixel); diff --git a/Modules/Filtering/FastMarching/include/itkFastMarchingReachedTargetNodesStoppingCriterion.h b/Modules/Filtering/FastMarching/include/itkFastMarchingReachedTargetNodesStoppingCriterion.h index ce7e0d2f119..6114c57a61e 100644 --- a/Modules/Filtering/FastMarching/include/itkFastMarchingReachedTargetNodesStoppingCriterion.h +++ b/Modules/Filtering/FastMarching/include/itkFastMarchingReachedTargetNodesStoppingCriterion.h @@ -134,8 +134,8 @@ class ITK_TEMPLATE_EXPORT FastMarchingReachedTargetNodesStoppingCriterion // there is at least one TargetPoint. if (!m_TargetNodes.empty()) { - typename std::vector::const_iterator pointsIter = m_TargetNodes.begin(); - typename std::vector::const_iterator pointsEnd = m_TargetNodes.end(); + typename std::vector::const_iterator pointsIter = m_TargetNodes.begin(); + const typename std::vector::const_iterator pointsEnd = m_TargetNodes.end(); while (pointsIter != pointsEnd) { diff --git a/Modules/Filtering/FastMarching/include/itkFastMarchingUpwindGradientImageFilter.h b/Modules/Filtering/FastMarching/include/itkFastMarchingUpwindGradientImageFilter.h index 771906686e8..6e6c3c4f9e6 100644 --- a/Modules/Filtering/FastMarching/include/itkFastMarchingUpwindGradientImageFilter.h +++ b/Modules/Filtering/FastMarching/include/itkFastMarchingUpwindGradientImageFilter.h @@ -289,7 +289,7 @@ class ITK_TEMPLATE_EXPORT FastMarchingUpwindGradientImageFilter : public FastMar void VerifyTargetReachedModeConditions(unsigned int targetModeMinPoints = 1) const { - bool targetPointsExist = this->IsTargetPointsExistenceConditionSatisfied(); + const bool targetPointsExist = this->IsTargetPointsExistenceConditionSatisfied(); if (!targetPointsExist) { @@ -297,7 +297,7 @@ class ITK_TEMPLATE_EXPORT FastMarchingUpwindGradientImageFilter : public FastMar } else { - SizeValueType availableNumberOfTargets = m_TargetPoints->Size(); + const SizeValueType availableNumberOfTargets = m_TargetPoints->Size(); if (targetModeMinPoints > availableNumberOfTargets) { itkExceptionMacro("Not enough target points: Available: " << availableNumberOfTargets diff --git a/Modules/Filtering/FastMarching/include/itkFastMarchingUpwindGradientImageFilter.hxx b/Modules/Filtering/FastMarching/include/itkFastMarchingUpwindGradientImageFilter.hxx index c0866cd6aa8..b4984a27653 100644 --- a/Modules/Filtering/FastMarching/include/itkFastMarchingUpwindGradientImageFilter.hxx +++ b/Modules/Filtering/FastMarching/include/itkFastMarchingUpwindGradientImageFilter.hxx @@ -127,7 +127,7 @@ FastMarchingUpwindGradientImageFilter::GenerateData() // cache the original stopping value that was set by the user // because this subclass may change it once a target point is // reached in order to control the execution of the superclass. - double stoppingValue = this->GetStoppingValue(); + const double stoppingValue = this->GetStoppingValue(); // run the GenerateData() method of the superclass try @@ -172,8 +172,8 @@ FastMarchingUpwindGradientImageFilter::UpdateNeighbors(c if (m_TargetReachedMode == TargetConditionEnum::OneTarget) { - typename NodeContainer::ConstIterator pointsIter = m_TargetPoints->Begin(); - typename NodeContainer::ConstIterator pointsEnd = m_TargetPoints->End(); + typename NodeContainer::ConstIterator pointsIter = m_TargetPoints->Begin(); + const typename NodeContainer::ConstIterator pointsEnd = m_TargetPoints->End(); for (; pointsIter != pointsEnd; ++pointsIter) { node = pointsIter.Value(); @@ -187,8 +187,8 @@ FastMarchingUpwindGradientImageFilter::UpdateNeighbors(c } else if (m_TargetReachedMode == TargetConditionEnum::SomeTargets) { - typename NodeContainer::ConstIterator pointsIter = m_TargetPoints->Begin(); - typename NodeContainer::ConstIterator pointsEnd = m_TargetPoints->End(); + typename NodeContainer::ConstIterator pointsIter = m_TargetPoints->Begin(); + const typename NodeContainer::ConstIterator pointsEnd = m_TargetPoints->End(); for (; pointsIter != pointsEnd; ++pointsIter) { node = pointsIter.Value(); @@ -207,8 +207,8 @@ FastMarchingUpwindGradientImageFilter::UpdateNeighbors(c } else if (m_TargetReachedMode == TargetConditionEnum::AllTargets) { - typename NodeContainer::ConstIterator pointsIter = m_TargetPoints->Begin(); - typename NodeContainer::ConstIterator pointsEnd = m_TargetPoints->End(); + typename NodeContainer::ConstIterator pointsIter = m_TargetPoints->Begin(); + const typename NodeContainer::ConstIterator pointsEnd = m_TargetPoints->End(); for (; pointsIter != pointsEnd; ++pointsIter) { node = pointsIter.Value(); @@ -229,7 +229,7 @@ FastMarchingUpwindGradientImageFilter::UpdateNeighbors(c if (targetReached) { m_TargetValue = static_cast(output->GetPixel(index)); - double newStoppingValue = m_TargetValue + m_TargetOffset; + const double newStoppingValue = m_TargetValue + m_TargetOffset; if (newStoppingValue < this->GetStoppingValue()) { // This changes the stopping value that may have been set by diff --git a/Modules/Filtering/FastMarching/include/itkFastMarchingUpwindGradientImageFilterBase.hxx b/Modules/Filtering/FastMarching/include/itkFastMarchingUpwindGradientImageFilterBase.hxx index 308eb7e8155..e936bccc9ca 100644 --- a/Modules/Filtering/FastMarching/include/itkFastMarchingUpwindGradientImageFilterBase.hxx +++ b/Modules/Filtering/FastMarching/include/itkFastMarchingUpwindGradientImageFilterBase.hxx @@ -31,7 +31,7 @@ namespace itk template FastMarchingUpwindGradientImageFilterBase::FastMarchingUpwindGradientImageFilterBase() { - GradientImagePointer GradientImage = GradientImageType::New(); + const GradientImagePointer GradientImage = GradientImageType::New(); this->SetNthOutput(1, GradientImage.GetPointer()); } @@ -62,7 +62,7 @@ FastMarchingUpwindGradientImageFilterBase::InitializeOutput(Out Superclass::InitializeOutput(output); // allocate memory for the GradientImage if requested - GradientImagePointer GradientImage = this->GetGradientImage(); + const GradientImagePointer GradientImage = this->GetGradientImage(); GradientImage->CopyInformation(this->GetInput()); GradientImage->SetBufferedRegion(output->GetBufferedRegion()); @@ -168,7 +168,7 @@ FastMarchingUpwindGradientImageFilterBase::ComputeGradient(Outp gradientPixel[j] /= spacing[j]; } - GradientImagePointer GradientImage = this->GetGradientImage(); + const GradientImagePointer GradientImage = this->GetGradientImage(); GradientImage->SetPixel(iNode, gradientPixel); } } // namespace itk diff --git a/Modules/Filtering/FastMarching/test/itkFastMarchingBaseTest.cxx b/Modules/Filtering/FastMarching/test/itkFastMarchingBaseTest.cxx index 46fb977c506..a328ade82c8 100644 --- a/Modules/Filtering/FastMarching/test/itkFastMarchingBaseTest.cxx +++ b/Modules/Filtering/FastMarching/test/itkFastMarchingBaseTest.cxx @@ -144,7 +144,7 @@ itkFastMarchingBaseTest(int argc, char * argv[]) double normalizationFactor = 1.0; ITK_TEST_SET_GET_VALUE(normalizationFactor, fmm->GetNormalizationFactor()); - typename ImageFastMarching::OutputPixelType targetReachedValue{}; + const typename ImageFastMarching::OutputPixelType targetReachedValue{}; ITK_TEST_EXPECT_EQUAL(targetReachedValue, fmm->GetTargetReachedValue()); bool collectPoints = false; @@ -157,9 +157,9 @@ itkFastMarchingBaseTest(int argc, char * argv[]) auto processedPoints = ImageFastMarching::NodePairContainerType::New(); typename ImageFastMarching::NodePairType node_pair; - ImageType::OffsetType offset = { { 28, 35 } }; + const ImageType::OffsetType offset = { { 28, 35 } }; - itk::Index index{}; + const itk::Index index{}; node_pair.SetValue(0.0); node_pair.SetNode(index + offset); @@ -189,7 +189,7 @@ itkFastMarchingBaseTest(int argc, char * argv[]) using OutputImageType = ImageFastMarching::OutputDomainType; - [[maybe_unused]] OutputImageType::Pointer output = fmm->GetOutput(); + [[maybe_unused]] const OutputImageType::Pointer output = fmm->GetOutput(); } else if (useMeshVsImage == 1) { @@ -205,7 +205,7 @@ itkFastMarchingBaseTest(int argc, char * argv[]) using OutputMeshType = MeshFastMarching::OutputDomainType; - [[maybe_unused]] OutputMeshType::Pointer output = fmm->GetOutput(); + [[maybe_unused]] const OutputMeshType::Pointer output = fmm->GetOutput(); } // Test streaming enumeration for FastMarchingTraitsEnums::TopologyCheck elements diff --git a/Modules/Filtering/FastMarching/test/itkFastMarchingExtensionImageFilterTest.cxx b/Modules/Filtering/FastMarching/test/itkFastMarchingExtensionImageFilterTest.cxx index 4b5b39283d7..38bbeeb4e08 100644 --- a/Modules/Filtering/FastMarching/test/itkFastMarchingExtensionImageFilterTest.cxx +++ b/Modules/Filtering/FastMarching/test/itkFastMarchingExtensionImageFilterTest.cxx @@ -74,7 +74,7 @@ itkFastMarchingExtensionImageFilterTest(int, char *[]) // setup alive points auto AlivePoints = NodePairContainerType::New(); - FloatImageType::OffsetType offset0 = { { 28, 35 } }; + const FloatImageType::OffsetType offset0 = { { 28, 35 } }; itk::Index<2> index{}; @@ -113,7 +113,7 @@ itkFastMarchingExtensionImageFilterTest(int, char *[]) marcher->SetTrialPoints(TrialPoints); // specify the size of the output image - FloatImageType::SizeType size = { { 64, 64 } }; + const FloatImageType::SizeType size = { { 64, 64 } }; marcher->SetOutputSize(size); // setup a speed image of ones @@ -250,11 +250,11 @@ itkFastMarchingExtensionImageFilterTest(int, char *[]) // check the results passed = true; - FloatImageType::Pointer output = marcher->GetOutput(); + const FloatImageType::Pointer output = marcher->GetOutput(); itk::ImageRegionIterator iterator(output, output->GetBufferedRegion()); using AuxImageType = MarcherType::AuxImageType; - AuxImageType::Pointer auxImage = marcher->GetAuxiliaryImage(0); + const AuxImageType::Pointer auxImage = marcher->GetAuxiliaryImage(0); itk::ImageRegionIterator auxIterator(auxImage, auxImage->GetBufferedRegion()); while (!iterator.IsAtEnd()) diff --git a/Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterBaseTest.cxx b/Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterBaseTest.cxx index f42126d9564..313825674da 100644 --- a/Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterBaseTest.cxx +++ b/Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterBaseTest.cxx @@ -39,7 +39,7 @@ FastMarchingImageFilterBaseTestFunction() using FastMarchingImageFilterType = itk::FastMarchingImageFilterBase; auto fastMarchingFilter = FastMarchingImageFilterType::New(); - bool overrideOutputInformation = true; + const bool overrideOutputInformation = true; ITK_TEST_SET_GET_BOOLEAN(fastMarchingFilter, OverrideOutputInformation, overrideOutputInformation); auto outputSize = FastMarchingImageFilterType::OutputSizeType::Filled(32); @@ -60,7 +60,7 @@ FastMarchingImageFilterBaseTestFunction() fastMarchingFilter->SetOutputDirection(outputDirection); ITK_TEST_SET_GET_VALUE(outputDirection, fastMarchingFilter->GetOutputDirection()); - typename FastMarchingImageFilterType::OutputPointType outputOrigin{}; + const typename FastMarchingImageFilterType::OutputPointType outputOrigin{}; fastMarchingFilter->SetOutputOrigin(outputOrigin); ITK_TEST_SET_GET_VALUE(outputOrigin, fastMarchingFilter->GetOutputOrigin()); diff --git a/Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterRealTest1.cxx b/Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterRealTest1.cxx index c9698f72b0e..25228b5c860 100644 --- a/Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterRealTest1.cxx +++ b/Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterRealTest1.cxx @@ -59,7 +59,7 @@ itkFastMarchingImageFilterRealTest1(int itkNotUsed(argc), char * itkNotUsed(argv auto criterion = CriterionType::New(); - typename FloatImageType::PixelType threshold = 100.0; + const typename FloatImageType::PixelType threshold = 100.0; criterion->SetThreshold(threshold); ITK_TEST_SET_GET_VALUE(threshold, criterion->GetThreshold()); @@ -71,8 +71,9 @@ itkFastMarchingImageFilterRealTest1(int itkNotUsed(argc), char * itkNotUsed(argv marcher->SetStoppingCriterion(criterion); ITK_TEST_SET_GET_VALUE(criterion, marcher->GetStoppingCriterion()); - ShowProgressObject progressWatch(marcher); - itk::SimpleMemberCommand::Pointer command = itk::SimpleMemberCommand::New(); + ShowProgressObject progressWatch(marcher); + const itk::SimpleMemberCommand::Pointer command = + itk::SimpleMemberCommand::New(); command->SetCallbackFunction(&progressWatch, &ShowProgressObject::ShowProgress); marcher->AddObserver(itk::ProgressEvent(), command); @@ -84,7 +85,7 @@ itkFastMarchingImageFilterRealTest1(int itkNotUsed(argc), char * itkNotUsed(argv NodePairType node_pair; - FloatImageType::OffsetType offset0 = { { 28, 35 } }; + const FloatImageType::OffsetType offset0 = { { 28, 35 } }; itk::Index index{}; @@ -136,7 +137,7 @@ itkFastMarchingImageFilterRealTest1(int itkNotUsed(argc), char * itkNotUsed(argv ITK_TEST_SET_GET_VALUE(trial, marcher->GetTrialPoints()); // Specify the size of the output image - FloatImageType::SizeType size = { { 64, 64 } }; + const FloatImageType::SizeType size = { { 64, 64 } }; marcher->SetOutputSize(size); // Set up a speed image of ones @@ -167,13 +168,13 @@ itkFastMarchingImageFilterRealTest1(int itkNotUsed(argc), char * itkNotUsed(argv std::cout << "ProcessedPoints: " << marcher->GetProcessedPoints() << std::endl; // Check the results - FloatImageType::Pointer output = marcher->GetOutput(); + const FloatImageType::Pointer output = marcher->GetOutput(); itk::ImageRegionIterator iterator(output, output->GetBufferedRegion()); bool passed = true; - double outputValueThreshold = 1.42; + const double outputValueThreshold = 1.42; while (!iterator.IsAtEnd()) { FloatImageType::IndexType tempIndex = iterator.GetIndex(); diff --git a/Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterRealTest2.cxx b/Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterRealTest2.cxx index b72acd3040e..a87775826fb 100644 --- a/Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterRealTest2.cxx +++ b/Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterRealTest2.cxx @@ -68,13 +68,14 @@ itkFastMarchingImageFilterRealTest2(int itkNotUsed(argc), char * itkNotUsed(argv marcher->SetStoppingCriterion(criterion); - ShowProgressObject progressWatch(marcher); - itk::SimpleMemberCommand::Pointer command = itk::SimpleMemberCommand::New(); + ShowProgressObject progressWatch(marcher); + const itk::SimpleMemberCommand::Pointer command = + itk::SimpleMemberCommand::New(); command->SetCallbackFunction(&progressWatch, &ShowProgressObject::ShowProgress); marcher->AddObserver(itk::ProgressEvent(), command); // Specify the size of the output image - FloatImageType::SizeType size = { { 64, 64 } }; + const FloatImageType::SizeType size = { { 64, 64 } }; marcher->SetOutputSize(size); // Set up a speed image of ones @@ -92,7 +93,7 @@ itkFastMarchingImageFilterRealTest2(int itkNotUsed(argc), char * itkNotUsed(argv aliveImage->Allocate(); aliveImage->FillBuffer(0.0); - FloatImageType::OffsetType offset0 = { { 28, 35 } }; + const FloatImageType::OffsetType offset0 = { { 28, 35 } }; itk::Index index{}; index += offset0; @@ -156,20 +157,20 @@ itkFastMarchingImageFilterRealTest2(int itkNotUsed(argc), char * itkNotUsed(argv ITK_EXERCISE_BASIC_OBJECT_METHODS(adaptor, FastMarchingImageToNodePairContainerAdaptor, Object); - bool isForbiddenImageBinaryMask = true; + const bool isForbiddenImageBinaryMask = true; ITK_TEST_SET_GET_BOOLEAN(adaptor, IsForbiddenImageBinaryMask, isForbiddenImageBinaryMask); adaptor->SetAliveImage(aliveImage.GetPointer()); ITK_TEST_SET_GET_VALUE(aliveImage.GetPointer(), adaptor->GetAliveImage()); - typename AdaptorType::OutputPixelType aliveValue = 0.0; + const typename AdaptorType::OutputPixelType aliveValue = 0.0; adaptor->SetAliveValue(aliveValue); ITK_TEST_SET_GET_VALUE(aliveValue, adaptor->GetAliveValue()); adaptor->SetTrialImage(trialImage.GetPointer()); ITK_TEST_SET_GET_VALUE(trialImage.GetPointer(), adaptor->GetTrialImage()); - typename AdaptorType::OutputPixelType trialValue = 1.0; + const typename AdaptorType::OutputPixelType trialValue = 1.0; adaptor->SetTrialValue(trialValue); ITK_TEST_SET_GET_VALUE(trialValue, adaptor->GetTrialValue()); @@ -193,13 +194,13 @@ itkFastMarchingImageFilterRealTest2(int itkNotUsed(argc), char * itkNotUsed(argv // Check the results - FloatImageType::Pointer output = marcher->GetOutput(); + const FloatImageType::Pointer output = marcher->GetOutput(); itk::ImageRegionIterator iterator(output, output->GetBufferedRegion()); bool passed = true; - double threshold = 1.42; + const double threshold = 1.42; while (!iterator.IsAtEnd()) { FloatImageType::IndexType tempIndex = iterator.GetIndex(); diff --git a/Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterRealWithNumberOfElementsTest.cxx b/Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterRealWithNumberOfElementsTest.cxx index a72366cd728..69a94f9006e 100644 --- a/Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterRealWithNumberOfElementsTest.cxx +++ b/Modules/Filtering/FastMarching/test/itkFastMarchingImageFilterRealWithNumberOfElementsTest.cxx @@ -53,7 +53,7 @@ itkFastMarchingImageFilterRealWithNumberOfElementsTest(int, char *[]) NodePairType node_pair; - FloatImageType::OffsetType offset0 = { { 28, 35 } }; + const FloatImageType::OffsetType offset0 = { { 28, 35 } }; itk::Index<2> index{}; @@ -103,7 +103,7 @@ itkFastMarchingImageFilterRealWithNumberOfElementsTest(int, char *[]) marcher->SetTrialPoints(trial); // specify the size of the output image - FloatImageType::SizeType size = { { 64, 64 } }; + const FloatImageType::SizeType size = { { 64, 64 } }; marcher->SetOutputSize(size); // setup a speed image of ones @@ -143,7 +143,7 @@ itkFastMarchingImageFilterRealWithNumberOfElementsTest(int, char *[]) ITK_TRY_EXPECT_NO_EXCEPTION(thresholder->Update()); - OutputImageType::Pointer output = thresholder->GetOutput(); + const OutputImageType::Pointer output = thresholder->GetOutput(); using OutputIteratorType = itk::ImageRegionConstIterator; diff --git a/Modules/Filtering/FastMarching/test/itkFastMarchingImageTopologicalTest.cxx b/Modules/Filtering/FastMarching/test/itkFastMarchingImageTopologicalTest.cxx index a303b7eccf1..e9f7981b646 100644 --- a/Modules/Filtering/FastMarching/test/itkFastMarchingImageTopologicalTest.cxx +++ b/Modules/Filtering/FastMarching/test/itkFastMarchingImageTopologicalTest.cxx @@ -41,15 +41,15 @@ FastMarchingImageFilter(unsigned int argc, char * argv[]) using CriterionPointer = typename CriterionType::Pointer; - InternalPixelType stoppingValue = std::stod(argv[5]); + const InternalPixelType stoppingValue = std::stod(argv[5]); - CriterionPointer criterion = CriterionType::New(); + const CriterionPointer criterion = CriterionType::New(); criterion->SetThreshold(stoppingValue); using ReaderType = itk::ImageFileReader; using ReaderPointer = typename ReaderType::Pointer; - ReaderPointer reader = ReaderType::New(); + const ReaderPointer reader = ReaderType::New(); reader->SetFileName(argv[2]); try { @@ -65,7 +65,7 @@ FastMarchingImageFilter(unsigned int argc, char * argv[]) using FastMarchingType = itk::FastMarchingImageFilterBase; using FastMarchingPointer = typename FastMarchingType::Pointer; - FastMarchingPointer fastMarching = FastMarchingType::New(); + const FastMarchingPointer fastMarching = FastMarchingType::New(); fastMarching->SetInput(reader->GetOutput()); fastMarching->SetStoppingCriterion(criterion); @@ -74,7 +74,7 @@ FastMarchingImageFilter(unsigned int argc, char * argv[]) using LabelImageReaderType = itk::ImageFileReader; using LabelImageReaderPointer = typename LabelImageReaderType::Pointer; - LabelImageReaderPointer labelImageReader = LabelImageReaderType::New(); + const LabelImageReaderPointer labelImageReader = LabelImageReaderType::New(); labelImageReader->SetFileName(argv[4]); try @@ -88,7 +88,7 @@ FastMarchingImageFilter(unsigned int argc, char * argv[]) return EXIT_FAILURE; } - LabelType label_zero{}; + const LabelType label_zero{}; using ContourFilterType = itk::LabelContourImageFilter; auto contour = ContourFilterType::New(); @@ -207,7 +207,7 @@ FastMarchingImageFilter(unsigned int argc, char * argv[]) if (argc > 7) { { - std::string filename = std::string(argv[7]) + std::string("LevelSet.nii.gz"); + const std::string filename = std::string(argv[7]) + std::string("LevelSet.nii.gz"); using InternalWriterType = itk::ImageFileWriter; auto internal_writer = InternalWriterType::New(); internal_writer->SetInput(fastMarching->GetOutput()); @@ -226,7 +226,7 @@ FastMarchingImageFilter(unsigned int argc, char * argv[]) } { - std::string filename = std::string(argv[7]) + std::string("LabelMap.nii.gz"); + const std::string filename = std::string(argv[7]) + std::string("LabelMap.nii.gz"); using LabelImageWriterType = itk::ImageFileWriter; auto mapWriter = LabelImageWriterType::New(); mapWriter->SetInput(fastMarching->GetLabelImage()); diff --git a/Modules/Filtering/FastMarching/test/itkFastMarchingQuadEdgeMeshFilterBaseTest.cxx b/Modules/Filtering/FastMarching/test/itkFastMarchingQuadEdgeMeshFilterBaseTest.cxx index 9818c8e4f84..a3929eeb875 100644 --- a/Modules/Filtering/FastMarching/test/itkFastMarchingQuadEdgeMeshFilterBaseTest.cxx +++ b/Modules/Filtering/FastMarching/test/itkFastMarchingQuadEdgeMeshFilterBaseTest.cxx @@ -45,7 +45,7 @@ itkFastMarchingQuadEdgeMeshFilterBaseTest(int, char *[]) using FastMarchingType = itk::FastMarchingQuadEdgeMeshFilterBase; - MeshType::PointType center{}; + const MeshType::PointType center{}; using SphereSourceType = itk::RegularSphereMeshSource; auto sphere_filter = SphereSourceType::New(); @@ -53,12 +53,12 @@ itkFastMarchingQuadEdgeMeshFilterBaseTest(int, char *[]) sphere_filter->SetResolution(5); sphere_filter->Update(); - MeshType::Pointer sphere_output = sphere_filter->GetOutput(); + const MeshType::Pointer sphere_output = sphere_filter->GetOutput(); - MeshType::PointsContainerConstPointer points = sphere_output->GetPoints(); + const MeshType::PointsContainerConstPointer points = sphere_output->GetPoints(); - MeshType::PointsContainerConstIterator p_it = points->Begin(); - MeshType::PointsContainerConstIterator p_end = points->End(); + MeshType::PointsContainerConstIterator p_it = points->Begin(); + const MeshType::PointsContainerConstIterator p_end = points->End(); while (p_it != p_end) { @@ -72,7 +72,7 @@ itkFastMarchingQuadEdgeMeshFilterBaseTest(int, char *[]) auto trial = NodePairContainerType::New(); - NodePairType node_pair(0, 0.); + const NodePairType node_pair(0, 0.); trial->push_back(node_pair); using CriterionType = itk::FastMarchingThresholdStoppingCriterion; diff --git a/Modules/Filtering/FastMarching/test/itkFastMarchingQuadEdgeMeshFilterBaseTest2.cxx b/Modules/Filtering/FastMarching/test/itkFastMarchingQuadEdgeMeshFilterBaseTest2.cxx index f4f84d1e960..c3ca92e1b09 100644 --- a/Modules/Filtering/FastMarching/test/itkFastMarchingQuadEdgeMeshFilterBaseTest2.cxx +++ b/Modules/Filtering/FastMarching/test/itkFastMarchingQuadEdgeMeshFilterBaseTest2.cxx @@ -54,8 +54,8 @@ itkFastMarchingQuadEdgeMeshFilterBaseTest2(int, char *[]) // Let's create here a plane! auto plane = MeshType::New(); - PointsContainerPointer points = PointsContainer::New(); - PointDataContainerPointer pointdata = PointDataContainer::New(); + const PointsContainerPointer points = PointsContainer::New(); + const PointDataContainerPointer pointdata = PointDataContainer::New(); points->Reserve(100); pointdata->Reserve(100); @@ -100,7 +100,7 @@ itkFastMarchingQuadEdgeMeshFilterBaseTest2(int, char *[]) auto trial = NodePairContainerType::New(); - NodePairType node_pair(0, 0.); + const NodePairType node_pair(0, 0.); trial->push_back(node_pair); using CriterionType = itk::FastMarchingThresholdStoppingCriterion; @@ -123,12 +123,12 @@ itkFastMarchingQuadEdgeMeshFilterBaseTest2(int, char *[]) return EXIT_FAILURE; } - MeshType::Pointer output = fmm_filter->GetOutput(); + const MeshType::Pointer output = fmm_filter->GetOutput(); - PointDataContainerPointer output_data = output->GetPointData(); + const PointDataContainerPointer output_data = output->GetPointData(); - PointDataContainer::ConstIterator o_data_it = output_data->Begin(); - PointDataContainer::ConstIterator o_data_end = output_data->End(); + PointDataContainer::ConstIterator o_data_it = output_data->Begin(); + const PointDataContainer::ConstIterator o_data_end = output_data->End(); PointsContainer::ConstIterator p_it = points->Begin(); @@ -138,7 +138,7 @@ itkFastMarchingQuadEdgeMeshFilterBaseTest2(int, char *[]) while (o_data_it != o_data_end) { - PixelType expected_value = p.EuclideanDistanceTo(p_it->Value()); + const PixelType expected_value = p.EuclideanDistanceTo(p_it->Value()); if ((o_data_it->Value() - expected_value) > 5. * expected_value / 100.) { diff --git a/Modules/Filtering/FastMarching/test/itkFastMarchingQuadEdgeMeshFilterBaseTest3.cxx b/Modules/Filtering/FastMarching/test/itkFastMarchingQuadEdgeMeshFilterBaseTest3.cxx index 2d0a99358fc..4188e79f749 100644 --- a/Modules/Filtering/FastMarching/test/itkFastMarchingQuadEdgeMeshFilterBaseTest3.cxx +++ b/Modules/Filtering/FastMarching/test/itkFastMarchingQuadEdgeMeshFilterBaseTest3.cxx @@ -51,8 +51,8 @@ itkFastMarchingQuadEdgeMeshFilterBaseTest3(int, char *[]) // Let's create here a plane! auto plane = MeshType::New(); - PointsContainerPointer points = PointsContainer::New(); - PointDataContainerPointer pointdata = PointDataContainer::New(); + const PointsContainerPointer points = PointsContainer::New(); + const PointDataContainerPointer pointdata = PointDataContainer::New(); points->Reserve(100); pointdata->Reserve(100); @@ -68,8 +68,8 @@ itkFastMarchingQuadEdgeMeshFilterBaseTest3(int, char *[]) p[1] = static_cast(j); if ((k % 2 == 0) && (i != 0) && (j != 0)) { - auto exp = static_cast(k / 2); - CoordType delta = 0.1 * std::pow(-1., exp); + auto exp = static_cast(k / 2); + const CoordType delta = 0.1 * std::pow(-1., exp); p[0] += delta; p[1] += delta; } @@ -105,7 +105,7 @@ itkFastMarchingQuadEdgeMeshFilterBaseTest3(int, char *[]) auto trial = NodePairContainerType::New(); - NodePairType node_pair(0, 0.); + const NodePairType node_pair(0, 0.); trial->push_back(node_pair); using CriterionType = itk::FastMarchingThresholdStoppingCriterion; @@ -128,12 +128,12 @@ itkFastMarchingQuadEdgeMeshFilterBaseTest3(int, char *[]) return EXIT_FAILURE; } - MeshType::Pointer output = fmm_filter->GetOutput(); + const MeshType::Pointer output = fmm_filter->GetOutput(); - PointDataContainerPointer output_data = output->GetPointData(); + const PointDataContainerPointer output_data = output->GetPointData(); - PointDataContainer::ConstIterator o_data_it = output_data->Begin(); - PointDataContainer::ConstIterator o_data_end = output_data->End(); + PointDataContainer::ConstIterator o_data_it = output_data->Begin(); + const PointDataContainer::ConstIterator o_data_end = output_data->End(); PointsContainer::ConstIterator p_it = points->Begin(); @@ -143,7 +143,7 @@ itkFastMarchingQuadEdgeMeshFilterBaseTest3(int, char *[]) while (o_data_it != o_data_end) { - PixelType expected_value = p.EuclideanDistanceTo(p_it->Value()); + const PixelType expected_value = p.EuclideanDistanceTo(p_it->Value()); if ((o_data_it->Value() - expected_value) > 5. * expected_value / 100.) { diff --git a/Modules/Filtering/FastMarching/test/itkFastMarchingQuadEdgeMeshFilterBaseTest4.cxx b/Modules/Filtering/FastMarching/test/itkFastMarchingQuadEdgeMeshFilterBaseTest4.cxx index 36900aee02e..533cfceef64 100644 --- a/Modules/Filtering/FastMarching/test/itkFastMarchingQuadEdgeMeshFilterBaseTest4.cxx +++ b/Modules/Filtering/FastMarching/test/itkFastMarchingQuadEdgeMeshFilterBaseTest4.cxx @@ -54,8 +54,8 @@ itkFastMarchingQuadEdgeMeshFilterBaseTest4(int, char *[]) // Let's create here a plane! auto plane = MeshType::New(); - PointsContainerPointer points = PointsContainer::New(); - PointDataContainerPointer pointdata = PointDataContainer::New(); + const PointsContainerPointer points = PointsContainer::New(); + const PointDataContainerPointer pointdata = PointDataContainer::New(); points->Reserve(100); pointdata->Reserve(100); @@ -63,9 +63,9 @@ itkFastMarchingQuadEdgeMeshFilterBaseTest4(int, char *[]) MeshType::PointType p; p[2] = 0.; - int k = 0; - double alpha = (30.0 / 180.0) * itk::Math::pi; - double delta = 2.0 / std::tan(alpha); + int k = 0; + const double alpha = (30.0 / 180.0) * itk::Math::pi; + const double delta = 2.0 / std::tan(alpha); for (int i = 0; i < 10; ++i) { @@ -102,7 +102,7 @@ itkFastMarchingQuadEdgeMeshFilterBaseTest4(int, char *[]) auto trial = NodePairContainerType::New(); - NodePairType node_pair(0, 0.); + const NodePairType node_pair(0, 0.); trial->push_back(node_pair); using CriterionType = itk::FastMarchingThresholdStoppingCriterion; @@ -125,12 +125,12 @@ itkFastMarchingQuadEdgeMeshFilterBaseTest4(int, char *[]) return EXIT_FAILURE; } - MeshType::Pointer output = fmm_filter->GetOutput(); + const MeshType::Pointer output = fmm_filter->GetOutput(); - PointDataContainerPointer output_data = output->GetPointData(); + const PointDataContainerPointer output_data = output->GetPointData(); - PointDataContainer::ConstIterator o_data_it = output_data->Begin(); - PointDataContainer::ConstIterator o_data_end = output_data->End(); + PointDataContainer::ConstIterator o_data_it = output_data->Begin(); + const PointDataContainer::ConstIterator o_data_end = output_data->End(); PointsContainer::ConstIterator p_it = points->Begin(); @@ -140,7 +140,7 @@ itkFastMarchingQuadEdgeMeshFilterBaseTest4(int, char *[]) while (o_data_it != o_data_end) { - PixelType expected_value = p.EuclideanDistanceTo(p_it->Value()); + const PixelType expected_value = p.EuclideanDistanceTo(p_it->Value()); if ((o_data_it->Value() - expected_value) > 5. * expected_value / 100.) { diff --git a/Modules/Filtering/FastMarching/test/itkFastMarchingQuadEdgeMeshFilterWithNumberOfElementsTest.cxx b/Modules/Filtering/FastMarching/test/itkFastMarchingQuadEdgeMeshFilterWithNumberOfElementsTest.cxx index 027716b35b6..06f19357d3e 100644 --- a/Modules/Filtering/FastMarching/test/itkFastMarchingQuadEdgeMeshFilterWithNumberOfElementsTest.cxx +++ b/Modules/Filtering/FastMarching/test/itkFastMarchingQuadEdgeMeshFilterWithNumberOfElementsTest.cxx @@ -44,7 +44,7 @@ itkFastMarchingQuadEdgeMeshFilterWithNumberOfElementsTest(int, char *[]) using FastMarchingType = itk::FastMarchingQuadEdgeMeshFilterBase; - MeshType::PointType center{}; + const MeshType::PointType center{}; using SphereSourceType = itk::RegularSphereMeshSource; auto sphere_filter = SphereSourceType::New(); @@ -52,12 +52,12 @@ itkFastMarchingQuadEdgeMeshFilterWithNumberOfElementsTest(int, char *[]) sphere_filter->SetResolution(5); sphere_filter->Update(); - MeshType::Pointer sphere_output = sphere_filter->GetOutput(); + const MeshType::Pointer sphere_output = sphere_filter->GetOutput(); - MeshType::PointsContainerConstPointer points = sphere_output->GetPoints(); + const MeshType::PointsContainerConstPointer points = sphere_output->GetPoints(); - MeshType::PointsContainerConstIterator p_it = points->Begin(); - MeshType::PointsContainerConstIterator p_end = points->End(); + MeshType::PointsContainerConstIterator p_it = points->Begin(); + const MeshType::PointsContainerConstIterator p_end = points->End(); while (p_it != p_end) { @@ -71,7 +71,7 @@ itkFastMarchingQuadEdgeMeshFilterWithNumberOfElementsTest(int, char *[]) auto trial = NodePairContainerType::New(); - NodePairType node_pair(0, 1.); + const NodePairType node_pair(0, 1.); trial->push_back(node_pair); using CriterionType = itk::FastMarchingNumberOfElementsStoppingCriterion; @@ -86,9 +86,9 @@ itkFastMarchingQuadEdgeMeshFilterWithNumberOfElementsTest(int, char *[]) ITK_TRY_EXPECT_NO_EXCEPTION(fmm_filter->Update()); - MeshType::Pointer output = fmm_filter->GetOutput(); + const MeshType::Pointer output = fmm_filter->GetOutput(); - MeshType::PointDataContainerPointer pointdata = output->GetPointData(); + const MeshType::PointDataContainerPointer pointdata = output->GetPointData(); MeshType::PointDataContainerIterator it = pointdata->Begin(); @@ -103,7 +103,7 @@ itkFastMarchingQuadEdgeMeshFilterWithNumberOfElementsTest(int, char *[]) ++it; } - unsigned int expectedMinPointCount = 100; + const unsigned int expectedMinPointCount = 100; if (counter < expectedMinPointCount) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/FastMarching/test/itkFastMarchingTest.cxx b/Modules/Filtering/FastMarching/test/itkFastMarchingTest.cxx index e9f1b4fba06..6b39c3aa7ce 100644 --- a/Modules/Filtering/FastMarching/test/itkFastMarchingTest.cxx +++ b/Modules/Filtering/FastMarching/test/itkFastMarchingTest.cxx @@ -78,7 +78,7 @@ itkFastMarchingTest(int argc, char * argv[]) NodeType node; - FloatImage::OffsetType offset0 = { { 28, 35 } }; + const FloatImage::OffsetType offset0 = { { 28, 35 } }; itk::Index<2> index{}; @@ -145,14 +145,14 @@ itkFastMarchingTest(int argc, char * argv[]) auto collectPoints = static_cast(std::stoi(argv[4])); ITK_TEST_SET_GET_BOOLEAN(marcher, CollectPoints, collectPoints); - typename FloatImage::SizeType size = { { 64, 64 } }; + const typename FloatImage::SizeType size = { { 64, 64 } }; marcher->SetOutputSize(size); ITK_TEST_SET_GET_VALUE(size, marcher->GetOutputSize()); auto outputRegionIndexValue = static_cast(std::stoi(argv[5])); auto outputRegionIndex = FloatFMType::LevelSetImageType::IndexType::Filled(outputRegionIndexValue); - typename FloatFMType::OutputRegionType outputRegion{ outputRegionIndex, size }; + const typename FloatFMType::OutputRegionType outputRegion{ outputRegionIndex, size }; marcher->SetOutputRegion(outputRegion); ITK_TEST_SET_GET_VALUE(outputRegion, marcher->GetOutputRegion()); @@ -198,7 +198,7 @@ itkFastMarchingTest(int argc, char * argv[]) marcher->Update(); // check the results - FloatImage::Pointer output = marcher->GetOutput(); + const FloatImage::Pointer output = marcher->GetOutput(); itk::ImageRegionIterator iterator(output, output->GetBufferedRegion()); bool passed = true; diff --git a/Modules/Filtering/FastMarching/test/itkFastMarchingTest2.cxx b/Modules/Filtering/FastMarching/test/itkFastMarchingTest2.cxx index cdd6185b1be..53464a38bc7 100644 --- a/Modules/Filtering/FastMarching/test/itkFastMarchingTest2.cxx +++ b/Modules/Filtering/FastMarching/test/itkFastMarchingTest2.cxx @@ -66,7 +66,7 @@ itkFastMarchingTest2(int, char *[]) NodeType node; - FloatImage::OffsetType offset0 = { { 28, 35 } }; + const FloatImage::OffsetType offset0 = { { 28, 35 } }; itk::Index<2> index{}; @@ -117,7 +117,7 @@ itkFastMarchingTest2(int, char *[]) marcher->SetTrialPoints(trialPoints); // specify the size of the output image - FloatImage::SizeType size = { { 64, 64 } }; + const FloatImage::SizeType size = { { 64, 64 } }; marcher->SetOutputSize(size); // setup a speed image of ones @@ -168,7 +168,7 @@ itkFastMarchingTest2(int, char *[]) // check the results - FloatImage::Pointer output = marcher->GetOutput(); + const FloatImage::Pointer output = marcher->GetOutput(); itk::ImageRegionIterator iterator(output, output->GetBufferedRegion()); bool passed = true; diff --git a/Modules/Filtering/FastMarching/test/itkFastMarchingUpwindGradientBaseTest.cxx b/Modules/Filtering/FastMarching/test/itkFastMarchingUpwindGradientBaseTest.cxx index 42f186be869..24a4121a98b 100644 --- a/Modules/Filtering/FastMarching/test/itkFastMarchingUpwindGradientBaseTest.cxx +++ b/Modules/Filtering/FastMarching/test/itkFastMarchingUpwindGradientBaseTest.cxx @@ -69,7 +69,7 @@ itkFastMarchingUpwindGradientBaseTest(int, char *[]) // &ShowProgressObject::ShowProgress); // marcher->AddObserver( itk::ProgressEvent(), command); - itk::SimpleFilterWatcher MarcherWatcher(marcher); + const itk::SimpleFilterWatcher MarcherWatcher(marcher); using NodeType = FloatFMType::NodeType; using NodePairType = FloatFMType::NodePairType; @@ -79,7 +79,7 @@ itkFastMarchingUpwindGradientBaseTest(int, char *[]) // setup alive points auto AlivePoints = NodePairContainerType::New(); - FloatImageType::OffsetType offset0 = { { 28, 35 } }; + const FloatImageType::OffsetType offset0 = { { 28, 35 } }; itk::Index<2> index{}; @@ -115,7 +115,7 @@ itkFastMarchingUpwindGradientBaseTest(int, char *[]) marcher->SetTrialPoints(TrialPoints); // specify the size of the output image - FloatImageType::SizeType size = { { 64, 64 } }; + const FloatImageType::SizeType size = { { 64, 64 } }; marcher->SetOutputSize(size); // setup a speed image of ones @@ -140,7 +140,7 @@ itkFastMarchingUpwindGradientBaseTest(int, char *[]) // check the results using FloatGradientImage = FloatFMType::GradientImageType; using GradientPixelType = FloatGradientImage::PixelType; - FloatGradientImage::Pointer gradientOutput = marcher->GetGradientImage(); + const FloatGradientImage::Pointer gradientOutput = marcher->GetGradientImage(); itk::ImageRegionIterator iterator(gradientOutput, gradientOutput->GetBufferedRegion()); bool passed = true; @@ -162,7 +162,7 @@ itkFastMarchingUpwindGradientBaseTest(int, char *[]) outputPixel = iterator.Get(); - double outputPixelNorm{ outputPixel.GetNorm() }; + const double outputPixelNorm{ outputPixel.GetNorm() }; if (itk::Math::AlmostEquals(distance, 0.0)) { @@ -206,7 +206,7 @@ itkFastMarchingUpwindGradientBaseTest(int, char *[]) } criterion->SetTargetNodes(TargetNodes); - typename CriterionType::OutputPixelType targetOffset{}; + const typename CriterionType::OutputPixelType targetOffset{}; criterion->SetTargetOffset(targetOffset); ITK_TEST_SET_GET_VALUE(targetOffset, criterion->GetTargetOffset()); diff --git a/Modules/Filtering/FastMarching/test/itkFastMarchingUpwindGradientTest.cxx b/Modules/Filtering/FastMarching/test/itkFastMarchingUpwindGradientTest.cxx index cbed365b5a1..c21def308c4 100644 --- a/Modules/Filtering/FastMarching/test/itkFastMarchingUpwindGradientTest.cxx +++ b/Modules/Filtering/FastMarching/test/itkFastMarchingUpwindGradientTest.cxx @@ -60,7 +60,7 @@ itkFastMarchingUpwindGradientTest(int, char *[]) // &ShowProgressObject::ShowProgress); // marcher->AddObserver( itk::ProgressEvent(), command); - itk::SimpleFilterWatcher MarcherWatcher(marcher); + const itk::SimpleFilterWatcher MarcherWatcher(marcher); using NodeType = FloatFMType::NodeType; using NodeContainer = FloatFMType::NodeContainer; @@ -70,7 +70,7 @@ itkFastMarchingUpwindGradientTest(int, char *[]) NodeType node; - FloatImage::OffsetType offset0 = { { 28, 35 } }; + const FloatImage::OffsetType offset0 = { { 28, 35 } }; itk::Index<2> index{}; @@ -121,7 +121,7 @@ itkFastMarchingUpwindGradientTest(int, char *[]) marcher->SetTrialPoints(trialPoints); // specify the size of the output image - FloatImage::SizeType size = { { 64, 64 } }; + const FloatImage::SizeType size = { { 64, 64 } }; marcher->SetOutputSize(size); // setup a speed image of ones @@ -140,17 +140,17 @@ itkFastMarchingUpwindGradientTest(int, char *[]) // speedImage->Print( std::cout ); marcher->SetInput(speedImage); - double stoppingValue = 100.0; + const double stoppingValue = 100.0; marcher->SetStoppingValue(stoppingValue); ITK_TEST_SET_GET_VALUE(stoppingValue, marcher->GetStoppingValue()); - bool generateGradientImage = true; + const bool generateGradientImage = true; ITK_TEST_SET_GET_BOOLEAN(marcher, GenerateGradientImage, generateGradientImage); // Exercise this member function. // It is also necessary that the TargetOffset be set to 0.0 for the TargetReached // tests to pass. - double targetOffset = 0.0; + const double targetOffset = 0.0; marcher->SetTargetOffset(targetOffset); ITK_TEST_SET_GET_VALUE(targetOffset, marcher->GetTargetOffset()); @@ -178,7 +178,7 @@ itkFastMarchingUpwindGradientTest(int, char *[]) // check the results using FloatGradientImage = FloatFMType::GradientImageType; using GradientPixelType = FloatGradientImage::PixelType; - FloatGradientImage::Pointer gradientOutput = marcher->GetGradientImage(); + const FloatGradientImage::Pointer gradientOutput = marcher->GetGradientImage(); itk::ImageRegionIterator iterator(gradientOutput, gradientOutput->GetBufferedRegion()); bool passed = true; @@ -201,7 +201,7 @@ itkFastMarchingUpwindGradientTest(int, char *[]) outputPixel = iterator.Get(); - double outputPixelNorm{ outputPixel.GetNorm() }; + const double outputPixelNorm{ outputPixel.GetNorm() }; if (distance == 0.0) { @@ -354,7 +354,7 @@ itkFastMarchingUpwindGradientTest(int, char *[]) #endif ITK_TEST_SET_GET_VALUE(FloatFMType::TargetConditionEnum::NoTargets, marcher->GetTargetReachedMode()); - double newStoppingValue = 10.0; + const double newStoppingValue = 10.0; marcher->SetStoppingValue(newStoppingValue); ITK_TRY_EXPECT_NO_EXCEPTION(marcher->Update()); diff --git a/Modules/Filtering/ImageCompare/include/itkCheckerBoardImageFilter.hxx b/Modules/Filtering/ImageCompare/include/itkCheckerBoardImageFilter.hxx index 6385df01e8f..56d4cf675d0 100644 --- a/Modules/Filtering/ImageCompare/include/itkCheckerBoardImageFilter.hxx +++ b/Modules/Filtering/ImageCompare/include/itkCheckerBoardImageFilter.hxx @@ -54,9 +54,9 @@ void CheckerBoardImageFilter::DynamicThreadedGenerateData(const ImageRegionType & outputRegionForThread) { // Get the output pointers - OutputImagePointer outputPtr = this->GetOutput(); - InputImageConstPointer input1Ptr = this->GetInput(0); - InputImageConstPointer input2Ptr = this->GetInput(1); + const OutputImagePointer outputPtr = this->GetOutput(); + const InputImageConstPointer input1Ptr = this->GetInput(0); + const InputImageConstPointer input2Ptr = this->GetInput(1); // Create an iterator that will walk the output region for this thread. using OutputIterator = ImageRegionIteratorWithIndex; diff --git a/Modules/Filtering/ImageCompare/include/itkSTAPLEImageFilter.hxx b/Modules/Filtering/ImageCompare/include/itkSTAPLEImageFilter.hxx index 3186caf9b75..5175dc74872 100644 --- a/Modules/Filtering/ImageCompare/include/itkSTAPLEImageFilter.hxx +++ b/Modules/Filtering/ImageCompare/include/itkSTAPLEImageFilter.hxx @@ -57,13 +57,13 @@ STAPLEImageFilter::GenerateData() // Allocate the output "fuzzy" image. this->GetOutput()->SetBufferedRegion(this->GetOutput()->GetRequestedRegion()); this->GetOutput()->Allocate(); - typename TOutputImage::Pointer W = this->GetOutput(); + const typename TOutputImage::Pointer W = this->GetOutput(); // Initialize the output to all 0's W->FillBuffer(0.0); // Record the number of input files. - ProcessObject::DataObjectPointerArraySizeType number_of_input_files = this->GetNumberOfIndexedInputs(); + const ProcessObject::DataObjectPointerArraySizeType number_of_input_files = this->GetNumberOfIndexedInputs(); const auto D_it = make_unique_for_overwrite(number_of_input_files); diff --git a/Modules/Filtering/ImageCompare/include/itkSimilarityIndexImageFilter.hxx b/Modules/Filtering/ImageCompare/include/itkSimilarityIndexImageFilter.hxx index 7d9c1df4796..05ab4a5ecc6 100644 --- a/Modules/Filtering/ImageCompare/include/itkSimilarityIndexImageFilter.hxx +++ b/Modules/Filtering/ImageCompare/include/itkSimilarityIndexImageFilter.hxx @@ -62,12 +62,12 @@ SimilarityIndexImageFilter::GenerateInputRequestedRe // - the corresponding region of the second image if (this->GetInput1()) { - InputImage1Pointer image1 = const_cast(this->GetInput1()); + const InputImage1Pointer image1 = const_cast(this->GetInput1()); image1->SetRequestedRegionToLargestPossibleRegion(); if (this->GetInput2()) { - InputImage2Pointer image2 = const_cast(this->GetInput2()); + const InputImage2Pointer image2 = const_cast(this->GetInput2()); image2->SetRequestedRegion(this->GetInput1()->GetRequestedRegion()); } } @@ -86,7 +86,7 @@ void SimilarityIndexImageFilter::AllocateOutputs() { // Pass the first input through as the output - InputImage1Pointer image = const_cast(this->GetInput1()); + const InputImage1Pointer image = const_cast(this->GetInput1()); this->GraftOutput(image); } @@ -95,7 +95,7 @@ template void SimilarityIndexImageFilter::BeforeThreadedGenerateData() { - ThreadIdType numberOfWorkUnits = this->GetNumberOfWorkUnits(); + const ThreadIdType numberOfWorkUnits = this->GetNumberOfWorkUnits(); // Resize the thread temporaries m_CountOfImage1.SetSize(numberOfWorkUnits); @@ -112,7 +112,7 @@ template void SimilarityIndexImageFilter::AfterThreadedGenerateData() { - ThreadIdType numberOfWorkUnits = this->GetNumberOfWorkUnits(); + const ThreadIdType numberOfWorkUnits = this->GetNumberOfWorkUnits(); SizeValueType countImage1 = 0; SizeValueType countImage2 = 0; diff --git a/Modules/Filtering/ImageCompare/test/itkAbsoluteValueDifferenceImageFilterTest.cxx b/Modules/Filtering/ImageCompare/test/itkAbsoluteValueDifferenceImageFilterTest.cxx index 7d76f600474..bc7bb386158 100644 --- a/Modules/Filtering/ImageCompare/test/itkAbsoluteValueDifferenceImageFilterTest.cxx +++ b/Modules/Filtering/ImageCompare/test/itkAbsoluteValueDifferenceImageFilterTest.cxx @@ -67,7 +67,7 @@ itkAbsoluteValueDifferenceImageFilterTest(int, char *[]) start[1] = 0; start[2] = 0; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; // Initialize Image A inputImageA->SetRegions(region); @@ -122,7 +122,7 @@ itkAbsoluteValueDifferenceImageFilterTest(int, char *[]) filter->SetInput2(inputImageB); // Get the Smart Pointer to the Filter Output - myImageType4::Pointer outputImage = filter->GetOutput(); + const myImageType4::Pointer outputImage = filter->GetOutput(); // Execute the filter diff --git a/Modules/Filtering/ImageCompare/test/itkCheckerBoardImageFilterTest.cxx b/Modules/Filtering/ImageCompare/test/itkCheckerBoardImageFilterTest.cxx index 4e5504c7fd3..2649d88f23a 100644 --- a/Modules/Filtering/ImageCompare/test/itkCheckerBoardImageFilterTest.cxx +++ b/Modules/Filtering/ImageCompare/test/itkCheckerBoardImageFilterTest.cxx @@ -131,7 +131,7 @@ itkCheckerBoardImageFilterTest(int argc, char * argv[]) checkerBoard->Update(); // Get the filter output - ImageType::Pointer outputImage = checkerBoard->GetOutput(); + const ImageType::Pointer outputImage = checkerBoard->GetOutput(); // Write the result image using WriterType = itk::ImageFileWriter; diff --git a/Modules/Filtering/ImageCompare/test/itkConstrainedValueDifferenceImageFilterTest.cxx b/Modules/Filtering/ImageCompare/test/itkConstrainedValueDifferenceImageFilterTest.cxx index 18467ff1e49..f2921ce81fd 100644 --- a/Modules/Filtering/ImageCompare/test/itkConstrainedValueDifferenceImageFilterTest.cxx +++ b/Modules/Filtering/ImageCompare/test/itkConstrainedValueDifferenceImageFilterTest.cxx @@ -124,7 +124,7 @@ itkConstrainedValueDifferenceImageFilterTest(int argc, char * argv[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Write the result image using WriterType = itk::ImageFileWriter; diff --git a/Modules/Filtering/ImageCompare/test/itkSTAPLEImageFilterTest.cxx b/Modules/Filtering/ImageCompare/test/itkSTAPLEImageFilterTest.cxx index 884e7337db7..9aa4e85d469 100644 --- a/Modules/Filtering/ImageCompare/test/itkSTAPLEImageFilterTest.cxx +++ b/Modules/Filtering/ImageCompare/test/itkSTAPLEImageFilterTest.cxx @@ -43,7 +43,7 @@ class StaplerBase void AddFileName(const char * s) { - std::string tmp(s); + const std::string tmp(s); m_Files.push_back(tmp); } @@ -184,10 +184,10 @@ template int Stapler::Execute() { - typename itk::ImageFileReader::Pointer reader; - typename itk::ImageFileWriter::Pointer writer = itk::ImageFileWriter::New(); + typename itk::ImageFileReader::Pointer reader; + const typename itk::ImageFileWriter::Pointer writer = itk::ImageFileWriter::New(); - size_t numberOfFiles = m_Files.size(); + const size_t numberOfFiles = m_Files.size(); // Set the inputs for (size_t i = 0; i < numberOfFiles; ++i) @@ -269,7 +269,7 @@ itkSTAPLEImageFilterTest(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(confidenceWeight, stapler->GetConfidenceWeight()); // Execute the stapler - int ret = stapler->Execute(); + const int ret = stapler->Execute(); if (ret != EXIT_SUCCESS) { std::cerr << "Stapler failed!" << std::endl; @@ -299,7 +299,7 @@ itkSTAPLEImageFilterTest(int argc, char * argv[]) << stapler->GetSpecificity(i) << std::endl; } - std::vector specificity = stapler->GetSpecificity(); + const std::vector specificity = stapler->GetSpecificity(); std::cout << "Specificity: "; for (auto value : specificity) { @@ -307,7 +307,7 @@ itkSTAPLEImageFilterTest(int argc, char * argv[]) } std::cout << std::endl; - std::vector sensitivity = stapler->GetSensitivity(); + const std::vector sensitivity = stapler->GetSensitivity(); std::cout << "Sensitivity: "; for (auto value : specificity) { @@ -321,7 +321,7 @@ itkSTAPLEImageFilterTest(int argc, char * argv[]) std::cout << "Mean:\t\t" << avgP << "\t\t" << avgQ << std::endl; // Test index exceptions - unsigned int i = stapler->GetNumberOfFiles() + 1; + const unsigned int i = stapler->GetNumberOfFiles() + 1; ITK_TRY_EXPECT_EXCEPTION(stapler->GetSensitivity(i)); ITK_TRY_EXPECT_EXCEPTION(stapler->GetSpecificity(i)); diff --git a/Modules/Filtering/ImageCompare/test/itkSimilarityIndexImageFilterTest.cxx b/Modules/Filtering/ImageCompare/test/itkSimilarityIndexImageFilterTest.cxx index e2d6c635279..db622de220e 100644 --- a/Modules/Filtering/ImageCompare/test/itkSimilarityIndexImageFilterTest.cxx +++ b/Modules/Filtering/ImageCompare/test/itkSimilarityIndexImageFilterTest.cxx @@ -45,11 +45,11 @@ itkSimilarityIndexImageFilterTest(int, char *[]) image1->Allocate(); image2->Allocate(); - unsigned long numOfPixels = image1->GetBufferedRegion().GetNumberOfPixels(); - unsigned long lower1 = 0; - unsigned long upper1 = static_cast(static_cast(numOfPixels) * 0.75) - 1; - auto lower2 = static_cast(static_cast(numOfPixels) * 0.25); - unsigned long upper2 = numOfPixels - 1; + const unsigned long numOfPixels = image1->GetBufferedRegion().GetNumberOfPixels(); + const unsigned long lower1 = 0; + const unsigned long upper1 = static_cast(static_cast(numOfPixels) * 0.75) - 1; + auto lower2 = static_cast(static_cast(numOfPixels) * 0.25); + const unsigned long upper2 = numOfPixels - 1; itk::ImageRegionIterator it1(image1, image1->GetBufferedRegion()); itk::ImageRegionIterator it2(image2, image2->GetBufferedRegion()); @@ -100,8 +100,8 @@ itkSimilarityIndexImageFilterTest(int, char *[]) // check results - FilterType::RealType trueOverlap = 0.5 / 0.75; - FilterType::RealType overlap = filter->GetSimilarityIndex(); + const FilterType::RealType trueOverlap = 0.5 / 0.75; + const FilterType::RealType overlap = filter->GetSimilarityIndex(); std::cout << " True index: " << trueOverlap << std::endl; std::cout << " Computed index: " << overlap << std::endl; diff --git a/Modules/Filtering/ImageCompare/test/itkSquaredDifferenceImageFilterTest.cxx b/Modules/Filtering/ImageCompare/test/itkSquaredDifferenceImageFilterTest.cxx index 2f6941c9b82..386b927a6ee 100644 --- a/Modules/Filtering/ImageCompare/test/itkSquaredDifferenceImageFilterTest.cxx +++ b/Modules/Filtering/ImageCompare/test/itkSquaredDifferenceImageFilterTest.cxx @@ -67,7 +67,7 @@ itkSquaredDifferenceImageFilterTest(int, char *[]) start[1] = 0; start[2] = 0; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; // Initialize Image A inputImageA->SetRegions(region); @@ -122,7 +122,7 @@ itkSquaredDifferenceImageFilterTest(int, char *[]) filter->SetInput2(inputImageB); // Get the Smart Pointer to the Filter Output - myImageType4::Pointer outputImage = filter->GetOutput(); + const myImageType4::Pointer outputImage = filter->GetOutput(); // Execute the filter diff --git a/Modules/Filtering/ImageCompare/test/itkTestingComparisonImageFilterTest.cxx b/Modules/Filtering/ImageCompare/test/itkTestingComparisonImageFilterTest.cxx index b55166c284a..a5743bbd67f 100644 --- a/Modules/Filtering/ImageCompare/test/itkTestingComparisonImageFilterTest.cxx +++ b/Modules/Filtering/ImageCompare/test/itkTestingComparisonImageFilterTest.cxx @@ -73,11 +73,11 @@ itkTestingComparisonImageFilterTest(int argc, char * argv[]) filter->SetDifferenceThreshold(differenceThreshold); ITK_TEST_SET_GET_VALUE(differenceThreshold, filter->GetDifferenceThreshold()); - int toleranceRadius = std::stoi(argv[6]); + const int toleranceRadius = std::stoi(argv[6]); filter->SetToleranceRadius(toleranceRadius); ITK_TEST_SET_GET_VALUE(toleranceRadius, filter->GetToleranceRadius()); - itk::SimpleFilterWatcher watcher(filter, "Difference"); + const itk::SimpleFilterWatcher watcher(filter, "Difference"); // wire the pipeline filter->SetValidInput(reader1->GetOutput()); @@ -94,7 +94,7 @@ itkTestingComparisonImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update()); - unsigned long numberOfPixelsWithDifferences = filter->GetNumberOfPixelsWithDifferences(); + const unsigned long numberOfPixelsWithDifferences = filter->GetNumberOfPixelsWithDifferences(); char * end; ITK_TEST_EXPECT_EQUAL(numberOfPixelsWithDifferences, std::strtoul(argv[7], &end, 10)); diff --git a/Modules/Filtering/ImageCompose/include/itkComposeImageFilter.hxx b/Modules/Filtering/ImageCompose/include/itkComposeImageFilter.hxx index 5625cc9d8dc..d1e786c1a26 100644 --- a/Modules/Filtering/ImageCompose/include/itkComposeImageFilter.hxx +++ b/Modules/Filtering/ImageCompose/include/itkComposeImageFilter.hxx @@ -108,7 +108,8 @@ template void ComposeImageFilter::DynamicThreadedGenerateData(const RegionType & outputRegionForThread) { - typename OutputImageType::Pointer outputImage = static_cast(this->ProcessObject::GetOutput(0)); + const typename OutputImageType::Pointer outputImage = + static_cast(this->ProcessObject::GetOutput(0)); TotalProgressReporter progress(this, outputImage->GetRequestedRegion().GetNumberOfPixels()); diff --git a/Modules/Filtering/ImageCompose/include/itkJoinSeriesImageFilter.hxx b/Modules/Filtering/ImageCompose/include/itkJoinSeriesImageFilter.hxx index 6f5fc14000b..c7c76b12e1b 100644 --- a/Modules/Filtering/ImageCompose/include/itkJoinSeriesImageFilter.hxx +++ b/Modules/Filtering/ImageCompose/include/itkJoinSeriesImageFilter.hxx @@ -81,8 +81,8 @@ JoinSeriesImageFilter::GenerateOutputInformation() // this filter allows the input the output to be of different dimensions // Get pointers to the input and output - typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); - typename Superclass::InputImageConstPointer inputPtr = this->GetInput(); + const typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); + const typename Superclass::InputImageConstPointer inputPtr = this->GetInput(); if (!outputPtr || !inputPtr) { @@ -141,8 +141,8 @@ JoinSeriesImageFilter::GenerateOutputInformation() using InputDirectionType = typename InputImageType::DirectionType; using OutputDirectionType = typename OutputImageType::DirectionType; InputDirectionType inputDir = inputPtr->GetDirection(); - unsigned int inputdim = InputImageType::GetImageDimension(); - unsigned int outputdim = OutputImageType::GetImageDimension(); + const unsigned int inputdim = InputImageType::GetImageDimension(); + const unsigned int outputdim = OutputImageType::GetImageDimension(); OutputDirectionType outputDir = outputPtr->GetDirection(); for (unsigned int i = 0; i < outputdim; ++i) { @@ -185,12 +185,12 @@ JoinSeriesImageFilter::GenerateInputRequestedRegion() { return; } - OutputImageRegionType outputRegion = this->GetOutput()->GetRequestedRegion(); - IndexValueType begin = outputRegion.GetIndex(InputImageDimension); - IndexValueType end = begin + outputRegion.GetSize(InputImageDimension); + const OutputImageRegionType outputRegion = this->GetOutput()->GetRequestedRegion(); + const IndexValueType begin = outputRegion.GetIndex(InputImageDimension); + const IndexValueType end = begin + outputRegion.GetSize(InputImageDimension); for (IndexValueType idx = 0; idx < this->GetNumberOfIndexedInputs(); ++idx) { - InputImagePointer inputPtr = const_cast(this->GetInput(idx)); + const InputImagePointer inputPtr = const_cast(this->GetInput(idx)); if (!inputPtr) { // Because DataObject::PropagateRequestedRegion() allows only diff --git a/Modules/Filtering/ImageCompose/test/itkCompose2DCovariantVectorImageFilterTest.cxx b/Modules/Filtering/ImageCompose/test/itkCompose2DCovariantVectorImageFilterTest.cxx index 6f3e607614a..5596cdcea21 100644 --- a/Modules/Filtering/ImageCompose/test/itkCompose2DCovariantVectorImageFilterTest.cxx +++ b/Modules/Filtering/ImageCompose/test/itkCompose2DCovariantVectorImageFilterTest.cxx @@ -45,7 +45,7 @@ itkCompose2DCovariantVectorImageFilterTest(int, char *[]) size[1] = 2; size[2] = 2; - IndexType start{}; + const IndexType start{}; RegionType region; region.SetIndex(start); @@ -77,7 +77,7 @@ itkCompose2DCovariantVectorImageFilterTest(int, char *[]) using OutputImageType = FilterType::OutputImageType; - OutputImageType::Pointer twoVectorImage = filter->GetOutput(); + const OutputImageType::Pointer twoVectorImage = filter->GetOutput(); using OutputIterator = itk::ImageRegionIterator; using InputIterator = itk::ImageRegionIterator; diff --git a/Modules/Filtering/ImageCompose/test/itkCompose2DVectorImageFilterTest.cxx b/Modules/Filtering/ImageCompose/test/itkCompose2DVectorImageFilterTest.cxx index e4d0121a009..349065c62c4 100644 --- a/Modules/Filtering/ImageCompose/test/itkCompose2DVectorImageFilterTest.cxx +++ b/Modules/Filtering/ImageCompose/test/itkCompose2DVectorImageFilterTest.cxx @@ -45,7 +45,7 @@ itkCompose2DVectorImageFilterTest(int, char *[]) size[1] = 2; size[2] = 2; - IndexType start{}; + const IndexType start{}; RegionType region; region.SetIndex(start); @@ -76,7 +76,7 @@ itkCompose2DVectorImageFilterTest(int, char *[]) using OutputImageType = FilterType::OutputImageType; - OutputImageType::Pointer twoVectorImage = filter->GetOutput(); + const OutputImageType::Pointer twoVectorImage = filter->GetOutput(); using OutputIterator = itk::ImageRegionIterator; using InputIterator = itk::ImageRegionIterator; diff --git a/Modules/Filtering/ImageCompose/test/itkCompose3DCovariantVectorImageFilterTest.cxx b/Modules/Filtering/ImageCompose/test/itkCompose3DCovariantVectorImageFilterTest.cxx index 0f52acc95e3..e1a03a1337e 100644 --- a/Modules/Filtering/ImageCompose/test/itkCompose3DCovariantVectorImageFilterTest.cxx +++ b/Modules/Filtering/ImageCompose/test/itkCompose3DCovariantVectorImageFilterTest.cxx @@ -47,7 +47,7 @@ itkCompose3DCovariantVectorImageFilterTest(int, char *[]) size[1] = 2; size[2] = 2; - IndexType start{}; + const IndexType start{}; RegionType region; region.SetIndex(start); @@ -83,7 +83,7 @@ itkCompose3DCovariantVectorImageFilterTest(int, char *[]) using OutputImageType = FilterType::OutputImageType; - OutputImageType::Pointer threeVectorImage = filter->GetOutput(); + const OutputImageType::Pointer threeVectorImage = filter->GetOutput(); using OutputIterator = itk::ImageRegionIterator; using InputIterator = itk::ImageRegionIterator; diff --git a/Modules/Filtering/ImageCompose/test/itkCompose3DVectorImageFilterTest.cxx b/Modules/Filtering/ImageCompose/test/itkCompose3DVectorImageFilterTest.cxx index 68d9342f422..7b213c158e9 100644 --- a/Modules/Filtering/ImageCompose/test/itkCompose3DVectorImageFilterTest.cxx +++ b/Modules/Filtering/ImageCompose/test/itkCompose3DVectorImageFilterTest.cxx @@ -46,7 +46,7 @@ itkCompose3DVectorImageFilterTest(int, char *[]) size[1] = 2; size[2] = 2; - IndexType start{}; + const IndexType start{}; RegionType region; region.SetIndex(start); @@ -81,7 +81,7 @@ itkCompose3DVectorImageFilterTest(int, char *[]) using OutputImageType = FilterType::OutputImageType; - OutputImageType::Pointer threeVectorImage = filter->GetOutput(); + const OutputImageType::Pointer threeVectorImage = filter->GetOutput(); using OutputIterator = itk::ImageRegionIterator; using InputIterator = itk::ImageRegionIterator; diff --git a/Modules/Filtering/ImageCompose/test/itkComposeRGBImageFilterTest.cxx b/Modules/Filtering/ImageCompose/test/itkComposeRGBImageFilterTest.cxx index 5229d4396fe..97fe9cc586c 100644 --- a/Modules/Filtering/ImageCompose/test/itkComposeRGBImageFilterTest.cxx +++ b/Modules/Filtering/ImageCompose/test/itkComposeRGBImageFilterTest.cxx @@ -47,7 +47,7 @@ itkComposeRGBImageFilterTest(int, char *[]) size[1] = 2; size[2] = 2; - IndexType start{}; + const IndexType start{}; RegionType region; region.SetIndex(start); @@ -81,7 +81,7 @@ itkComposeRGBImageFilterTest(int, char *[]) return EXIT_FAILURE; } - OutputImageType::Pointer rgbImage = filter->GetOutput(); + const OutputImageType::Pointer rgbImage = filter->GetOutput(); using OutputIterator = itk::ImageRegionIterator; using InputIterator = itk::ImageRegionIterator; @@ -102,7 +102,7 @@ itkComposeRGBImageFilterTest(int, char *[]) while (!ot.IsAtEnd()) { - OutputPixelType outp = ot.Get(); + const OutputPixelType outp = ot.Get(); if (ir.Get() != outp.GetRed()) { std::cerr << "Error in red component" << std::endl; diff --git a/Modules/Filtering/ImageCompose/test/itkJoinImageFilterTest.cxx b/Modules/Filtering/ImageCompose/test/itkJoinImageFilterTest.cxx index 3458bf8818c..09c0388ea41 100644 --- a/Modules/Filtering/ImageCompose/test/itkJoinImageFilterTest.cxx +++ b/Modules/Filtering/ImageCompose/test/itkJoinImageFilterTest.cxx @@ -56,7 +56,7 @@ itkJoinImageFilterTest(int, char *[]) start[0] = 0; start[1] = 0; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; // Initialize Image A inputImageA->SetRegions(region); @@ -159,8 +159,8 @@ itkJoinImageFilterTest(int, char *[]) filter123->Update(); // This Update will force filter to execute, then filter123 // Create an iterator for going through the image #1#2 - myFilterType::OutputImageType::Pointer outputImage = filter->GetOutput(); - myOutputIteratorType it3(outputImage, outputImage->GetRequestedRegion()); + const myFilterType::OutputImageType::Pointer outputImage = filter->GetOutput(); + myOutputIteratorType it3(outputImage, outputImage->GetRequestedRegion()); // Print the content of the result image std::cout << std::endl; @@ -172,8 +172,8 @@ itkJoinImageFilterTest(int, char *[]) } // Create an iterator for going through the image #1#2#3 - myFilterType3::OutputImageType::Pointer outputImage123 = filter123->GetOutput(); - myOutputIteratorType3 it123(outputImage123, outputImage123->GetRequestedRegion()); + const myFilterType3::OutputImageType::Pointer outputImage123 = filter123->GetOutput(); + myOutputIteratorType3 it123(outputImage123, outputImage123->GetRequestedRegion()); // Print the content of the result image std::cout << std::endl; @@ -195,8 +195,8 @@ itkJoinImageFilterTest(int, char *[]) filter1->Update(); // Create an iterator for going through the image output - myFilterType1::OutputImageType::Pointer outputImage1 = filter1->GetOutput(); - myOutputIteratorType1 it4(outputImage1, outputImage1->GetRequestedRegion()); + const myFilterType1::OutputImageType::Pointer outputImage1 = filter1->GetOutput(); + myOutputIteratorType1 it4(outputImage1, outputImage1->GetRequestedRegion()); // Print the content of the result image std::cout << std::endl; @@ -218,8 +218,8 @@ itkJoinImageFilterTest(int, char *[]) filter2->Update(); // Create an iterator for going through the image output - myFilterType2::OutputImageType::Pointer outputImage2 = filter2->GetOutput(); - myOutputIteratorType2 it5(outputImage2, outputImage2->GetRequestedRegion()); + const myFilterType2::OutputImageType::Pointer outputImage2 = filter2->GetOutput(); + myOutputIteratorType2 it5(outputImage2, outputImage2->GetRequestedRegion()); // Print the content of the result image std::cout << "Joining #1 and #1 image " << std::endl; @@ -240,8 +240,8 @@ itkJoinImageFilterTest(int, char *[]) filter4->Update(); // Create an iterator for going through the image output - myFilterType4::OutputImageType::Pointer outputImage4 = filter4->GetOutput(); - myOutputIteratorType4 it6(outputImage4, outputImage4->GetRequestedRegion()); + const myFilterType4::OutputImageType::Pointer outputImage4 = filter4->GetOutput(); + myOutputIteratorType4 it6(outputImage4, outputImage4->GetRequestedRegion()); // Print the content of the result image std::cout << "Joining #2 and #2 image " << std::endl; diff --git a/Modules/Filtering/ImageCompose/test/itkJoinSeriesImageFilterStreamingTest.cxx b/Modules/Filtering/ImageCompose/test/itkJoinSeriesImageFilterStreamingTest.cxx index 73878b8b410..30c4b3fc209 100644 --- a/Modules/Filtering/ImageCompose/test/itkJoinSeriesImageFilterStreamingTest.cxx +++ b/Modules/Filtering/ImageCompose/test/itkJoinSeriesImageFilterStreamingTest.cxx @@ -43,8 +43,8 @@ itkJoinSeriesImageFilterStreamingTest(int argc, char * argv[]) } - std::string inputFileName = argv[1]; - std::string outputFileName = argv[2]; + const std::string inputFileName = argv[1]; + const std::string outputFileName = argv[2]; auto reader = ImageFileReaderType::New(); reader->SetFileName(inputFileName); @@ -55,7 +55,8 @@ itkJoinSeriesImageFilterStreamingTest(int argc, char * argv[]) itk::Math::CastWithRangeCheck(reader->GetOutput()->GetLargestPossibleRegion().GetSize(2)); - itk::PipelineMonitorImageFilter::Pointer monitor1 = itk::PipelineMonitorImageFilter::New(); + const itk::PipelineMonitorImageFilter::Pointer monitor1 = + itk::PipelineMonitorImageFilter::New(); monitor1->SetInput(reader->GetOutput()); std::vector savedPointers; @@ -85,7 +86,8 @@ itkJoinSeriesImageFilterStreamingTest(int argc, char * argv[]) } - itk::PipelineMonitorImageFilter::Pointer monitor2 = itk::PipelineMonitorImageFilter::New(); + const itk::PipelineMonitorImageFilter::Pointer monitor2 = + itk::PipelineMonitorImageFilter::New(); monitor2->SetInput(joinSeries->GetOutput()); auto writer = ImageFileWriterType::New(); diff --git a/Modules/Filtering/ImageCompose/test/itkJoinSeriesImageFilterTest.cxx b/Modules/Filtering/ImageCompose/test/itkJoinSeriesImageFilterTest.cxx index 9233b870eef..0417c31e2ea 100644 --- a/Modules/Filtering/ImageCompose/test/itkJoinSeriesImageFilterTest.cxx +++ b/Modules/Filtering/ImageCompose/test/itkJoinSeriesImageFilterTest.cxx @@ -45,10 +45,10 @@ itkJoinSeriesImageFilterTest(int, char *[]) using OutputImageType = itk::Image; // Expected result - OutputImageType::IndexType expectedIndex = { { 1, 2, 0, 0 } }; - OutputImageType::SizeType expectedSize = { { 8, 5, 4, 1 } }; - OutputImageType::RegionType expectedRegion{ expectedIndex, expectedSize }; - OutputImageType::SpacingType expectedSpacing; + const OutputImageType::IndexType expectedIndex = { { 1, 2, 0, 0 } }; + const OutputImageType::SizeType expectedSize = { { 8, 5, 4, 1 } }; + const OutputImageType::RegionType expectedRegion{ expectedIndex, expectedSize }; + OutputImageType::SpacingType expectedSpacing; expectedSpacing[0] = 1.1; expectedSpacing[1] = 1.2; expectedSpacing[2] = 1.3; @@ -60,12 +60,12 @@ itkJoinSeriesImageFilterTest(int, char *[]) expectedOrigin[3] = 0.0; // Create the input images - int numInputs = 4; - InputImageType::IndexType index = { { 1, 2 } }; - InputImageType::SizeType size = { { 8, 5 } }; - InputImageType::RegionType region{ index, size }; - constexpr double spacingValue = 1.3; - InputImageType::SpacingType spacing; + const int numInputs = 4; + const InputImageType::IndexType index = { { 1, 2 } }; + const InputImageType::SizeType size = { { 8, 5 } }; + const InputImageType::RegionType region{ index, size }; + constexpr double spacingValue = 1.3; + InputImageType::SpacingType spacing; spacing[0] = 1.1; spacing[1] = 1.2; constexpr double originValue = 0.3; @@ -154,7 +154,7 @@ itkJoinSeriesImageFilterTest(int, char *[]) return EXIT_FAILURE; } - OutputImageType::Pointer output = streamingImage->GetOutput(); + const OutputImageType::Pointer output = streamingImage->GetOutput(); // Check the information diff --git a/Modules/Filtering/ImageFeature/include/itkBilateralImageFilter.hxx b/Modules/Filtering/ImageFeature/include/itkBilateralImageFilter.hxx index 441ff4d5c87..bbd6f7505b0 100644 --- a/Modules/Filtering/ImageFeature/include/itkBilateralImageFilter.hxx +++ b/Modules/Filtering/ImageFeature/include/itkBilateralImageFilter.hxx @@ -63,7 +63,7 @@ BilateralImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); + const typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); if (!inputPtr) { @@ -207,10 +207,10 @@ BilateralImageFilter::BeforeThreadedGenerateData() // Now create the lookup table whose domain runs from 0.0 to // (max-min) and range is gaussian evaluated at // that point - double rangeVariance = m_RangeSigma * m_RangeSigma; + const double rangeVariance = m_RangeSigma * m_RangeSigma; // denominator (normalization factor) for Gaussian used for range - double rangeGaussianDenom = m_RangeSigma * std::sqrt(2.0 * itk::Math::pi); + const double rangeGaussianDenom = m_RangeSigma * std::sqrt(2.0 * itk::Math::pi); // Maximum delta for the dynamic range double tableDelta; @@ -235,14 +235,14 @@ void BilateralImageFilter::DynamicThreadedGenerateData( const OutputImageRegionType & outputRegionForThread) { - typename TInputImage::ConstPointer input = this->GetInput(); - typename TOutputImage::Pointer output = this->GetOutput(); + const typename TInputImage::ConstPointer input = this->GetInput(); + const typename TOutputImage::Pointer output = this->GetOutput(); const double rangeDistanceThreshold = m_DynamicRangeUsed; // Find the boundary "faces" - NeighborhoodAlgorithm::ImageBoundaryFacesCalculator fC; - typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = + NeighborhoodAlgorithm::ImageBoundaryFacesCalculator fC; + const typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = fC(this->GetInput(), outputRegionForThread, m_GaussianKernel.GetRadius()); const double distanceToTableIndex = static_cast(m_NumberOfRangeGaussianSamples) / m_DynamicRangeUsed; @@ -267,29 +267,29 @@ BilateralImageFilter::DynamicThreadedGenerateData( while (!b_iter.IsAtEnd()) { // Setup - OutputPixelRealType centerPixel = static_cast(b_iter.GetCenterPixel()); - OutputPixelRealType val = 0.0; - OutputPixelRealType normFactor = 0.0; + const OutputPixelRealType centerPixel = static_cast(b_iter.GetCenterPixel()); + OutputPixelRealType val = 0.0; + OutputPixelRealType normFactor = 0.0; // Walk the neighborhood of the input and the kernel KernelConstIteratorType k_it = m_GaussianKernel.Begin(); for (typename TInputImage::IndexValueType i = 0; k_it < kernelEnd; ++k_it, ++i) { // range distance between neighborhood pixel and neighborhood center - OutputPixelRealType pixel = static_cast(b_iter.GetPixel(i)); + const OutputPixelRealType pixel = static_cast(b_iter.GetPixel(i)); // flip sign if needed - OutputPixelRealType rangeDistance = std::abs(pixel - centerPixel); + const OutputPixelRealType rangeDistance = std::abs(pixel - centerPixel); // if the range distance is close enough, then use the pixel if (rangeDistance < rangeDistanceThreshold) { // look up the range gaussian in a table - OutputPixelRealType tableArg = rangeDistance * distanceToTableIndex; - OutputPixelRealType rangeGaussian = m_RangeGaussianTable[Math::Floor(tableArg)]; + const OutputPixelRealType tableArg = rangeDistance * distanceToTableIndex; + const OutputPixelRealType rangeGaussian = m_RangeGaussianTable[Math::Floor(tableArg)]; // normalization factor so filter integrates to one // (product of the domain and the range gaussian) - OutputPixelRealType gaussianProduct = (*k_it) * rangeGaussian; + const OutputPixelRealType gaussianProduct = (*k_it) * rangeGaussian; normFactor += gaussianProduct; // Input Image * Domain Gaussian * Range Gaussian diff --git a/Modules/Filtering/ImageFeature/include/itkCannyEdgeDetectionImageFilter.hxx b/Modules/Filtering/ImageFeature/include/itkCannyEdgeDetectionImageFilter.hxx index 7bbaec483f1..b8f1f7360ad 100644 --- a/Modules/Filtering/ImageFeature/include/itkCannyEdgeDetectionImageFilter.hxx +++ b/Modules/Filtering/ImageFeature/include/itkCannyEdgeDetectionImageFilter.hxx @@ -82,7 +82,7 @@ void CannyEdgeDetectionImageFilter::AllocateUpdateBuffer() { // The update buffer looks just like the input - typename TInputImage::ConstPointer input = this->GetInput(); + const typename TInputImage::ConstPointer input = this->GetInput(); m_UpdateBuffer1->CopyInformation(input); m_UpdateBuffer1->SetRequestedRegion(input->GetRequestedRegion()); @@ -103,14 +103,14 @@ CannyEdgeDetectionImageFilter::ThreadedCompute2ndDeri // Here input is the result from the gaussian filter output is the update // buffer - typename OutputImageType::Pointer input = m_GaussianFilter->GetOutput(); + const typename OutputImageType::Pointer input = m_GaussianFilter->GetOutput(); // Set iterator radius constexpr auto radius = Size::Filled(1); // Find the data-set boundary "faces" - NeighborhoodAlgorithm::ImageBoundaryFacesCalculator bC; - typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = + NeighborhoodAlgorithm::ImageBoundaryFacesCalculator bC; + const typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = bC(input, outputRegionForThread, radius); // Process the non-boundary region and then each of the boundary faces. @@ -139,7 +139,7 @@ CannyEdgeDetectionImageFilter::ComputeCannyEdge(const -> OutputImagePixelType { - NeighborhoodInnerProduct innerProduct; + const NeighborhoodInnerProduct innerProduct; OutputImagePixelType dx[ImageDimension]; OutputImagePixelType dxx[ImageDimension]; @@ -272,8 +272,8 @@ CannyEdgeDetectionImageFilter::HysteresisThresholding // This is the Zero crossings of the Second derivative multiplied with the // gradients of the image. HysteresisThresholding of this image should give // the Canny output. - typename OutputImageType::Pointer input = m_MultiplyImageFilter->GetOutput(); - float value; + const typename OutputImageType::Pointer input = m_MultiplyImageFilter->GetOutput(); + float value; ListNodeType * node; @@ -312,7 +312,7 @@ CannyEdgeDetectionImageFilter::FollowEdge(IndexType // This is the Zero crossings of the Second derivative multiplied with the // gradients of the image. HysteresisThresholding of this image should give // the Canny output. - InputImageRegionType inputRegion = multiplyImageFilterOutput->GetRequestedRegion(); + const InputImageRegionType inputRegion = multiplyImageFilterOutput->GetRequestedRegion(); IndexType nIndex; IndexType cIndex; @@ -337,7 +337,7 @@ CannyEdgeDetectionImageFilter::FollowEdge(IndexType return; } - int nSize = m_Center * 2 + 1; + const int nSize = m_Center * 2 + 1; while (!m_NodeList->Empty()) { // Pop the front node from the list and read its index value. @@ -388,20 +388,20 @@ CannyEdgeDetectionImageFilter::ThreadedCompute2ndDeri // Here input is the result from the gaussian filter // input1 is the 2nd derivative result // output is the gradient of 2nd derivative - typename OutputImageType::Pointer input1 = this->m_OutputImage; - typename OutputImageType::Pointer input = m_GaussianFilter->GetOutput(); + const typename OutputImageType::Pointer input1 = this->m_OutputImage; + const typename OutputImageType::Pointer input = m_GaussianFilter->GetOutput(); - typename InputImageType::Pointer output = m_UpdateBuffer1; + const typename InputImageType::Pointer output = m_UpdateBuffer1; // Set iterator radius constexpr auto radius = Size::Filled(1); // Find the data-set boundary "faces" - NeighborhoodAlgorithm::ImageBoundaryFacesCalculator bC; - typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = + NeighborhoodAlgorithm::ImageBoundaryFacesCalculator bC; + const typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = bC(input, outputRegionForThread, radius); - InputImagePixelType zero{}; + const InputImagePixelType zero{}; OutputImagePixelType dx[ImageDimension]; OutputImagePixelType dx1[ImageDimension]; @@ -414,7 +414,7 @@ CannyEdgeDetectionImageFilter::ThreadedCompute2ndDeri // Process the non-boundary region and then each of the boundary faces. // These are N-d regions which border the edge of the buffer. - NeighborhoodInnerProduct IP; + const NeighborhoodInnerProduct IP; for (const auto & face : faceList) { diff --git a/Modules/Filtering/ImageFeature/include/itkDerivativeImageFilter.hxx b/Modules/Filtering/ImageFeature/include/itkDerivativeImageFilter.hxx index 23d8617dc29..1efbfb677be 100644 --- a/Modules/Filtering/ImageFeature/include/itkDerivativeImageFilter.hxx +++ b/Modules/Filtering/ImageFeature/include/itkDerivativeImageFilter.hxx @@ -34,7 +34,7 @@ DerivativeImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); + const typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); if (!inputPtr) { diff --git a/Modules/Filtering/ImageFeature/include/itkDiscreteGaussianDerivativeImageFilter.hxx b/Modules/Filtering/ImageFeature/include/itkDiscreteGaussianDerivativeImageFilter.hxx index bc7ab987cdd..716d1133ab0 100644 --- a/Modules/Filtering/ImageFeature/include/itkDiscreteGaussianDerivativeImageFilter.hxx +++ b/Modules/Filtering/ImageFeature/include/itkDiscreteGaussianDerivativeImageFilter.hxx @@ -35,7 +35,7 @@ DiscreteGaussianDerivativeImageFilter::GenerateInputR Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); + const typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); if (!inputPtr) { @@ -100,7 +100,7 @@ template void DiscreteGaussianDerivativeImageFilter::GenerateData() { - typename TOutputImage::Pointer output = this->GetOutput(); + const typename TOutputImage::Pointer output = this->GetOutput(); output->SetBufferedRegion(output->GetRequestedRegion()); output->Allocate(); @@ -178,7 +178,7 @@ DiscreteGaussianDerivativeImageFilter::GenerateData() if constexpr (ImageDimension == 1) { // Use just a single filter - SingleFilterPointer singleFilter = SingleFilterType::New(); + const SingleFilterPointer singleFilter = SingleFilterType::New(); singleFilter->SetOperator(oper[0]); singleFilter->SetInput(localInput); progress->RegisterInternalFilter(singleFilter, 1.0f / ImageDimension); @@ -200,10 +200,10 @@ DiscreteGaussianDerivativeImageFilter::GenerateData() { // Setup a full mini-pipeline and stream the data through the // pipeline. - unsigned int numberOfStages = ImageDimension * this->GetInternalNumberOfStreamDivisions() + 1; + const unsigned int numberOfStages = ImageDimension * this->GetInternalNumberOfStreamDivisions() + 1; // First filter convolves and changes type from input type to real type - FirstFilterPointer firstFilter = FirstFilterType::New(); + const FirstFilterPointer firstFilter = FirstFilterType::New(); firstFilter->SetOperator(oper[0]); firstFilter->ReleaseDataFlagOn(); firstFilter->SetInput(localInput); @@ -235,7 +235,7 @@ DiscreteGaussianDerivativeImageFilter::GenerateData() } // Last filter convolves and changes type from real type to output type - LastFilterPointer lastFilter = LastFilterType::New(); + const LastFilterPointer lastFilter = LastFilterType::New(); lastFilter->SetOperator(oper[ImageDimension - 1]); lastFilter->ReleaseDataFlagOn(); if constexpr (ImageDimension > 2) @@ -251,7 +251,7 @@ DiscreteGaussianDerivativeImageFilter::GenerateData() // Put in a StreamingImageFilter so the mini-pipeline is processed // in chunks to minimize memory usage - StreamingFilterPointer streamingFilter = StreamingFilterType::New(); + const StreamingFilterPointer streamingFilter = StreamingFilterType::New(); streamingFilter->SetInput(lastFilter->GetOutput()); streamingFilter->SetNumberOfStreamDivisions(this->GetInternalNumberOfStreamDivisions()); progress->RegisterInternalFilter(streamingFilter, 1.0f / numberOfStages); diff --git a/Modules/Filtering/ImageFeature/include/itkGradientVectorFlowImageFilter.hxx b/Modules/Filtering/ImageFeature/include/itkGradientVectorFlowImageFilter.hxx index 0223ce507ac..787df72b050 100644 --- a/Modules/Filtering/ImageFeature/include/itkGradientVectorFlowImageFilter.hxx +++ b/Modules/Filtering/ImageFeature/include/itkGradientVectorFlowImageFilter.hxx @@ -38,7 +38,7 @@ template void GradientVectorFlowImageFilter::GenerateData() { - typename TOutputImage::Pointer output = this->GetOutput(); + const typename TOutputImage::Pointer output = this->GetOutput(); output->SetLargestPossibleRegion(this->GetInput()->GetLargestPossibleRegion()); output->SetBufferedRegion(this->GetInput()->GetLargestPossibleRegion()); @@ -112,7 +112,7 @@ GradientVectorFlowImageFilter::InitIn InputImageConstIterator inputIt(this->GetInput(), this->GetInput()->GetBufferedRegion()); - InputImageIterator intermediateIt(m_IntermediateImage, m_IntermediateImage->GetBufferedRegion()); + const InputImageIterator intermediateIt(m_IntermediateImage, m_IntermediateImage->GetBufferedRegion()); itk::ImageAlgorithm::Copy(this->GetInput(), m_IntermediateImage.GetPointer(), diff --git a/Modules/Filtering/ImageFeature/include/itkHessian3DToVesselnessMeasureImageFilter.hxx b/Modules/Filtering/ImageFeature/include/itkHessian3DToVesselnessMeasureImageFilter.hxx index c5725a7b6a7..8db87d5903c 100644 --- a/Modules/Filtering/ImageFeature/include/itkHessian3DToVesselnessMeasureImageFilter.hxx +++ b/Modules/Filtering/ImageFeature/include/itkHessian3DToVesselnessMeasureImageFilter.hxx @@ -43,7 +43,7 @@ Hessian3DToVesselnessMeasureImageFilter::GenerateData() m_SymmetricEigenValueFilter->SetInput(this->GetInput()); - typename OutputImageType::Pointer output = this->GetOutput(); + const typename OutputImageType::Pointer output = this->GetOutput(); using EigenValueOutputImageType = typename EigenAnalysisFilterType::OutputImageType; @@ -64,7 +64,7 @@ Hessian3DToVesselnessMeasureImageFilter::GenerateData() eigenValue = it.Get(); // normalizeValue <= 0 for bright line structures - double normalizeValue = std::min(-1.0 * eigenValue[1], -1.0 * eigenValue[0]); + const double normalizeValue = std::min(-1.0 * eigenValue[1], -1.0 * eigenValue[0]); // Similarity measure to a line structure if (normalizeValue > 0) diff --git a/Modules/Filtering/ImageFeature/include/itkHessianRecursiveGaussianImageFilter.hxx b/Modules/Filtering/ImageFeature/include/itkHessianRecursiveGaussianImageFilter.hxx index 7e30ca27597..cec84b64025 100644 --- a/Modules/Filtering/ImageFeature/include/itkHessianRecursiveGaussianImageFilter.hxx +++ b/Modules/Filtering/ImageFeature/include/itkHessianRecursiveGaussianImageFilter.hxx @@ -30,11 +30,11 @@ HessianRecursiveGaussianImageFilter::HessianRecursive m_NormalizeAcrossScale = false; // note: this is not constant to suppress a warning - unsigned int numberOfSmoothingFilters = NumberOfSmoothingFilters; + const unsigned int numberOfSmoothingFilters = NumberOfSmoothingFilters; for (unsigned int i = 0; i < numberOfSmoothingFilters; ++i) { - GaussianFilterPointer filter = GaussianFilterType::New(); + const GaussianFilterPointer filter = GaussianFilterType::New(); filter->SetOrder(GaussianOrderEnum::ZeroOrder); filter->SetNormalizeAcrossScale(m_NormalizeAcrossScale); filter->InPlaceOn(); @@ -81,7 +81,7 @@ template void HessianRecursiveGaussianImageFilter::SetSigma(RealType sigma) { - unsigned int numberOfSmoothingFilters = NumberOfSmoothingFilters; + const unsigned int numberOfSmoothingFilters = NumberOfSmoothingFilters; for (unsigned int i = 0; i < numberOfSmoothingFilters; ++i) { @@ -123,7 +123,7 @@ HessianRecursiveGaussianImageFilter::GenerateInputReq Superclass::GenerateInputRequestedRegion(); // This filter needs all of the input - typename HessianRecursiveGaussianImageFilter::InputImagePointer image = + const typename HessianRecursiveGaussianImageFilter::InputImagePointer image = const_cast(this->GetInput()); if (image) { @@ -167,7 +167,7 @@ HessianRecursiveGaussianImageFilter::GenerateData() const double weight = 1.0 / (ImageDimension * (ImageDimension * (ImageDimension + 1) / 2)); // note: this is not constant to suppress a warning - unsigned int numberOfSmoothingFilters = NumberOfSmoothingFilters; + const unsigned int numberOfSmoothingFilters = NumberOfSmoothingFilters; for (unsigned int i = 0; i < numberOfSmoothingFilters; ++i) { @@ -280,8 +280,8 @@ HessianRecursiveGaussianImageFilter::GenerateData() // Deal with the 2D case. if (numberOfSmoothingFilters > 0) { - int temp_dim = static_cast(ImageDimension) - 3; - GaussianFilterPointer lastFilter = m_SmoothingFilters[temp_dim]; + const int temp_dim = static_cast(ImageDimension) - 3; + const GaussianFilterPointer lastFilter = m_SmoothingFilters[temp_dim]; lastFilter->UpdateLargestPossibleRegion(); derivativeImage = lastFilter->GetOutput(); } diff --git a/Modules/Filtering/ImageFeature/include/itkHessianToObjectnessMeasureImageFilter.hxx b/Modules/Filtering/ImageFeature/include/itkHessianToObjectnessMeasureImageFilter.hxx index bd0a8f3b601..a38ad9911cc 100644 --- a/Modules/Filtering/ImageFeature/include/itkHessianToObjectnessMeasureImageFilter.hxx +++ b/Modules/Filtering/ImageFeature/include/itkHessianToObjectnessMeasureImageFilter.hxx @@ -61,7 +61,7 @@ HessianToObjectnessMeasureImageFilter::DynamicThreade // Calculator for computation of the eigen values using CalculatorType = SymmetricEigenAnalysisFixedDimension; - CalculatorType eigenCalculator; + const CalculatorType eigenCalculator; // Walk the region of eigen values and get the objectness measure ImageRegionConstIterator it(input, outputRegionForThread); diff --git a/Modules/Filtering/ImageFeature/include/itkHoughTransform2DCirclesImageFilter.hxx b/Modules/Filtering/ImageFeature/include/itkHoughTransform2DCirclesImageFilter.hxx index d8e99250cc7..6ec70c716eb 100644 --- a/Modules/Filtering/ImageFeature/include/itkHoughTransform2DCirclesImageFilter.hxx +++ b/Modules/Filtering/ImageFeature/include/itkHoughTransform2DCirclesImageFilter.hxx @@ -57,7 +57,7 @@ HoughTransform2DCirclesImageFilterGetInput()) { - InputImagePointer image = const_cast(this->GetInput()); + const InputImagePointer image = const_cast(this->GetInput()); image->SetRequestedRegionToLargestPossibleRegion(); } } @@ -213,8 +213,9 @@ HoughTransform2DCirclesImageFilterUpdate(); const InternalImageType::Pointer postProcessImage = gaussianFilter->GetOutput(); - const auto minMaxCalculator = MinimumMaximumImageCalculator::New(); - ImageRegionIterator it_input(postProcessImage, postProcessImage->GetLargestPossibleRegion()); + const auto minMaxCalculator = MinimumMaximumImageCalculator::New(); + const ImageRegionIterator it_input(postProcessImage, + postProcessImage->GetLargestPossibleRegion()); CirclesListSizeType circles = 0; diff --git a/Modules/Filtering/ImageFeature/include/itkHoughTransform2DLinesImageFilter.hxx b/Modules/Filtering/ImageFeature/include/itkHoughTransform2DLinesImageFilter.hxx index d39139f7e2a..4ae65af5996 100644 --- a/Modules/Filtering/ImageFeature/include/itkHoughTransform2DLinesImageFilter.hxx +++ b/Modules/Filtering/ImageFeature/include/itkHoughTransform2DLinesImageFilter.hxx @@ -53,8 +53,8 @@ HoughTransform2DLinesImageFilter::GenerateOut Superclass::GenerateOutputInformation(); // Get pointers to the input and output - InputImageConstPointer input = this->GetInput(); - OutputImagePointer output = this->GetOutput(); + const InputImageConstPointer input = this->GetInput(); + const OutputImagePointer output = this->GetOutput(); if (!input || !output) { @@ -81,7 +81,7 @@ HoughTransform2DLinesImageFilter::GenerateInp Superclass::GenerateInputRequestedRegion(); if (this->GetInput()) { - InputImagePointer image = const_cast(this->GetInput()); + const InputImagePointer image = const_cast(this->GetInput()); image->SetRequestedRegionToLargestPossibleRegion(); } } @@ -92,8 +92,8 @@ void HoughTransform2DLinesImageFilter::GenerateData() { // Get the input and output pointers - InputImageConstPointer inputImage = this->GetInput(0); - OutputImagePointer outputImage = this->GetOutput(0); + const InputImageConstPointer inputImage = this->GetInput(0); + const OutputImagePointer outputImage = this->GetOutput(0); // Allocate the output this->AllocateOutputs(); @@ -136,8 +136,8 @@ void HoughTransform2DLinesImageFilter::Simplify() { // Get the input and output pointers. - InputImageConstPointer inputImage = this->GetInput(0); - OutputImagePointer outputImage = this->GetOutput(0); + const InputImageConstPointer inputImage = this->GetInput(0); + const OutputImagePointer outputImage = this->GetOutput(0); if (!inputImage || !outputImage) { @@ -227,7 +227,7 @@ HoughTransform2DLinesImageFilter::GetLines() using InternalImagePixelType = float; using InternalImageType = Image; - OutputImagePointer outputImage = this->GetOutput(0); + const OutputImagePointer outputImage = this->GetOutput(0); if (!outputImage) { @@ -282,13 +282,13 @@ HoughTransform2DLinesImageFilter::GetLines() // Create the line. LineType::LinePointListType list; // Insert two points per line. - double radius = it_input.GetIndex()[0]; - double teta = ((it_input.GetIndex()[1]) * 2 * Math::pi / this->GetAngleResolution()) - Math::pi; - double Vx = radius * std::cos(teta); - double Vy = radius * std::sin(teta); - double norm = std::sqrt(Vx * Vx + Vy * Vy); - double VxNorm = Vx / norm; - double VyNorm = Vy / norm; + const double radius = it_input.GetIndex()[0]; + const double teta = ((it_input.GetIndex()[1]) * 2 * Math::pi / this->GetAngleResolution()) - Math::pi; + const double Vx = radius * std::cos(teta); + const double Vy = radius * std::sin(teta); + const double norm = std::sqrt(Vx * Vx + Vy * Vy); + double VxNorm = Vx / norm; + double VyNorm = Vy / norm; if (teta <= 0 || teta >= Math::pi / 2) { @@ -314,7 +314,7 @@ HoughTransform2DLinesImageFilter::GetLines() } // Create a Line Spatial Object. - LinePointer line = LineType::New(); + const LinePointer line = LineType::New(); line->SetId(lines); line->SetPoints(list); line->Update(); diff --git a/Modules/Filtering/ImageFeature/include/itkLaplacianImageFilter.hxx b/Modules/Filtering/ImageFeature/include/itkLaplacianImageFilter.hxx index 62bb59287ef..d522e900cf1 100644 --- a/Modules/Filtering/ImageFeature/include/itkLaplacianImageFilter.hxx +++ b/Modules/Filtering/ImageFeature/include/itkLaplacianImageFilter.hxx @@ -42,7 +42,7 @@ LaplacianImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - InputImagePointer inputPtr = const_cast(this->GetInput()); + const InputImagePointer inputPtr = const_cast(this->GetInput()); if (!inputPtr) { @@ -89,7 +89,7 @@ LaplacianImageFilter::GenerateData() { double s[ImageDimension]; - typename TOutputImage::Pointer output = this->GetOutput(); + const typename TOutputImage::Pointer output = this->GetOutput(); output->SetBufferedRegion(output->GetRequestedRegion()); output->Allocate(); diff --git a/Modules/Filtering/ImageFeature/include/itkLaplacianRecursiveGaussianImageFilter.hxx b/Modules/Filtering/ImageFeature/include/itkLaplacianRecursiveGaussianImageFilter.hxx index 1335726c337..8a97c91a8be 100644 --- a/Modules/Filtering/ImageFeature/include/itkLaplacianRecursiveGaussianImageFilter.hxx +++ b/Modules/Filtering/ImageFeature/include/itkLaplacianRecursiveGaussianImageFilter.hxx @@ -143,7 +143,7 @@ LaplacianRecursiveGaussianImageFilter::GenerateData() // because the cast image filter will either run inplace, or allocate // the output there. The requested region has already been set in // ImageToImageFilter::GenerateInputImageFilter. - typename TOutputImage::Pointer outputImage(this->GetOutput()); + const typename TOutputImage::Pointer outputImage(this->GetOutput()); // outputImage->Allocate(); let the CasterImageFilter allocate the image // Auxiliary image for accumulating the second-order derivatives @@ -197,7 +197,7 @@ LaplacianRecursiveGaussianImageFilter::GenerateData() } m_DerivativeFilter->SetDirection(dim); - GaussianFilterPointer lastFilter = m_SmoothingFilters[ImageDimension - 2]; + const GaussianFilterPointer lastFilter = m_SmoothingFilters[ImageDimension - 2]; // scale the new value by the inverse of the spacing squared const RealType spacing2 = itk::Math::sqr(inputImage->GetSpacing()[dim]); diff --git a/Modules/Filtering/ImageFeature/include/itkLaplacianSharpeningImageFilter.hxx b/Modules/Filtering/ImageFeature/include/itkLaplacianSharpeningImageFilter.hxx index d10f13c6a74..ea8ab8e8844 100644 --- a/Modules/Filtering/ImageFeature/include/itkLaplacianSharpeningImageFilter.hxx +++ b/Modules/Filtering/ImageFeature/include/itkLaplacianSharpeningImageFilter.hxx @@ -109,8 +109,8 @@ LaplacianSharpeningImageFilter::GenerateData() filteredMinMaxFilter->SetInput(laplacianFilter->GetOutput()); filteredMinMaxFilter->Update(); - RealType filteredShift = static_cast(filteredMinMaxFilter->GetMinimum()); - RealType filteredScale = static_cast(filteredMinMaxFilter->GetMaximum()) - filteredShift; + const RealType filteredShift = static_cast(filteredMinMaxFilter->GetMinimum()); + const RealType filteredScale = static_cast(filteredMinMaxFilter->GetMaximum()) - filteredShift; filteredMinMaxFilter = nullptr; // Combine the input image and the laplacian image diff --git a/Modules/Filtering/ImageFeature/include/itkMaskFeaturePointSelectionFilter.hxx b/Modules/Filtering/ImageFeature/include/itkMaskFeaturePointSelectionFilter.hxx index 6d2ae45efaf..a14f1bb7009 100644 --- a/Modules/Filtering/ImageFeature/include/itkMaskFeaturePointSelectionFilter.hxx +++ b/Modules/Filtering/ImageFeature/include/itkMaskFeaturePointSelectionFilter.hxx @@ -105,17 +105,17 @@ MaskFeaturePointSelectionFilter::GenerateData() RegionType region = image->GetLargestPossibleRegion(); typename ImageType::SpacingType voxelSpacing = image->GetSpacing(); - FeaturePointsPointer pointSet = this->GetOutput(); + const FeaturePointsPointer pointSet = this->GetOutput(); using PointsContainer = typename FeaturePointsType::PointsContainer; using PointsContainerPointer = typename PointsContainer::Pointer; - PointsContainerPointer points = PointsContainer::New(); + const PointsContainerPointer points = PointsContainer::New(); using PointDataContainer = typename FeaturePointsType::PointDataContainer; using PointDataContainerPointer = typename PointDataContainer::Pointer; - PointDataContainerPointer pointData = PointDataContainer::New(); + const PointDataContainerPointer pointData = PointDataContainer::New(); // initialize selectionMap using MapPixelType = unsigned char; @@ -172,7 +172,7 @@ MaskFeaturePointSelectionFilter::GenerateData() ImageRegionIterator mapItr(selectionMap, region); ConstNeighborhoodIterator imageItr(m_BlockRadius, image, region); using NeighborSizeType = typename ConstNeighborhoodIterator::NeighborIndexType; - NeighborSizeType numPixelsInNeighborhood = imageItr.Size(); + const NeighborSizeType numPixelsInNeighborhood = imageItr.Size(); // sorted container for feature points, stores pair(variance, index) using MultiMapType = std::multimap; @@ -208,9 +208,9 @@ MaskFeaturePointSelectionFilter::GenerateData() } // number of points to select - IndexValueType numberOfPointsInserted = -1; // initialize to -1 - IndexValueType maxNumberPointsToInserted = Math::Floor(0.5 + pointMap.size() * m_SelectFraction); - const double TRACE_EPSILON = 1e-8; + IndexValueType numberOfPointsInserted = -1; // initialize to -1 + const IndexValueType maxNumberPointsToInserted = Math::Floor(0.5 + pointMap.size() * m_SelectFraction); + const double TRACE_EPSILON = 1e-8; // pick points with highest variance first (inverse iteration) auto rit = pointMap.rbegin(); @@ -236,7 +236,7 @@ MaskFeaturePointSelectionFilter::GenerateData() center.SetSize(radius); center.SetIndex(indexOfPointToPick); - SizeType neighborRadiusForTensor = m_BlockRadius + m_BlockRadius; + const SizeType neighborRadiusForTensor = m_BlockRadius + m_BlockRadius; ConstNeighborhoodIterator gradientItr(neighborRadiusForTensor, image, center); gradientItr.GoToBegin(); @@ -244,7 +244,7 @@ MaskFeaturePointSelectionFilter::GenerateData() // iterate over voxels in the neighbourhood for (SizeValueType i = 0; i < gradientItr.Size(); ++i) { - OffsetType off = gradientItr.GetOffset(i); + const OffsetType off = gradientItr.GetOffset(i); for (unsigned int j = 0; j < ImageDimension; ++j) { @@ -264,7 +264,7 @@ MaskFeaturePointSelectionFilter::GenerateData() // Compute tensor product of gradI with itself const vnl_matrix tnspose{ gradI.GetTranspose().as_matrix() }; - StructureTensorType product(gradI * tnspose); + const StructureTensorType product(gradI * tnspose); tensor += product; } diff --git a/Modules/Filtering/ImageFeature/include/itkMultiScaleHessianBasedMeasureImageFilter.hxx b/Modules/Filtering/ImageFeature/include/itkMultiScaleHessianBasedMeasureImageFilter.hxx index 845cd20defa..b54f0301f3d 100644 --- a/Modules/Filtering/ImageFeature/include/itkMultiScaleHessianBasedMeasureImageFilter.hxx +++ b/Modules/Filtering/ImageFeature/include/itkMultiScaleHessianBasedMeasureImageFilter.hxx @@ -97,7 +97,7 @@ MultiScaleHessianBasedMeasureImageFilterGetOutput(); + const typename TOutputImage::Pointer output = this->GetOutput(); // this copies meta data describing the output such as origin, // spacing and the largest region @@ -135,7 +135,8 @@ MultiScaleHessianBasedMeasureImageFilter(this->ProcessObject::GetOutput(1)); + const typename ScalesImageType::Pointer scalesImage = + dynamic_cast(this->ProcessObject::GetOutput(1)); scalesImage->SetBufferedRegion(scalesImage->GetRequestedRegion()); scalesImage->AllocateInitialized(); @@ -143,7 +144,7 @@ MultiScaleHessianBasedMeasureImageFilter(this->ProcessObject::GetOutput(2)); hessianImage->SetBufferedRegion(hessianImage->GetRequestedRegion()); @@ -152,14 +153,14 @@ MultiScaleHessianBasedMeasureImageFilterFillBuffer(zeroTensor); } // Allocate the buffer AllocateUpdateBuffer(); - typename InputImageType::ConstPointer input = this->GetInput(); + const typename InputImageType::ConstPointer input = this->GetInput(); this->m_HessianFilter->SetInput(input); @@ -195,7 +196,7 @@ MultiScaleHessianBasedMeasureImageFilterGetOutput()->GetBufferedRegion(); + const OutputRegionType outputRegion = this->GetOutput()->GetBufferedRegion(); ImageRegionIterator it(m_UpdateBuffer, outputRegion); ImageRegionIterator oit(this->GetOutput(), outputRegion); @@ -217,14 +218,16 @@ MultiScaleHessianBasedMeasureImageFilterGetOutput()->GetBufferedRegion(); + const OutputRegionType outputRegion = this->GetOutput()->GetBufferedRegion(); ImageRegionIterator oit(m_UpdateBuffer, outputRegion); - typename ScalesImageType::Pointer scalesImage = static_cast(this->ProcessObject::GetOutput(1)); + const typename ScalesImageType::Pointer scalesImage = + static_cast(this->ProcessObject::GetOutput(1)); ImageRegionIterator osit; - typename HessianImageType::Pointer hessianImage = static_cast(this->ProcessObject::GetOutput(2)); + const typename HessianImageType::Pointer hessianImage = + static_cast(this->ProcessObject::GetOutput(2)); ImageRegionIterator ohit; if (m_GenerateScalesOutput) diff --git a/Modules/Filtering/ImageFeature/include/itkSimpleContourExtractorImageFilter.hxx b/Modules/Filtering/ImageFeature/include/itkSimpleContourExtractorImageFilter.hxx index fe7a47c7861..af4b891ed0f 100644 --- a/Modules/Filtering/ImageFeature/include/itkSimpleContourExtractorImageFilter.hxx +++ b/Modules/Filtering/ImageFeature/include/itkSimpleContourExtractorImageFilter.hxx @@ -51,12 +51,12 @@ SimpleContourExtractorImageFilter::DynamicThreadedGen ImageRegionIterator it; // Allocate output - typename OutputImageType::Pointer output = this->GetOutput(); - typename InputImageType::ConstPointer input = this->GetInput(); + const typename OutputImageType::Pointer output = this->GetOutput(); + const typename InputImageType::ConstPointer input = this->GetInput(); // Find the data-set boundary "faces" - NeighborhoodAlgorithm::ImageBoundaryFacesCalculator bC; - typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = + NeighborhoodAlgorithm::ImageBoundaryFacesCalculator bC; + const typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = bC(input, outputRegionForThread, this->GetRadius()); TotalProgressReporter progress(this, output->GetRequestedRegion().GetNumberOfPixels()); @@ -66,7 +66,7 @@ SimpleContourExtractorImageFilter::DynamicThreadedGen for (const auto & face : faceList) { bit = ConstNeighborhoodIterator(this->GetRadius(), input, face); - unsigned int neighborhoodSize = bit.Size(); + const unsigned int neighborhoodSize = bit.Size(); it = ImageRegionIterator(output, face); bit.OverrideBoundaryCondition(&nbc); diff --git a/Modules/Filtering/ImageFeature/include/itkSobelEdgeDetectionImageFilter.hxx b/Modules/Filtering/ImageFeature/include/itkSobelEdgeDetectionImageFilter.hxx index c077f2fe633..41278f7c21e 100644 --- a/Modules/Filtering/ImageFeature/include/itkSobelEdgeDetectionImageFilter.hxx +++ b/Modules/Filtering/ImageFeature/include/itkSobelEdgeDetectionImageFilter.hxx @@ -35,7 +35,7 @@ SobelEdgeDetectionImageFilter::GenerateInputRequested Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - InputImagePointer inputPtr = const_cast(this->GetInput()); + const InputImagePointer inputPtr = const_cast(this->GetInput()); if (!inputPtr) { @@ -95,7 +95,7 @@ SobelEdgeDetectionImageFilter::GenerateData() unsigned int i; - typename TOutputImage::Pointer output = this->GetOutput(); + const typename TOutputImage::Pointer output = this->GetOutput(); output->SetBufferedRegion(output->GetRequestedRegion()); output->Allocate(); diff --git a/Modules/Filtering/ImageFeature/include/itkUnsharpMaskImageFilter.hxx b/Modules/Filtering/ImageFeature/include/itkUnsharpMaskImageFilter.hxx index e85bd52a690..f6a4adb0879 100644 --- a/Modules/Filtering/ImageFeature/include/itkUnsharpMaskImageFilter.hxx +++ b/Modules/Filtering/ImageFeature/include/itkUnsharpMaskImageFilter.hxx @@ -46,7 +46,7 @@ UnsharpMaskImageFilter::GenerateI Superclass::GenerateInputRequestedRegion(); // This filter needs all of the input - InputImagePointer image = const_cast(this->GetInput()); + const InputImagePointer image = const_cast(this->GetInput()); if (image) { image->SetRequestedRegion(this->GetInput()->GetLargestPossibleRegion()); @@ -83,7 +83,7 @@ UnsharpMaskImageFilter::GenerateD auto functorF = BinaryFunctorType::New(); functorF->SetInput1(this->GetInput()); functorF->SetInput2(gaussianF->GetOutput()); - USMType usmT(m_Amount, m_Threshold, m_Clamp); + const USMType usmT(m_Amount, m_Threshold, m_Clamp); functorF->SetFunctor(usmT); functorF->SetNumberOfWorkUnits(this->GetNumberOfWorkUnits()); diff --git a/Modules/Filtering/ImageFeature/include/itkZeroCrossingBasedEdgeDetectionImageFilter.hxx b/Modules/Filtering/ImageFeature/include/itkZeroCrossingBasedEdgeDetectionImageFilter.hxx index f982c6506ff..12fbb91fdcb 100644 --- a/Modules/Filtering/ImageFeature/include/itkZeroCrossingBasedEdgeDetectionImageFilter.hxx +++ b/Modules/Filtering/ImageFeature/include/itkZeroCrossingBasedEdgeDetectionImageFilter.hxx @@ -40,7 +40,7 @@ template void ZeroCrossingBasedEdgeDetectionImageFilter::GenerateData() { - typename InputImageType::ConstPointer input = this->GetInput(); + const typename InputImageType::ConstPointer input = this->GetInput(); // Create the filters that are needed auto gaussianFilter = DiscreteGaussianImageFilter::New(); diff --git a/Modules/Filtering/ImageFeature/include/itkZeroCrossingImageFilter.hxx b/Modules/Filtering/ImageFeature/include/itkZeroCrossingImageFilter.hxx index 9dd907ade0a..20d5d5b1ed1 100644 --- a/Modules/Filtering/ImageFeature/include/itkZeroCrossingImageFilter.hxx +++ b/Modules/Filtering/ImageFeature/include/itkZeroCrossingImageFilter.hxx @@ -45,22 +45,22 @@ ZeroCrossingImageFilter::GenerateInputRequestedRegion Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); - typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); + const typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); + const typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { return; } - // Build an operator so that we can determine the kernel size - SizeValueType radius{}; // get a copy of the input requested region (should equal the output // requested region) typename TInputImage::RegionType inputRequestedRegion = inputPtr->GetRequestedRegion(); // pad the input requested region by the operator radius + // Build an operator so that we can determine the kernel size + SizeValueType radius{}; inputRequestedRegion.PadByRadius(radius); // crop the input requested region at the input's largest possible region @@ -91,8 +91,8 @@ void ZeroCrossingImageFilter::DynamicThreadedGenerateData( const OutputImageRegionType & outputRegionForThread) { - typename OutputImageType::Pointer output = this->GetOutput(); - typename InputImageType::ConstPointer input = this->GetInput(); + const typename OutputImageType::Pointer output = this->GetOutput(); + const typename InputImageType::ConstPointer input = this->GetInput(); // Calculate iterator radius static constexpr auto radius = Size::Filled(1); @@ -102,8 +102,8 @@ ZeroCrossingImageFilter::DynamicThreadedGenerateData( typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = bC(input, outputRegionForThread, radius); - TotalProgressReporter progress(this, output->GetRequestedRegion().GetNumberOfPixels()); - InputImagePixelType zero{}; + TotalProgressReporter progress(this, output->GetRequestedRegion().GetNumberOfPixels()); + const InputImagePixelType zero{}; ConstNeighborhoodIterator bit = ConstNeighborhoodIterator(radius, input, faceList.front()); @@ -130,17 +130,17 @@ ZeroCrossingImageFilter::DynamicThreadedGenerateData( ImageRegionIterator it = ImageRegionIterator(output, face); while (!bit.IsAtEnd()) { - InputImagePixelType this_one = bit.GetPixel(center); + const InputImagePixelType this_one = bit.GetPixel(center); it.Set(m_BackgroundValue); for (unsigned int i = 0; i < ImageDimension * 2; ++i) { - InputImagePixelType that = bit.GetPixel(center + offset[i]); + const InputImagePixelType that = bit.GetPixel(center + offset[i]); if (((this_one < zero) && (that > zero)) || ((this_one > zero) && (that < zero)) || ((Math::ExactlyEquals(this_one, zero)) && (Math::NotExactlyEquals(that, zero))) || ((Math::NotExactlyEquals(this_one, zero)) && (Math::ExactlyEquals(that, zero)))) { - InputImagePixelType abs_this_one = itk::Math::abs(this_one); - InputImagePixelType abs_that = itk::Math::abs(that); + const InputImagePixelType abs_this_one = itk::Math::abs(this_one); + const InputImagePixelType abs_that = itk::Math::abs(that); if (abs_this_one < abs_that) { it.Set(m_ForegroundValue); diff --git a/Modules/Filtering/ImageFeature/test/itkBilateralImageFilterTest.cxx b/Modules/Filtering/ImageFeature/test/itkBilateralImageFilterTest.cxx index 10de9f83349..7afce05183f 100644 --- a/Modules/Filtering/ImageFeature/test/itkBilateralImageFilterTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkBilateralImageFilterTest.cxx @@ -47,26 +47,26 @@ itkBilateralImageFilterTest(int, char *[]) filter->SetDomainSigma(domainSigma); ITK_TEST_SET_GET_VALUE(domainSigma, filter->GetDomainSigma()); - double domainMu = 2.5; + const double domainMu = 2.5; filter->SetDomainMu(domainMu); ITK_TEST_SET_GET_VALUE(domainMu, filter->GetDomainMu()); - double rangeSigma = 35.0f; + const double rangeSigma = 35.0f; filter->SetRangeSigma(rangeSigma); ITK_TEST_SET_GET_VALUE(rangeSigma, filter->GetRangeSigma()); filter->SetFilterDimensionality(Dimension); ITK_TEST_SET_GET_VALUE(Dimension, filter->GetFilterDimensionality()); - bool automaticKernelSize = true; + const bool automaticKernelSize = true; ITK_TEST_SET_GET_BOOLEAN(filter, AutomaticKernelSize, automaticKernelSize); - typename FilterType::SizeType::SizeValueType radiusVal = 2; - typename FilterType::SizeType radius = FilterType::SizeType::Filled(radiusVal); + const typename FilterType::SizeType::SizeValueType radiusVal = 2; + const typename FilterType::SizeType radius = FilterType::SizeType::Filled(radiusVal); filter->SetRadius(radius); ITK_TEST_SET_GET_VALUE(radius, filter->GetRadius()); - unsigned long numberOfRangeGaussianSamples = 150; + const unsigned long numberOfRangeGaussianSamples = 150; filter->SetNumberOfRangeGaussianSamples(numberOfRangeGaussianSamples); ITK_TEST_SET_GET_VALUE(numberOfRangeGaussianSamples, filter->GetNumberOfRangeGaussianSamples()); diff --git a/Modules/Filtering/ImageFeature/test/itkBilateralImageFilterTest2.cxx b/Modules/Filtering/ImageFeature/test/itkBilateralImageFilterTest2.cxx index a8df430c2d7..829799ec8f7 100644 --- a/Modules/Filtering/ImageFeature/test/itkBilateralImageFilterTest2.cxx +++ b/Modules/Filtering/ImageFeature/test/itkBilateralImageFilterTest2.cxx @@ -36,14 +36,14 @@ itkBilateralImageFilterTest2(int argc, char * argv[]) using PixelType = unsigned char; constexpr unsigned int dimension = 2; using myImage = itk::Image; - itk::ImageFileReader::Pointer input = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer input = itk::ImageFileReader::New(); input->SetFileName(argv[1]); // Create a filter using FilterType = itk::BilateralImageFilter; - auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter, "filter"); + auto filter = FilterType::New(); + const itk::SimpleFilterWatcher watcher(filter, "filter"); filter->SetInput(input->GetOutput()); @@ -78,11 +78,11 @@ itkBilateralImageFilterTest2(int argc, char * argv[]) filter->SetDomainMu(domainMu); ITK_TEST_SET_GET_VALUE(domainMu, filter->GetDomainMu()); - unsigned int filterDimensionality = dimension; + const unsigned int filterDimensionality = dimension; filter->SetFilterDimensionality(filterDimensionality); ITK_TEST_SET_GET_VALUE(filterDimensionality, filter->GetFilterDimensionality()); - unsigned long numberOfRangeGaussianSamples = 100; + const unsigned long numberOfRangeGaussianSamples = 100; filter->SetNumberOfRangeGaussianSamples(numberOfRangeGaussianSamples); ITK_TEST_SET_GET_VALUE(numberOfRangeGaussianSamples, filter->GetNumberOfRangeGaussianSamples()); diff --git a/Modules/Filtering/ImageFeature/test/itkBilateralImageFilterTest3.cxx b/Modules/Filtering/ImageFeature/test/itkBilateralImageFilterTest3.cxx index 250f1db5360..40583841d87 100644 --- a/Modules/Filtering/ImageFeature/test/itkBilateralImageFilterTest3.cxx +++ b/Modules/Filtering/ImageFeature/test/itkBilateralImageFilterTest3.cxx @@ -35,7 +35,7 @@ itkBilateralImageFilterTest3(int argc, char * argv[]) using PixelType = unsigned char; using myImage = itk::Image; - itk::ImageFileReader::Pointer input = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer input = itk::ImageFileReader::New(); input->SetFileName(argv[1]); // Create a filter diff --git a/Modules/Filtering/ImageFeature/test/itkCannyEdgeDetectionImageFilterTest.cxx b/Modules/Filtering/ImageFeature/test/itkCannyEdgeDetectionImageFilterTest.cxx index cf030a995d6..015271afa31 100644 --- a/Modules/Filtering/ImageFeature/test/itkCannyEdgeDetectionImageFilterTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkCannyEdgeDetectionImageFilterTest.cxx @@ -43,7 +43,7 @@ itkCannyEdgeDetectionImageFilterTest(int argc, char * argv[]) using CannyEdgeDetectionImageFilterType = itk::CannyEdgeDetectionImageFilter; - itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); reader->SetFileName(argv[1]); // Set up the filter @@ -51,28 +51,28 @@ itkCannyEdgeDetectionImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, CannyEdgeDetectionImageFilter, ImageToImageFilter); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); filter->SetInput(reader->GetOutput()); - CannyEdgeDetectionImageFilterType::OutputImagePixelType upperThreshold = 30; + const CannyEdgeDetectionImageFilterType::OutputImagePixelType upperThreshold = 30; filter->SetUpperThreshold(upperThreshold); ITK_TEST_SET_GET_VALUE(upperThreshold, filter->GetUpperThreshold()); - CannyEdgeDetectionImageFilterType::OutputImagePixelType lowerThreshold = 15; + const CannyEdgeDetectionImageFilterType::OutputImagePixelType lowerThreshold = 15; filter->SetLowerThreshold(lowerThreshold); ITK_TEST_SET_GET_VALUE(lowerThreshold, filter->GetLowerThreshold()); - CannyEdgeDetectionImageFilterType::ArrayType variance(1.0f); + const CannyEdgeDetectionImageFilterType::ArrayType variance(1.0f); filter->SetVariance(variance); ITK_TEST_SET_GET_VALUE(variance, filter->GetVariance()); - CannyEdgeDetectionImageFilterType::ArrayType maximumError(.01f); + const CannyEdgeDetectionImageFilterType::ArrayType maximumError(.01f); filter->SetMaximumError(maximumError); ITK_TEST_SET_GET_VALUE(maximumError, filter->GetMaximumError()); - itk::RescaleIntensityImageFilter::Pointer rescale = + const itk::RescaleIntensityImageFilter::Pointer rescale = itk::RescaleIntensityImageFilter::New(); rescale->SetInput(filter->GetOutput()); @@ -80,7 +80,7 @@ itkCannyEdgeDetectionImageFilterTest(int argc, char * argv[]) rescale->SetOutputMinimum(0); rescale->SetOutputMaximum(255); - itk::ImageFileWriter::Pointer writer = itk::ImageFileWriter::New(); + const itk::ImageFileWriter::Pointer writer = itk::ImageFileWriter::New(); writer->SetInput(rescale->GetOutput()); writer->SetFileName(argv[2]); diff --git a/Modules/Filtering/ImageFeature/test/itkCannyEdgeDetectionImageFilterTest2.cxx b/Modules/Filtering/ImageFeature/test/itkCannyEdgeDetectionImageFilterTest2.cxx index 6a13fab8621..9221e778ffd 100644 --- a/Modules/Filtering/ImageFeature/test/itkCannyEdgeDetectionImageFilterTest2.cxx +++ b/Modules/Filtering/ImageFeature/test/itkCannyEdgeDetectionImageFilterTest2.cxx @@ -42,7 +42,7 @@ itkCannyEdgeDetectionImageFilterTest2(int argc, char * argv[]) using OutputImage = itk::Image; using CannyEdgeDetectionImageFilterType = itk::CannyEdgeDetectionImageFilter; - itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); reader->SetFileName(argv[1]); // Set up the filter @@ -60,16 +60,16 @@ itkCannyEdgeDetectionImageFilterTest2(int argc, char * argv[]) filter->SetLowerThreshold(lowerThreshold); ITK_TEST_SET_GET_VALUE(lowerThreshold, filter->GetLowerThreshold()); - CannyEdgeDetectionImageFilterType::ArrayType variance(1.0f); + const CannyEdgeDetectionImageFilterType::ArrayType variance(1.0f); filter->SetVariance(variance); ITK_TEST_SET_GET_VALUE(variance, filter->GetVariance()); - CannyEdgeDetectionImageFilterType::ArrayType maximumError(.01f); + const CannyEdgeDetectionImageFilterType::ArrayType maximumError(.01f); filter->SetMaximumError(maximumError); ITK_TEST_SET_GET_VALUE(maximumError, filter->GetMaximumError()); - itk::RescaleIntensityImageFilter::Pointer rescale = + const itk::RescaleIntensityImageFilter::Pointer rescale = itk::RescaleIntensityImageFilter::New(); rescale->SetInput(filter->GetOutput()); @@ -77,7 +77,7 @@ itkCannyEdgeDetectionImageFilterTest2(int argc, char * argv[]) rescale->SetOutputMinimum(0); rescale->SetOutputMaximum(255); - itk::ImageFileWriter::Pointer writer = itk::ImageFileWriter::New(); + const itk::ImageFileWriter::Pointer writer = itk::ImageFileWriter::New(); writer->SetInput(rescale->GetOutput()); writer->SetFileName(argv[2]); diff --git a/Modules/Filtering/ImageFeature/test/itkDerivativeImageFilterTest.cxx b/Modules/Filtering/ImageFeature/test/itkDerivativeImageFilterTest.cxx index bd6a2cf7d14..87b3dce78aa 100644 --- a/Modules/Filtering/ImageFeature/test/itkDerivativeImageFilterTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkDerivativeImageFilterTest.cxx @@ -59,11 +59,11 @@ itkDerivativeImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, DerivativeImageFilter, ImageToImageFilter); // Set up the filter - unsigned int order = std::stoi(argv[3]); + const unsigned int order = std::stoi(argv[3]); filter->SetOrder(order); ITK_TEST_SET_GET_VALUE(order, filter->GetOrder()); - unsigned int direction = std::stoi(argv[4]); + const unsigned int direction = std::stoi(argv[4]); filter->SetDirection(direction); ITK_TEST_SET_GET_VALUE(direction, filter->GetDirection()); @@ -81,7 +81,7 @@ itkDerivativeImageFilterTest(int argc, char * argv[]) ITK_TEST_SET_GET_BOOLEAN(filter, UseImageSpacing, useImageSpacing); - itk::SimpleFilterWatcher watcher(filter, "Derivative"); + const itk::SimpleFilterWatcher watcher(filter, "Derivative"); // wire the pipeline filter->SetInput(reader->GetOutput()); diff --git a/Modules/Filtering/ImageFeature/test/itkDiscreteGaussianDerivativeImageFilterScaleSpaceTest.cxx b/Modules/Filtering/ImageFeature/test/itkDiscreteGaussianDerivativeImageFilterScaleSpaceTest.cxx index fc0c2f605b6..f8eb846990d 100644 --- a/Modules/Filtering/ImageFeature/test/itkDiscreteGaussianDerivativeImageFilterScaleSpaceTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkDiscreteGaussianDerivativeImageFilterScaleSpaceTest.cxx @@ -34,13 +34,13 @@ NormalizeSineWave(double frequencyPerImage, unsigned int order, double pixelSpac const double tolerance1 = std::pow(.001, 1.0 / order); // still larger than it should be! - double frequency = frequencyPerImage * 2.0 * itk::Math::pi / (imageSize * pixelSpacing); + const double frequency = frequencyPerImage * 2.0 * itk::Math::pi / (imageSize * pixelSpacing); // The theoretical maximal value should occur at this sigma - double sigmaMax = std::sqrt(static_cast(order)) / frequency; + const double sigmaMax = std::sqrt(static_cast(order)) / frequency; // The theoreical maximal value of the derivative, obtained at sigmaMax - double expectedMax = std::pow(static_cast(order), order * 0.5) * std::exp(-0.5 * order); + const double expectedMax = std::pow(static_cast(order), order * 0.5) * std::exp(-0.5 * order); using ImageType = itk::Image; auto image = ImageType::New(); @@ -62,7 +62,7 @@ NormalizeSineWave(double frequencyPerImage, unsigned int order, double pixelSpac ImageType::PointType p; image->TransformIndexToPhysicalPoint(iter.GetIndex(), p); const double x = p[0]; - double value = std::sin(x * frequency); + const double value = std::sin(x * frequency); iter.Set(value); ++iter; @@ -79,7 +79,7 @@ NormalizeSineWave(double frequencyPerImage, unsigned int order, double pixelSpac filter->SetMaximumKernelWidth(500); filter->SetNormalizeAcrossScale(true); - ImageType::Pointer outputImage = filter->GetOutput(); + const ImageType::Pointer outputImage = filter->GetOutput(); outputImage->Update(); // Maximal value of the first derivative diff --git a/Modules/Filtering/ImageFeature/test/itkDiscreteGaussianDerivativeImageFilterTest.cxx b/Modules/Filtering/ImageFeature/test/itkDiscreteGaussianDerivativeImageFilterTest.cxx index c85d0312f66..35006512f26 100644 --- a/Modules/Filtering/ImageFeature/test/itkDiscreteGaussianDerivativeImageFilterTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkDiscreteGaussianDerivativeImageFilterTest.cxx @@ -69,7 +69,7 @@ itkDiscreteGaussianDerivativeImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(derivativeFilter, DiscreteGaussianDerivativeImageFilter, ImageToImageFilter); - itk::SimpleFilterWatcher watcher(derivativeFilter, "DiscreteGaussianDerivativeImageFilter"); + const itk::SimpleFilterWatcher watcher(derivativeFilter, "DiscreteGaussianDerivativeImageFilter"); derivativeFilter->SetInput(reader->GetOutput()); @@ -82,7 +82,7 @@ itkDiscreteGaussianDerivativeImageFilterTest(int argc, char * argv[]) derivativeFilter->SetOrder(order); ITK_TEST_SET_GET_VALUE(order, derivativeFilter->GetOrder()); - double sigma = std::stod(argv[5]); + const double sigma = std::stod(argv[5]); DerivativeFilterType::ArrayType::ValueType maxErrorVal = 0.001; int maxKernelWidth = 100; @@ -109,14 +109,14 @@ itkDiscreteGaussianDerivativeImageFilterTest(int argc, char * argv[]) derivativeFilter->SetMaximumKernelWidth(maxKernelWidth); ITK_TEST_SET_GET_VALUE(maxKernelWidth, derivativeFilter->GetMaximumKernelWidth()); - bool useImageSpacing = true; + const bool useImageSpacing = true; ITK_TEST_SET_GET_BOOLEAN(derivativeFilter, UseImageSpacing, useImageSpacing); - bool normalizeAcrossScale = false; + const bool normalizeAcrossScale = false; ITK_TEST_SET_GET_BOOLEAN(derivativeFilter, NormalizeAcrossScale, normalizeAcrossScale); - unsigned int internalNumberOfStreamDivisions = DerivativeFilterType::InputImageType::GetImageDimension() * - DerivativeFilterType::InputImageType::GetImageDimension(); + const unsigned int internalNumberOfStreamDivisions = DerivativeFilterType::InputImageType::GetImageDimension() * + DerivativeFilterType::InputImageType::GetImageDimension(); derivativeFilter->SetInternalNumberOfStreamDivisions(internalNumberOfStreamDivisions); ITK_TEST_SET_GET_VALUE(internalNumberOfStreamDivisions, derivativeFilter->GetInternalNumberOfStreamDivisions()); diff --git a/Modules/Filtering/ImageFeature/test/itkGradientVectorFlowImageFilterTest.cxx b/Modules/Filtering/ImageFeature/test/itkGradientVectorFlowImageFilterTest.cxx index b824a639db3..4af710fa232 100644 --- a/Modules/Filtering/ImageFeature/test/itkGradientVectorFlowImageFilterTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkGradientVectorFlowImageFilterTest.cxx @@ -141,15 +141,15 @@ itkGradientVectorFlowImageFilterTest(int, char *[]) m_GVFFilter->SetLaplacianFilter(m_LFilter); ITK_TEST_SET_GET_VALUE(m_LFilter, m_GVFFilter->GetLaplacianFilter()); - double noiseLevel = 500; + const double noiseLevel = 500; m_GVFFilter->SetNoiseLevel(noiseLevel); ITK_TEST_SET_GET_VALUE(noiseLevel, m_GVFFilter->GetNoiseLevel()); - double timeStep = 0.001; + const double timeStep = 0.001; m_GVFFilter->SetTimeStep(timeStep); ITK_TEST_SET_GET_VALUE(timeStep, m_GVFFilter->GetTimeStep()); - int iterationNum = 2; + const int iterationNum = 2; m_GVFFilter->SetIterationNum(iterationNum); ITK_TEST_SET_GET_VALUE(iterationNum, m_GVFFilter->GetIterationNum()); @@ -158,10 +158,10 @@ itkGradientVectorFlowImageFilterTest(int, char *[]) // It is important to do it AFTER the filter is Updated // Because the object connected to the output may be changed // by another during GenerateData() call - myGradientImageType::Pointer outputImage = filter->GetOutput(); + const myGradientImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the output image - myOutputIteratorType itg(outputImage, outputImage->GetRequestedRegion()); + const myOutputIteratorType itg(outputImage, outputImage->GetRequestedRegion()); // Print the content of the result image std::cout << " Result " << std::endl; @@ -180,7 +180,7 @@ itkGradientVectorFlowImageFilterTest(int, char *[]) std::cout << m_GVFFilter->GetIterationNum() << std::endl; - myOutputIteratorType itgvf(m_GVFFilter->GetOutput(), m_GVFFilter->GetOutput()->GetRequestedRegion()); + const myOutputIteratorType itgvf(m_GVFFilter->GetOutput(), m_GVFFilter->GetOutput()->GetRequestedRegion()); std::cout << "Completed" << std::endl; // All objects should be automatically destroyed at this point diff --git a/Modules/Filtering/ImageFeature/test/itkHessian3DToVesselnessMeasureImageFilterTest.cxx b/Modules/Filtering/ImageFeature/test/itkHessian3DToVesselnessMeasureImageFilterTest.cxx index 5581f18b48d..56c724e9e11 100644 --- a/Modules/Filtering/ImageFeature/test/itkHessian3DToVesselnessMeasureImageFilterTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkHessian3DToVesselnessMeasureImageFilterTest.cxx @@ -139,7 +139,7 @@ itkHessian3DToVesselnessMeasureImageFilterTest(int argc, char * argv[]) // It is important to do it AFTER the filter is Updated // Because the object connected to the output may be changed // by another during GenerateData() call - myVesselnessImageType::Pointer outputImage = filterVesselness->GetOutput(); + const myVesselnessImageType::Pointer outputImage = filterVesselness->GetOutput(); // Declare Iterator type for the output image using myOutputIteratorType = itk::ImageRegionIteratorWithIndex; diff --git a/Modules/Filtering/ImageFeature/test/itkHessianRecursiveGaussianFilterScaleSpaceTest.cxx b/Modules/Filtering/ImageFeature/test/itkHessianRecursiveGaussianFilterScaleSpaceTest.cxx index 7010c85df23..0d49ce893d5 100644 --- a/Modules/Filtering/ImageFeature/test/itkHessianRecursiveGaussianFilterScaleSpaceTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkHessianRecursiveGaussianFilterScaleSpaceTest.cxx @@ -41,7 +41,7 @@ itkHessianRecursiveGaussianFilterScaleSpaceTest(int, char *[]) auto size = SizeType::Filled(21); size[0] = 401; - IndexType start{}; + const IndexType start{}; RegionType region; region.SetIndex(start); @@ -69,7 +69,7 @@ itkHessianRecursiveGaussianFilterScaleSpaceTest(int, char *[]) // changing the size of the object with the size of the // gaussian should produce the same results - for (double objectSize : scales) + for (const double objectSize : scales) { IteratorType it(inputImage, inputImage->GetRequestedRegion()); @@ -80,7 +80,7 @@ itkHessianRecursiveGaussianFilterScaleSpaceTest(int, char *[]) while (!it.IsAtEnd()) { inputImage->TransformIndexToPhysicalPoint(it.GetIndex(), point); - double value = std::exp(-point[0] * point[0] / (2.0 * objectSize * objectSize)); + const double value = std::exp(-point[0] * point[0] / (2.0 * objectSize * objectSize)); it.Set(value); ++it; } @@ -96,15 +96,15 @@ itkHessianRecursiveGaussianFilterScaleSpaceTest(int, char *[]) filter->SetNormalizeAcrossScale(true); filter->Update(); - HessianImageType::Pointer outputImage = filter->GetOutput(); + const HessianImageType::Pointer outputImage = filter->GetOutput(); // Get the value at the center of the image, the location of the peak of the Gaussian - PointType center{}; + const PointType center{}; - IndexType centerIndex = outputImage->TransformPhysicalPointToIndex(center); + const IndexType centerIndex = outputImage->TransformPhysicalPointToIndex(center); // Irrespective of the scale, the Hxx component should be the same - double centerHxx = outputImage->GetPixel(centerIndex)[0]; + const double centerHxx = outputImage->GetPixel(centerIndex)[0]; if (centerHxx > -0.3546 || centerHxx < -0.3547) { @@ -116,12 +116,12 @@ itkHessianRecursiveGaussianFilterScaleSpaceTest(int, char *[]) // maintaining the size of the object and gaussian, in physical // size, should maintain the value, while the size of the image changes. - for (double scale : scales) + for (const double scale : scales) { IteratorType it(inputImage, inputImage->GetRequestedRegion()); - PointType point; - double objectSize = 5.0; + PointType point; + const double objectSize = 5.0; spacing.Fill(scale / 5.0); @@ -134,7 +134,7 @@ itkHessianRecursiveGaussianFilterScaleSpaceTest(int, char *[]) while (!it.IsAtEnd()) { inputImage->TransformIndexToPhysicalPoint(it.GetIndex(), point); - double value = std::exp(-point[0] * point[0] / (2.0 * objectSize * objectSize)); + const double value = std::exp(-point[0] * point[0] / (2.0 * objectSize * objectSize)); it.Set(value); ++it; } @@ -150,15 +150,15 @@ itkHessianRecursiveGaussianFilterScaleSpaceTest(int, char *[]) filter->SetNormalizeAcrossScale(true); filter->Update(); - HessianImageType::Pointer outputImage = filter->GetOutput(); + const HessianImageType::Pointer outputImage = filter->GetOutput(); // Get the value at the center of the image, the location of the peak of the Gaussian - PointType center{}; + const PointType center{}; - IndexType centerIndex = outputImage->TransformPhysicalPointToIndex(center); + const IndexType centerIndex = outputImage->TransformPhysicalPointToIndex(center); // Irrespective of the scale, the Hxx component should be the same - double centerHxx = outputImage->GetPixel(centerIndex)[0]; + const double centerHxx = outputImage->GetPixel(centerIndex)[0]; if (centerHxx > -0.354 || centerHxx < -0.355) { diff --git a/Modules/Filtering/ImageFeature/test/itkHessianRecursiveGaussianFilterTest.cxx b/Modules/Filtering/ImageFeature/test/itkHessianRecursiveGaussianFilterTest.cxx index 5081fb1030c..43e5947d392 100644 --- a/Modules/Filtering/ImageFeature/test/itkHessianRecursiveGaussianFilterTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkHessianRecursiveGaussianFilterTest.cxx @@ -124,7 +124,7 @@ itkHessianRecursiveGaussianFilterTest(int argc, char * argv[]) // It is important to do it AFTER the filter is Updated // Because the object connected to the output may be changed // by another during GenerateData() call - myHessianImageType::Pointer outputImage = filter->GetOutput(); + const myHessianImageType::Pointer outputImage = filter->GetOutput(); // Declare Iterator type for the output image using myOutputIteratorType = itk::ImageRegionIteratorWithIndex; diff --git a/Modules/Filtering/ImageFeature/test/itkHessianToObjectnessMeasureImageFilterTest.cxx b/Modules/Filtering/ImageFeature/test/itkHessianToObjectnessMeasureImageFilterTest.cxx index 5e7b93232a1..c2b47fe0664 100644 --- a/Modules/Filtering/ImageFeature/test/itkHessianToObjectnessMeasureImageFilterTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkHessianToObjectnessMeasureImageFilterTest.cxx @@ -74,21 +74,21 @@ itkHessianToObjectnessMeasureImageFilterTest(int argc, char * argv[]) objectnessFilter->SetInput(gaussianFilter->GetOutput()); // Set the filter properties - bool scaleObjectnessMeasure = false; + const bool scaleObjectnessMeasure = false; ITK_TEST_SET_GET_BOOLEAN(objectnessFilter, ScaleObjectnessMeasure, scaleObjectnessMeasure); bool brightObject = true; ITK_TEST_SET_GET_BOOLEAN(objectnessFilter, BrightObject, brightObject); - double alphaValue = 0.5; + const double alphaValue = 0.5; objectnessFilter->SetAlpha(alphaValue); ITK_TEST_SET_GET_VALUE(alphaValue, objectnessFilter->GetAlpha()); - double betaValue = 0.5; + const double betaValue = 0.5; objectnessFilter->SetBeta(betaValue); ITK_TEST_SET_GET_VALUE(betaValue, objectnessFilter->GetBeta()); - double gammaValue = 0.5; + const double gammaValue = 0.5; objectnessFilter->SetGamma(gammaValue); ITK_TEST_SET_GET_VALUE(gammaValue, objectnessFilter->GetGamma()); @@ -102,7 +102,7 @@ itkHessianToObjectnessMeasureImageFilterTest(int argc, char * argv[]) if (argc >= 3) { - unsigned int objectDimension = std::stoi(argv[3]); + const unsigned int objectDimension = std::stoi(argv[3]); objectnessFilter->SetObjectDimension(objectDimension); ITK_TEST_SET_GET_VALUE(objectDimension, objectnessFilter->GetObjectDimension()); } diff --git a/Modules/Filtering/ImageFeature/test/itkHoughTransform2DCirclesImageTest.cxx b/Modules/Filtering/ImageFeature/test/itkHoughTransform2DCirclesImageTest.cxx index 01e61c4daed..a243be31699 100644 --- a/Modules/Filtering/ImageFeature/test/itkHoughTransform2DCirclesImageTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkHoughTransform2DCirclesImageTest.cxx @@ -369,20 +369,20 @@ itkHoughTransform2DCirclesImageTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(houghFilter, HoughTransform2DCirclesImageFilter, ImageToImageFilter); - double threshold = 2.3; + const double threshold = 2.3; houghFilter->SetThreshold(threshold); ITK_TEST_SET_GET_VALUE(threshold, houghFilter->GetThreshold()); - double minMaxRadius = 16.2; + const double minMaxRadius = 16.2; houghFilter->SetRadius(minMaxRadius); ITK_TEST_SET_GET_VALUE(minMaxRadius, houghFilter->GetMinimumRadius()); ITK_TEST_SET_GET_VALUE(minMaxRadius, houghFilter->GetMaximumRadius()); - double minimumRadius = 2.1; + const double minimumRadius = 2.1; houghFilter->SetMinimumRadius(minimumRadius); ITK_TEST_SET_GET_VALUE(minimumRadius, houghFilter->GetMinimumRadius()); - double maximumRadius = 20.4; + const double maximumRadius = 20.4; houghFilter->SetMaximumRadius(maximumRadius); ITK_TEST_SET_GET_VALUE(maximumRadius, houghFilter->GetMaximumRadius()); @@ -390,19 +390,19 @@ itkHoughTransform2DCirclesImageTest(int, char *[]) houghFilter->SetGradientNormThreshold(gradientNormThreshold); ITK_TEST_SET_GET_VALUE(gradientNormThreshold, houghFilter->GetGradientNormThreshold()); - double sigmaGradient = 1.2; + const double sigmaGradient = 1.2; houghFilter->SetSigmaGradient(sigmaGradient); ITK_TEST_SET_GET_VALUE(sigmaGradient, houghFilter->GetSigmaGradient()); - float discRadiusRatio = 1.1; + const float discRadiusRatio = 1.1; houghFilter->SetDiscRadiusRatio(discRadiusRatio); ITK_TEST_SET_GET_VALUE(discRadiusRatio, houghFilter->GetDiscRadiusRatio()); - float variance = 10; + const float variance = 10; houghFilter->SetVariance(variance); ITK_TEST_SET_GET_VALUE(variance, houghFilter->GetVariance()); - float sweepAngle = 0.2; + const float sweepAngle = 0.2; houghFilter->SetSweepAngle(sweepAngle); ITK_TEST_SET_GET_VALUE(sweepAngle, houghFilter->GetSweepAngle()); @@ -410,7 +410,7 @@ itkHoughTransform2DCirclesImageTest(int, char *[]) houghFilter->SetNumberOfCircles(numberOfCircles); ITK_TEST_SET_GET_VALUE(numberOfCircles, houghFilter->GetNumberOfCircles()); - bool useImageSpacing = false; + const bool useImageSpacing = false; houghFilter->SetUseImageSpacing(useImageSpacing); ITK_TEST_SET_GET_VALUE(useImageSpacing, houghFilter->GetUseImageSpacing()); @@ -425,7 +425,7 @@ itkHoughTransform2DCirclesImageTest(int, char *[]) circleList = houghFilter->GetCircles(); - double radiusTolerance = 2.0; + const double radiusTolerance = 2.0; HoughTransformFilterType::CirclesListType::const_iterator it = circleList.begin(); @@ -453,9 +453,9 @@ itkHoughTransform2DCirclesImageTest(int, char *[]) } // Check the circle center - HoughImageType::Pointer accumulator = houghFilter->GetOutput(); + const HoughImageType::Pointer accumulator = houghFilter->GetOutput(); - HoughImageType::ConstPointer radiusImage = houghFilter->GetRadiusImage(); + const HoughImageType::ConstPointer radiusImage = houghFilter->GetRadiusImage(); // Blur the accumulator in order to find the maximum using GaussianFilterType = itk::DiscreteGaussianImageFilter; @@ -470,7 +470,7 @@ itkHoughTransform2DCirclesImageTest(int, char *[]) gaussianFilter->Update(); - HoughImageType::Pointer postProcessImage = gaussianFilter->GetOutput(); + const HoughImageType::Pointer postProcessImage = gaussianFilter->GetOutput(); using MinMaxCalculatorType = itk::MinimumMaximumImageCalculator; auto minMaxCalculator = MinMaxCalculatorType::New(); @@ -497,7 +497,7 @@ itkHoughTransform2DCirclesImageTest(int, char *[]) if (itk::Math::ExactlyEquals(it_input.Get(), max)) { it_output.Set(255); - double radius2 = radiusImage->GetPixel(it_output.GetIndex()); + const double radius2 = radiusImage->GetPixel(it_output.GetIndex()); centerResult[foundCircles][0] = it_output.GetIndex()[0]; centerResult[foundCircles][1] = it_output.GetIndex()[1]; radiusResult[foundCircles] = radius2; @@ -533,7 +533,7 @@ itkHoughTransform2DCirclesImageTest(int, char *[]) } while (foundCircles < numberOfCircles); // Check the circle detection - double centerTolerance = 2.0; + const double centerTolerance = 2.0; for (i = 0; i < numberOfCircles; ++i) { if (!itk::Math::FloatAlmostEqual( diff --git a/Modules/Filtering/ImageFeature/test/itkHoughTransform2DLinesImageTest.cxx b/Modules/Filtering/ImageFeature/test/itkHoughTransform2DLinesImageTest.cxx index 4653596cb80..e9bb4f8e072 100644 --- a/Modules/Filtering/ImageFeature/test/itkHoughTransform2DLinesImageTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkHoughTransform2DLinesImageTest.cxx @@ -152,17 +152,17 @@ itkHoughTransform2DLinesImageTest(int, char *[]) // Create a line constexpr unsigned int lines = 1; - double theta = 0.20; // radians - double radius = 50; + const double theta = 0.20; // radians + const double radius = 50; - double Vx = radius * std::cos(theta); - double Vy = radius * std::sin(theta); + const double Vx = radius * std::cos(theta); + const double Vy = radius * std::sin(theta); - double norm = std::sqrt(Vx * Vx + Vy * Vy); - double VxNorm = Vx / norm; - double VyNorm = Vy / norm; + const double norm = std::sqrt(Vx * Vx + Vy * Vy); + const double VxNorm = Vx / norm; + const double VyNorm = Vy / norm; - unsigned int numberOfPixels = size[0] * size[1]; + const unsigned int numberOfPixels = size[0] * size[1]; for (unsigned int i = 0; i < numberOfPixels; i += 1) { @@ -200,8 +200,8 @@ itkHoughTransform2DLinesImageTest(int, char *[]) auto threshFilter = ThresholdFilterType::New(); threshFilter->SetInput(gradFilter->GetOutput()); threshFilter->SetOutsideValue(0); - unsigned char lowerThreshold = 10; - unsigned char upperThreshold = 200; + const unsigned char lowerThreshold = 10; + const unsigned char upperThreshold = 200; threshFilter->ThresholdOutside(lowerThreshold, upperThreshold); threshFilter->Update(); @@ -214,11 +214,11 @@ itkHoughTransform2DLinesImageTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(houghFilter, HoughTransform2DLinesImageFilter, ImageToImageFilter); - float threshold = 2.3; + const float threshold = 2.3; houghFilter->SetThreshold(threshold); ITK_TEST_SET_GET_VALUE(threshold, houghFilter->GetThreshold()); - float angleResolution = 200.0; + const float angleResolution = 200.0; houghFilter->SetAngleResolution(angleResolution); ITK_TEST_SET_GET_VALUE(angleResolution, houghFilter->GetAngleResolution()); @@ -226,11 +226,11 @@ itkHoughTransform2DLinesImageTest(int, char *[]) houghFilter->SetNumberOfLines(numberOfLines); ITK_TEST_SET_GET_VALUE(numberOfLines, houghFilter->GetNumberOfLines()); - float discRadius = 25.0; + const float discRadius = 25.0; houghFilter->SetDiscRadius(discRadius); ITK_TEST_SET_GET_VALUE(discRadius, houghFilter->GetDiscRadius()); - float variance = 10; + const float variance = 10; houghFilter->SetVariance(variance); ITK_TEST_SET_GET_VALUE(variance, houghFilter->GetVariance()); @@ -241,9 +241,9 @@ itkHoughTransform2DLinesImageTest(int, char *[]) houghFilter->Simplify(); - HoughImageType::Pointer accumulator = houghFilter->GetOutput(); + const HoughImageType::Pointer accumulator = houghFilter->GetOutput(); - HoughImageType::ConstPointer simplifyAccumulator = houghFilter->GetSimplifyAccumulator(); + const HoughImageType::ConstPointer simplifyAccumulator = houghFilter->GetSimplifyAccumulator(); // Blur the accumulator in order to find the maximum @@ -259,12 +259,13 @@ itkHoughTransform2DLinesImageTest(int, char *[]) gaussianFilter->Update(); - HoughImageType::Pointer postProcessImage = gaussianFilter->GetOutput(); + const HoughImageType::Pointer postProcessImage = gaussianFilter->GetOutput(); using MinMaxCalculatorType = itk::MinimumMaximumImageCalculator; auto minMaxCalculator = MinMaxCalculatorType::New(); - itk::ImageRegionIterator it_output(m_HoughSpaceImage, m_HoughSpaceImage->GetLargestPossibleRegion()); + const itk::ImageRegionIterator it_output(m_HoughSpaceImage, + m_HoughSpaceImage->GetLargestPossibleRegion()); itk::ImageRegionIterator it_input(postProcessImage, postProcessImage->GetLargestPossibleRegion()); @@ -323,8 +324,8 @@ itkHoughTransform2DLinesImageTest(int, char *[]) // Check the line detection auto it_list = linesList.begin(); - double angleTolerance = 0.1; - double radiusTolerance = 1.0; + const double angleTolerance = 0.1; + const double radiusTolerance = 1.0; while (it_list != linesList.end()) { if (!itk::Math::FloatAlmostEqual(it_list->angle, theta, 10, angleTolerance)) diff --git a/Modules/Filtering/ImageFeature/test/itkLaplacianImageFilterTest.cxx b/Modules/Filtering/ImageFeature/test/itkLaplacianImageFilterTest.cxx index 67a69b3042e..a8a3ab36a6b 100644 --- a/Modules/Filtering/ImageFeature/test/itkLaplacianImageFilterTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkLaplacianImageFilterTest.cxx @@ -63,13 +63,13 @@ itkLaplacianImageFilterTest(int argc, char * argv[]) reader->GetOutput()->SetSpacing(spacing); // Set up filter - itk::LaplacianImageFilter::Pointer filter = + const itk::LaplacianImageFilter::Pointer filter = itk::LaplacianImageFilter::New(); auto useImageSpacing = static_cast(std::stoi(argv[3])); ITK_TEST_SET_GET_BOOLEAN(filter, UseImageSpacing, useImageSpacing); - itk::SimpleFilterWatcher watch(filter); + const itk::SimpleFilterWatcher watch(filter); // Run test itk::Size sz; diff --git a/Modules/Filtering/ImageFeature/test/itkLaplacianRecursiveGaussianImageFilterTest.cxx b/Modules/Filtering/ImageFeature/test/itkLaplacianRecursiveGaussianImageFilterTest.cxx index 06d0b55bec8..0679ab2f6cd 100644 --- a/Modules/Filtering/ImageFeature/test/itkLaplacianRecursiveGaussianImageFilterTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkLaplacianRecursiveGaussianImageFilterTest.cxx @@ -73,9 +73,9 @@ itkLaplacianRecursiveGaussianImageFilterTest(int argc, char * argv[]) // Setting the ITK pipeline filter - auto lapFilter = LaplacianFilter::New(); - itk::SimpleFilterWatcher watcher(lapFilter); - auto zeroFilter = ZeroCrossingFilter::New(); + auto lapFilter = LaplacianFilter::New(); + const itk::SimpleFilterWatcher watcher(lapFilter); + auto zeroFilter = ZeroCrossingFilter::New(); reader->SetFileName(inputFilename); writer->SetFileName(outputFilename); @@ -96,7 +96,7 @@ itkLaplacianRecursiveGaussianImageFilterTest(int argc, char * argv[]) rescale->SetInput(zeroFilter->GetOutput()); // Test itkGetMacro - bool bNormalizeAcrossScale = lapFilter->GetNormalizeAcrossScale(); + const bool bNormalizeAcrossScale = lapFilter->GetNormalizeAcrossScale(); std::cout << "lapFilter->GetNormalizeAcrossScale(): " << bNormalizeAcrossScale << std::endl; ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update()); diff --git a/Modules/Filtering/ImageFeature/test/itkMaskFeaturePointSelectionFilterTest.cxx b/Modules/Filtering/ImageFeature/test/itkMaskFeaturePointSelectionFilterTest.cxx index 32b3b8e91ca..eb65461038c 100644 --- a/Modules/Filtering/ImageFeature/test/itkMaskFeaturePointSelectionFilterTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkMaskFeaturePointSelectionFilterTest.cxx @@ -141,8 +141,8 @@ itkMaskFeaturePointSelectionFilterTest(int argc, char * argv[]) // Highlight the feature points identified in the output image using PointIteratorType = PointSetType::PointsContainer::ConstIterator; - PointIteratorType pointItr = filter->GetOutput()->GetPoints()->Begin(); - PointIteratorType pointEnd = filter->GetOutput()->GetPoints()->End(); + PointIteratorType pointItr = filter->GetOutput()->GetPoints()->Begin(); + const PointIteratorType pointEnd = filter->GetOutput()->GetPoints()->End(); OutputImageType::IndexType index; diff --git a/Modules/Filtering/ImageFeature/test/itkMultiScaleHessianBasedMeasureImageFilterTest.cxx b/Modules/Filtering/ImageFeature/test/itkMultiScaleHessianBasedMeasureImageFilterTest.cxx index 69e4f2d9251..966d64b5b76 100644 --- a/Modules/Filtering/ImageFeature/test/itkMultiScaleHessianBasedMeasureImageFilterTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkMultiScaleHessianBasedMeasureImageFilterTest.cxx @@ -93,13 +93,13 @@ itkMultiScaleHessianBasedMeasureImageFilterTest(int argc, char * argv[]) multiScaleEnhancementFilter->SetSigmaStepMethodToLogarithmic(); - itk::SimpleFilterWatcher watcher(multiScaleEnhancementFilter); + const itk::SimpleFilterWatcher watcher(multiScaleEnhancementFilter); constexpr double tolerance = 0.01; if (argc > 4) { - double sigmaMinimum = std::stod(argv[4]); + const double sigmaMinimum = std::stod(argv[4]); multiScaleEnhancementFilter->SetSigmaMinimum(sigmaMinimum); if (itk::Math::abs(multiScaleEnhancementFilter->GetSigmaMinimum() - sigmaMinimum) > tolerance) @@ -111,7 +111,7 @@ itkMultiScaleHessianBasedMeasureImageFilterTest(int argc, char * argv[]) if (argc > 5) { - double sigmaMaximum = std::stod(argv[5]); + const double sigmaMaximum = std::stod(argv[5]); multiScaleEnhancementFilter->SetSigmaMaximum(sigmaMaximum); if (itk::Math::abs(multiScaleEnhancementFilter->GetSigmaMaximum() - sigmaMaximum) > tolerance) @@ -123,7 +123,7 @@ itkMultiScaleHessianBasedMeasureImageFilterTest(int argc, char * argv[]) if (argc > 6) { - unsigned int numberOfSigmaSteps = std::stoi(argv[6]); + const unsigned int numberOfSigmaSteps = std::stoi(argv[6]); multiScaleEnhancementFilter->SetNumberOfSigmaSteps(numberOfSigmaSteps); if (multiScaleEnhancementFilter->GetNumberOfSigmaSteps() != numberOfSigmaSteps) diff --git a/Modules/Filtering/ImageFeature/test/itkSimpleContourExtractorImageFilterTest.cxx b/Modules/Filtering/ImageFeature/test/itkSimpleContourExtractorImageFilterTest.cxx index d65ffc8bb7e..2b3bfe64809 100644 --- a/Modules/Filtering/ImageFeature/test/itkSimpleContourExtractorImageFilterTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkSimpleContourExtractorImageFilterTest.cxx @@ -63,16 +63,16 @@ itkSimpleContourExtractorImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, SimpleContourExtractorImageFilter, BoxImageFilter); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); // Connect the pipeline filter->SetInput(reader->GetOutput()); writer->SetInput(filter->GetOutput()); - FilterType::InputPixelType inputForegroundValue = 255; - FilterType::InputPixelType inputBackgroundValue = 0; - FilterType::OutputPixelType outputForegroundValue = itk::NumericTraits::max(); - FilterType::OutputPixelType outputBackgroundValue{}; + const FilterType::InputPixelType inputForegroundValue = 255; + const FilterType::InputPixelType inputBackgroundValue = 0; + const FilterType::OutputPixelType outputForegroundValue = itk::NumericTraits::max(); + const FilterType::OutputPixelType outputBackgroundValue{}; filter->SetInputForegroundValue(inputForegroundValue); diff --git a/Modules/Filtering/ImageFeature/test/itkSobelEdgeDetectionImageFilterTest.cxx b/Modules/Filtering/ImageFeature/test/itkSobelEdgeDetectionImageFilterTest.cxx index 645e90b7f98..6722d01b93e 100644 --- a/Modules/Filtering/ImageFeature/test/itkSobelEdgeDetectionImageFilterTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkSobelEdgeDetectionImageFilterTest.cxx @@ -40,7 +40,7 @@ itkSobelEdgeDetectionImageFilterTest(int argc, char * argv[]) using InputImageType = itk::Image; using OutputImageType = itk::Image; - itk::SobelEdgeDetectionImageFilter::Pointer filter = + const itk::SobelEdgeDetectionImageFilter::Pointer filter = itk::SobelEdgeDetectionImageFilter::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, SobelEdgeDetectionImageFilter, ImageToImageFilter); diff --git a/Modules/Filtering/ImageFeature/test/itkUnsharpMaskImageFilterTestSimple.cxx b/Modules/Filtering/ImageFeature/test/itkUnsharpMaskImageFilterTestSimple.cxx index 36efe752ebd..69830f255ca 100644 --- a/Modules/Filtering/ImageFeature/test/itkUnsharpMaskImageFilterTestSimple.cxx +++ b/Modules/Filtering/ImageFeature/test/itkUnsharpMaskImageFilterTestSimple.cxx @@ -90,7 +90,7 @@ itkUnsharpMaskImageFilterTestSimple(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, UnsharpMaskImageFilter, ImageToImageFilter); - itk::SimpleFilterWatcher watchit(filter); + const itk::SimpleFilterWatcher watchit(filter); // Connect the input images filter->SetInput(inputImage); @@ -103,15 +103,15 @@ itkUnsharpMaskImageFilterTestSimple(int, char *[]) // Set the filter properties - UnsharpMaskImageFilterFilterType::SigmaArrayType::ValueType sigma = 2.5; + const UnsharpMaskImageFilterFilterType::SigmaArrayType::ValueType sigma = 2.5; filter->SetSigma(sigma); UnsharpMaskImageFilterFilterType::SigmaArrayType sigmas = filter->GetSigmas(); - double tolerance = 10e-6; + const double tolerance = 10e-6; for (unsigned int i = 0; i < sigmas.Size(); ++i) { - UnsharpMaskImageFilterFilterType::SigmaArrayType::ValueType sigma2 = sigmas[i]; + const UnsharpMaskImageFilterFilterType::SigmaArrayType::ValueType sigma2 = sigmas[i]; if (!itk::Math::FloatAlmostEqual(sigma, sigma2, 10, tolerance)) { std::cerr.precision(static_cast(itk::Math::abs(std::log10(tolerance)))); @@ -123,7 +123,7 @@ itkUnsharpMaskImageFilterTestSimple(int, char *[]) } } - UnsharpMaskImageFilterFilterType::InternalPrecisionType amount = 0.8; + const UnsharpMaskImageFilterFilterType::InternalPrecisionType amount = 0.8; filter->SetAmount(amount); ITK_TEST_SET_GET_VALUE(amount, filter->GetAmount()); @@ -153,12 +153,12 @@ itkUnsharpMaskImageFilterTestSimple(int, char *[]) // It is important to do it AFTER the filter is Updated // Because the object connected to the output may be changed // by another during GenerateData() call - GradientImageType::Pointer outputImage = filter->GetOutput(); + const GradientImageType::Pointer outputImage = filter->GetOutput(); // check that output is correct near the step start[0] = 9; - float mins[4] = { -0.21f, -0.33f, 1.32f, 1.20f }; - float maxs[4] = { -0.20f, -0.32f, 1.33f, 1.21f }; + const float mins[4] = { -0.21f, -0.33f, 1.32f, 1.20f }; + const float maxs[4] = { -0.20f, -0.32f, 1.33f, 1.21f }; for (unsigned int i = 0; i < 4; ++i) { if (outputImage->GetPixel(start) < mins[i] || outputImage->GetPixel(start) > maxs[i]) diff --git a/Modules/Filtering/ImageFeature/test/itkZeroCrossingBasedEdgeDetectionImageFilterTest.cxx b/Modules/Filtering/ImageFeature/test/itkZeroCrossingBasedEdgeDetectionImageFilterTest.cxx index b4b96bb8590..840345def2a 100644 --- a/Modules/Filtering/ImageFeature/test/itkZeroCrossingBasedEdgeDetectionImageFilterTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkZeroCrossingBasedEdgeDetectionImageFilterTest.cxx @@ -43,9 +43,9 @@ itkZeroCrossingBasedEdgeDetectionImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, ZeroCrossingBasedEdgeDetectionImageFilter, ImageToImageFilter); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); - float varianceValue = std::stod(argv[1]); + const float varianceValue = std::stod(argv[1]); filter->SetVariance(varianceValue); for (auto i : filter->GetVariance()) { @@ -62,7 +62,7 @@ itkZeroCrossingBasedEdgeDetectionImageFilterTest(int argc, char * argv[]) filter->SetVariance(variance); ITK_TEST_SET_GET_VALUE(variance, filter->GetVariance()); - float maximumErrorValue = std::stod(argv[2]); + const float maximumErrorValue = std::stod(argv[2]); filter->SetMaximumError(maximumErrorValue); for (auto i : filter->GetMaximumError()) { diff --git a/Modules/Filtering/ImageFeature/test/itkZeroCrossingImageFilterTest.cxx b/Modules/Filtering/ImageFeature/test/itkZeroCrossingImageFilterTest.cxx index 46915e44ba8..4cf49d7db8c 100644 --- a/Modules/Filtering/ImageFeature/test/itkZeroCrossingImageFilterTest.cxx +++ b/Modules/Filtering/ImageFeature/test/itkZeroCrossingImageFilterTest.cxx @@ -44,12 +44,12 @@ itkZeroCrossingImageFilterTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, ZeroCrossingImageFilter, ImageToImageFilter); - typename FilterType::OutputImagePixelType foregroundValue = + const typename FilterType::OutputImagePixelType foregroundValue = itk::NumericTraits::OneValue(); filter->SetForegroundValue(foregroundValue); ITK_TEST_SET_GET_VALUE(foregroundValue, filter->GetForegroundValue()); - typename FilterType::OutputImagePixelType backgroundValue{}; + const typename FilterType::OutputImagePixelType backgroundValue{}; filter->SetBackgroundValue(backgroundValue); ITK_TEST_SET_GET_VALUE(backgroundValue, filter->GetBackgroundValue()); diff --git a/Modules/Filtering/ImageFilterBase/include/itkBinaryFunctorImageFilter.hxx b/Modules/Filtering/ImageFilterBase/include/itkBinaryFunctorImageFilter.hxx index 1e8f95e0177..6b2d64ff090 100644 --- a/Modules/Filtering/ImageFilterBase/include/itkBinaryFunctorImageFilter.hxx +++ b/Modules/Filtering/ImageFilterBase/include/itkBinaryFunctorImageFilter.hxx @@ -134,9 +134,9 @@ template ::GenerateOutputInformation() { - const DataObject * input = nullptr; - Input1ImagePointer inputPtr1 = dynamic_cast(ProcessObject::GetInput(0)); - Input2ImagePointer inputPtr2 = dynamic_cast(ProcessObject::GetInput(1)); + const DataObject * input = nullptr; + const Input1ImagePointer inputPtr1 = dynamic_cast(ProcessObject::GetInput(0)); + const Input2ImagePointer inputPtr2 = dynamic_cast(ProcessObject::GetInput(1)); if (this->GetNumberOfInputs() >= 2) { diff --git a/Modules/Filtering/ImageFilterBase/include/itkBoxImageFilter.hxx b/Modules/Filtering/ImageFilterBase/include/itkBoxImageFilter.hxx index 327d49f5e9e..705991a763d 100644 --- a/Modules/Filtering/ImageFilterBase/include/itkBoxImageFilter.hxx +++ b/Modules/Filtering/ImageFilterBase/include/itkBoxImageFilter.hxx @@ -55,7 +55,7 @@ BoxImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); + const typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); if (!inputPtr) { diff --git a/Modules/Filtering/ImageFilterBase/include/itkCastImageFilter.hxx b/Modules/Filtering/ImageFilterBase/include/itkCastImageFilter.hxx index 5f0d78d04c0..8efeedc7c16 100644 --- a/Modules/Filtering/ImageFilterBase/include/itkCastImageFilter.hxx +++ b/Modules/Filtering/ImageFilterBase/include/itkCastImageFilter.hxx @@ -42,7 +42,7 @@ CastImageFilter::GenerateData() // nothing to do, so avoid iterating over all the pixels // for nothing! Allocate the output, generate a fake progress and exit this->AllocateOutputs(); - ProgressReporter progress(this, 0, 1); + const ProgressReporter progress(this, 0, 1); return; } // else do normal Before+Threaded+After @@ -72,7 +72,8 @@ CastImageFilter::GenerateOutputInformation() this->CallCopyInputRegionToOutputRegion(outputLargestPossibleRegion, inputPtr->GetLargestPossibleRegion()); outputPtr->SetLargestPossibleRegion(outputLargestPossibleRegion); - ImageToImageFilterDetail::ImageInformationCopier + const ImageToImageFilterDetail::ImageInformationCopier informationCopier; informationCopier(outputPtr, inputPtr); } diff --git a/Modules/Filtering/ImageFilterBase/include/itkMaskNeighborhoodOperatorImageFilter.hxx b/Modules/Filtering/ImageFilterBase/include/itkMaskNeighborhoodOperatorImageFilter.hxx index 942183166c2..9a152ed0477 100644 --- a/Modules/Filtering/ImageFilterBase/include/itkMaskNeighborhoodOperatorImageFilter.hxx +++ b/Modules/Filtering/ImageFilterBase/include/itkMaskNeighborhoodOperatorImageFilter.hxx @@ -52,8 +52,8 @@ MaskNeighborhoodOperatorImageFilter(this->GetInput()); - MaskImagePointer maskPtr = const_cast(this->GetMaskImage()); + const InputImagePointer inputPtr = const_cast(this->GetInput()); + const MaskImagePointer maskPtr = const_cast(this->GetMaskImage()); if (!inputPtr || !maskPtr) { @@ -62,7 +62,7 @@ MaskNeighborhoodOperatorImageFilterGetRequestedRegion(); + const typename TInputImage::RegionType inputRequestedRegion = inputPtr->GetRequestedRegion(); // set the mask requested region to match the input requested region if (maskPtr->GetLargestPossibleRegion().IsInside(inputRequestedRegion)) @@ -103,7 +103,7 @@ MaskNeighborhoodOperatorImageFilter smartInnerProduct; + const NeighborhoodInnerProduct smartInnerProduct; // Break the input into a series of regions. The first region is free // of boundary conditions, the rest with boundary conditions. Note, // we pass in the input image and the OUTPUT requested region. We are @@ -112,13 +112,13 @@ MaskNeighborhoodOperatorImageFilter; using FaceListType = typename BFC::FaceListType; - BFC faceCalculator; - FaceListType faceList = faceCalculator(input, outputRegionForThread, this->GetOperator().GetRadius()); + BFC faceCalculator; + const FaceListType faceList = faceCalculator(input, outputRegionForThread, this->GetOperator().GetRadius()); TotalProgressReporter progress(this, output->GetRequestedRegion().GetNumberOfPixels()); // Get the operator - OutputNeighborhoodType noperator = this->GetOperator(); + const OutputNeighborhoodType noperator = this->GetOperator(); // Process non-boundary region and each of the boundary faces. // These are N-d regions which border the edge of the buffer. diff --git a/Modules/Filtering/ImageFilterBase/include/itkMovingHistogramImageFilter.hxx b/Modules/Filtering/ImageFilterBase/include/itkMovingHistogramImageFilter.hxx index 9e7d8e41d95..5c3129bd749 100644 --- a/Modules/Filtering/ImageFilterBase/include/itkMovingHistogramImageFilter.hxx +++ b/Modules/Filtering/ImageFilterBase/include/itkMovingHistogramImageFilter.hxx @@ -47,14 +47,14 @@ MovingHistogramImageFilter::Dyna OutputImageType * outputImage = this->GetOutput(); const InputImageType * inputImage = this->GetInput(); - RegionType inputRegion = inputImage->GetRequestedRegion(); + const RegionType inputRegion = inputImage->GetRequestedRegion(); TotalProgressReporter progress(this, outputImage->GetRequestedRegion().GetNumberOfPixels()); // initialize the histogram for (auto listIt = this->m_KernelOffsets.begin(); listIt != this->m_KernelOffsets.end(); ++listIt) { - IndexType idx = outputRegionForThread.GetIndex() + (*listIt); + const IndexType idx = outputRegionForThread.GetIndex() + (*listIt); if (inputRegion.IsInside(idx)) { histogram.AddPixel(inputImage->GetPixel(idx)); @@ -67,7 +67,7 @@ MovingHistogramImageFilter::Dyna // now move the histogram auto direction = MakeFilled>(1); - int axis = ImageDimension - 1; + const int axis = ImageDimension - 1; OffsetType offset{}; RegionType stRegion; stRegion.SetSize(this->m_Kernel.GetSize()); @@ -79,8 +79,8 @@ MovingHistogramImageFilter::Dyna centerOffset[i] = stRegion.GetSize()[i] / 2; } - int BestDirection = this->m_Axes[axis]; - int LineLength = inputRegion.GetSize()[BestDirection]; + const int BestDirection = this->m_Axes[axis]; + const int LineLength = inputRegion.GetSize()[BestDirection]; // init the offset and get the lists for the best axis offset[BestDirection] = direction[BestDirection]; @@ -115,11 +115,11 @@ MovingHistogramImageFilter::Dyna while (!InLineIt.IsAtEnd()) { HistogramType & histRef = HistVec[BestDirection]; - IndexType PrevLineStart = InLineIt.GetIndex(); + const IndexType PrevLineStart = InLineIt.GetIndex(); for (InLineIt.GoToBeginOfLine(); !InLineIt.IsAtEndOfLine(); ++InLineIt) { // Update the histogram - IndexType currentIdx = InLineIt.GetIndex(); + const IndexType currentIdx = InLineIt.GetIndex(); outputImage->SetPixel(currentIdx, static_cast(histRef.GetValue(inputImage->GetPixel(currentIdx)))); stRegion.SetIndex(currentIdx - centerOffset); @@ -145,7 +145,7 @@ MovingHistogramImageFilter::Dyna OffsetType Changes; this->GetDirAndOffset(LineStart, PrevLineStart, LineOffset, Changes, LineDirection); ++(Steps[LineDirection]); - IndexType PrevLineStartHist = LineStart - LineOffset; + const IndexType PrevLineStartHist = LineStart - LineOffset; const OffsetListType * addedListLine = &this->m_AddedOffsets[LineOffset]; const OffsetListType * removedListLine = &this->m_RemovedOffsets[LineOffset]; HistogramType & tmpHist = HistVec[LineDirection]; @@ -197,7 +197,7 @@ MovingHistogramImageFilter::Push // update the histogram for (auto addedIt = addedList->begin(); addedIt != addedList->end(); ++addedIt) { - IndexType idx = currentIdx + (*addedIt); + const IndexType idx = currentIdx + (*addedIt); if (inputRegion.IsInside(idx)) { histogram.AddPixel(inputImage->GetPixel(idx)); @@ -209,7 +209,7 @@ MovingHistogramImageFilter::Push } for (auto removedIt = removedList->begin(); removedIt != removedList->end(); ++removedIt) { - IndexType idx = currentIdx + (*removedIt); + const IndexType idx = currentIdx + (*removedIt); if (inputRegion.IsInside(idx)) { histogram.RemovePixel(inputImage->GetPixel(idx)); diff --git a/Modules/Filtering/ImageFilterBase/include/itkMovingHistogramImageFilterBase.hxx b/Modules/Filtering/ImageFilterBase/include/itkMovingHistogramImageFilterBase.hxx index e91052e0098..a7807879145 100644 --- a/Modules/Filtering/ImageFilterBase/include/itkMovingHistogramImageFilterBase.hxx +++ b/Modules/Filtering/ImageFilterBase/include/itkMovingHistogramImageFilterBase.hxx @@ -51,7 +51,7 @@ MovingHistogramImageFilterBase::SetKernel(co auto tmpSEImage = BoolImageType::New(); tmpSEImage->SetRegions(kernel.GetSize()); tmpSEImage->Allocate(); - RegionType tmpSEImageRegion = tmpSEImage->GetRequestedRegion(); + const RegionType tmpSEImageRegion = tmpSEImage->GetRequestedRegion(); ImageRegionIteratorWithIndex kernelImageIt(tmpSEImage, tmpSEImageRegion); KernelIteratorType kernel_it = kernel.Begin(); OffsetListType kernelOffsets; @@ -117,12 +117,12 @@ MovingHistogramImageFilterBase::SetKernel(co refOffset[axis] = direction; for (kernelImageIt.GoToBegin(); !kernelImageIt.IsAtEnd(); ++kernelImageIt) { - IndexType idx = kernelImageIt.GetIndex(); + const IndexType idx = kernelImageIt.GetIndex(); if (kernelImageIt.Get()) { // search for added pixel during a translation - IndexType nextIdx = idx + refOffset; + const IndexType nextIdx = idx + refOffset; if (tmpSEImageRegion.IsInside(nextIdx)) { if (!tmpSEImage->GetPixel(nextIdx)) @@ -137,7 +137,7 @@ MovingHistogramImageFilterBase::SetKernel(co axisCount[axis]++; } // search for removed pixel during a translation - IndexType prevIdx = idx - refOffset; + const IndexType prevIdx = idx - refOffset; if (tmpSEImageRegion.IsInside(prevIdx)) { if (!tmpSEImage->GetPixel(prevIdx)) diff --git a/Modules/Filtering/ImageFilterBase/include/itkNeighborhoodOperatorImageFilter.hxx b/Modules/Filtering/ImageFilterBase/include/itkNeighborhoodOperatorImageFilter.hxx index 12a6f2f35e0..98a25377162 100644 --- a/Modules/Filtering/ImageFilterBase/include/itkNeighborhoodOperatorImageFilter.hxx +++ b/Modules/Filtering/ImageFilterBase/include/itkNeighborhoodOperatorImageFilter.hxx @@ -36,7 +36,7 @@ NeighborhoodOperatorImageFilter:: Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - InputImagePointer inputPtr = const_cast(this->GetInput()); + const InputImagePointer inputPtr = const_cast(this->GetInput()); if (!inputPtr) { @@ -81,8 +81,8 @@ NeighborhoodOperatorImageFilter:: using BFC = NeighborhoodAlgorithm::ImageBoundaryFacesCalculator; using FaceListType = typename BFC::FaceListType; - NeighborhoodInnerProduct smartInnerProduct; - BFC faceCalculator; + const NeighborhoodInnerProduct smartInnerProduct; + BFC faceCalculator; OutputImageType * output = this->GetOutput(); const InputImageType * input = this->GetInput(); @@ -92,7 +92,7 @@ NeighborhoodOperatorImageFilter:: // we pass in the input image and the OUTPUT requested region. We are // only concerned with centering the neighborhood operator at the // pixels that correspond to output pixels. - FaceListType faceList = faceCalculator(input, outputRegionForThread, m_Operator.GetRadius()); + const FaceListType faceList = faceCalculator(input, outputRegionForThread, m_Operator.GetRadius()); ImageRegionIterator it; diff --git a/Modules/Filtering/ImageFilterBase/include/itkNoiseImageFilter.hxx b/Modules/Filtering/ImageFilterBase/include/itkNoiseImageFilter.hxx index c8f8a3c223d..4af5d1454de 100644 --- a/Modules/Filtering/ImageFilterBase/include/itkNoiseImageFilter.hxx +++ b/Modules/Filtering/ImageFilterBase/include/itkNoiseImageFilter.hxx @@ -47,12 +47,12 @@ NoiseImageFilter::DynamicThreadedGenerateData( ImageRegionIterator it; // Allocate output - typename OutputImageType::Pointer output = this->GetOutput(); - typename InputImageType::ConstPointer input = this->GetInput(); + const typename OutputImageType::Pointer output = this->GetOutput(); + const typename InputImageType::ConstPointer input = this->GetInput(); // Find the data-set boundary "faces" - NeighborhoodAlgorithm::ImageBoundaryFacesCalculator bC; - typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = + NeighborhoodAlgorithm::ImageBoundaryFacesCalculator bC; + const typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = bC(input, outputRegionForThread, this->GetRadius()); TotalProgressReporter progress(this, output->GetRequestedRegion().GetNumberOfPixels()); @@ -68,7 +68,7 @@ NoiseImageFilter::DynamicThreadedGenerateData( for (const auto & face : faceList) { bit = ConstNeighborhoodIterator(this->GetRadius(), input, face); - unsigned int neighborhoodSize = bit.Size(); + const unsigned int neighborhoodSize = bit.Size(); num = static_cast(bit.Size()); it = ImageRegionIterator(output, face); diff --git a/Modules/Filtering/ImageFilterBase/include/itkNullImageToImageFilterDriver.hxx b/Modules/Filtering/ImageFilterBase/include/itkNullImageToImageFilterDriver.hxx index b86f12cbfd9..185c648600c 100644 --- a/Modules/Filtering/ImageFilterBase/include/itkNullImageToImageFilterDriver.hxx +++ b/Modules/Filtering/ImageFilterBase/include/itkNullImageToImageFilterDriver.hxx @@ -165,18 +165,18 @@ NullImageToImageFilterDriver::Execute() // << m_Filter->GetOutput() << std::endl; using ImageFilterType = ImageToImageFilter; - typename ImageFilterType::Pointer sourceBefore = + const typename ImageFilterType::Pointer sourceBefore = dynamic_cast(m_Filter->GetOutput()->GetSource().GetPointer()); // Execute the filter - clock_t start = ::clock(); + const clock_t start = ::clock(); m_Filter->UpdateLargestPossibleRegion(); - clock_t stop = ::clock(); + const clock_t stop = ::clock(); // print out the output object so we can see it modified times and regions std::cout << "Output object after filter execution" << std::endl << m_Filter->GetOutput() << std::endl; - typename ImageFilterType::Pointer sourceAfter = + const typename ImageFilterType::Pointer sourceAfter = dynamic_cast(m_Filter->GetOutput()->GetSource().GetPointer()); std::cout << sourceBefore.GetPointer() << ", " << sourceAfter.GetPointer() << std::endl; diff --git a/Modules/Filtering/ImageFilterBase/include/itkRecursiveSeparableImageFilter.hxx b/Modules/Filtering/ImageFilterBase/include/itkRecursiveSeparableImageFilter.hxx index 725eee78a75..8b6679bdb18 100644 --- a/Modules/Filtering/ImageFilterBase/include/itkRecursiveSeparableImageFilter.hxx +++ b/Modules/Filtering/ImageFilterBase/include/itkRecursiveSeparableImageFilter.hxx @@ -200,8 +200,8 @@ RecursiveSeparableImageFilter::BeforeThreadedGenerate { using RegionType = ImageRegion; - typename TInputImage::ConstPointer inputImage(this->GetInputImage()); - typename TOutputImage::Pointer outputImage(this->GetOutput()); + const typename TInputImage::ConstPointer inputImage(this->GetInputImage()); + const typename TOutputImage::Pointer outputImage(this->GetOutput()); const unsigned int imageDimension = inputImage->GetImageDimension(); @@ -241,8 +241,8 @@ RecursiveSeparableImageFilter::GenerateData() this->BeforeThreadedGenerateData(); using RegionType = ImageRegion; - typename TOutputImage::Pointer outputImage(this->GetOutput()); - const RegionType region = outputImage->GetRequestedRegion(); + const typename TOutputImage::Pointer outputImage(this->GetOutput()); + const RegionType region = outputImage->GetRequestedRegion(); this->GetMultiThreader()->SetNumberOfWorkUnits(this->GetNumberOfWorkUnits()); this->GetMultiThreader()->template ParallelizeImageRegionRestrictDirection( @@ -268,10 +268,10 @@ RecursiveSeparableImageFilter::DynamicThreadedGenerat using RegionType = ImageRegion; - typename TInputImage::ConstPointer inputImage(this->GetInputImage()); - typename TOutputImage::Pointer outputImage(this->GetOutput()); + const typename TInputImage::ConstPointer inputImage(this->GetInputImage()); + const typename TOutputImage::Pointer outputImage(this->GetOutput()); - RegionType region = outputRegionForThread; + const RegionType region = outputRegionForThread; InputConstIteratorType inputIterator(inputImage, region); OutputIteratorType outputIterator(outputImage, region); diff --git a/Modules/Filtering/ImageFilterBase/include/itkTernaryGeneratorImageFilter.hxx b/Modules/Filtering/ImageFilterBase/include/itkTernaryGeneratorImageFilter.hxx index b4dd84ad2fa..1bad8b1798c 100644 --- a/Modules/Filtering/ImageFilterBase/include/itkTernaryGeneratorImageFilter.hxx +++ b/Modules/Filtering/ImageFilterBase/include/itkTernaryGeneratorImageFilter.hxx @@ -247,10 +247,10 @@ TernaryGeneratorImageFilter(ProcessObject::GetInput(0)); - const auto * inputPtr2 = dynamic_cast(ProcessObject::GetInput(1)); - const auto * inputPtr3 = dynamic_cast(ProcessObject::GetInput(2)); - OutputImagePointer outputPtr = this->GetOutput(0); + const auto * inputPtr1 = dynamic_cast(ProcessObject::GetInput(0)); + const auto * inputPtr2 = dynamic_cast(ProcessObject::GetInput(1)); + const auto * inputPtr3 = dynamic_cast(ProcessObject::GetInput(2)); + const OutputImagePointer outputPtr = this->GetOutput(0); TotalProgressReporter progress(this, outputPtr->GetRequestedRegion().GetNumberOfPixels()); diff --git a/Modules/Filtering/ImageFilterBase/include/itkUnaryGeneratorImageFilter.hxx b/Modules/Filtering/ImageFilterBase/include/itkUnaryGeneratorImageFilter.hxx index 284e53f6604..d96e2bee98f 100644 --- a/Modules/Filtering/ImageFilterBase/include/itkUnaryGeneratorImageFilter.hxx +++ b/Modules/Filtering/ImageFilterBase/include/itkUnaryGeneratorImageFilter.hxx @@ -56,7 +56,8 @@ UnaryGeneratorImageFilter::GenerateOutputInformation( this->CallCopyInputRegionToOutputRegion(outputLargestPossibleRegion, inputPtr->GetLargestPossibleRegion()); outputPtr->SetLargestPossibleRegion(outputLargestPossibleRegion); - ImageToImageFilterDetail::ImageInformationCopier + const ImageToImageFilterDetail::ImageInformationCopier informationCopier; informationCopier(outputPtr, inputPtr); } diff --git a/Modules/Filtering/ImageFilterBase/include/itkVectorNeighborhoodOperatorImageFilter.hxx b/Modules/Filtering/ImageFilterBase/include/itkVectorNeighborhoodOperatorImageFilter.hxx index 6a785bd30c8..20e728273c0 100644 --- a/Modules/Filtering/ImageFilterBase/include/itkVectorNeighborhoodOperatorImageFilter.hxx +++ b/Modules/Filtering/ImageFilterBase/include/itkVectorNeighborhoodOperatorImageFilter.hxx @@ -35,7 +35,7 @@ VectorNeighborhoodOperatorImageFilter::GenerateInputR Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - InputImagePointer inputPtr = const_cast(this->GetInput()); + const InputImagePointer inputPtr = const_cast(this->GetInput()); if (!inputPtr) { @@ -80,8 +80,8 @@ VectorNeighborhoodOperatorImageFilter::DynamicThreade using BFC = NeighborhoodAlgorithm::ImageBoundaryFacesCalculator; using FaceListType = typename BFC::FaceListType; - VectorNeighborhoodInnerProduct smartInnerProduct; - BFC faceCalculator; + const VectorNeighborhoodInnerProduct smartInnerProduct; + BFC faceCalculator; // Allocate output OutputImageType * output = this->GetOutput(); @@ -92,7 +92,7 @@ VectorNeighborhoodOperatorImageFilter::DynamicThreade // we pass in the input image and the OUTPUT requested region. We are // only concerned with centering the neighborhood operator at the // pixels that correspond to output pixels. - FaceListType faceList = faceCalculator(input, outputRegionForThread, m_Operator.GetRadius()); + const FaceListType faceList = faceCalculator(input, outputRegionForThread, m_Operator.GetRadius()); TotalProgressReporter progress(this, output->GetRequestedRegion().GetNumberOfPixels()); diff --git a/Modules/Filtering/ImageFilterBase/test/itkCastImageFilterTest.cxx b/Modules/Filtering/ImageFilterBase/test/itkCastImageFilterTest.cxx index 8fd5cabfda2..70c2643f07f 100644 --- a/Modules/Filtering/ImageFilterBase/test/itkCastImageFilterTest.cxx +++ b/Modules/Filtering/ImageFilterBase/test/itkCastImageFilterTest.cxx @@ -77,7 +77,7 @@ GetCastTypeName() { std::string name; #ifdef GCC_USEDEMANGLE - char const * mangledName = typeid(T).name(); + const char * mangledName = typeid(T).name(); int status; char * unmangled = abi::__cxa_demangle(mangledName, nullptr, nullptr, &status); name = unmangled; @@ -149,13 +149,13 @@ TestCastFromTo() randomValuesImageSource->SetSize(randomSize); } randomValuesImageSource->UpdateLargestPossibleRegion(); - typename InputImageType::Pointer randomSourceImagePtr = randomValuesImageSource->GetOutput(); + const typename InputImageType::Pointer randomSourceImagePtr = randomValuesImageSource->GetOutput(); { - typename InputImageType::IndexType Index000{ { 0, 0, 0 } }; - typename InputImageType::IndexType Index100{ { 1, 0, 0 } }; - typename InputImageType::IndexType Index200{ { 2, 0, 0 } }; - typename InputImageType::IndexType Index300{ { 3, 0, 0 } }; - typename InputImageType::IndexType Index400{ { 4, 0, 0 } }; + const typename InputImageType::IndexType Index000{ { 0, 0, 0 } }; + const typename InputImageType::IndexType Index100{ { 1, 0, 0 } }; + const typename InputImageType::IndexType Index200{ { 2, 0, 0 } }; + const typename InputImageType::IndexType Index300{ { 3, 0, 0 } }; + const typename InputImageType::IndexType Index400{ { 4, 0, 0 } }; /* Exercise input image type domain values (important for float -> integer conversions) * @@ -286,7 +286,7 @@ TestVectorImageCast1() const itk::Size<2> size{ { 1, 3 } }; const itk::Index<2> start{ { 0, 0 } }; - itk::ImageRegion<2> region(start, size); + const itk::ImageRegion<2> region(start, size); image->SetNumberOfComponentsPerPixel(2); image->SetRegions(region); image->Allocate(); @@ -353,7 +353,7 @@ TestVectorImageCast2() const itk::Size<2> size{ { 1, 3 } }; const itk::Index<2> start{ { 0, 0 } }; - itk::ImageRegion<2> region(start, size); + const itk::ImageRegion<2> region(start, size); image->SetNumberOfComponentsPerPixel(2); image->SetRegions(region); image->Allocate(); @@ -411,8 +411,8 @@ itkCastImageFilterTest(int, char *[]) // This test casts floats to char, generating float point exceptions. // We disable float point exceptions only for this tests - bool fpeSupport = itk::FloatingPointExceptions::HasFloatingPointExceptionsSupport(); - bool fpeStatus = itk::FloatingPointExceptions::GetEnabled(); + const bool fpeSupport = itk::FloatingPointExceptions::HasFloatingPointExceptionsSupport(); + const bool fpeStatus = itk::FloatingPointExceptions::GetEnabled(); if (fpeSupport && fpeStatus) { std::cout << "FloatingPointExceptions are disabled only for this test." << std::endl; diff --git a/Modules/Filtering/ImageFilterBase/test/itkGeneratorImageFilterGTest.cxx b/Modules/Filtering/ImageFilterBase/test/itkGeneratorImageFilterGTest.cxx index 61d3e1a2a70..0b3e160c463 100644 --- a/Modules/Filtering/ImageFilterBase/test/itkGeneratorImageFilterGTest.cxx +++ b/Modules/Filtering/ImageFilterBase/test/itkGeneratorImageFilterGTest.cxx @@ -106,7 +106,7 @@ TEST(UnaryGeneratorImageFilter, SetGetBasic) auto filter = FilterType::New(); filter->Print(std::cout); - FilterType::ConstPointer constFilter = (const FilterType *)(filter.GetPointer()); + const FilterType::ConstPointer constFilter = (const FilterType *)(filter.GetPointer()); EXPECT_STREQ("UnaryGeneratorImageFilter", filter->GetNameOfClass()); EXPECT_STREQ("InPlaceImageFilter", filter->Superclass::GetNameOfClass()); @@ -125,7 +125,7 @@ TEST(BinaryGeneratorImageFilter, SetGetBasic) filter->Print(std::cout); - FilterType::ConstPointer constFilter = (const FilterType *)(filter.GetPointer()); + const FilterType::ConstPointer constFilter = (const FilterType *)(filter.GetPointer()); EXPECT_STREQ("BinaryGeneratorImageFilter", filter->GetNameOfClass()); EXPECT_STREQ("InPlaceImageFilter", filter->Superclass::GetNameOfClass()); @@ -154,7 +154,7 @@ TEST(TernaryGeneratorImageFilter, SetGetBasic) filter->Print(std::cout); - FilterType::ConstPointer constFilter = (const FilterType *)(filter.GetPointer()); + const FilterType::ConstPointer constFilter = (const FilterType *)(filter.GetPointer()); EXPECT_STREQ("TernaryGeneratorImageFilter", filter->GetNameOfClass()); EXPECT_STREQ("InPlaceImageFilter", filter->Superclass::GetNameOfClass()); @@ -190,7 +190,7 @@ TEST(UnaryGeneratorImageFilter, SetFunctor) Utils::ImageType::Pointer outputImage; - Utils::IndexType idx{}; + const Utils::IndexType idx{}; // Test with C style function pointer filter->SetFunctor(static_cast(std::cos)); @@ -212,7 +212,7 @@ TEST(UnaryGeneratorImageFilter, SetFunctor) EXPECT_NEAR(10.0, outputImage->GetPixel(idx), 1e-8); // test with std::functional - std::function func1 = static_cast(std::sin); + const std::function func1 = static_cast(std::sin); filter->SetFunctor(func1); EXPECT_NO_THROW(filter->Update()); @@ -221,7 +221,7 @@ TEST(UnaryGeneratorImageFilter, SetFunctor) EXPECT_NEAR(0.0, outputImage->GetPixel(idx), 1e-8); - std::function func2 = static_cast(Utils::MyUnaryFunction); + const std::function func2 = static_cast(Utils::MyUnaryFunction); filter->SetFunctor(func2); EXPECT_NO_THROW(filter->Update()); @@ -259,7 +259,7 @@ TEST(BinaryGeneratorImageFilter, SetFunctor) Utils::ImageType::Pointer outputImage; - Utils::IndexType idx{}; + const Utils::IndexType idx{}; // Test with C style function pointer filter->SetFunctor(Utils::MyBinaryFunction1); @@ -280,7 +280,7 @@ TEST(BinaryGeneratorImageFilter, SetFunctor) EXPECT_NEAR(4.0, outputImage->GetPixel(idx), 1e-8); // test with std::functional - std::function func1 = Utils::MyBinaryFunction1; + const std::function func1 = Utils::MyBinaryFunction1; filter->SetFunctor(func1); EXPECT_NO_THROW(filter->Update()); @@ -289,7 +289,7 @@ TEST(BinaryGeneratorImageFilter, SetFunctor) EXPECT_NEAR(7.0, outputImage->GetPixel(idx), 1e-8); - std::function func2 = Utils::MyBinaryFunction2; + const std::function func2 = Utils::MyBinaryFunction2; filter->SetFunctor(func2); EXPECT_NO_THROW(filter->Update()); @@ -333,7 +333,7 @@ TEST(TernaryGeneratorImageFilter, SetFunctor) Utils::ImageType::Pointer outputImage; - Utils::IndexType idx{}; + const Utils::IndexType idx{}; // Test with C style function pointer filter->SetFunctor(Utils::MyTernaryFunction1); @@ -354,7 +354,7 @@ TEST(TernaryGeneratorImageFilter, SetFunctor) EXPECT_NEAR(-5.0, outputImage->GetPixel(idx), 1e-8); // test with std::functional - std::function func1 = Utils::MyTernaryFunction1; + const std::function func1 = Utils::MyTernaryFunction1; filter->SetFunctor(func1); EXPECT_NO_THROW(filter->Update()); @@ -363,7 +363,7 @@ TEST(TernaryGeneratorImageFilter, SetFunctor) EXPECT_NEAR(6.0, outputImage->GetPixel(idx), 1e-8); - std::function func2 = Utils::MyTernaryFunction2; + const std::function func2 = Utils::MyTernaryFunction2; filter->SetFunctor(func2); EXPECT_NO_THROW(filter->Update()); @@ -400,7 +400,7 @@ TEST(TernaryGeneratorImageFilter, Constants) Utils::ImageType::Pointer outputImage; - Utils::IndexType idx{}; + const Utils::IndexType idx{}; // Test with C style function pointer filter->SetFunctor(Utils::MyTernaryFunction1); diff --git a/Modules/Filtering/ImageFilterBase/test/itkMaskNeighborhoodOperatorImageFilterTest.cxx b/Modules/Filtering/ImageFilterBase/test/itkMaskNeighborhoodOperatorImageFilterTest.cxx index 19fec2c988e..78db024a0c4 100644 --- a/Modules/Filtering/ImageFilterBase/test/itkMaskNeighborhoodOperatorImageFilterTest.cxx +++ b/Modules/Filtering/ImageFilterBase/test/itkMaskNeighborhoodOperatorImageFilterTest.cxx @@ -40,7 +40,7 @@ itkMaskNeighborhoodOperatorImageFilterTest(int argc, char * argv[]) using InputImageType = itk::Image; using OutputImageType = itk::Image; - itk::ImageFileReader::Pointer input = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer input = itk::ImageFileReader::New(); input->SetFileName(argv[1]); input->Update(); @@ -62,7 +62,7 @@ itkMaskNeighborhoodOperatorImageFilterTest(int argc, char * argv[]) size = region.GetSize(); index = region.GetIndex(); - unsigned int width = size[0]; + const unsigned int width = size[0]; size[0] = width / 2 - static_cast(.25 * static_cast(width)); index[0] = size[0] + static_cast(.25 * static_cast(width)); region.SetSize(size); @@ -107,11 +107,11 @@ itkMaskNeighborhoodOperatorImageFilterTest(int argc, char * argv[]) filter1->SetMaskImage(mask1); filter1->SetOperator(sobelHorizontal); - typename FilterType::OutputPixelType defaultValue{}; + const typename FilterType::OutputPixelType defaultValue{}; filter1->SetDefaultValue(defaultValue); ITK_TEST_SET_GET_VALUE(defaultValue, filter1->GetDefaultValue()); - bool useDefaultValue = false; + const bool useDefaultValue = false; ITK_TEST_SET_GET_BOOLEAN(filter1, UseDefaultValue, useDefaultValue); auto filter2 = FilterType::New(); @@ -134,7 +134,7 @@ itkMaskNeighborhoodOperatorImageFilterTest(int argc, char * argv[]) rescaler->SetInput(filter2->GetOutput()); // Generate test image - itk::ImageFileWriter::Pointer writer = itk::ImageFileWriter::New(); + const itk::ImageFileWriter::Pointer writer = itk::ImageFileWriter::New(); writer->SetInput(rescaler->GetOutput()); writer->SetFileName(argv[2]); diff --git a/Modules/Filtering/ImageFilterBase/test/itkNeighborhoodOperatorImageFilterTest.cxx b/Modules/Filtering/ImageFilterBase/test/itkNeighborhoodOperatorImageFilterTest.cxx index ba1c3816597..2e6c4aab758 100644 --- a/Modules/Filtering/ImageFilterBase/test/itkNeighborhoodOperatorImageFilterTest.cxx +++ b/Modules/Filtering/ImageFilterBase/test/itkNeighborhoodOperatorImageFilterTest.cxx @@ -35,7 +35,7 @@ itkNeighborhoodOperatorImageFilterTest(int, char *[]) oper.CreateDirectional(); // Set up filter - itk::NeighborhoodOperatorImageFilter::Pointer filter = + const itk::NeighborhoodOperatorImageFilter::Pointer filter = itk::NeighborhoodOperatorImageFilter::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, NeighborhoodOperatorImageFilter, ImageToImageFilter); diff --git a/Modules/Filtering/ImageFilterBase/test/itkVectorNeighborhoodOperatorImageFilterTest.cxx b/Modules/Filtering/ImageFilterBase/test/itkVectorNeighborhoodOperatorImageFilterTest.cxx index eaf6c4d75a2..c5b991032a4 100644 --- a/Modules/Filtering/ImageFilterBase/test/itkVectorNeighborhoodOperatorImageFilterTest.cxx +++ b/Modules/Filtering/ImageFilterBase/test/itkVectorNeighborhoodOperatorImageFilterTest.cxx @@ -37,7 +37,7 @@ itkVectorNeighborhoodOperatorImageFilterTest(int itkNotUsed(argc), char * itkNot oper.CreateDirectional(); // Set up filter - itk::VectorNeighborhoodOperatorImageFilter::Pointer filter = + const itk::VectorNeighborhoodOperatorImageFilter::Pointer filter = itk::VectorNeighborhoodOperatorImageFilter::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, VectorNeighborhoodOperatorImageFilter, ImageToImageFilter); diff --git a/Modules/Filtering/ImageFrequency/test/itkFrequencyBandImageFilterTest.cxx b/Modules/Filtering/ImageFrequency/test/itkFrequencyBandImageFilterTest.cxx index 34e3ef6a945..c1f9035a485 100644 --- a/Modules/Filtering/ImageFrequency/test/itkFrequencyBandImageFilterTest.cxx +++ b/Modules/Filtering/ImageFrequency/test/itkFrequencyBandImageFilterTest.cxx @@ -42,7 +42,7 @@ compareImages(ImageType * baseline, ImageType * test) differenceFilter->Update(); - unsigned int numberOfDiffPixels = differenceFilter->GetNumberOfPixelsWithDifferences(); + const unsigned int numberOfDiffPixels = differenceFilter->GetNumberOfPixelsWithDifferences(); if (numberOfDiffPixels > 0) { std::cerr << "Expected images to be equal, but got " << numberOfDiffPixels << "unequal pixels" << std::endl; @@ -144,7 +144,7 @@ itkFrequencyBandImageFilterTest(int argc, char * argv[]) passBandFilter->SetHighFrequencyThreshold(highFreqThreshold); ITK_TEST_SET_GET_VALUE(highFreqThreshold, passBandFilter->GetHighFrequencyThreshold()); - bool passBand = true; + const bool passBand = true; ITK_TEST_SET_GET_BOOLEAN(passBandFilter, PassBand, passBand); bool passLowFreqThreshold = true; @@ -189,14 +189,14 @@ itkFrequencyBandImageFilterTest(int argc, char * argv[]) // Tests with radians - BandFilterType::FrequencyValueType lowFreqThresholdRadians = itk::Math::pi_over_4; + const BandFilterType::FrequencyValueType lowFreqThresholdRadians = itk::Math::pi_over_4; passBandFilter->SetLowFrequencyThresholdInRadians(lowFreqThresholdRadians); - BandFilterType::FrequencyValueType highFreqThresholdRadians = itk::Math::pi_over_2; + const BandFilterType::FrequencyValueType highFreqThresholdRadians = itk::Math::pi_over_2; passBandFilter->SetHighFrequencyThresholdInRadians(highFreqThresholdRadians); - BandFilterType::FrequencyValueType knownLowFrequencyHertz = lowFreqThresholdRadians / (2 * itk::Math::pi); - BandFilterType::FrequencyValueType knownHighFrequencyHertz = highFreqThresholdRadians / (2 * itk::Math::pi); + const BandFilterType::FrequencyValueType knownLowFrequencyHertz = lowFreqThresholdRadians / (2 * itk::Math::pi); + const BandFilterType::FrequencyValueType knownHighFrequencyHertz = highFreqThresholdRadians / (2 * itk::Math::pi); if (itk::Math::NotAlmostEquals(knownLowFrequencyHertz, passBandFilter->GetLowFrequencyThreshold()) || itk::Math::NotAlmostEquals(knownHighFrequencyHertz, passBandFilter->GetHighFrequencyThreshold())) @@ -211,11 +211,11 @@ itkFrequencyBandImageFilterTest(int argc, char * argv[]) // Test the non-radial cut-off. // Don't pass negative frequency thresholds. - bool radialBand = false; + const bool radialBand = false; ITK_TEST_SET_GET_BOOLEAN(passBandFilter, RadialBand, radialBand); - bool passNegativeLowFrequencyThreshold = false; + const bool passNegativeLowFrequencyThreshold = false; ITK_TEST_SET_GET_BOOLEAN(passBandFilter, PassNegativeLowFrequencyThreshold, passNegativeLowFrequencyThreshold); - bool passNegativeHighFrequencyThreshold = false; + const bool passNegativeHighFrequencyThreshold = false; ITK_TEST_SET_GET_BOOLEAN(passBandFilter, PassNegativeHighFrequencyThreshold, passNegativeHighFrequencyThreshold); passBandFilter->Update(); @@ -300,7 +300,7 @@ itkFrequencyBandImageFilterTest(int argc, char * argv[]) // Test with std::functional auto stdFilter = UnaryFilterType::New(); stdFilter->SetInput(image); - std::function func1 = + const std::function func1 = static_cast(TestStruct::ConstUnaryFunction); stdFilter->SetFunctor(func1); ITK_TRY_EXPECT_NO_EXCEPTION(stdFilter->Update()); @@ -314,7 +314,7 @@ itkFrequencyBandImageFilterTest(int argc, char * argv[]) // Test with std::functional (in-place variant) auto stdFilterIP = UnaryFilterType::New(); stdFilterIP->SetInput(image); - std::function func2 = + const std::function func2 = static_cast(TestStruct::UnaryFunction); stdFilterIP->SetFunctor(func2); ITK_TRY_EXPECT_NO_EXCEPTION(stdFilterIP->Update()); diff --git a/Modules/Filtering/ImageFrequency/test/itkFrequencyFFTLayoutImageRegionIteratorWithIndexTest.cxx b/Modules/Filtering/ImageFrequency/test/itkFrequencyFFTLayoutImageRegionIteratorWithIndexTest.cxx index a681cedaf42..1299bad4bfd 100644 --- a/Modules/Filtering/ImageFrequency/test/itkFrequencyFFTLayoutImageRegionIteratorWithIndexTest.cxx +++ b/Modules/Filtering/ImageFrequency/test/itkFrequencyFFTLayoutImageRegionIteratorWithIndexTest.cxx @@ -41,7 +41,7 @@ class itkFrequencyFFTLayoutImageRegionIteratorWithIndexTester typename ImageType::IndexType start{}; - typename ImageType::RegionType region{ start, size }; + const typename ImageType::RegionType region{ start, size }; m_Image->SetRegions(region); @@ -53,7 +53,7 @@ class itkFrequencyFFTLayoutImageRegionIteratorWithIndexTester m_ImageIsOdd = inputImageSize % 2 == 1 ? true : false; // Setup the half, negative frequencies region. - unsigned int isImageSizeOdd = m_ImageIsOdd ? 1 : 0; + const unsigned int isImageSizeOdd = m_ImageIsOdd ? 1 : 0; size.Fill(inputImageSize / 2); start.Fill(inputImageSize / 2 + isImageSizeOdd); m_NegativeHalfRegion.SetSize(size); @@ -198,7 +198,7 @@ class itkFrequencyFFTLayoutImageRegionIteratorWithIndexTester } } - IndexType zero_freq_index{}; + const IndexType zero_freq_index{}; it.GoToBegin(); if (it.GetIndex() == m_Image->GetLargestPossibleRegion().GetIndex() && it.GetFrequencyBin() != zero_freq_index) @@ -210,9 +210,9 @@ class itkFrequencyFFTLayoutImageRegionIteratorWithIndexTester while (!it.IsAtEnd()) { - IndexType index = it.GetIndex(); + const IndexType index = it.GetIndex(); // Check to see if the index is within allowed bounds - bool isInside = m_Image->GetLargestPossibleRegion().IsInside(index); + const bool isInside = m_Image->GetLargestPossibleRegion().IsInside(index); if (!isInside) { std::cerr << "Test failed! " << std::endl; @@ -262,7 +262,7 @@ itkFrequencyFFTLayoutImageRegionIteratorWithIndexTest(int, char *[]) // Even input image size test { - size_t inputImageSize(8); + const size_t inputImageSize(8); std::cout << "Testing with EVEN Image< std::complex, 3 > with size: " << inputImageSize << std::endl; itkFrequencyFFTLayoutImageRegionIteratorWithIndexTester, Dimension>> Tester( inputImageSize); @@ -274,7 +274,7 @@ itkFrequencyFFTLayoutImageRegionIteratorWithIndexTest(int, char *[]) // Even input image size test { - size_t inputImageSize(10); + const size_t inputImageSize(10); std::cout << "Testing with EVEN Image< char, 3 > with size: " << inputImageSize << std::endl; itkFrequencyFFTLayoutImageRegionIteratorWithIndexTester> Tester( inputImageSize); @@ -286,7 +286,7 @@ itkFrequencyFFTLayoutImageRegionIteratorWithIndexTest(int, char *[]) // Odd input image size test { - size_t inputImageSize(9); + const size_t inputImageSize(9); std::cout << "Testing with ODD Image< char, 3 > with size: " << inputImageSize << std::endl; itkFrequencyFFTLayoutImageRegionIteratorWithIndexTester> Tester( inputImageSize); diff --git a/Modules/Filtering/ImageFrequency/test/itkFrequencyIteratorsGTest.cxx b/Modules/Filtering/ImageFrequency/test/itkFrequencyIteratorsGTest.cxx index 086642f0c4a..a5ceacf32a4 100644 --- a/Modules/Filtering/ImageFrequency/test/itkFrequencyIteratorsGTest.cxx +++ b/Modules/Filtering/ImageFrequency/test/itkFrequencyIteratorsGTest.cxx @@ -133,7 +133,7 @@ compareImages(ImageType * imageToTest, ImageType * knownImage, double difference differenceFilter->SetTestInput(imageToTest); differenceFilter->Update(); - unsigned int numberOfDiffPixels = differenceFilter->GetNumberOfPixelsWithDifferences(); + const unsigned int numberOfDiffPixels = differenceFilter->GetNumberOfPixelsWithDifferences(); if (numberOfDiffPixels > 0) { std::cerr << "Unequal images, with " << numberOfDiffPixels << " unequal pixels" << std::endl; @@ -204,7 +204,7 @@ applyBandFilterHermitian(typename ImageType::Pointer image) forwardFFT->Update(); using ComplexImageType = typename ForwardFFTType::OutputImageType; - typename ComplexImageType::Pointer forwardHandler = forwardFFT->GetOutput(); + const typename ComplexImageType::Pointer forwardHandler = forwardFFT->GetOutput(); using BandFilterType = itk::FrequencyBandImageFilter; auto bandFilter = BandFilterType::New(); @@ -213,7 +213,7 @@ applyBandFilterHermitian(typename ImageType::Pointer image) bandFilter->SetActualXDimensionIsOdd(forwardFFT->GetActualXDimensionIsOdd()); bandFilter->Update(); - typename ComplexImageType::Pointer inverseHandler = bandFilter->GetOutput(); + const typename ComplexImageType::Pointer inverseHandler = bandFilter->GetOutput(); auto inverseFFT = InverseFFTType::New(); inverseFFT->SetInput(inverseHandler); @@ -240,13 +240,13 @@ compareAllTypesOfIterators(typename TImageType::Pointer image, double difference // Shifted Full Forward FFT using FrequencyShiftedIteratorType = itk::FrequencyShiftedFFTLayoutImageRegionIteratorWithIndex; - bool shifted = true; - auto filteredShiftedImage = + const bool shifted = true; + auto filteredShiftedImage = applyBandFilter(image, shifted); // Compare Full and Shifted - bool fullAndShiftedAreEqual = compareImages(filteredShiftedImage, filteredImage); + const bool fullAndShiftedAreEqual = compareImages(filteredShiftedImage, filteredImage); EXPECT_TRUE(fullAndShiftedAreEqual); // Hermitian overload @@ -257,7 +257,8 @@ compareAllTypesOfIterators(typename TImageType::Pointer image, double difference // in the reconstruction (forward + inverse == original_image) // This is the minimum threshold for the comparison between // original and reconstructed image to be equal (without any extra band filter). - bool fullAndHermitian = compareImages(filteredHermitianImage, filteredImage, differenceHermitianThreshold); + const bool fullAndHermitian = + compareImages(filteredHermitianImage, filteredImage, differenceHermitianThreshold); EXPECT_TRUE(fullAndHermitian); } @@ -281,8 +282,8 @@ TEST_F(FrequencyIterators, Even3D) constexpr unsigned int ImageDimension = 3; using PixelType = float; using ImageType = itk::Image; - auto image = CreateImage(16); - double differenceHermitianThreshold = 0.00001; + auto image = CreateImage(16); + const double differenceHermitianThreshold = 0.00001; compareAllTypesOfIterators(image, differenceHermitianThreshold); } @@ -291,8 +292,8 @@ TEST_F(FrequencyIterators, Even2D) constexpr unsigned int ImageDimension = 2; using PixelType = float; using ImageType = itk::Image; - auto image = CreateImage(16); - double differenceHermitianThreshold = 0.00001; + auto image = CreateImage(16); + const double differenceHermitianThreshold = 0.00001; compareAllTypesOfIterators(image, differenceHermitianThreshold); } @@ -301,8 +302,8 @@ TEST_F(FrequencyIterators, Odd3D) constexpr unsigned int ImageDimension = 3; using PixelType = float; using ImageType = itk::Image; - auto image = CreateImage(15); - double differenceHermitianThreshold = 0.00001; + auto image = CreateImage(15); + const double differenceHermitianThreshold = 0.00001; compareAllTypesOfIterators(image, differenceHermitianThreshold); } @@ -311,7 +312,7 @@ TEST_F(FrequencyIterators, Odd2D) constexpr unsigned int ImageDimension = 2; using PixelType = float; using ImageType = itk::Image; - auto image = CreateImage(27); - double differenceHermitianThreshold = 0.0001; + auto image = CreateImage(27); + const double differenceHermitianThreshold = 0.0001; compareAllTypesOfIterators(image, differenceHermitianThreshold); } diff --git a/Modules/Filtering/ImageFusion/include/itkLabelMapContourOverlayImageFilter.hxx b/Modules/Filtering/ImageFusion/include/itkLabelMapContourOverlayImageFilter.hxx index 3380c7b4f92..4ed5026ea32 100644 --- a/Modules/Filtering/ImageFusion/include/itkLabelMapContourOverlayImageFilter.hxx +++ b/Modules/Filtering/ImageFusion/include/itkLabelMapContourOverlayImageFilter.hxx @@ -58,7 +58,7 @@ LabelMapContourOverlayImageFilter::Gener Superclass::GenerateInputRequestedRegion(); // We need all the input. - LabelMapPointer input = const_cast(this->GetInput()); + const LabelMapPointer input = const_cast(this->GetInput()); if (!input) { return; diff --git a/Modules/Filtering/ImageFusion/include/itkLabelMapOverlayImageFilter.hxx b/Modules/Filtering/ImageFusion/include/itkLabelMapOverlayImageFilter.hxx index d0e7d0ae943..8965cab2402 100644 --- a/Modules/Filtering/ImageFusion/include/itkLabelMapOverlayImageFilter.hxx +++ b/Modules/Filtering/ImageFusion/include/itkLabelMapOverlayImageFilter.hxx @@ -42,7 +42,7 @@ LabelMapOverlayImageFilter::GenerateInpu Superclass::GenerateInputRequestedRegion(); // We need all the input. - LabelMapPointer input = const_cast(this->GetInput()); + const LabelMapPointer input = const_cast(this->GetInput()); if (!input) { return; diff --git a/Modules/Filtering/ImageFusion/include/itkLabelToRGBFunctor.h b/Modules/Filtering/ImageFusion/include/itkLabelToRGBFunctor.h index 05f60f4851a..110eca6b46b 100644 --- a/Modules/Filtering/ImageFusion/include/itkLabelToRGBFunctor.h +++ b/Modules/Filtering/ImageFusion/include/itkLabelToRGBFunctor.h @@ -111,7 +111,7 @@ class LabelToRGBFunctor using ValueType = typename TRGBPixel::ValueType; - ValueType m = NumericTraits::max(); + const ValueType m = NumericTraits::max(); rgbPixel[0] = static_cast(static_cast(r) / 255 * m); rgbPixel[1] = static_cast(static_cast(g) / 255 * m); diff --git a/Modules/Filtering/ImageFusion/test/itkLabelMapContourOverlayImageFilterTest1.cxx b/Modules/Filtering/ImageFusion/test/itkLabelMapContourOverlayImageFilterTest1.cxx index 7a0a83828fe..31f894bc7ab 100644 --- a/Modules/Filtering/ImageFusion/test/itkLabelMapContourOverlayImageFilterTest1.cxx +++ b/Modules/Filtering/ImageFusion/test/itkLabelMapContourOverlayImageFilterTest1.cxx @@ -84,7 +84,7 @@ itkLabelMapContourOverlayImageFilterTest1(int argc, char * argv[]) colorizer->SetSliceDimension(sliceDimension); ITK_TEST_SET_GET_VALUE(sliceDimension, colorizer->GetSliceDimension()); - itk::SimpleFilterWatcher watcher(colorizer, "filter"); + const itk::SimpleFilterWatcher watcher(colorizer, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageFusion/test/itkLabelMapContourOverlayImageFilterTest2.cxx b/Modules/Filtering/ImageFusion/test/itkLabelMapContourOverlayImageFilterTest2.cxx index d91e179782b..dc7f94a1426 100644 --- a/Modules/Filtering/ImageFusion/test/itkLabelMapContourOverlayImageFilterTest2.cxx +++ b/Modules/Filtering/ImageFusion/test/itkLabelMapContourOverlayImageFilterTest2.cxx @@ -66,7 +66,7 @@ itkLabelMapContourOverlayImageFilterTest2(int argc, char * argv[]) colorizer->SetPriority(std::stoi(argv[8])); - itk::SimpleFilterWatcher watcher(colorizer, "filter"); + const itk::SimpleFilterWatcher watcher(colorizer, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageFusion/test/itkLabelMapContourOverlayImageFilterTest3.cxx b/Modules/Filtering/ImageFusion/test/itkLabelMapContourOverlayImageFilterTest3.cxx index 5768e166170..aa4ed9216ef 100644 --- a/Modules/Filtering/ImageFusion/test/itkLabelMapContourOverlayImageFilterTest3.cxx +++ b/Modules/Filtering/ImageFusion/test/itkLabelMapContourOverlayImageFilterTest3.cxx @@ -70,7 +70,7 @@ itkLabelMapContourOverlayImageFilterTest3(int argc, char * argv[]) functor.AddColor(255, 0, 0); colorizer->SetFunctor(functor); - itk::SimpleFilterWatcher watcher(colorizer, "filter"); + const itk::SimpleFilterWatcher watcher(colorizer, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageFusion/test/itkLabelMapOverlayImageFilterTest1.cxx b/Modules/Filtering/ImageFusion/test/itkLabelMapOverlayImageFilterTest1.cxx index 63343e6fd04..16f134484e7 100644 --- a/Modules/Filtering/ImageFusion/test/itkLabelMapOverlayImageFilterTest1.cxx +++ b/Modules/Filtering/ImageFusion/test/itkLabelMapOverlayImageFilterTest1.cxx @@ -58,11 +58,11 @@ itkLabelMapOverlayImageFilterTest1(int argc, char * argv[]) colorizer->SetInput(converter->GetOutput()); colorizer->SetFeatureImage(reader2->GetOutput()); - double opacity = std::stod(argv[4]); + const double opacity = std::stod(argv[4]); colorizer->SetOpacity(opacity); ITK_TEST_SET_GET_VALUE(opacity, colorizer->GetOpacity()); - itk::SimpleFilterWatcher watcher(colorizer, "filter"); + const itk::SimpleFilterWatcher watcher(colorizer, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageFusion/test/itkLabelMapOverlayImageFilterTest2.cxx b/Modules/Filtering/ImageFusion/test/itkLabelMapOverlayImageFilterTest2.cxx index a236f5cb31f..508945dc73d 100644 --- a/Modules/Filtering/ImageFusion/test/itkLabelMapOverlayImageFilterTest2.cxx +++ b/Modules/Filtering/ImageFusion/test/itkLabelMapOverlayImageFilterTest2.cxx @@ -58,7 +58,7 @@ itkLabelMapOverlayImageFilterTest2(int argc, char * argv[]) colorizer->SetFeatureImage(reader2->GetOutput()); colorizer->SetOpacity(std::stod(argv[4])); - itk::SimpleFilterWatcher watcher(colorizer, "filter"); + const itk::SimpleFilterWatcher watcher(colorizer, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageFusion/test/itkLabelMapOverlayImageFilterTest3.cxx b/Modules/Filtering/ImageFusion/test/itkLabelMapOverlayImageFilterTest3.cxx index 8d78173ba20..cce1b13cbd7 100644 --- a/Modules/Filtering/ImageFusion/test/itkLabelMapOverlayImageFilterTest3.cxx +++ b/Modules/Filtering/ImageFusion/test/itkLabelMapOverlayImageFilterTest3.cxx @@ -65,7 +65,7 @@ itkLabelMapOverlayImageFilterTest3(int argc, char * argv[]) functor.AddColor(255, 0, 0); colorizer->SetFunctor(functor); - itk::SimpleFilterWatcher watcher(colorizer, "filter"); + const itk::SimpleFilterWatcher watcher(colorizer, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageFusion/test/itkLabelMapToRGBImageFilterTest1.cxx b/Modules/Filtering/ImageFusion/test/itkLabelMapToRGBImageFilterTest1.cxx index d694a5638b9..ee624f8520a 100644 --- a/Modules/Filtering/ImageFusion/test/itkLabelMapToRGBImageFilterTest1.cxx +++ b/Modules/Filtering/ImageFusion/test/itkLabelMapToRGBImageFilterTest1.cxx @@ -54,7 +54,7 @@ itkLabelMapToRGBImageFilterTest1(int argc, char * argv[]) auto colorizer = ColorizerType::New(); colorizer->SetInput(converter->GetOutput()); - itk::SimpleFilterWatcher watcher(colorizer, "filter"); + const itk::SimpleFilterWatcher watcher(colorizer, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageFusion/test/itkLabelMapToRGBImageFilterTest2.cxx b/Modules/Filtering/ImageFusion/test/itkLabelMapToRGBImageFilterTest2.cxx index e173e9086f2..eb579e32c75 100644 --- a/Modules/Filtering/ImageFusion/test/itkLabelMapToRGBImageFilterTest2.cxx +++ b/Modules/Filtering/ImageFusion/test/itkLabelMapToRGBImageFilterTest2.cxx @@ -52,7 +52,7 @@ itkLabelMapToRGBImageFilterTest2(int argc, char * argv[]) auto colorizer = ColorizerType::New(); colorizer->SetInput(converter->GetOutput()); - itk::SimpleFilterWatcher watcher(colorizer, "filter"); + const itk::SimpleFilterWatcher watcher(colorizer, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageFusion/test/itkLabelOverlayImageFilterTest.cxx b/Modules/Filtering/ImageFusion/test/itkLabelOverlayImageFilterTest.cxx index da692c8f527..36ead6d28ae 100644 --- a/Modules/Filtering/ImageFusion/test/itkLabelOverlayImageFilterTest.cxx +++ b/Modules/Filtering/ImageFusion/test/itkLabelOverlayImageFilterTest.cxx @@ -87,7 +87,7 @@ itkLabelOverlayImageFilterTest(int argc, char * argv[]) // Set opacity filter->SetOpacity(std::stod(argv[3])); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); // Instantiate output image using WriterType = itk::ImageFileWriter; @@ -107,10 +107,10 @@ itkLabelOverlayImageFilterTest(int argc, char * argv[]) } // exercise the methods to change the colors - unsigned int numberOfColors1 = filter->GetNumberOfColors(); + const unsigned int numberOfColors1 = filter->GetNumberOfColors(); filter->AddColor(1, 255, 255); - unsigned int numberOfColors2 = filter->GetNumberOfColors(); + const unsigned int numberOfColors2 = filter->GetNumberOfColors(); if (numberOfColors2 != numberOfColors1 + 1) { @@ -121,7 +121,7 @@ itkLabelOverlayImageFilterTest(int argc, char * argv[]) filter->ResetColors(); filter->AddColor(255, 255, 255); - unsigned int numberOfColors3 = filter->GetNumberOfColors(); + const unsigned int numberOfColors3 = filter->GetNumberOfColors(); if (numberOfColors3 != 1) { diff --git a/Modules/Filtering/ImageFusion/test/itkLabelToRGBImageFilterTest.cxx b/Modules/Filtering/ImageFusion/test/itkLabelToRGBImageFilterTest.cxx index 5071fc2f37a..16c2db35bdf 100644 --- a/Modules/Filtering/ImageFusion/test/itkLabelToRGBImageFilterTest.cxx +++ b/Modules/Filtering/ImageFusion/test/itkLabelToRGBImageFilterTest.cxx @@ -60,7 +60,7 @@ itkLabelToRGBImageFilterTest(int argc, char * argv[]) filter->SetBackgroundValue(backgroundValue); ITK_TEST_SET_GET_VALUE(backgroundValue, filter->GetBackgroundValue()); - typename FilterType::OutputPixelType backgroundColor{}; + const typename FilterType::OutputPixelType backgroundColor{}; filter->SetBackgroundColor(backgroundColor); ITK_TEST_SET_GET_VALUE(backgroundColor, filter->GetBackgroundColor()); @@ -72,7 +72,7 @@ itkLabelToRGBImageFilterTest(int argc, char * argv[]) filter->SetBackgroundValue(backgroundValue); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); // Instantiate output image using WriterType = itk::ImageFileWriter; @@ -85,10 +85,10 @@ itkLabelToRGBImageFilterTest(int argc, char * argv[]) // exercise the methods to change the colors - unsigned int numberOfColors1 = filter->GetNumberOfColors(); + const unsigned int numberOfColors1 = filter->GetNumberOfColors(); filter->AddColor(1, 255, 255); - unsigned int numberOfColors2 = filter->GetNumberOfColors(); + const unsigned int numberOfColors2 = filter->GetNumberOfColors(); if (numberOfColors2 != numberOfColors1 + 1) { @@ -99,7 +99,7 @@ itkLabelToRGBImageFilterTest(int argc, char * argv[]) filter->ResetColors(); filter->AddColor(255, 255, 255); - unsigned int numberOfColors3 = filter->GetNumberOfColors(); + const unsigned int numberOfColors3 = filter->GetNumberOfColors(); if (numberOfColors3 != 1) { diff --git a/Modules/Filtering/ImageFusion/test/itkScalarToRGBPixelFunctorTest.cxx b/Modules/Filtering/ImageFusion/test/itkScalarToRGBPixelFunctorTest.cxx index 3bc78d2ec32..3d877296a7f 100644 --- a/Modules/Filtering/ImageFusion/test/itkScalarToRGBPixelFunctorTest.cxx +++ b/Modules/Filtering/ImageFusion/test/itkScalarToRGBPixelFunctorTest.cxx @@ -48,7 +48,7 @@ itkScalarToRGBPixelFunctorTest(int, char *[]) } // Test with unsigned char. - itk::Functor::ScalarToRGBPixelFunctor ucf; + const itk::Functor::ScalarToRGBPixelFunctor ucf; std::cout << "Testing unsigned char" << std::endl; for (char c = 0; c < 100; ++c) diff --git a/Modules/Filtering/ImageGradient/include/itkDifferenceOfGaussiansGradientImageFilter.hxx b/Modules/Filtering/ImageGradient/include/itkDifferenceOfGaussiansGradientImageFilter.hxx index ba0db676505..1964cab716a 100644 --- a/Modules/Filtering/ImageGradient/include/itkDifferenceOfGaussiansGradientImageFilter.hxx +++ b/Modules/Filtering/ImageGradient/include/itkDifferenceOfGaussiansGradientImageFilter.hxx @@ -39,14 +39,14 @@ DifferenceOfGaussiansGradientImageFilter::GenerateData() itkDebugMacro("DifferenceOfGaussiansGradientImageFilter::GenerateData() called"); // Get the input and output pointers - typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput(0)); - typename Superclass::OutputImagePointer outputPtr = this->GetOutput(0); + const typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput(0)); + const typename Superclass::OutputImagePointer outputPtr = this->GetOutput(0); // Make sure we're getting everything inputPtr->SetRequestedRegionToLargestPossibleRegion(); // How big is the input image? - typename TInputImage::SizeType size = inputPtr->GetLargestPossibleRegion().GetSize(); + const typename TInputImage::SizeType size = inputPtr->GetLargestPossibleRegion().GetSize(); // Create a region object native to the output image type OutputImageRegionType outputRegion; diff --git a/Modules/Filtering/ImageGradient/include/itkGradientImageFilter.hxx b/Modules/Filtering/ImageGradient/include/itkGradientImageFilter.hxx index a5a21e3d885..2dbca3e9b33 100644 --- a/Modules/Filtering/ImageGradient/include/itkGradientImageFilter.hxx +++ b/Modules/Filtering/ImageGradient/include/itkGradientImageFilter.hxx @@ -53,8 +53,8 @@ GradientImageFilter(this->GetInput()); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImagePointer inputPtr = const_cast(this->GetInput()); + const OutputImagePointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -98,7 +98,7 @@ GradientImageFilter SIP; + const NeighborhoodInnerProduct SIP; OutputImageType * outputImage = this->GetOutput(); const InputImageType * inputImage = this->GetInput(); diff --git a/Modules/Filtering/ImageGradient/include/itkGradientMagnitudeImageFilter.hxx b/Modules/Filtering/ImageGradient/include/itkGradientMagnitudeImageFilter.hxx index 974ad50a543..a20f4bf909c 100644 --- a/Modules/Filtering/ImageGradient/include/itkGradientMagnitudeImageFilter.hxx +++ b/Modules/Filtering/ImageGradient/include/itkGradientMagnitudeImageFilter.hxx @@ -54,8 +54,8 @@ GradientMagnitudeImageFilter::GenerateInputRequestedR Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - InputImagePointer inputPtr = const_cast(this->GetInput()); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImagePointer inputPtr = const_cast(this->GetInput()); + const OutputImagePointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -106,10 +106,10 @@ GradientMagnitudeImageFilter::DynamicThreadedGenerate ConstNeighborhoodIterator bit; ImageRegionIterator it; - NeighborhoodInnerProduct SIP; + const NeighborhoodInnerProduct SIP; - typename OutputImageType::Pointer output = this->GetOutput(); - typename InputImageType::ConstPointer input = this->GetInput(); + const typename OutputImageType::Pointer output = this->GetOutput(); + const typename InputImageType::ConstPointer input = this->GetInput(); // Set up operators DerivativeOperator op[ImageDimension]; diff --git a/Modules/Filtering/ImageGradient/include/itkGradientMagnitudeRecursiveGaussianImageFilter.hxx b/Modules/Filtering/ImageGradient/include/itkGradientMagnitudeRecursiveGaussianImageFilter.hxx index f9101f023f4..ea9b43b7f10 100644 --- a/Modules/Filtering/ImageGradient/include/itkGradientMagnitudeRecursiveGaussianImageFilter.hxx +++ b/Modules/Filtering/ImageGradient/include/itkGradientMagnitudeRecursiveGaussianImageFilter.hxx @@ -149,7 +149,7 @@ GradientMagnitudeRecursiveGaussianImageFilter::Genera Superclass::GenerateInputRequestedRegion(); // This filter needs all of the input - typename GradientMagnitudeRecursiveGaussianImageFilter::InputImagePointer image = + const typename GradientMagnitudeRecursiveGaussianImageFilter::InputImagePointer image = const_cast(this->GetInput()); if (image) { @@ -178,7 +178,7 @@ GradientMagnitudeRecursiveGaussianImageFilter::Genera const typename TInputImage::ConstPointer inputImage(this->GetInput()); - typename TOutputImage::Pointer outputImage(this->GetOutput()); + const typename TOutputImage::Pointer outputImage(this->GetOutput()); // Reset progress of internal filters to zero, // otherwise progress starts from non-zero value the second time the filter is invoked. diff --git a/Modules/Filtering/ImageGradient/include/itkGradientRecursiveGaussianImageFilter.hxx b/Modules/Filtering/ImageGradient/include/itkGradientRecursiveGaussianImageFilter.hxx index 1f2e57fc22f..2c5fa78464c 100644 --- a/Modules/Filtering/ImageGradient/include/itkGradientRecursiveGaussianImageFilter.hxx +++ b/Modules/Filtering/ImageGradient/include/itkGradientRecursiveGaussianImageFilter.hxx @@ -77,7 +77,7 @@ template void GradientRecursiveGaussianImageFilter::SetSigma(ScalarRealType sigma) { - SigmaArrayType sigmas(sigma); + const SigmaArrayType sigmas(sigma); this->SetSigmaArray(sigmas); } @@ -140,7 +140,7 @@ GradientRecursiveGaussianImageFilter::GenerateInputRe Superclass::GenerateInputRequestedRegion(); // This filter needs all of the input - typename GradientRecursiveGaussianImageFilter::InputImagePointer image = + const typename GradientRecursiveGaussianImageFilter::InputImagePointer image = const_cast(this->GetInput()); if (image) { @@ -185,7 +185,7 @@ GradientRecursiveGaussianImageFilter::GenerateData() progress->RegisterInternalFilter(m_DerivativeFilter, weight); const typename TInputImage::ConstPointer inputImage(this->GetInput()); - typename TOutputImage::Pointer outputImage(this->GetOutput()); + const typename TOutputImage::Pointer outputImage(this->GetOutput()); unsigned int nComponents = inputImage->GetNumberOfComponentsPerPixel(); /* An Image of VariableLengthVectors will return 0 */ @@ -208,7 +208,8 @@ GradientRecursiveGaussianImageFilter::GenerateData() m_DerivativeFilter->SetInput(inputImage); // For variable length output pixel types - ImageRegionIteratorWithIndex initGradIt(outputImage, this->m_ImageAdaptor->GetRequestedRegion()); + const ImageRegionIteratorWithIndex initGradIt(outputImage, + this->m_ImageAdaptor->GetRequestedRegion()); for (unsigned int nc = 0; nc < nComponents; ++nc) @@ -230,7 +231,6 @@ GradientRecursiveGaussianImageFilter::GenerateData() m_DerivativeFilter->SetDirection(dim); GaussianFilterPointer lastFilter; - if constexpr (ImageDimension > 1) { const auto imageDimensionMinus2 = static_cast(ImageDimension - 2); @@ -278,7 +278,7 @@ GradientRecursiveGaussianImageFilter::GenerateData() // manually release memory in last filter in the mini-pipeline if constexpr (ImageDimension > 1) { - int temp_dim = static_cast(ImageDimension) - 2; + const int temp_dim = static_cast(ImageDimension) - 2; m_SmoothingFilters[temp_dim]->GetOutput()->ReleaseData(); } else diff --git a/Modules/Filtering/ImageGradient/include/itkVectorGradientMagnitudeImageFilter.h b/Modules/Filtering/ImageGradient/include/itkVectorGradientMagnitudeImageFilter.h index d0661714aef..bc4e6c7f594 100644 --- a/Modules/Filtering/ImageGradient/include/itkVectorGradientMagnitudeImageFilter.h +++ b/Modules/Filtering/ImageGradient/include/itkVectorGradientMagnitudeImageFilter.h @@ -380,7 +380,7 @@ class ITK_TEMPLATE_EXPORT VectorGradientMagnitudeImageFilter : public ImageToIma g[2][0] * (g[1][1] * g[0][2] - g[0][1] * g[1][2]); // Find the eigenvalues of g - int numberOfDistinctRoots = this->CubicSolver(CharEqn, Lambda); + const int numberOfDistinctRoots = this->CubicSolver(CharEqn, Lambda); // Define gradient magnitude as the difference between two largest // eigenvalues. Other definitions may be appropriate here as well. @@ -480,7 +480,7 @@ class ITK_TEMPLATE_EXPORT VectorGradientMagnitudeImageFilter : public ImageToIma } // Find the eigenvalues of g - vnl_symmetric_eigensystem E(g); + const vnl_symmetric_eigensystem E(g); // Return the difference in length between the first two principle axes. // Note that other edge strength metrics may be appropriate here instead.. diff --git a/Modules/Filtering/ImageGradient/include/itkVectorGradientMagnitudeImageFilter.hxx b/Modules/Filtering/ImageGradient/include/itkVectorGradientMagnitudeImageFilter.hxx index 18ef39d8049..f6c021b74ad 100644 --- a/Modules/Filtering/ImageGradient/include/itkVectorGradientMagnitudeImageFilter.hxx +++ b/Modules/Filtering/ImageGradient/include/itkVectorGradientMagnitudeImageFilter.hxx @@ -89,8 +89,8 @@ VectorGradientMagnitudeImageFilter::Genera Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - InputImagePointer inputPtr = const_cast(this->GetInput()); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImagePointer inputPtr = const_cast(this->GetInput()); + const OutputImagePointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -195,7 +195,7 @@ VectorGradientMagnitudeImageFilter::Dynami // Find the data-set boundary "faces" NeighborhoodAlgorithm::ImageBoundaryFacesCalculator bC; auto r1 = MakeFilled(1); - typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = + const typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = bC(m_RealValuedInputImage.GetPointer(), outputRegionForThread, r1); TotalProgressReporter progress(this, this->GetOutput()->GetRequestedRegion().GetNumberOfPixels()); @@ -261,18 +261,18 @@ VectorGradientMagnitudeImageFilter::CubicS const double epsilon = 1.0e-11; // Substitution of x = y - c[2]/3 eliminate the quadric term x^3 +px + q = 0 - double sq_c2 = c[2] * c[2]; - double p = 1.0 / 3 * (-1.0 / 3.0 * sq_c2 + c[1]); - double q = 1.0 / 2 * (2.0 / 27.0 * c[2] * sq_c2 - 1.0 / 3.0 * c[2] * c[1] + c[0]); + const double sq_c2 = c[2] * c[2]; + const double p = 1.0 / 3 * (-1.0 / 3.0 * sq_c2 + c[1]); + const double q = 1.0 / 2 * (2.0 / 27.0 * c[2] * sq_c2 - 1.0 / 3.0 * c[2] * c[1] + c[0]); // Cardano's formula - double cb_p = p * p * p; - double D = q * q + cb_p; + const double cb_p = p * p * p; + const double D = q * q + cb_p; if (D < -epsilon) // D < 0, three real solutions, by far the common case. { - double phi = 1.0 / 3.0 * std::acos(-q / std::sqrt(-cb_p)); - double t = 2.0 * std::sqrt(-p); + const double phi = 1.0 / 3.0 * std::acos(-q / std::sqrt(-cb_p)); + const double t = 2.0 * std::sqrt(-p); s[0] = t * std::cos(phi); s[1] = -t * std::cos(phi + dpi / 3); @@ -289,7 +289,7 @@ VectorGradientMagnitudeImageFilter::CubicS } else { - double u = itk::Math::cbrt(-q); + const double u = itk::Math::cbrt(-q); s[0] = 2 * u; s[1] = -u; num = 2; @@ -298,16 +298,16 @@ VectorGradientMagnitudeImageFilter::CubicS else // Only one real solution. This case misses a double root on rare // occasions with very large char eqn coefficients. { - double sqrt_D = std::sqrt(D); - double u = itk::Math::cbrt(sqrt_D - q); - double v = -itk::Math::cbrt(sqrt_D + q); + const double sqrt_D = std::sqrt(D); + const double u = itk::Math::cbrt(sqrt_D - q); + const double v = -itk::Math::cbrt(sqrt_D + q); s[0] = u + v; num = 1; } // Resubstitute - double sub = 1.0 / 3.0 * c[2]; + const double sub = 1.0 / 3.0 * c[2]; for (int i = 0; i < num; ++i) { diff --git a/Modules/Filtering/ImageGradient/test/itkDifferenceOfGaussiansGradientTest.cxx b/Modules/Filtering/ImageGradient/test/itkDifferenceOfGaussiansGradientTest.cxx index f14cf8e98af..b25ae294b51 100644 --- a/Modules/Filtering/ImageGradient/test/itkDifferenceOfGaussiansGradientTest.cxx +++ b/Modules/Filtering/ImageGradient/test/itkDifferenceOfGaussiansGradientTest.cxx @@ -138,7 +138,7 @@ itkDifferenceOfGaussiansGradientTest(int, char *[]) binfilter->SetRepetitions(4); // Set up the output of the filter - TImageType::Pointer blurredImage = binfilter->GetOutput(); + const TImageType::Pointer blurredImage = binfilter->GetOutput(); // Execute the filter binfilter->Update(); @@ -148,19 +148,19 @@ itkDifferenceOfGaussiansGradientTest(int, char *[]) // Create a differennce of gaussians gradient filter using TDOGFilterType = itk::DifferenceOfGaussiansGradientImageFilter; - auto DOGFilter = TDOGFilterType::New(); - itk::SimpleFilterWatcher watcher(DOGFilter); + auto DOGFilter = TDOGFilterType::New(); + const itk::SimpleFilterWatcher watcher(DOGFilter); // We're filtering the output of the binomial filter DOGFilter->SetInput(blurredImage); // Test the get/set macro for width DOGFilter->SetWidth(4); - unsigned int theWidth = DOGFilter->GetWidth(); + const unsigned int theWidth = DOGFilter->GetWidth(); std::cout << "DOGFilter->GetWidth(): " << theWidth << std::endl; // Get the output of the gradient filter - TDOGFilterType::TOutputImage::Pointer gradientImage = DOGFilter->GetOutput(); + const TDOGFilterType::TOutputImage::Pointer gradientImage = DOGFilter->GetOutput(); // Go! DOGFilter->Update(); diff --git a/Modules/Filtering/ImageGradient/test/itkGradientImageFilterTest2.cxx b/Modules/Filtering/ImageGradient/test/itkGradientImageFilterTest2.cxx index 47b959e15fc..1aff6e9d45b 100644 --- a/Modules/Filtering/ImageGradient/test/itkGradientImageFilterTest2.cxx +++ b/Modules/Filtering/ImageGradient/test/itkGradientImageFilterTest2.cxx @@ -109,7 +109,7 @@ itkGradientImageFilterTest2(int argc, char * argv[]) const std::string infname = argv[1]; const std::string outfname = argv[2]; - itk::ImageIOBase::Pointer iobase = + const itk::ImageIOBase::Pointer iobase = itk::ImageIOFactory::CreateImageIO(infname.c_str(), itk::ImageIOFactory::IOFileModeEnum::ReadMode); if (iobase.IsNull()) diff --git a/Modules/Filtering/ImageGradient/test/itkGradientMagnitudeImageFilterTest.cxx b/Modules/Filtering/ImageGradient/test/itkGradientMagnitudeImageFilterTest.cxx index 2ac14c30a2b..a6b76cde07d 100644 --- a/Modules/Filtering/ImageGradient/test/itkGradientMagnitudeImageFilterTest.cxx +++ b/Modules/Filtering/ImageGradient/test/itkGradientMagnitudeImageFilterTest.cxx @@ -46,7 +46,7 @@ itkGradientMagnitudeImageFilterTest(int argc, char * argv[]) using ImageType = itk::Image; // Set up filter - itk::GradientMagnitudeImageFilter::Pointer filter = + const itk::GradientMagnitudeImageFilter::Pointer filter = itk::GradientMagnitudeImageFilter::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, GradientMagnitudeImageFilter, ImageToImageFilter); diff --git a/Modules/Filtering/ImageGradient/test/itkGradientMagnitudeRecursiveGaussianFilterTest.cxx b/Modules/Filtering/ImageGradient/test/itkGradientMagnitudeRecursiveGaussianFilterTest.cxx index c63fdc19503..08df64b47e5 100644 --- a/Modules/Filtering/ImageGradient/test/itkGradientMagnitudeRecursiveGaussianFilterTest.cxx +++ b/Modules/Filtering/ImageGradient/test/itkGradientMagnitudeRecursiveGaussianFilterTest.cxx @@ -115,7 +115,7 @@ itkGradientMagnitudeRecursiveGaussianFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, GradientMagnitudeRecursiveGaussianImageFilter, InPlaceImageFilter); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); auto sigma = static_cast(std::stod(argv[1])); filter->SetSigma(sigma); @@ -134,7 +134,7 @@ itkGradientMagnitudeRecursiveGaussianFilterTest(int argc, char * argv[]) // It is important to do it AFTER the filter is Updated // Because the object connected to the output may be changed // by another during GenerateData() call - myGradientImageType::Pointer outputImage = filter->GetOutput(); + const myGradientImageType::Pointer outputImage = filter->GetOutput(); #ifndef NDEBUG using myOutputIteratorType = itk::ImageRegionIteratorWithIndex; diff --git a/Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterSpeedTest.cxx b/Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterSpeedTest.cxx index 76f4464a409..829dad9d280 100644 --- a/Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterSpeedTest.cxx +++ b/Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterSpeedTest.cxx @@ -29,8 +29,8 @@ itkGradientRecursiveGaussianFilterSpeedTest(int argc, char * argv[]) return EXIT_FAILURE; } - int imageSize = std::stoi(argv[1]); - int reps = std::stoi(argv[2]); + const int imageSize = std::stoi(argv[1]); + const int reps = std::stoi(argv[2]); std::cout << "imageSize: " << imageSize << " reps: " << reps << std::endl; @@ -61,7 +61,7 @@ itkGradientRecursiveGaussianFilterSpeedTest(int argc, char * argv[]) myIndexType start{}; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; // Initialize Image A inputImage->SetRegions(region); @@ -87,8 +87,8 @@ itkGradientRecursiveGaussianFilterSpeedTest(int argc, char * argv[]) start[2] = 2; // Create one iterator for an internal region - myRegionType innerRegion{ start, size }; - myIteratorType itb(inputImage, innerRegion); + const myRegionType innerRegion{ start, size }; + myIteratorType itb(inputImage, innerRegion); // Initialize the content the internal region while (!itb.IsAtEnd()) @@ -127,7 +127,7 @@ itkGradientRecursiveGaussianFilterSpeedTest(int argc, char * argv[]) // It is important to do it AFTER the filter is Updated // Because the object connected to the output may be changed // by another during GenerateData() call - myGradientImageType::Pointer outputImage = filter->GetOutput(); + const myGradientImageType::Pointer outputImage = filter->GetOutput(); // Declare Iterator type for the output image using myOutputIteratorType = itk::ImageRegionIteratorWithIndex; diff --git a/Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterTest.cxx b/Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterTest.cxx index f0ca259ae76..cdda5cc4ea0 100644 --- a/Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterTest.cxx +++ b/Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterTest.cxx @@ -58,7 +58,7 @@ itkGradientRecursiveGaussianFilterTest(int argc, char * argv[]) myIndexType start{}; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; // Initialize Image A inputImage->SetRegions(region); @@ -86,8 +86,8 @@ itkGradientRecursiveGaussianFilterTest(int argc, char * argv[]) start[2] = 2; // Create one iterator for an internal region - myRegionType innerRegion{ start, size }; - myIteratorType itb(inputImage, innerRegion); + const myRegionType innerRegion{ start, size }; + myIteratorType itb(inputImage, innerRegion); // Initialize the content the internal region while (!itb.IsAtEnd()) @@ -108,7 +108,7 @@ itkGradientRecursiveGaussianFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, GradientRecursiveGaussianImageFilter, ImageToImageFilter); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); auto normalizeAcrossScale = static_cast(std::stoi(argv[1])); filter->SetNormalizeAcrossScale(normalizeAcrossScale); @@ -118,7 +118,7 @@ itkGradientRecursiveGaussianFilterTest(int argc, char * argv[]) ITK_TEST_SET_GET_BOOLEAN(filter, UseImageDirection, useImageDirection); // Select the value of Sigma - typename myFilterType::ScalarRealType sigma = 2.5; + const typename myFilterType::ScalarRealType sigma = 2.5; filter->SetSigma(sigma); ITK_TEST_SET_GET_VALUE(sigma, filter->GetSigma()); @@ -132,7 +132,7 @@ itkGradientRecursiveGaussianFilterTest(int argc, char * argv[]) // It is important to do it AFTER the filter is Updated // Because the object connected to the output may be changed // by another during GenerateData() call - myGradientImageType::Pointer outputImage = filter->GetOutput(); + const myGradientImageType::Pointer outputImage = filter->GetOutput(); // Declare Iterator type for the output image using myOutputIteratorType = itk::ImageRegionIteratorWithIndex; @@ -164,7 +164,7 @@ itkGradientRecursiveGaussianFilterTest(int argc, char * argv[]) filter2->SetInput(inputImage); filter2->SetSigma(2.5); filter2->Update(); - myGradientImageType::Pointer outputFlippedImage = filter2->GetOutput(); + const myGradientImageType::Pointer outputFlippedImage = filter2->GetOutput(); // compare the output between identity direction and flipped direction std::cout << " Result of flipped image " << std::endl; diff --git a/Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterTest2.cxx b/Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterTest2.cxx index 9c79d720e22..43a090c4967 100644 --- a/Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterTest2.cxx +++ b/Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterTest2.cxx @@ -110,13 +110,13 @@ itkGradientRecursiveGaussianFilterTest2(int, char *[]) // It is important to do it AFTER the filter is Updated // Because the object connected to the output may be changed // by another during GenerateData() call - myGradientImageType::Pointer outputImage = filter->GetOutput(); + const myGradientImageType::Pointer outputImage = filter->GetOutput(); // Declare Iterator type for the output image using myOutputIteratorType = itk::ImageRegionIteratorWithIndex; // Create an iterator for going through the output image - myOutputIteratorType itg(outputImage, outputImage->GetRequestedRegion()); + const myOutputIteratorType itg(outputImage, outputImage->GetRequestedRegion()); // All objects should be automatically destroyed at this point return EXIT_SUCCESS; diff --git a/Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterTest3.cxx b/Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterTest3.cxx index 530a145097d..0cad4a82a0c 100644 --- a/Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterTest3.cxx +++ b/Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterTest3.cxx @@ -152,7 +152,7 @@ itkGradientRecursiveGaussianFilterTest3Compare(typename TGradImage1DType::Pointe vectorPixelGradImage->GetBufferedRegion()); scalarIt.GoToBegin(); vector2DIt.GoToBegin(); - typename TGradImage1DType::PixelType::ValueType tolerance = 1e-5; + const typename TGradImage1DType::PixelType::ValueType tolerance = 1e-5; while (!scalarIt.IsAtEnd() && !vector2DIt.IsAtEnd()) { @@ -162,8 +162,8 @@ itkGradientRecursiveGaussianFilterTest3Compare(typename TGradImage1DType::Pointe { for (unsigned int c = 0; c < vector.GetNumberOfComponents() / numDimensions; ++c) { - typename TGradImage1DType::PixelType::ValueType truth = scalar[d] / (c + 1.0); - typename TGradImage1DType::PixelType::ValueType test = vector[d + (c * numDimensions)]; + const typename TGradImage1DType::PixelType::ValueType truth = scalar[d] / (c + 1.0); + const typename TGradImage1DType::PixelType::ValueType test = vector[d + (c * numDimensions)]; if (itk::Math::abs(truth - test) > tolerance) { std::cerr << "One or more components of vector gradient image pixel are not as expected: " << std::endl diff --git a/Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterTest4.cxx b/Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterTest4.cxx index 50c740b4987..fabf8a392b9 100644 --- a/Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterTest4.cxx +++ b/Modules/Filtering/ImageGradient/test/itkGradientRecursiveGaussianFilterTest4.cxx @@ -33,9 +33,9 @@ itkGradientRecursiveGaussianFilterTest4(int argc, char * argv[]) return EXIT_FAILURE; } - std::string inFileName = argv[1]; + const std::string inFileName = argv[1]; - std::string outFileName = argv[2]; + const std::string outFileName = argv[2]; // Define the dimension of the images constexpr unsigned int myDimension = 2; diff --git a/Modules/Filtering/ImageGrid/include/itkBSplineCenteredResampleImageFilterBase.hxx b/Modules/Filtering/ImageGrid/include/itkBSplineCenteredResampleImageFilterBase.hxx index 88f016e7677..1c7fc8b0336 100644 --- a/Modules/Filtering/ImageGrid/include/itkBSplineCenteredResampleImageFilterBase.hxx +++ b/Modules/Filtering/ImageGrid/include/itkBSplineCenteredResampleImageFilterBase.hxx @@ -229,10 +229,10 @@ BSplineCenteredResampleImageFilterBase::Reduce1DImage unsigned int inTraverseSize, ProgressReporter & progress) { - SizeValueType outTraverseSize = inTraverseSize / 2; + const SizeValueType outTraverseSize = inTraverseSize / 2; - inTraverseSize = outTraverseSize * 2; // ensures that an even number is used. - SizeValueType inModK = 2L * inTraverseSize; // number for modulus math of in + inTraverseSize = outTraverseSize * 2; // ensures that an even number is used. + const SizeValueType inModK = 2L * inTraverseSize; // number for modulus math of in // TODO: Need to allocate this once as a scratch variable instead of each // time through. @@ -272,8 +272,8 @@ BSplineCenteredResampleImageFilterBase::Reduce1DImage for (SizeValueType outK = 0; outK < outTraverseSize; ++outK) { - IndexValueType i1 = 2 * outK; - double outVal = (temp[i1] + temp[i1 + 1]) / 2.0; + const IndexValueType i1 = 2 * outK; + const double outVal = (temp[i1] + temp[i1 + 1]) / 2.0; out.Set(static_cast(outVal)); ++out; progress.CompletedPixel(); @@ -294,13 +294,13 @@ BSplineCenteredResampleImageFilterBase::Expand1DImage IndexValueType i1; IndexValueType i2; - IndexValueType inK; - SizeValueType outTraverseSize = inTraverseSize * 2; + IndexValueType inK; + const SizeValueType outTraverseSize = inTraverseSize * 2; // inTraverseSize = outTraverseSize/2; // ensures that an even number is used. IndexValueType inModK; // number for modulus math of in inModK = outTraverseSize; - IndexValueType k0 = (this->m_HSize / 2) * 2 - 1L; + const IndexValueType k0 = (this->m_HSize / 2) * 2 - 1L; double outVal; double outVal2; @@ -339,7 +339,7 @@ BSplineCenteredResampleImageFilterBase::Expand1DImage outVal2 = 0; for (IndexValueType k = -k0; k < this->m_HSize; k += 2L) { - IndexValueType kk = itk::Math::abs(static_cast(k)); + const IndexValueType kk = itk::Math::abs(static_cast(k)); i1 = inK + (k + 1L) / 2L; if (i1 < 0L) { diff --git a/Modules/Filtering/ImageGrid/include/itkBSplineControlPointImageFilter.hxx b/Modules/Filtering/ImageGrid/include/itkBSplineControlPointImageFilter.hxx index bf0d58c296d..e297199dd8c 100644 --- a/Modules/Filtering/ImageGrid/include/itkBSplineControlPointImageFilter.hxx +++ b/Modules/Filtering/ImageGrid/include/itkBSplineControlPointImageFilter.hxx @@ -129,7 +129,7 @@ BSplineControlPointImageFilter::SetSplineOrder(ArrayT } for (unsigned int j = 0; j < C.cols(); ++j) { - RealType c = std::pow(static_cast(2.0), static_cast(C.cols() - j - 1)); + const RealType c = std::pow(static_cast(2.0), static_cast(C.cols() - j - 1)); for (unsigned int k = 0; k < C.rows(); ++k) { R(k, j) *= c; @@ -216,14 +216,14 @@ BSplineControlPointImageFilter::DynamicThreadedGenera FixedArray U; auto currentU = MakeFilled>(-1); - typename OutputImageType::IndexType startIndex = outputPtr->GetRequestedRegion().GetIndex(); - typename PointDataImageType::IndexType startPhiIndex = inputPtr->GetLargestPossibleRegion().GetIndex(); + typename OutputImageType::IndexType startIndex = outputPtr->GetRequestedRegion().GetIndex(); + const typename PointDataImageType::IndexType startPhiIndex = inputPtr->GetLargestPossibleRegion().GetIndex(); RealArrayType epsilon; for (unsigned int i = 0; i < ImageDimension; ++i) { - RealType r = static_cast(this->m_NumberOfControlPoints[i] - this->m_SplineOrder[i]) / - (static_cast(this->m_Size[i] - 1) * this->m_Spacing[i]); + const RealType r = static_cast(this->m_NumberOfControlPoints[i] - this->m_SplineOrder[i]) / + (static_cast(this->m_Size[i] - 1) * this->m_Spacing[i]); epsilon[i] = r * this->m_Spacing[i] * this->m_BSplineEpsilon; } @@ -283,7 +283,7 @@ BSplineControlPointImageFilter::CollapsePhiLattice(Po for (unsigned int i = 0; i < this->m_SplineOrder[dimension] + 1; ++i) { idx[dimension] = static_cast(u) + i; - RealType v = u - idx[dimension] + 0.5 * static_cast(this->m_SplineOrder[dimension] - 1); + const RealType v = u - idx[dimension] + 0.5 * static_cast(this->m_SplineOrder[dimension] - 1); RealType B = 0.0; switch (this->m_SplineOrder[dimension]) @@ -348,7 +348,7 @@ BSplineControlPointImageFilter::SplitRequestedRegion( splitAxis = outputPtr->GetImageDimension() - 1; // determine the actual number of pieces that will be generated - typename SizeType::SizeValueType range = requestedRegionSize[splitAxis]; + const typename SizeType::SizeValueType range = requestedRegionSize[splitAxis]; auto valuesPerThread = static_cast(std::ceil(range / static_cast(num))); auto maxThreadIdUsed = static_cast(std::ceil(range / static_cast(valuesPerThread)) - 1); @@ -419,7 +419,7 @@ BSplineControlPointImageFilter::RefineControlPoi auto refinedLattice = ControlPointLatticeType::New(); refinedLattice->SetRegions(size); refinedLattice->Allocate(); - PixelType data{}; + const PixelType data{}; refinedLattice->FillBuffer(data); typename ControlPointLatticeType::IndexType idx; @@ -547,7 +547,7 @@ BSplineControlPointImageFilter::RefineControlPoi for (unsigned int i = 0; i < ImageDimension; ++i) { - RealType domain = this->m_Spacing[i] * static_cast(this->m_Size[i] - 1); + const RealType domain = this->m_Spacing[i] * static_cast(this->m_Size[i] - 1); unsigned int totalNumberOfSpans = psiLattice->GetLargestPossibleRegion().GetSize()[i]; if (!this->m_CloseDimension[i]) diff --git a/Modules/Filtering/ImageGrid/include/itkBSplineControlPointImageFunction.hxx b/Modules/Filtering/ImageGrid/include/itkBSplineControlPointImageFunction.hxx index 665553f5b8e..2d6a03b4fb5 100644 --- a/Modules/Filtering/ImageGrid/include/itkBSplineControlPointImageFunction.hxx +++ b/Modules/Filtering/ImageGrid/include/itkBSplineControlPointImageFunction.hxx @@ -96,7 +96,7 @@ BSplineControlPointImageFunction::SetInputImage(const unsigned int maximumNumberOfSpans = 0; for (unsigned int d = 0; d < ImageDimension; ++d) { - unsigned int numberOfSpans = this->m_NumberOfControlPoints[d] - this->m_SplineOrder[d]; + const unsigned int numberOfSpans = this->m_NumberOfControlPoints[d] - this->m_SplineOrder[d]; if (numberOfSpans > maximumNumberOfSpans) { maximumNumberOfSpans = numberOfSpans; @@ -200,8 +200,8 @@ BSplineControlPointImageFunction::Evaluate(const Point { for (unsigned int j = 0; j < bsplineWeights[i].size(); ++j) { - CoordinateType u = p[i] - static_cast(static_cast(p[i]) + j) + - 0.5 * static_cast(this->m_SplineOrder[i] - 1); + const CoordinateType u = p[i] - static_cast(static_cast(p[i]) + j) + + 0.5 * static_cast(this->m_SplineOrder[i] - 1); CoordinateType B = 1.0; switch (this->m_SplineOrder[i]) @@ -358,8 +358,8 @@ BSplineControlPointImageFunction::EvaluateGradient(con { for (unsigned int j = 0; j < bsplineWeights[i].size(); ++j) { - CoordinateType u = p[i] - static_cast(static_cast(p[i]) + j) + - 0.5 * static_cast(this->m_SplineOrder[i] - 1); + const CoordinateType u = p[i] - static_cast(static_cast(p[i]) + j) + + 0.5 * static_cast(this->m_SplineOrder[i] - 1); CoordinateType B = 1.0; if (i == k) @@ -530,8 +530,8 @@ BSplineControlPointImageFunction::EvaluateHessian(cons { for (unsigned int h = 0; h < bsplineWeights[i].size(); ++h) { - CoordinateType u = p[i] - static_cast(static_cast(p[i]) + h) + - 0.5 * static_cast(this->m_SplineOrder[i] - 1); + const CoordinateType u = p[i] - static_cast(static_cast(p[i]) + h) + + 0.5 * static_cast(this->m_SplineOrder[i] - 1); CoordinateType B = 1.0; if (i == j && j == k) diff --git a/Modules/Filtering/ImageGrid/include/itkBSplineDownsampleImageFilter.hxx b/Modules/Filtering/ImageGrid/include/itkBSplineDownsampleImageFilter.hxx index c6852beb8d1..90062b6d188 100644 --- a/Modules/Filtering/ImageGrid/include/itkBSplineDownsampleImageFilter.hxx +++ b/Modules/Filtering/ImageGrid/include/itkBSplineDownsampleImageFilter.hxx @@ -37,8 +37,8 @@ BSplineDownsampleImageFilter::Generate itkDebugMacro("Actually executing"); // Get the input and output pointers - InputImagePointer inputPtr = const_cast(this->GetInput()); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImagePointer inputPtr = const_cast(this->GetInput()); + const OutputImagePointer outputPtr = this->GetOutput(); // Since we are providing a GenerateData() method, we need to allocate the // output buffer memory (if we provided a ThreadedGenerateData(), then @@ -65,8 +65,8 @@ BSplineDownsampleImageFilter::Generate Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - InputImagePointer inputPtr = const_cast(this->GetInput()); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImagePointer inputPtr = const_cast(this->GetInput()); + const OutputImagePointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -105,9 +105,9 @@ BSplineDownsampleImageFilter::Generate Superclass::GenerateOutputInformation(); // get pointers to the input and output - InputImagePointer inputPtr = const_cast(this->GetInput()); + const InputImagePointer inputPtr = const_cast(this->GetInput()); // typeInputImageConstPointer inputPtr = this->GetInput(); - OutputImagePointer outputPtr = this->GetOutput(); + const OutputImagePointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { diff --git a/Modules/Filtering/ImageGrid/include/itkBSplineResampleImageFilterBase.hxx b/Modules/Filtering/ImageGrid/include/itkBSplineResampleImageFilterBase.hxx index 92a6f283672..2d99cdebad7 100644 --- a/Modules/Filtering/ImageGrid/include/itkBSplineResampleImageFilterBase.hxx +++ b/Modules/Filtering/ImageGrid/include/itkBSplineResampleImageFilterBase.hxx @@ -191,18 +191,18 @@ BSplineResampleImageFilterBase::Reduce1DImage(const s unsigned int inTraverseSize, ProgressReporter & progress) { - unsigned int outTraverseSize = inTraverseSize / 2; + const unsigned int outTraverseSize = inTraverseSize / 2; - inTraverseSize = outTraverseSize * 2; // ensures that an even number is used. - unsigned int inModK = inTraverseSize - 1; // number for modulus math of in + inTraverseSize = outTraverseSize * 2; // ensures that an even number is used. + const unsigned int inModK = inTraverseSize - 1; // number for modulus math of in // TODO: m_GSize < 2 has not been tested. if (m_GSize < 2) { for (unsigned int outK = 0; outK < outTraverseSize; ++outK) { - unsigned int inK = 2 * outK; - int i2 = inK + 1; + const unsigned int inK = 2 * outK; + int i2 = inK + 1; if (i2 > static_cast(inModK)) { // Original was @@ -221,7 +221,7 @@ BSplineResampleImageFilterBase::Reduce1DImage(const s { for (unsigned int outK = 0; outK < outTraverseSize; ++outK) { - unsigned int inK = 2L * outK; + const unsigned int inK = 2L * outK; double outVal = in[inK] * m_G[0]; @@ -264,9 +264,9 @@ BSplineResampleImageFilterBase::Expand1DImage(const s unsigned int inTraverseSize, ProgressReporter & progress) { - unsigned int outTraverseSize = inTraverseSize * 2; + const unsigned int outTraverseSize = inTraverseSize * 2; // inTraverseSize = outTraverseSize/2; // ensures that an even number is used. - int inModK = inTraverseSize - 1; // number for modulus math of in + const int inModK = inTraverseSize - 1; // number for modulus math of in // TODO: m_GSize < 2 has not been tested. if (m_HSize < 2) @@ -324,8 +324,8 @@ void BSplineResampleImageFilterBase::ReduceNDImage(OutputImageIterator & outItr) { // Does not support streaming - typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); - SizeType startSize = inputPtr->GetBufferedRegion().GetSize(); + const typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); + SizeType startSize = inputPtr->GetBufferedRegion().GetSize(); // Initialize scratchImage space and allocate memory InitializeScratch(startSize); @@ -359,10 +359,10 @@ BSplineResampleImageFilterBase::ReduceNDImage(OutputI * OutputImage for direct writing into the final variable. */ // The first time through the loop our input image is inputPtr - typename TInputImage::ConstPointer workingImage = inputPtr; + const typename TInputImage::ConstPointer workingImage = inputPtr; - unsigned int count = scratchRegion.GetNumberOfPixels() * ImageDimension; - ProgressReporter progress(this, 0, count, 10); + const unsigned int count = scratchRegion.GetNumberOfPixels() * ImageDimension; + ProgressReporter progress(this, 0, count, 10); for (unsigned int n = 0; n < ImageDimension; ++n) { // Setup iterators for input image. @@ -433,8 +433,8 @@ BSplineResampleImageFilterBase::ExpandNDImage(OutputI { // Set up variables for waking the image regions. // Does not support streaming - typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); - SizeType startSize = inputPtr->GetBufferedRegion().GetSize(); + const typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); + SizeType startSize = inputPtr->GetBufferedRegion().GetSize(); // Initialize scratchImage space and allocate memory InitializeScratch(startSize); @@ -469,12 +469,12 @@ BSplineResampleImageFilterBase::ExpandNDImage(OutputI **/ // The first time through the loop our input image is m_Image - typename TInputImage::ConstPointer workingImage = inputPtr; + const typename TInputImage::ConstPointer workingImage = inputPtr; - RegionType workingRegion = validRegion; + const RegionType workingRegion = validRegion; - unsigned int count = scratchRegion.GetNumberOfPixels() * ImageDimension; - ProgressReporter progress(this, 0, count, 10); + const unsigned int count = scratchRegion.GetNumberOfPixels() * ImageDimension; + ProgressReporter progress(this, 0, count, 10); for (unsigned int n = 0; n < ImageDimension; ++n) { // Setup iterators for input image. diff --git a/Modules/Filtering/ImageGrid/include/itkBSplineScatteredDataPointSetToImageFilter.hxx b/Modules/Filtering/ImageGrid/include/itkBSplineScatteredDataPointSetToImageFilter.hxx index d4472798ede..5587aff0229 100644 --- a/Modules/Filtering/ImageGrid/include/itkBSplineScatteredDataPointSetToImageFilter.hxx +++ b/Modules/Filtering/ImageGrid/include/itkBSplineScatteredDataPointSetToImageFilter.hxx @@ -108,7 +108,7 @@ BSplineScatteredDataPointSetToImageFilter::SetSpli } for (unsigned int j = 0; j < C.cols(); ++j) { - RealType c = std::pow(static_cast(2.0), static_cast(C.cols()) - j - 1); + const RealType c = std::pow(static_cast(2.0), static_cast(C.cols()) - j - 1); for (unsigned int k = 0; k < C.rows(); ++k) { @@ -264,7 +264,7 @@ BSplineScatteredDataPointSetToImageFilter::Generat { this->m_PsiLattice->SetRegions(this->m_PhiLattice->GetLargestPossibleRegion()); this->m_PsiLattice->Allocate(); - PointDataType P{}; + const PointDataType P{}; this->m_PsiLattice->FillBuffer(P); for (this->m_CurrentLevel = 1; this->m_CurrentLevel < this->m_MaximumNumberOfLevels; this->m_CurrentLevel++) @@ -421,7 +421,7 @@ BSplineScatteredDataPointSetToImageFilter::Threade { size[i] = this->m_SplineOrder[i] + 1; } - RealImagePointer neighborhoodWeightImage = RealImageType::New(); + const RealImagePointer neighborhoodWeightImage = RealImageType::New(); neighborhoodWeightImage->SetRegions(size); neighborhoodWeightImage->AllocateInitialized(); @@ -440,11 +440,11 @@ BSplineScatteredDataPointSetToImageFilter::Threade // Determine which points should be handled by this particular thread. - ThreadIdType numberOfWorkUnits = this->GetNumberOfWorkUnits(); - auto numberOfPointsPerThread = static_cast(input->GetNumberOfPoints() / numberOfWorkUnits); + const ThreadIdType numberOfWorkUnits = this->GetNumberOfWorkUnits(); + auto numberOfPointsPerThread = static_cast(input->GetNumberOfPoints() / numberOfWorkUnits); - unsigned int start = threadId * numberOfPointsPerThread; - unsigned int end = start + numberOfPointsPerThread; + const unsigned int start = threadId * numberOfPointsPerThread; + unsigned int end = start + numberOfPointsPerThread; if (threadId == this->GetNumberOfWorkUnits() - 1) { end = input->GetNumberOfPoints(); @@ -458,7 +458,7 @@ BSplineScatteredDataPointSetToImageFilter::Threade for (unsigned int i = 0; i < ImageDimension; ++i) { - unsigned int totalNumberOfSpans = this->m_CurrentNumberOfControlPoints[i] - this->m_SplineOrder[i]; + const unsigned int totalNumberOfSpans = this->m_CurrentNumberOfControlPoints[i] - this->m_SplineOrder[i]; p[i] = (point[i] - this->m_Origin[i]) * r[i]; if (itk::Math::abs(p[i] - static_cast(totalNumberOfSpans)) <= epsilon[i]) @@ -485,8 +485,8 @@ BSplineScatteredDataPointSetToImageFilter::Threade typename RealImageType::IndexType idx = ItW.GetIndex(); for (unsigned int i = 0; i < ImageDimension; ++i) { - RealType u = static_cast(p[i] - static_cast(p[i]) - idx[i]) + - 0.5 * static_cast(this->m_SplineOrder[i] - 1); + const RealType u = static_cast(p[i] - static_cast(p[i]) - idx[i]) + + 0.5 * static_cast(this->m_SplineOrder[i] - 1); switch (this->m_SplineOrder[i]) { @@ -535,8 +535,8 @@ BSplineScatteredDataPointSetToImageFilter::Threade idx[i] %= size[i]; } } - RealType wc = this->m_PointWeights->GetElement(n); - RealType t = ItW.Get(); + const RealType wc = this->m_PointWeights->GetElement(n); + const RealType t = ItW.Get(); currentThreadOmegaLattice->SetPixel(idx, currentThreadOmegaLattice->GetPixel(idx) + wc * t * t); PointDataType data = this->m_ResidualPointSetValues->GetElement(n); data *= (t * t * t * wc / w2Sum); @@ -601,8 +601,9 @@ BSplineScatteredDataPointSetToImageFilter::Threade FixedArray U; auto currentU = MakeFilled>(-1); - typename ImageType::IndexType startIndex = this->GetOutput()->GetRequestedRegion().GetIndex(); - typename PointDataImageType::IndexType startPhiIndex = this->m_PhiLattice->GetLargestPossibleRegion().GetIndex(); + typename ImageType::IndexType startIndex = this->GetOutput()->GetRequestedRegion().GetIndex(); + const typename PointDataImageType::IndexType startPhiIndex = + this->m_PhiLattice->GetLargestPossibleRegion().GetIndex(); for (ImageRegionIteratorWithIndex It(this->GetOutput(), region); !It.IsAtEnd(); ++It) { @@ -746,11 +747,11 @@ BSplineScatteredDataPointSetToImageFilter::RefineC } } - PointDataImagePointer refinedLattice = PointDataImageType::New(); + const PointDataImagePointer refinedLattice = PointDataImageType::New(); refinedLattice->SetRegions(size); refinedLattice->Allocate(); - PointDataType data{}; + const PointDataType data{}; refinedLattice->FillBuffer(data); typename PointDataImageType::IndexType idx; @@ -921,15 +922,16 @@ BSplineScatteredDataPointSetToImageFilter::Threade FixedArray U; auto currentU = MakeFilled>(-1); - typename PointDataImageType::IndexType startPhiIndex = this->m_PhiLattice->GetLargestPossibleRegion().GetIndex(); + const typename PointDataImageType::IndexType startPhiIndex = + this->m_PhiLattice->GetLargestPossibleRegion().GetIndex(); // Determine which points should be handled by this particular thread. - ThreadIdType numberOfWorkUnits = this->GetNumberOfWorkUnits(); - auto numberOfPointsPerThread = static_cast(input->GetNumberOfPoints() / numberOfWorkUnits); + const ThreadIdType numberOfWorkUnits = this->GetNumberOfWorkUnits(); + auto numberOfPointsPerThread = static_cast(input->GetNumberOfPoints() / numberOfWorkUnits); - unsigned int start = threadId * numberOfPointsPerThread; - unsigned int end = start + numberOfPointsPerThread; + const unsigned int start = threadId * numberOfPointsPerThread; + unsigned int end = start + numberOfPointsPerThread; if (threadId == this->GetNumberOfWorkUnits() - 1) { end = input->GetNumberOfPoints(); @@ -997,7 +999,7 @@ BSplineScatteredDataPointSetToImageFilter::Collaps for (unsigned int i = 0; i < this->m_SplineOrder[dimension] + 1; ++i) { idx[dimension] = static_cast(u) + i; - RealType v = u - idx[dimension] + 0.5 * static_cast(this->m_SplineOrder[dimension] - 1); + const RealType v = u - idx[dimension] + 0.5 * static_cast(this->m_SplineOrder[dimension] - 1); RealType B = 0.0; switch (this->m_SplineOrder[dimension]) @@ -1047,7 +1049,7 @@ BSplineScatteredDataPointSetToImageFilter::SetPhiL for (unsigned int i = 0; i < ImageDimension; ++i) { - RealType domain = this->m_Spacing[i] * static_cast(this->m_Size[i] - 1); + const RealType domain = this->m_Spacing[i] * static_cast(this->m_Size[i] - 1); unsigned int totalNumberOfSpans = this->m_PhiLattice->GetLargestPossibleRegion().GetSize()[i]; if (!this->m_CloseDimension[i]) diff --git a/Modules/Filtering/ImageGrid/include/itkBSplineUpsampleImageFilter.hxx b/Modules/Filtering/ImageGrid/include/itkBSplineUpsampleImageFilter.hxx index 0fc0c0c19dd..fc524c9e116 100644 --- a/Modules/Filtering/ImageGrid/include/itkBSplineUpsampleImageFilter.hxx +++ b/Modules/Filtering/ImageGrid/include/itkBSplineUpsampleImageFilter.hxx @@ -48,8 +48,8 @@ BSplineUpsampleImageFilter::GenerateDa itkDebugMacro("Actually executing"); // Get the input and output pointers - InputImagePointer inputPtr = const_cast(this->GetInput()); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImagePointer inputPtr = const_cast(this->GetInput()); + const OutputImagePointer outputPtr = this->GetOutput(); // Since we are providing a GenerateData() method, we need to allocate the // output buffer memory (if we provided a ThreadedGenerateData(), then @@ -76,8 +76,8 @@ BSplineUpsampleImageFilter::GenerateIn Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - InputImagePointer inputPtr = const_cast(this->GetInput()); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImagePointer inputPtr = const_cast(this->GetInput()); + const OutputImagePointer outputPtr = this->GetOutput(); if (!outputPtr || !inputPtr) { @@ -116,8 +116,8 @@ BSplineUpsampleImageFilter::GenerateOu Superclass::GenerateOutputInformation(); // get pointers to the input and output - InputImagePointer inputPtr = const_cast(this->GetInput()); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImagePointer inputPtr = const_cast(this->GetInput()); + const OutputImagePointer outputPtr = this->GetOutput(); if (!outputPtr || !inputPtr) { diff --git a/Modules/Filtering/ImageGrid/include/itkChangeInformationImageFilter.hxx b/Modules/Filtering/ImageGrid/include/itkChangeInformationImageFilter.hxx index 48edd2133a2..3cbdf7b4ef9 100644 --- a/Modules/Filtering/ImageGrid/include/itkChangeInformationImageFilter.hxx +++ b/Modules/Filtering/ImageGrid/include/itkChangeInformationImageFilter.hxx @@ -45,8 +45,8 @@ ChangeInformationImageFilter::GenerateOutputInformation() itkDebugMacro("GenerateOutputInformation Start"); // Get pointers to the input and output - typename Superclass::OutputImagePointer output = this->GetOutput(); - typename Superclass::InputImagePointer input = const_cast(this->GetInput()); + const typename Superclass::OutputImagePointer output = this->GetOutput(); + const typename Superclass::InputImagePointer input = const_cast(this->GetInput()); if (!output || !input) { diff --git a/Modules/Filtering/ImageGrid/include/itkCoxDeBoorBSplineKernelFunction.hxx b/Modules/Filtering/ImageGrid/include/itkCoxDeBoorBSplineKernelFunction.hxx index e7e5ced4142..f335e522aab 100644 --- a/Modules/Filtering/ImageGrid/include/itkCoxDeBoorBSplineKernelFunction.hxx +++ b/Modules/Filtering/ImageGrid/include/itkCoxDeBoorBSplineKernelFunction.hxx @@ -87,7 +87,7 @@ CoxDeBoorBSplineKernelFunction::CoxDeBoor(const un if (itk::Math::AlmostEquals(den, TRealValueType{ 0.0 })) { - PolynomialType poly(TRealValueType{ 0.0 }); + const PolynomialType poly(TRealValueType{ 0.0 }); poly1 = poly; } else @@ -102,7 +102,7 @@ CoxDeBoorBSplineKernelFunction::CoxDeBoor(const un den = knots(i + p + 1) - knots(i + 1); if (itk::Math::AlmostEquals(den, TRealValueType{ 0.0 })) { - PolynomialType poly(TRealValueType{ 0.0 }); + const PolynomialType poly(TRealValueType{ 0.0 }); poly2 = poly; } else diff --git a/Modules/Filtering/ImageGrid/include/itkCyclicShiftImageFilter.hxx b/Modules/Filtering/ImageGrid/include/itkCyclicShiftImageFilter.hxx index 7cc93e67d8a..4fd9ab6bde6 100644 --- a/Modules/Filtering/ImageGrid/include/itkCyclicShiftImageFilter.hxx +++ b/Modules/Filtering/ImageGrid/include/itkCyclicShiftImageFilter.hxx @@ -41,7 +41,7 @@ CyclicShiftImageFilter::GenerateInputRequestedRegion( Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (!input) { return; diff --git a/Modules/Filtering/ImageGrid/include/itkExpandImageFilter.hxx b/Modules/Filtering/ImageGrid/include/itkExpandImageFilter.hxx index acbc67d2afe..a65f4b6e53b 100644 --- a/Modules/Filtering/ImageGrid/include/itkExpandImageFilter.hxx +++ b/Modules/Filtering/ImageGrid/include/itkExpandImageFilter.hxx @@ -110,7 +110,7 @@ ExpandImageFilter::DynamicThreadedGenerateData( const OutputImageRegionType & outputRegionForThread) { // Get the input and output pointers - OutputImagePointer outputPtr = this->GetOutput(); + const OutputImagePointer outputPtr = this->GetOutput(); // Report progress on a per scanline basis const SizeValueType ln = outputRegionForThread.GetSize(0); diff --git a/Modules/Filtering/ImageGrid/include/itkFlipImageFilter.hxx b/Modules/Filtering/ImageGrid/include/itkFlipImageFilter.hxx index 130b5d5274c..fccd1b2989c 100644 --- a/Modules/Filtering/ImageGrid/include/itkFlipImageFilter.hxx +++ b/Modules/Filtering/ImageGrid/include/itkFlipImageFilter.hxx @@ -41,8 +41,8 @@ FlipImageFilter::GenerateOutputInformation() Superclass::GenerateOutputInformation(); // Get pointers to the input and output - InputImagePointer inputPtr = const_cast(this->GetInput()); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImagePointer inputPtr = const_cast(this->GetInput()); + const OutputImagePointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -115,8 +115,8 @@ FlipImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // Get pointers to the input and output - InputImagePointer inputPtr = const_cast(this->GetInput()); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImagePointer inputPtr = const_cast(this->GetInput()); + const OutputImagePointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -141,7 +141,7 @@ FlipImageFilter::GenerateInputRequestedRegion() } } - typename TImage::RegionType inputRequestedRegion(inputRequestedIndex, outputRequestedSize); + const typename TImage::RegionType inputRequestedRegion(inputRequestedIndex, outputRequestedSize); inputPtr->SetRequestedRegion(inputRequestedRegion); } @@ -150,8 +150,8 @@ template void FlipImageFilter::DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) { - InputImageConstPointer inputPtr = this->GetInput(); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImageConstPointer inputPtr = this->GetInput(); + const OutputImagePointer outputPtr = this->GetOutput(); const typename TImage::SizeType & outputLargestPossibleSize = outputPtr->GetLargestPossibleRegion().GetSize(); const typename TImage::IndexType & outputLargestPossibleIndex = outputPtr->GetLargestPossibleRegion().GetIndex(); diff --git a/Modules/Filtering/ImageGrid/include/itkInterpolateImageFilter.hxx b/Modules/Filtering/ImageGrid/include/itkInterpolateImageFilter.hxx index 770b3d314e2..fe1bf147560 100644 --- a/Modules/Filtering/ImageGrid/include/itkInterpolateImageFilter.hxx +++ b/Modules/Filtering/ImageGrid/include/itkInterpolateImageFilter.hxx @@ -85,12 +85,12 @@ InterpolateImageFilter::BeforeThreadedGenerateData() using IntermediateImageRegionType = typename IntermediateImageType::RegionType; using ImageRegionType = typename TOutputImage::RegionType; - ImageRegionType outputRegion = this->GetOutput()->GetRequestedRegion(); + const ImageRegionType outputRegion = this->GetOutput()->GetRequestedRegion(); IntermediateImageRegionType intermediateRegion; using RegionCopierType = ImageToImageFilterDetail::ImageRegionCopier; - RegionCopierType regionCopier; + const RegionCopierType regionCopier; regionCopier(intermediateRegion, outputRegion); intermediateRegion.SetIndex(ImageDimension, 0); @@ -146,7 +146,7 @@ void InterpolateImageFilter::DynamicThreadedGenerateData( const OutputImageRegionType & outputRegionForThread) { - OutputImagePointer outputPtr = this->GetOutput(); + const OutputImagePointer outputPtr = this->GetOutput(); using OutputIterator = ImageRegionIteratorWithIndex; using OutputPixelType = typename TOutputImage::PixelType; diff --git a/Modules/Filtering/ImageGrid/include/itkInterpolateImagePointsFilter.hxx b/Modules/Filtering/ImageGrid/include/itkInterpolateImagePointsFilter.hxx index 31a2674b708..7adfa8240cd 100644 --- a/Modules/Filtering/ImageGrid/include/itkInterpolateImagePointsFilter.hxx +++ b/Modules/Filtering/ImageGrid/include/itkInterpolateImagePointsFilter.hxx @@ -70,12 +70,12 @@ void InterpolateImagePointsFilter::DynamicThreadedGenerateData( const OutputImageRegionType & outputRegionForThread) { - OutputImagePointer outputPtr = this->GetOutput(); + const OutputImagePointer outputPtr = this->GetOutput(); // There is a direct mapping between the desired outputRegion and the // CoordRegion. coordRegion is set to outputRegionForThread. - RegionCopierType regionCopier; - CoordImageRegionType coordRegion; + const RegionCopierType regionCopier; + CoordImageRegionType coordRegion; regionCopier(coordRegion, outputRegionForThread); // Setup iterator for the output @@ -85,7 +85,7 @@ InterpolateImagePointsFilterGetInput(j + 1), coordRegion); + const CoordImageIterator temp(this->GetInput(j + 1), coordRegion); coordIter[j] = temp; } @@ -135,7 +135,7 @@ InterpolateImagePointsFilter(this->GetInput(0)); + const InputImagePointer inputPtr = const_cast(this->GetInput(0)); inputPtr->SetRequestedRegionToLargestPossibleRegion(); } @@ -152,8 +152,8 @@ InterpolateImagePointsFilter(this->GetInput(1)); - OutputImagePointer outputPtr = this->GetOutput(); + const CoordImageTypePointer xCoordPtr = const_cast(this->GetInput(1)); + const OutputImagePointer outputPtr = this->GetOutput(); // We need to compute the output spacing, the output image size, and the // output image start index. This is all determined by the coordinate data diff --git a/Modules/Filtering/ImageGrid/include/itkMirrorPadImageFilter.hxx b/Modules/Filtering/ImageGrid/include/itkMirrorPadImageFilter.hxx index db818c91cdb..3c39aba9252 100644 --- a/Modules/Filtering/ImageGrid/include/itkMirrorPadImageFilter.hxx +++ b/Modules/Filtering/ImageGrid/include/itkMirrorPadImageFilter.hxx @@ -150,8 +150,8 @@ template int MirrorPadImageFilter::FindRegionsInArea(long start, long end, long size, long offset) { - int result = 1; - long regionsize = end - start; + int result = 1; + const long regionsize = end - start; if (regionsize > 0) // Find out home many regions we have, { result = regionsize / size; @@ -189,12 +189,12 @@ MirrorPadImageFilter::ConvertOutputIndexToInputIndex( { // Output region goes from a to a+b-1 // Input region goes from c to c+b-1 - long a = outputRegionStart[dimCtr]; - long c = inputRegionStart[dimCtr]; + const long a = outputRegionStart[dimCtr]; + const long c = inputRegionStart[dimCtr]; if (oddRegionArray[dimCtr]) { - long b = inputSizes[dimCtr]; + const long b = inputSizes[dimCtr]; inputIndex[dimCtr] = a + c + b - 1 - outputIndex[dimCtr]; } else @@ -235,11 +235,11 @@ MirrorPadImageFilter::RegionIsOdd(long base, long tes if (test < base) { - long oddness = (base - test - 1) / size; + const long oddness = (base - test - 1) / size; return !(oddness & 1); } - long oddness = (test - base) / size; + const long oddness = (test - base) / size; return (oddness & 1); } @@ -454,8 +454,8 @@ MirrorPadImageFilter::GenerateInputRequestedRegion() // Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); - typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); + const typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); + const typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -731,9 +731,9 @@ MirrorPadImageFilter::DynamicThreadedGenerateData( { // If both a valid output and input region are defined for the particular // defined region, then copy the input values to the output values. - int goodOutput = + const int goodOutput = this->GenerateNextOutputRegion(outRegIndices, outRegLimit, outputRegionStart, outputRegionSizes, outputRegion); - int goodInput = + const int goodInput = this->GenerateNextInputRegion(inRegIndices, inRegLimit, inputRegionStart, inputRegionSizes, inputRegion); if (goodInput && goodOutput) { diff --git a/Modules/Filtering/ImageGrid/include/itkOrientImageFilter.hxx b/Modules/Filtering/ImageGrid/include/itkOrientImageFilter.hxx index f25abaa1611..23b4333b85d 100644 --- a/Modules/Filtering/ImageGrid/include/itkOrientImageFilter.hxx +++ b/Modules/Filtering/ImageGrid/include/itkOrientImageFilter.hxx @@ -44,8 +44,8 @@ OrientImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // Get pointers to the input and output - InputImagePointer inputPtr = const_cast(this->GetInput()); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImagePointer inputPtr = const_cast(this->GetInput()); + const OutputImagePointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -394,9 +394,9 @@ OrientImageFilter::GenerateData() progress->RegisterInternalFilter(flip, .3333333f); progress->RegisterInternalFilter(cast, .3333333f); - InputImagePointer permuteInput = const_cast(this->GetInput()); - InputImagePointer flipInput = permuteInput; - InputImagePointer castInput = permuteInput; + const InputImagePointer permuteInput = const_cast(this->GetInput()); + InputImagePointer flipInput = permuteInput; + InputImagePointer castInput = permuteInput; // Only run those filters that will do something if (NeedToPermute()) @@ -453,8 +453,8 @@ OrientImageFilter::GenerateOutputInformation() Superclass::GenerateOutputInformation(); // Get pointers to the input and output - InputImageConstPointer inputPtr = this->GetInput(); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImageConstPointer inputPtr = this->GetInput(); + const OutputImagePointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { diff --git a/Modules/Filtering/ImageGrid/include/itkPadImageFilter.hxx b/Modules/Filtering/ImageGrid/include/itkPadImageFilter.hxx index 89e8f2036b4..53667640e16 100644 --- a/Modules/Filtering/ImageGrid/include/itkPadImageFilter.hxx +++ b/Modules/Filtering/ImageGrid/include/itkPadImageFilter.hxx @@ -90,8 +90,8 @@ PadImageFilter::GenerateOutputInformation() Superclass::GenerateOutputInformation(); // get pointers to the input and output - typename Superclass::InputImageConstPointer inputPtr = this->GetInput(); - typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); + const typename Superclass::InputImageConstPointer inputPtr = this->GetInput(); + const typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); if (!outputPtr || !inputPtr) { diff --git a/Modules/Filtering/ImageGrid/include/itkPadImageFilterBase.hxx b/Modules/Filtering/ImageGrid/include/itkPadImageFilterBase.hxx index 43dbc70ed2c..63bc4b622b1 100644 --- a/Modules/Filtering/ImageGrid/include/itkPadImageFilterBase.hxx +++ b/Modules/Filtering/ImageGrid/include/itkPadImageFilterBase.hxx @@ -59,8 +59,8 @@ void PadImageFilterBase::GenerateInputRequestedRegion() { // Get pointers to the input and output. - typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); - typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); + const typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); + const typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); const InputImageRegionType & inputLargestPossibleRegion = inputPtr->GetLargestPossibleRegion(); const OutputImageRegionType & outputRequestedRegion = outputPtr->GetRequestedRegion(); @@ -70,7 +70,7 @@ PadImageFilterBase::GenerateInputRequestedRegion() { itkExceptionMacro("Boundary condition is nullptr so no request region can be generated."); } - InputImageRegionType inputRequestedRegion = + const InputImageRegionType inputRequestedRegion = m_BoundaryCondition->GetInputRequestedRegion(inputLargestPossibleRegion, outputRequestedRegion); inputPtr->SetRequestedRegion(inputRequestedRegion); @@ -82,15 +82,15 @@ PadImageFilterBase::DynamicThreadedGenerateData( const OutputImageRegionType & outputRegionForThread) { - typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); - typename Superclass::InputImageConstPointer inputPtr = this->GetInput(); + const typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); + const typename Superclass::InputImageConstPointer inputPtr = this->GetInput(); TotalProgressReporter progress(this, outputPtr->GetRequestedRegion().GetNumberOfPixels()); // Use the region copy method to copy the input image values to the // output image. OutputImageRegionType copyRegion(outputRegionForThread); - bool regionOverlaps = copyRegion.Crop(inputPtr->GetLargestPossibleRegion()); + const bool regionOverlaps = copyRegion.Crop(inputPtr->GetLargestPossibleRegion()); if (regionOverlaps) { // Do a block copy for the overlapping region. diff --git a/Modules/Filtering/ImageGrid/include/itkPasteImageFilter.hxx b/Modules/Filtering/ImageGrid/include/itkPasteImageFilter.hxx index f142f2f613a..0e9a7bb0cd6 100644 --- a/Modules/Filtering/ImageGrid/include/itkPasteImageFilter.hxx +++ b/Modules/Filtering/ImageGrid/include/itkPasteImageFilter.hxx @@ -56,9 +56,9 @@ PasteImageFilter::GenerateInputRequeste Superclass::GenerateInputRequestedRegion(); // Get the pointers for the inputs and output - InputImagePointer destPtr = const_cast(this->GetInput()); - SourceImagePointer sourcePtr = const_cast(this->GetSourceImage()); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImagePointer destPtr = const_cast(this->GetInput()); + const SourceImagePointer sourcePtr = const_cast(this->GetSourceImage()); + const OutputImagePointer outputPtr = this->GetOutput(); if (!destPtr || !outputPtr) { @@ -128,7 +128,7 @@ PasteImageFilter::DynamicThreadedGenera // Do we need to use the source image at all for the region generated by this // thread? - InputImageSizeType destinationSize = this->GetPresumedDestinationSize(); + const InputImageSizeType destinationSize = this->GetPresumedDestinationSize(); InputImageRegionType destinationRegion(this->GetDestinationIndex(), destinationSize); @@ -211,7 +211,7 @@ PasteImageFilter::DynamicThreadedGenera } else { - SourceImagePixelType sourceValue = this->GetConstant(); + const SourceImagePixelType sourceValue = this->GetConstant(); for (ImageScanlineIterator outputIt(outputPtr, destinationRegion); !outputIt.IsAtEnd(); outputIt.NextLine()) { @@ -254,7 +254,7 @@ PasteImageFilter::DynamicThreadedGenera } else { - SourceImagePixelType sourceValue = this->GetConstant(); + const SourceImagePixelType sourceValue = this->GetConstant(); for (ImageScanlineIterator outputIt(outputPtr, destinationRegion); !outputIt.IsAtEnd(); outputIt.NextLine()) { diff --git a/Modules/Filtering/ImageGrid/include/itkPermuteAxesImageFilter.hxx b/Modules/Filtering/ImageGrid/include/itkPermuteAxesImageFilter.hxx index e7477e94d40..16a6c2057eb 100644 --- a/Modules/Filtering/ImageGrid/include/itkPermuteAxesImageFilter.hxx +++ b/Modules/Filtering/ImageGrid/include/itkPermuteAxesImageFilter.hxx @@ -109,8 +109,8 @@ PermuteAxesImageFilter::GenerateOutputInformation() Superclass::GenerateOutputInformation(); // get pointers to the input and output - typename Superclass::InputImageConstPointer inputPtr = this->GetInput(); - typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); + const typename Superclass::InputImageConstPointer inputPtr = this->GetInput(); + const typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -159,8 +159,8 @@ PermuteAxesImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - InputImagePointer inputPtr = const_cast(this->GetInput()); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImagePointer inputPtr = const_cast(this->GetInput()); + const OutputImagePointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -189,8 +189,8 @@ void PermuteAxesImageFilter::DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) { // Get the input and output pointers - typename Superclass::InputImageConstPointer inputPtr = this->GetInput(); - typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); + const typename Superclass::InputImageConstPointer inputPtr = this->GetInput(); + const typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); TotalProgressReporter progress(this, outputPtr->GetRequestedRegion().GetNumberOfPixels()); diff --git a/Modules/Filtering/ImageGrid/include/itkRegionOfInterestImageFilter.hxx b/Modules/Filtering/ImageGrid/include/itkRegionOfInterestImageFilter.hxx index 0e5143977ee..dce4712e170 100644 --- a/Modules/Filtering/ImageGrid/include/itkRegionOfInterestImageFilter.hxx +++ b/Modules/Filtering/ImageGrid/include/itkRegionOfInterestImageFilter.hxx @@ -41,7 +41,7 @@ RegionOfInterestImageFilter::GenerateInputRequestedRe Superclass::GenerateInputRequestedRegion(); // Get pointer to the input - typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); + const typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); if (inputPtr) { @@ -69,8 +69,8 @@ RegionOfInterestImageFilter::GenerateOutputInformatio // this filter allows the input the output to be of different dimensions // Get pointers to the input and output - typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); - typename Superclass::InputImageConstPointer inputPtr = this->GetInput(); + const typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); + const typename Superclass::InputImageConstPointer inputPtr = this->GetInput(); if (!outputPtr || !inputPtr) { @@ -87,7 +87,7 @@ RegionOfInterestImageFilter::GenerateOutputInformatio outputPtr->SetLargestPossibleRegion(region); // Correct origin of the extracted region. - IndexType roiStart(m_RegionOfInterest.GetIndex()); + const IndexType roiStart(m_RegionOfInterest.GetIndex()); typename Superclass::OutputImageType::PointType outputOrigin; inputPtr->TransformIndexToPhysicalPoint(roiStart, outputOrigin); outputPtr->SetOrigin(outputOrigin); diff --git a/Modules/Filtering/ImageGrid/include/itkResampleImageFilter.hxx b/Modules/Filtering/ImageGrid/include/itkResampleImageFilter.hxx index 9efed7e7802..16493faf7ce 100644 --- a/Modules/Filtering/ImageGrid/include/itkResampleImageFilter.hxx +++ b/Modules/Filtering/ImageGrid/include/itkResampleImageFilter.hxx @@ -79,7 +79,7 @@ ResampleImageFilter; - typename IdentityTransformType::Pointer defaultTransform = + const typename IdentityTransformType::Pointer defaultTransform = IdentityTransform::New(); if constexpr (InputImageDimension == OutputImageDimension) { @@ -175,8 +175,8 @@ ResampleImageFilter::ZeroValue(tempZeroComponents); + const PixelComponentType tempZeroComponents{ 0 }; + const PixelComponentType zeroComponent = NumericTraits::ZeroValue(tempZeroComponents); nComponents = this->GetInput()->GetNumberOfComponentsPerPixel(); NumericTraits::SetLength(m_DefaultPixelValue, nComponents); for (unsigned int n = 0; n < nComponents; ++n) @@ -261,7 +261,7 @@ ResampleImageFilter(largestPossibleRegion.GetSize(0)); // Cache information from the superclass - PixelType defaultValue = this->GetDefaultPixelValue(); + const PixelType defaultValue = this->GetDefaultPixelValue(); // As we walk across a scan line in the output image, we trace // an oriented/scaled/translated line in the input image. Each scan diff --git a/Modules/Filtering/ImageGrid/include/itkShrinkImageFilter.hxx b/Modules/Filtering/ImageGrid/include/itkShrinkImageFilter.hxx index a543630570e..be3fe035fed 100644 --- a/Modules/Filtering/ImageGrid/include/itkShrinkImageFilter.hxx +++ b/Modules/Filtering/ImageGrid/include/itkShrinkImageFilter.hxx @@ -108,8 +108,8 @@ ShrinkImageFilter::DynamicThreadedGenerateData( const OutputImageRegionType & outputRegionForThread) { // Get the input and output pointers - InputImageConstPointer inputPtr = this->GetInput(); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImageConstPointer inputPtr = this->GetInput(); + const OutputImagePointer outputPtr = this->GetOutput(); TotalProgressReporter progress(this, outputPtr->GetRequestedRegion().GetNumberOfPixels()); @@ -141,7 +141,7 @@ ShrinkImageFilter::DynamicThreadedGenerateData( // Given that the size is scaled by a constant factor eq: // inputIndex = outputIndex * factorSize // is equivalent up to a fixed offset which we now compute - OffsetValueType zeroOffset = 0; + const OffsetValueType zeroOffset = 0; for (i = 0; i < TInputImage::ImageDimension; ++i) { offsetIndex[i] = inputIndex[i] - outputIndex[i] * m_ShrinkFactors[i]; @@ -220,7 +220,7 @@ ShrinkImageFilter::GenerateInputRequestedRegion() // Given that the size is scaled by a constant factor eq: // inputIndex = outputIndex * factorSize // is equivalent up to a fixed offset which we now compute - OffsetValueType zeroOffset = 0; + const OffsetValueType zeroOffset = 0; for (i = 0; i < TInputImage::ImageDimension; ++i) { offsetIndex[i] = inputIndex[i] - outputIndex[i] * m_ShrinkFactors[i]; @@ -311,7 +311,7 @@ ShrinkImageFilter::GenerateOutputInformation() outputPtr->TransformContinuousIndexToPhysicalPoint(outputCenterIndex, outputCenterPoint); const typename TOutputImage::PointType & inputOrigin = inputPtr->GetOrigin(); - typename TOutputImage::PointType outputOrigin = inputOrigin + (inputCenterPoint - outputCenterPoint); + const typename TOutputImage::PointType outputOrigin = inputOrigin + (inputCenterPoint - outputCenterPoint); outputPtr->SetOrigin(outputOrigin); // Set region diff --git a/Modules/Filtering/ImageGrid/include/itkSliceImageFilter.hxx b/Modules/Filtering/ImageGrid/include/itkSliceImageFilter.hxx index e11d72cb2f9..96673a9322c 100644 --- a/Modules/Filtering/ImageGrid/include/itkSliceImageFilter.hxx +++ b/Modules/Filtering/ImageGrid/include/itkSliceImageFilter.hxx @@ -118,8 +118,8 @@ void SliceImageFilter::DynamicThreadedGenerateData( const OutputImageRegionType & outputRegionForThread) { - InputImageConstPointer inputPtr = this->GetInput(); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImageConstPointer inputPtr = this->GetInput(); + const OutputImagePointer outputPtr = this->GetOutput(); TotalProgressReporter progress(this, outputPtr->GetRequestedRegion().GetNumberOfPixels()); @@ -163,8 +163,8 @@ SliceImageFilter::GenerateInputRequestedRegion() // Get pointers to the input and output - InputImagePointer inputPtr = const_cast(this->GetInput()); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImagePointer inputPtr = const_cast(this->GetInput()); + const OutputImagePointer outputPtr = this->GetOutput(); const typename TOutputImage::SizeType & outputRequestedRegionSize = outputPtr->GetRequestedRegion().GetSize(); const typename TOutputImage::IndexType & outputRequestedRegionStartIndex = outputPtr->GetRequestedRegion().GetIndex(); @@ -226,8 +226,8 @@ SliceImageFilter::GenerateOutputInformation() Superclass::GenerateOutputInformation(); // Get pointers to the input and output - InputImageConstPointer inputPtr = this->GetInput(); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImageConstPointer inputPtr = this->GetInput(); + const OutputImagePointer outputPtr = this->GetOutput(); // Compute the output spacing, the output image size, and the // output image start index @@ -244,14 +244,14 @@ SliceImageFilter::GenerateOutputInformation() outputSpacing[i] = inputSpacing[i] * itk::Math::abs(m_Step[i]); // clamp start, inclusive start interval - IndexValueType start = + const IndexValueType start = std::clamp(m_Start[i], inputIndex[i] - static_cast(m_Step[i] < 0), static_cast(inputIndex[i] + inputSize[i]) - static_cast(m_Step[i] < 0)); // clamp stop as open interval // Based on the sign of the step include 1 after the end. - IndexValueType stop = + const IndexValueType stop = std::clamp(m_Stop[i], inputIndex[i] - static_cast(m_Step[i] < 0), static_cast(inputIndex[i] + inputSize[i]) - static_cast(m_Step[i] < 0)); diff --git a/Modules/Filtering/ImageGrid/include/itkTileImageFilter.hxx b/Modules/Filtering/ImageGrid/include/itkTileImageFilter.hxx index edc6d8999b3..abef79ccb1c 100644 --- a/Modules/Filtering/ImageGrid/include/itkTileImageFilter.hxx +++ b/Modules/Filtering/ImageGrid/include/itkTileImageFilter.hxx @@ -108,7 +108,7 @@ TileImageFilter::GenerateData() tempSize[i] = 1; tempIndex[i] = 0; } - OutputImageRegionType tempRegion(tempIndex, tempSize); + const OutputImageRegionType tempRegion(tempIndex, tempSize); tempImage->SetRegions(tempRegion); const TInputImage * inputImage = this->GetInput(it.Get().m_ImageNumber); @@ -224,7 +224,7 @@ TileImageFilter::GenerateOutputInformation() // Determine the size of the output. Each "row" size is determined // and the maximum size for each "row" will be the size for that // dimension. - RegionType tileRegion(tileSize); + const RegionType tileRegion(tileSize); m_TileImage->SetRegions(tileRegion); m_TileImage->Allocate(); @@ -279,7 +279,7 @@ TileImageFilter::GenerateOutputInformation() int count = 0; while (!tit.IsAtEndOfLine()) { - int value = tit.Get().m_ImageNumber; + const int value = tit.Get().m_ImageNumber; if (value != -1) { if (i < InputImageDimension) @@ -314,7 +314,7 @@ TileImageFilter::GenerateOutputInformation() it.GoToBegin(); while (!it.IsAtEnd()) { - int value = it.Get().m_ImageNumber; + const int value = it.Get().m_ImageNumber; if (value >= 0) { typename TileImageType::IndexType tileIndex2 = it.GetIndex(); @@ -333,7 +333,7 @@ TileImageFilter::GenerateOutputInformation() regionSize[i] = 1; } } - OutputImageRegionType region(regionIndex, regionSize); + const OutputImageRegionType region(regionIndex, regionSize); info = it.Get(); info.m_Region = region; it.Set(info); diff --git a/Modules/Filtering/ImageGrid/include/itkWarpImageFilter.hxx b/Modules/Filtering/ImageGrid/include/itkWarpImageFilter.hxx index 9482902c7a7..41fa320dc1c 100644 --- a/Modules/Filtering/ImageGrid/include/itkWarpImageFilter.hxx +++ b/Modules/Filtering/ImageGrid/include/itkWarpImageFilter.hxx @@ -127,7 +127,7 @@ WarpImageFilter::BeforeThreadedGe if (numberOfComponents != this->GetInput()->GetNumberOfComponentsPerPixel()) { - PixelComponentType zeroComponent = NumericTraits::ZeroValue(PixelComponentType{}); + const PixelComponentType zeroComponent = NumericTraits::ZeroValue(PixelComponentType{}); numberOfComponents = this->GetInput()->GetNumberOfComponentsPerPixel(); NumericTraits::SetLength(m_EdgePaddingValue, numberOfComponents); @@ -224,8 +224,8 @@ WarpImageFilter::EvaluateDisplace */ output.Fill(0); - double totalOverlap = 0.0; - unsigned int numNeighbors(1 << TInputImage::ImageDimension); + double totalOverlap = 0.0; + const unsigned int numNeighbors(1 << TInputImage::ImageDimension); for (unsigned int counter = 0; counter < numNeighbors; ++counter) { @@ -401,7 +401,7 @@ WarpImageFilter::GenerateInputReq using TransformType = itk::Transform; - DisplacementRegionType fieldRequestedRegion = ImageAlgorithm::EnlargeRegionOverBox( + const DisplacementRegionType fieldRequestedRegion = ImageAlgorithm::EnlargeRegionOverBox( outputPtr->GetRequestedRegion(), outputPtr, fieldPtr, static_cast(nullptr)); fieldPtr->SetRequestedRegion(fieldRequestedRegion); } diff --git a/Modules/Filtering/ImageGrid/include/itkWarpVectorImageFilter.hxx b/Modules/Filtering/ImageGrid/include/itkWarpVectorImageFilter.hxx index d4dbcf2a6b9..d40850f9340 100644 --- a/Modules/Filtering/ImageGrid/include/itkWarpVectorImageFilter.hxx +++ b/Modules/Filtering/ImageGrid/include/itkWarpVectorImageFilter.hxx @@ -140,9 +140,9 @@ void WarpVectorImageFilter::DynamicThreadedGenerateData( const OutputImageRegionType & outputRegionForThread) { - InputImageConstPointer inputPtr = this->GetInput(); - OutputImagePointer outputPtr = this->GetOutput(); - DisplacementFieldPointer fieldPtr = this->GetDisplacementField(); + const InputImageConstPointer inputPtr = this->GetInput(); + const OutputImagePointer outputPtr = this->GetOutput(); + const DisplacementFieldPointer fieldPtr = this->GetDisplacementField(); ImageRegionIteratorWithIndex outputIt(outputPtr, outputRegionForThread); @@ -198,7 +198,7 @@ WarpVectorImageFilter::GenerateIn Superclass::GenerateInputRequestedRegion(); // request the largest possible region for the input image - InputImagePointer inputPtr = const_cast(this->GetInput()); + const InputImagePointer inputPtr = const_cast(this->GetInput()); if (inputPtr) { @@ -207,8 +207,8 @@ WarpVectorImageFilter::GenerateIn // just propagate up the output requested region for the // displacement field. - DisplacementFieldPointer fieldPtr = this->GetDisplacementField(); - OutputImagePointer outputPtr = this->GetOutput(); + const DisplacementFieldPointer fieldPtr = this->GetDisplacementField(); + const OutputImagePointer outputPtr = this->GetOutput(); if (fieldPtr) { fieldPtr->SetRequestedRegion(outputPtr->GetRequestedRegion()); @@ -222,13 +222,13 @@ WarpVectorImageFilter::GenerateOu // call the superclass's implementation of this method Superclass::GenerateOutputInformation(); - OutputImagePointer outputPtr = this->GetOutput(); + const OutputImagePointer outputPtr = this->GetOutput(); outputPtr->SetSpacing(m_OutputSpacing); outputPtr->SetOrigin(m_OutputOrigin); outputPtr->SetDirection(m_OutputDirection); - DisplacementFieldPointer fieldPtr = this->GetDisplacementField(); + const DisplacementFieldPointer fieldPtr = this->GetDisplacementField(); if (fieldPtr) { outputPtr->SetLargestPossibleRegion(fieldPtr->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/ImageGrid/test/itkBSplineControlPointImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkBSplineControlPointImageFilterTest.cxx index c07e211d444..bffd64857c2 100644 --- a/Modules/Filtering/ImageGrid/test/itkBSplineControlPointImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkBSplineControlPointImageFilterTest.cxx @@ -47,21 +47,21 @@ BSpline(int argc, char * argv[]) // Reconstruction of the scalar field from the control points - typename ScalarFieldType::PointType origin{}; - auto size = ScalarFieldType::SizeType::Filled(100); - auto spacing = itk::MakeFilled(1.0); + const typename ScalarFieldType::PointType origin{}; + auto size = ScalarFieldType::SizeType::Filled(100); + auto spacing = itk::MakeFilled(1.0); using BSplinerType = itk::BSplineControlPointImageFilter; auto bspliner = BSplinerType::New(); bspliner->SetInput(reader->GetOutput()); - typename BSplinerType::ArrayType::ValueType closeDimensionVal = 0; + const typename BSplinerType::ArrayType::ValueType closeDimensionVal = 0; auto closeDimension = itk::MakeFilled(closeDimensionVal); bspliner->SetCloseDimension(closeDimension); ITK_TEST_SET_GET_VALUE(closeDimension, bspliner->GetCloseDimension()); - typename BSplinerType::ArrayType splineOrder(3); + const typename BSplinerType::ArrayType splineOrder(3); bspliner->SetSplineOrder(splineOrder); ITK_TEST_SET_GET_VALUE(splineOrder, bspliner->GetSplineOrder()); @@ -74,7 +74,7 @@ BSpline(int argc, char * argv[]) bspliner->SetSpacing(spacing); ITK_TEST_SET_GET_VALUE(spacing, bspliner->GetSpacing()); - typename BSplinerType::DirectionType direction = reader->GetOutput()->GetDirection(); + const typename BSplinerType::DirectionType direction = reader->GetOutput()->GetDirection(); bspliner->SetDirection(direction); ITK_TEST_SET_GET_VALUE(direction, bspliner->GetDirection()); @@ -102,7 +102,7 @@ BSpline(int argc, char * argv[]) // auto numberOfRefinementLevels = itk::MakeFilled(3); - typename BSplinerType::ControlPointLatticeType::Pointer refinedControlPointLattice = + const typename BSplinerType::ControlPointLatticeType::Pointer refinedControlPointLattice = bspliner->RefineControlPointLattice(numberOfRefinementLevels); auto bspliner2 = BSplinerType::New(); diff --git a/Modules/Filtering/ImageGrid/test/itkBSplineControlPointImageFunctionTest.cxx b/Modules/Filtering/ImageGrid/test/itkBSplineControlPointImageFunctionTest.cxx index d26094f1c84..87498c148c6 100644 --- a/Modules/Filtering/ImageGrid/test/itkBSplineControlPointImageFunctionTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkBSplineControlPointImageFunctionTest.cxx @@ -79,7 +79,7 @@ itkBSplineControlPointImageFunctionTest(int, char *[]) bspliner->SetSize(size); ITK_TEST_SET_GET_VALUE(size, bspliner->GetSize()); - unsigned int bSplineOrderValue = 3; + const unsigned int bSplineOrderValue = 3; bspliner->SetSplineOrder(bSplineOrderValue); for (auto i : bspliner->GetSplineOrder()) { @@ -96,12 +96,12 @@ itkBSplineControlPointImageFunctionTest(int, char *[]) bspliner->SetSplineOrder(bSplineOrder); ITK_TEST_SET_GET_VALUE(bSplineOrder, bspliner->GetSplineOrder()); - BSplinerType::ArrayType::ValueType closeDimensionValue = 0; - auto closeDimension = itk::MakeFilled(closeDimensionValue); + const BSplinerType::ArrayType::ValueType closeDimensionValue = 0; + auto closeDimension = itk::MakeFilled(closeDimensionValue); bspliner->SetCloseDimension(closeDimension); ITK_TEST_SET_GET_VALUE(closeDimension, bspliner->GetCloseDimension()); - BSplinerType::RealType bSplineEpsilon = 1e-3; + const BSplinerType::RealType bSplineEpsilon = 1e-3; bspliner->SetBSplineEpsilon(bSplineEpsilon); ITK_TEST_SET_GET_VALUE(bSplineEpsilon, bspliner->GetBSplineEpsilon()); diff --git a/Modules/Filtering/ImageGrid/test/itkBSplineDownsampleImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkBSplineDownsampleImageFilterTest.cxx index 7a4a110f185..d3c40a865f4 100644 --- a/Modules/Filtering/ImageGrid/test/itkBSplineDownsampleImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkBSplineDownsampleImageFilterTest.cxx @@ -55,7 +55,7 @@ itkBSplineDownsampleImageFilterTest(int argc, char * argv[]) auto filter = DownsamplerFilterType::New(); - itk::SimpleFilterWatcher watcher(filter, "BSplineDownsampleImageFilter"); + const itk::SimpleFilterWatcher watcher(filter, "BSplineDownsampleImageFilter"); using ReaderType = itk::ImageFileReader; auto reader = ReaderType::New(); diff --git a/Modules/Filtering/ImageGrid/test/itkBSplineResampleImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkBSplineResampleImageFilterTest.cxx index 20e3f38fa40..8dac07b43cf 100644 --- a/Modules/Filtering/ImageGrid/test/itkBSplineResampleImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkBSplineResampleImageFilterTest.cxx @@ -59,7 +59,7 @@ PrintImageData(ImageTypePtr2D imgPtr) using Iterator = itk::ImageLinearIteratorWithIndex; std::cout << "Size: " << imgPtr->GetLargestPossibleRegion().GetSize() << std::endl; - int dim = ImageType2D::ImageDimension; + const int dim = ImageType2D::ImageDimension; std::cout << "Spacing: " << std::endl; for (int n = 0; n < dim; ++n) @@ -92,8 +92,8 @@ PrintImageData(ImageTypePtr2D imgPtr) void set2DData(ImageType2D::Pointer imgPtr) { - SizeType2D size = { { 4, 4 } }; - double mydata[49] = { 0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 3, 2 }; + const SizeType2D size = { { 4, 4 } }; + const double mydata[49] = { 0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 3, 2 }; ImageType2D::RegionType region; region.SetSize(size); @@ -122,8 +122,8 @@ set2DData(ImageType2D::Pointer imgPtr) void setInt2DData(IntImageType2D::Pointer imgPtr) { - IntSizeType2D size = { { 4, 4 } }; - int mydata[49] = { 0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 3, 2 }; + const IntSizeType2D size = { { 4, 4 } }; + const int mydata[49] = { 0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 3, 2 }; IntImageType2D::RegionType region; region.SetSize(size); @@ -159,7 +159,7 @@ VerifyResultsHigherOrderSpline(ImageTypePtr2D ActualResults, double * ExpectedRe while (!ActualResultsIter.IsAtEnd()) { - double val1 = ActualResultsIter.Get(); + const double val1 = ActualResultsIter.Get(); percentErr += itk::Math::abs((val1 - *ERptr) / val1); @@ -185,7 +185,7 @@ VerifyResults3rdOrderSpline(ImageTypePtr2D ActualResults, double * ExpectedResul while (!ActualResultsIter.IsAtEnd()) { - double val1 = ActualResultsIter.Get(); + const double val1 = ActualResultsIter.Get(); if (itk::Math::abs(val1 - *ERptr) > 1e-6) { // std::cout << "*** Error: value should be " << trueValue << std::endl; @@ -207,7 +207,7 @@ VerifyResults2ndOrderSpline(ImageTypePtr2D ActualResults, double * ExpectedResul while (!ActualResultsIter.IsAtEnd()) { - double val1 = ActualResultsIter.Get(); + const double val1 = ActualResultsIter.Get(); percentErr += itk::Math::abs((val1 - *ERptr) / val1); @@ -235,7 +235,7 @@ VerifyResultsLowerOrderSpline(ImageTypePtr2D ActualResults, double * ExpectedRes while (!ActualResultsIter.IsAtEnd()) { - double val1 = ActualResultsIter.Get(); + const double val1 = ActualResultsIter.Get(); percentErr += itk::Math::abs((val1 - *ERptr) / val1); @@ -259,7 +259,7 @@ test2D_Standard_l2_NthOrderSpline_filter(unsigned int splineOrder) int flag = 0; /* Allocate a simple test image */ - ImageTypePtr2D image = ImageType2D::New(); + const ImageTypePtr2D image = ImageType2D::New(); set2DData(image); double ExpectedResults[] = { 0.517188, 1.575548, 2.634784, 2.847124, 1.547224, 2.323852, 3.101771, 3.257328, @@ -269,22 +269,22 @@ test2D_Standard_l2_NthOrderSpline_filter(unsigned int splineOrder) using DownsamplerType2D = itk::BSplineDownsampleImageFilter; using UpsamplerType2D = itk::BSplineUpsampleImageFilter; - auto downSampler = DownsamplerType2D::New(); - itk::SimpleFilterWatcher downWatcher(downSampler, "test2D_Standard_l2_filter"); + auto downSampler = DownsamplerType2D::New(); + const itk::SimpleFilterWatcher downWatcher(downSampler, "test2D_Standard_l2_filter"); - auto upSampler = UpsamplerType2D::New(); - itk::SimpleFilterWatcher upWatcher(upSampler, "test2D_Standard_l2_filter"); + auto upSampler = UpsamplerType2D::New(); + const itk::SimpleFilterWatcher upWatcher(upSampler, "test2D_Standard_l2_filter"); downSampler->SetSplineOrder(splineOrder); upSampler->SetSplineOrder(splineOrder); downSampler->SetInput(image); downSampler->Update(); - ImageTypePtr2D outImage1 = downSampler->GetOutput(); + const ImageTypePtr2D outImage1 = downSampler->GetOutput(); PrintImageData(outImage1); upSampler->SetInput(outImage1); upSampler->Update(); - ImageTypePtr2D outImage2 = upSampler->GetOutput(); + const ImageTypePtr2D outImage2 = upSampler->GetOutput(); PrintImageData(outImage2); bool sameResults = false; @@ -328,7 +328,7 @@ test2D_Standard_L2_NthOrderSpline_filter(unsigned int splineOrder) int flag = 0; // Allocate a simple test image - ImageTypePtr2D image = ImageType2D::New(); + const ImageTypePtr2D image = ImageType2D::New(); set2DData(image); double ExpectedResults[] = { 0.527796, 1.584850, 2.642784, 2.854860, 1.554069, 2.328161, 3.103548, 3.258594, @@ -339,22 +339,22 @@ test2D_Standard_L2_NthOrderSpline_filter(unsigned int splineOrder) using DownsamplerType2D = itk::BSplineDownsampleImageFilter; using UpsamplerType2D = itk::BSplineUpsampleImageFilter; - auto downSampler = DownsamplerType2D::New(); - itk::SimpleFilterWatcher downWatcher(downSampler, "test2D_Standard_L2_filter"); + auto downSampler = DownsamplerType2D::New(); + const itk::SimpleFilterWatcher downWatcher(downSampler, "test2D_Standard_L2_filter"); - auto upSampler = UpsamplerType2D::New(); - itk::SimpleFilterWatcher upWatcher(upSampler, "test2D_Standard_L2_filter"); + auto upSampler = UpsamplerType2D::New(); + const itk::SimpleFilterWatcher upWatcher(upSampler, "test2D_Standard_L2_filter"); downSampler->SetSplineOrder(splineOrder); upSampler->SetSplineOrder(splineOrder); downSampler->SetInput(image); downSampler->Update(); - ImageTypePtr2D outImage1 = downSampler->GetOutput(); + const ImageTypePtr2D outImage1 = downSampler->GetOutput(); PrintImageData(outImage1); upSampler->SetInput(outImage1); upSampler->Update(); - ImageTypePtr2D outImage2 = upSampler->GetOutput(); + const ImageTypePtr2D outImage2 = upSampler->GetOutput(); PrintImageData(outImage2); bool sameResults = false; @@ -397,7 +397,7 @@ test2D_Centered_l2_NthOrderSpline_filter(unsigned int splineOrder) int flag = 0; // Allocate a simple test image - ImageTypePtr2D image = ImageType2D::New(); + const ImageTypePtr2D image = ImageType2D::New(); set2DData(image); double ExpectedResults[] = { 0.124139, 0.606412, 1.322693, 1.803619, 0.580514, 1.719005, 2.834988, 3.584282, @@ -408,20 +408,20 @@ test2D_Centered_l2_NthOrderSpline_filter(unsigned int splineOrder) using DownsamplerType2D = itk::BSplineDownsampleImageFilter; using UpsamplerType2D = itk::BSplineUpsampleImageFilter; - auto downSampler = DownsamplerType2D::New(); - itk::SimpleFilterWatcher downWatcher(downSampler, "test2D_Centered_l2_filter"); - auto upSampler = UpsamplerType2D::New(); - itk::SimpleFilterWatcher upWatcher(upSampler, "test2D_Centered_l2_filter"); + auto downSampler = DownsamplerType2D::New(); + const itk::SimpleFilterWatcher downWatcher(downSampler, "test2D_Centered_l2_filter"); + auto upSampler = UpsamplerType2D::New(); + const itk::SimpleFilterWatcher upWatcher(upSampler, "test2D_Centered_l2_filter"); downSampler->SetSplineOrder(splineOrder); upSampler->SetSplineOrder(splineOrder); downSampler->SetInput(image); downSampler->Update(); - ImageTypePtr2D outImage1 = downSampler->GetOutput(); + const ImageTypePtr2D outImage1 = downSampler->GetOutput(); PrintImageData(outImage1); upSampler->SetInput(outImage1); upSampler->Update(); - ImageTypePtr2D outImage2 = upSampler->GetOutput(); + const ImageTypePtr2D outImage2 = upSampler->GetOutput(); PrintImageData(outImage2); bool sameResults = false; if (splineOrder == 4) @@ -469,7 +469,7 @@ testIntInputDoubleOutput() // Note this only tests the downsampling using Int input and double output. // TODO: Modify to test upsampling also. // Allocate a simple test image - IntImageTypePtr2D image = IntImageType2D::New(); + const IntImageTypePtr2D image = IntImageType2D::New(); setInt2DData(image); double ExpectedResults[] = { 0.124139, 0.606412, 1.322693, 1.803619, 0.580514, 1.719005, 2.834988, 3.584282, @@ -482,24 +482,24 @@ testIntInputDoubleOutput() using UpsamplerType2D = itk::BSplineUpsampleImageFilter; - auto downSampler = DownsamplerType2D::New(); - auto upSampler = UpsamplerType2D::New(); - int splineOrder = 3; + auto downSampler = DownsamplerType2D::New(); + auto upSampler = UpsamplerType2D::New(); + const int splineOrder = 3; downSampler->SetSplineOrder(splineOrder); upSampler->SetSplineOrder(splineOrder); downSampler->SetInput(image); downSampler->Update(); - ImageTypePtr2D outImage1 = downSampler->GetOutput(); + const ImageTypePtr2D outImage1 = downSampler->GetOutput(); PrintImageData(outImage1); // interp->Print( std::cout ); // PrintImageData(image); // upSampler->SetInput( downSampler->GetOutput() ); upSampler->SetInput(outImage1); upSampler->Update(); - ImageTypePtr2D outImage2 = upSampler->GetOutput(); + const ImageTypePtr2D outImage2 = upSampler->GetOutput(); PrintImageData(outImage2); - bool sameResults = VerifyResults3rdOrderSpline(outImage2, ExpectedResults); + const bool sameResults = VerifyResults3rdOrderSpline(outImage2, ExpectedResults); if (!sameResults) { flag = 1; @@ -521,7 +521,7 @@ test2D_Centered_L2_NthOrderSpline_filter(unsigned int splineOrder) int flag = 0; // Allocate a simple test image - ImageTypePtr2D image = ImageType2D::New(); + const ImageTypePtr2D image = ImageType2D::New(); set2DData(image); double ExpectedResults[] = { 0.119494, 0.600647, 1.323863, 1.802788, 0.574571, 1.712082, 2.837723, 3.583139, @@ -532,24 +532,24 @@ test2D_Centered_L2_NthOrderSpline_filter(unsigned int splineOrder) using DownsamplerType2D = itk::BSplineDownsampleImageFilter; using UpsamplerType2D = itk::BSplineUpsampleImageFilter; - auto downSampler = DownsamplerType2D::New(); - itk::SimpleFilterWatcher downWatcher(downSampler, "test2D_Centered_L2_filter"); - auto upSampler = UpsamplerType2D::New(); - itk::SimpleFilterWatcher upWatcher(upSampler, "test2D_Centered_L2_filter"); + auto downSampler = DownsamplerType2D::New(); + const itk::SimpleFilterWatcher downWatcher(downSampler, "test2D_Centered_L2_filter"); + auto upSampler = UpsamplerType2D::New(); + const itk::SimpleFilterWatcher upWatcher(upSampler, "test2D_Centered_L2_filter"); // int splineOrder = 2; downSampler->SetSplineOrder(splineOrder); upSampler->SetSplineOrder(splineOrder); downSampler->SetInput(image); downSampler->Update(); - ImageTypePtr2D outImage1 = downSampler->GetOutput(); + const ImageTypePtr2D outImage1 = downSampler->GetOutput(); PrintImageData(outImage1); // interp->Print( std::cout ); // PrintImageData(image); // upSampler->SetInput( downSampler->GetOutput() ); upSampler->SetInput(outImage1); upSampler->Update(); - ImageTypePtr2D outImage2 = upSampler->GetOutput(); + const ImageTypePtr2D outImage2 = upSampler->GetOutput(); PrintImageData(outImage2); bool sameResults = false; diff --git a/Modules/Filtering/ImageGrid/test/itkBSplineScatteredDataPointSetToImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkBSplineScatteredDataPointSetToImageFilterTest.cxx index 58ac224fa7a..e0aa7a5be95 100644 --- a/Modules/Filtering/ImageGrid/test/itkBSplineScatteredDataPointSetToImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkBSplineScatteredDataPointSetToImageFilterTest.cxx @@ -72,7 +72,7 @@ itkBSplineScatteredDataPointSetToImageFilterTest(int argc, char * argv[]) PointSetType::PointType point; reader->GetOutput()->TransformIndexToPhysicalPoint(It.GetIndex(), point); - unsigned long i = pointSet->GetNumberOfPoints(); + const unsigned long i = pointSet->GetNumberOfPoints(); pointSet->SetPoint(i, point); auto V = itk::MakeFilled(DataDimension); @@ -120,7 +120,7 @@ itkBSplineScatteredDataPointSetToImageFilterTest(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(ncps, filter->GetNumberOfControlPoints()); - FilterType::ArrayType close{}; + const FilterType::ArrayType close{}; filter->SetCloseDimension(close); ITK_TEST_SET_GET_VALUE(close, filter->GetCloseDimension()); diff --git a/Modules/Filtering/ImageGrid/test/itkBSplineScatteredDataPointSetToImageFilterTest2.cxx b/Modules/Filtering/ImageGrid/test/itkBSplineScatteredDataPointSetToImageFilterTest2.cxx index f401bc813b0..108b98cf184 100644 --- a/Modules/Filtering/ImageGrid/test/itkBSplineScatteredDataPointSetToImageFilterTest2.cxx +++ b/Modules/Filtering/ImageGrid/test/itkBSplineScatteredDataPointSetToImageFilterTest2.cxx @@ -55,7 +55,7 @@ itkBSplineScatteredDataPointSetToImageFilterTest2(int argc, char * argv[]) // Sample the helix for (RealType t = 0.0; t <= 1.0 + 1e-10; t += 0.05) { - unsigned long i = pointSet->GetNumberOfPoints(); + const unsigned long i = pointSet->GetNumberOfPoints(); PointSetType::PointType point; point[0] = t; @@ -77,16 +77,16 @@ itkBSplineScatteredDataPointSetToImageFilterTest2(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, BSplineScatteredDataPointSetToImageFilter, PointSetToImageFilter); // Define the parametric domain - auto spacing = itk::MakeFilled(0.01); - auto size = ImageType::SizeType::Filled(101); - ImageType::PointType origin{}; + auto spacing = itk::MakeFilled(0.01); + auto size = ImageType::SizeType::Filled(101); + const ImageType::PointType origin{}; filter->SetSize(size); filter->SetOrigin(origin); filter->SetSpacing(spacing); filter->SetInput(pointSet); - FilterType::RealType bSplineEpsilon = 1e-4; + const FilterType::RealType bSplineEpsilon = 1e-4; filter->SetBSplineEpsilon(bSplineEpsilon); ITK_TEST_SET_GET_VALUE(bSplineEpsilon, filter->GetBSplineEpsilon()); @@ -96,9 +96,9 @@ itkBSplineScatteredDataPointSetToImageFilterTest2(int argc, char * argv[]) filter->SetNumberOfLevels(5); filter->SetGenerateOutputImage(false); - FilterType::WeightsContainerType::Pointer pointWeights = FilterType::WeightsContainerType::New(); + const FilterType::WeightsContainerType::Pointer pointWeights = FilterType::WeightsContainerType::New(); - unsigned int abritrarySize = filter->GetInput()->GetNumberOfPoints() - 1; + const unsigned int abritrarySize = filter->GetInput()->GetNumberOfPoints() - 1; pointWeights->resize(abritrarySize); for (unsigned int i = 0; i < pointWeights->Size(); ++i) { diff --git a/Modules/Filtering/ImageGrid/test/itkBSplineScatteredDataPointSetToImageFilterTest3.cxx b/Modules/Filtering/ImageGrid/test/itkBSplineScatteredDataPointSetToImageFilterTest3.cxx index 9ab0504c88d..bdf33501bbb 100644 --- a/Modules/Filtering/ImageGrid/test/itkBSplineScatteredDataPointSetToImageFilterTest3.cxx +++ b/Modules/Filtering/ImageGrid/test/itkBSplineScatteredDataPointSetToImageFilterTest3.cxx @@ -98,7 +98,7 @@ itkBSplineScatteredDataPointSetToImageFilterTest3(int argc, char * argv[]) ImageType::SizeType size; // Adding 0.5 to avoid rounding errors size.Fill(static_cast(1.0 / spacing[0] + .5) + 1); - ImageType::PointType origin{}; + const ImageType::PointType origin{}; filter->SetSize(size); filter->SetOrigin(origin); @@ -113,7 +113,7 @@ itkBSplineScatteredDataPointSetToImageFilterTest3(int argc, char * argv[]) // fails because of the choice of B-spline epsilon filter->SetNumberOfLevels(15); - bool generateOutputImage = true; + const bool generateOutputImage = true; filter->SetGenerateOutputImage(generateOutputImage); ITK_TEST_SET_GET_VALUE(generateOutputImage, filter->GetGenerateOutputImage()); @@ -127,7 +127,7 @@ itkBSplineScatteredDataPointSetToImageFilterTest3(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); // Get the filter output - ImageType::Pointer outputImage = filter->GetOutput(); + const ImageType::Pointer outputImage = filter->GetOutput(); // Cast the output image using CastImageFilterType = itk::CastImageFilter; diff --git a/Modules/Filtering/ImageGrid/test/itkBSplineScatteredDataPointSetToImageFilterTest4.cxx b/Modules/Filtering/ImageGrid/test/itkBSplineScatteredDataPointSetToImageFilterTest4.cxx index 2bc98116936..44ed1acb857 100644 --- a/Modules/Filtering/ImageGrid/test/itkBSplineScatteredDataPointSetToImageFilterTest4.cxx +++ b/Modules/Filtering/ImageGrid/test/itkBSplineScatteredDataPointSetToImageFilterTest4.cxx @@ -47,10 +47,10 @@ itkBSplineScatteredDataPointSetToImageFilterTest4(int, char *[]) using FilterType = itk::BSplineScatteredDataPointSetToImageFilter; - auto size = VectorImageType::SizeType::Filled(100); - VectorImageType::PointType origin{}; - auto spacing = itk::MakeFilled(1); - VectorImageType::DirectionType direction; + auto size = VectorImageType::SizeType::Filled(100); + const VectorImageType::PointType origin{}; + auto spacing = itk::MakeFilled(1); + VectorImageType::DirectionType direction; direction.SetIdentity(); // Instantiate example corresponding points with relative weighting @@ -72,7 +72,7 @@ itkBSplineScatteredDataPointSetToImageFilterTest4(int, char *[]) landmarkInSecondImage1[1] = 5.0; landmarkInSecondImage1[2] = 5.0; - RealType weight1 = 1.0; + const RealType weight1 = 1.0; weights->InsertElement(0, weight1); VectorType vector1; @@ -95,7 +95,7 @@ itkBSplineScatteredDataPointSetToImageFilterTest4(int, char *[]) landmarkInSecondImage2[1] = 35.0; landmarkInSecondImage2[2] = 45.0; - RealType weight2 = 3.0; + const RealType weight2 = 3.0; weights->InsertElement(1, weight2); VectorType vector2; @@ -118,7 +118,7 @@ itkBSplineScatteredDataPointSetToImageFilterTest4(int, char *[]) landmarkInSecondImage3[1] = 35.0; landmarkInSecondImage3[2] = 45.0; - RealType weight3 = 0.5; + const RealType weight3 = 0.5; weights->InsertElement(2, weight3); VectorType vector3; @@ -158,7 +158,7 @@ itkBSplineScatteredDataPointSetToImageFilterTest4(int, char *[]) auto ncps = itk::MakeFilled(4); filter->SetNumberOfControlPoints(ncps); filter->SetNumberOfLevels(3); - FilterType::ArrayType close{}; + const FilterType::ArrayType close{}; filter->SetCloseDimension(close); @@ -192,7 +192,7 @@ itkBSplineScatteredDataPointSetToImageFilterTest4(int, char *[]) auto inputPoint = itk::MakeFilled(50.0); - OutputPointType outputPoint = transform->TransformPoint(inputPoint); + const OutputPointType outputPoint = transform->TransformPoint(inputPoint); // Now instantiate an interpolator to get an approximation of what // the transform should produce @@ -204,9 +204,9 @@ itkBSplineScatteredDataPointSetToImageFilterTest4(int, char *[]) VectorImageType::PointType testPoint; testPoint.CastFrom(inputPoint); - VectorType vector = interpolator->Evaluate(testPoint); - RealType testDistance = vector.GetNorm(); - RealType approximateDistance = inputPoint.EuclideanDistanceTo(outputPoint); + VectorType vector = interpolator->Evaluate(testPoint); + const RealType testDistance = vector.GetNorm(); + const RealType approximateDistance = inputPoint.EuclideanDistanceTo(outputPoint); VectorImageType::PointType approximateOutputPoint; for (unsigned int d = 0; d < DataDimension; ++d) diff --git a/Modules/Filtering/ImageGrid/test/itkBSplineScatteredDataPointSetToImageFilterTest5.cxx b/Modules/Filtering/ImageGrid/test/itkBSplineScatteredDataPointSetToImageFilterTest5.cxx index 027bbe36646..fc1fe3c0da8 100644 --- a/Modules/Filtering/ImageGrid/test/itkBSplineScatteredDataPointSetToImageFilterTest5.cxx +++ b/Modules/Filtering/ImageGrid/test/itkBSplineScatteredDataPointSetToImageFilterTest5.cxx @@ -36,7 +36,7 @@ makeTestableScalarImage(typename InternalImageType::Pointer internalImage, std:: using OutputPixelType = uint8_t; using OutputImageType = itk::Image; - OutputImageType::Pointer outputImage = OutputImageType::New(); + const OutputImageType::Pointer outputImage = OutputImageType::New(); outputImage->CopyInformation(internalImage); outputImage->SetRegions(internalImage->GetBufferedRegion()); outputImage->AllocateInitialized(); @@ -144,7 +144,7 @@ itkBSplineScatteredDataPointSetToImageFilterTest5(int argc, char * argv[]) size[0] = 1000; size[1] = 100; - ImageType::PointType origin{}; + const ImageType::PointType origin{}; filter->SetSize(size); filter->SetOrigin(origin); diff --git a/Modules/Filtering/ImageGrid/test/itkBSplineUpsampleImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkBSplineUpsampleImageFilterTest.cxx index 1c3c174aebd..c800d16bc6f 100644 --- a/Modules/Filtering/ImageGrid/test/itkBSplineUpsampleImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkBSplineUpsampleImageFilterTest.cxx @@ -55,7 +55,7 @@ itkBSplineUpsampleImageFilterTest(int argc, char * argv[]) auto filter = UpsamplerFilterType::New(); - itk::SimpleFilterWatcher watcher(filter, "BSplineUpsampleImageFilter"); + const itk::SimpleFilterWatcher watcher(filter, "BSplineUpsampleImageFilter"); using ReaderType = itk::ImageFileReader; auto reader = ReaderType::New(); diff --git a/Modules/Filtering/ImageGrid/test/itkBasicArchitectureTest.cxx b/Modules/Filtering/ImageGrid/test/itkBasicArchitectureTest.cxx index de34661b1e9..880f6d8e461 100644 --- a/Modules/Filtering/ImageGrid/test/itkBasicArchitectureTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkBasicArchitectureTest.cxx @@ -157,7 +157,7 @@ itkBasicArchitectureTest(int, char *[]) itk::SimpleMemberCommand::Pointer end; end = itk::SimpleMemberCommand::New(); end->SetCallbackFunction(&startEndWatch, &StartEndEvent::End); - unsigned long endEventObserverTag = shrink->AddObserver(itk::EndEvent(), end); + const unsigned long endEventObserverTag = shrink->AddObserver(itk::EndEvent(), end); ITK_TEST_EXPECT_TRUE(shrink->HasObserver(itk::EndEvent())); // Create a command that to call AnyEvent when event is fired @@ -165,7 +165,7 @@ itkBasicArchitectureTest(int, char *[]) itk::MemberCommand::Pointer allEvents; allEvents = itk::MemberCommand::New(); allEvents->SetCallbackFunction(&allWatch, &AllEvents::WatchEvents); - unsigned long anyEventObserverTag = shrink->AddObserver(itk::AnyEvent(), allEvents); + const unsigned long anyEventObserverTag = shrink->AddObserver(itk::AnyEvent(), allEvents); ITK_TEST_EXPECT_TRUE(shrink->HasObserver(itk::AnyEvent())); shrink->Update(); diff --git a/Modules/Filtering/ImageGrid/test/itkBinShrinkImageFilterTest1.cxx b/Modules/Filtering/ImageGrid/test/itkBinShrinkImageFilterTest1.cxx index b8363515245..9068c52e142 100644 --- a/Modules/Filtering/ImageGrid/test/itkBinShrinkImageFilterTest1.cxx +++ b/Modules/Filtering/ImageGrid/test/itkBinShrinkImageFilterTest1.cxx @@ -306,7 +306,7 @@ itkBinShrinkImageFilterTest1(int, char *[]) bool lfailed = false; for (inIt.GoToBegin(); !inIt.IsAtEnd(); ++inIt) { - int expectedValue = inIt.GetIndex()[0] * 10; + const int expectedValue = inIt.GetIndex()[0] * 10; if (inIt.Get() != expectedValue) { if (!lfailed) diff --git a/Modules/Filtering/ImageGrid/test/itkChangeInformationImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkChangeInformationImageFilterTest.cxx index 94c878caaa7..1c2dbb2a0ae 100644 --- a/Modules/Filtering/ImageGrid/test/itkChangeInformationImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkChangeInformationImageFilterTest.cxx @@ -159,8 +159,8 @@ itkChangeInformationImageFilterTest(int, char *[]) inputImage->SetSpacing(spacing); inputImage->SetOrigin(origin); - itk::SpacePrecisionType newOrigin[ImageDimension] = { 1000.0, 2000.0, 3000.0 }; - itk::SpacePrecisionType newSpacing[ImageDimension] = { 10.0, 20.0, 30.0 }; + const itk::SpacePrecisionType newOrigin[ImageDimension] = { 1000.0, 2000.0, 3000.0 }; + itk::SpacePrecisionType newSpacing[ImageDimension] = { 10.0, 20.0, 30.0 }; ImageType::OffsetValueType newOffset[ImageDimension] = { 10, 20, 30 }; @@ -188,7 +188,7 @@ itkChangeInformationImageFilterTest(int, char *[]) std::cout << "filter->GetReferenceImage(): " << referenceImage2 << std::endl; // Test GetMacros - bool useReferenceImage = filter->GetUseReferenceImage(); + const bool useReferenceImage = filter->GetUseReferenceImage(); std::cout << "filter->GetUseReferenceImage(): " << useReferenceImage << std::endl; const ArrayType outputSpacing = filter->GetOutputSpacing(); std::cout << "filter->GetOutputSpacing(): " << outputSpacing << std::endl; @@ -199,19 +199,19 @@ itkChangeInformationImageFilterTest(int, char *[]) const ImageType::DirectionType outputDirection = filter->GetOutputDirection(); std::cout << "filter->GetOutputDirection(): " << std::endl << outputDirection << std::endl; - bool changeSpacing = filter->GetChangeSpacing(); + const bool changeSpacing = filter->GetChangeSpacing(); std::cout << "filter->GetChangeSpacing(): " << changeSpacing << std::endl; - bool changeOrigin = filter->GetChangeOrigin(); + const bool changeOrigin = filter->GetChangeOrigin(); std::cout << "filter->GetChangeOrigin(): " << changeOrigin << std::endl; - bool changeDirection = filter->GetChangeDirection(); + const bool changeDirection = filter->GetChangeDirection(); std::cout << "filter->GetChangeDirection(): " << changeDirection << std::endl; - bool changeRegion = filter->GetChangeRegion(); + const bool changeRegion = filter->GetChangeRegion(); std::cout << "filter->GetChangeRegion(): " << changeRegion << std::endl; - bool centerImage = filter->GetCenterImage(); + const bool centerImage = filter->GetCenterImage(); std::cout << "filter->GetCenterImage(): " << centerImage << std::endl; // Test GetVectorMacro diff --git a/Modules/Filtering/ImageGrid/test/itkConstantPadImageTest.cxx b/Modules/Filtering/ImageGrid/test/itkConstantPadImageTest.cxx index 75d34901822..36a0211dcae 100644 --- a/Modules/Filtering/ImageGrid/test/itkConstantPadImageTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkConstantPadImageTest.cxx @@ -51,8 +51,8 @@ itkConstantPadImageTest(int, char *[]) // Create a filter using PadFilterType = itk::ConstantPadImageFilter; - auto constantPad = PadFilterType::New(); - itk::SimpleFilterWatcher watch(constantPad); + auto constantPad = PadFilterType::New(); + const itk::SimpleFilterWatcher watch(constantPad); constantPad->SetInput(image); using SizeValueType = ShortImage::SizeValueType; @@ -64,7 +64,7 @@ itkConstantPadImageTest(int, char *[]) constexpr float constant = 13.3f; constantPad->SetConstant(constant); // check the method using the SizeType rather than the simple table type. - ShortImage::SizeType stfactors{}; + const ShortImage::SizeType stfactors{}; constantPad->SetPadLowerBound(stfactors); constantPad->SetPadUpperBound(stfactors); constantPad->SetPadBound(stfactors); @@ -100,8 +100,8 @@ itkConstantPadImageTest(int, char *[]) !iteratorIn1.IsAtEnd(); ++iteratorIn1) { - int row = iteratorIn1.GetIndex()[0]; - int column = iteratorIn1.GetIndex()[1]; + const int row = iteratorIn1.GetIndex()[0]; + const int column = iteratorIn1.GetIndex()[1]; if ((row < 0) || (row > 7) || (column < 0) || (column > 11)) { if (itk::Math::NotExactlyEquals(iteratorIn1.Get(), constant)) @@ -111,7 +111,7 @@ itkConstantPadImageTest(int, char *[]) } else { - int nextVal = 8 * column + row; + const int nextVal = 8 * column + row; if (itk::Math::NotExactlyEquals(iteratorIn1.Get(), nextVal)) { std::cout << "Error: (" << row << ", " << column << "), expected " << nextVal << " got " << iteratorIn1.Get() @@ -172,8 +172,8 @@ itkConstantPadImageTest(int, char *[]) !iteratorIn2.IsAtEnd(); ++iteratorIn2) { - int row = iteratorIn2.GetIndex()[0]; - int column = iteratorIn2.GetIndex()[1]; + const int row = iteratorIn2.GetIndex()[0]; + const int column = iteratorIn2.GetIndex()[1]; if ((row < 0) || (row > 7) || (column < 0) || (column > 11)) { if (itk::Math::NotExactlyEquals(iteratorIn2.Get(), constant)) @@ -183,7 +183,7 @@ itkConstantPadImageTest(int, char *[]) } else { - int nextVal = 8 * column + row; + const int nextVal = 8 * column + row; if (itk::Math::NotExactlyEquals(iteratorIn2.Get(), nextVal)) { std::cout << "Error: (" << row << ", " << column << "), expected " << nextVal << " got " diff --git a/Modules/Filtering/ImageGrid/test/itkCoxDeBoorBSplineKernelFunctionTest2.cxx b/Modules/Filtering/ImageGrid/test/itkCoxDeBoorBSplineKernelFunctionTest2.cxx index 36be09cf087..d0ee2991554 100644 --- a/Modules/Filtering/ImageGrid/test/itkCoxDeBoorBSplineKernelFunctionTest2.cxx +++ b/Modules/Filtering/ImageGrid/test/itkCoxDeBoorBSplineKernelFunctionTest2.cxx @@ -36,7 +36,7 @@ itkCoxDeBoorBSplineKernelFunctionTest2(int, char *[]) for (double t = 0.0; t < static_cast(0.5 * (order + 1)); t += 0.1) { - KernelType::RealType derivative = kernel->EvaluateDerivative(t); + const KernelType::RealType derivative = kernel->EvaluateDerivative(t); if (itk::Math::abs(derivative - (kernelOrderMinus1->Evaluate(t + 0.5) - kernelOrderMinus1->Evaluate(t - 0.5))) > 1e-10) { diff --git a/Modules/Filtering/ImageGrid/test/itkCropImageFilter3DTest.cxx b/Modules/Filtering/ImageGrid/test/itkCropImageFilter3DTest.cxx index 22491865377..00370c2e0dd 100644 --- a/Modules/Filtering/ImageGrid/test/itkCropImageFilter3DTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkCropImageFilter3DTest.cxx @@ -33,10 +33,10 @@ itkCropImageFilter3DTest(int, char *[]) // Declare the types of the images using ImageType = itk::Image; - ImageType::RegionType region; - const unsigned int dimSize(8); - ImageType::RegionType::SizeType size = { { dimSize, dimSize, dimSize } }; - ImageType::RegionType::IndexType index = { { 0, 0, 0 } }; + ImageType::RegionType region; + const unsigned int dimSize(8); + const ImageType::RegionType::SizeType size = { { dimSize, dimSize, dimSize } }; + const ImageType::RegionType::IndexType index = { { 0, 0, 0 } }; region.SetSize(size); region.SetIndex(index); @@ -51,14 +51,15 @@ itkCropImageFilter3DTest(int, char *[]) it.Set(i); } - itk::CropImageFilter::Pointer cropFilter = itk::CropImageFilter::New(); + const itk::CropImageFilter::Pointer cropFilter = + itk::CropImageFilter::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(cropFilter, CropImageFilter, ExtractImageFilter); cropFilter->SetInput(image); // Set the filter properties - ImageType::SizeType extractSize = { { 1, 1, 1 } }; + const ImageType::SizeType extractSize = { { 1, 1, 1 } }; cropFilter->SetBoundaryCropSize(extractSize); @@ -70,7 +71,7 @@ itkCropImageFilter3DTest(int, char *[]) ITK_TRY_EXPECT_NO_EXCEPTION(cropFilter->Update()); - ImageType::Pointer croppedImage = cropFilter->GetOutput(); + const ImageType::Pointer croppedImage = cropFilter->GetOutput(); // check size of cropped image ImageType::RegionType::SizeType croppedSize = croppedImage->GetLargestPossibleRegion().GetSize(); @@ -83,9 +84,9 @@ itkCropImageFilter3DTest(int, char *[]) return EXIT_FAILURE; } } - ImageType::RegionType subRegion; - ImageType::RegionType::SizeType subSize = { { dimSize - 2, dimSize - 2, dimSize - 2 } }; - ImageType::RegionType::IndexType subIndex = { { 1, 1, 1 } }; + ImageType::RegionType subRegion; + const ImageType::RegionType::SizeType subSize = { { dimSize - 2, dimSize - 2, dimSize - 2 } }; + const ImageType::RegionType::IndexType subIndex = { { 1, 1, 1 } }; subRegion.SetSize(subSize); subRegion.SetIndex(subIndex); diff --git a/Modules/Filtering/ImageGrid/test/itkCropImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkCropImageFilterTest.cxx index d752ec84074..ca6d1c648fc 100644 --- a/Modules/Filtering/ImageGrid/test/itkCropImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkCropImageFilterTest.cxx @@ -37,9 +37,9 @@ itkCropImageFilterTest(int, char *[]) auto inputImage = ImageType::New(); // Fill in the image - ImageType::IndexType index = { { 0, 0 } }; - ImageType::SizeType size = { { 8, 12 } }; - ImageType::RegionType region; + const ImageType::IndexType index = { { 0, 0 } }; + const ImageType::SizeType size = { { 8, 12 } }; + ImageType::RegionType region; region.SetSize(size); region.SetIndex(index); @@ -56,11 +56,12 @@ itkCropImageFilterTest(int, char *[]) } // Create the filter - itk::CropImageFilter::Pointer cropFilter = itk::CropImageFilter::New(); + const itk::CropImageFilter::Pointer cropFilter = + itk::CropImageFilter::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(cropFilter, CropImageFilter, ExtractImageFilter); - itk::SimpleFilterWatcher watcher(cropFilter); + const itk::SimpleFilterWatcher watcher(cropFilter); cropFilter->SetInput(inputImage); diff --git a/Modules/Filtering/ImageGrid/test/itkCyclicReferences.cxx b/Modules/Filtering/ImageGrid/test/itkCyclicReferences.cxx index 6258e281424..c2941df7307 100644 --- a/Modules/Filtering/ImageGrid/test/itkCyclicReferences.cxx +++ b/Modules/Filtering/ImageGrid/test/itkCyclicReferences.cxx @@ -56,7 +56,7 @@ itkCyclicReferences(int, char *[]) // Test the deletion of an image with native type. // (scope operators cause automatic smart pointer destruction) { // image - itk::Image::Pointer if2 = itk::Image::New(); + const itk::Image::Pointer if2 = itk::Image::New(); DeleteEvent deleteEvent; itk::MemberCommand::Pointer deleteCommand; deleteCommand = itk::MemberCommand::New(); diff --git a/Modules/Filtering/ImageGrid/test/itkCyclicShiftImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkCyclicShiftImageFilterTest.cxx index a73f17e6510..b12a5fc3138 100644 --- a/Modules/Filtering/ImageGrid/test/itkCyclicShiftImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkCyclicShiftImageFilterTest.cxx @@ -75,7 +75,7 @@ itkCyclicShiftImageFilterTest(int argc, char * argv[]) shiftFilter->UpdateLargestPossibleRegion(); itk::ImageRegionConstIteratorWithIndex inputIter(reader->GetOutput(), reader->GetOutput()->GetLargestPossibleRegion()); - ImageType::RegionType imageRegion = reader->GetOutput()->GetLargestPossibleRegion(); + const ImageType::RegionType imageRegion = reader->GetOutput()->GetLargestPossibleRegion(); ImageType::SizeType imageSize = imageRegion.GetSize(); bool success = true; @@ -83,7 +83,7 @@ itkCyclicShiftImageFilterTest(int argc, char * argv[]) for (; !inputIter.IsAtEnd(); ++inputIter) { - ImageType::IndexType inputIndex = inputIter.GetIndex(); + const ImageType::IndexType inputIndex = inputIter.GetIndex(); CyclicShiftFilterType::IndexType outputIndex(inputIndex); for (unsigned int i = 0; i < Dimension; ++i) @@ -96,8 +96,8 @@ itkCyclicShiftImageFilterTest(int argc, char * argv[]) outputIndex[i] += newOrigin[i]; } - PixelType inputPixel = inputIter.Get(); - PixelType outputPixel = shiftFilterOutput->GetPixel(outputIndex); + const PixelType inputPixel = inputIter.Get(); + const PixelType outputPixel = shiftFilterOutput->GetPixel(outputIndex); if (inputPixel != outputPixel) { diff --git a/Modules/Filtering/ImageGrid/test/itkExpandImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkExpandImageFilterTest.cxx index 160fd2f99a5..1e5817166cc 100644 --- a/Modules/Filtering/ImageGrid/test/itkExpandImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkExpandImageFilterTest.cxx @@ -82,8 +82,8 @@ itkExpandImageFilterTest(int, char *[]) int testPassed = EXIT_SUCCESS; std::cout << "Create the input image pattern." << std::endl; - ImageType::RegionType region; - ImageType::SizeType size = { { 64, 64 } }; + ImageType::RegionType region; + const ImageType::SizeType size = { { 64, 64 } }; region.SetSize(size); auto input = ImageType::New(); @@ -119,8 +119,8 @@ itkExpandImageFilterTest(int, char *[]) expander->SetExpandFactors(5); - unsigned int factors[ImageDimension] = { 2, 3 }; - ImageType::PixelType padValue = 4.0; + unsigned int factors[ImageDimension] = { 2, 3 }; + const ImageType::PixelType padValue = 4.0; expander->SetInput(input); expander->SetExpandFactors(factors); // TEST_RMV20100728 expander->SetEdgePaddingValue( padValue ); @@ -139,8 +139,8 @@ itkExpandImageFilterTest(int, char *[]) Iterator outIter(expander->GetOutput(), expander->GetOutput()->GetBufferedRegion()); // compute non-padded output region - ImageType::RegionType validRegion = expander->GetOutput()->GetLargestPossibleRegion(); - ImageType::SizeType validSize = validRegion.GetSize(); + ImageType::RegionType validRegion = expander->GetOutput()->GetLargestPossibleRegion(); + const ImageType::SizeType validSize = validRegion.GetSize(); validRegion.SetSize(validSize); @@ -148,18 +148,18 @@ itkExpandImageFilterTest(int, char *[]) while (!outIter.IsAtEnd()) { - ImageType::IndexType index = outIter.GetIndex(); - double value = outIter.Get(); + const ImageType::IndexType index = outIter.GetIndex(); + const double value = outIter.Get(); if (validRegion.IsInside(index)) { ImageType::PointType point; expanderOutput->TransformIndexToPhysicalPoint(outIter.GetIndex(), point); - ImageType::IndexType inputIndex = input->TransformPhysicalPointToIndex(point); - double trueValue = pattern.Evaluate(inputIndex); + const ImageType::IndexType inputIndex = input->TransformPhysicalPointToIndex(point); + const double trueValue = pattern.Evaluate(inputIndex); - double epsilon = 1e-4; + const double epsilon = 1e-4; if (itk::Math::abs(trueValue - value) > epsilon) { std::cerr.precision(static_cast(itk::Math::abs(std::log10(epsilon)))); diff --git a/Modules/Filtering/ImageGrid/test/itkExpandImageFilterTest2.cxx b/Modules/Filtering/ImageGrid/test/itkExpandImageFilterTest2.cxx index 80396ca5fea..a6c30f2a136 100644 --- a/Modules/Filtering/ImageGrid/test/itkExpandImageFilterTest2.cxx +++ b/Modules/Filtering/ImageGrid/test/itkExpandImageFilterTest2.cxx @@ -43,7 +43,7 @@ GetPattern(const typename TVectorImage::IndexType & index, unsigned int nImages) { typename TVectorImage::PixelType ans(nImages); - int d = TVectorImage::SizeType::Dimension; + const int d = TVectorImage::SizeType::Dimension; int volume = 1; for (int j = 0; j < d; ++j) @@ -80,7 +80,7 @@ std::string PrintTestImage1D(const TVectorImage * img) { std::string ans = ""; - unsigned int nImages = img->GetVectorLength(); + const unsigned int nImages = img->GetVectorLength(); typename TVectorImage::SizeType size = img->GetLargestPossibleRegion().GetSize(); for (unsigned int i = 0; i < nImages; ++i) @@ -108,7 +108,7 @@ std::string PrintTestImage3D(const TVectorImage * img) { std::string ans = ""; - unsigned int nImages = img->GetVectorLength(); + const unsigned int nImages = img->GetVectorLength(); typename TVectorImage::SizeType size = img->GetLargestPossibleRegion().GetSize(); for (unsigned int i = 0; i < nImages; ++i) @@ -193,9 +193,9 @@ itkExpandImageFilterTest2(int, char *[]) // Test 1D: A 5 pixel long 1D image with 2 channels. Using a NearestNeighborInterpolator for simplicity. Expanding // by 2. - VectorImage1D::SizeType size1D = { { 5 } }; + const VectorImage1D::SizeType size1D = { { 5 } }; - VectorImage1D::Pointer input1D = GetVectorTestImage(size1D, 2); + const VectorImage1D::Pointer input1D = GetVectorTestImage(size1D, 2); std::cout << "Output input1D:" << std::endl; std::cout << PrintTestImage1D(input1D) << std::endl; @@ -210,7 +210,7 @@ itkExpandImageFilterTest2(int, char *[]) expander1D->SetInput(input1D); expander1D->SetExpandFactors(factors1); expander1D->Update(); - VectorImage1D::Pointer output1D = expander1D->GetOutput(); + const VectorImage1D::Pointer output1D = expander1D->GetOutput(); std::cout << "Output 1D: " << std::endl; std::cout << PrintTestImage1D(output1D) << std::endl; @@ -240,8 +240,8 @@ itkExpandImageFilterTest2(int, char *[]) // Test 3D: a 3 x 3 4-channel image. Like above, incremental pixel values along each channel, dim 0, dim 1, dim 2. // Channel 1 values are 1-27, Channel 2 is 28-54, etc. Expanding by 2 along dim 1. - VectorImage3D::SizeType size3D = { { 3, 3, 3 } }; - VectorImage3D::Pointer input3D = GetVectorTestImage(size3D, 4); + const VectorImage3D::SizeType size3D = { { 3, 3, 3 } }; + const VectorImage3D::Pointer input3D = GetVectorTestImage(size3D, 4); std::cout << "Output input3D:" << std::endl; std::cout << PrintTestImage3D(input3D) << std::endl; @@ -258,7 +258,7 @@ itkExpandImageFilterTest2(int, char *[]) expander3D->SetExpandFactors(factors3); expander3D->Update(); - VectorImage3D::Pointer output3D = expander3D->GetOutput(); + const VectorImage3D::Pointer output3D = expander3D->GetOutput(); std::cout << "Output 3D: " << std::endl; std::cout << PrintTestImage3D(output3D) << std::endl; diff --git a/Modules/Filtering/ImageGrid/test/itkFlipImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkFlipImageFilterTest.cxx index 847b38169ec..23869e45d20 100644 --- a/Modules/Filtering/ImageGrid/test/itkFlipImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkFlipImageFilterTest.cxx @@ -41,9 +41,9 @@ itkFlipImageFilterTest(int argc, char * argv[]) using FlipperType = itk::FlipImageFilter; // Define a small input image - ImageType::IndexType index = { { 10, 20, 30 } }; - ImageType::SizeType size = { { 5, 4, 3 } }; - ImageType::RegionType region{ index, size }; + const ImageType::IndexType index = { { 10, 20, 30 } }; + const ImageType::SizeType size = { { 5, 4, 3 } }; + const ImageType::RegionType region{ index, size }; ImageType::SpacingType spacing; spacing[0] = 1.1; @@ -79,7 +79,7 @@ itkFlipImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(flipper, FlipImageFilter, ImageToImageFilter); - itk::SimpleFilterWatcher watcher(flipper, "FlipImageFilter"); + const itk::SimpleFilterWatcher watcher(flipper, "FlipImageFilter"); bool bArray[ImageDimension] = { true, false, true }; FlipperType::FlipAxesArrayType flipAxes(bArray); @@ -95,7 +95,7 @@ itkFlipImageFilterTest(int argc, char * argv[]) flipper->Update(); // Check the output - ImageType::Pointer outputImage = flipper->GetOutput(); + const ImageType::Pointer outputImage = flipper->GetOutput(); const ImageType::SpacingType & inputSpacing = inputImage->GetSpacing(); const ImageType::PointType & inputOrigin = inputImage->GetOrigin(); @@ -116,12 +116,13 @@ itkFlipImageFilterTest(int argc, char * argv[]) { if (flipAxes[j]) { - int sign = flipAboutOrigin ? -1 : 1; + const int sign = flipAboutOrigin ? -1 : 1; - ImageType::PointType::ValueType temp = + const ImageType::PointType::ValueType temp = sign * (static_cast(inputIndex[j]) * inputSpacing[j] + inputOrigin[j]); - ImageType::PointType::ValueType outputPoint = flipAboutOrigin ? temp - outputOrigin[j] : outputOrigin[j] - temp; + const ImageType::PointType::ValueType outputPoint = + flipAboutOrigin ? temp - outputOrigin[j] : outputOrigin[j] - temp; outputIndex[j] = itk::Math::Round(outputPoint / outputSpacing[j]); } diff --git a/Modules/Filtering/ImageGrid/test/itkInterpolateImagePointsFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkInterpolateImagePointsFilterTest.cxx index 723e4d9b24a..8421afbc14e 100644 --- a/Modules/Filtering/ImageGrid/test/itkInterpolateImagePointsFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkInterpolateImagePointsFilterTest.cxx @@ -90,7 +90,7 @@ test2DInterpolateImagePointsFilter() std::cout << "Testing 2D InterpolateImagePointsFilter at sample index locations.\n "; // Initialize input image - ImageType2DPointer image = ImageType2D::New(); + const ImageType2DPointer image = ImageType2D::New(); set2DInterpolateImagePointsFilterData(image); // Using Index Coordinates so setting of origin and spacing should // not change results. @@ -103,15 +103,15 @@ test2DInterpolateImagePointsFilter() constexpr int NPOINTS2 = 4; // number of points constexpr double DEFAULTPIXELVALUE = 1.23; // Arbitrary value to test setting - double xcoord[NPOINTS2] = { 0.1, 3.4, 4.0, 2.0 }; - double ycoord[NPOINTS2] = { 0.2, 5.8, 6.0, 7.0 }; - double truth[NPOINTS2] = { 151.650316034, 22.411473093, 36.2, DEFAULTPIXELVALUE }; + const double xcoord[NPOINTS2] = { 0.1, 3.4, 4.0, 2.0 }; + const double ycoord[NPOINTS2] = { 0.2, 5.8, 6.0, 7.0 }; + const double truth[NPOINTS2] = { 151.650316034, 22.411473093, 36.2, DEFAULTPIXELVALUE }; // Place continuous index coordinates into an image data structure - CoordImageType2DPointer index1 = CoordImageType2D::New(); - CoordImageType2DPointer index2 = CoordImageType2D::New(); + const CoordImageType2DPointer index1 = CoordImageType2D::New(); + const CoordImageType2DPointer index2 = CoordImageType2D::New(); - CoordImage2DSizeType size = { { 2, 2 } }; + const CoordImage2DSizeType size = { { 2, 2 } }; CoordImageType2D::RegionType region; region.SetSize(size); @@ -146,13 +146,13 @@ test2DInterpolateImagePointsFilter() ITK_EXERCISE_BASIC_OBJECT_METHODS(resamp, InterpolateImagePointsFilter, ImageToImageFilter); - unsigned int splineOrder = 3; + const unsigned int splineOrder = 3; resamp->GetInterpolator()->SetSplineOrder(splineOrder); resamp->SetInputImage(image); resamp->SetInterpolationCoordinate(index1, 0); resamp->SetInterpolationCoordinate(index2, 1); - InterpolatorType2D::PixelType defaultPixelValue = DEFAULTPIXELVALUE; + const InterpolatorType2D::PixelType defaultPixelValue = DEFAULTPIXELVALUE; resamp->SetDefaultPixelValue(defaultPixelValue); ITK_TEST_SET_GET_VALUE(defaultPixelValue, resamp->GetDefaultPixelValue()); @@ -165,10 +165,10 @@ test2DInterpolateImagePointsFilter() outputImage = resamp->GetOutput(); InputIterator outIter(outputImage, region); int i = 0; - double epsilon = 1e-9; + const double epsilon = 1e-9; while (!outIter.IsAtEnd()) { - double value = outIter.Get(); + const double value = outIter.Get(); std::cout.width(10); std::cout.precision(static_cast(itk::Math::abs(std::log10(epsilon)))); std::cout << "Checking image value: " << value << std::endl; @@ -197,14 +197,14 @@ test3DInterpolateImagePointsFilter() std::cout << "Testing 3D InterpolateImagePointsFilter.\n "; // Initialize input image - ImageTypePtr3D image = set3DData(); + const ImageTypePtr3D image = set3DData(); // Initialize InterpolateImagePointsFilter and set input image auto resamp = InterpolatorType3D::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(resamp, InterpolateImagePointsFilter, ImageToImageFilter); - unsigned int splineOrder = 3; + const unsigned int splineOrder = 3; resamp->GetInterpolator()->SetSplineOrder(splineOrder); resamp->SetInputImage(image); @@ -215,7 +215,7 @@ test3DInterpolateImagePointsFilter() region.SetSize(size); for (auto & i : coord) { - CoordImageType3DPointer temp = CoordImageType3D::New(); + const CoordImageType3DPointer temp = CoordImageType3D::New(); i = temp; i->SetLargestPossibleRegion(region); i->SetBufferedRegion(region); @@ -258,7 +258,7 @@ test3DInterpolateImagePointsFilter() double rmse = 0.0; while (!outIter.IsAtEnd()) { - double temp = inIter.Get() - outIter.Get(); + const double temp = inIter.Get() - outIter.Get(); rmse += temp * temp; ++outIter; ++inIter; @@ -267,7 +267,7 @@ test3DInterpolateImagePointsFilter() // Write home and let mom & dad know how we're doing. std::cout << "rmse of image is " << rmse << "\n "; - double epsilon = 1e-7; + const double epsilon = 1e-7; std::cout.precision(static_cast(itk::Math::abs(std::log10(epsilon)))); if (!itk::Math::FloatAlmostEqual(rmse, 0.0, 10, epsilon)) { @@ -288,7 +288,7 @@ itkInterpolateImagePointsFilterTest(int, char *[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope // scope. - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); int testStatus = EXIT_SUCCESS; @@ -313,13 +313,13 @@ itkInterpolateImagePointsFilterTest(int, char *[]) void set2DInterpolateImagePointsFilterData(ImageType2D::Pointer imgPtr) { - ImageType2DSizeType size = { { 7, 7 } }; - double mydata[49] = { 154.5000, 82.4000, 30.9000, 0, -10.3000, 0, 30.9000, 117.0000, 62.4000, - 23.4000, 0, -7.8000, 0, 23.4000, 18.0000, 9.6000, 3.6000, 0, - -1.2000, 0, 3.6000, -120.0000, -64.0000, -24.0000, 0, 8.0000, 0, - -24.0000, -274.5000, -146.4000, -54.9000, 0, 18.3000, 0, -54.9000, -423.0000, - -225.6000, -84.6000, 0, 28.2000, 0, -84.6000, -543.0000, -289.6000, -108.6000, - 0, 36.2000, 0, -108.6000 }; + const ImageType2DSizeType size = { { 7, 7 } }; + const double mydata[49] = { + 154.5000, 82.4000, 30.9000, 0, -10.3000, 0, 30.9000, 117.0000, 62.4000, 23.4000, 0, -7.8000, 0, 23.4000, + 18.0000, 9.6000, 3.6000, 0, -1.2000, 0, 3.6000, -120.0000, -64.0000, -24.0000, 0, 8.0000, 0, -24.0000, + -274.5000, -146.4000, -54.9000, 0, 18.3000, 0, -54.9000, -423.0000, -225.6000, -84.6000, 0, 28.2000, 0, -84.6000, + -543.0000, -289.6000, -108.6000, 0, 36.2000, 0, -108.6000 + }; ImageType2D::RegionType region; region.SetSize(size); @@ -349,9 +349,9 @@ set3DData() using GaussianSourceType = itk::GaussianImageSource; auto pSource = GaussianSourceType::New(); - ImageType3D::SpacingValueType spacing[] = { 1.2f, 1.3f, 1.4f }; - ImageType3D::PointValueType origin[] = { 1.0f, 4.0f, 2.0f }; - ImageType3D::SizeValueType size[] = { 65, 75, 60 }; + ImageType3D::SpacingValueType spacing[] = { 1.2f, 1.3f, 1.4f }; + const ImageType3D::PointValueType origin[] = { 1.0f, 4.0f, 2.0f }; + ImageType3D::SizeValueType size[] = { 65, 75, 60 }; GaussianSourceType::ArrayType mean; mean[0] = size[0] / 2.0f + origin[0]; diff --git a/Modules/Filtering/ImageGrid/test/itkMirrorPadImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkMirrorPadImageFilterTest.cxx index ffe949013c4..ab52f2e18f4 100644 --- a/Modules/Filtering/ImageGrid/test/itkMirrorPadImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkMirrorPadImageFilterTest.cxx @@ -50,7 +50,7 @@ RunTest(int argc, char * argv[]) if (argc > 4) { - double decayFactor = std::stod(argv[4]); + const double decayFactor = std::stod(argv[4]); filter->SetDecayBase(decayFactor); ITK_TEST_SET_GET_VALUE(decayFactor, filter->GetDecayBase()); } diff --git a/Modules/Filtering/ImageGrid/test/itkMirrorPadImageTest.cxx b/Modules/Filtering/ImageGrid/test/itkMirrorPadImageTest.cxx index af70548b058..8147ff68c16 100644 --- a/Modules/Filtering/ImageGrid/test/itkMirrorPadImageTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkMirrorPadImageTest.cxx @@ -73,7 +73,7 @@ VerifyPixel(int row, int col, int val) col -= 12; colVal = col; } - int nextVal = 8 * colVal + rowVal; + const int nextVal = 8 * colVal + rowVal; return (val == nextVal); } } // namespace @@ -112,9 +112,9 @@ itkMirrorPadImageTest(int, char *[]) } } // Create a filter - itk::MirrorPadImageFilter::Pointer mirrorPad = + const itk::MirrorPadImageFilter::Pointer mirrorPad = itk::MirrorPadImageFilter::New(); - itk::SimpleFilterWatcher watcher(mirrorPad); + const itk::SimpleFilterWatcher watcher(mirrorPad); mirrorPad->SetInput(if2); @@ -159,8 +159,8 @@ itkMirrorPadImageTest(int, char *[]) !iteratorIn1.IsAtEnd(); ++iteratorIn1) { - int row = iteratorIn1.GetIndex()[0]; - int column = iteratorIn1.GetIndex()[1]; + const int row = iteratorIn1.GetIndex()[0]; + const int column = iteratorIn1.GetIndex()[1]; if (!VerifyPixel(row, column, iteratorIn1.Get())) { std::cout << "Error: (" << row << ", " << column << "), got " << iteratorIn1.Get() << std::endl; @@ -211,8 +211,8 @@ itkMirrorPadImageTest(int, char *[]) !iteratorIn2.IsAtEnd(); ++iteratorIn2) { - int row = iteratorIn2.GetIndex()[0]; - int column = iteratorIn2.GetIndex()[1]; + const int row = iteratorIn2.GetIndex()[0]; + const int column = iteratorIn2.GetIndex()[1]; if (!VerifyPixel(row, column, iteratorIn2.Get())) { std::cout << "Error: (" << row << ", " << column << "), got " << iteratorIn2.Get() << std::endl; @@ -270,8 +270,8 @@ itkMirrorPadImageTest(int, char *[]) !iteratorIn3.IsAtEnd(); ++iteratorIn3) { - int row = iteratorIn3.GetIndex()[0]; - int column = iteratorIn3.GetIndex()[1]; + const int row = iteratorIn3.GetIndex()[0]; + const int column = iteratorIn3.GetIndex()[1]; if (!VerifyPixel(row, column, iteratorIn3.Get())) { std::cout << "Error: (" << row << ", " << column << "), got " << iteratorIn3.Get() << std::endl; diff --git a/Modules/Filtering/ImageGrid/test/itkOrientImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkOrientImageFilterTest.cxx index 6c31f081934..8371ae71087 100644 --- a/Modules/Filtering/ImageGrid/test/itkOrientImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkOrientImageFilterTest.cxx @@ -26,10 +26,10 @@ using ImageType = itk::Image; ImageType::Pointer CreateRandomImage() { - const ImageType::SizeType imageSize = { { 4, 4, 4 } }; - const ImageType::IndexType imageIndex = { { 0, 0, 0 } }; - ImageType::RegionType region{ imageIndex, imageSize }; - auto img = ImageType::New(); + const ImageType::SizeType imageSize = { { 4, 4, 4 } }; + const ImageType::IndexType imageIndex = { { 0, 0, 0 } }; + const ImageType::RegionType region{ imageIndex, imageSize }; + auto img = ImageType::New(); img->SetRegions(region); img->Allocate(); itk::ImageRegionIterator ri(img, region); @@ -70,7 +70,7 @@ itkOrientImageFilterTest(int argc, char * argv[]) } itk::MultiThreaderBase::SetGlobalMaximumNumberOfThreads(1); - ImageType::Pointer randImage = CreateRandomImage(); + const ImageType::Pointer randImage = CreateRandomImage(); std::cerr << "Original" << std::endl; PrintImg(randImage); @@ -88,7 +88,7 @@ itkOrientImageFilterTest(int argc, char * argv[]) // Try permuting axes orienter->SetDesiredCoordinateOrientation(itk::AnatomicalOrientation::PositiveEnum::SLA); orienter->Update(); - ImageType::Pointer SLA = orienter->GetOutput(); + const ImageType::Pointer SLA = orienter->GetOutput(); std::cerr << "SLA" << std::endl; PrintImg(SLA); @@ -108,8 +108,8 @@ itkOrientImageFilterTest(int argc, char * argv[]) originalIndex[0] < static_cast(originalSize[0]); originalIndex[0]++, transformedIndex[1]++) { - ImageType::PixelType orig = randImage->GetPixel(originalIndex); - ImageType::PixelType xfrm = SLA->GetPixel(transformedIndex); + const ImageType::PixelType orig = randImage->GetPixel(originalIndex); + const ImageType::PixelType xfrm = SLA->GetPixel(transformedIndex); if (orig != xfrm) { return EXIT_FAILURE; @@ -124,7 +124,7 @@ itkOrientImageFilterTest(int argc, char * argv[]) orienter->SetGivenCoordinateOrientation(itk::AnatomicalOrientation::NegativeEnum::RIP); orienter->SetDesiredCoordinateOrientation(itk::AnatomicalOrientation::NegativeEnum::LIP); orienter->Update(); - ImageType::Pointer LIP = orienter->GetOutput(); + const ImageType::Pointer LIP = orienter->GetOutput(); std::cerr << "LIP" << std::endl; PrintImg(LIP); ImageType::RegionType::SizeType transformedSize = LIP->GetLargestPossibleRegion().GetSize(); @@ -141,8 +141,8 @@ itkOrientImageFilterTest(int argc, char * argv[]) originalIndex[0] < static_cast(originalSize[0]); originalIndex[0]++, transformedIndex[0]--) { - ImageType::PixelType orig = randImage->GetPixel(originalIndex); - ImageType::PixelType xfrm = LIP->GetPixel(transformedIndex); + const ImageType::PixelType orig = randImage->GetPixel(originalIndex); + const ImageType::PixelType xfrm = LIP->GetPixel(transformedIndex); if (orig != xfrm) { return EXIT_FAILURE; diff --git a/Modules/Filtering/ImageGrid/test/itkOrientImageFilterTest2.cxx b/Modules/Filtering/ImageGrid/test/itkOrientImageFilterTest2.cxx index 1be034ac241..f3af94799db 100644 --- a/Modules/Filtering/ImageGrid/test/itkOrientImageFilterTest2.cxx +++ b/Modules/Filtering/ImageGrid/test/itkOrientImageFilterTest2.cxx @@ -50,10 +50,10 @@ PrintImg(ImageType::Pointer img, const OrientImageFilterType::PermuteOrderArrayT ImageType::Pointer CreateAxialImage() { - const ImageType::SizeType imageSize = { { 4, 4, 4 } }; - ImageType::IndexType imageIndex = { { 0, 0, 0 } }; - ImageType::RegionType region{ imageIndex, imageSize }; - auto img = ImageType::New(); + const ImageType::SizeType imageSize = { { 4, 4, 4 } }; + ImageType::IndexType imageIndex = { { 0, 0, 0 } }; + const ImageType::RegionType region{ imageIndex, imageSize }; + auto img = ImageType::New(); img->SetRegions(region); img->Allocate(); @@ -90,7 +90,7 @@ CreateAxialImage() { column = "L"; } - std::string label = column + row + slice; + const std::string label = column + row + slice; img->SetPixel(imageIndex, label); } } @@ -102,10 +102,10 @@ CreateAxialImage() ImageType::Pointer CreateCoronalImage() { - const ImageType::SizeType imageSize = { { 4, 4, 4 } }; - ImageType::IndexType imageIndex = { { 0, 0, 0 } }; - ImageType::RegionType region{ imageIndex, imageSize }; - auto img = ImageType::New(); + const ImageType::SizeType imageSize = { { 4, 4, 4 } }; + ImageType::IndexType imageIndex = { { 0, 0, 0 } }; + const ImageType::RegionType region{ imageIndex, imageSize }; + auto img = ImageType::New(); img->SetRegions(region); img->Allocate(); @@ -155,7 +155,7 @@ CreateCoronalImage() { column = "L"; } - std::string label = column + row + slice; + const std::string label = column + row + slice; img->SetPixel(imageIndex, label); } } @@ -167,7 +167,7 @@ CreateCoronalImage() int itkOrientImageFilterTest2(int, char *[]) { - ImageType::Pointer axialImage = CreateAxialImage(); + const ImageType::Pointer axialImage = CreateAxialImage(); std::cerr << "Original" << std::endl; OrientImageFilterType::PermuteOrderArrayType permute; permute[0] = 0; @@ -186,7 +186,7 @@ itkOrientImageFilterTest2(int, char *[]) orienter->SetDesiredCoordinateOrientationToAxial(); orienter->Update(); - ImageType::Pointer axial = orienter->GetOutput(); + const ImageType::Pointer axial = orienter->GetOutput(); std::cerr << "axial" << std::endl; std::cout << "PermuteOrder: " << orienter->GetPermuteOrder() << std::endl; std::cout << "FlipAxes: " << orienter->GetFlipAxes() << std::endl; @@ -200,7 +200,7 @@ itkOrientImageFilterTest2(int, char *[]) orienter->SetDesiredCoordinateOrientationToCoronal(); orienter->Update(); - ImageType::Pointer coronal = orienter->GetOutput(); + const ImageType::Pointer coronal = orienter->GetOutput(); std::cerr << "coronal" << std::endl; orienter->GetOutput()->Print(std::cout); std::cout << "PermuteOrder: " << orienter->GetPermuteOrder() << std::endl; @@ -215,7 +215,7 @@ itkOrientImageFilterTest2(int, char *[]) orienter->SetDesiredCoordinateOrientationToSagittal(); orienter->Update(); - ImageType::Pointer sagittal = orienter->GetOutput(); + const ImageType::Pointer sagittal = orienter->GetOutput(); std::cerr << "sagittal" << std::endl; std::cout << "PermuteOrder: " << orienter->GetPermuteOrder() << std::endl; std::cout << "FlipAxes: " << orienter->GetFlipAxes() << std::endl; diff --git a/Modules/Filtering/ImageGrid/test/itkPadImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkPadImageFilterTest.cxx index 0fc31d368f7..bba81318882 100644 --- a/Modules/Filtering/ImageGrid/test/itkPadImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkPadImageFilterTest.cxx @@ -29,10 +29,10 @@ itkPadImageFilterTest(int, char *[]) using FilterType = itk::PadImageFilter; auto padFilter = FilterType::New(); - SizeType lowerBound = { { 1, 2 } }; - SizeType upperBound = { { 3, 4 } }; - SizeValueType lowerBoundArray[2] = { 1, 2 }; - SizeValueType upperBoundArray[2] = { 3, 4 }; + SizeType lowerBound = { { 1, 2 } }; + const SizeType upperBound = { { 3, 4 } }; + SizeValueType lowerBoundArray[2] = { 1, 2 }; + SizeValueType upperBoundArray[2] = { 3, 4 }; padFilter->SetPadLowerBound(lowerBound); if (padFilter->GetPadLowerBound() != lowerBound) @@ -98,9 +98,9 @@ itkPadImageFilterTest(int, char *[]) } // Fill in a test image - auto inputImage = ShortImage::New(); - ShortImage::SizeType inputSize = { { 1, 1 } }; - ShortImage::RegionType inputRegion(inputSize); + auto inputImage = ShortImage::New(); + const ShortImage::SizeType inputSize = { { 1, 1 } }; + const ShortImage::RegionType inputRegion(inputSize); inputImage->SetRegions(inputRegion); inputImage->Allocate(); inputImage->FillBuffer(1); @@ -112,7 +112,7 @@ itkPadImageFilterTest(int, char *[]) padFilter->UpdateLargestPossibleRegion(); // Checkout output values - ShortImage::Pointer output = padFilter->GetOutput(); + const ShortImage::Pointer output = padFilter->GetOutput(); for (int j = -2; j <= 2; ++j) { for (int i = -2; i <= 2; ++i) @@ -121,7 +121,7 @@ itkPadImageFilterTest(int, char *[]) index[0] = i; index[1] = j; - short pixel = output->GetPixel(index); + const short pixel = output->GetPixel(index); std::cout << pixel << ' '; if (index[0] == 0 && index[1] == 0) { diff --git a/Modules/Filtering/ImageGrid/test/itkPasteImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkPasteImageFilterTest.cxx index 13e6786aab3..f9a74d005d2 100644 --- a/Modules/Filtering/ImageGrid/test/itkPasteImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkPasteImageFilterTest.cxx @@ -38,11 +38,11 @@ itkPasteImageFilterTest(int argc, char * argv[]) using ImageType = itk::Image; - itk::ImageFileReader::Pointer dest = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer dest = itk::ImageFileReader::New(); dest->SetFileName(argv[1]); - itk::ImageFileReader::Pointer src = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer src = itk::ImageFileReader::New(); src->SetFileName(argv[2]); diff --git a/Modules/Filtering/ImageGrid/test/itkPermuteAxesImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkPermuteAxesImageFilterTest.cxx index 03288bbf748..7405668eb4b 100644 --- a/Modules/Filtering/ImageGrid/test/itkPermuteAxesImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkPermuteAxesImageFilterTest.cxx @@ -51,9 +51,9 @@ itkPermuteAxesImageFilterTest(int, char *[]) // define a small input test - ImageType::IndexType index = { { 10, 20, 30, 40 } }; - ImageType::SizeType size = { { 5, 4, 3, 2 } }; - ImageType::RegionType region{ index, size }; + const ImageType::IndexType index = { { 10, 20, 30, 40 } }; + const ImageType::SizeType size = { { 5, 4, 3, 2 } }; + const ImageType::RegionType region{ index, size }; double spacing[ImageDimension] = { 1.1, 1.2, 1.3, 1.4 }; double origin[ImageDimension] = { 0.5, 0.4, 0.3, 0.2 }; @@ -98,7 +98,7 @@ itkPermuteAxesImageFilterTest(int, char *[]) permuter->Print(std::cout); // check the output - ImageType::Pointer outputImage = permuter->GetOutput(); + const ImageType::Pointer outputImage = permuter->GetOutput(); inputIter.GoToBegin(); bool passed = true; diff --git a/Modules/Filtering/ImageGrid/test/itkPushPopTileImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkPushPopTileImageFilterTest.cxx index f62e60ac4d1..e03117ceaba 100644 --- a/Modules/Filtering/ImageGrid/test/itkPushPopTileImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkPushPopTileImageFilterTest.cxx @@ -59,8 +59,8 @@ itkPushPopTileImageFilterTest(int argc, char * argv[]) auto tiler4 = TilerType::New(); auto tiler = TilerType::New(); - unsigned char yellow[3] = { 255, 255, 127 }; - itk::RGBPixel fillPixel = yellow; + unsigned char yellow[3] = { 255, 255, 127 }; + const itk::RGBPixel fillPixel = yellow; tiler1->SetDefaultPixelValue(fillPixel); tiler1->SetLayout(layout); diff --git a/Modules/Filtering/ImageGrid/test/itkRegionOfInterestImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkRegionOfInterestImageFilterTest.cxx index 43a8a57ecbf..52b17d386f1 100644 --- a/Modules/Filtering/ImageGrid/test/itkRegionOfInterestImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkRegionOfInterestImageFilterTest.cxx @@ -46,7 +46,7 @@ itkRegionOfInterestImageFilterTest(int, char *[]) auto image = ImageType::New(); - IndexType start{}; + const IndexType start{}; SizeType size; size[0] = 40; @@ -96,7 +96,7 @@ itkRegionOfInterestImageFilterTest(int, char *[]) regionOfInterest.SetIndex(roiStart); regionOfInterest.SetSize(roiSize); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); filter->SetRegionOfInterest(regionOfInterest); ITK_TEST_SET_GET_VALUE(regionOfInterest, filter->GetRegionOfInterest()); diff --git a/Modules/Filtering/ImageGrid/test/itkResampleImageFilterGTest.cxx b/Modules/Filtering/ImageGrid/test/itkResampleImageFilterGTest.cxx index a235b9b98f7..26b794aeb89 100644 --- a/Modules/Filtering/ImageGrid/test/itkResampleImageFilterGTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkResampleImageFilterGTest.cxx @@ -81,7 +81,7 @@ TestThrowErrorOnEmptyResampleSpace(const TPixel inputPixel, const bool setUseRef filter->UseReferenceImageOn(); } filter->Update(); - typename ImageType::ConstPointer filterOutputImage = filter->GetOutput(); + const typename ImageType::ConstPointer filterOutputImage = filter->GetOutput(); if (filterOutputImage->GetLargestPossibleRegion().GetNumberOfPixels() == 0) { return itk::NumericTraits::max(); diff --git a/Modules/Filtering/ImageGrid/test/itkResampleImageTest.cxx b/Modules/Filtering/ImageGrid/test/itkResampleImageTest.cxx index b9d36ea3409..e318d00f3be 100644 --- a/Modules/Filtering/ImageGrid/test/itkResampleImageTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkResampleImageTest.cxx @@ -43,10 +43,10 @@ itkResampleImageTest(int, char *[]) // Create and configure an image - ImagePointerType image = ImageType::New(); - ImageIndexType index = { { 0, 0 } }; - ImageSizeType size = { { 18, 12 } }; - ImageRegionType region{ index, size }; + const ImagePointerType image = ImageType::New(); + ImageIndexType index = { { 0, 0 } }; + const ImageSizeType size = { { 18, 12 } }; + const ImageRegionType region{ index, size }; image->SetLargestPossibleRegion(region); image->SetBufferedRegion(region); image->Allocate(); @@ -70,7 +70,7 @@ itkResampleImageTest(int, char *[]) interp->SetInputImage(image); // Create and configure a resampling filter - itk::ResampleImageFilter::Pointer resample = + const itk::ResampleImageFilter::Pointer resample = itk::ResampleImageFilter::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(resample, ResampleImageFilter, ImageToImageFilter); @@ -91,7 +91,7 @@ itkResampleImageTest(int, char *[]) resample->SetOutputStartIndex(index); ITK_TEST_SET_GET_VALUE(index, resample->GetOutputStartIndex()); - ImageType::PointType origin{}; + const ImageType::PointType origin{}; resample->SetOutputOrigin(origin); ITK_TEST_SET_GET_VALUE(origin, resample->GetOutputOrigin()); diff --git a/Modules/Filtering/ImageGrid/test/itkResampleImageTest2.cxx b/Modules/Filtering/ImageGrid/test/itkResampleImageTest2.cxx index 4d6d56c2c31..b7d56a09002 100644 --- a/Modules/Filtering/ImageGrid/test/itkResampleImageTest2.cxx +++ b/Modules/Filtering/ImageGrid/test/itkResampleImageTest2.cxx @@ -135,7 +135,7 @@ itkResampleImageTest2(int argc, char * argv[]) resample->SetInterpolator(interpolator); ITK_TEST_SET_GET_VALUE(interpolator, resample->GetInterpolator()); - bool useReferenceImage = std::stoi(argv[7]); + const bool useReferenceImage = std::stoi(argv[7]); ITK_TEST_SET_GET_BOOLEAN(resample, UseReferenceImage, useReferenceImage); @@ -177,9 +177,9 @@ itkResampleImageTest2(int argc, char * argv[]) itk::Math::Ceil(static_cast(inputSize[i]) * inputSpacing[i] / outputSpacing[i]); } - typename ImageType::DirectionType outputDirection = resample->GetInput()->GetDirection(); + const typename ImageType::DirectionType outputDirection = resample->GetInput()->GetDirection(); - typename ImageType::PointType outputOrigin = resample->GetInput()->GetOrigin(); + const typename ImageType::PointType outputOrigin = resample->GetInput()->GetOrigin(); resample->SetOutputSpacing(outputSpacing); ITK_TEST_SET_GET_VALUE(outputSpacing, resample->GetOutputSpacing()); diff --git a/Modules/Filtering/ImageGrid/test/itkResampleImageTest3.cxx b/Modules/Filtering/ImageGrid/test/itkResampleImageTest3.cxx index 13097afd18c..237b10e9978 100644 --- a/Modules/Filtering/ImageGrid/test/itkResampleImageTest3.cxx +++ b/Modules/Filtering/ImageGrid/test/itkResampleImageTest3.cxx @@ -73,8 +73,8 @@ itkResampleImageTest3(int argc, char * argv[]) direction[0][1] = 0.0; direction[1][0] = 0.0; direction[1][1] = -1.0; - ImageType::RegionType inputRegion = reader1->GetOutput()->GetLargestPossibleRegion(); - ImageType::PointType origin; + const ImageType::RegionType inputRegion = reader1->GetOutput()->GetLargestPossibleRegion(); + ImageType::PointType origin; origin[0] = inputRegion.GetSize()[0]; origin[1] = inputRegion.GetSize()[1]; diff --git a/Modules/Filtering/ImageGrid/test/itkResampleImageTest4.cxx b/Modules/Filtering/ImageGrid/test/itkResampleImageTest4.cxx index 69cf8ffca0a..68897becea6 100644 --- a/Modules/Filtering/ImageGrid/test/itkResampleImageTest4.cxx +++ b/Modules/Filtering/ImageGrid/test/itkResampleImageTest4.cxx @@ -51,10 +51,10 @@ itkResampleImageTest4(int argc, char * argv[]) } // Create and configure an image - ImagePointerType image = ImageType::New(); - ImageIndexType index = { { 0, 0 } }; - ImageSizeType size = { { 64, 64 } }; - ImageRegionType region{ index, size }; + const ImagePointerType image = ImageType::New(); + ImageIndexType index = { { 0, 0 } }; + ImageSizeType size = { { 64, 64 } }; + const ImageRegionType region{ index, size }; image->SetRegions(region); image->Allocate(); @@ -84,7 +84,7 @@ itkResampleImageTest4(int argc, char * argv[]) interp->SetInputImage(image); // Create and configure a resampling filter - itk::ResampleImageFilter::Pointer resample = + const itk::ResampleImageFilter::Pointer resample = itk::ResampleImageFilter::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(resample, ResampleImageFilter, ImageToImageFilter); @@ -107,7 +107,7 @@ itkResampleImageTest4(int argc, char * argv[]) resample->SetOutputStartIndex(index); ITK_TEST_SET_GET_VALUE(index, resample->GetOutputStartIndex()); - ImageType::PointType origin{}; + const ImageType::PointType origin{}; resample->SetOutputOrigin(origin); ITK_TEST_SET_GET_VALUE(origin, resample->GetOutputOrigin()); diff --git a/Modules/Filtering/ImageGrid/test/itkResampleImageTest5.cxx b/Modules/Filtering/ImageGrid/test/itkResampleImageTest5.cxx index 9f97484a87f..106606cd516 100644 --- a/Modules/Filtering/ImageGrid/test/itkResampleImageTest5.cxx +++ b/Modules/Filtering/ImageGrid/test/itkResampleImageTest5.cxx @@ -53,13 +53,13 @@ itkResampleImageTest5(int argc, char * argv[]) using InterpolatorType = itk::LinearInterpolateImageFunction; using WriterType = itk::ImageFileWriter; - float scaling = std::stod(argv[1]); + const float scaling = std::stod(argv[1]); // Create and configure an image - ImagePointerType image = ImageType::New(); - ImageIndexType index = { { 0, 0 } }; - ImageSizeType size = { { 64, 64 } }; - ImageRegionType region{ index, size }; + const ImagePointerType image = ImageType::New(); + ImageIndexType index = { { 0, 0 } }; + ImageSizeType size = { { 64, 64 } }; + const ImageRegionType region{ index, size }; image->SetLargestPossibleRegion(region); image->SetBufferedRegion(region); image->Allocate(); @@ -89,7 +89,7 @@ itkResampleImageTest5(int argc, char * argv[]) interp->SetInputImage(image); // Create and configure a resampling filter - itk::ResampleImageFilter::Pointer resample = + const itk::ResampleImageFilter::Pointer resample = itk::ResampleImageFilter::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(resample, ResampleImageFilter, ImageToImageFilter); @@ -110,7 +110,7 @@ itkResampleImageTest5(int argc, char * argv[]) resample->SetOutputStartIndex(index); ITK_TEST_SET_GET_VALUE(index, resample->GetOutputStartIndex()); - ImageType::PointType origin{}; + const ImageType::PointType origin{}; resample->SetOutputOrigin(origin); ITK_TEST_SET_GET_VALUE(origin, resample->GetOutputOrigin()); diff --git a/Modules/Filtering/ImageGrid/test/itkResampleImageTest6.cxx b/Modules/Filtering/ImageGrid/test/itkResampleImageTest6.cxx index c404c39b6b7..ce23983e27b 100644 --- a/Modules/Filtering/ImageGrid/test/itkResampleImageTest6.cxx +++ b/Modules/Filtering/ImageGrid/test/itkResampleImageTest6.cxx @@ -56,13 +56,13 @@ itkResampleImageTest6(int argc, char * argv[]) using InterpolatorType = itk::LinearInterpolateImageFunction; using WriterType = itk::ImageFileWriter; - float scaling = std::stod(argv[1]); + const float scaling = std::stod(argv[1]); // Create and configure an image - ImagePointerType image = ImageType::New(); - ImageIndexType index = { { 0, 0 } }; - ImageSizeType size = { { 64, 64 } }; - ImageRegionType region{ index, size }; + const ImagePointerType image = ImageType::New(); + ImageIndexType index = { { 0, 0 } }; + ImageSizeType size = { { 64, 64 } }; + const ImageRegionType region{ index, size }; image->SetLargestPossibleRegion(region); image->SetBufferedRegion(region); image->SetVectorLength(3); @@ -100,7 +100,7 @@ itkResampleImageTest6(int argc, char * argv[]) interp->SetInputImage(image); // Create and configure a resampling filter - itk::ResampleImageFilter::Pointer resample = + const itk::ResampleImageFilter::Pointer resample = itk::ResampleImageFilter::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(resample, ResampleImageFilter, ImageToImageFilter); @@ -121,7 +121,7 @@ itkResampleImageTest6(int argc, char * argv[]) resample->SetOutputStartIndex(index); ITK_TEST_SET_GET_VALUE(index, resample->GetOutputStartIndex()); - ImageType::PointType origin{}; + const ImageType::PointType origin{}; resample->SetOutputOrigin(origin); ITK_TEST_SET_GET_VALUE(origin, resample->GetOutputOrigin()); diff --git a/Modules/Filtering/ImageGrid/test/itkResampleImageTest7.cxx b/Modules/Filtering/ImageGrid/test/itkResampleImageTest7.cxx index 7c41e64025e..e800b5dbe00 100644 --- a/Modules/Filtering/ImageGrid/test/itkResampleImageTest7.cxx +++ b/Modules/Filtering/ImageGrid/test/itkResampleImageTest7.cxx @@ -48,10 +48,10 @@ itkResampleImageTest7(int, char *[]) using InterpolatorType = itk::LinearInterpolateImageFunction; // Create and configure an image - ImagePointerType image = ImageType::New(); - ImageIndexType index = { { 0, 0 } }; - ImageSizeType size = { { 64, 64 } }; - ImageRegionType region{ index, size }; + const ImagePointerType image = ImageType::New(); + ImageIndexType index = { { 0, 0 } }; + const ImageSizeType size = { { 64, 64 } }; + const ImageRegionType region{ index, size }; image->SetRegions(region); image->Allocate(); @@ -74,7 +74,7 @@ itkResampleImageTest7(int, char *[]) interp->SetInputImage(image); // Create and configure a resampling filter - itk::ResampleImageFilter::Pointer resample = + const itk::ResampleImageFilter::Pointer resample = itk::ResampleImageFilter::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(resample, ResampleImageFilter, ImageToImageFilter); @@ -96,7 +96,7 @@ itkResampleImageTest7(int, char *[]) resample->SetOutputStartIndex(index); ITK_TEST_SET_GET_VALUE(index, resample->GetOutputStartIndex()); - ImageType::PointType origin{}; + const ImageType::PointType origin{}; resample->SetOutputOrigin(origin); ITK_TEST_SET_GET_VALUE(origin, resample->GetOutputOrigin()); @@ -117,8 +117,8 @@ itkResampleImageTest7(int, char *[]) streamer->SetNumberOfStreamDivisions(numStreamDiv); ITK_TRY_EXPECT_NO_EXCEPTION(streamer->UpdateLargestPossibleRegion()); - ImagePointerType outputNoSDI = streamer->GetOutput(); // save output for later comparison - outputNoSDI->DisconnectPipeline(); // disconnect to create new output + const ImagePointerType outputNoSDI = streamer->GetOutput(); // save output for later comparison + outputNoSDI->DisconnectPipeline(); // disconnect to create new output // Run the resampling filter with streaming image->Modified(); @@ -133,7 +133,7 @@ itkResampleImageTest7(int, char *[]) ITK_TEST_SET_GET_VALUE(60, finalRequestedRegion.GetSize(0)); ITK_TEST_SET_GET_VALUE(12, finalRequestedRegion.GetSize(1)); - ImagePointerType outputSDI = streamer->GetOutput(); + const ImagePointerType outputSDI = streamer->GetOutput(); outputSDI->DisconnectPipeline(); itk::ImageRegionIterator itNoSDI(outputNoSDI, outputNoSDI->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/ImageGrid/test/itkResampleImageTest8.cxx b/Modules/Filtering/ImageGrid/test/itkResampleImageTest8.cxx index 8d5e868bb01..183da4cd8f3 100644 --- a/Modules/Filtering/ImageGrid/test/itkResampleImageTest8.cxx +++ b/Modules/Filtering/ImageGrid/test/itkResampleImageTest8.cxx @@ -141,10 +141,10 @@ itkResampleImageTest8(int, char *[]) std::cout << "Input Image Type\n"; // Create and configure an image - InputImagePointerType inputImage = InputImageType::New(); - InputImageIndexType inputIndex = { { 0, 0 } }; - InputImageSizeType inputSize = { { 18, 12 } }; - InputImageRegionType inputRegion{ inputIndex, inputSize }; + const InputImagePointerType inputImage = InputImageType::New(); + InputImageIndexType inputIndex = { { 0, 0 } }; + const InputImageSizeType inputSize = { { 18, 12 } }; + const InputImageRegionType inputRegion{ inputIndex, inputSize }; inputImage->SetLargestPossibleRegion(inputRegion); inputImage->SetBufferedRegion(inputRegion); inputImage->Allocate(); @@ -163,15 +163,15 @@ itkResampleImageTest8(int, char *[]) auto tform = TransformType::New(); // OutputImagePointerType outputImage = OutputImageType::New(); - OutputImageIndexType outputIndex = { { 0, 0, 0 } }; - OutputImageSizeType outputSize = { { 18, 12, 5 } }; + OutputImageIndexType outputIndex = { { 0, 0, 0 } }; + const OutputImageSizeType outputSize = { { 18, 12, 5 } }; // Create a linear interpolation image function auto interp = InterpolatorType::New(); interp->SetInputImage(inputImage); // Create and configure a resampling filter - itk::ResampleImageFilter::Pointer resample = + const itk::ResampleImageFilter::Pointer resample = itk::ResampleImageFilter::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(resample, ResampleImageFilter, ImageToImageFilter); @@ -193,7 +193,7 @@ itkResampleImageTest8(int, char *[]) resample->SetOutputStartIndex(outputIndex); ITK_TEST_SET_GET_VALUE(outputIndex, resample->GetOutputStartIndex()); - OutputImageType::PointType origin{}; + const OutputImageType::PointType origin{}; resample->SetOutputOrigin(origin); ITK_TEST_SET_GET_VALUE(origin, resample->GetOutputOrigin()); diff --git a/Modules/Filtering/ImageGrid/test/itkResamplePhasedArray3DSpecialCoordinatesImageTest.cxx b/Modules/Filtering/ImageGrid/test/itkResamplePhasedArray3DSpecialCoordinatesImageTest.cxx index ad8912cdf70..427283f8946 100644 --- a/Modules/Filtering/ImageGrid/test/itkResamplePhasedArray3DSpecialCoordinatesImageTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkResamplePhasedArray3DSpecialCoordinatesImageTest.cxx @@ -44,10 +44,10 @@ int itkResamplePhasedArray3DSpecialCoordinatesImageTest(int, char *[]) { // Create and configure an image - InputImagePointerType image = InputImageType::New(); - ImageIndexType index = { { 0, 0, 0 } }; - ImageSizeType size = { { 13, 13, 9 } }; - ImageRegionType region{ index, size }; + const InputImagePointerType image = InputImageType::New(); + ImageIndexType index = { { 0, 0, 0 } }; + ImageSizeType size = { { 13, 13, 9 } }; + const ImageRegionType region{ index, size }; image->SetLargestPossibleRegion(region); image->SetBufferedRegion(region); image->SetAzimuthAngularSeparation(5.0 * 2.0 * itk::Math::pi / 360.0); diff --git a/Modules/Filtering/ImageGrid/test/itkShrinkImageStreamingTest.cxx b/Modules/Filtering/ImageGrid/test/itkShrinkImageStreamingTest.cxx index 87cad9cec61..84955ea4835 100644 --- a/Modules/Filtering/ImageGrid/test/itkShrinkImageStreamingTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkShrinkImageStreamingTest.cxx @@ -36,9 +36,9 @@ itkShrinkImageStreamingTest(int, char *[]) using MonitorFilter = itk::PipelineMonitorImageFilter; // fill in an image - ShortImage::IndexType index = { { 100, 100 } }; - ShortImage::SizeType size = { { 8, 12 } }; - ShortImage::RegionType region{ index, size }; + const ShortImage::IndexType index = { { 100, 100 } }; + const ShortImage::SizeType size = { { 8, 12 } }; + const ShortImage::RegionType region{ index, size }; sourceImage->SetRegions(region); sourceImage->Allocate(); diff --git a/Modules/Filtering/ImageGrid/test/itkShrinkImageTest.cxx b/Modules/Filtering/ImageGrid/test/itkShrinkImageTest.cxx index f6a54f6f245..d752e583a87 100644 --- a/Modules/Filtering/ImageGrid/test/itkShrinkImageTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkShrinkImageTest.cxx @@ -25,7 +25,7 @@ int itkShrinkImageTest(int, char *[]) { - itk::FileOutputWindow::Pointer fow = itk::FileOutputWindow::New(); + const itk::FileOutputWindow::Pointer fow = itk::FileOutputWindow::New(); fow->SetInstance(fow); std::cout << "Shrink an image by (2,3)" << std::endl; @@ -44,9 +44,9 @@ itkShrinkImageTest(int, char *[]) auto if2 = ShortImage::New(); // fill in an image - ShortImage::IndexType index = { { 0, 0 } }; - ShortImage::SizeType size = { { 8, 12 } }; - ShortImage::RegionType region{ index, size }; + const ShortImage::IndexType index = { { 0, 0 } }; + const ShortImage::SizeType size = { { 8, 12 } }; + const ShortImage::RegionType region{ index, size }; if2->SetLargestPossibleRegion(region); if2->SetBufferedRegion(region); if2->Allocate(); @@ -116,7 +116,7 @@ itkShrinkImageTest(int, char *[]) auto row = itk::Math::RoundHalfIntegerUp(shrink->GetShrinkFactors()[1] * iterator2.GetIndex()[1] + (shrink->GetShrinkFactors()[1] - 1.0) / 2.0); row += rowOffset; - short trueValue = col + region.GetSize()[0] * row; + const short trueValue = col + region.GetSize()[0] * row; if (iterator2.Get() != trueValue) { @@ -194,11 +194,12 @@ itkShrinkImageTest(int, char *[]) std::cout << "Pixel " << iterator2.GetIndex() << " = " << iterator2.Get() << std::endl; std::cout << std::flush; - short trueValue = itk::Math::RoundHalfIntegerUp((shrink->GetShrinkFactors()[0] * iterator2.GetIndex()[0] + - (shrink->GetShrinkFactors()[0] - 1.0) / 2.0)) + - (region.GetSize()[0] * - itk::Math::RoundHalfIntegerUp((shrink->GetShrinkFactors()[1] * iterator2.GetIndex()[1] + - (shrink->GetShrinkFactors()[1] - 1.0) / 2.0))); + const short trueValue = + itk::Math::RoundHalfIntegerUp( + (shrink->GetShrinkFactors()[0] * iterator2.GetIndex()[0] + (shrink->GetShrinkFactors()[0] - 1.0) / 2.0)) + + (region.GetSize()[0] * + itk::Math::RoundHalfIntegerUp( + (shrink->GetShrinkFactors()[1] * iterator2.GetIndex()[1] + (shrink->GetShrinkFactors()[1] - 1.0) / 2.0))); if (iterator2.Get() != trueValue) { std::cout << "B) Pixel " << iterator2.GetIndex() << " expected " << trueValue << " but got " << iterator2.Get() diff --git a/Modules/Filtering/ImageGrid/test/itkSliceBySliceImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkSliceBySliceImageFilterTest.cxx index 2ceb2e9f02a..7572af4b38f 100644 --- a/Modules/Filtering/ImageGrid/test/itkSliceBySliceImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkSliceBySliceImageFilterTest.cxx @@ -89,12 +89,12 @@ itkSliceBySliceImageFilterTest(int argc, char * argv[]) using MonitorType = itk::PipelineMonitorImageFilter; auto monitor = MonitorType::New(); - itk::CStyleCommand::Pointer command = itk::CStyleCommand::New(); + const itk::CStyleCommand::Pointer command = itk::CStyleCommand::New(); command->SetCallback(*sliceCallBack); filter->AddObserver(itk::IterationEvent(), command); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using WriterType = itk::ImageFileWriter; diff --git a/Modules/Filtering/ImageGrid/test/itkSliceImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkSliceImageFilterTest.cxx index 06d1b9bcc83..be42f3189f4 100644 --- a/Modules/Filtering/ImageGrid/test/itkSliceImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkSliceImageFilterTest.cxx @@ -287,7 +287,7 @@ TEST(SliceImageFilterTests, Sizes) using SourceType = itk::GaussianImageSource; auto source = SourceType::New(); - SourceType::SizeType size = { { 64, 64, 64 } }; + const SourceType::SizeType size = { { 64, 64, 64 } }; source->SetSize(size); source->ReleaseDataFlagOn(); diff --git a/Modules/Filtering/ImageGrid/test/itkTileImageFilterGTest.cxx b/Modules/Filtering/ImageGrid/test/itkTileImageFilterGTest.cxx index 458dc5c5ac5..f3ac81909a3 100644 --- a/Modules/Filtering/ImageGrid/test/itkTileImageFilterGTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkTileImageFilterGTest.cxx @@ -92,12 +92,12 @@ TEST_F(TileImageFixture, SetGetPrint) auto filter = Utils::FilterType::New(); filter->Print(std::cout); - typename Utils::FilterType::ConstPointer constfilter = (const Utils::FilterType *)(filter.GetPointer()); + const typename Utils::FilterType::ConstPointer constfilter = (const Utils::FilterType *)(filter.GetPointer()); EXPECT_STREQ("TileImageFilter", filter->GetNameOfClass()); EXPECT_STREQ("ImageToImageFilter", filter->Superclass::GetNameOfClass()); - Utils::FilterType::LayoutArrayType layout(99); + const Utils::FilterType::LayoutArrayType layout(99); EXPECT_NO_THROW(filter->SetLayout(layout)); ITK_EXPECT_VECTOR_NEAR(layout, filter->GetLayout(), 0); @@ -117,7 +117,7 @@ TEST_F(TileImageFixture, VectorImage) auto image = ImageType::New(); - typename ImageType::SizeType imageSize = itk::MakeSize(10, 10); + const typename ImageType::SizeType imageSize = itk::MakeSize(10, 10); const unsigned int numberOfComponents = 5; diff --git a/Modules/Filtering/ImageGrid/test/itkTileImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkTileImageFilterTest.cxx index 75ffc4891a1..28baa9ac013 100644 --- a/Modules/Filtering/ImageGrid/test/itkTileImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkTileImageFilterTest.cxx @@ -56,9 +56,9 @@ itkTileImageFilterTest(int argc, char * argv[]) layout[2] = std::stoi(argv[3]); // Tile the input images - auto tiler = TilerType::New(); - itk::SimpleFilterWatcher tileWatcher(tiler, "Tiler"); - int f = 0; + auto tiler = TilerType::New(); + const itk::SimpleFilterWatcher tileWatcher(tiler, "Tiler"); + int f = 0; for (int i = 4; i < argc - 1; ++i) { auto reader = ImageReaderType::New(); @@ -67,8 +67,8 @@ itkTileImageFilterTest(int argc, char * argv[]) tiler->SetInput(f++, reader->GetOutput()); } tiler->SetLayout(layout); - unsigned char yellow[3] = { 255, 255, 127 }; - itk::RGBPixel fillPixel = yellow; + unsigned char yellow[3] = { 255, 255, 127 }; + const itk::RGBPixel fillPixel = yellow; tiler->SetDefaultPixelValue(fillPixel); tiler->Update(); tiler->GetOutput()->Print(std::cout); diff --git a/Modules/Filtering/ImageGrid/test/itkWarpImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkWarpImageFilterTest.cxx index 4e2f0c2ac03..c906a2fa818 100644 --- a/Modules/Filtering/ImageGrid/test/itkWarpImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkWarpImageFilterTest.cxx @@ -113,7 +113,7 @@ itkWarpImageFilterTest(int, char *[]) input->SetBufferedRegion(region); input->Allocate(); - ImageType::PixelType padValue = 4.0; + const ImageType::PixelType padValue = 4.0; ImagePattern pattern; @@ -133,7 +133,7 @@ itkWarpImageFilterTest(int, char *[]) std::cout << "Create the input displacement field." << std::endl; // Tested with { 2, 4 } and { 2, 5 } as well... - unsigned int factors[ImageDimension] = { 2, 3 }; + const unsigned int factors[ImageDimension] = { 2, 3 }; ImageType::RegionType fieldRegion; ImageType::SizeType fieldSize; @@ -204,13 +204,13 @@ itkWarpImageFilterTest(int, char *[]) warper->SetOutputDirection(outputDirection); ITK_TEST_SET_GET_VALUE(outputDirection, warper->GetOutputDirection()); - typename WarperType::IndexType::value_type outputStartIndexVal = 0; - auto outputStartIndex = WarperType::IndexType::Filled(outputStartIndexVal); + const typename WarperType::IndexType::value_type outputStartIndexVal = 0; + auto outputStartIndex = WarperType::IndexType::Filled(outputStartIndexVal); warper->SetOutputStartIndex(outputStartIndex); ITK_TEST_SET_GET_VALUE(outputStartIndex, warper->GetOutputStartIndex()); - typename WarperType::SizeType::value_type outputSizeVal = 0; - auto outputSize = WarperType::SizeType::Filled(outputSizeVal); + const typename WarperType::SizeType::value_type outputSizeVal = 0; + auto outputSize = WarperType::SizeType::Filled(outputSizeVal); warper->SetOutputSize(outputSize); ITK_TEST_SET_GET_VALUE(outputSize, warper->GetOutputSize()); @@ -279,16 +279,16 @@ itkWarpImageFilterTest(int, char *[]) Iterator outIter(warper->GetOutput(), warper->GetOutput()->GetBufferedRegion()); while (!outIter.IsAtEnd()) { - ImageType::IndexType index = outIter.GetIndex(); + const ImageType::IndexType index = outIter.GetIndex(); - double value = outIter.Get(); + const double value = outIter.Get(); if (validRegion.IsInside(index)) { - double trueValue = pattern.Evaluate(outIter.GetIndex(), validSize, clampSize, padValue); + const double trueValue = pattern.Evaluate(outIter.GetIndex(), validSize, clampSize, padValue); - double epsilon = 1e-4; + const double epsilon = 1e-4; if (itk::Math::abs(trueValue - value) > epsilon) { std::cerr.precision(static_cast(itk::Math::abs(std::log10(epsilon)))); @@ -358,7 +358,7 @@ itkWarpImageFilterTest(int, char *[]) // Exercise error handling using InterpolatorType = WarperType::InterpolatorType; - InterpolatorType::Pointer interp = warper->GetModifiableInterpolator(); + const InterpolatorType::Pointer interp = warper->GetModifiableInterpolator(); std::cout << "Setting interpolator to nullptr" << std::endl; warper->SetInterpolator(nullptr); diff --git a/Modules/Filtering/ImageGrid/test/itkWarpImageFilterTest2.cxx b/Modules/Filtering/ImageGrid/test/itkWarpImageFilterTest2.cxx index 3b44edd6546..9bd57d1ff46 100644 --- a/Modules/Filtering/ImageGrid/test/itkWarpImageFilterTest2.cxx +++ b/Modules/Filtering/ImageGrid/test/itkWarpImageFilterTest2.cxx @@ -44,22 +44,22 @@ ImageType::Pointer MakeCheckerboard() { using IteratorType = itk::ImageRegionIterator; - ImageType::SizeType size = { { 16, 16, 16 } }; - ImageType::SpacingType spacing; + const ImageType::SizeType size = { { 16, 16, 16 } }; + ImageType::SpacingType spacing; spacing[0] = spacing[1] = spacing[2] = 1.0; - ImageType::IndexType index = { { 0, 0, 0 } }; - ImageType::RegionType region{ index, size }; - ImageType::Pointer image; + const ImageType::IndexType index = { { 0, 0, 0 } }; + const ImageType::RegionType region{ index, size }; + ImageType::Pointer image; AllocateImageFromRegionAndSpacing(ImageType, image, region, spacing); image->FillBuffer(0.0); for (IteratorType it(image, image->GetLargestPossibleRegion()); !it.IsAtEnd(); ++it) { ImageType::IndexType ind(it.GetIndex()); // initially checkboard 4 pixels wide - int x = ind[0] / 4; - int y = ind[1] / 4; - int z = ind[2] / 4; - bool black(((x & 1) + (y & 1)) & 1); + const int x = ind[0] / 4; + const int y = ind[1] / 4; + const int z = ind[2] / 4; + bool black(((x & 1) + (y & 1)) & 1); if (z & 1) { black = !black; @@ -77,9 +77,9 @@ MakeDisplacementField() const DisplacementFieldType::SizeType size = { { TImageIndexSpaceSize, TImageIndexSpaceSize, TImageIndexSpaceSize } }; DisplacementFieldType::SpacingType spacing; spacing[0] = spacing[1] = spacing[2] = 16.0 / static_cast(TImageIndexSpaceSize); - DisplacementFieldType::IndexType index = { { 0, 0, 0 } }; - DisplacementFieldType::RegionType region{ index, size }; - DisplacementFieldType::Pointer image; + const DisplacementFieldType::IndexType index = { { 0, 0, 0 } }; + const DisplacementFieldType::RegionType region{ index, size }; + DisplacementFieldType::Pointer image; AllocateImageFromRegionAndSpacing(DisplacementFieldType, image, region, spacing); for (IteratorType it(image, image->GetLargestPossibleRegion()); !it.IsAtEnd(); ++it) { @@ -100,12 +100,12 @@ itkWarpImageFilterTest2(int, char *[]) { // itk::MultiThreaderBase::SetGlobalDefaultNumberOfThreads(1); // Make test image - ImageType::Pointer image = MakeCheckerboard(); + const ImageType::Pointer image = MakeCheckerboard(); // Make full-res displacement field - DisplacementFieldType::Pointer defField1 = MakeDisplacementField<16u>(); + const DisplacementFieldType::Pointer defField1 = MakeDisplacementField<16u>(); // Make half-res displacement field - DisplacementFieldType::Pointer defField2 = MakeDisplacementField<8u>(); + const DisplacementFieldType::Pointer defField2 = MakeDisplacementField<8u>(); auto filter = WarpFilterType::New(); // Test with full res @@ -114,7 +114,7 @@ itkWarpImageFilterTest2(int, char *[]) filter->SetOutputParametersFromImage(image); filter->Update(); // Save output for later comparison - ImageType::Pointer result1 = filter->GetOutput(); + const ImageType::Pointer result1 = filter->GetOutput(); // Disconnect to create new output result1->DisconnectPipeline(); // Test with half res @@ -124,7 +124,7 @@ itkWarpImageFilterTest2(int, char *[]) // Enforce re-execution just to be sure filter->Modified(); filter->Update(); - ImageType::Pointer result2 = filter->GetOutput(); + const ImageType::Pointer result2 = filter->GetOutput(); itk::ImageRegionIterator it1(result1, result1->GetLargestPossibleRegion()); itk::ImageRegionIterator it2(result2, result1->GetLargestPossibleRegion()); for (it1.GoToBegin(), it2.GoToBegin(); !it1.IsAtEnd() && !it2.IsAtEnd(); ++it1, ++it2) diff --git a/Modules/Filtering/ImageGrid/test/itkWarpVectorImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkWarpVectorImageFilterTest.cxx index aaa1ba2d4c9..4fa0c871ad5 100644 --- a/Modules/Filtering/ImageGrid/test/itkWarpVectorImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkWarpVectorImageFilterTest.cxx @@ -123,7 +123,7 @@ itkWarpVectorImageFilterTest(int, char *[]) using Iterator = itk::ImageRegionIteratorWithIndex; - float padValue = 4.0; + const float padValue = 4.0; for (Iterator inIter(input, region); !inIter.IsAtEnd(); ++inIter) { @@ -132,7 +132,7 @@ itkWarpVectorImageFilterTest(int, char *[]) std::cout << "Create the input displacement field." << std::endl; - unsigned int factors[ImageDimension] = { 2, 3 }; + const unsigned int factors[ImageDimension] = { 2, 3 }; ImageType::RegionType fieldRegion; ImageType::SizeType fieldSize; @@ -256,8 +256,8 @@ itkWarpVectorImageFilterTest(int, char *[]) Iterator outIter(warper->GetOutput(), warper->GetOutput()->GetBufferedRegion()); while (!outIter.IsAtEnd()) { - IndexType index = outIter.GetIndex(); - PixelType value = outIter.Get(); + const IndexType index = outIter.GetIndex(); + PixelType value = outIter.Get(); if (validRegion.IsInside(index)) { @@ -339,7 +339,7 @@ itkWarpVectorImageFilterTest(int, char *[]) // Exercise error handling using InterpolatorType = WarperType::InterpolatorType; - InterpolatorType::Pointer interp = warper->GetModifiableInterpolator(); + const InterpolatorType::Pointer interp = warper->GetModifiableInterpolator(); std::cout << "Setting interpolator to nullptr" << std::endl; warper->SetInterpolator(nullptr); diff --git a/Modules/Filtering/ImageGrid/test/itkWrapPadImageTest.cxx b/Modules/Filtering/ImageGrid/test/itkWrapPadImageTest.cxx index b1287439ac9..e814834439a 100644 --- a/Modules/Filtering/ImageGrid/test/itkWrapPadImageTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkWrapPadImageTest.cxx @@ -75,10 +75,10 @@ itkWrapPadImageTest(int, char *[]) using VectorImage = itk::VectorImage; // Test the creation of an image with native type - auto image = ShortImage::New(); - ShortImage::IndexType index = { { 0, 0 } }; - ShortImage::SizeType size = { { 8, 12 } }; - ShortImage::RegionType region(index, size); + auto image = ShortImage::New(); + ShortImage::IndexType index = { { 0, 0 } }; + ShortImage::SizeType size = { { 8, 12 } }; + const ShortImage::RegionType region(index, size); image->SetRegions(region); image->Allocate(); @@ -160,8 +160,8 @@ itkWrapPadImageTest(int, char *[]) { for (; !itIn1.IsAtEnd(); ++itIn1, ++vitIn1) { - int row = itIn1.GetIndex()[0]; - int column = itIn1.GetIndex()[1]; + const int row = itIn1.GetIndex()[0]; + const int column = itIn1.GetIndex()[1]; FloatImage::PixelType expected = 0.0f; if (!VerifyPixel(row, column, static_cast(itIn1.Get()), expected)) @@ -225,8 +225,8 @@ itkWrapPadImageTest(int, char *[]) { for (; !itIn2.IsAtEnd(); ++itIn2, ++vitIn2) { - int row = itIn2.GetIndex()[0]; - int column = itIn2.GetIndex()[1]; + const int row = itIn2.GetIndex()[0]; + const int column = itIn2.GetIndex()[1]; FloatImage::PixelType expected = 0.0f; if (!VerifyPixel(row, column, static_cast(itIn2.Get()), expected)) @@ -271,7 +271,7 @@ itkWrapPadImageTest(int, char *[]) stream->SetInput(wrapPad->GetOutput()); stream->SetNumberOfStreamDivisions(3); - itk::StreamingImageFilter::Pointer vectorStream = + const itk::StreamingImageFilter::Pointer vectorStream = itk::StreamingImageFilter::New(); vectorStream->SetInput(vectorWrapPad->GetOutput()); vectorStream->SetNumberOfStreamDivisions(3); @@ -302,8 +302,8 @@ itkWrapPadImageTest(int, char *[]) { for (; !itIn3.IsAtEnd(); ++itIn3, ++vitIn3) { - int row = itIn3.GetIndex()[0]; - int column = itIn3.GetIndex()[1]; + const int row = itIn3.GetIndex()[0]; + const int column = itIn3.GetIndex()[1]; FloatImage::PixelType expected = 0.0f; if (!VerifyPixel(row, column, static_cast(itIn3.Get()), expected)) diff --git a/Modules/Filtering/ImageGrid/test/itkZeroFluxNeumannPadImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkZeroFluxNeumannPadImageFilterTest.cxx index c6cfe75e243..6e4588e6948 100644 --- a/Modules/Filtering/ImageGrid/test/itkZeroFluxNeumannPadImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkZeroFluxNeumannPadImageFilterTest.cxx @@ -33,17 +33,17 @@ using FilterType = itk::ZeroFluxNeumannPadImageFilter; static bool VerifyFilterOutput(const ShortImage * inputImage, const FloatImage * outputImage) { - ShortImage::RegionType inputRegion = inputImage->GetLargestPossibleRegion(); - ShortImage::IndexType inputIndex = inputRegion.GetIndex(); - ShortImage::SizeType inputSize = inputRegion.GetSize(); + const ShortImage::RegionType inputRegion = inputImage->GetLargestPossibleRegion(); + ShortImage::IndexType inputIndex = inputRegion.GetIndex(); + ShortImage::SizeType inputSize = inputRegion.GetSize(); - ShortImage::RegionType outputRegion = outputImage->GetLargestPossibleRegion(); + const ShortImage::RegionType outputRegion = outputImage->GetLargestPossibleRegion(); itk::ImageRegionConstIteratorWithIndex outputIterator(outputImage, outputRegion); // Check pixel values for (; !outputIterator.IsAtEnd(); ++outputIterator) { - ShortImage::IndexType idx = outputIterator.GetIndex(); + const ShortImage::IndexType idx = outputIterator.GetIndex(); if (inputRegion.IsInside(idx)) { if (itk::Math::NotAlmostEquals(outputIterator.Get(), inputImage->GetPixel(idx))) @@ -100,13 +100,13 @@ VerifyFilter(const ShortImage * inputImage, return false; } - ShortImage::RegionType outputRegion = padFilter->GetOutput()->GetLargestPossibleRegion(); - ShortImage::IndexType outputIndex = outputRegion.GetIndex(); - ShortImage::SizeType outputSize = outputRegion.GetSize(); + const ShortImage::RegionType outputRegion = padFilter->GetOutput()->GetLargestPossibleRegion(); + const ShortImage::IndexType outputIndex = outputRegion.GetIndex(); + const ShortImage::SizeType outputSize = outputRegion.GetSize(); - ShortImage::RegionType inputRegion = inputImage->GetLargestPossibleRegion(); - ShortImage::IndexType inputIndex = inputRegion.GetIndex(); - ShortImage::SizeType inputSize = inputRegion.GetSize(); + const ShortImage::RegionType inputRegion = inputImage->GetLargestPossibleRegion(); + ShortImage::IndexType inputIndex = inputRegion.GetIndex(); + ShortImage::SizeType inputSize = inputRegion.GetSize(); ShortImage::IndexType expectedIndex; ShortImage::SizeType expectedSize; @@ -170,9 +170,9 @@ itkZeroFluxNeumannPadImageFilterTest(int, char *[]) auto inputImage = ShortImage::New(); // Fill in a test image - ShortImage::IndexType inputIndex = { { 0, 0 } }; - ShortImage::SizeType inputSize = { { 8, 12 } }; - ShortImage::RegionType inputRegion{ inputIndex, inputSize }; + const ShortImage::IndexType inputIndex = { { 0, 0 } }; + const ShortImage::SizeType inputSize = { { 8, 12 } }; + const ShortImage::RegionType inputRegion{ inputIndex, inputSize }; inputImage->SetLargestPossibleRegion(inputRegion); inputImage->SetBufferedRegion(inputRegion); inputImage->Allocate(); diff --git a/Modules/Filtering/ImageIntensity/include/itkClampImageFilter.hxx b/Modules/Filtering/ImageIntensity/include/itkClampImageFilter.hxx index 4d143bce0c3..5976cd63a24 100644 --- a/Modules/Filtering/ImageIntensity/include/itkClampImageFilter.hxx +++ b/Modules/Filtering/ImageIntensity/include/itkClampImageFilter.hxx @@ -111,7 +111,7 @@ ClampImageFilter::GenerateData() // then there is nothing to do. To avoid iterating over all the pixels for // nothing, graft the input to the output, generate a fake progress and exit. this->AllocateOutputs(); - ProgressReporter progress(this, 0, 1); + const ProgressReporter progress(this, 0, 1); return; } Superclass::GenerateData(); diff --git a/Modules/Filtering/ImageIntensity/include/itkHistogramMatchingImageFilter.hxx b/Modules/Filtering/ImageIntensity/include/itkHistogramMatchingImageFilter.hxx index fc8e27b1d70..41a81c77f99 100644 --- a/Modules/Filtering/ImageIntensity/include/itkHistogramMatchingImageFilter.hxx +++ b/Modules/Filtering/ImageIntensity/include/itkHistogramMatchingImageFilter.hxx @@ -143,7 +143,7 @@ HistogramMatchingImageFilter:: if (m_GenerateReferenceHistogramFromImage) { - InputImageConstPointer reference = this->GetReferenceImage(); + const InputImageConstPointer reference = this->GetReferenceImage(); if (reference.IsNull()) { itkExceptionMacro("ERROR: ReferenceImage required when GenerateReferenceHistogramFromImage is true.\n"); @@ -158,7 +158,7 @@ HistogramMatchingImageFilter:: referenceIntensityThreshold = static_cast(m_ReferenceMinValue); } { - HistogramPointer tempHistptr = HistogramType::New(); + const HistogramPointer tempHistptr = HistogramType::New(); this->ConstructHistogramFromIntensityRange(reference, tempHistptr, referenceIntensityThreshold, @@ -196,7 +196,7 @@ HistogramMatchingImageFilter:: } } - InputImageConstPointer source = this->GetSourceImage(); + const InputImageConstPointer source = this->GetSourceImage(); this->ComputeMinMaxMean(source, m_SourceMinValue, m_SourceMaxValue, sourceMeanValue); @@ -281,7 +281,7 @@ HistogramMatchingImageFilter:: OutputPixelType outputIntensityThreshold; - OutputImagePointer output = this->GetOutput(); + const OutputImagePointer output = this->GetOutput(); this->ComputeMinMaxMean(output, outputMinValue, outputMaxValue, outputMeanValue); @@ -316,8 +316,8 @@ void HistogramMatchingImageFilter::DynamicThreadedGenerateData( const OutputImageRegionType & outputRegionForThread) { - InputImageConstPointer input = this->GetSourceImage(); - OutputImagePointer output = this->GetOutput(); + const InputImageConstPointer input = this->GetSourceImage(); + const OutputImagePointer output = this->GetOutput(); // Transform the source image and write to output. using InputConstIterator = ImageRegionConstIterator; diff --git a/Modules/Filtering/ImageIntensity/include/itkMaskImageFilter.h b/Modules/Filtering/ImageIntensity/include/itkMaskImageFilter.h index 8d85ffab058..d309b5a747c 100644 --- a/Modules/Filtering/ImageIntensity/include/itkMaskImageFilter.h +++ b/Modules/Filtering/ImageIntensity/include/itkMaskImageFilter.h @@ -272,8 +272,8 @@ class ITK_TEMPLATE_EXPORT MaskImageFilter : public BinaryGeneratorImageFilter currentValue = this->GetFunctor().GetOutsideValue(); - VariableLengthVector zeroVector(currentValue.GetSize()); + const VariableLengthVector currentValue = this->GetFunctor().GetOutsideValue(); + VariableLengthVector zeroVector(currentValue.GetSize()); zeroVector.Fill(TValue{}); if (currentValue == zeroVector) diff --git a/Modules/Filtering/ImageIntensity/include/itkMaskNegatedImageFilter.h b/Modules/Filtering/ImageIntensity/include/itkMaskNegatedImageFilter.h index fa88d56892b..2b28506f2de 100644 --- a/Modules/Filtering/ImageIntensity/include/itkMaskNegatedImageFilter.h +++ b/Modules/Filtering/ImageIntensity/include/itkMaskNegatedImageFilter.h @@ -271,8 +271,8 @@ class ITK_TEMPLATE_EXPORT MaskNegatedImageFilter // image. Otherwise, check that the number of components in the // outside value is the same as the number of components in the // output image. If not, throw an exception. - VariableLengthVector currentValue = this->GetFunctor().GetOutsideValue(); - VariableLengthVector zeroVector(currentValue.GetSize()); + const VariableLengthVector currentValue = this->GetFunctor().GetOutsideValue(); + VariableLengthVector zeroVector(currentValue.GetSize()); zeroVector.Fill(TValue{}); if (currentValue == zeroVector) diff --git a/Modules/Filtering/ImageIntensity/include/itkNaryFunctorImageFilter.hxx b/Modules/Filtering/ImageIntensity/include/itkNaryFunctorImageFilter.hxx index 3ffbcb4c29c..1abfb4dfa3e 100644 --- a/Modules/Filtering/ImageIntensity/include/itkNaryFunctorImageFilter.hxx +++ b/Modules/Filtering/ImageIntensity/include/itkNaryFunctorImageFilter.hxx @@ -52,7 +52,7 @@ NaryFunctorImageFilter::DynamicThreadedGen // count the number of inputs that are non-null for (unsigned int i = 0; i < numberOfInputImages; ++i) { - InputImagePointer inputPtr = dynamic_cast(ProcessObject::GetInput(i)); + const InputImagePointer inputPtr = dynamic_cast(ProcessObject::GetInput(i)); if (inputPtr) { @@ -71,7 +71,7 @@ NaryFunctorImageFilter::DynamicThreadedGen NaryArrayType naryInputArray(numberOfValidInputImages); - OutputImagePointer outputPtr = this->GetOutput(0); + const OutputImagePointer outputPtr = this->GetOutput(0); typename std::vector::iterator regionIterators; const typename std::vector::const_iterator regionItEnd = inputItrVector.end(); diff --git a/Modules/Filtering/ImageIntensity/include/itkNormalizeImageFilter.hxx b/Modules/Filtering/ImageIntensity/include/itkNormalizeImageFilter.hxx index 0021e2a8922..2af175e2606 100644 --- a/Modules/Filtering/ImageIntensity/include/itkNormalizeImageFilter.hxx +++ b/Modules/Filtering/ImageIntensity/include/itkNormalizeImageFilter.hxx @@ -38,7 +38,7 @@ NormalizeImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); if (this->GetInput()) { - InputImagePointer image = const_cast(this->GetInput()); + const InputImagePointer image = const_cast(this->GetInput()); image->SetRequestedRegionToLargestPossibleRegion(); } } diff --git a/Modules/Filtering/ImageIntensity/include/itkPolylineMask2DImageFilter.hxx b/Modules/Filtering/ImageIntensity/include/itkPolylineMask2DImageFilter.hxx index 4175881bfea..617aa1279f8 100644 --- a/Modules/Filtering/ImageIntensity/include/itkPolylineMask2DImageFilter.hxx +++ b/Modules/Filtering/ImageIntensity/include/itkPolylineMask2DImageFilter.hxx @@ -67,9 +67,10 @@ PolylineMask2DImageFilter::GenerateData() using VertexType = typename TPolyline::VertexType; using VertexListType = typename TPolyline::VertexListType; - typename TInputImage::ConstPointer inputImagePtr(dynamic_cast(this->ProcessObject::GetInput(0))); - typename TPolyline::ConstPointer polylinePtr(dynamic_cast(this->ProcessObject::GetInput(1))); - typename TOutputImage::Pointer outputImagePtr(dynamic_cast(this->ProcessObject::GetOutput(0))); + const typename TInputImage::ConstPointer inputImagePtr( + dynamic_cast(this->ProcessObject::GetInput(0))); + const typename TPolyline::ConstPointer polylinePtr(dynamic_cast(this->ProcessObject::GetInput(1))); + const typename TOutputImage::Pointer outputImagePtr(dynamic_cast(this->ProcessObject::GetOutput(0))); outputImagePtr->SetOrigin(inputImagePtr->GetOrigin()); outputImagePtr->SetSpacing(inputImagePtr->GetSpacing()); @@ -110,10 +111,10 @@ PolylineMask2DImageFilter::GenerateData() bool pflag; /* define background, foreground pixel values and unlabeled pixel value */ - PixelType zero_val{}; - auto u_val = static_cast(0); - auto b_val = static_cast(2); - auto f_val = static_cast(255); + const PixelType zero_val{}; + auto u_val = static_cast(0); + auto b_val = static_cast(2); + auto f_val = static_cast(255); outputImagePtr->FillBuffer(u_val); pstartVertex = piter.Value(); diff --git a/Modules/Filtering/ImageIntensity/include/itkPolylineMaskImageFilter.hxx b/Modules/Filtering/ImageIntensity/include/itkPolylineMaskImageFilter.hxx index 5685389bd57..cb998bca48b 100644 --- a/Modules/Filtering/ImageIntensity/include/itkPolylineMaskImageFilter.hxx +++ b/Modules/Filtering/ImageIntensity/include/itkPolylineMaskImageFilter.hxx @@ -133,7 +133,7 @@ PolylineMaskImageFilter::Transfor ProjPlanePointType result; - double factor = m_FocalDistance / (rotated[2]); + const double factor = m_FocalDistance / (rotated[2]); result[0] = m_FocalPoint[0] + (rotated[0] * factor); result[1] = m_FocalPoint[1] + (rotated[1] * factor); @@ -158,11 +158,12 @@ PolylineMaskImageFilter::Generate using OriginType = Point; - typename TInputImage::ConstPointer inputImagePtr(dynamic_cast(this->ProcessObject::GetInput(0))); - typename TPolyline::ConstPointer polylinePtr(dynamic_cast(this->ProcessObject::GetInput(1))); - typename TOutputImage::Pointer outputImagePtr(dynamic_cast(this->ProcessObject::GetOutput(0))); + const typename TInputImage::ConstPointer inputImagePtr( + dynamic_cast(this->ProcessObject::GetInput(0))); + const typename TPolyline::ConstPointer polylinePtr(dynamic_cast(this->ProcessObject::GetInput(1))); + const typename TOutputImage::Pointer outputImagePtr(dynamic_cast(this->ProcessObject::GetOutput(0))); - OriginType originInput{}; + const OriginType originInput{}; // outputImagePtr->SetOrigin(inputImagePtr->GetOrigin()); outputImagePtr->SetOrigin(originInput); outputImagePtr->SetSpacing(inputImagePtr->GetSpacing()); @@ -293,7 +294,7 @@ PolylineMaskImageFilter::Generate projectionStart[1] = 0; ProjectionImageSizeType projectionSize; - IndexValueType pad = 5; + const IndexValueType pad = 5; projectionSize[0] = (IndexValueType)(bounds[1] - bounds[0]) + pad; projectionSize[1] = (IndexValueType)(bounds[3] - bounds[2]) + pad; @@ -323,7 +324,7 @@ PolylineMaskImageFilter::Generate projectionImagePtr->AllocateInitialized(); using ProjectionImageIteratorType = ImageRegionIterator; - ProjectionImageIteratorType projectionIt(projectionImagePtr, projectionImagePtr->GetLargestPossibleRegion()); + const ProjectionImageIteratorType projectionIt(projectionImagePtr, projectionImagePtr->GetLargestPossibleRegion()); itkDebugMacro("Rotation matrix" << m_RotationMatrix); diff --git a/Modules/Filtering/ImageIntensity/include/itkRescaleIntensityImageFilter.h b/Modules/Filtering/ImageIntensity/include/itkRescaleIntensityImageFilter.h index 3d2af64deb3..bc6208edbdc 100644 --- a/Modules/Filtering/ImageIntensity/include/itkRescaleIntensityImageFilter.h +++ b/Modules/Filtering/ImageIntensity/include/itkRescaleIntensityImageFilter.h @@ -74,8 +74,8 @@ class ITK_TEMPLATE_EXPORT IntensityLinearTransform inline TOutput operator()(const TInput & x) const { - RealType value = static_cast(x) * m_Factor + m_Offset; - auto result = static_cast(value); + const RealType value = static_cast(x) * m_Factor + m_Offset; + auto result = static_cast(value); result = (result > m_Maximum) ? m_Maximum : result; result = (result < m_Minimum) ? m_Minimum : result; diff --git a/Modules/Filtering/ImageIntensity/include/itkVectorExpandImageFilter.hxx b/Modules/Filtering/ImageIntensity/include/itkVectorExpandImageFilter.hxx index c613cb92741..6980a9f5b8a 100644 --- a/Modules/Filtering/ImageIntensity/include/itkVectorExpandImageFilter.hxx +++ b/Modules/Filtering/ImageIntensity/include/itkVectorExpandImageFilter.hxx @@ -111,7 +111,7 @@ void VectorExpandImageFilter::DynamicThreadedGenerateData( const OutputImageRegionType & outputRegionForThread) { - OutputImagePointer outputPtr = this->GetOutput(); + const OutputImagePointer outputPtr = this->GetOutput(); using OutputIterator = ImageRegionIteratorWithIndex; TotalProgressReporter progress(this, outputPtr->GetRequestedRegion().GetNumberOfPixels()); @@ -167,8 +167,8 @@ VectorExpandImageFilter::GenerateInputRequestedRegion { Superclass::GenerateInputRequestedRegion(); - InputImagePointer inputPtr = const_cast(this->GetInput()); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImagePointer inputPtr = const_cast(this->GetInput()); + const OutputImagePointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -230,8 +230,8 @@ VectorExpandImageFilter::GenerateOutputInformation() { Superclass::GenerateOutputInformation(); - InputImagePointer inputPtr = const_cast(this->GetInput()); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImagePointer inputPtr = const_cast(this->GetInput()); + const OutputImagePointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { diff --git a/Modules/Filtering/ImageIntensity/include/itkVectorRescaleIntensityImageFilter.hxx b/Modules/Filtering/ImageIntensity/include/itkVectorRescaleIntensityImageFilter.hxx index b9fcb705359..c6739eba676 100644 --- a/Modules/Filtering/ImageIntensity/include/itkVectorRescaleIntensityImageFilter.hxx +++ b/Modules/Filtering/ImageIntensity/include/itkVectorRescaleIntensityImageFilter.hxx @@ -50,7 +50,7 @@ VectorRescaleIntensityImageFilter::BeforeThreadedGene itkExceptionMacro("Maximum output value cannot be negative. You are passing " << m_OutputMaximumMagnitude); } - InputImagePointer inputImage = this->GetInput(); + const InputImagePointer inputImage = this->GetInput(); using InputIterator = ImageRegionConstIterator; @@ -60,7 +60,7 @@ VectorRescaleIntensityImageFilter::BeforeThreadedGene while (!it.IsAtEnd()) { - InputRealType magnitude = it.Get().GetSquaredNorm(); + const InputRealType magnitude = it.Get().GetSquaredNorm(); if (magnitude > maximumSquaredMagnitude) { maximumSquaredMagnitude = magnitude; diff --git a/Modules/Filtering/ImageIntensity/test/itkAbsImageFilterAndAdaptorTest.cxx b/Modules/Filtering/ImageIntensity/test/itkAbsImageFilterAndAdaptorTest.cxx index 1af1344dd78..4510f7434f8 100644 --- a/Modules/Filtering/ImageIntensity/test/itkAbsImageFilterAndAdaptorTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkAbsImageFilterAndAdaptorTest.cxx @@ -97,7 +97,7 @@ itkAbsImageFilterAndAdaptorTest(int, char *[]) filter->SetInput(inputImage); // Get the Smart Pointer to the Filter Output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Execute the filter filter->Update(); @@ -153,7 +153,7 @@ itkAbsImageFilterAndAdaptorTest(int, char *[]) diffFilter->Update(); // Get the Smart Pointer to the Diff filter Output - OutputImageType::Pointer diffImage = diffFilter->GetOutput(); + const OutputImageType::Pointer diffImage = diffFilter->GetOutput(); // Check the content of the diff image std::cout << "Comparing the results with those of an Adaptor" << std::endl; diff --git a/Modules/Filtering/ImageIntensity/test/itkAcosImageFilterAndAdaptorTest.cxx b/Modules/Filtering/ImageIntensity/test/itkAcosImageFilterAndAdaptorTest.cxx index 247edae6d54..0550aed8b2d 100644 --- a/Modules/Filtering/ImageIntensity/test/itkAcosImageFilterAndAdaptorTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkAcosImageFilterAndAdaptorTest.cxx @@ -95,7 +95,7 @@ itkAcosImageFilterAndAdaptorTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, AcosImageFilter, UnaryGeneratorImageFilter); - itk::SimpleFilterWatcher watch(filter); + const itk::SimpleFilterWatcher watch(filter); // Set the input image filter->SetInput(inputImage); @@ -105,7 +105,7 @@ itkAcosImageFilterAndAdaptorTest(int, char *[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output OutputIteratorType ot(outputImage, outputImage->GetRequestedRegion()); @@ -155,7 +155,7 @@ itkAcosImageFilterAndAdaptorTest(int, char *[]) diffFilter->Update(); // Get the filter output - OutputImageType::Pointer diffImage = diffFilter->GetOutput(); + const OutputImageType::Pointer diffImage = diffFilter->GetOutput(); // Check the content of the diff image // diff --git a/Modules/Filtering/ImageIntensity/test/itkAdaptImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkAdaptImageFilterTest.cxx index 419522419b2..f0e2667c0bf 100644 --- a/Modules/Filtering/ImageIntensity/test/itkAdaptImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkAdaptImageFilterTest.cxx @@ -72,7 +72,7 @@ itkAdaptImageFilterTest(int, char *[]) index[0] = 0; index[1] = 0; - myRGBImageType::RegionType region{ index, size }; + const myRGBImageType::RegionType region{ index, size }; auto myImage = myRGBImageType::New(); @@ -112,9 +112,9 @@ itkAdaptImageFilterTest(int, char *[]) bool passed = true; // Convert to a red image - itk::AdaptImageFilter::Pointer adaptImageToRed = + const itk::AdaptImageFilter::Pointer adaptImageToRed = itk::AdaptImageFilter::New(); - itk::SimpleFilterWatcher redWatcher(adaptImageToRed, "Red"); + const itk::SimpleFilterWatcher redWatcher(adaptImageToRed, "Red"); adaptImageToRed->SetInput(myImage); adaptImageToRed->UpdateLargestPossibleRegion(); @@ -137,9 +137,9 @@ itkAdaptImageFilterTest(int, char *[]) } // Convert to a green image - itk::AdaptImageFilter::Pointer adaptImageToGreen = + const itk::AdaptImageFilter::Pointer adaptImageToGreen = itk::AdaptImageFilter::New(); - itk::SimpleFilterWatcher greenWatcher(adaptImageToGreen, "Green"); + const itk::SimpleFilterWatcher greenWatcher(adaptImageToGreen, "Green"); adaptImageToGreen->SetInput(myImage); adaptImageToGreen->UpdateLargestPossibleRegion(); @@ -163,9 +163,9 @@ itkAdaptImageFilterTest(int, char *[]) } // Convert to a blue image - itk::AdaptImageFilter::Pointer adaptImageToBlue = + const itk::AdaptImageFilter::Pointer adaptImageToBlue = itk::AdaptImageFilter::New(); - itk::SimpleFilterWatcher blueWatcher(adaptImageToBlue, "Blue"); + const itk::SimpleFilterWatcher blueWatcher(adaptImageToBlue, "Blue"); adaptImageToBlue->SetInput(myImage); adaptImageToBlue->UpdateLargestPossibleRegion(); diff --git a/Modules/Filtering/ImageIntensity/test/itkAdaptImageFilterTest2.cxx b/Modules/Filtering/ImageIntensity/test/itkAdaptImageFilterTest2.cxx index 2ab4024cdd3..a493536e2a1 100644 --- a/Modules/Filtering/ImageIntensity/test/itkAdaptImageFilterTest2.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkAdaptImageFilterTest2.cxx @@ -67,7 +67,7 @@ itkAdaptImageFilterTest2(int, char *[]) index[0] = 0; index[1] = 0; - myVectorImageType::RegionType region{ index, size }; + const myVectorImageType::RegionType region{ index, size }; auto myImage = myVectorImageType::New(); diff --git a/Modules/Filtering/ImageIntensity/test/itkAddImageAdaptorTest.cxx b/Modules/Filtering/ImageIntensity/test/itkAddImageAdaptorTest.cxx index 3f12c412716..817d19b2e63 100644 --- a/Modules/Filtering/ImageIntensity/test/itkAddImageAdaptorTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkAddImageAdaptorTest.cxx @@ -89,7 +89,7 @@ itkAddImageAdaptorTest(int, char *[]) auto addAdaptor = AdaptorType::New(); - PixelType additiveConstant = 19; + const PixelType additiveConstant = 19; addAdaptor->SetImage(inputImage); addAdaptor->SetValue(additiveConstant); @@ -104,7 +104,7 @@ itkAddImageAdaptorTest(int, char *[]) diffFilter->Update(); // Get the Smart Pointer to the Diff filter Output - ImageType::Pointer diffImage = diffFilter->GetOutput(); + const ImageType::Pointer diffImage = diffFilter->GetOutput(); // Check the content of the diff image std::cout << "Comparing the results with those of an Adaptor" << std::endl; @@ -124,7 +124,7 @@ itkAddImageAdaptorTest(int, char *[]) auto v1 = static_cast(dt.Get()); auto v2 = static_cast(additiveConstant); - RealPixelType diff = itk::Math::abs(v1 - v2); + const RealPixelType diff = itk::Math::abs(v1 - v2); if (diff > itk::Math::eps) { @@ -144,16 +144,16 @@ itkAddImageAdaptorTest(int, char *[]) index[1] = 1; index[2] = 1; - PixelType p1 = addAdaptor->GetPixel(index); + const PixelType p1 = addAdaptor->GetPixel(index); std::cout << " Pixel " << index << " had value = " << p1 << std::endl; - PixelType newValue = 27; + const PixelType newValue = 27; std::cout << " We set Pixel " << index << " to value = " << newValue << std::endl; addAdaptor->SetPixel(index, newValue); - PixelType p2 = addAdaptor->GetPixel(index); + const PixelType p2 = addAdaptor->GetPixel(index); std::cout << " Now Pixel " << index << " has value = " << p2 << std::endl; if (p2 != newValue) diff --git a/Modules/Filtering/ImageIntensity/test/itkAddImageFilterFrameTest.cxx b/Modules/Filtering/ImageIntensity/test/itkAddImageFilterFrameTest.cxx index 77d9012f7d6..5e0d04c988c 100644 --- a/Modules/Filtering/ImageIntensity/test/itkAddImageFilterFrameTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkAddImageFilterFrameTest.cxx @@ -51,8 +51,8 @@ itkAddImageFilterFrameTest(int, char *[]) using myFilterTypePointer = myFilterType::Pointer; // Create two images - myImageType1Pointer inputImageA = myImageType1::New(); - myImageType2Pointer inputImageB = myImageType2::New(); + const myImageType1Pointer inputImageA = myImageType1::New(); + const myImageType2Pointer inputImageB = myImageType2::New(); // Define their size, and start index mySizeType size; @@ -65,7 +65,7 @@ itkAddImageFilterFrameTest(int, char *[]) start[1] = 0; start[2] = 0; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; // Initialize Image A inputImageA->SetRegions(region); @@ -105,7 +105,7 @@ itkAddImageFilterFrameTest(int, char *[]) // Create an ADD Filter - myFilterTypePointer filter = myFilterType::New(); + const myFilterTypePointer filter = myFilterType::New(); // Connect the input images @@ -114,7 +114,7 @@ itkAddImageFilterFrameTest(int, char *[]) // Get the Smart Pointer to the Filter Output - myImageType3Pointer outputImage = filter->GetOutput(); + const myImageType3Pointer outputImage = filter->GetOutput(); // Make Image B have a different origin auto borigin = itk::MakeFilled(0.01); diff --git a/Modules/Filtering/ImageIntensity/test/itkAddImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkAddImageFilterTest.cxx index 52b2ad9adf6..20403d9d96f 100644 --- a/Modules/Filtering/ImageIntensity/test/itkAddImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkAddImageFilterTest.cxx @@ -105,7 +105,7 @@ itkAddImageFilterTest(int, char *[]) // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output diff --git a/Modules/Filtering/ImageIntensity/test/itkAndImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkAndImageFilterTest.cxx index 777afd030f2..295fc2e81fe 100644 --- a/Modules/Filtering/ImageIntensity/test/itkAndImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkAndImageFilterTest.cxx @@ -86,7 +86,7 @@ itkAndImageFilterTest(int argc, char * argv[]) it1.GoToBegin(); // Initialize the content of Image A - InputImage1Type::PixelType valueA = 2; + const InputImage1Type::PixelType valueA = 2; while (!it1.IsAtEnd()) { it1.Set(valueA); @@ -98,7 +98,7 @@ itkAndImageFilterTest(int argc, char * argv[]) it2.GoToBegin(); // Initialize the content of Image B - InputImage2Type::PixelType valueB = 3; + const InputImage2Type::PixelType valueB = 3; while (!it2.IsAtEnd()) { it2.Set(valueB); @@ -121,7 +121,7 @@ itkAndImageFilterTest(int argc, char * argv[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Write the result image using WriterType = itk::ImageFileWriter; diff --git a/Modules/Filtering/ImageIntensity/test/itkArithmeticOpsFunctorsTest.cxx b/Modules/Filtering/ImageIntensity/test/itkArithmeticOpsFunctorsTest.cxx index d962dae984b..639107e6026 100644 --- a/Modules/Filtering/ImageIntensity/test/itkArithmeticOpsFunctorsTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkArithmeticOpsFunctorsTest.cxx @@ -24,8 +24,8 @@ TEST(ArithmeticOpsTest, DivFloorFloat) { using OpType = itk::Functor::DivFloor; - OpType op1; - OpType op2; + OpType op1; + const OpType op2; EXPECT_EQ(op1, op1); EXPECT_EQ(op1, op2); @@ -41,8 +41,8 @@ TEST(ArithmeticOpsTest, DivFloorShort) { using OpType = itk::Functor::DivFloor; - OpType op1; - OpType op2; + OpType op1; + const OpType op2; EXPECT_EQ(op1, op1); EXPECT_EQ(op1, op2); @@ -59,8 +59,8 @@ TEST(ArithmeticOpsTest, DivReal) using OpType = itk::Functor::DivReal; - OpType op1; - OpType op2; + OpType op1; + const OpType op2; EXPECT_EQ(op1, op1); EXPECT_EQ(op1, op2); @@ -78,8 +78,8 @@ TEST(ArithmeticOpsTest, UnaryMinus) using OpType = itk::Functor::UnaryMinus; - OpType op1; - OpType op2; + OpType op1; + const OpType op2; EXPECT_EQ(op1, op1); EXPECT_EQ(op1, op2); diff --git a/Modules/Filtering/ImageIntensity/test/itkAsinImageFilterAndAdaptorTest.cxx b/Modules/Filtering/ImageIntensity/test/itkAsinImageFilterAndAdaptorTest.cxx index 356c3cee51c..10813aa53b4 100644 --- a/Modules/Filtering/ImageIntensity/test/itkAsinImageFilterAndAdaptorTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkAsinImageFilterAndAdaptorTest.cxx @@ -101,7 +101,7 @@ itkAsinImageFilterAndAdaptorTest(int, char *[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output OutputIteratorType ot(outputImage, outputImage->GetRequestedRegion()); @@ -151,7 +151,7 @@ itkAsinImageFilterAndAdaptorTest(int, char *[]) diffFilter->Update(); // Get the filter output - OutputImageType::Pointer diffImage = diffFilter->GetOutput(); + const OutputImageType::Pointer diffImage = diffFilter->GetOutput(); // Check the content of the diff image // diff --git a/Modules/Filtering/ImageIntensity/test/itkAtan2ImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkAtan2ImageFilterTest.cxx index a2e4f1aeb7e..75d0ca1ace1 100644 --- a/Modules/Filtering/ImageIntensity/test/itkAtan2ImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkAtan2ImageFilterTest.cxx @@ -114,7 +114,7 @@ itkAtan2ImageFilterTest(int, char *[]) filter->SetInput2(cosImage); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Execute the filter filter->Update(); diff --git a/Modules/Filtering/ImageIntensity/test/itkAtanImageFilterAndAdaptorTest.cxx b/Modules/Filtering/ImageIntensity/test/itkAtanImageFilterAndAdaptorTest.cxx index 41afaa973d2..bbaf27ddcd1 100644 --- a/Modules/Filtering/ImageIntensity/test/itkAtanImageFilterAndAdaptorTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkAtanImageFilterAndAdaptorTest.cxx @@ -100,7 +100,7 @@ itkAtanImageFilterAndAdaptorTest(int, char *[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output OutputIteratorType ot(outputImage, outputImage->GetRequestedRegion()); @@ -150,7 +150,7 @@ itkAtanImageFilterAndAdaptorTest(int, char *[]) diffFilter->Update(); // Get the filter output - OutputImageType::Pointer diffImage = diffFilter->GetOutput(); + const OutputImageType::Pointer diffImage = diffFilter->GetOutput(); // Check the content of the diff image // diff --git a/Modules/Filtering/ImageIntensity/test/itkBinaryMagnitudeImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkBinaryMagnitudeImageFilterTest.cxx index e2293f0366f..f82ec6479ec 100644 --- a/Modules/Filtering/ImageIntensity/test/itkBinaryMagnitudeImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkBinaryMagnitudeImageFilterTest.cxx @@ -121,7 +121,7 @@ itkBinaryMagnitudeImageFilterTest(int, char *[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output OutputImageIteratorType oIt(outputImage, outputImage->GetBufferedRegion()); diff --git a/Modules/Filtering/ImageIntensity/test/itkBitwiseOpsFunctorsTest.cxx b/Modules/Filtering/ImageIntensity/test/itkBitwiseOpsFunctorsTest.cxx index 24ba969ae1c..3cab85a2e0a 100644 --- a/Modules/Filtering/ImageIntensity/test/itkBitwiseOpsFunctorsTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkBitwiseOpsFunctorsTest.cxx @@ -24,8 +24,8 @@ TEST(BitwiseOpsTest, DivFloor) { using OpType = itk::Functor::BitwiseNot; - OpType op1; - OpType op2; + OpType op1; + const OpType op2; EXPECT_EQ(op1, op1); EXPECT_EQ(op1, op2); diff --git a/Modules/Filtering/ImageIntensity/test/itkBoundedReciprocalImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkBoundedReciprocalImageFilterTest.cxx index f674e244f07..100e827df06 100644 --- a/Modules/Filtering/ImageIntensity/test/itkBoundedReciprocalImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkBoundedReciprocalImageFilterTest.cxx @@ -62,7 +62,7 @@ itkBoundedReciprocalImageFilterTest(int argc, char * argv[]) ImageIterator inIter(inputImage, inputImage->GetBufferedRegion()); ImageIterator outIter(outputImage, outputImage->GetBufferedRegion()); - double tolerance = 10e-6; + const double tolerance = 10e-6; std::cerr.precision(static_cast(itk::Math::abs(std::log10(tolerance)))); for (; !inIter.IsAtEnd() || !outIter.IsAtEnd(); ++inIter, ++outIter) diff --git a/Modules/Filtering/ImageIntensity/test/itkClampImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkClampImageFilterTest.cxx index 8fbe5c107a1..6ad798e3403 100644 --- a/Modules/Filtering/ImageIntensity/test/itkClampImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkClampImageFilterTest.cxx @@ -42,7 +42,7 @@ GetClampTypeName() { std::string name; #ifdef GCC_USEDEMANGLE - char const * mangledName = typeid(T).name(); + const char * mangledName = typeid(T).name(); int status; char * unmangled = abi::__cxa_demangle(mangledName, nullptr, nullptr, &status); name = unmangled; @@ -66,7 +66,7 @@ TestClampFromTo() using SourceType = itk::RandomImageSource; auto source = SourceType::New(); - typename InputImageType::SizeType randomSize = { { 18, 17, 23 } }; + const typename InputImageType::SizeType randomSize = { { 18, 17, 23 } }; source->SetSize(randomSize); source->UpdateLargestPossibleRegion(); auto sourceCopy = InputImageType::New(); @@ -150,18 +150,18 @@ template bool TestClampFrom() { - bool success = TestClampFromTo() && TestClampFromTo() && - TestClampFromTo() && TestClampFromTo() && - TestClampFromTo() && TestClampFromTo() && - TestClampFromTo() && TestClampFromTo() && + const bool success = + TestClampFromTo() && TestClampFromTo() && + TestClampFromTo() && TestClampFromTo() && + TestClampFromTo() && TestClampFromTo() && + TestClampFromTo() && TestClampFromTo() && // Visual Studio has a false failure in due to // imprecise integer to double conversion. It causes the comparison // dInValue > expectedMax to pass when it should fail. #ifndef _MSC_VER - TestClampFromTo() && - TestClampFromTo() && + TestClampFromTo() && TestClampFromTo() && #endif - TestClampFromTo() && TestClampFromTo(); + TestClampFromTo() && TestClampFromTo(); return success; } @@ -179,7 +179,7 @@ TestClampFromToWithCustomBounds() source->SetMin(static_cast(0)); source->SetMax(static_cast(20)); - typename InputImageType::SizeType randomSize = { { 18, 17, 23 } }; + const typename InputImageType::SizeType randomSize = { { 18, 17, 23 } }; source->SetSize(randomSize); source->UpdateLargestPossibleRegion(); auto sourceCopy = InputImageType::New(); @@ -219,9 +219,9 @@ TestClampFromToWithCustomBounds() TOutputPixelType outValue = ot.Value(); TOutputPixelType expectedValue; - auto dInValue = static_cast(inValue); - double expectedMin = filter->GetLowerBound(); - double expectedMax = filter->GetUpperBound(); + auto dInValue = static_cast(inValue); + const double expectedMin = filter->GetLowerBound(); + const double expectedMax = filter->GetUpperBound(); if (dInValue < expectedMin) @@ -264,18 +264,18 @@ template bool TestClampFromWithCustomBounds() { - bool success = TestClampFromToWithCustomBounds() && - TestClampFromToWithCustomBounds() && - TestClampFromToWithCustomBounds() && - TestClampFromToWithCustomBounds() && - TestClampFromToWithCustomBounds() && - TestClampFromToWithCustomBounds() && - TestClampFromToWithCustomBounds() && - TestClampFromToWithCustomBounds() && - TestClampFromToWithCustomBounds() && - TestClampFromToWithCustomBounds() && - TestClampFromToWithCustomBounds() && - TestClampFromToWithCustomBounds(); + const bool success = TestClampFromToWithCustomBounds() && + TestClampFromToWithCustomBounds() && + TestClampFromToWithCustomBounds() && + TestClampFromToWithCustomBounds() && + TestClampFromToWithCustomBounds() && + TestClampFromToWithCustomBounds() && + TestClampFromToWithCustomBounds() && + TestClampFromToWithCustomBounds() && + TestClampFromToWithCustomBounds() && + TestClampFromToWithCustomBounds() && + TestClampFromToWithCustomBounds() && + TestClampFromToWithCustomBounds(); return success; } @@ -291,17 +291,18 @@ itkClampImageFilterTest(int, char *[]) auto filter = FilterType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, ClampImageFilter, UnaryFunctorImageFilter); - bool success = TestClampFrom() && TestClampFrom() && TestClampFrom() && - TestClampFrom() && TestClampFrom() && TestClampFrom() && - TestClampFrom() && TestClampFrom() && TestClampFrom() && - TestClampFrom() && TestClampFrom() && TestClampFrom() && - - TestClampFromWithCustomBounds() && TestClampFromWithCustomBounds() && - TestClampFromWithCustomBounds() && TestClampFromWithCustomBounds() && - TestClampFromWithCustomBounds() && TestClampFromWithCustomBounds() && - TestClampFromWithCustomBounds() && TestClampFromWithCustomBounds() && - TestClampFromWithCustomBounds() && TestClampFromWithCustomBounds() && - TestClampFromWithCustomBounds() && TestClampFromWithCustomBounds(); + const bool success = TestClampFrom() && TestClampFrom() && TestClampFrom() && + TestClampFrom() && TestClampFrom() && TestClampFrom() && + TestClampFrom() && TestClampFrom() && TestClampFrom() && + TestClampFrom() && TestClampFrom() && TestClampFrom() && + + TestClampFromWithCustomBounds() && TestClampFromWithCustomBounds() && + TestClampFromWithCustomBounds() && TestClampFromWithCustomBounds() && + TestClampFromWithCustomBounds() && TestClampFromWithCustomBounds() && + TestClampFromWithCustomBounds() && TestClampFromWithCustomBounds() && + TestClampFromWithCustomBounds() && + TestClampFromWithCustomBounds() && TestClampFromWithCustomBounds() && + TestClampFromWithCustomBounds(); std::cout << std::endl; if (!success) diff --git a/Modules/Filtering/ImageIntensity/test/itkComplexToImaginaryFilterAndAdaptorTest.cxx b/Modules/Filtering/ImageIntensity/test/itkComplexToImaginaryFilterAndAdaptorTest.cxx index 0e51d0b471d..b0715563397 100644 --- a/Modules/Filtering/ImageIntensity/test/itkComplexToImaginaryFilterAndAdaptorTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkComplexToImaginaryFilterAndAdaptorTest.cxx @@ -74,7 +74,7 @@ itkComplexToImaginaryFilterAndAdaptorTest(int, char *[]) InputIteratorType it(inputImage, inputImage->GetBufferedRegion()); // Initialize the content of Image A - InputPixelType value(13, 25); + const InputPixelType value(13, 25); it.GoToBegin(); while (!it.IsAtEnd()) { @@ -97,7 +97,7 @@ itkComplexToImaginaryFilterAndAdaptorTest(int, char *[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output OutputIteratorType ot(outputImage, outputImage->GetRequestedRegion()); @@ -146,7 +146,7 @@ itkComplexToImaginaryFilterAndAdaptorTest(int, char *[]) diffFilter->Update(); // Get the Smart Pointer to the Diff filter Output - OutputImageType::Pointer diffImage = diffFilter->GetOutput(); + const OutputImageType::Pointer diffImage = diffFilter->GetOutput(); // Check the content of the diff image // diff --git a/Modules/Filtering/ImageIntensity/test/itkComplexToModulusFilterAndAdaptorTest.cxx b/Modules/Filtering/ImageIntensity/test/itkComplexToModulusFilterAndAdaptorTest.cxx index aa95040df0c..d1e1dcffd3b 100644 --- a/Modules/Filtering/ImageIntensity/test/itkComplexToModulusFilterAndAdaptorTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkComplexToModulusFilterAndAdaptorTest.cxx @@ -74,9 +74,9 @@ itkComplexToModulusFilterAndAdaptorTest(int, char *[]) InputIteratorType it(inputImage, inputImage->GetBufferedRegion()); // Initialize the content of Image A - InputPixelType value(13, 25); + const InputPixelType value(13, 25); - double modulus = std::sqrt(value.real() * value.real() + value.imag() * value.imag()); + const double modulus = std::sqrt(value.real() * value.real() + value.imag() * value.imag()); std::cout << "Modulus of input pixel = " << modulus << std::endl; it.GoToBegin(); @@ -101,7 +101,7 @@ itkComplexToModulusFilterAndAdaptorTest(int, char *[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output OutputIteratorType ot(outputImage, outputImage->GetRequestedRegion()); @@ -115,7 +115,7 @@ itkComplexToModulusFilterAndAdaptorTest(int, char *[]) const InputImageType::PixelType input = it.Get(); const OutputImageType::PixelType output = ot.Get(); - double normd = std::sqrt(input.real() * input.real() + input.imag() * input.imag()); + const double normd = std::sqrt(input.real() * input.real() + input.imag() * input.imag()); const auto norm = static_cast(normd); @@ -154,7 +154,7 @@ itkComplexToModulusFilterAndAdaptorTest(int, char *[]) diffFilter->Update(); // Get the filter output - OutputImageType::Pointer diffImage = diffFilter->GetOutput(); + const OutputImageType::Pointer diffImage = diffFilter->GetOutput(); // Check the content of the diff image: // Create an iterator for going through the image output diff --git a/Modules/Filtering/ImageIntensity/test/itkComplexToPhaseFilterAndAdaptorTest.cxx b/Modules/Filtering/ImageIntensity/test/itkComplexToPhaseFilterAndAdaptorTest.cxx index f577adc83c6..9c41e5af392 100644 --- a/Modules/Filtering/ImageIntensity/test/itkComplexToPhaseFilterAndAdaptorTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkComplexToPhaseFilterAndAdaptorTest.cxx @@ -74,7 +74,7 @@ itkComplexToPhaseFilterAndAdaptorTest(int, char *[]) InputIteratorType it(inputImage, inputImage->GetBufferedRegion()); // Initialize the content of Image A - InputPixelType value(13, 25); + const InputPixelType value(13, 25); it.GoToBegin(); while (!it.IsAtEnd()) { @@ -97,7 +97,7 @@ itkComplexToPhaseFilterAndAdaptorTest(int, char *[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output OutputIteratorType ot(outputImage, outputImage->GetRequestedRegion()); @@ -111,7 +111,7 @@ itkComplexToPhaseFilterAndAdaptorTest(int, char *[]) const InputImageType::PixelType input = it.Get(); const OutputImageType::PixelType output = ot.Get(); - double phased = std::atan2(input.imag(), input.real()); + const double phased = std::atan2(input.imag(), input.real()); const auto phase = static_cast(phased); @@ -150,7 +150,7 @@ itkComplexToPhaseFilterAndAdaptorTest(int, char *[]) diffFilter->Update(); // Get the filter output - OutputImageType::Pointer diffImage = diffFilter->GetOutput(); + const OutputImageType::Pointer diffImage = diffFilter->GetOutput(); // Check the content of the diff image // diff --git a/Modules/Filtering/ImageIntensity/test/itkComplexToRealFilterAndAdaptorTest.cxx b/Modules/Filtering/ImageIntensity/test/itkComplexToRealFilterAndAdaptorTest.cxx index cadf908dd8d..9b25385712b 100644 --- a/Modules/Filtering/ImageIntensity/test/itkComplexToRealFilterAndAdaptorTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkComplexToRealFilterAndAdaptorTest.cxx @@ -74,7 +74,7 @@ itkComplexToRealFilterAndAdaptorTest(int, char *[]) InputIteratorType it(inputImage, inputImage->GetBufferedRegion()); // Initialize the content of Image A - InputPixelType value(13, 25); + const InputPixelType value(13, 25); it.GoToBegin(); while (!it.IsAtEnd()) { @@ -97,7 +97,7 @@ itkComplexToRealFilterAndAdaptorTest(int, char *[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output OutputIteratorType ot(outputImage, outputImage->GetRequestedRegion()); @@ -146,7 +146,7 @@ itkComplexToRealFilterAndAdaptorTest(int, char *[]) diffFilter->Update(); // Get the filter output - OutputImageType::Pointer diffImage = diffFilter->GetOutput(); + const OutputImageType::Pointer diffImage = diffFilter->GetOutput(); // Check the content of the diff image // diff --git a/Modules/Filtering/ImageIntensity/test/itkConstrainedValueAdditionImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkConstrainedValueAdditionImageFilterTest.cxx index 3d9703fdbf2..75deb3f1621 100644 --- a/Modules/Filtering/ImageIntensity/test/itkConstrainedValueAdditionImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkConstrainedValueAdditionImageFilterTest.cxx @@ -124,7 +124,7 @@ itkConstrainedValueAdditionImageFilterTest(int argc, char * argv[]) filter->Update(); // Get the filter Output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Write the result image using WriterType = itk::ImageFileWriter; diff --git a/Modules/Filtering/ImageIntensity/test/itkCosImageFilterAndAdaptorTest.cxx b/Modules/Filtering/ImageIntensity/test/itkCosImageFilterAndAdaptorTest.cxx index 64973499302..6aa7ef2cd23 100644 --- a/Modules/Filtering/ImageIntensity/test/itkCosImageFilterAndAdaptorTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkCosImageFilterAndAdaptorTest.cxx @@ -100,7 +100,7 @@ itkCosImageFilterAndAdaptorTest(int, char *[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output OutputIteratorType ot(outputImage, outputImage->GetRequestedRegion()); @@ -150,7 +150,7 @@ itkCosImageFilterAndAdaptorTest(int, char *[]) diffFilter->Update(); // Get the filter output - OutputImageType::Pointer diffImage = diffFilter->GetOutput(); + const OutputImageType::Pointer diffImage = diffFilter->GetOutput(); // Check the content of the diff image // diff --git a/Modules/Filtering/ImageIntensity/test/itkDivideImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkDivideImageFilterTest.cxx index 95a51747a9a..439a24bed23 100644 --- a/Modules/Filtering/ImageIntensity/test/itkDivideImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkDivideImageFilterTest.cxx @@ -103,7 +103,7 @@ itkDivideImageFilterTest(int, char *[]) // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output diff --git a/Modules/Filtering/ImageIntensity/test/itkDivideImageFilterTest2.cxx b/Modules/Filtering/ImageIntensity/test/itkDivideImageFilterTest2.cxx index 5b70bd186e2..38fa3a60afc 100644 --- a/Modules/Filtering/ImageIntensity/test/itkDivideImageFilterTest2.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkDivideImageFilterTest2.cxx @@ -79,8 +79,8 @@ itkDivideImageFilterTest2(int, char *[]) inputImageB->Allocate(); // Initialize the content of Image A - InputImageType1::PixelType valueA(inputImageA->GetNumberOfComponentsPerPixel()); - InputImageType1::PixelType::ValueType elementValueA = 2.0; + InputImageType1::PixelType valueA(inputImageA->GetNumberOfComponentsPerPixel()); + const InputImageType1::PixelType::ValueType elementValueA = 2.0; valueA.Fill(elementValueA); inputImageA->FillBuffer(valueA); @@ -107,7 +107,7 @@ itkDivideImageFilterTest2(int, char *[]) // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output OutputImageIteratorType oIt(outputImage, outputImage->GetBufferedRegion()); diff --git a/Modules/Filtering/ImageIntensity/test/itkDivideOrZeroOutImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkDivideOrZeroOutImageFilterTest.cxx index 23888ce340f..1031986d2fd 100644 --- a/Modules/Filtering/ImageIntensity/test/itkDivideOrZeroOutImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkDivideOrZeroOutImageFilterTest.cxx @@ -29,7 +29,7 @@ itkDivideOrZeroOutImageFilterTest(int, char *[]) using ImageType = itk::Image; using DivideFilterType = itk::DivideOrZeroOutImageFilter; - ImageType::SizeType size = { { 10, 12, 14 } }; + const ImageType::SizeType size = { { 10, 12, 14 } }; auto numeratorImage = ImageType::New(); numeratorImage->SetRegions(size); @@ -42,7 +42,7 @@ itkDivideOrZeroOutImageFilterTest(int, char *[]) // Set input test values denominatorImage->FillBuffer(1.0f); - ImageType::IndexType zeroIndex = { { 4, 5, 6 } }; + const ImageType::IndexType zeroIndex = { { 4, 5, 6 } }; denominatorImage->SetPixel(zeroIndex, 0.0f); // Instantiate and run the filter @@ -52,11 +52,11 @@ itkDivideOrZeroOutImageFilterTest(int, char *[]) divider->InPlaceOn(); divider->UpdateLargestPossibleRegion(); - ImageType::RegionType region = divider->GetOutput()->GetLargestPossibleRegion(); + const ImageType::RegionType region = divider->GetOutput()->GetLargestPossibleRegion(); itk::ImageRegionConstIteratorWithIndex iter(divider->GetOutput(), region); for (; !iter.IsAtEnd(); ++iter) { - ImageType::IndexType index = iter.GetIndex(); + const ImageType::IndexType index = iter.GetIndex(); if (index != zeroIndex) { if (iter.Get() != 1.0f) diff --git a/Modules/Filtering/ImageIntensity/test/itkEdgePotentialImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkEdgePotentialImageFilterTest.cxx index e91bada951d..06a1130dee6 100644 --- a/Modules/Filtering/ImageIntensity/test/itkEdgePotentialImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkEdgePotentialImageFilterTest.cxx @@ -89,14 +89,14 @@ itkEdgePotentialImageFilterTest(int, char *[]) // create an EdgePotentialImageFilter using FilterType = itk::EdgePotentialImageFilter; - auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + auto filter = FilterType::New(); + const itk::SimpleFilterWatcher watcher(filter); // Connect the input images filter->SetInput(inputImage); // Get the Smart Pointer to the Filter Output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Execute the filter filter->Update(); diff --git a/Modules/Filtering/ImageIntensity/test/itkEqualTest.cxx b/Modules/Filtering/ImageIntensity/test/itkEqualTest.cxx index 9e4c5ea8eb6..9c44126d731 100644 --- a/Modules/Filtering/ImageIntensity/test/itkEqualTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkEqualTest.cxx @@ -95,8 +95,8 @@ itkEqualTest(int, char *[]) using myFilterTypePointer = myFilterType::Pointer; // Create two images - myImageType1Pointer inputImageA = myImageType1::New(); - myImageType2Pointer inputImageB = myImageType2::New(); + const myImageType1Pointer inputImageA = myImageType1::New(); + const myImageType2Pointer inputImageB = myImageType2::New(); // Define their size, and start index mySizeType size; @@ -109,7 +109,7 @@ itkEqualTest(int, char *[]) start[1] = 0; start[2] = 0; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; // Initialize Image A inputImageA->SetRegions(region); @@ -149,7 +149,7 @@ itkEqualTest(int, char *[]) { // Create a logic Filter - myFilterTypePointer filter = myFilterType::New(); + const myFilterTypePointer filter = myFilterType::New(); if (filter.IsNull()) { return EXIT_FAILURE; @@ -162,18 +162,19 @@ itkEqualTest(int, char *[]) filter->SetFunctor(filter->GetFunctor()); // Get the Smart Pointer to the Filter Output - myImageType3Pointer outputImage = filter->GetOutput(); + const myImageType3Pointer outputImage = filter->GetOutput(); // Execute the filter filter->Update(); filter->SetFunctor(filter->GetFunctor()); // check the results - PixelType FG = filter->GetFunctor().GetForegroundValue(); - PixelType BG = filter->GetFunctor().GetBackgroundValue(); + const PixelType FG = filter->GetFunctor().GetForegroundValue(); + const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - int status1 = checkImOnImRes>( - inputImageA, inputImageB, outputImage, FG, BG); + const int status1 = + checkImOnImRes>( + inputImageA, inputImageB, outputImage, FG, BG); if (status1 == EXIT_FAILURE) { return (EXIT_FAILURE); @@ -186,7 +187,7 @@ itkEqualTest(int, char *[]) { // Create a logic Filter - myFilterTypePointer filter = myFilterType::New(); + const myFilterTypePointer filter = myFilterType::New(); // Connect the input images filter->SetInput1(inputImageA); @@ -194,15 +195,15 @@ itkEqualTest(int, char *[]) filter->SetFunctor(filter->GetFunctor()); // Get the Smart Pointer to the Filter Output - myImageType3Pointer outputImage = filter->GetOutput(); + const myImageType3Pointer outputImage = filter->GetOutput(); // Now try testing with constant : Im1 == 2 filter->SetConstant(2.0); filter->Update(); - PixelType FG = filter->GetFunctor().GetForegroundValue(); - PixelType BG = filter->GetFunctor().GetBackgroundValue(); - PixelType C = filter->GetConstant2(); - int status2 = checkImOnConstRes>( + const PixelType FG = filter->GetFunctor().GetForegroundValue(); + const PixelType BG = filter->GetFunctor().GetBackgroundValue(); + const PixelType C = filter->GetConstant2(); + const int status2 = checkImOnConstRes>( inputImageA, C, outputImage, FG, BG); if (status2 == EXIT_FAILURE) { @@ -216,7 +217,7 @@ itkEqualTest(int, char *[]) // Now try testing with constant : 3 == Im2 { // Create a logic Filter - myFilterTypePointer filter = myFilterType::New(); + const myFilterTypePointer filter = myFilterType::New(); // Connect the input images @@ -224,14 +225,14 @@ itkEqualTest(int, char *[]) filter->SetFunctor(filter->GetFunctor()); // Get the Smart Pointer to the Filter Output - myImageType3Pointer outputImage = filter->GetOutput(); + const myImageType3Pointer outputImage = filter->GetOutput(); filter->SetConstant1(3.0); filter->SetInput2(inputImageB); filter->Update(); - PixelType FG = filter->GetFunctor().GetForegroundValue(); - PixelType BG = filter->GetFunctor().GetBackgroundValue(); + const PixelType FG = filter->GetFunctor().GetForegroundValue(); + const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - int status3 = checkConstOnImRes>( + const int status3 = checkConstOnImRes>( filter->GetConstant1(), inputImageB, outputImage, FG, BG); if (status3 == EXIT_FAILURE) { diff --git a/Modules/Filtering/ImageIntensity/test/itkExpImageFilterAndAdaptorTest.cxx b/Modules/Filtering/ImageIntensity/test/itkExpImageFilterAndAdaptorTest.cxx index c4da8a5ac94..17bb1249382 100644 --- a/Modules/Filtering/ImageIntensity/test/itkExpImageFilterAndAdaptorTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkExpImageFilterAndAdaptorTest.cxx @@ -93,7 +93,7 @@ itkExpImageFilterAndAdaptorTest(int, char *[]) filter->SetNumberOfWorkUnits(1); // Get the Smart Pointer to the Filter Output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Execute the filter @@ -147,7 +147,7 @@ itkExpImageFilterAndAdaptorTest(int, char *[]) diffFilter->Update(); // Get the Smart Pointer to the Diff filter Output - OutputImageType::Pointer diffImage = diffFilter->GetOutput(); + const OutputImageType::Pointer diffImage = diffFilter->GetOutput(); // Check the content of the diff image std::cout << "Comparing the results with those of an Adaptor" << std::endl; diff --git a/Modules/Filtering/ImageIntensity/test/itkExpNegativeImageFilterAndAdaptorTest.cxx b/Modules/Filtering/ImageIntensity/test/itkExpNegativeImageFilterAndAdaptorTest.cxx index e0c00d72344..895b46a700c 100644 --- a/Modules/Filtering/ImageIntensity/test/itkExpNegativeImageFilterAndAdaptorTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkExpNegativeImageFilterAndAdaptorTest.cxx @@ -92,7 +92,7 @@ itkExpNegativeImageFilterAndAdaptorTest(int, char *[]) filter->SetInput(inputImage); // Get the Smart Pointer to the Filter Output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Execute the filter @@ -147,7 +147,7 @@ itkExpNegativeImageFilterAndAdaptorTest(int, char *[]) diffFilter->Update(); // Get the Smart Pointer to the Diff filter Output - OutputImageType::Pointer diffImage = diffFilter->GetOutput(); + const OutputImageType::Pointer diffImage = diffFilter->GetOutput(); // Check the content of the diff image std::cout << "Comparing the results with those of an Adaptor" << std::endl; diff --git a/Modules/Filtering/ImageIntensity/test/itkGreaterEqualTest.cxx b/Modules/Filtering/ImageIntensity/test/itkGreaterEqualTest.cxx index 288d3e810a1..a82b5ade690 100644 --- a/Modules/Filtering/ImageIntensity/test/itkGreaterEqualTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkGreaterEqualTest.cxx @@ -56,8 +56,8 @@ itkGreaterEqualTest(int, char *[]) using myFilterTypePointer = myFilterType::Pointer; // Create two images - myImageType1Pointer inputImageA = myImageType1::New(); - myImageType2Pointer inputImageB = myImageType2::New(); + const myImageType1Pointer inputImageA = myImageType1::New(); + const myImageType2Pointer inputImageB = myImageType2::New(); // Define their size, and start index mySizeType size; @@ -70,7 +70,7 @@ itkGreaterEqualTest(int, char *[]) start[1] = 0; start[2] = 0; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; // Initialize Image A inputImageA->SetRegions(region); @@ -109,7 +109,7 @@ itkGreaterEqualTest(int, char *[]) { // Create a logic Filter - myFilterTypePointer filter = myFilterType::New(); + const myFilterTypePointer filter = myFilterType::New(); // Connect the input images @@ -119,16 +119,17 @@ itkGreaterEqualTest(int, char *[]) filter->SetFunctor(filter->GetFunctor()); // Get the Smart Pointer to the Filter Output - myImageType3Pointer outputImage = filter->GetOutput(); + const myImageType3Pointer outputImage = filter->GetOutput(); // Execute the filter filter->Update(); filter->SetFunctor(filter->GetFunctor()); - PixelType FG = filter->GetFunctor().GetForegroundValue(); - PixelType BG = filter->GetFunctor().GetBackgroundValue(); + const PixelType FG = filter->GetFunctor().GetForegroundValue(); + const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - int status1 = checkImOnImRes>( - inputImageA, inputImageB, outputImage, FG, BG); + const int status1 = + checkImOnImRes>( + inputImageA, inputImageB, outputImage, FG, BG); if (status1 == EXIT_FAILURE) { return (EXIT_FAILURE); @@ -141,7 +142,7 @@ itkGreaterEqualTest(int, char *[]) { // Create a logic Filter - myFilterTypePointer filter = myFilterType::New(); + const myFilterTypePointer filter = myFilterType::New(); // Connect the input images @@ -150,15 +151,15 @@ itkGreaterEqualTest(int, char *[]) filter->SetFunctor(filter->GetFunctor()); // Get the Smart Pointer to the Filter Output - myImageType3Pointer outputImage = filter->GetOutput(); + const myImageType3Pointer outputImage = filter->GetOutput(); // Now try testing with constant : Im1 > 2 filter->SetConstant(2.0); filter->Update(); - PixelType FG = filter->GetFunctor().GetForegroundValue(); - PixelType BG = filter->GetFunctor().GetBackgroundValue(); - PixelType C = filter->GetConstant2(); - int status2 = checkImOnConstRes>( + const PixelType FG = filter->GetFunctor().GetForegroundValue(); + const PixelType BG = filter->GetFunctor().GetBackgroundValue(); + const PixelType C = filter->GetConstant2(); + const int status2 = checkImOnConstRes>( inputImageA, C, outputImage, FG, BG); if (status2 == EXIT_FAILURE) { @@ -172,7 +173,7 @@ itkGreaterEqualTest(int, char *[]) // Now try testing with constant : 3 != Im2 { // Create a logic Filter - myFilterTypePointer filter = myFilterType::New(); + const myFilterTypePointer filter = myFilterType::New(); // Connect the input images @@ -180,14 +181,14 @@ itkGreaterEqualTest(int, char *[]) filter->SetFunctor(filter->GetFunctor()); // Get the Smart Pointer to the Filter Output - myImageType3Pointer outputImage = filter->GetOutput(); + const myImageType3Pointer outputImage = filter->GetOutput(); filter->SetConstant1(3.0); filter->SetInput2(inputImageB); filter->Update(); - PixelType FG = filter->GetFunctor().GetForegroundValue(); - PixelType BG = filter->GetFunctor().GetBackgroundValue(); + const PixelType FG = filter->GetFunctor().GetForegroundValue(); + const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - int status3 = checkConstOnImRes>( + const int status3 = checkConstOnImRes>( filter->GetConstant1(), inputImageB, outputImage, FG, BG); if (status3 == EXIT_FAILURE) { diff --git a/Modules/Filtering/ImageIntensity/test/itkGreaterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkGreaterTest.cxx index 4370775646f..d32cd926dec 100644 --- a/Modules/Filtering/ImageIntensity/test/itkGreaterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkGreaterTest.cxx @@ -55,8 +55,8 @@ itkGreaterTest(int, char *[]) using myFilterTypePointer = myFilterType::Pointer; // Create two images - myImageType1Pointer inputImageA = myImageType1::New(); - myImageType2Pointer inputImageB = myImageType2::New(); + const myImageType1Pointer inputImageA = myImageType1::New(); + const myImageType2Pointer inputImageB = myImageType2::New(); // Define their size, and start index mySizeType size; @@ -69,7 +69,7 @@ itkGreaterTest(int, char *[]) start[1] = 0; start[2] = 0; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; // Initialize Image A inputImageA->SetRegions(region); @@ -108,7 +108,7 @@ itkGreaterTest(int, char *[]) { // Create a logic Filter - myFilterTypePointer filter = myFilterType::New(); + const myFilterTypePointer filter = myFilterType::New(); // Connect the input images @@ -118,16 +118,16 @@ itkGreaterTest(int, char *[]) filter->SetFunctor(filter->GetFunctor()); // Get the Smart Pointer to the Filter Output - myImageType3Pointer outputImage = filter->GetOutput(); + const myImageType3Pointer outputImage = filter->GetOutput(); // Execute the filter filter->Update(); filter->SetFunctor(filter->GetFunctor()); - PixelType FG = filter->GetFunctor().GetForegroundValue(); - PixelType BG = filter->GetFunctor().GetBackgroundValue(); + const PixelType FG = filter->GetFunctor().GetForegroundValue(); + const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - int status1 = checkImOnImRes>( + const int status1 = checkImOnImRes>( inputImageA, inputImageB, outputImage, FG, BG); if (status1 == EXIT_FAILURE) { @@ -141,7 +141,7 @@ itkGreaterTest(int, char *[]) { // Create a logic Filter - myFilterTypePointer filter = myFilterType::New(); + const myFilterTypePointer filter = myFilterType::New(); // Connect the input images @@ -150,15 +150,15 @@ itkGreaterTest(int, char *[]) filter->SetFunctor(filter->GetFunctor()); // Get the Smart Pointer to the Filter Output - myImageType3Pointer outputImage = filter->GetOutput(); + const myImageType3Pointer outputImage = filter->GetOutput(); // Now try testing with constant : Im1 > 2 filter->SetConstant(2.0); filter->Update(); - PixelType FG = filter->GetFunctor().GetForegroundValue(); - PixelType BG = filter->GetFunctor().GetBackgroundValue(); - PixelType C = filter->GetConstant2(); - int status2 = checkImOnConstRes>( + const PixelType FG = filter->GetFunctor().GetForegroundValue(); + const PixelType BG = filter->GetFunctor().GetBackgroundValue(); + const PixelType C = filter->GetConstant2(); + const int status2 = checkImOnConstRes>( inputImageA, C, outputImage, FG, BG); if (status2 == EXIT_FAILURE) { @@ -172,20 +172,20 @@ itkGreaterTest(int, char *[]) // Now try testing with constant : 3 != Im2 { // Create a logic Filter - myFilterTypePointer filter = myFilterType::New(); + const myFilterTypePointer filter = myFilterType::New(); // Connect the input images filter->SetFunctor(filter->GetFunctor()); // Get the Smart Pointer to the Filter Output - myImageType3Pointer outputImage = filter->GetOutput(); + const myImageType3Pointer outputImage = filter->GetOutput(); filter->SetConstant1(3.0); filter->SetInput2(inputImageB); filter->Update(); - PixelType FG = filter->GetFunctor().GetForegroundValue(); - PixelType BG = filter->GetFunctor().GetBackgroundValue(); + const PixelType FG = filter->GetFunctor().GetForegroundValue(); + const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - int status3 = checkConstOnImRes>( + const int status3 = checkConstOnImRes>( filter->GetConstant1(), inputImageB, outputImage, FG, BG); if (status3 == EXIT_FAILURE) { diff --git a/Modules/Filtering/ImageIntensity/test/itkHistogramMatchingImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkHistogramMatchingImageFilterTest.cxx index b230dbc59fc..57f04d7f986 100644 --- a/Modules/Filtering/ImageIntensity/test/itkHistogramMatchingImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkHistogramMatchingImageFilterTest.cxx @@ -98,7 +98,7 @@ CompareImages(itk::ImageRegionIterator & refIter, itk::ImageRegionIte outIter.GoToBegin(); while (!outIter.IsAtEnd()) { - typename ImageType::PixelType diff = refIter.Get() - outIter.Get(); + const typename ImageType::PixelType diff = refIter.Get() - outIter.Get(); if (itk::Math::abs(diff) > 1) { passed = false; @@ -215,7 +215,7 @@ itkHistogramMatchingImageFilterTest() ITK_EXERCISE_BASIC_OBJECT_METHODS(filterWithReferenceImage, HistogramMatchingImageFilter, ImageToImageFilter); - bool generateReferenceHistogramFromImage = true; + const bool generateReferenceHistogramFromImage = true; ITK_TEST_SET_GET_BOOLEAN( filterWithReferenceImage, GenerateReferenceHistogramFromImage, generateReferenceHistogramFromImage); @@ -225,11 +225,11 @@ itkHistogramMatchingImageFilterTest() filterWithReferenceImage->SetSourceImage(source); ITK_TEST_SET_GET_VALUE(source, filterWithReferenceImage->GetSourceImage()); - itk::SizeValueType numberOfHistogramLevels = 50; + const itk::SizeValueType numberOfHistogramLevels = 50; filterWithReferenceImage->SetNumberOfHistogramLevels(numberOfHistogramLevels); ITK_TEST_SET_GET_VALUE(numberOfHistogramLevels, filterWithReferenceImage->GetNumberOfHistogramLevels()); - itk::SizeValueType numberOfMatchPoints = 8; + const itk::SizeValueType numberOfMatchPoints = 8; filterWithReferenceImage->SetNumberOfMatchPoints(numberOfMatchPoints); ITK_TEST_SET_GET_VALUE(numberOfMatchPoints, filterWithReferenceImage->GetNumberOfMatchPoints()); @@ -241,7 +241,7 @@ itkHistogramMatchingImageFilterTest() { // Exercise and test with ThresholdAtMeanIntensityOff - bool thresholdAtMeanIntensity = false; + const bool thresholdAtMeanIntensity = false; ITK_TEST_SET_GET_BOOLEAN(filterWithReferenceImage, ThresholdAtMeanIntensity, thresholdAtMeanIntensity); filterWithReferenceImage->Update(); @@ -255,7 +255,7 @@ itkHistogramMatchingImageFilterTest() } { // Exercise and test with ThresholdAtMeanIntensityOn - bool thresholdAtMeanIntensity = true; + const bool thresholdAtMeanIntensity = true; ITK_TEST_SET_GET_BOOLEAN(filterWithReferenceImage, ThresholdAtMeanIntensity, thresholdAtMeanIntensity); filterWithReferenceImage->Update(); diff --git a/Modules/Filtering/ImageIntensity/test/itkImageAdaptorNthElementTest.cxx b/Modules/Filtering/ImageIntensity/test/itkImageAdaptorNthElementTest.cxx index d59e37ac64f..9a59e7233b0 100644 --- a/Modules/Filtering/ImageIntensity/test/itkImageAdaptorNthElementTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkImageAdaptorNthElementTest.cxx @@ -37,7 +37,7 @@ itkImageAdaptorNthElementTest(int, char *[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope // scope. - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); //------------------------------------------------------------- // Typedefs @@ -77,10 +77,10 @@ itkImageAdaptorNthElementTest(int, char *[]) size[1] = 2; size[2] = 2; // Small size, because we are printing it - myIndexType start{}; + const myIndexType start{}; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; float spacing[3]; spacing[0] = 1.0; @@ -146,7 +146,7 @@ itkImageAdaptorNthElementTest(int, char *[]) myFloatIteratorType itf(myFloatImage, myFloatImage->GetRequestedRegion()); - myFloatPixelType initialFloatValue = 5.0; + const myFloatPixelType initialFloatValue = 5.0; while (!itf.IsAtEnd()) { diff --git a/Modules/Filtering/ImageIntensity/test/itkIntensityWindowingImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkIntensityWindowingImageFilterTest.cxx index 8bb166987df..4febd64e7f3 100644 --- a/Modules/Filtering/ImageIntensity/test/itkIntensityWindowingImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkIntensityWindowingImageFilterTest.cxx @@ -37,7 +37,7 @@ itkIntensityWindowingImageFilterTest(int, char *[]) auto size = TestInputImage::SizeType::Filled(64); - TestInputImage::IndexType index{}; + const TestInputImage::IndexType index{}; region.SetIndex(index); region.SetSize(size); @@ -56,8 +56,8 @@ itkIntensityWindowingImageFilterTest(int, char *[]) // Set up source source->SetSize(randomSize); - double minValue = -128.0; - double maxValue = 127.0; + const double minValue = -128.0; + const double maxValue = 127.0; source->SetMin(static_cast(minValue)); source->SetMax(static_cast(maxValue)); diff --git a/Modules/Filtering/ImageIntensity/test/itkInvertIntensityImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkInvertIntensityImageFilterTest.cxx index a02790574e4..46c20d8d204 100644 --- a/Modules/Filtering/ImageIntensity/test/itkInvertIntensityImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkInvertIntensityImageFilterTest.cxx @@ -49,9 +49,9 @@ itkInvertIntensityImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, InvertIntensityImageFilter, UnaryFunctorImageFilter); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); - FilterType::InputPixelType maximum = itk::NumericTraits::max(); + const FilterType::InputPixelType maximum = itk::NumericTraits::max(); filter->SetMaximum(maximum); ITK_TEST_SET_GET_VALUE(maximum, filter->GetMaximum()); diff --git a/Modules/Filtering/ImageIntensity/test/itkLessEqualTest.cxx b/Modules/Filtering/ImageIntensity/test/itkLessEqualTest.cxx index d5f8d012038..f0dd87189a3 100644 --- a/Modules/Filtering/ImageIntensity/test/itkLessEqualTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkLessEqualTest.cxx @@ -56,8 +56,8 @@ itkLessEqualTest(int, char *[]) using myFilterTypePointer = myFilterType::Pointer; // Create two images - myImageType1Pointer inputImageA = myImageType1::New(); - myImageType2Pointer inputImageB = myImageType2::New(); + const myImageType1Pointer inputImageA = myImageType1::New(); + const myImageType2Pointer inputImageB = myImageType2::New(); // Define their size, and start index mySizeType size; @@ -70,7 +70,7 @@ itkLessEqualTest(int, char *[]) start[1] = 0; start[2] = 0; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; // Initialize Image A inputImageA->SetRegions(region); @@ -109,7 +109,7 @@ itkLessEqualTest(int, char *[]) { // Create a logic Filter - myFilterTypePointer filter = myFilterType::New(); + const myFilterTypePointer filter = myFilterType::New(); // Connect the input images @@ -119,17 +119,18 @@ itkLessEqualTest(int, char *[]) filter->SetFunctor(filter->GetFunctor()); // Get the Smart Pointer to the Filter Output - myImageType3Pointer outputImage = filter->GetOutput(); + const myImageType3Pointer outputImage = filter->GetOutput(); // Execute the filter filter->Update(); filter->SetFunctor(filter->GetFunctor()); - PixelType FG = filter->GetFunctor().GetForegroundValue(); - PixelType BG = filter->GetFunctor().GetBackgroundValue(); + const PixelType FG = filter->GetFunctor().GetForegroundValue(); + const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - int status1 = checkImOnImRes>( - inputImageA, inputImageB, outputImage, FG, BG); + const int status1 = + checkImOnImRes>( + inputImageA, inputImageB, outputImage, FG, BG); if (status1 == EXIT_FAILURE) { return (EXIT_FAILURE); @@ -142,7 +143,7 @@ itkLessEqualTest(int, char *[]) { // Create a logic Filter - myFilterTypePointer filter = myFilterType::New(); + const myFilterTypePointer filter = myFilterType::New(); // Connect the input images filter->SetInput1(inputImageA); @@ -150,15 +151,15 @@ itkLessEqualTest(int, char *[]) filter->SetFunctor(filter->GetFunctor()); // Get the Smart Pointer to the Filter Output - myImageType3Pointer outputImage = filter->GetOutput(); + const myImageType3Pointer outputImage = filter->GetOutput(); // Now try testing with constant : Im1 > 2 filter->SetConstant(2.0); filter->Update(); - PixelType FG = filter->GetFunctor().GetForegroundValue(); - PixelType BG = filter->GetFunctor().GetBackgroundValue(); - PixelType C = filter->GetConstant2(); - int status2 = checkImOnConstRes>( + const PixelType FG = filter->GetFunctor().GetForegroundValue(); + const PixelType BG = filter->GetFunctor().GetBackgroundValue(); + const PixelType C = filter->GetConstant2(); + const int status2 = checkImOnConstRes>( inputImageA, C, outputImage, FG, BG); if (status2 == EXIT_FAILURE) { @@ -172,20 +173,20 @@ itkLessEqualTest(int, char *[]) // Now try testing with constant : 3 != Im2 { // Create a logic Filter - myFilterTypePointer filter = myFilterType::New(); + const myFilterTypePointer filter = myFilterType::New(); // Connect the input images filter->SetFunctor(filter->GetFunctor()); // Get the Smart Pointer to the Filter Output - myImageType3Pointer outputImage = filter->GetOutput(); + const myImageType3Pointer outputImage = filter->GetOutput(); filter->SetConstant1(3.0); filter->SetInput2(inputImageB); filter->Update(); - PixelType FG = filter->GetFunctor().GetForegroundValue(); - PixelType BG = filter->GetFunctor().GetBackgroundValue(); + const PixelType FG = filter->GetFunctor().GetForegroundValue(); + const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - int status3 = checkConstOnImRes>( + const int status3 = checkConstOnImRes>( filter->GetConstant1(), inputImageB, outputImage, FG, BG); if (status3 == EXIT_FAILURE) { diff --git a/Modules/Filtering/ImageIntensity/test/itkLessTest.cxx b/Modules/Filtering/ImageIntensity/test/itkLessTest.cxx index 16f6b52d866..c92ce13d688 100644 --- a/Modules/Filtering/ImageIntensity/test/itkLessTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkLessTest.cxx @@ -56,8 +56,8 @@ itkLessTest(int, char *[]) using myFilterTypePointer = myFilterType::Pointer; // Create two images - myImageType1Pointer inputImageA = myImageType1::New(); - myImageType2Pointer inputImageB = myImageType2::New(); + const myImageType1Pointer inputImageA = myImageType1::New(); + const myImageType2Pointer inputImageB = myImageType2::New(); // Define their size, and start index mySizeType size; @@ -70,7 +70,7 @@ itkLessTest(int, char *[]) start[1] = 0; start[2] = 0; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; // Initialize Image A inputImageA->SetRegions(region); @@ -109,7 +109,7 @@ itkLessTest(int, char *[]) { // Create a logic Filter - myFilterTypePointer filter = myFilterType::New(); + const myFilterTypePointer filter = myFilterType::New(); // Connect the input images filter->SetInput1(inputImageA); @@ -118,15 +118,15 @@ itkLessTest(int, char *[]) filter->SetFunctor(filter->GetFunctor()); // Get the Smart Pointer to the Filter Output - myImageType3Pointer outputImage = filter->GetOutput(); + const myImageType3Pointer outputImage = filter->GetOutput(); // Execute the filter filter->Update(); filter->SetFunctor(filter->GetFunctor()); - PixelType FG = filter->GetFunctor().GetForegroundValue(); - PixelType BG = filter->GetFunctor().GetBackgroundValue(); + const PixelType FG = filter->GetFunctor().GetForegroundValue(); + const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - int status1 = checkImOnImRes>( + const int status1 = checkImOnImRes>( inputImageA, inputImageB, outputImage, FG, BG); if (status1 == EXIT_FAILURE) { @@ -140,7 +140,7 @@ itkLessTest(int, char *[]) { // Create a logic Filter - myFilterTypePointer filter = myFilterType::New(); + const myFilterTypePointer filter = myFilterType::New(); // Connect the input images filter->SetInput1(inputImageA); @@ -148,15 +148,15 @@ itkLessTest(int, char *[]) filter->SetFunctor(filter->GetFunctor()); // Get the Smart Pointer to the Filter Output - myImageType3Pointer outputImage = filter->GetOutput(); + const myImageType3Pointer outputImage = filter->GetOutput(); // Now try testing with constant : Im1 > 2 filter->SetConstant(2.0); filter->Update(); - PixelType FG = filter->GetFunctor().GetForegroundValue(); - PixelType BG = filter->GetFunctor().GetBackgroundValue(); - PixelType C = filter->GetConstant2(); - int status2 = checkImOnConstRes>( + const PixelType FG = filter->GetFunctor().GetForegroundValue(); + const PixelType BG = filter->GetFunctor().GetBackgroundValue(); + const PixelType C = filter->GetConstant2(); + const int status2 = checkImOnConstRes>( inputImageA, C, outputImage, FG, BG); if (status2 == EXIT_FAILURE) { @@ -170,20 +170,20 @@ itkLessTest(int, char *[]) // Now try testing with constant : 3 != Im2 { // Create a logic Filter - myFilterTypePointer filter = myFilterType::New(); + const myFilterTypePointer filter = myFilterType::New(); // Connect the input images filter->SetFunctor(filter->GetFunctor()); // Get the Smart Pointer to the Filter Output - myImageType3Pointer outputImage = filter->GetOutput(); + const myImageType3Pointer outputImage = filter->GetOutput(); filter->SetConstant1(3.0); filter->SetInput2(inputImageB); filter->Update(); - PixelType FG = filter->GetFunctor().GetForegroundValue(); - PixelType BG = filter->GetFunctor().GetBackgroundValue(); + const PixelType FG = filter->GetFunctor().GetForegroundValue(); + const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - int status3 = checkConstOnImRes>( + const int status3 = checkConstOnImRes>( filter->GetConstant1(), inputImageB, outputImage, FG, BG); if (status3 == EXIT_FAILURE) { diff --git a/Modules/Filtering/ImageIntensity/test/itkLog10ImageFilterAndAdaptorTest.cxx b/Modules/Filtering/ImageIntensity/test/itkLog10ImageFilterAndAdaptorTest.cxx index 1a4db9a33d7..9c266308d3d 100644 --- a/Modules/Filtering/ImageIntensity/test/itkLog10ImageFilterAndAdaptorTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkLog10ImageFilterAndAdaptorTest.cxx @@ -98,7 +98,7 @@ itkLog10ImageFilterAndAdaptorTest(int, char *[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output OutputIteratorType ot(outputImage, outputImage->GetRequestedRegion()); @@ -148,7 +148,7 @@ itkLog10ImageFilterAndAdaptorTest(int, char *[]) diffFilter->Update(); // Get the filter output - OutputImageType::Pointer diffImage = diffFilter->GetOutput(); + const OutputImageType::Pointer diffImage = diffFilter->GetOutput(); // Check the content of the diff image // diff --git a/Modules/Filtering/ImageIntensity/test/itkLogImageFilterAndAdaptorTest.cxx b/Modules/Filtering/ImageIntensity/test/itkLogImageFilterAndAdaptorTest.cxx index fa40024289e..ac4f915ae8f 100644 --- a/Modules/Filtering/ImageIntensity/test/itkLogImageFilterAndAdaptorTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkLogImageFilterAndAdaptorTest.cxx @@ -99,7 +99,7 @@ itkLogImageFilterAndAdaptorTest(int, char *[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output OutputIteratorType ot(outputImage, outputImage->GetRequestedRegion()); @@ -149,7 +149,7 @@ itkLogImageFilterAndAdaptorTest(int, char *[]) diffFilter->Update(); // Get the filter output - OutputImageType::Pointer diffImage = diffFilter->GetOutput(); + const OutputImageType::Pointer diffImage = diffFilter->GetOutput(); // Check the content of the diff image // diff --git a/Modules/Filtering/ImageIntensity/test/itkMagnitudeAndPhaseToComplexImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkMagnitudeAndPhaseToComplexImageFilterTest.cxx index 33a4ae93aff..f69d9e1bef0 100644 --- a/Modules/Filtering/ImageIntensity/test/itkMagnitudeAndPhaseToComplexImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkMagnitudeAndPhaseToComplexImageFilterTest.cxx @@ -65,7 +65,7 @@ itkMagnitudeAndPhaseToComplexImageFilterTest(int argc, char * argv[]) using MagnitudeAndPhaseToComplexFilterType = itk::MagnitudeAndPhaseToComplexImageFilter; - MagnitudeAndPhaseToComplexFilterType::Pointer magnitudeAndPhaseToComplexFilter = + const MagnitudeAndPhaseToComplexFilterType::Pointer magnitudeAndPhaseToComplexFilter = MagnitudeAndPhaseToComplexFilterType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS( diff --git a/Modules/Filtering/ImageIntensity/test/itkMaskImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkMaskImageFilterTest.cxx index 3b47e5ae813..9763bd384f9 100644 --- a/Modules/Filtering/ImageIntensity/test/itkMaskImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkMaskImageFilterTest.cxx @@ -57,7 +57,7 @@ itkMaskImageFilterTest(int, char *[]) start[1] = 0; start[2] = 0; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; // Initialize Image A inputImageA->SetRegions(region); @@ -128,7 +128,7 @@ itkMaskImageFilterTest(int, char *[]) filter->SetOutsideValue(50); // Get the Smart Pointer to the Filter Output - myImageType3::Pointer outputImage = filter->GetOutput(); + const myImageType3::Pointer outputImage = filter->GetOutput(); // Execute the filter @@ -181,8 +181,8 @@ itkMaskImageFilterTest(int, char *[]) } // Check that the outside value consists of three zeros. - myVectorImageType::PixelType outsideValue3 = vectorFilter->GetOutsideValue(); - myVectorImageType::PixelType threeZeros(3); + const myVectorImageType::PixelType outsideValue3 = vectorFilter->GetOutsideValue(); + myVectorImageType::PixelType threeZeros(3); threeZeros.Fill(0.0f); if (outsideValue3 != threeZeros) { @@ -245,8 +245,8 @@ itkMaskImageFilterTest(int, char *[]) } // Check updated outside value. - myVectorImageType::PixelType outsideValue5 = vectorFilter->GetOutsideValue(); - myVectorImageType::PixelType fiveZeros(5); + const myVectorImageType::PixelType outsideValue5 = vectorFilter->GetOutsideValue(); + myVectorImageType::PixelType fiveZeros(5); fiveZeros.Fill(0.0f); if (outsideValue5 != fiveZeros) { diff --git a/Modules/Filtering/ImageIntensity/test/itkMaskNegatedImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkMaskNegatedImageFilterTest.cxx index 31b1a4f09d5..9d451c4725c 100644 --- a/Modules/Filtering/ImageIntensity/test/itkMaskNegatedImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkMaskNegatedImageFilterTest.cxx @@ -59,7 +59,7 @@ itkMaskNegatedImageFilterTest(int, char *[]) start[1] = 0; start[2] = 0; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; // Initialize the image inputImage->SetRegions(region); @@ -130,7 +130,7 @@ itkMaskNegatedImageFilterTest(int, char *[]) filter->SetOutsideValue(50); // Get the Smart Pointer to the Filter Output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Execute the filter @@ -153,7 +153,7 @@ itkMaskNegatedImageFilterTest(int, char *[]) // Test named mutator/accessors { filter->SetMaskImage(inputMask); - myFilterType::MaskImageType::ConstPointer retrievedMask = filter->GetMaskImage(); + const myFilterType::MaskImageType::ConstPointer retrievedMask = filter->GetMaskImage(); if (retrievedMask != inputMask) { std::cerr << "Mask not retrieved successfully!" << std::endl; @@ -175,15 +175,15 @@ itkMaskNegatedImageFilterTest(int, char *[]) vectorFilter->SetInput1(inputVectorImage); vectorFilter->SetMaskImage(inputMask); - myVectorImageType::PixelType outsideValue = vectorFilter->GetOutsideValue(); + const myVectorImageType::PixelType outsideValue = vectorFilter->GetOutsideValue(); ITK_TEST_EXPECT_EQUAL(outsideValue.GetSize(), 0); ITK_TRY_EXPECT_NO_EXCEPTION(vectorFilter->Update()); // Check that the outside value consists of three zeros. - myVectorImageType::PixelType outsideValue3 = vectorFilter->GetOutsideValue(); - myVectorImageType::PixelType threeZeros(3); + const myVectorImageType::PixelType outsideValue3 = vectorFilter->GetOutsideValue(); + myVectorImageType::PixelType threeZeros(3); threeZeros.Fill(0.0f); ITK_TEST_EXPECT_EQUAL(outsideValue3, threeZeros); diff --git a/Modules/Filtering/ImageIntensity/test/itkMatrixIndexSelectionImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkMatrixIndexSelectionImageFilterTest.cxx index 487743e35aa..02efff07499 100644 --- a/Modules/Filtering/ImageIntensity/test/itkMatrixIndexSelectionImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkMatrixIndexSelectionImageFilterTest.cxx @@ -58,8 +58,8 @@ itkMatrixIndexSelectionImageFilterTest(int argc, char * argv[]) size = region.GetSize(); index = region.GetIndex(); - unsigned int width = size[0]; - unsigned int height = size[1]; + const unsigned int width = size[0]; + const unsigned int height = size[1]; size[0] = width; size[1] = height / 2; @@ -114,8 +114,8 @@ itkMatrixIndexSelectionImageFilterTest(int argc, char * argv[]) filter->SetInput(image); - unsigned int indexA = 0; - unsigned int indexB = 1; + const unsigned int indexA = 0; + const unsigned int indexB = 1; filter->SetIndices(indexA, indexB); unsigned int testIndexA; diff --git a/Modules/Filtering/ImageIntensity/test/itkMaximumImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkMaximumImageFilterTest.cxx index 96b00054c27..46e17ae2cc4 100644 --- a/Modules/Filtering/ImageIntensity/test/itkMaximumImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkMaximumImageFilterTest.cxx @@ -73,8 +73,8 @@ itkMaximumImageFilterTest(int, char *[]) inputImageB->Allocate(); // Define the pixel values for each image - PixelType largePixelValue = 3; - PixelType smallPixelValue = 2; + const PixelType largePixelValue = 3; + const PixelType smallPixelValue = 2; // Declare Iterator types apropriated for each image using IteratorType = itk::ImageRegionIteratorWithIndex; @@ -109,7 +109,7 @@ itkMaximumImageFilterTest(int, char *[]) maximumImageFilter->SetInput2(inputImageB); // Get the Smart Pointer to the filter output - ImageType::Pointer outputImage = maximumImageFilter->GetOutput(); + const ImageType::Pointer outputImage = maximumImageFilter->GetOutput(); // Execute the filter @@ -119,7 +119,7 @@ itkMaximumImageFilterTest(int, char *[]) // Note that we are not comparing the entirety of the filter output in order // to keep compile time as small as possible - ImageType::IndexType pixelIndex = { { 0, 1, 1 } }; + const ImageType::IndexType pixelIndex = { { 0, 1, 1 } }; ITK_TEST_EXPECT_EQUAL(outputImage->GetPixel(start), largePixelValue); ITK_TEST_EXPECT_EQUAL(outputImage->GetPixel(pixelIndex), largePixelValue); diff --git a/Modules/Filtering/ImageIntensity/test/itkMinimumImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkMinimumImageFilterTest.cxx index 3ab88550c12..dd319e9f164 100644 --- a/Modules/Filtering/ImageIntensity/test/itkMinimumImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkMinimumImageFilterTest.cxx @@ -73,8 +73,8 @@ itkMinimumImageFilterTest(int, char *[]) inputImageB->Allocate(); // Define the pixel values for each image - PixelType largePixelValue = 3; - PixelType smallPixelValue = 2; + const PixelType largePixelValue = 3; + const PixelType smallPixelValue = 2; // Declare Iterator types apropriated for each image using IteratorType = itk::ImageRegionIteratorWithIndex; @@ -109,7 +109,7 @@ itkMinimumImageFilterTest(int, char *[]) minimumImageFilter->SetInput2(inputImageB); // Get the Smart Pointer to the filter output - ImageType::Pointer outputImage = minimumImageFilter->GetOutput(); + const ImageType::Pointer outputImage = minimumImageFilter->GetOutput(); // Execute the filter @@ -119,7 +119,7 @@ itkMinimumImageFilterTest(int, char *[]) // Note that we are not comparing the entirety of the filter output in order // to keep compile time as small as possible - ImageType::IndexType pixelIndex = { { 0, 1, 1 } }; + const ImageType::IndexType pixelIndex = { { 0, 1, 1 } }; ITK_TEST_EXPECT_EQUAL(outputImage->GetPixel(start), smallPixelValue); ITK_TEST_EXPECT_EQUAL(outputImage->GetPixel(pixelIndex), smallPixelValue); diff --git a/Modules/Filtering/ImageIntensity/test/itkModulusImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkModulusImageFilterTest.cxx index a03527de286..48f694e52d1 100644 --- a/Modules/Filtering/ImageIntensity/test/itkModulusImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkModulusImageFilterTest.cxx @@ -57,13 +57,13 @@ itkModulusImageFilterTest(int argc, char * argv[]) filter->SetInput(distance->GetOutput()); - FilterType::InputPixelType dividend = 8; + const FilterType::InputPixelType dividend = 8; filter->SetDividend(dividend); ITK_TEST_SET_GET_VALUE(dividend, filter->GetDividend()); filter->InPlaceOn(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); using ThresholdType = itk::RescaleIntensityImageFilter; auto rescale = ThresholdType::New(); diff --git a/Modules/Filtering/ImageIntensity/test/itkMultiplyImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkMultiplyImageFilterTest.cxx index a9c8747297d..2c420911cdc 100644 --- a/Modules/Filtering/ImageIntensity/test/itkMultiplyImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkMultiplyImageFilterTest.cxx @@ -103,7 +103,7 @@ itkMultiplyImageFilterTest(int, char *[]) // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output diff --git a/Modules/Filtering/ImageIntensity/test/itkNaryAddImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkNaryAddImageFilterTest.cxx index 1d5182c834f..0c75a56d46e 100644 --- a/Modules/Filtering/ImageIntensity/test/itkNaryAddImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkNaryAddImageFilterTest.cxx @@ -29,14 +29,14 @@ template void InitializeImage(ImageType * image, const typename ImageType::PixelType & value) { - typename ImageType::Pointer inputImage(image); + const typename ImageType::Pointer inputImage(image); // Define their size, and start index auto size = ImageType::SizeType::Filled(2); - typename ImageType::IndexType start{}; + const typename ImageType::IndexType start{}; - typename ImageType::RegionType region{ start, size }; + const typename ImageType::RegionType region{ start, size }; inputImage->SetRegions(region); inputImage->Allocate(); @@ -94,7 +94,7 @@ itkNaryAddImageFilterTest(int, char *[]) // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Test the validity of the output using InputImageIteratorType = itk::ImageRegionConstIterator; @@ -203,7 +203,7 @@ itkNaryAddImageFilterTest(int, char *[]) vectorFilter->SetInput(2, vectorImageC); // Get the filter output - VectorImageType::Pointer vectorOutputImage = vectorFilter->GetOutput(); + const VectorImageType::Pointer vectorOutputImage = vectorFilter->GetOutput(); // Execute the filter diff --git a/Modules/Filtering/ImageIntensity/test/itkNaryMaximumImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkNaryMaximumImageFilterTest.cxx index 9e9ad6f0795..704380d2a7a 100644 --- a/Modules/Filtering/ImageIntensity/test/itkNaryMaximumImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkNaryMaximumImageFilterTest.cxx @@ -56,7 +56,7 @@ using FilterType = itk::NaryMaximumImageFilter; void InitializeImage(InputImageType * image, double value) { - InputImageType::Pointer inputImage(image); + const InputImageType::Pointer inputImage(image); // Define their size, and start index SizeType size; @@ -64,7 +64,7 @@ InitializeImage(InputImageType * image, double value) size[1] = 2; size[2] = 2; - IndexType start{}; + const IndexType start{}; RegionType region; region.SetIndex(start); @@ -138,7 +138,7 @@ itkNaryMaximumImageFilterTest(int, char *[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); PrintImage(outputImage, "Resulting image 1"); diff --git a/Modules/Filtering/ImageIntensity/test/itkNormalizeImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkNormalizeImageFilterTest.cxx index 24497c80ea9..df35d1ab3a0 100644 --- a/Modules/Filtering/ImageIntensity/test/itkNormalizeImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkNormalizeImageFilterTest.cxx @@ -37,15 +37,15 @@ itkNormalizeImageFilterTest(int, char *[]) ShortImage::SizeValueType randomSize[3] = { 18, 17, 67 }; source->SetSize(randomSize); - float minValue = -1000.0; - float maxValue = 1000.0; + const float minValue = -1000.0; + const float maxValue = 1000.0; source->SetMin(static_cast(minValue)); source->SetMax(static_cast(maxValue)); using NormalizeType = itk::NormalizeImageFilter; - auto normalize = NormalizeType::New(); - itk::SimpleFilterWatcher watch(normalize, "Streaming"); + auto normalize = NormalizeType::New(); + const itk::SimpleFilterWatcher watch(normalize, "Streaming"); normalize->SetInput(source->GetOutput()); diff --git a/Modules/Filtering/ImageIntensity/test/itkNormalizeToConstantImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkNormalizeToConstantImageFilterTest.cxx index 871170f5d5f..0ccc43888cc 100644 --- a/Modules/Filtering/ImageIntensity/test/itkNormalizeToConstantImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkNormalizeToConstantImageFilterTest.cxx @@ -42,8 +42,8 @@ itkNormalizeToConstantImageFilterTest(int, char *[]) source->SetSize(randomSize); - IntImage::PixelType minValue = 0; - IntImage::PixelType maxValue = 1000; + const IntImage::PixelType minValue = 0; + const IntImage::PixelType maxValue = 1000; source->SetMin(minValue); source->SetMax(maxValue); @@ -56,7 +56,7 @@ itkNormalizeToConstantImageFilterTest(int, char *[]) normalize->SetConstant(constant); ITK_TEST_SET_GET_VALUE(constant, normalize->GetConstant()); - itk::SimpleFilterWatcher watch(normalize, "NormalizeToConstant"); + const itk::SimpleFilterWatcher watch(normalize, "NormalizeToConstant"); normalize->SetInput(source->GetOutput()); normalize->Update(); diff --git a/Modules/Filtering/ImageIntensity/test/itkNotEqualTest.cxx b/Modules/Filtering/ImageIntensity/test/itkNotEqualTest.cxx index 2eafa95b97f..c4d90a47c87 100644 --- a/Modules/Filtering/ImageIntensity/test/itkNotEqualTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkNotEqualTest.cxx @@ -56,8 +56,8 @@ itkNotEqualTest(int, char *[]) using myFilterTypePointer = myFilterType::Pointer; // Create two images - myImageType1Pointer inputImageA = myImageType1::New(); - myImageType2Pointer inputImageB = myImageType2::New(); + const myImageType1Pointer inputImageA = myImageType1::New(); + const myImageType2Pointer inputImageB = myImageType2::New(); // Define their size, and start index mySizeType size; @@ -70,7 +70,7 @@ itkNotEqualTest(int, char *[]) start[1] = 0; start[2] = 0; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; // Initialize Image A inputImageA->SetRegions(region); @@ -110,7 +110,7 @@ itkNotEqualTest(int, char *[]) { // Create a logic Filter - myFilterTypePointer filter = myFilterType::New(); + const myFilterTypePointer filter = myFilterType::New(); // Connect the input images filter->SetInput1(inputImageA); @@ -119,17 +119,18 @@ itkNotEqualTest(int, char *[]) filter->SetFunctor(filter->GetFunctor()); // Get the Smart Pointer to the Filter Output - myImageType3Pointer outputImage = filter->GetOutput(); + const myImageType3Pointer outputImage = filter->GetOutput(); // Execute the filter filter->GetFunctor().SetForegroundValue(3); filter->Update(); - PixelType FG = filter->GetFunctor().GetForegroundValue(); - PixelType BG = filter->GetFunctor().GetBackgroundValue(); + const PixelType FG = filter->GetFunctor().GetForegroundValue(); + const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - int status1 = checkImOnImRes>( - inputImageA, inputImageB, outputImage, FG, BG); + const int status1 = + checkImOnImRes>( + inputImageA, inputImageB, outputImage, FG, BG); if (status1 == EXIT_FAILURE) { return (EXIT_FAILURE); @@ -141,23 +142,23 @@ itkNotEqualTest(int, char *[]) } { // Create a logic Filter - myFilterTypePointer filter = myFilterType::New(); + const myFilterTypePointer filter = myFilterType::New(); // Connect the input images filter->SetInput1(inputImageA); filter->SetFunctor(filter->GetFunctor()); // Get the Smart Pointer to the Filter Output - myImageType3Pointer outputImage = filter->GetOutput(); + const myImageType3Pointer outputImage = filter->GetOutput(); // Now try testing with constant : Im1 != 2 filter->SetConstant2(2.0); filter->Update(); - PixelType FG = filter->GetFunctor().GetForegroundValue(); - PixelType BG = filter->GetFunctor().GetBackgroundValue(); - PixelType C = filter->GetConstant2(); - int status2 = checkImOnConstRes>( + const PixelType FG = filter->GetFunctor().GetForegroundValue(); + const PixelType BG = filter->GetFunctor().GetBackgroundValue(); + const PixelType C = filter->GetConstant2(); + const int status2 = checkImOnConstRes>( inputImageA, C, outputImage, FG, BG); if (status2 == EXIT_FAILURE) { @@ -171,20 +172,20 @@ itkNotEqualTest(int, char *[]) { // Now try testing with constant : 3 != Im2 // Create a logic Filter - myFilterTypePointer filter = myFilterType::New(); + const myFilterTypePointer filter = myFilterType::New(); // Connect the input images filter->SetFunctor(filter->GetFunctor()); // Get the Smart Pointer to the Filter Output - myImageType3Pointer outputImage = filter->GetOutput(); + const myImageType3Pointer outputImage = filter->GetOutput(); filter->SetConstant1(3.0); filter->SetInput2(inputImageB); filter->Update(); - PixelType FG = filter->GetFunctor().GetForegroundValue(); - PixelType BG = filter->GetFunctor().GetBackgroundValue(); + const PixelType FG = filter->GetFunctor().GetForegroundValue(); + const PixelType BG = filter->GetFunctor().GetBackgroundValue(); - int status3 = checkConstOnImRes>( + const int status3 = checkConstOnImRes>( filter->GetConstant1(), inputImageB, outputImage, FG, BG); if (status3 == EXIT_FAILURE) { diff --git a/Modules/Filtering/ImageIntensity/test/itkNotImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkNotImageFilterTest.cxx index bfc55feea93..3551d600073 100644 --- a/Modules/Filtering/ImageIntensity/test/itkNotImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkNotImageFilterTest.cxx @@ -105,7 +105,7 @@ itkNotImageFilterTest(int, char *[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output OutputIteratorType ot(outputImage, outputImage->GetBufferedRegion()); diff --git a/Modules/Filtering/ImageIntensity/test/itkNthElementPixelAccessorTest2.cxx b/Modules/Filtering/ImageIntensity/test/itkNthElementPixelAccessorTest2.cxx index 62388fe7f14..c9bc57cc5e8 100644 --- a/Modules/Filtering/ImageIntensity/test/itkNthElementPixelAccessorTest2.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkNthElementPixelAccessorTest2.cxx @@ -68,7 +68,7 @@ itkNthElementPixelAccessorTest2(int, char *[]) index[0] = 0; index[1] = 0; - VectorImageType::RegionType region{ index, size }; + const VectorImageType::RegionType region{ index, size }; auto vectorImage = VectorImageType::New(); diff --git a/Modules/Filtering/ImageIntensity/test/itkOrImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkOrImageFilterTest.cxx index 0e8aa2c4f1e..1b63c63a727 100644 --- a/Modules/Filtering/ImageIntensity/test/itkOrImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkOrImageFilterTest.cxx @@ -90,7 +90,7 @@ itkOrImageFilterTest(int argc, char * argv[]) it1.GoToBegin(); // Initialize the content of Image A - InputImage1Type::PixelType valueA = 2; + const InputImage1Type::PixelType valueA = 2; while (!it1.IsAtEnd()) { it1.Set(valueA); @@ -102,7 +102,7 @@ itkOrImageFilterTest(int argc, char * argv[]) it2.GoToBegin(); // Initialize the content of Image B - InputImage2Type::PixelType valueB = 3; + const InputImage2Type::PixelType valueB = 3; while (!it2.IsAtEnd()) { it2.Set(valueB); @@ -123,7 +123,7 @@ itkOrImageFilterTest(int argc, char * argv[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Write the result image using WriterType = itk::ImageFileWriter; diff --git a/Modules/Filtering/ImageIntensity/test/itkPolylineMask2DImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkPolylineMask2DImageFilterTest.cxx index 1a45ebfb486..5d1573c91cb 100644 --- a/Modules/Filtering/ImageIntensity/test/itkPolylineMask2DImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkPolylineMask2DImageFilterTest.cxx @@ -61,7 +61,7 @@ itkPolylineMask2DImageFilterTest(int argc, char * argv[]) return EXIT_FAILURE; } - InputImageType::ConstPointer inputImage = reader->GetOutput(); + const InputImageType::ConstPointer inputImage = reader->GetOutput(); // Create polyline auto inputPolyline = InputPolylineType::New(); diff --git a/Modules/Filtering/ImageIntensity/test/itkPolylineMaskImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkPolylineMaskImageFilterTest.cxx index a79ab40cd18..b5a6492c685 100644 --- a/Modules/Filtering/ImageIntensity/test/itkPolylineMaskImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkPolylineMaskImageFilterTest.cxx @@ -169,7 +169,7 @@ itkPolylineMaskImageFilterTest(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(cameraCenterPoint, polylineMaskFilter->GetCameraCenterPoint()); // Set the camera focal distance - double focalDistance = 30.0; + const double focalDistance = 30.0; polylineMaskFilter->SetFocalDistance(focalDistance); ITK_TEST_SET_GET_VALUE(focalDistance, polylineMaskFilter->GetFocalDistance()); diff --git a/Modules/Filtering/ImageIntensity/test/itkPowImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkPowImageFilterTest.cxx index 0b113df87f3..006588c17d8 100644 --- a/Modules/Filtering/ImageIntensity/test/itkPowImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkPowImageFilterTest.cxx @@ -49,7 +49,7 @@ itkPowImageFilterTest(int, char *[]) SizeType size; size[0] = 2; - ImageType::RegionType region(size); + const ImageType::RegionType region(size); // Initialize Image A inputImageA->SetRegions(region); @@ -81,7 +81,7 @@ itkPowImageFilterTest(int, char *[]) filter->SetInput2(inputImageB); // Get the Smart Pointer to the Filter Output - ImageType::Pointer outputImage = filter->GetOutput(); + const ImageType::Pointer outputImage = filter->GetOutput(); // Execute the filter filter->Update(); diff --git a/Modules/Filtering/ImageIntensity/test/itkRGBToLuminanceImageFilterAndAdaptorTest.cxx b/Modules/Filtering/ImageIntensity/test/itkRGBToLuminanceImageFilterAndAdaptorTest.cxx index 60c6f3d8d16..e3b01d86a69 100644 --- a/Modules/Filtering/ImageIntensity/test/itkRGBToLuminanceImageFilterAndAdaptorTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkRGBToLuminanceImageFilterAndAdaptorTest.cxx @@ -107,7 +107,7 @@ itkRGBToLuminanceImageFilterAndAdaptorTest(int, char *[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output OutputIteratorType ot(outputImage, outputImage->GetRequestedRegion()); @@ -158,7 +158,7 @@ itkRGBToLuminanceImageFilterAndAdaptorTest(int, char *[]) diffFilter->Update(); // Get the filter output - OutputImageType::Pointer diffImage = diffFilter->GetOutput(); + const OutputImageType::Pointer diffImage = diffFilter->GetOutput(); // Check the content of the diff image // diff --git a/Modules/Filtering/ImageIntensity/test/itkRGBToVectorAdaptImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkRGBToVectorAdaptImageFilterTest.cxx index dca9c123f47..2ff50d08ab8 100644 --- a/Modules/Filtering/ImageIntensity/test/itkRGBToVectorAdaptImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkRGBToVectorAdaptImageFilterTest.cxx @@ -70,7 +70,7 @@ itkRGBToVectorAdaptImageFilterTest(int, char *[]) index[0] = 0; index[1] = 0; - RGBImageType::RegionType region{ index, size }; + const RGBImageType::RegionType region{ index, size }; auto myImage = RGBImageType::New(); @@ -112,8 +112,8 @@ itkRGBToVectorAdaptImageFilterTest(int, char *[]) it1.GoToBegin(); while (!it.IsAtEnd()) { - VectorPixelType v = it.Get(); - RGBPixelType c = it1.Get(); + VectorPixelType v = it.Get(); + const RGBPixelType c = it1.Get(); if (itk::Math::NotExactlyEquals(v[0], c.GetRed()) || itk::Math::NotExactlyEquals(v[1], c.GetGreen()) || itk::Math::NotExactlyEquals(v[2], c.GetBlue())) diff --git a/Modules/Filtering/ImageIntensity/test/itkRescaleIntensityImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkRescaleIntensityImageFilterTest.cxx index 7345488aeba..8c94049b983 100644 --- a/Modules/Filtering/ImageIntensity/test/itkRescaleIntensityImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkRescaleIntensityImageFilterTest.cxx @@ -42,7 +42,7 @@ itkRescaleIntensityImageFilterTest(int, char *[]) auto size = TestInputImage::SizeType::Filled(64); - TestInputImage::IndexType index{}; + const TestInputImage::IndexType index{}; region.SetIndex(index); region.SetSize(size); @@ -63,8 +63,8 @@ itkRescaleIntensityImageFilterTest(int, char *[]) // Set up source source->SetSize(randomSize); - double minValue = -128.0; - double maxValue = 127.0; + const double minValue = -128.0; + const double maxValue = 127.0; source->SetMin(static_cast(minValue)); source->SetMax(static_cast(maxValue)); diff --git a/Modules/Filtering/ImageIntensity/test/itkShiftScaleImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkShiftScaleImageFilterTest.cxx index 17d2d8607c4..07fdbd026b9 100644 --- a/Modules/Filtering/ImageIntensity/test/itkShiftScaleImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkShiftScaleImageFilterTest.cxx @@ -33,16 +33,16 @@ itkShiftScaleImageFilterTest(int, char *[]) using TestOutputImage = itk::Image; using RealType = itk::NumericTraits::RealType; - auto inputImage = TestInputImage::New(); - TestInputImage::RegionType region; - auto size = TestInputImage::SizeType::Filled(64); - TestInputImage::IndexType index{}; + auto inputImage = TestInputImage::New(); + TestInputImage::RegionType region; + auto size = TestInputImage::SizeType::Filled(64); + const TestInputImage::IndexType index{}; region.SetIndex(index); region.SetSize(size); // first try a constant image - double fillValue = -100.0; + const double fillValue = -100.0; inputImage->SetRegions(region); inputImage->Allocate(); inputImage->FillBuffer(static_cast(fillValue)); @@ -51,7 +51,7 @@ itkShiftScaleImageFilterTest(int, char *[]) auto filter = FilterType::New(); // Set up Start, End and Progress callbacks - itk::SimpleFilterWatcher filterWatch(filter); + const itk::SimpleFilterWatcher filterWatch(filter); // Filter the image filter->SetInput(inputImage); @@ -64,12 +64,12 @@ itkShiftScaleImageFilterTest(int, char *[]) TestInputImage::SizeValueType randomSize[3] = { 17, 8, 20 }; // Set up Start, End and Progress callbacks - itk::SimpleFilterWatcher sourceWatch(source); + const itk::SimpleFilterWatcher sourceWatch(source); // Set up source source->SetSize(randomSize); - double minValue = -128.0; - double maxValue = 127.0; + const double minValue = -128.0; + const double maxValue = 127.0; source->SetMin(static_cast(minValue)); source->SetMax(static_cast(maxValue)); @@ -77,13 +77,13 @@ itkShiftScaleImageFilterTest(int, char *[]) // Test GetMacros - RealType getShift = filter->GetShift(); + const RealType getShift = filter->GetShift(); std::cout << "filter->GetShift(): " << getShift << std::endl; - RealType getScale = filter->GetScale(); + const RealType getScale = filter->GetScale(); std::cout << "filter->GetScale(): " << getScale << std::endl; - long underflowCount = filter->GetUnderflowCount(); + const long underflowCount = filter->GetUnderflowCount(); std::cout << "filter->GetUnderflowCount(): " << underflowCount << std::endl; - long overflowCount = filter->GetOverflowCount(); + const long overflowCount = filter->GetOverflowCount(); std::cout << "filter->GetOverflowCount(): " << overflowCount << std::endl; diff --git a/Modules/Filtering/ImageIntensity/test/itkSigmoidImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkSigmoidImageFilterTest.cxx index eea21d0ff55..f5d52cfac8a 100644 --- a/Modules/Filtering/ImageIntensity/test/itkSigmoidImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkSigmoidImageFilterTest.cxx @@ -118,7 +118,7 @@ itkSigmoidImageFilterTest(int, char *[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output OutputIteratorType ot(outputImage, outputImage->GetRequestedRegion()); diff --git a/Modules/Filtering/ImageIntensity/test/itkSinImageFilterAndAdaptorTest.cxx b/Modules/Filtering/ImageIntensity/test/itkSinImageFilterAndAdaptorTest.cxx index e5a54d30d71..9538a8811b6 100644 --- a/Modules/Filtering/ImageIntensity/test/itkSinImageFilterAndAdaptorTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkSinImageFilterAndAdaptorTest.cxx @@ -100,7 +100,7 @@ itkSinImageFilterAndAdaptorTest(int, char *[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output OutputIteratorType ot(outputImage, outputImage->GetRequestedRegion()); @@ -150,7 +150,7 @@ itkSinImageFilterAndAdaptorTest(int, char *[]) diffFilter->Update(); // Get the filter output - OutputImageType::Pointer diffImage = diffFilter->GetOutput(); + const OutputImageType::Pointer diffImage = diffFilter->GetOutput(); // Check the content of the diff image // diff --git a/Modules/Filtering/ImageIntensity/test/itkSqrtImageFilterAndAdaptorTest.cxx b/Modules/Filtering/ImageIntensity/test/itkSqrtImageFilterAndAdaptorTest.cxx index d46b9ebd4a9..255bdbdee11 100644 --- a/Modules/Filtering/ImageIntensity/test/itkSqrtImageFilterAndAdaptorTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkSqrtImageFilterAndAdaptorTest.cxx @@ -100,7 +100,7 @@ itkSqrtImageFilterAndAdaptorTest(int, char *[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output OutputIteratorType ot(outputImage, outputImage->GetRequestedRegion()); @@ -149,7 +149,7 @@ itkSqrtImageFilterAndAdaptorTest(int, char *[]) diffFilter->Update(); // Get the filter output - OutputImageType::Pointer diffImage = diffFilter->GetOutput(); + const OutputImageType::Pointer diffImage = diffFilter->GetOutput(); // Check the content of the diff image // diff --git a/Modules/Filtering/ImageIntensity/test/itkSquareImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkSquareImageFilterTest.cxx index d718644e850..538a23e7451 100644 --- a/Modules/Filtering/ImageIntensity/test/itkSquareImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkSquareImageFilterTest.cxx @@ -98,7 +98,7 @@ itkSquareImageFilterTest(int, char *[]) filter->Update(); // Get the Smart Pointer to the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output OutputIteratorType ot(outputImage, outputImage->GetRequestedRegion()); diff --git a/Modules/Filtering/ImageIntensity/test/itkSubtractImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkSubtractImageFilterTest.cxx index b8408fa3a20..20e6d6bf92c 100644 --- a/Modules/Filtering/ImageIntensity/test/itkSubtractImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkSubtractImageFilterTest.cxx @@ -104,7 +104,7 @@ itkSubtractImageFilterTest(int, char *[]) // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output diff --git a/Modules/Filtering/ImageIntensity/test/itkSymmetricEigenAnalysisImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkSymmetricEigenAnalysisImageFilterTest.cxx index 32a191b4bf6..611d43bddad 100644 --- a/Modules/Filtering/ImageIntensity/test/itkSymmetricEigenAnalysisImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkSymmetricEigenAnalysisImageFilterTest.cxx @@ -35,7 +35,7 @@ makeTestableScalarImage(typename InternalImageType::Pointer internalImage, std:: using OutputPixelType = uint8_t; using OutputImageType = itk::Image; - OutputImageType::Pointer outputImage = OutputImageType::New(); + const OutputImageType::Pointer outputImage = OutputImageType::New(); outputImage->CopyInformation(internalImage); outputImage->SetRegions(internalImage->GetBufferedRegion()); outputImage->AllocateInitialized(); @@ -119,7 +119,7 @@ class SymmetricEigenAnalysisImageFilterHelper : public SymmetricEigenAnalysisIma size[1] = 8; size[2] = 8; - IndexType start{}; + const IndexType start{}; RegionType region; region.SetIndex(start); @@ -173,7 +173,7 @@ class SymmetricEigenAnalysisImageFilterHelper : public SymmetricEigenAnalysisIma // It is important to do it AFTER the filter is Updated // Because the object connected to the output may be changed // by another during GenerateData() call - typename InternalImageType::Pointer internalImage = filter->GetOutput(); + const typename InternalImageType::Pointer internalImage = filter->GetOutput(); ITK_TRY_EXPECT_NO_EXCEPTION(makeTestableScalarImage(internalImage, outputFilename)); @@ -226,7 +226,7 @@ class SymmetricEigenAnalysisFixedDimensionImageFilterHelper size[1] = 8; size[2] = 8; - IndexType start{}; + const IndexType start{}; RegionType region; region.SetIndex(start); @@ -258,7 +258,7 @@ class SymmetricEigenAnalysisFixedDimensionImageFilterHelper } // Create the filter - typename SymmetricEigenAnalysisFixedDimensionImageFilterType::Pointer filter = + const typename SymmetricEigenAnalysisFixedDimensionImageFilterType::Pointer filter = SymmetricEigenAnalysisFixedDimensionImageFilterType::New(); // Set the input image @@ -273,7 +273,7 @@ class SymmetricEigenAnalysisFixedDimensionImageFilterHelper // It is important to do it AFTER the filter is Updated // Because the object connected to the output may be changed // by another during GenerateData() call - typename InternalImageType::Pointer internalImage = filter->GetOutput(); + const typename InternalImageType::Pointer internalImage = filter->GetOutput(); ITK_TRY_EXPECT_NO_EXCEPTION(makeTestableScalarImage(internalImage, outputFilename)); std::cout << "Test succeeded." << std::endl; @@ -333,7 +333,7 @@ itkSymmetricEigenAnalysisImageFilterTest(int argc, char * argv[]) // Test the filter - int testResult = + const int testResult = itk::SymmetricEigenAnalysisImageFilterHelper::Exercise( order, outputFilename); @@ -354,7 +354,7 @@ itkSymmetricEigenAnalysisImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS( filterFixedDimension, SymmetricEigenAnalysisFixedDimensionImageFilter, UnaryFunctorImageFilter); - int testFixedDimensionResult = + const int testFixedDimensionResult = itk::SymmetricEigenAnalysisFixedDimensionImageFilterHelperUpdate(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output OutputIteratorType ot(outputImage, outputImage->GetRequestedRegion()); @@ -147,7 +147,7 @@ itkTanImageFilterAndAdaptorTest(int, char *[]) diffFilter->Update(); // Get the filter output - OutputImageType::Pointer diffImage = diffFilter->GetOutput(); + const OutputImageType::Pointer diffImage = diffFilter->GetOutput(); // Check the content of the diff image // diff --git a/Modules/Filtering/ImageIntensity/test/itkTernaryMagnitudeImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkTernaryMagnitudeImageFilterTest.cxx index 33fc2735227..1b1764b9805 100644 --- a/Modules/Filtering/ImageIntensity/test/itkTernaryMagnitudeImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkTernaryMagnitudeImageFilterTest.cxx @@ -92,7 +92,7 @@ itkTernaryMagnitudeImageFilterTest(int argc, char * argv[]) InputImage1IteratorType it1(inputImageA, inputImageA->GetBufferedRegion()); // Initialize the content of Image A - InputImage1Type::PixelType valueA = 2.0; + const InputImage1Type::PixelType valueA = 2.0; while (!it1.IsAtEnd()) { it1.Set(valueA); @@ -103,7 +103,7 @@ itkTernaryMagnitudeImageFilterTest(int argc, char * argv[]) InputImage2IteratorType it2(inputImageB, inputImageB->GetBufferedRegion()); // Initialize the content of Image B - InputImage2Type::PixelType valueB = 3.0; + const InputImage2Type::PixelType valueB = 3.0; while (!it2.IsAtEnd()) { it2.Set(valueB); @@ -114,7 +114,7 @@ itkTernaryMagnitudeImageFilterTest(int argc, char * argv[]) InputImage3IteratorType it3(inputImageC, inputImageC->GetBufferedRegion()); // Initialize the content of Image C - InputImage3Type::PixelType valueC = 4.0; + const InputImage3Type::PixelType valueC = 4.0; while (!it3.IsAtEnd()) { it3.Set(valueC); @@ -138,7 +138,7 @@ itkTernaryMagnitudeImageFilterTest(int argc, char * argv[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Write the result image using WriterType = itk::ImageFileWriter; diff --git a/Modules/Filtering/ImageIntensity/test/itkTernaryMagnitudeSquaredImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkTernaryMagnitudeSquaredImageFilterTest.cxx index 0c16e17a0eb..0b820e64a56 100644 --- a/Modules/Filtering/ImageIntensity/test/itkTernaryMagnitudeSquaredImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkTernaryMagnitudeSquaredImageFilterTest.cxx @@ -136,7 +136,7 @@ itkTernaryMagnitudeSquaredImageFilterTest(int, char *[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output OutputImageIteratorType oIt(outputImage, outputImage->GetBufferedRegion()); diff --git a/Modules/Filtering/ImageIntensity/test/itkTernaryOperatorImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkTernaryOperatorImageFilterTest.cxx index ec6f5f81395..ea809586fcf 100644 --- a/Modules/Filtering/ImageIntensity/test/itkTernaryOperatorImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkTernaryOperatorImageFilterTest.cxx @@ -30,7 +30,7 @@ itkTernaryOperatorImageFilterTest(int, char *[]) // Test the functor // - itk::Functor::TernaryOperator func; + const itk::Functor::TernaryOperator func; if ((true ? 12 : 37) != func(true, 12, 37)) { @@ -67,9 +67,9 @@ itkTernaryOperatorImageFilterTest(int, char *[]) using MaskImageType = itk::Image; using GrayImageType = itk::Image; - MaskImageType::IndexType origin{}; - auto size = MaskImageType::SizeType::Filled(20); - MaskImageType::RegionType region(origin, size); + const MaskImageType::IndexType origin{}; + auto size = MaskImageType::SizeType::Filled(20); + const MaskImageType::RegionType region(origin, size); auto mask = MaskImageType::New(); mask->SetRegions(region); diff --git a/Modules/Filtering/ImageIntensity/test/itkVectorExpandImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkVectorExpandImageFilterTest.cxx index 39752de3df3..14ce8799459 100644 --- a/Modules/Filtering/ImageIntensity/test/itkVectorExpandImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkVectorExpandImageFilterTest.cxx @@ -91,8 +91,8 @@ itkVectorExpandImageFilterTest(int, char *[]) std::cout << "Create the input image pattern." << std::endl; - ImageType::RegionType region; - ImageType::SizeType size = { { 64, 64 } }; + ImageType::RegionType region; + const ImageType::SizeType size = { { 64, 64 } }; region.SetSize(size); auto input = ImageType::New(); @@ -108,7 +108,7 @@ itkVectorExpandImageFilterTest(int, char *[]) pattern.m_Coeff[j] = 1.0; } - double vectorCoeff[VectorDimension] = { 1.0, 4.0, 6.0 }; + const double vectorCoeff[VectorDimension] = { 1.0, 4.0, 6.0 }; using Iterator = itk::ImageRegionIteratorWithIndex; Iterator inIter(input, region); @@ -116,8 +116,8 @@ itkVectorExpandImageFilterTest(int, char *[]) for (; !inIter.IsAtEnd(); ++inIter) { - double value = pattern.Evaluate(inIter.GetIndex()); - PixelType pixel; + const double value = pattern.Evaluate(inIter.GetIndex()); + PixelType pixel; for (k = 0; k < VectorDimension; ++k) { pixel[k] = vectorCoeff[k] * value; @@ -170,23 +170,23 @@ itkVectorExpandImageFilterTest(int, char *[]) Iterator outIter(expanderOutput, expanderOutput->GetBufferedRegion()); // compute non-padded output region - ImageType::RegionType validRegion = expanderOutput->GetLargestPossibleRegion(); - ImageType::SizeType validSize = validRegion.GetSize(); + ImageType::RegionType validRegion = expanderOutput->GetLargestPossibleRegion(); + const ImageType::SizeType validSize = validRegion.GetSize(); validRegion.SetSize(validSize); for (; !outIter.IsAtEnd(); ++outIter) { - ImageType::IndexType index = outIter.GetIndex(); - ImageType::PixelType value = outIter.Get(); + const ImageType::IndexType index = outIter.GetIndex(); + ImageType::PixelType value = outIter.Get(); if (validRegion.IsInside(index)) { ImageType::PointType point; expanderOutput->TransformIndexToPhysicalPoint(outIter.GetIndex(), point); - ImageType::IndexType inputIndex = input->TransformPhysicalPointToIndex(point); - double baseValue = pattern.Evaluate(inputIndex); + const ImageType::IndexType inputIndex = input->TransformPhysicalPointToIndex(point); + const double baseValue = pattern.Evaluate(inputIndex); for (k = 0; k < VectorDimension; ++k) { diff --git a/Modules/Filtering/ImageIntensity/test/itkVectorIndexSelectionCastImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkVectorIndexSelectionCastImageFilterTest.cxx index 5c5a0dd2b55..0cc3f7ebfc8 100644 --- a/Modules/Filtering/ImageIntensity/test/itkVectorIndexSelectionCastImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkVectorIndexSelectionCastImageFilterTest.cxx @@ -67,7 +67,7 @@ itkVectorIndexSelectionCastImageFilterTest(int argc, char * argv[]) std::cout << "Test the exception if the index is too large" << std::endl; - InputImageType::ConstPointer inputImage = reader->GetOutput(); + const InputImageType::ConstPointer inputImage = reader->GetOutput(); const unsigned int maximumIndex = inputImage->GetNumberOfComponentsPerPixel(); diff --git a/Modules/Filtering/ImageIntensity/test/itkVectorMagnitudeImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkVectorMagnitudeImageFilterTest.cxx index dde123e980e..9b0f508747a 100644 --- a/Modules/Filtering/ImageIntensity/test/itkVectorMagnitudeImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkVectorMagnitudeImageFilterTest.cxx @@ -33,9 +33,9 @@ itkVectorMagnitudeImageFilterTest(int, char *[]) // Define the size start index of the image auto size = VectorImageType::SizeType::Filled(3); - VectorImageType::IndexType start{}; + const VectorImageType::IndexType start{}; - VectorImageType::RegionType region(start, size); + const VectorImageType::RegionType region(start, size); // Construct an image auto image = VectorImageType::New(); @@ -78,7 +78,7 @@ itkVectorMagnitudeImageFilterTest(int, char *[]) } // Get the filter output - FloatImageType::Pointer outputImage = magnitude->GetOutput(); + const FloatImageType::Pointer outputImage = magnitude->GetOutput(); // Declare Iterator type for the output image using myOutputIteratorType = itk::ImageRegionIterator; diff --git a/Modules/Filtering/ImageIntensity/test/itkVectorRescaleIntensityImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkVectorRescaleIntensityImageFilterTest.cxx index 61f4aa02cd6..b7ba0d69113 100644 --- a/Modules/Filtering/ImageIntensity/test/itkVectorRescaleIntensityImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkVectorRescaleIntensityImageFilterTest.cxx @@ -77,20 +77,20 @@ itkVectorRescaleIntensityImageFilterTest(int, char *[]) ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); - FilterType::InputRealType scale = filter->GetScale(); + const FilterType::InputRealType scale = filter->GetScale(); std::cout << "Input scale value: " << static_cast::PrintType>(scale) << std::endl; - FilterType::InputRealType shift = filter->GetShift(); + const FilterType::InputRealType shift = filter->GetShift(); std::cout << "Input scale value: " << static_cast::PrintType>(shift) << std::endl; - FilterType::InputRealType inputMaximumMagnitude = filter->GetInputMaximumMagnitude(); + const FilterType::InputRealType inputMaximumMagnitude = filter->GetInputMaximumMagnitude(); std::cout << "Input maximum magnitude: " << static_cast::PrintType>(inputMaximumMagnitude) << std::endl; - OutputImageType::ConstPointer outputImage = filter->GetOutput(); + const OutputImageType::ConstPointer outputImage = filter->GetOutput(); using IteratorType = itk::ImageRegionConstIterator; diff --git a/Modules/Filtering/ImageIntensity/test/itkVectorToRGBImageAdaptorTest.cxx b/Modules/Filtering/ImageIntensity/test/itkVectorToRGBImageAdaptorTest.cxx index 1ba642ffbfd..cd41ca2fa0e 100644 --- a/Modules/Filtering/ImageIntensity/test/itkVectorToRGBImageAdaptorTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkVectorToRGBImageAdaptorTest.cxx @@ -64,7 +64,7 @@ itkVectorToRGBImageAdaptorTest(int, char *[]) index[0] = 0; index[1] = 0; - ImageType::RegionType region{ index, size }; + const ImageType::RegionType region{ index, size }; auto image = ImageType::New(); diff --git a/Modules/Filtering/ImageIntensity/test/itkWeightedAddImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkWeightedAddImageFilterTest.cxx index 5eb5596f997..227d180dcba 100644 --- a/Modules/Filtering/ImageIntensity/test/itkWeightedAddImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkWeightedAddImageFilterTest.cxx @@ -60,8 +60,8 @@ itkWeightedAddImageFilterTest(int argc, char * argv[]) using myFilterTypePointer = myFilterType::Pointer; // Create two images - myImageType1Pointer inputImageA = myImageType1::New(); - myImageType2Pointer inputImageB = myImageType2::New(); + const myImageType1Pointer inputImageA = myImageType1::New(); + const myImageType2Pointer inputImageB = myImageType2::New(); // Define their size, and start index mySizeType size; @@ -74,7 +74,7 @@ itkWeightedAddImageFilterTest(int argc, char * argv[]) start[1] = 0; start[2] = 0; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; // Initialize Image A inputImageA->SetRegions(region); @@ -116,7 +116,7 @@ itkWeightedAddImageFilterTest(int argc, char * argv[]) // Create an ADD Filter - myFilterTypePointer filter = myFilterType::New(); + const myFilterTypePointer filter = myFilterType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, WeightedAddImageFilter, BinaryGeneratorImageFilter); @@ -130,7 +130,7 @@ itkWeightedAddImageFilterTest(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(alpha, filter->GetAlpha()); // Get the Smart Pointer to the Filter Output - myImageType3Pointer outputImage = filter->GetOutput(); + const myImageType3Pointer outputImage = filter->GetOutput(); // Execute the filter diff --git a/Modules/Filtering/ImageIntensity/test/itkXorImageFilterTest.cxx b/Modules/Filtering/ImageIntensity/test/itkXorImageFilterTest.cxx index bc7c6d694c0..a8bfce05a86 100644 --- a/Modules/Filtering/ImageIntensity/test/itkXorImageFilterTest.cxx +++ b/Modules/Filtering/ImageIntensity/test/itkXorImageFilterTest.cxx @@ -88,7 +88,7 @@ itkXorImageFilterTest(int argc, char * argv[]) it1.GoToBegin(); // Initialize the content of Image A - InputImage1Type::PixelType valueA = 2; + const InputImage1Type::PixelType valueA = 2; while (!it1.IsAtEnd()) { it1.Set(valueA); @@ -100,7 +100,7 @@ itkXorImageFilterTest(int argc, char * argv[]) it2.GoToBegin(); // Initialize the content of Image B - InputImage2Type::PixelType valueB = 3; + const InputImage2Type::PixelType valueB = 3; while (!it2.IsAtEnd()) { it2.Set(valueB); @@ -121,7 +121,7 @@ itkXorImageFilterTest(int argc, char * argv[]) filter->Update(); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Write the result image using WriterType = itk::ImageFileWriter; diff --git a/Modules/Filtering/ImageLabel/include/itkBinaryContourImageFilter.hxx b/Modules/Filtering/ImageLabel/include/itkBinaryContourImageFilter.hxx index f4b41fc5eed..d42a9298396 100644 --- a/Modules/Filtering/ImageLabel/include/itkBinaryContourImageFilter.hxx +++ b/Modules/Filtering/ImageLabel/include/itkBinaryContourImageFilter.hxx @@ -47,7 +47,7 @@ BinaryContourImageFilter::GenerateInputRequestedRegio Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (!input) { return; @@ -59,7 +59,7 @@ template void BinaryContourImageFilter::EnlargeOutputRequestedRegion(DataObject *) { - OutputImagePointer output = this->GetOutput(); + const OutputImagePointer output = this->GetOutput(); output->SetRequestedRegionToLargestPossibleRegion(); } @@ -74,7 +74,7 @@ BinaryContourImageFilter::GenerateData() ProgressTransformer progress1(0.05f, 0.5f, this); - RegionType reqRegion = this->GetOutput()->GetRequestedRegion(); + const RegionType reqRegion = this->GetOutput()->GetRequestedRegion(); this->GetMultiThreader()->SetNumberOfWorkUnits(this->GetNumberOfWorkUnits()); // parallelize in a way which does not split the region along X axis @@ -102,8 +102,8 @@ template void BinaryContourImageFilter::BeforeThreadedGenerateData() { - OutputImagePointer output = this->GetOutput(); - InputImageConstPointer input = this->GetInput(); + const OutputImagePointer output = this->GetOutput(); + const InputImageConstPointer input = this->GetInput(); const RegionType & reqRegion = output->GetRequestedRegion(); const SizeValueType pixelcount = reqRegion.GetNumberOfPixels(); @@ -137,13 +137,13 @@ BinaryContourImageFilter::DynamicThreadedGenerateData while (!inLineIt.IsAtEndOfLine()) { - InputImagePixelType PVal = inLineIt.Get(); + const InputImagePixelType PVal = inLineIt.Get(); if (Math::AlmostEquals(PVal, m_ForegroundValue)) { // We've hit the start of a run - SizeValueType length = 0; - IndexType thisIndex = inLineIt.GetIndex(); + SizeValueType length = 0; + const IndexType thisIndex = inLineIt.GetIndex(); outLineIt.Set(m_BackgroundValue); @@ -164,8 +164,8 @@ BinaryContourImageFilter::DynamicThreadedGenerateData else { // We've hit the start of a run - SizeValueType length = 0; - IndexType thisIndex = inLineIt.GetIndex(); + SizeValueType length = 0; + const IndexType thisIndex = inLineIt.GetIndex(); outLineIt.Set(PVal); ++length; @@ -193,24 +193,24 @@ template void BinaryContourImageFilter::ThreadedIntegrateData(const RegionType & outputRegionForThread) { - OutputImagePointer output = this->GetOutput(); + const OutputImagePointer output = this->GetOutput(); - OffsetValueType linecount = m_ForegroundLineMap.size(); + const OffsetValueType linecount = m_ForegroundLineMap.size(); for (ImageScanlineIterator outLineIt(output, outputRegionForThread); !outLineIt.IsAtEnd(); outLineIt.NextLine()) { - SizeValueType thisIdx = this->IndexToLinearIndex(outLineIt.GetIndex()); + const SizeValueType thisIdx = this->IndexToLinearIndex(outLineIt.GetIndex()); if (!m_ForegroundLineMap[thisIdx].empty()) { for (OffsetVectorConstIterator I = this->m_LineOffsets.begin(); I != this->m_LineOffsets.end(); ++I) { - OffsetValueType neighIdx = thisIdx + (*I); + const OffsetValueType neighIdx = thisIdx + (*I); // check if the neighbor is in the map if (neighIdx >= 0 && neighIdx < OffsetValueType(linecount) && !m_BackgroundLineMap[neighIdx].empty()) { // Now check whether they are really neighbors - bool areNeighbors = + const bool areNeighbors = this->CheckNeighbors(m_ForegroundLineMap[thisIdx][0].where, m_BackgroundLineMap[neighIdx][0].where); if (areNeighbors) { diff --git a/Modules/Filtering/ImageLabel/include/itkChangeLabelImageFilter.hxx b/Modules/Filtering/ImageLabel/include/itkChangeLabelImageFilter.hxx index dbf8b1e5e08..fb3e8c1a187 100644 --- a/Modules/Filtering/ImageLabel/include/itkChangeLabelImageFilter.hxx +++ b/Modules/Filtering/ImageLabel/include/itkChangeLabelImageFilter.hxx @@ -39,7 +39,7 @@ void ChangeLabelImageFilter::SetChange(const InputPixelType & original, const OutputPixelType & result) { - OutputPixelType current = this->GetFunctor().GetChange(original); + const OutputPixelType current = this->GetFunctor().GetChange(original); if (current != result) { diff --git a/Modules/Filtering/ImageLabel/include/itkLabelContourImageFilter.hxx b/Modules/Filtering/ImageLabel/include/itkLabelContourImageFilter.hxx index 63f62aa9443..98324bc4970 100644 --- a/Modules/Filtering/ImageLabel/include/itkLabelContourImageFilter.hxx +++ b/Modules/Filtering/ImageLabel/include/itkLabelContourImageFilter.hxx @@ -42,7 +42,7 @@ LabelContourImageFilter::GenerateInputRequestedRegion Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (!input) { @@ -70,7 +70,7 @@ LabelContourImageFilter::GenerateData() ProgressTransformer progress1(0.01f, 0.5f, this); - OutputRegionType reqRegion = this->GetOutput()->GetRequestedRegion(); + const OutputRegionType reqRegion = this->GetOutput()->GetRequestedRegion(); this->GetMultiThreader()->SetNumberOfWorkUnits(this->GetNumberOfWorkUnits()); this->GetMultiThreader()->template ParallelizeImageRegionRestrictDirection( @@ -97,9 +97,9 @@ LabelContourImageFilter::BeforeThreadedGenerateData() { OutputImageType * output = this->GetOutput(); - SizeValueType pixelcount = output->GetRequestedRegion().GetNumberOfPixels(); - SizeValueType xsize = output->GetRequestedRegion().GetSize()[0]; - SizeValueType linecount = pixelcount / xsize; + const SizeValueType pixelcount = output->GetRequestedRegion().GetNumberOfPixels(); + const SizeValueType xsize = output->GetRequestedRegion().GetSize()[0]; + const SizeValueType linecount = pixelcount / xsize; m_LineMap.clear(); m_LineMap.resize(linecount); @@ -121,14 +121,14 @@ LabelContourImageFilter::DynamicThreadedGenerateData( for (inLineIt.GoToBegin(); !inLineIt.IsAtEnd(); inLineIt.NextLine(), outLineIt.NextLine()) { - SizeValueType lineId = this->IndexToLinearIndex(inLineIt.GetIndex()); - LineEncodingType thisLine; + const SizeValueType lineId = this->IndexToLinearIndex(inLineIt.GetIndex()); + LineEncodingType thisLine; while (!inLineIt.IsAtEndOfLine()) { - InputPixelType PVal = inLineIt.Get(); + const InputPixelType PVal = inLineIt.Get(); - SizeValueType length = 0; - InputIndexType thisIndex = inLineIt.GetIndex(); + SizeValueType length = 0; + const InputIndexType thisIndex = inLineIt.GetIndex(); outLineIt.Set(m_BackgroundValue); ++length; ++inLineIt; @@ -141,7 +141,7 @@ LabelContourImageFilter::DynamicThreadedGenerateData( ++outLineIt; } // create the run length object to go in the vector - RunLength thisRun = { length, thisIndex, static_cast(PVal) }; + const RunLength thisRun = { length, thisIndex, static_cast(PVal) }; thisLine.push_back(thisRun); } @@ -156,19 +156,19 @@ LabelContourImageFilter::ThreadedIntegrateData( { OutputImageType * output = this->GetOutput(); - SizeValueType pixelcount = output->GetRequestedRegion().GetNumberOfPixels(); - SizeValueType xsize = output->GetRequestedRegion().GetSize()[0]; - OffsetValueType linecount = pixelcount / xsize; + const SizeValueType pixelcount = output->GetRequestedRegion().GetNumberOfPixels(); + const SizeValueType xsize = output->GetRequestedRegion().GetSize()[0]; + const OffsetValueType linecount = pixelcount / xsize; itkAssertInDebugAndIgnoreInReleaseMacro(SizeValueType(linecount) == m_LineMap.size()); for (ImageScanlineIterator outLineIt(output, outputRegionForThread); !outLineIt.IsAtEnd(); outLineIt.NextLine()) { - SizeValueType thisIdx = this->IndexToLinearIndex(outLineIt.GetIndex()); + const SizeValueType thisIdx = this->IndexToLinearIndex(outLineIt.GetIndex()); if (!m_LineMap[thisIdx].empty()) { for (OffsetVectorConstIterator I = this->m_LineOffsets.begin(); I != this->m_LineOffsets.end(); ++I) { - OffsetValueType neighIdx = thisIdx + (*I); + const OffsetValueType neighIdx = thisIdx + (*I); // check if the neighbor is in the map if (neighIdx >= 0 && neighIdx < linecount) @@ -176,7 +176,7 @@ LabelContourImageFilter::ThreadedIntegrateData( if (!m_LineMap[neighIdx].empty()) { // Now check whether they are really neighbors - bool areNeighbors = this->CheckNeighbors(m_LineMap[thisIdx][0].where, m_LineMap[neighIdx][0].where); + const bool areNeighbors = this->CheckNeighbors(m_LineMap[thisIdx][0].where, m_LineMap[neighIdx][0].where); if (areNeighbors) { this->CompareLines(m_LineMap[thisIdx], diff --git a/Modules/Filtering/ImageLabel/include/itkScanlineFilterCommon.h b/Modules/Filtering/ImageLabel/include/itkScanlineFilterCommon.h index 925f60494fa..e0295828dd5 100644 --- a/Modules/Filtering/ImageLabel/include/itkScanlineFilterCommon.h +++ b/Modules/Filtering/ImageLabel/include/itkScanlineFilterCommon.h @@ -139,9 +139,9 @@ class ScanlineFilterCommon SizeValueType IndexToLinearIndex(const IndexType & index) const { - SizeValueType linearIndex = 0; - SizeValueType stride = 1; - RegionType requestedRegion = m_EnclosingFilter->GetOutput()->GetRequestedRegion(); + SizeValueType linearIndex = 0; + SizeValueType stride = 1; + const RegionType requestedRegion = m_EnclosingFilter->GetOutput()->GetRequestedRegion(); // ignore x axis, which is always full size for (unsigned int dim = 1; dim < ImageDimension; ++dim) { @@ -157,9 +157,9 @@ class ScanlineFilterCommon { m_UnionFind = UnionFindType(numberOfLabels + 1); - typename LineMapType::iterator MapBegin = m_LineMap.begin(); - typename LineMapType::iterator MapEnd = m_LineMap.end(); - InternalLabelType label = 1; + const typename LineMapType::iterator MapBegin = m_LineMap.begin(); + const typename LineMapType::iterator MapEnd = m_LineMap.end(); + InternalLabelType label = 1; for (typename LineMapType::iterator LineIt = MapBegin; LineIt != MapEnd; ++LineIt) { for (LineEncodingIterator cIt = LineIt->begin(); cIt != LineIt->end(); ++cIt) @@ -186,8 +186,8 @@ class ScanlineFilterCommon LinkLabels(const InternalLabelType label1, const InternalLabelType label2) { const std::lock_guard lockGuard(m_Mutex); - InternalLabelType E1 = this->LookupSet(label1); - InternalLabelType E2 = this->LookupSet(label2); + const InternalLabelType E1 = this->LookupSet(label1); + const InternalLabelType E2 = this->LookupSet(label2); if (E1 < E2) { @@ -235,7 +235,7 @@ class ScanlineFilterCommon SizeValueType diffSum = 0; for (unsigned int i = 1; i < OutputImageDimension; ++i) { - SizeValueType diff = itk::Math::abs(A[i] - B[i]); + const SizeValueType diff = itk::Math::abs(A[i] - B[i]); if (diff > 1) { return false; @@ -290,8 +290,8 @@ class ScanlineFilterCommon { if (!labelCompare || cIt->label != InternalLabelType(background)) { - OffsetValueType cStart = cIt->where[0]; // the start x position - OffsetValueType cLast = cStart + cIt->length - 1; + const OffsetValueType cStart = cIt->where[0]; // the start x position + const OffsetValueType cLast = cStart + cIt->length - 1; if (labelCompare) { @@ -302,8 +302,8 @@ class ScanlineFilterCommon { if (!labelCompare || cIt->label != nIt->label) { - OffsetValueType nStart = nIt->where[0]; - OffsetValueType nLast = nStart + nIt->length - 1; + const OffsetValueType nStart = nIt->where[0]; + const OffsetValueType nLast = nStart + nIt->length - 1; // there are a few ways that neighbouring lines might overlap // neighbor S------------------E @@ -318,10 +318,10 @@ class ScanlineFilterCommon // neighbor S------------------E // current S-------E //------------- - OffsetValueType ss1 = nStart - offset; + const OffsetValueType ss1 = nStart - offset; // OffsetValueType ss2 = nStart + offset; - OffsetValueType ee1 = nLast - offset; - OffsetValueType ee2 = nLast + offset; + const OffsetValueType ee1 = nLast - offset; + const OffsetValueType ee2 = nLast + offset; bool eq = false; OffsetValueType oStart = 0; @@ -388,7 +388,7 @@ class ScanlineFilterCommon // We are going to misuse the neighborhood iterators to compute the // offset for us. All this messing around produces an array of // offsets that will be used to index the map - typename TOutputImage::Pointer output = m_EnclosingFilter->GetOutput(); + const typename TOutputImage::Pointer output = m_EnclosingFilter->GetOutput(); using PretendImageType = Image; using PretendSizeType = typename PretendImageType::RegionType::SizeType; using PretendIndexType = typename PretendImageType::RegionType::IndexType; @@ -423,8 +423,8 @@ class ScanlineFilterCommon typename LineNeighborhoodType::IndexListType ActiveIndexes = lnit.GetActiveIndexList(); - PretendIndexType idx = LineRegion.GetIndex(); - OffsetValueType offset = fakeImage->ComputeOffset(idx); + const PretendIndexType idx = LineRegion.GetIndex(); + const OffsetValueType offset = fakeImage->ComputeOffset(idx); for (typename LineNeighborhoodType::IndexListType::const_iterator LI = ActiveIndexes.begin(); LI != ActiveIndexes.end(); @@ -464,7 +464,7 @@ class ScanlineFilterCommon ComputeEquivalence(const SizeValueType workUnitResultsIndex, bool strictlyLess) { const OffsetValueType linecount = m_LineMap.size(); - WorkUnitData wud = m_WorkUnitResults[workUnitResultsIndex]; + const WorkUnitData wud = m_WorkUnitResults[workUnitResultsIndex]; SizeValueType lastLine = wud.lastLine; if (!strictlyLess) { @@ -479,12 +479,12 @@ class ScanlineFilterCommon auto it = this->m_LineOffsets.begin(); while (it != this->m_LineOffsets.end()) { - OffsetValueType neighIdx = thisIdx + (*it); + const OffsetValueType neighIdx = thisIdx + (*it); // check if the neighbor is in the map if (neighIdx >= 0 && neighIdx < linecount && !m_LineMap[neighIdx].empty()) { // Now check whether they are really neighbors - bool areNeighbors = this->CheckNeighbors(m_LineMap[thisIdx][0].where, m_LineMap[neighIdx][0].where); + const bool areNeighbors = this->CheckNeighbors(m_LineMap[thisIdx][0].where, m_LineMap[neighIdx][0].where); if (areNeighbors) { this->CompareLines(m_LineMap[thisIdx], diff --git a/Modules/Filtering/ImageLabel/test/itkBinaryContourImageFilterTest.cxx b/Modules/Filtering/ImageLabel/test/itkBinaryContourImageFilterTest.cxx index b67e0ef7838..61857b396fb 100644 --- a/Modules/Filtering/ImageLabel/test/itkBinaryContourImageFilterTest.cxx +++ b/Modules/Filtering/ImageLabel/test/itkBinaryContourImageFilterTest.cxx @@ -73,7 +73,7 @@ itkBinaryContourImageFilterTest(int argc, char * argv[]) filter->SetInput(reader->GetOutput()); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageLabel/test/itkChangeLabelImageFilterTest.cxx b/Modules/Filtering/ImageLabel/test/itkChangeLabelImageFilterTest.cxx index f22357cad68..fd6ac6e762f 100644 --- a/Modules/Filtering/ImageLabel/test/itkChangeLabelImageFilterTest.cxx +++ b/Modules/Filtering/ImageLabel/test/itkChangeLabelImageFilterTest.cxx @@ -45,7 +45,7 @@ itkChangeLabelImageFilterTest(int, char *[]) InputImageType::SizeValueType sizeArray[ImageDimension] = { 3, 3, 3 }; // limit to a few labels - InputPixelType upper = 10; + const InputPixelType upper = 10; source->SetMin(InputPixelType{}); source->SetMax(upper); source->SetSize(sizeArray); @@ -58,8 +58,8 @@ itkChangeLabelImageFilterTest(int, char *[]) auto filter = FilterType::New(); // Eliminate most labels - InputPixelType background = 0; - InputPixelType maxRemainingLabel = 2; + const InputPixelType background = 0; + const InputPixelType maxRemainingLabel = 2; for (InputPixelType i = maxRemainingLabel; i <= upper; ++i) { filter->SetChange(i, background); @@ -74,7 +74,7 @@ itkChangeLabelImageFilterTest(int, char *[]) filter->SetInput(source->GetOutput()); // Get the Smart Pointer to the Filter Output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Execute the filter try diff --git a/Modules/Filtering/ImageLabel/test/itkLabelContourImageFilterTest.cxx b/Modules/Filtering/ImageLabel/test/itkLabelContourImageFilterTest.cxx index fc43305c30d..f5f661a6a1f 100644 --- a/Modules/Filtering/ImageLabel/test/itkLabelContourImageFilterTest.cxx +++ b/Modules/Filtering/ImageLabel/test/itkLabelContourImageFilterTest.cxx @@ -64,7 +64,7 @@ itkLabelContourImageFilterTest(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(backgroundValue, filter->GetBackgroundValue()); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageNoise/test/itkAdditiveGaussianNoiseImageFilterTest.cxx b/Modules/Filtering/ImageNoise/test/itkAdditiveGaussianNoiseImageFilterTest.cxx index 84e15316b90..95fe7695caf 100644 --- a/Modules/Filtering/ImageNoise/test/itkAdditiveGaussianNoiseImageFilterTest.cxx +++ b/Modules/Filtering/ImageNoise/test/itkAdditiveGaussianNoiseImageFilterTest.cxx @@ -67,7 +67,7 @@ itkAdditiveGaussianNoiseImageFilterTest(int argc, char * argv[]) additiveGaussianNoiseFilter->SetInput(reader->GetOutput()); - itk::SimpleFilterWatcher watcher(additiveGaussianNoiseFilter, "AdditiveGaussianNoiseImageFilter"); + const itk::SimpleFilterWatcher watcher(additiveGaussianNoiseFilter, "AdditiveGaussianNoiseImageFilter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageNoise/test/itkPeakSignalToNoiseRatioCalculatorTest.cxx b/Modules/Filtering/ImageNoise/test/itkPeakSignalToNoiseRatioCalculatorTest.cxx index 7efd50b3e81..d6227ad40da 100644 --- a/Modules/Filtering/ImageNoise/test/itkPeakSignalToNoiseRatioCalculatorTest.cxx +++ b/Modules/Filtering/ImageNoise/test/itkPeakSignalToNoiseRatioCalculatorTest.cxx @@ -56,8 +56,8 @@ itkPeakSignalToNoiseRatioCalculatorTest(int argc, char * argv[]) if (argc >= 5) { - double expectedValue = std::stod(argv[3]); - double tolerance = std::stod(argv[4]); + const double expectedValue = std::stod(argv[3]); + const double tolerance = std::stod(argv[4]); std::cout << ""; std::cout << psnr->GetOutput(); diff --git a/Modules/Filtering/ImageNoise/test/itkSaltAndPepperNoiseImageFilterTest.cxx b/Modules/Filtering/ImageNoise/test/itkSaltAndPepperNoiseImageFilterTest.cxx index 020c0060619..9a53df64617 100644 --- a/Modules/Filtering/ImageNoise/test/itkSaltAndPepperNoiseImageFilterTest.cxx +++ b/Modules/Filtering/ImageNoise/test/itkSaltAndPepperNoiseImageFilterTest.cxx @@ -58,10 +58,10 @@ itkSaltAndPepperNoiseImageFilterTest(int argc, char * argv[]) // change the default values and then set back to defaults so that // the original test image is still valid. - PixelType saltValue = 245; + const PixelType saltValue = 245; saltAndPepperNoiseImageFilter->SetSaltValue(saltValue); ITK_TEST_SET_GET_VALUE(saltValue, saltAndPepperNoiseImageFilter->GetSaltValue()); - PixelType pepperValue = 10; + const PixelType pepperValue = 10; saltAndPepperNoiseImageFilter->SetPepperValue(pepperValue); ITK_TEST_SET_GET_VALUE(pepperValue, saltAndPepperNoiseImageFilter->GetPepperValue()); saltAndPepperNoiseImageFilter->SetSaltValue(itk::NumericTraits::max()); @@ -69,7 +69,7 @@ itkSaltAndPepperNoiseImageFilterTest(int argc, char * argv[]) saltAndPepperNoiseImageFilter->SetInput(reader->GetOutput()); - itk::SimpleFilterWatcher watcher(saltAndPepperNoiseImageFilter, "SaltAndPepperNoiseImageFilter"); + const itk::SimpleFilterWatcher watcher(saltAndPepperNoiseImageFilter, "SaltAndPepperNoiseImageFilter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageNoise/test/itkShotNoiseImageFilterTest.cxx b/Modules/Filtering/ImageNoise/test/itkShotNoiseImageFilterTest.cxx index fc7575696bc..ebdf9f522af 100644 --- a/Modules/Filtering/ImageNoise/test/itkShotNoiseImageFilterTest.cxx +++ b/Modules/Filtering/ImageNoise/test/itkShotNoiseImageFilterTest.cxx @@ -59,7 +59,7 @@ itkShotNoiseImageFilterTest(int argc, char * argv[]) shotNoiseImageFilter->SetInput(reader->GetOutput()); - itk::SimpleFilterWatcher watcher(shotNoiseImageFilter, "ShotNoiseImageFilter"); + const itk::SimpleFilterWatcher watcher(shotNoiseImageFilter, "ShotNoiseImageFilter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageNoise/test/itkSpeckleNoiseImageFilterTest.cxx b/Modules/Filtering/ImageNoise/test/itkSpeckleNoiseImageFilterTest.cxx index d1f517cea74..792eb49149b 100644 --- a/Modules/Filtering/ImageNoise/test/itkSpeckleNoiseImageFilterTest.cxx +++ b/Modules/Filtering/ImageNoise/test/itkSpeckleNoiseImageFilterTest.cxx @@ -59,7 +59,7 @@ itkSpeckleNoiseImageFilterTest(int argc, char * argv[]) speckleNoiseImageFilter->SetInput(reader->GetOutput()); - itk::SimpleFilterWatcher watcher(speckleNoiseImageFilter, "SpeckleNoiseImageFilter"); + const itk::SimpleFilterWatcher watcher(speckleNoiseImageFilter, "SpeckleNoiseImageFilter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageSources/include/itkGridImageSource.hxx b/Modules/Filtering/ImageSources/include/itkGridImageSource.hxx index a11671d696e..682fb31565a 100644 --- a/Modules/Filtering/ImageSources/include/itkGridImageSource.hxx +++ b/Modules/Filtering/ImageSources/include/itkGridImageSource.hxx @@ -62,7 +62,7 @@ GridImageSource::BeforeThreadedGenerateData() // Add two extra functions in the front and one in the back to ensure // coverage. - unsigned int numberOfGaussians = + const unsigned int numberOfGaussians = Math::Ceil(this->GetSize()[i] * output->GetSpacing()[i] / this->m_GridSpacing[i]) + 4u; for (It.GoToBegin(); !It.IsAtEndOfLine(); ++It) { @@ -73,8 +73,8 @@ GridImageSource::BeforeThreadedGenerateData() RealType val = 0; for (unsigned int j = 0; j < numberOfGaussians; ++j) { - RealType num = point[i] - static_cast(j - 2) * this->m_GridSpacing[i] - output->GetOrigin()[i] - - this->m_GridOffset[i]; + const RealType num = point[i] - static_cast(j - 2) * this->m_GridSpacing[i] - + output->GetOrigin()[i] - this->m_GridOffset[i]; val += this->m_KernelFunction->Evaluate(num / this->m_Sigma[i]); } pixels[index[i]] = val; diff --git a/Modules/Filtering/ImageSources/test/itkGaborImageSourceTest.cxx b/Modules/Filtering/ImageSources/test/itkGaborImageSourceTest.cxx index c9020ba8b33..716469ce484 100644 --- a/Modules/Filtering/ImageSources/test/itkGaborImageSourceTest.cxx +++ b/Modules/Filtering/ImageSources/test/itkGaborImageSourceTest.cxx @@ -53,11 +53,11 @@ itkGaborImageSourceTestHelper(char * outputFilename, bool calculcateImaginaryPar gaborImage->SetSigma(sigma); ITK_TEST_SET_GET_VALUE(sigma, gaborImage->GetSigma()); - typename GaborSourceType::ArrayType mean(0.1); + const typename GaborSourceType::ArrayType mean(0.1); gaborImage->SetMean(mean); ITK_TEST_SET_GET_VALUE(mean, gaborImage->GetMean()); - double frequency = 0.1; + const double frequency = 0.1; gaborImage->SetFrequency(frequency); ITK_TEST_SET_GET_VALUE(frequency, gaborImage->GetFrequency()); diff --git a/Modules/Filtering/ImageSources/test/itkGaborKernelFunctionTest.cxx b/Modules/Filtering/ImageSources/test/itkGaborKernelFunctionTest.cxx index 34e5b16dabe..c582d9c7eb2 100644 --- a/Modules/Filtering/ImageSources/test/itkGaborKernelFunctionTest.cxx +++ b/Modules/Filtering/ImageSources/test/itkGaborKernelFunctionTest.cxx @@ -28,29 +28,29 @@ itkGaborKernelFunctionTest(int itkNotUsed(argc), char * itkNotUsed(argv)[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(gabor, GaborKernelFunction, KernelFunctionBase); - double sigma = 1.5; + const double sigma = 1.5; gabor->SetSigma(sigma); ITK_TEST_SET_GET_VALUE(sigma, gabor->GetSigma()); - double frequency = 2.; + const double frequency = 2.; gabor->SetFrequency(frequency); ITK_TEST_SET_GET_VALUE(frequency, gabor->GetFrequency()); - double phaseOffset = 0.8; + const double phaseOffset = 0.8; gabor->SetPhaseOffset(phaseOffset); ITK_TEST_SET_GET_VALUE(phaseOffset, gabor->GetPhaseOffset()); - bool calculateImaginaryPart = true; + const bool calculateImaginaryPart = true; gabor->SetCalculateImaginaryPart(calculateImaginaryPart); ITK_TEST_SET_GET_VALUE(calculateImaginaryPart, gabor->GetCalculateImaginaryPart()); gabor->CalculateImaginaryPartOn(); ITK_TEST_SET_GET_VALUE(true, gabor->GetCalculateImaginaryPart()); - double tolerance = 1e-12; - double point = 2.86; - double expectedValue = -0.13297125073713259; - double result = gabor->Evaluate(point); + const double tolerance = 1e-12; + const double point = 2.86; + double expectedValue = -0.13297125073713259; + double result = gabor->Evaluate(point); if (!itk::Math::FloatAlmostEqual(expectedValue, result, 10, tolerance)) { std::cerr.precision(static_cast(itk::Math::abs(std::log10(tolerance)))); diff --git a/Modules/Filtering/ImageSources/test/itkGaussianImageSourceTest.cxx b/Modules/Filtering/ImageSources/test/itkGaussianImageSourceTest.cxx index f3ab853f918..37da1443f92 100644 --- a/Modules/Filtering/ImageSources/test/itkGaussianImageSourceTest.cxx +++ b/Modules/Filtering/ImageSources/test/itkGaussianImageSourceTest.cxx @@ -78,11 +78,11 @@ itkGaussianImageSourceTest(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(direction, gaussianImage->GetDirection()); // Test SetReferenceImage from GenerateImageSource base class. - auto referenceImage = ImageType::New(); - ImageType::IndexType startIndex{}; - ImageType::SizeType referenceSize; + auto referenceImage = ImageType::New(); + const ImageType::IndexType startIndex{}; + ImageType::SizeType referenceSize; referenceSize.SetSize(size); - ImageType::RegionType region(startIndex, referenceSize); + const ImageType::RegionType region(startIndex, referenceSize); referenceImage->SetRegions(region); referenceImage->Allocate(); referenceImage->FillBuffer(0); @@ -91,14 +91,14 @@ itkGaussianImageSourceTest(int argc, char * argv[]) referenceImage->SetSpacing(spacing); referenceImage->SetDirection(direction); gaussianImage->SetReferenceImage(referenceImage); - bool useReferenceImage = true; + const bool useReferenceImage = true; ITK_TEST_SET_GET_BOOLEAN(gaussianImage, UseReferenceImage, useReferenceImage); gaussianImage->SetReferenceImage(referenceImage); ITK_TEST_SET_GET_VALUE(referenceImage, gaussianImage->GetReferenceImage()); gaussianImage->SetOutputParametersFromImage(referenceImage); - bool normalized = std::stoi(argv[2]) != 0; + const bool normalized = std::stoi(argv[2]) != 0; ITK_TEST_SET_GET_BOOLEAN(gaussianImage, Normalized, normalized); gaussianImage->SetMean(mean); @@ -173,14 +173,14 @@ itkGaussianImageSourceTest(int argc, char * argv[]) } - itk::SimpleFilterWatcher watcher(gaussianImage, "GaussianImageSource"); + const itk::SimpleFilterWatcher watcher(gaussianImage, "GaussianImageSource"); // Run the pipeline ITK_TRY_EXPECT_NO_EXCEPTION(gaussianImage->Update()); // Get the output of the image source - ImageType::Pointer outputImage = gaussianImage->GetOutput(); + const ImageType::Pointer outputImage = gaussianImage->GetOutput(); // Write the result image using WriterType = itk::ImageFileWriter; diff --git a/Modules/Filtering/ImageSources/test/itkGridImageSourceTest.cxx b/Modules/Filtering/ImageSources/test/itkGridImageSourceTest.cxx index c4a91831068..86b245ca4a8 100644 --- a/Modules/Filtering/ImageSources/test/itkGridImageSourceTest.cxx +++ b/Modules/Filtering/ImageSources/test/itkGridImageSourceTest.cxx @@ -58,7 +58,7 @@ itkGridImageSourceTest(int argc, char * argv[]) auto size = static_cast(std::stod(argv[2])); auto imageSize = ImageType::SizeType::Filled(size); - ImageType::PointType origin{}; + const ImageType::PointType origin{}; auto imageSpacing = itk::MakeFilled(1.0); @@ -72,7 +72,7 @@ itkGridImageSourceTest(int argc, char * argv[]) // Specify grid parameters - double scale = 255.0; + const double scale = 255.0; gridImage->SetScale(scale); ITK_TEST_SET_GET_VALUE(scale, gridImage->GetScale()); @@ -118,7 +118,7 @@ itkGridImageSourceTest(int argc, char * argv[]) auto gridAllDimensions = static_cast(std::stoi(argv[8])); auto whichDimension = itk::MakeFilled(gridAllDimensions); - bool toggleLastGridDimension = std::stod(argv[9]); + const bool toggleLastGridDimension = std::stod(argv[9]); if (toggleLastGridDimension) { whichDimension[ImageDimension - 1] = !gridAllDimensions; @@ -130,7 +130,7 @@ itkGridImageSourceTest(int argc, char * argv[]) auto useBSplineKernel = static_cast(std::stoi(argv[10])); if (useBSplineKernel) { - unsigned int bSplineOrder = std::stoi(argv[11]); + const unsigned int bSplineOrder = std::stoi(argv[11]); // Specify B-Spline function if (bSplineOrder == 3) { @@ -147,7 +147,7 @@ itkGridImageSourceTest(int argc, char * argv[]) } - itk::SimpleFilterWatcher watcher(gridImage, "GridImageSource"); + const itk::SimpleFilterWatcher watcher(gridImage, "GridImageSource"); ITK_TRY_EXPECT_NO_EXCEPTION(gridImage->Update()); diff --git a/Modules/Filtering/ImageStatistics/include/itkAccumulateImageFilter.hxx b/Modules/Filtering/ImageStatistics/include/itkAccumulateImageFilter.hxx index 9c7c4a47f53..eff98b2157f 100644 --- a/Modules/Filtering/ImageStatistics/include/itkAccumulateImageFilter.hxx +++ b/Modules/Filtering/ImageStatistics/include/itkAccumulateImageFilter.hxx @@ -47,8 +47,8 @@ AccumulateImageFilter::GenerateOutputInformation() typename TOutputImage::PointType outOrigin; // Get pointers to the input and output - typename Superclass::OutputImagePointer output = this->GetOutput(); - typename Superclass::InputImagePointer input = const_cast(this->GetInput()); + const typename Superclass::OutputImagePointer output = this->GetOutput(); + const typename Superclass::InputImagePointer input = const_cast(this->GetInput()); if (!input || !output) { @@ -124,7 +124,7 @@ AccumulateImageFilter::GenerateInputRequestedRegion() } const typename TInputImage::RegionType RequestedRegion(inputIndex, inputSize); - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); input->SetRequestedRegion(RequestedRegion); } @@ -144,8 +144,8 @@ AccumulateImageFilter::GenerateData() using OutputPixelType = typename TOutputImage::PixelType; using AccumulateType = typename NumericTraits::AccumulateType; - typename Superclass::InputImageConstPointer inputImage = this->GetInput(); - typename TOutputImage::Pointer outputImage = this->GetOutput(); + const typename Superclass::InputImageConstPointer inputImage = this->GetInput(); + const typename TOutputImage::Pointer outputImage = this->GetOutput(); outputImage->SetBufferedRegion(outputImage->GetRequestedRegion()); outputImage->Allocate(); @@ -158,9 +158,9 @@ AccumulateImageFilter::GenerateData() typename TInputImage::SizeType AccumulatedSize = inputImage->GetLargestPossibleRegion().GetSize(); typename TInputImage::IndexType AccumulatedIndex = inputImage->GetLargestPossibleRegion().GetIndex(); - typename TInputImage::SizeValueType SizeAccumulateDimension = AccumulatedSize[m_AccumulateDimension]; - const auto sizeAccumulateDimensionDouble = static_cast(SizeAccumulateDimension); - typename TInputImage::IndexValueType IndexAccumulateDimension = AccumulatedIndex[m_AccumulateDimension]; + const typename TInputImage::SizeValueType SizeAccumulateDimension = AccumulatedSize[m_AccumulateDimension]; + const auto sizeAccumulateDimensionDouble = static_cast(SizeAccumulateDimension); + const typename TInputImage::IndexValueType IndexAccumulateDimension = AccumulatedIndex[m_AccumulateDimension]; for (unsigned int i = 0; i < InputImageDimension; ++i) { if (i != m_AccumulateDimension) diff --git a/Modules/Filtering/ImageStatistics/include/itkImageMomentsCalculator.hxx b/Modules/Filtering/ImageStatistics/include/itkImageMomentsCalculator.hxx index 46bacc6b2e0..0a44ece3a96 100644 --- a/Modules/Filtering/ImageStatistics/include/itkImageMomentsCalculator.hxx +++ b/Modules/Filtering/ImageStatistics/include/itkImageMomentsCalculator.hxx @@ -82,7 +82,7 @@ ImageMomentsCalculator::Compute() while (!it.IsAtEnd()) { - double value = it.Value(); + const double value = it.Value(); IndexType indexPosition = it.GetIndex(); @@ -98,7 +98,7 @@ ImageMomentsCalculator::Compute() m_M1[i] += static_cast(indexPosition[i]) * value; for (unsigned int j = 0; j < ImageDimension; ++j) { - double weight = value * static_cast(indexPosition[i]) * static_cast(indexPosition[j]); + const double weight = value * static_cast(indexPosition[i]) * static_cast(indexPosition[j]); m_M2[i][j] += weight; } } @@ -108,7 +108,7 @@ ImageMomentsCalculator::Compute() m_Cg[i] += physicalPosition[i] * value; for (unsigned int j = 0; j < ImageDimension; ++j) { - double weight = value * physicalPosition[i] * physicalPosition[j]; + const double weight = value * physicalPosition[i] * physicalPosition[j]; m_Cm[i][j] += weight; } } @@ -147,8 +147,8 @@ ImageMomentsCalculator::Compute() } // Compute principal moments and axes - vnl_symmetric_eigensystem eigen{ m_Cm.GetVnlMatrix().as_matrix() }; - vnl_diag_matrix pm{ eigen.D }; + const vnl_symmetric_eigensystem eigen{ m_Cm.GetVnlMatrix().as_matrix() }; + vnl_diag_matrix pm{ eigen.D }; for (unsigned int i = 0; i < ImageDimension; ++i) { m_Pm[i] = pm(i) * m_M0; @@ -157,7 +157,7 @@ ImageMomentsCalculator::Compute() // Add a final reflection if needed for a proper rotation, // by multiplying the last row by the determinant - vnl_real_eigensystem eigenrot{ m_Pa.GetVnlMatrix().as_matrix() }; + const vnl_real_eigensystem eigenrot{ m_Pa.GetVnlMatrix().as_matrix() }; vnl_diag_matrix> eigenval{ eigenrot.D }; std::complex det(1.0, 0.0); @@ -310,7 +310,7 @@ ImageMomentsCalculator::GetPhysicalAxesToPrincipalAxesTransform() const } } - AffineTransformPointer result = AffineTransformType::New(); + const AffineTransformPointer result = AffineTransformType::New(); result->SetMatrix(matrix); result->SetOffset(offset); diff --git a/Modules/Filtering/ImageStatistics/include/itkImagePCAShapeModelEstimator.hxx b/Modules/Filtering/ImageStatistics/include/itkImagePCAShapeModelEstimator.hxx index e01c596916d..f42170d4206 100644 --- a/Modules/Filtering/ImageStatistics/include/itkImagePCAShapeModelEstimator.hxx +++ b/Modules/Filtering/ImageStatistics/include/itkImagePCAShapeModelEstimator.hxx @@ -78,7 +78,7 @@ ImagePCAShapeModelEstimator::GenerateInputRequestedRe if (this->GetInput(0)) { // Set the requested region of the first input to largest possible region - InputImagePointer input = const_cast(this->GetInput(0)); + const InputImagePointer input = const_cast(this->GetInput(0)); input->SetRequestedRegionToLargestPossibleRegion(); // Set the requested region of the remaining input to the largest possible @@ -88,9 +88,9 @@ ImagePCAShapeModelEstimator::GenerateInputRequestedRe { if (this->GetInput(idx)) { - typename TInputImage::RegionType requestedRegion = this->GetInput(0)->GetLargestPossibleRegion(); + const typename TInputImage::RegionType requestedRegion = this->GetInput(0)->GetLargestPossibleRegion(); - typename TInputImage::RegionType largestRegion = this->GetInput(idx)->GetLargestPossibleRegion(); + const typename TInputImage::RegionType largestRegion = this->GetInput(idx)->GetLargestPossibleRegion(); if (!largestRegion.IsInside(requestedRegion)) { @@ -98,7 +98,7 @@ ImagePCAShapeModelEstimator::GenerateInputRequestedRe << idx << " is not a superset of the LargestPossibleRegion of input 0"); } - InputImagePointer ptr = const_cast(this->GetInput(idx)); + const InputImagePointer ptr = const_cast(this->GetInput(idx)); ptr->SetRequestedRegion(requestedRegion); } } @@ -114,11 +114,11 @@ ImagePCAShapeModelEstimator::GenerateData() // Allocate memory for each output. auto numberOfOutputs = static_cast(this->GetNumberOfIndexedOutputs()); - InputImagePointer input = const_cast(this->GetInput(0)); - unsigned int j; + const InputImagePointer input = const_cast(this->GetInput(0)); + unsigned int j; for (j = 0; j < numberOfOutputs; ++j) { - OutputImagePointer output = this->GetOutput(j); + const OutputImagePointer output = this->GetOutput(j); output->SetBufferedRegion(output->GetRequestedRegion()); output->Allocate(); } @@ -141,8 +141,8 @@ ImagePCAShapeModelEstimator::GenerateData() } // Now fill the principal component outputs - unsigned int kthLargestPrincipalComp = m_NumberOfTrainingImages; - unsigned int numberOfValidOutputs = std::min(numberOfOutputs, m_NumberOfTrainingImages + 1); + unsigned int kthLargestPrincipalComp = m_NumberOfTrainingImages; + const unsigned int numberOfValidOutputs = std::min(numberOfOutputs, m_NumberOfTrainingImages + 1); for (j = 1; j < numberOfValidOutputs; ++j) { @@ -207,7 +207,7 @@ ImagePCAShapeModelEstimator::SetNumberOfPrincipalComp // Make and add extra outputs for (idx = numberOfOutputs; idx <= m_NumberOfPrincipalComponentsRequired; ++idx) { - typename DataObject::Pointer output = this->MakeOutput(idx); + const typename DataObject::Pointer output = this->MakeOutput(idx); this->SetNthOutput(idx, output.GetPointer()); } } @@ -261,11 +261,11 @@ ImagePCAShapeModelEstimator::CalculateInnerProduct() for (unsigned int i = 0; i < m_NumberOfTrainingImages; ++i) { - InputImageConstPointer inputImagePtr = dynamic_cast(ProcessObject::GetInput(i)); + const InputImageConstPointer inputImagePtr = dynamic_cast(ProcessObject::GetInput(i)); inputImagePointerArray[i] = inputImagePtr; - InputImageConstIterator inputImageIt(inputImagePtr, inputImagePtr->GetBufferedRegion()); + const InputImageConstIterator inputImageIt(inputImagePtr, inputImagePtr->GetBufferedRegion()); m_InputImageIteratorArray[i] = inputImageIt; @@ -355,7 +355,7 @@ ImagePCAShapeModelEstimator::EstimatePCAShapeModelPar identityMatrix.set_identity(); - vnl_generalized_eigensystem eigenVectors_eigenValues(m_InnerProduct, identityMatrix); + const vnl_generalized_eigensystem eigenVectors_eigenValues(m_InnerProduct, identityMatrix); MatrixOfDoubleType eigenVectorsOfInnerProductMatrix = eigenVectors_eigenValues.V; diff --git a/Modules/Filtering/ImageStatistics/include/itkLabelOverlapMeasuresImageFilter.hxx b/Modules/Filtering/ImageStatistics/include/itkLabelOverlapMeasuresImageFilter.hxx index 122efa2a504..ddf3f4ef321 100644 --- a/Modules/Filtering/ImageStatistics/include/itkLabelOverlapMeasuresImageFilter.hxx +++ b/Modules/Filtering/ImageStatistics/include/itkLabelOverlapMeasuresImageFilter.hxx @@ -88,8 +88,8 @@ LabelOverlapMeasuresImageFilter::ThreadedStreamedGenerateData(const for (itS.GoToBegin(), itT.GoToBegin(); !itS.IsAtEnd(); ++itS, ++itT) { - LabelType sourceLabel = itS.Get(); - LabelType targetLabel = itT.Get(); + const LabelType sourceLabel = itS.Get(); + const LabelType targetLabel = itT.Get(); // Initialized to empty if key does not already exist auto & sValue = localStatistics[sourceLabel]; @@ -246,7 +246,7 @@ template auto LabelOverlapMeasuresImageFilter::GetMeanOverlap() const -> RealType { - RealType uo = this->GetUnionOverlap(); + const RealType uo = this->GetUnionOverlap(); return (2.0 * uo / (1.0 + uo)); } @@ -254,7 +254,7 @@ template auto LabelOverlapMeasuresImageFilter::GetMeanOverlap(LabelType label) const -> RealType { - RealType uo = this->GetUnionOverlap(label); + const RealType uo = this->GetUnionOverlap(label); return (2.0 * uo / (1.0 + uo)); } @@ -295,9 +295,9 @@ LabelOverlapMeasuresImageFilter::GetVolumeSimilarity(LabelType labe itkWarningMacro("Label " << static_cast(label) << " not found."); return 0.0; } - RealType value = 2.0 * - (static_cast(mapIt->second.m_Source) - static_cast(mapIt->second.m_Target)) / - (static_cast(mapIt->second.m_Source) + static_cast(mapIt->second.m_Target)); + const RealType value = + 2.0 * (static_cast(mapIt->second.m_Source) - static_cast(mapIt->second.m_Target)) / + (static_cast(mapIt->second.m_Source) + static_cast(mapIt->second.m_Target)); return value; } diff --git a/Modules/Filtering/ImageStatistics/include/itkLabelStatisticsImageFilter.hxx b/Modules/Filtering/ImageStatistics/include/itkLabelStatisticsImageFilter.hxx index 9be87f673b5..e9a4a80f00a 100644 --- a/Modules/Filtering/ImageStatistics/include/itkLabelStatisticsImageFilter.hxx +++ b/Modules/Filtering/ImageStatistics/include/itkLabelStatisticsImageFilter.hxx @@ -271,7 +271,7 @@ template auto LabelStatisticsImageFilter::GetMinimum(LabelPixelType label) const -> RealType { - MapConstIterator mapIt = m_LabelStatistics.find(label); + const MapConstIterator mapIt = m_LabelStatistics.find(label); if (mapIt == m_LabelStatistics.end()) { // label does not exist, return a default value @@ -287,7 +287,7 @@ template auto LabelStatisticsImageFilter::GetMaximum(LabelPixelType label) const -> RealType { - MapConstIterator mapIt = m_LabelStatistics.find(label); + const MapConstIterator mapIt = m_LabelStatistics.find(label); if (mapIt == m_LabelStatistics.end()) { // label does not exist, return a default value @@ -303,7 +303,7 @@ template auto LabelStatisticsImageFilter::GetMean(LabelPixelType label) const -> RealType { - MapConstIterator mapIt = m_LabelStatistics.find(label); + const MapConstIterator mapIt = m_LabelStatistics.find(label); if (mapIt == m_LabelStatistics.end()) { // label does not exist, return a default value @@ -319,7 +319,7 @@ template auto LabelStatisticsImageFilter::GetSum(LabelPixelType label) const -> RealType { - MapConstIterator mapIt = m_LabelStatistics.find(label); + const MapConstIterator mapIt = m_LabelStatistics.find(label); if (mapIt == m_LabelStatistics.end()) { // label does not exist, return a default value @@ -335,7 +335,7 @@ template auto LabelStatisticsImageFilter::GetSigma(LabelPixelType label) const -> RealType { - MapConstIterator mapIt = m_LabelStatistics.find(label); + const MapConstIterator mapIt = m_LabelStatistics.find(label); if (mapIt == m_LabelStatistics.end()) { // label does not exist, return a default value @@ -351,7 +351,7 @@ template auto LabelStatisticsImageFilter::GetVariance(LabelPixelType label) const -> RealType { - MapConstIterator mapIt = m_LabelStatistics.find(label); + const MapConstIterator mapIt = m_LabelStatistics.find(label); if (mapIt == m_LabelStatistics.end()) { // label does not exist, return a default value @@ -367,7 +367,7 @@ template auto LabelStatisticsImageFilter::GetBoundingBox(LabelPixelType label) const -> BoundingBoxType { - MapConstIterator mapIt = m_LabelStatistics.find(label); + const MapConstIterator mapIt = m_LabelStatistics.find(label); if (mapIt == m_LabelStatistics.end()) { BoundingBoxType emptyBox; @@ -384,11 +384,11 @@ template auto LabelStatisticsImageFilter::GetRegion(LabelPixelType label) const -> RegionType { - MapConstIterator mapIt = m_LabelStatistics.find(label); + const MapConstIterator mapIt = m_LabelStatistics.find(label); if (mapIt == m_LabelStatistics.end()) { - RegionType emptyRegion; + const RegionType emptyRegion; // label does not exist, return a default value return emptyRegion; } @@ -413,7 +413,7 @@ template auto LabelStatisticsImageFilter::GetCount(LabelPixelType label) const -> MapSizeType { - MapConstIterator mapIt = m_LabelStatistics.find(label); + const MapConstIterator mapIt = m_LabelStatistics.find(label); if (mapIt == m_LabelStatistics.end()) { // label does not exist, return a default value @@ -429,8 +429,8 @@ template auto LabelStatisticsImageFilter::GetMedian(LabelPixelType label) const -> RealType { - RealType median = 0.0; - MapConstIterator mapIt = m_LabelStatistics.find(label); + RealType median = 0.0; + const MapConstIterator mapIt = m_LabelStatistics.find(label); if (mapIt == m_LabelStatistics.end() || !m_UseHistograms) { // label does not exist OR histograms not enabled, return the default value @@ -455,8 +455,8 @@ LabelStatisticsImageFilter::GetMedian(LabelPixelType l index[0] = bin; // return center of bin range - RealType lowRange = mapIt->second.m_Histogram->GetBinMin(0, bin); - RealType highRange = mapIt->second.m_Histogram->GetBinMax(0, bin); + const RealType lowRange = mapIt->second.m_Histogram->GetBinMin(0, bin); + const RealType highRange = mapIt->second.m_Histogram->GetBinMax(0, bin); median = lowRange + (highRange - lowRange) / 2; return median; } @@ -466,7 +466,7 @@ template auto LabelStatisticsImageFilter::GetHistogram(LabelPixelType label) const -> HistogramPointer { - MapConstIterator mapIt = m_LabelStatistics.find(label); + const MapConstIterator mapIt = m_LabelStatistics.find(label); if (mapIt == m_LabelStatistics.end()) { // label does not exist, return a default value diff --git a/Modules/Filtering/ImageStatistics/include/itkProjectionImageFilter.hxx b/Modules/Filtering/ImageStatistics/include/itkProjectionImageFilter.hxx index 3667a654f55..3ecfb0eb0cd 100644 --- a/Modules/Filtering/ImageStatistics/include/itkProjectionImageFilter.hxx +++ b/Modules/Filtering/ImageStatistics/include/itkProjectionImageFilter.hxx @@ -57,8 +57,8 @@ ProjectionImageFilter::GenerateOutputIn typename TOutputImage::DirectionType outDirection; // Get pointers to the input and output - typename Superclass::OutputImagePointer output = this->GetOutput(); - typename Superclass::InputImagePointer input = const_cast(this->GetInput()); + const typename Superclass::OutputImagePointer output = this->GetOutput(); + const typename Superclass::InputImagePointer input = const_cast(this->GetInput()); inputIndex = input->GetLargestPossibleRegion().GetIndex(); inputSize = input->GetLargestPossibleRegion().GetSize(); @@ -187,7 +187,7 @@ ProjectionImageFilter::GenerateInputReq } const typename TInputImage::RegionType RequestedRegion(inputIndex, inputSize); - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); input->SetRequestedRegion(RequestedRegion); } @@ -211,14 +211,14 @@ ProjectionImageFilter::DynamicThreadedG using OutputPixelType = typename TOutputImage::PixelType; // get some values, just to be easier to manipulate - typename Superclass::InputImageConstPointer inputImage = this->GetInput(); + const typename Superclass::InputImageConstPointer inputImage = this->GetInput(); - typename TInputImage::RegionType inputRegion = inputImage->GetLargestPossibleRegion(); + const typename TInputImage::RegionType inputRegion = inputImage->GetLargestPossibleRegion(); typename TInputImage::SizeType inputSize = inputRegion.GetSize(); typename TInputImage::IndexType inputIndex = inputRegion.GetIndex(); - typename TOutputImage::Pointer outputImage = this->GetOutput(); + const typename TOutputImage::Pointer outputImage = this->GetOutput(); typename TOutputImage::SizeType outputSizeForThread = outputRegionForThread.GetSize(); typename TOutputImage::IndexType outputIndexForThread = outputRegionForThread.GetIndex(); @@ -262,7 +262,7 @@ ProjectionImageFilter::DynamicThreadedG inputRegionForThread.SetSize(inputSizeForThread); inputRegionForThread.SetIndex(inputIndexForThread); - SizeValueType projectionSize = inputSize[m_ProjectionDimension]; + const SizeValueType projectionSize = inputSize[m_ProjectionDimension]; // create the iterators for input and output image using InputIteratorType = ImageLinearConstIteratorWithIndex; diff --git a/Modules/Filtering/ImageStatistics/include/itkStandardDeviationProjectionImageFilter.h b/Modules/Filtering/ImageStatistics/include/itkStandardDeviationProjectionImageFilter.h index 4e99f957e3f..b0dd43f2fec 100644 --- a/Modules/Filtering/ImageStatistics/include/itkStandardDeviationProjectionImageFilter.h +++ b/Modules/Filtering/ImageStatistics/include/itkStandardDeviationProjectionImageFilter.h @@ -83,9 +83,9 @@ class StandardDeviationAccumulator return RealType{}; } - typename NumericTraits::RealType mean = ((RealType)m_Sum) / m_Size; - typename std::vector::iterator it; - RealType squaredSum{}; + const typename NumericTraits::RealType mean = ((RealType)m_Sum) / m_Size; + typename std::vector::iterator it; + RealType squaredSum{}; for (it = m_Values.begin(); it != m_Values.end(); ++it) { squaredSum += itk::Math::sqr(*it - mean); diff --git a/Modules/Filtering/ImageStatistics/test/itkAdaptiveHistogramEqualizationImageFilterTest.cxx b/Modules/Filtering/ImageStatistics/test/itkAdaptiveHistogramEqualizationImageFilterTest.cxx index 9f213501a9f..f1811dd66d4 100644 --- a/Modules/Filtering/ImageStatistics/test/itkAdaptiveHistogramEqualizationImageFilterTest.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkAdaptiveHistogramEqualizationImageFilterTest.cxx @@ -52,16 +52,16 @@ itkAdaptiveHistogramEqualizationImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, AdaptiveHistogramEqualizationImageFilter, MovingHistogramImageFilter); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); filter->SetInput(reader->GetOutput()); filter->SetRadius(radius); - float alpha = std::stod(argv[4]); + const float alpha = std::stod(argv[4]); filter->SetAlpha(alpha); ITK_TEST_SET_GET_VALUE(alpha, filter->GetAlpha()); - float beta = std::stod(argv[5]); + const float beta = std::stod(argv[5]); filter->SetBeta(beta); ITK_TEST_SET_GET_VALUE(beta, filter->GetBeta()); diff --git a/Modules/Filtering/ImageStatistics/test/itkBinaryProjectionImageFilterTest.cxx b/Modules/Filtering/ImageStatistics/test/itkBinaryProjectionImageFilterTest.cxx index c4cb421b9b8..cc436f971ae 100644 --- a/Modules/Filtering/ImageStatistics/test/itkBinaryProjectionImageFilterTest.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkBinaryProjectionImageFilterTest.cxx @@ -86,7 +86,7 @@ itkBinaryProjectionImageFilterTest(int argc, char * argv[]) filter->SetBackgroundValue(std::stoi(argv[4])); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageStatistics/test/itkHistogramToEntropyImageFilterTest1.cxx b/Modules/Filtering/ImageStatistics/test/itkHistogramToEntropyImageFilterTest1.cxx index 8179075d360..260e05c16f7 100644 --- a/Modules/Filtering/ImageStatistics/test/itkHistogramToEntropyImageFilterTest1.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkHistogramToEntropyImageFilterTest1.cxx @@ -47,7 +47,7 @@ itkHistogramToEntropyImageFilterTest1(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); - itk::MinimumMaximumImageFilter::Pointer minmaxFilter = + const itk::MinimumMaximumImageFilter::Pointer minmaxFilter = itk::MinimumMaximumImageFilter::New(); minmaxFilter->SetInput(reader->GetOutput()); minmaxFilter->Update(); diff --git a/Modules/Filtering/ImageStatistics/test/itkHistogramToEntropyImageFilterTest2.cxx b/Modules/Filtering/ImageStatistics/test/itkHistogramToEntropyImageFilterTest2.cxx index 1a45e330684..a2c6a457277 100644 --- a/Modules/Filtering/ImageStatistics/test/itkHistogramToEntropyImageFilterTest2.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkHistogramToEntropyImageFilterTest2.cxx @@ -68,7 +68,7 @@ itkHistogramToEntropyImageFilterTest2(int argc, char * argv[]) constexpr unsigned int NumberOfComponents = 2; - itk::MinimumMaximumImageFilter::Pointer minmaxFilter = + const itk::MinimumMaximumImageFilter::Pointer minmaxFilter = itk::MinimumMaximumImageFilter::New(); HistogramMeasurementVectorType imageMin(NumberOfComponents); diff --git a/Modules/Filtering/ImageStatistics/test/itkHistogramToIntensityImageFilterTest1.cxx b/Modules/Filtering/ImageStatistics/test/itkHistogramToIntensityImageFilterTest1.cxx index 5670a50ac45..5297402788f 100644 --- a/Modules/Filtering/ImageStatistics/test/itkHistogramToIntensityImageFilterTest1.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkHistogramToIntensityImageFilterTest1.cxx @@ -47,7 +47,7 @@ itkHistogramToIntensityImageFilterTest1(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); - itk::MinimumMaximumImageFilter::Pointer minmaxFilter = + const itk::MinimumMaximumImageFilter::Pointer minmaxFilter = itk::MinimumMaximumImageFilter::New(); minmaxFilter->SetInput(reader->GetOutput()); diff --git a/Modules/Filtering/ImageStatistics/test/itkHistogramToIntensityImageFilterTest2.cxx b/Modules/Filtering/ImageStatistics/test/itkHistogramToIntensityImageFilterTest2.cxx index bade2ff7f92..a79013a37bc 100644 --- a/Modules/Filtering/ImageStatistics/test/itkHistogramToIntensityImageFilterTest2.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkHistogramToIntensityImageFilterTest2.cxx @@ -68,7 +68,7 @@ itkHistogramToIntensityImageFilterTest2(int argc, char * argv[]) constexpr unsigned int NumberOfComponents = 2; - itk::MinimumMaximumImageFilter::Pointer minmaxFilter = + const itk::MinimumMaximumImageFilter::Pointer minmaxFilter = itk::MinimumMaximumImageFilter::New(); HistogramMeasurementVectorType imageMin(NumberOfComponents); diff --git a/Modules/Filtering/ImageStatistics/test/itkHistogramToLogProbabilityImageFilterTest1.cxx b/Modules/Filtering/ImageStatistics/test/itkHistogramToLogProbabilityImageFilterTest1.cxx index 56fa2fad98f..56b068d38fe 100644 --- a/Modules/Filtering/ImageStatistics/test/itkHistogramToLogProbabilityImageFilterTest1.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkHistogramToLogProbabilityImageFilterTest1.cxx @@ -47,7 +47,7 @@ itkHistogramToLogProbabilityImageFilterTest1(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); - itk::MinimumMaximumImageFilter::Pointer minmaxFilter = + const itk::MinimumMaximumImageFilter::Pointer minmaxFilter = itk::MinimumMaximumImageFilter::New(); minmaxFilter->SetInput(reader->GetOutput()); diff --git a/Modules/Filtering/ImageStatistics/test/itkHistogramToLogProbabilityImageFilterTest2.cxx b/Modules/Filtering/ImageStatistics/test/itkHistogramToLogProbabilityImageFilterTest2.cxx index bdfcc1ad55a..3506e7fd2c3 100644 --- a/Modules/Filtering/ImageStatistics/test/itkHistogramToLogProbabilityImageFilterTest2.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkHistogramToLogProbabilityImageFilterTest2.cxx @@ -68,7 +68,7 @@ itkHistogramToLogProbabilityImageFilterTest2(int argc, char * argv[]) constexpr unsigned int NumberOfComponents = 2; - itk::MinimumMaximumImageFilter::Pointer minmaxFilter = + const itk::MinimumMaximumImageFilter::Pointer minmaxFilter = itk::MinimumMaximumImageFilter::New(); HistogramMeasurementVectorType imageMin(NumberOfComponents); diff --git a/Modules/Filtering/ImageStatistics/test/itkHistogramToProbabilityImageFilterTest1.cxx b/Modules/Filtering/ImageStatistics/test/itkHistogramToProbabilityImageFilterTest1.cxx index 4492402e092..ddc2341c27b 100644 --- a/Modules/Filtering/ImageStatistics/test/itkHistogramToProbabilityImageFilterTest1.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkHistogramToProbabilityImageFilterTest1.cxx @@ -47,7 +47,7 @@ itkHistogramToProbabilityImageFilterTest1(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); - itk::MinimumMaximumImageFilter::Pointer minmaxFilter = + const itk::MinimumMaximumImageFilter::Pointer minmaxFilter = itk::MinimumMaximumImageFilter::New(); minmaxFilter->SetInput(reader->GetOutput()); minmaxFilter->Update(); diff --git a/Modules/Filtering/ImageStatistics/test/itkHistogramToProbabilityImageFilterTest2.cxx b/Modules/Filtering/ImageStatistics/test/itkHistogramToProbabilityImageFilterTest2.cxx index fe2025aeea5..a95402391b1 100644 --- a/Modules/Filtering/ImageStatistics/test/itkHistogramToProbabilityImageFilterTest2.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkHistogramToProbabilityImageFilterTest2.cxx @@ -76,7 +76,7 @@ itkHistogramToProbabilityImageFilterTest2(int argc, char * argv[]) constexpr unsigned int NumberOfComponents = 2; - itk::MinimumMaximumImageFilter::Pointer minmaxFilter = + const itk::MinimumMaximumImageFilter::Pointer minmaxFilter = itk::MinimumMaximumImageFilter::New(); HistogramMeasurementVectorType imageMin(NumberOfComponents); diff --git a/Modules/Filtering/ImageStatistics/test/itkImageMomentsTest.cxx b/Modules/Filtering/ImageStatistics/test/itkImageMomentsTest.cxx index a727bb893dc..3a11ca080c1 100644 --- a/Modules/Filtering/ImageStatistics/test/itkImageMomentsTest.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkImageMomentsTest.cxx @@ -53,20 +53,20 @@ itkImageMomentsTest(int argc, char * argv[]) constexpr double maxerr = 5.0e-15; /* Define the image size and physical coordinates */ - itk::Size<3> size = { { 20, 40, 80 } }; - double origin[3] = { 0.5, 0.5, 0.5 }; - double spacing[3] = { 0.1, 0.05, 0.025 }; + const itk::Size<3> size = { { 20, 40, 80 } }; + double origin[3] = { 0.5, 0.5, 0.5 }; + double spacing[3] = { 0.1, 0.05, 0.025 }; /* Define positions of the test masses in index coordinates */ - unsigned short mass = 1; // Test mass + const unsigned short mass = 1; // Test mass itk::Index<3>::IndexValueType point[8][3] = { { 10 + 8, 20 + 12, 40 + 0 }, { 10 - 8, 20 - 12, 40 - 0 }, { 10 + 3, 20 - 8, 40 + 0 }, { 10 - 3, 20 + 8, 40 - 0 }, { 10 + 0, 20 + 0, 40 + 10 }, { 10 - 0, 20 - 0, 40 - 10 }, }; /* Define the expected (true) results for comparison */ - double ttm = 6.0; // Total mass - double pad[3][3] = { + const double ttm = 6.0; // Total mass + double pad[3][3] = { // Principal axes { 0.0, 0.0, 1.0 }, { 0.6, -0.8, 0.0 }, @@ -131,7 +131,7 @@ itkImageMomentsTest(int argc, char * argv[]) mask->SetImage(maskimg.GetPointer()); mask->Update(); // Purposefully use the base class type - typename itk::SpatialObject::Pointer test = + const typename itk::SpatialObject::Pointer test = dynamic_cast *>(mask.GetPointer()); if (test.IsNull()) { @@ -144,10 +144,10 @@ itkImageMomentsTest(int argc, char * argv[]) /* Printout info */ moments->Print(std::cout); - double ctm = moments->GetTotalMass(); - VectorType ccg = moments->GetCenterOfGravity(); - VectorType cpm = moments->GetPrincipalMoments(); - MatrixType cpa = moments->GetPrincipalAxes(); + const double ctm = moments->GetTotalMass(); + VectorType ccg = moments->GetCenterOfGravity(); + VectorType cpm = moments->GetPrincipalMoments(); + MatrixType cpa = moments->GetPrincipalAxes(); /* Flip the principal axes if necessary. @@ -198,29 +198,29 @@ itkImageMomentsTest(int argc, char * argv[]) /* Compute transforms between principal and physical axes */ /* FIXME: Automatically check correctness of these results? */ - AffineTransformType::Pointer pa2p = moments->GetPrincipalAxesToPhysicalAxesTransform(); + const AffineTransformType::Pointer pa2p = moments->GetPrincipalAxesToPhysicalAxesTransform(); std::cout << "\nPrincipal axes to physical axes transform:\n"; std::cout << pa2p->GetMatrix() << std::endl; - AffineTransformType::Pointer p2pa = moments->GetPhysicalAxesToPrincipalAxesTransform(); + const AffineTransformType::Pointer p2pa = moments->GetPhysicalAxesToPrincipalAxesTransform(); std::cout << "\nPhysical axes to principal axes transform:\n"; std::cout << p2pa->GetMatrix() << std::endl; /* Do some error checking on the transforms */ - double dist = pa2p->Metric(pa2p); + const double dist = pa2p->Metric(pa2p); std::cout << "Distance from self to self = " << dist << std::endl; auto p2pa2p = AffineTransformType::New(); p2pa2p->Compose(p2pa); p2pa2p->Compose(pa2p); - double trerr = p2pa2p->Metric(); + const double trerr = p2pa2p->Metric(); std::cout << "Distance from composition to identity = "; std::cout << trerr << std::endl; /* Compute and report max abs error in computed */ - double tmerr = itk::Math::abs(ttm - ctm); // Error in total mass - double cgerr = 0.0; // Error in center of gravity - double pmerr = 0.0; // Error in moments - double paerr = 0.0; // Error in axes + const double tmerr = itk::Math::abs(ttm - ctm); // Error in total mass + double cgerr = 0.0; // Error in center of gravity + double pmerr = 0.0; // Error in moments + double paerr = 0.0; // Error in axes for (int i = 0; i < 3; ++i) { @@ -249,7 +249,7 @@ itkImageMomentsTest(int argc, char * argv[]) std::cout << " Transformations = " << trerr << std::endl; /* Return error if differences are too large */ - int stat = tmerr > maxerr || cgerr > maxerr || pmerr > maxerr || paerr > maxerr || trerr > maxerr; + const int stat = tmerr > maxerr || cgerr > maxerr || pmerr > maxerr || paerr > maxerr || trerr > maxerr; std::cout << std::endl; bool pass; diff --git a/Modules/Filtering/ImageStatistics/test/itkImagePCADecompositionCalculatorTest.cxx b/Modules/Filtering/ImageStatistics/test/itkImagePCADecompositionCalculatorTest.cxx index 8728e60ee15..763fae9aba6 100644 --- a/Modules/Filtering/ImageStatistics/test/itkImagePCADecompositionCalculatorTest.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkImagePCADecompositionCalculatorTest.cxx @@ -75,10 +75,10 @@ itkImagePCADecompositionCalculatorTest(int, char *[]) auto image8 = InputImageType::New(); - InputImageType::SizeType inputImageSize = { { IMGWIDTH, IMGHEIGHT } }; + const InputImageType::SizeType inputImageSize = { { IMGWIDTH, IMGHEIGHT } }; - InputImageType::IndexType index{}; - InputImageType::RegionType region; + const InputImageType::IndexType index{}; + InputImageType::RegionType region; region.SetSize(inputImageSize); region.SetIndex(index); @@ -322,11 +322,11 @@ itkImagePCADecompositionCalculatorTest(int, char *[]) decomposer->SetImage(image3); decomposer->Compute(); - ImagePCAShapeModelEstimatorType::BasisVectorType proj3_3 = decomposer->GetProjection(); + const ImagePCAShapeModelEstimatorType::BasisVectorType proj3_3 = decomposer->GetProjection(); decomposer->SetImage(image4); decomposer->Compute(); - ImagePCAShapeModelEstimatorType::BasisVectorType proj4_3 = decomposer->GetProjection(); + const ImagePCAShapeModelEstimatorType::BasisVectorType proj4_3 = decomposer->GetProjection(); // get the basis images diff --git a/Modules/Filtering/ImageStatistics/test/itkImagePCAShapeModelEstimatorTest.cxx b/Modules/Filtering/ImageStatistics/test/itkImagePCAShapeModelEstimatorTest.cxx index d798f2ec030..9fd0ff3357a 100644 --- a/Modules/Filtering/ImageStatistics/test/itkImagePCAShapeModelEstimatorTest.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkImagePCAShapeModelEstimatorTest.cxx @@ -67,10 +67,10 @@ itkImagePCAShapeModelEstimatorTest(int, char *[]) auto image3 = InputImageType::New(); - InputImageType::SizeType inputImageSize = { { IMGWIDTH, IMGHEIGHT } }; + const InputImageType::SizeType inputImageSize = { { IMGWIDTH, IMGHEIGHT } }; - InputImageType::IndexType index{}; - InputImageType::RegionType region; + const InputImageType::IndexType index{}; + InputImageType::RegionType region; region.SetSize(inputImageSize); region.SetIndex(index); @@ -159,7 +159,7 @@ itkImagePCAShapeModelEstimatorTest(int, char *[]) // Print the eigen vectors vnl_vector eigenValues = applyPCAShapeEstimator->GetEigenValues(); - unsigned int numEigVal = eigenValues.size(); + const unsigned int numEigVal = eigenValues.size(); std::cout << "Number of returned eign-values: " << numEigVal << std::endl; std::cout << "The " << applyPCAShapeEstimator->GetNumberOfPrincipalComponentsRequired() @@ -174,8 +174,8 @@ itkImagePCAShapeModelEstimatorTest(int, char *[]) // Print the MeanImage - OutputImageType::Pointer outImage = applyPCAShapeEstimator->GetOutput(0); - OutputImageIterator outImageIt(outImage, outImage->GetBufferedRegion()); + const OutputImageType::Pointer outImage = applyPCAShapeEstimator->GetOutput(0); + OutputImageIterator outImageIt(outImage, outImage->GetBufferedRegion()); outImageIt.GoToBegin(); std::cout << "The mean image is:" << std::endl; @@ -189,8 +189,8 @@ itkImagePCAShapeModelEstimatorTest(int, char *[]) // Print the largest two eigen vectors for (unsigned int j = 1; j < NUMLARGESTPC + 1; ++j) { - OutputImageType::Pointer outImage2 = applyPCAShapeEstimator->GetOutput(j); - OutputImageIterator outImage2It(outImage2, outImage2->GetBufferedRegion()); + const OutputImageType::Pointer outImage2 = applyPCAShapeEstimator->GetOutput(j); + OutputImageIterator outImage2It(outImage2, outImage2->GetBufferedRegion()); outImage2It.GoToBegin(); std::cout << "" << std::endl; diff --git a/Modules/Filtering/ImageStatistics/test/itkLabelOverlapMeasuresImageFilterGTest.cxx b/Modules/Filtering/ImageStatistics/test/itkLabelOverlapMeasuresImageFilterGTest.cxx index b36cb7c9c06..10baa495272 100644 --- a/Modules/Filtering/ImageStatistics/test/itkLabelOverlapMeasuresImageFilterGTest.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkLabelOverlapMeasuresImageFilterGTest.cxx @@ -49,8 +49,8 @@ class LabelOverlapMeasuresImageFilterFixture : public ::testing::Test { auto image = ImageType::New(); - auto imageSize = ImageType::SizeType::Filled(m_ImageSize); - typename ImageType::RegionType region(imageSize); + auto imageSize = ImageType::SizeType::Filled(m_ImageSize); + const typename ImageType::RegionType region(imageSize); image->SetRegions(region); image->Allocate(); image->FillBuffer(fillValue); diff --git a/Modules/Filtering/ImageStatistics/test/itkLabelOverlapMeasuresImageFilterTest.cxx b/Modules/Filtering/ImageStatistics/test/itkLabelOverlapMeasuresImageFilterTest.cxx index 6afc85d5d13..4a7c317d543 100644 --- a/Modules/Filtering/ImageStatistics/test/itkLabelOverlapMeasuresImageFilterTest.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkLabelOverlapMeasuresImageFilterTest.cxx @@ -94,8 +94,8 @@ LabelOverlapMeasures(int, char * argv[]) // Assume that no such label exists label = itk::NumericTraits::max(); - typename FilterType::RealType expectedValue = 0.0; - typename FilterType::RealType result = filter->GetTargetOverlap(label); + const typename FilterType::RealType expectedValue = 0.0; + typename FilterType::RealType result = filter->GetTargetOverlap(label); if (itk::Math::NotAlmostEquals(expectedValue, result)) { std::cout << "Error in label " << static_cast::PrintType>(label) << ": "; @@ -169,7 +169,7 @@ itkLabelOverlapMeasuresImageFilterTest(int argc, char * argv[]) using LabelOverlapMeasuresImageFilterType = itk::LabelOverlapMeasuresImageFilter; - LabelOverlapMeasuresImageFilterType::Pointer labelOverlapMeasuresImageFilter = + const LabelOverlapMeasuresImageFilterType::Pointer labelOverlapMeasuresImageFilter = LabelOverlapMeasuresImageFilterType::New(); // Exercise basic object methods diff --git a/Modules/Filtering/ImageStatistics/test/itkLabelStatisticsImageFilterTest.cxx b/Modules/Filtering/ImageStatistics/test/itkLabelStatisticsImageFilterTest.cxx index 2a0d8b9782d..13f0c8a6d7d 100644 --- a/Modules/Filtering/ImageStatistics/test/itkLabelStatisticsImageFilterTest.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkLabelStatisticsImageFilterTest.cxx @@ -63,7 +63,7 @@ itkLabelStatisticsImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, LabelStatisticsImageFilter, ImageSink); - itk::SimpleFilterWatcher filterWatch(filter); + const itk::SimpleFilterWatcher filterWatch(filter); auto useHistograms = static_cast(std::stoi(argv[3])); ITK_TEST_SET_GET_BOOLEAN(filter, UseHistograms, useHistograms); diff --git a/Modules/Filtering/ImageStatistics/test/itkMaximumProjectionImageFilterTest.cxx b/Modules/Filtering/ImageStatistics/test/itkMaximumProjectionImageFilterTest.cxx index ee5176e8b02..a4304c2d9ec 100644 --- a/Modules/Filtering/ImageStatistics/test/itkMaximumProjectionImageFilterTest.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkMaximumProjectionImageFilterTest.cxx @@ -47,7 +47,7 @@ itkMaximumProjectionImageFilterTest(int argc, char * argv[]) auto filter = FilterType::New(); filter->SetInput(reader->GetOutput()); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageStatistics/test/itkMaximumProjectionImageFilterTest2.cxx b/Modules/Filtering/ImageStatistics/test/itkMaximumProjectionImageFilterTest2.cxx index ef6dd530c10..b342e197b10 100644 --- a/Modules/Filtering/ImageStatistics/test/itkMaximumProjectionImageFilterTest2.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkMaximumProjectionImageFilterTest2.cxx @@ -36,7 +36,7 @@ itkMaximumProjectionImageFilterTest2(int argc, char * argv[]) // Legacy compat with older MetaImages itk::MetaImageIO::SetDefaultDoublePrecision(6); - int dim = std::stoi(argv[1]); + const int dim = std::stoi(argv[1]); using PixelType = unsigned char; @@ -54,7 +54,7 @@ itkMaximumProjectionImageFilterTest2(int argc, char * argv[]) // proc computer filter->SetNumberOfWorkUnits(2); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageStatistics/test/itkMaximumProjectionImageFilterTest3.cxx b/Modules/Filtering/ImageStatistics/test/itkMaximumProjectionImageFilterTest3.cxx index 0a4c39d88b6..9e8e0d6570a 100644 --- a/Modules/Filtering/ImageStatistics/test/itkMaximumProjectionImageFilterTest3.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkMaximumProjectionImageFilterTest3.cxx @@ -34,7 +34,7 @@ itkMaximumProjectionImageFilterTest3(int argc, char * argv[]) return EXIT_FAILURE; } - int dim = std::stoi(argv[1]); + const int dim = std::stoi(argv[1]); using PixelType = unsigned char; @@ -51,7 +51,7 @@ itkMaximumProjectionImageFilterTest3(int argc, char * argv[]) filter->SetInput(reader->GetOutput()); filter->SetProjectionDimension(dim); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageStatistics/test/itkMeanProjectionImageFilterTest.cxx b/Modules/Filtering/ImageStatistics/test/itkMeanProjectionImageFilterTest.cxx index 13b3a3eb4cd..7d46de91d52 100644 --- a/Modules/Filtering/ImageStatistics/test/itkMeanProjectionImageFilterTest.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkMeanProjectionImageFilterTest.cxx @@ -46,7 +46,7 @@ itkMeanProjectionImageFilterTest(int argc, char * argv[]) auto filter = FilterType::New(); filter->SetInput(reader->GetOutput()); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageStatistics/test/itkMedianProjectionImageFilterTest.cxx b/Modules/Filtering/ImageStatistics/test/itkMedianProjectionImageFilterTest.cxx index bbc772252c5..3c416d4e619 100644 --- a/Modules/Filtering/ImageStatistics/test/itkMedianProjectionImageFilterTest.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkMedianProjectionImageFilterTest.cxx @@ -47,7 +47,7 @@ itkMedianProjectionImageFilterTest(int argc, char * argv[]) auto filter = FilterType::New(); filter->SetInput(reader->GetOutput()); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageStatistics/test/itkMinimumMaximumImageFilterGTest.cxx b/Modules/Filtering/ImageStatistics/test/itkMinimumMaximumImageFilterGTest.cxx index 8bb97bc21dc..ffe76462c9b 100644 --- a/Modules/Filtering/ImageStatistics/test/itkMinimumMaximumImageFilterGTest.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkMinimumMaximumImageFilterGTest.cxx @@ -54,8 +54,8 @@ class MinimumMaximumFixture : public ::testing::Test auto image = ImageType::New(); - auto imageSize = ImageType::SizeType::Filled(m_ImageSize); - typename ImageType::RegionType region(imageSize); + auto imageSize = ImageType::SizeType::Filled(m_ImageSize); + const typename ImageType::RegionType region(imageSize); image->SetRegions(region); image->Allocate(); image->FillBuffer(1); diff --git a/Modules/Filtering/ImageStatistics/test/itkMinimumMaximumImageFilterTest.cxx b/Modules/Filtering/ImageStatistics/test/itkMinimumMaximumImageFilterTest.cxx index bff25484042..378a6fa5136 100644 --- a/Modules/Filtering/ImageStatistics/test/itkMinimumMaximumImageFilterTest.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkMinimumMaximumImageFilterTest.cxx @@ -37,9 +37,9 @@ itkMinimumMaximumImageFilterTest(int argc, char * argv[]) using MinMaxFilterType = itk::MinimumMaximumImageFilter; /* Define the image size and physical coordinates */ - SizeType size = { { 20, 20, 20 } }; - double origin[3] = { 0.0, 0.0, 0.0 }; - double spacing[3] = { 1, 1, 1 }; + const SizeType size = { { 20, 20, 20 } }; + double origin[3] = { 0.0, 0.0, 0.0 }; + double spacing[3] = { 1, 1, 1 }; int flag = 0; /* Did this test program work? */ @@ -56,8 +56,8 @@ itkMinimumMaximumImageFilterTest(int argc, char * argv[]) image->SetOrigin(origin); image->SetSpacing(spacing); - float minimum = -52; - float maximum = -10; + const float minimum = -52; + const float maximum = -10; // Initialize the image contents with the minimum value @@ -88,7 +88,7 @@ itkMinimumMaximumImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, MinimumMaximumImageFilter, ImageSink); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); const auto numberOfStreamDivisions = static_cast(std::stoi(argv[1])); filter->SetNumberOfStreamDivisions(numberOfStreamDivisions); @@ -98,7 +98,7 @@ itkMinimumMaximumImageFilterTest(int argc, char * argv[]) filter->Update(); // Return minimum of intensity - float minimumResult = filter->GetMinimum(); + const float minimumResult = filter->GetMinimum(); std::cout << "The Minimum intensity value is : " << minimumResult << std::endl; if (itk::Math::NotExactlyEquals(minimumResult, minimum)) @@ -109,7 +109,7 @@ itkMinimumMaximumImageFilterTest(int argc, char * argv[]) } // Return maximum of intensity - float maximumResult = filter->GetMaximum(); + const float maximumResult = filter->GetMaximum(); std::cout << "The Maximum intensity value is : " << maximumResult << std::endl; if (itk::Math::NotExactlyEquals(maximumResult, maximum)) diff --git a/Modules/Filtering/ImageStatistics/test/itkMinimumProjectionImageFilterTest.cxx b/Modules/Filtering/ImageStatistics/test/itkMinimumProjectionImageFilterTest.cxx index 99fe6c2d5ca..2d54af71df0 100644 --- a/Modules/Filtering/ImageStatistics/test/itkMinimumProjectionImageFilterTest.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkMinimumProjectionImageFilterTest.cxx @@ -46,7 +46,7 @@ itkMinimumProjectionImageFilterTest(int argc, char * argv[]) auto filter = FilterType::New(); filter->SetInput(reader->GetOutput()); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageStatistics/test/itkProjectionImageFilterTest.cxx b/Modules/Filtering/ImageStatistics/test/itkProjectionImageFilterTest.cxx index 94f602c9c4f..a0c81d7d0d1 100644 --- a/Modules/Filtering/ImageStatistics/test/itkProjectionImageFilterTest.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkProjectionImageFilterTest.cxx @@ -133,7 +133,7 @@ itkProjectionImageFilterTest(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(projectionDimension, filter->GetProjectionDimension()); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageStatistics/test/itkStandardDeviationProjectionImageFilterTest.cxx b/Modules/Filtering/ImageStatistics/test/itkStandardDeviationProjectionImageFilterTest.cxx index 12beb743f32..11767a8aab7 100644 --- a/Modules/Filtering/ImageStatistics/test/itkStandardDeviationProjectionImageFilterTest.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkStandardDeviationProjectionImageFilterTest.cxx @@ -47,7 +47,7 @@ itkStandardDeviationProjectionImageFilterTest(int argc, char * argv[]) auto filter = FilterType::New(); filter->SetInput(reader->GetOutput()); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/ImageStatistics/test/itkStatisticsImageFilterTest.cxx b/Modules/Filtering/ImageStatistics/test/itkStatisticsImageFilterTest.cxx index 0d4c6cb5237..bc2c30349be 100644 --- a/Modules/Filtering/ImageStatistics/test/itkStatisticsImageFilterTest.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkStatisticsImageFilterTest.cxx @@ -46,22 +46,22 @@ itkStatisticsImageFilterTest(int argc, char * argv[]) itk::Statistics::MersenneTwisterRandomVariateGenerator::GetInstance()->SetSeed(987); - auto image = FloatImage::New(); - FloatImage::RegionType region; - auto size = FloatImage::SizeType::Filled(64); - FloatImage::IndexType index{}; + auto image = FloatImage::New(); + FloatImage::RegionType region; + auto size = FloatImage::SizeType::Filled(64); + const FloatImage::IndexType index{}; region.SetIndex(index); region.SetSize(size); // first try a constant image - float fillValue = -100.0; + const float fillValue = -100.0; image->SetRegions(region); image->Allocate(); image->FillBuffer(static_cast(fillValue)); - float sum = fillValue * static_cast(region.GetNumberOfPixels()); - float sumOfSquares = std::pow(fillValue, 2.0) * static_cast(region.GetNumberOfPixels()); + const float sum = fillValue * static_cast(region.GetNumberOfPixels()); + const float sumOfSquares = std::pow(fillValue, 2.0) * static_cast(region.GetNumberOfPixels()); using FilterType = itk::StatisticsImageFilter; auto filter = FilterType::New(); @@ -69,7 +69,7 @@ itkStatisticsImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, StatisticsImageFilter, ImageSink); - itk::SimpleFilterWatcher filterWatch(filter); + const itk::SimpleFilterWatcher filterWatch(filter); filter->SetNumberOfStreamDivisions(numberOfStreamDivisions); ITK_TEST_SET_GET_VALUE(numberOfStreamDivisions, filter->GetNumberOfStreamDivisions()); @@ -120,8 +120,8 @@ itkStatisticsImageFilterTest(int argc, char * argv[]) FloatImage::SizeValueType randomSize[3] = { 17, 8, 241 }; source->SetSize(randomSize); - float minValue = -100.0; - float maxValue = 1000.0; + const float minValue = -100.0; + const float maxValue = 1000.0; source->SetMin(static_cast(minValue)); source->SetMax(static_cast(maxValue)); @@ -130,8 +130,8 @@ itkStatisticsImageFilterTest(int argc, char * argv[]) filter->SetNumberOfStreamDivisions(numberOfStreamDivisions); ITK_TRY_EXPECT_NO_EXCEPTION(filter->UpdateLargestPossibleRegion()); - double expectedSigma = std::sqrt((maxValue - minValue) * (maxValue - minValue) / 12.0); - double epsilon = (maxValue - minValue) * .001; + const double expectedSigma = std::sqrt((maxValue - minValue) * (maxValue - minValue) / 12.0); + const double epsilon = (maxValue - minValue) * .001; if (itk::Math::abs(filter->GetSigma() - expectedSigma) > epsilon) { @@ -139,10 +139,10 @@ itkStatisticsImageFilterTest(int argc, char * argv[]) } // Now generate an image with a known mean and variance - itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer rvgen = + const itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer rvgen = itk::Statistics::MersenneTwisterRandomVariateGenerator::GetInstance(); - double knownMean = 12.0; - double knownVariance = 10.0; + const double knownMean = 12.0; + const double knownVariance = 10.0; using DoubleImage = itk::Image; auto dImage = DoubleImage::New(); @@ -166,9 +166,9 @@ itkStatisticsImageFilterTest(int argc, char * argv[]) dfilter->SetInput(dImage); dfilter->SetNumberOfStreamDivisions(numberOfStreamDivisions); ITK_TRY_EXPECT_NO_EXCEPTION(dfilter->UpdateLargestPossibleRegion()); - double testMean = dfilter->GetMean(); - double testVariance = dfilter->GetVariance(); - double diff = itk::Math::abs(testMean - knownMean); + const double testMean = dfilter->GetMean(); + const double testVariance = dfilter->GetVariance(); + double diff = itk::Math::abs(testMean - knownMean); if ((diff != 0.0 && knownMean != 0.0) && diff / itk::Math::abs(knownMean) > .01) { std::cout << "Expected mean is " << knownMean << ", computed mean is " << testMean << std::endl; diff --git a/Modules/Filtering/ImageStatistics/test/itkSumProjectionImageFilterTest.cxx b/Modules/Filtering/ImageStatistics/test/itkSumProjectionImageFilterTest.cxx index 89aa2612d87..3ceb6b75017 100644 --- a/Modules/Filtering/ImageStatistics/test/itkSumProjectionImageFilterTest.cxx +++ b/Modules/Filtering/ImageStatistics/test/itkSumProjectionImageFilterTest.cxx @@ -49,7 +49,7 @@ itkSumProjectionImageFilterTest(int argc, char * argv[]) auto filter = FilterType::New(); filter->SetInput(reader->GetOutput()); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/LabelMap/include/itkAttributeKeepNObjectsLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkAttributeKeepNObjectsLabelMapFilter.hxx index 80d07e8fd9e..6a0bbfcf052 100644 --- a/Modules/Filtering/LabelMap/include/itkAttributeKeepNObjectsLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkAttributeKeepNObjectsLabelMapFilter.hxx @@ -66,12 +66,12 @@ AttributeKeepNObjectsLabelMapFilter::GenerateData() auto end = labelObjects.begin() + m_NumberOfObjects; if (m_ReverseOrdering) { - ReverseComparator comparator; + const ReverseComparator comparator; std::nth_element(labelObjects.begin(), end, labelObjects.end(), comparator); } else { - Comparator comparator; + const Comparator comparator; std::nth_element(labelObjects.begin(), end, labelObjects.end(), comparator); } // progress.CompletedPixel(); diff --git a/Modules/Filtering/LabelMap/include/itkAttributeOpeningLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkAttributeOpeningLabelMapFilter.hxx index 249d34f2945..a1ea7b09d69 100644 --- a/Modules/Filtering/LabelMap/include/itkAttributeOpeningLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkAttributeOpeningLabelMapFilter.hxx @@ -55,8 +55,8 @@ AttributeOpeningLabelMapFilter::GenerateData() typename ImageType::Iterator it(output); while (!it.IsAtEnd()) { - typename LabelObjectType::LabelType label = it.GetLabel(); - LabelObjectType * labelObject = it.GetLabelObject(); + const typename LabelObjectType::LabelType label = it.GetLabel(); + LabelObjectType * labelObject = it.GetLabelObject(); if ((!m_ReverseOrdering && accessor(labelObject) < m_Lambda) || (m_ReverseOrdering && accessor(labelObject) > m_Lambda)) diff --git a/Modules/Filtering/LabelMap/include/itkAttributeRelabelLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkAttributeRelabelLabelMapFilter.hxx index e6c1fd7d5b8..7f171d3f323 100644 --- a/Modules/Filtering/LabelMap/include/itkAttributeRelabelLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkAttributeRelabelLabelMapFilter.hxx @@ -56,12 +56,12 @@ AttributeRelabelLabelMapFilter::GenerateData() // instantiate the comparator and sort the vector if (m_ReverseOrdering) { - ReverseComparator comparator; + const ReverseComparator comparator; std::sort(labelObjects.begin(), labelObjects.end(), comparator); } else { - Comparator comparator; + const Comparator comparator; std::sort(labelObjects.begin(), labelObjects.end(), comparator); } // progress.CompletedPixel(); diff --git a/Modules/Filtering/LabelMap/include/itkAttributeSelectionLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkAttributeSelectionLabelMapFilter.hxx index a7eec26d527..2c1913c20b4 100644 --- a/Modules/Filtering/LabelMap/include/itkAttributeSelectionLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkAttributeSelectionLabelMapFilter.hxx @@ -54,9 +54,9 @@ AttributeSelectionLabelMapFilter::GenerateData() typename ImageType::Iterator it(output); while (!it.IsAtEnd()) { - typename LabelObjectType::LabelType label = it.GetLabel(); - LabelObjectType * labelObject = it.GetLabelObject(); - bool notInSet = m_AttributeSet.find(accessor(labelObject)) == m_AttributeSet.end(); + const typename LabelObjectType::LabelType label = it.GetLabel(); + LabelObjectType * labelObject = it.GetLabelObject(); + const bool notInSet = m_AttributeSet.find(accessor(labelObject)) == m_AttributeSet.end(); if (m_Exclude != notInSet) // no xor in c++, use != instead { // must increment the iterator before removing the object to avoid invalidating the iterator diff --git a/Modules/Filtering/LabelMap/include/itkAttributeUniqueLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkAttributeUniqueLabelMapFilter.hxx index 11545e267bf..27f795d524d 100644 --- a/Modules/Filtering/LabelMap/include/itkAttributeUniqueLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkAttributeUniqueLabelMapFilter.hxx @@ -86,7 +86,7 @@ AttributeUniqueLabelMapFilter::GenerateData() IndexType prevIdx = prev.line.GetIndex(); pq.pop(); - AttributeAccessorType accessor; + const AttributeAccessorType accessor; while (!pq.empty()) { @@ -120,8 +120,8 @@ AttributeUniqueLabelMapFilter::GenerateData() } else { - OffsetValueType prevLength = prev.line.GetLength(); - OffsetValueType length = l.line.GetLength(); + OffsetValueType prevLength = prev.line.GetLength(); + const OffsetValueType length = l.line.GetLength(); if (prevIdx[0] + prevLength > idx[0]) { @@ -173,7 +173,7 @@ AttributeUniqueLabelMapFilter::GenerateData() // add it to the priority queue IndexType newIdx = idx; newIdx[0] = idx[0] + length; - OffsetValueType newLength = prevIdx[0] + prevLength - newIdx[0]; + const OffsetValueType newLength = prevIdx[0] + prevLength - newIdx[0]; pq.push(LineOfLabelObject(LineType(newIdx, newLength), prev.labelObject)); } // truncate the previous line to let some place for the current one @@ -203,7 +203,7 @@ AttributeUniqueLabelMapFilter::GenerateData() { IndexType newIdx = idx; newIdx[0] = prevIdx[0] + prevLength; - OffsetValueType newLength = idx[0] + length - newIdx[0]; + const OffsetValueType newLength = idx[0] + length - newIdx[0]; if (newLength > 0) { @@ -244,8 +244,8 @@ AttributeUniqueLabelMapFilter::GenerateData() typename ImageType::Iterator it(this->GetLabelMap()); while (it.IsAtEnd()) { - typename LabelObjectType::LabelType label = it.GetLabel(); - LabelObjectType * labelObject = it.GetLabelObject(); + const typename LabelObjectType::LabelType label = it.GetLabel(); + LabelObjectType * labelObject = it.GetLabelObject(); if (labelObject->Empty()) { diff --git a/Modules/Filtering/LabelMap/include/itkBinaryFillholeImageFilter.hxx b/Modules/Filtering/LabelMap/include/itkBinaryFillholeImageFilter.hxx index 427d883c078..5fa7f528d9a 100644 --- a/Modules/Filtering/LabelMap/include/itkBinaryFillholeImageFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkBinaryFillholeImageFilter.hxx @@ -42,7 +42,7 @@ BinaryFillholeImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/LabelMap/include/itkBinaryGrindPeakImageFilter.hxx b/Modules/Filtering/LabelMap/include/itkBinaryGrindPeakImageFilter.hxx index f36b23eb642..842b25682d6 100644 --- a/Modules/Filtering/LabelMap/include/itkBinaryGrindPeakImageFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkBinaryGrindPeakImageFilter.hxx @@ -41,7 +41,7 @@ BinaryGrindPeakImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // We need the whole input - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/LabelMap/include/itkBinaryImageToLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkBinaryImageToLabelMapFilter.hxx index 47b6ca78fbc..35e0fe75684 100644 --- a/Modules/Filtering/LabelMap/include/itkBinaryImageToLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkBinaryImageToLabelMapFilter.hxx @@ -44,7 +44,7 @@ BinaryImageToLabelMapFilter::GenerateInputRequestedRe Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (!input) { return; @@ -92,7 +92,7 @@ BinaryImageToLabelMapFilter::GenerateData() progress1.GetProcessObject()); // compute the total number of labels - SizeValueType nbOfLabels = this->m_NumberOfLabels.load(); + const SizeValueType nbOfLabels = this->m_NumberOfLabels.load(); // insert all the labels into the structure -- an extra loop but // saves complicating the ones that come later @@ -113,7 +113,7 @@ BinaryImageToLabelMapFilter::GenerateData() progress3.GetProcessObject()); // AfterThreadedGenerateData - typename TInputImage::ConstPointer input = this->GetInput(); + const typename TInputImage::ConstPointer input = this->GetInput(); m_NumberOfObjects = this->CreateConsecutive(m_OutputBackgroundValue); ProgressReporter progress(this, 0, linecount, 25, 0.75f, 0.25f); // check for overflow exception here @@ -154,8 +154,8 @@ BinaryImageToLabelMapFilter::DynamicThreadedGenerateD { const TInputImage * input = this->GetInput(); - WorkUnitData workUnitData = this->CreateWorkUnitData(outputRegionForThread); - SizeValueType lineId = workUnitData.firstLine; + const WorkUnitData workUnitData = this->CreateWorkUnitData(outputRegionForThread); + SizeValueType lineId = workUnitData.firstLine; SizeValueType nbOfLabels = 0; for (ImageScanlineConstIterator inLineIt(input, outputRegionForThread); !inLineIt.IsAtEnd(); inLineIt.NextLine()) @@ -167,8 +167,8 @@ BinaryImageToLabelMapFilter::DynamicThreadedGenerateD if (pixelValue == this->m_InputForegroundValue) { // We've hit the start of a run - SizeValueType length = 0; - IndexType thisIndex = inLineIt.GetIndex(); + SizeValueType length = 0; + const IndexType thisIndex = inLineIt.GetIndex(); ++length; ++inLineIt; while (!inLineIt.IsAtEndOfLine() && inLineIt.Get() == this->m_InputForegroundValue) @@ -177,7 +177,7 @@ BinaryImageToLabelMapFilter::DynamicThreadedGenerateD ++inLineIt; } // create the run length object to go in the vector - RunLength thisRun(length, thisIndex, 0); // will give a real label later + const RunLength thisRun(length, thisIndex, 0); // will give a real label later thisLine.push_back(thisRun); ++nbOfLabels; } diff --git a/Modules/Filtering/LabelMap/include/itkBinaryImageToShapeLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkBinaryImageToShapeLabelMapFilter.hxx index c3b76c75217..7dd34d8fa1f 100644 --- a/Modules/Filtering/LabelMap/include/itkBinaryImageToShapeLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkBinaryImageToShapeLabelMapFilter.hxx @@ -41,7 +41,7 @@ BinaryImageToShapeLabelMapFilter::GenerateInputReques Superclass::GenerateInputRequestedRegion(); // We need all the inputs. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/LabelMap/include/itkBinaryImageToStatisticsLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkBinaryImageToStatisticsLabelMapFilter.hxx index 3278e37387a..a5a52c8e2c1 100644 --- a/Modules/Filtering/LabelMap/include/itkBinaryImageToStatisticsLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkBinaryImageToStatisticsLabelMapFilter.hxx @@ -43,7 +43,7 @@ BinaryImageToStatisticsLabelMapFilter: Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/LabelMap/include/itkBinaryNotImageFilter.h b/Modules/Filtering/LabelMap/include/itkBinaryNotImageFilter.h index a8ec93ab8d3..2e232747f85 100644 --- a/Modules/Filtering/LabelMap/include/itkBinaryNotImageFilter.h +++ b/Modules/Filtering/LabelMap/include/itkBinaryNotImageFilter.h @@ -69,7 +69,7 @@ class BinaryNot inline TPixel operator()(const TPixel & A) const { - bool a = (A == m_ForegroundValue); + const bool a = (A == m_ForegroundValue); if (!a) { return m_ForegroundValue; diff --git a/Modules/Filtering/LabelMap/include/itkBinaryShapeKeepNObjectsImageFilter.hxx b/Modules/Filtering/LabelMap/include/itkBinaryShapeKeepNObjectsImageFilter.hxx index 67a9135477d..d2173f8e432 100644 --- a/Modules/Filtering/LabelMap/include/itkBinaryShapeKeepNObjectsImageFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkBinaryShapeKeepNObjectsImageFilter.hxx @@ -37,7 +37,7 @@ BinaryShapeKeepNObjectsImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/LabelMap/include/itkBinaryShapeOpeningImageFilter.hxx b/Modules/Filtering/LabelMap/include/itkBinaryShapeOpeningImageFilter.hxx index 4df6b1062b3..12dd46a9cd7 100644 --- a/Modules/Filtering/LabelMap/include/itkBinaryShapeOpeningImageFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkBinaryShapeOpeningImageFilter.hxx @@ -41,7 +41,7 @@ BinaryShapeOpeningImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/LabelMap/include/itkBinaryStatisticsKeepNObjectsImageFilter.hxx b/Modules/Filtering/LabelMap/include/itkBinaryStatisticsKeepNObjectsImageFilter.hxx index bc642236bb8..8b671a40b14 100644 --- a/Modules/Filtering/LabelMap/include/itkBinaryStatisticsKeepNObjectsImageFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkBinaryStatisticsKeepNObjectsImageFilter.hxx @@ -39,7 +39,7 @@ BinaryStatisticsKeepNObjectsImageFilter::GenerateInp Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/LabelMap/include/itkBinaryStatisticsOpeningImageFilter.hxx b/Modules/Filtering/LabelMap/include/itkBinaryStatisticsOpeningImageFilter.hxx index fba1bbd7362..d5234850aec 100644 --- a/Modules/Filtering/LabelMap/include/itkBinaryStatisticsOpeningImageFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkBinaryStatisticsOpeningImageFilter.hxx @@ -42,7 +42,7 @@ BinaryStatisticsOpeningImageFilter::GenerateInputReq Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/LabelMap/include/itkChangeLabelLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkChangeLabelLabelMapFilter.hxx index f5cf48b93bf..b6500374f37 100644 --- a/Modules/Filtering/LabelMap/include/itkChangeLabelLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkChangeLabelLabelMapFilter.hxx @@ -107,8 +107,8 @@ ChangeLabelLabelMapFilter::GenerateData() // ChangeBackgroundIfNeeded // Check if the background is among the list of labels to relabel. - ChangeMapIterator backgroundLabelItr = m_MapOfLabelToBeReplaced.find(output->GetBackgroundValue()); - const bool backgroundLabelMustBeReplaced = (backgroundLabelItr != m_MapOfLabelToBeReplaced.end()); + const ChangeMapIterator backgroundLabelItr = m_MapOfLabelToBeReplaced.find(output->GetBackgroundValue()); + const bool backgroundLabelMustBeReplaced = (backgroundLabelItr != m_MapOfLabelToBeReplaced.end()); // Then change the label of the background if needed if (backgroundLabelMustBeReplaced) @@ -134,7 +134,7 @@ ChangeLabelLabelMapFilter::GenerateData() while (labelObjectItr != labelObjectsToBeRelabeled.end()) { LabelObjectType * labelObjectSource = *labelObjectItr; - PixelType newLabel = m_MapOfLabelToBeReplaced[labelObjectSource->GetLabel()]; + const PixelType newLabel = m_MapOfLabelToBeReplaced[labelObjectSource->GetLabel()]; // Ignore the label if it is the background if (newLabel != output->GetBackgroundValue()) diff --git a/Modules/Filtering/LabelMap/include/itkChangeRegionLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkChangeRegionLabelMapFilter.hxx index 9376b208b40..ea7440372fe 100644 --- a/Modules/Filtering/LabelMap/include/itkChangeRegionLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkChangeRegionLabelMapFilter.hxx @@ -40,7 +40,7 @@ ChangeRegionLabelMapFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (!input) { return; @@ -70,7 +70,7 @@ ChangeRegionLabelMapFilter::GenerateData() if (m_Region.IsInside(this->GetInput()->GetLargestPossibleRegion())) { // only copy the image, report progress anyway - ProgressReporter progress(this, 0, 1); + const ProgressReporter progress(this, 0, 1); this->AllocateOutputs(); } else diff --git a/Modules/Filtering/LabelMap/include/itkCropLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkCropLabelMapFilter.hxx index c0d521ab002..1cb8dda8161 100644 --- a/Modules/Filtering/LabelMap/include/itkCropLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkCropLabelMapFilter.hxx @@ -46,10 +46,10 @@ CropLabelMapFilter::GenerateOutputInformation() SizeType size; IndexType index; - SizeType inputSize = inputPtr->GetLargestPossibleRegion().GetSize(); - IndexType inputIndex = inputPtr->GetLargestPossibleRegion().GetIndex(); + const SizeType inputSize = inputPtr->GetLargestPossibleRegion().GetSize(); + const IndexType inputIndex = inputPtr->GetLargestPossibleRegion().GetIndex(); - SizeType originalCropSize = m_UpperBoundaryCropSize + m_LowerBoundaryCropSize; + const SizeType originalCropSize = m_UpperBoundaryCropSize + m_LowerBoundaryCropSize; index = inputIndex + m_LowerBoundaryCropSize; size = inputSize - (originalCropSize); diff --git a/Modules/Filtering/LabelMap/include/itkInPlaceLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkInPlaceLabelMapFilter.hxx index bd21c803985..091606ae759 100644 --- a/Modules/Filtering/LabelMap/include/itkInPlaceLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkInPlaceLabelMapFilter.hxx @@ -60,14 +60,14 @@ InPlaceLabelMapFilter::AllocateOutputs() // Graft this first input to the output. Later, we'll need to // remove the input's hold on the bulk data. // - OutputImagePointer inputAsOutput = const_cast(this->GetInput()); + const OutputImagePointer inputAsOutput = const_cast(this->GetInput()); if (inputAsOutput) { // save the largest possible region to restore it after the graft output. // the largest possible region is not that important with LabelMap and // can be managed by the filter, even when running inplace - RegionType region = this->GetOutput()->GetLargestPossibleRegion(); + const RegionType region = this->GetOutput()->GetLargestPossibleRegion(); this->GraftOutput(inputAsOutput); this->GetOutput()->SetRegions(region); } @@ -75,7 +75,7 @@ InPlaceLabelMapFilter::AllocateOutputs() // If there are more than one outputs, allocate the remaining outputs for (unsigned int i = 1; i < this->GetNumberOfIndexedOutputs(); ++i) { - OutputImagePointer outputPtr = this->GetOutput(i); + const OutputImagePointer outputPtr = this->GetOutput(i); outputPtr->SetBufferedRegion(outputPtr->GetRequestedRegion()); outputPtr->Allocate(); } diff --git a/Modules/Filtering/LabelMap/include/itkLabelImageToLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkLabelImageToLabelMapFilter.hxx index c8777b99ee1..652bac1fae1 100644 --- a/Modules/Filtering/LabelMap/include/itkLabelImageToLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkLabelImageToLabelMapFilter.hxx @@ -39,7 +39,7 @@ LabelImageToLabelMapFilter::GenerateInputRequestedReg Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (!input) { return; @@ -103,8 +103,8 @@ LabelImageToLabelMapFilter::ThreadedGenerateData( if (value != static_cast(m_BackgroundValue)) { // We've hit the start of a run - IndexType idx = it.GetIndex(); - LengthType length = 1; + const IndexType idx = it.GetIndex(); + LengthType length = 1; ++it; while (!it.IsAtEndOfLine() && it.Get() == value) { diff --git a/Modules/Filtering/LabelMap/include/itkLabelImageToShapeLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkLabelImageToShapeLabelMapFilter.hxx index b9969607cba..1fd93d8c966 100644 --- a/Modules/Filtering/LabelMap/include/itkLabelImageToShapeLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkLabelImageToShapeLabelMapFilter.hxx @@ -39,7 +39,7 @@ LabelImageToShapeLabelMapFilter::GenerateInputRequest Superclass::GenerateInputRequestedRegion(); // We need all the inputs - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/LabelMap/include/itkLabelImageToStatisticsLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkLabelImageToStatisticsLabelMapFilter.hxx index 4d04abad4b7..a2e602e12bf 100644 --- a/Modules/Filtering/LabelMap/include/itkLabelImageToStatisticsLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkLabelImageToStatisticsLabelMapFilter.hxx @@ -41,7 +41,7 @@ LabelImageToStatisticsLabelMapFilter:: Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/LabelMap/include/itkLabelMap.hxx b/Modules/Filtering/LabelMap/include/itkLabelMap.hxx index bf353ab3293..71d7e60425d 100644 --- a/Modules/Filtering/LabelMap/include/itkLabelMap.hxx +++ b/Modules/Filtering/LabelMap/include/itkLabelMap.hxx @@ -214,7 +214,7 @@ LabelMap::SetPixel(const IndexType & idx, const LabelType & iLabel { auto tempIt = it; ++it; - bool emitModifiedEvent = (iLabel == m_BackgroundValue); + const bool emitModifiedEvent = (iLabel == m_BackgroundValue); this->RemovePixel(tempIt, idx, emitModifiedEvent); } else @@ -268,7 +268,7 @@ LabelMap::AddPixel(const LabelObjectContainerIterator & it, else { // the label does not exist yet - create a new one - LabelObjectPointerType labelObject = LabelObjectType::New(); + const LabelObjectPointerType labelObject = LabelObjectType::New(); labelObject->SetLabel(label); labelObject->AddIndex(idx); // Modified() is called in AddLabelObject() @@ -339,7 +339,7 @@ LabelMap::SetLine(const IndexType & idx, const LengthType & length else { // the label does not exist yet - create a new one - LabelObjectPointerType labelObject = LabelObjectType::New(); + const LabelObjectPointerType labelObject = LabelObjectType::New(); labelObject->SetLabel(label); labelObject->AddLine(idx, length); // Modified() is called in AddLabelObject() @@ -394,8 +394,8 @@ LabelMap::PushLabelObject(LabelObjectType * labelObject) } else { - LabelType lastLabel = m_LabelObjectContainer.rbegin()->first; - LabelType firstLabel = m_LabelObjectContainer.begin()->first; + const LabelType lastLabel = m_LabelObjectContainer.rbegin()->first; + const LabelType firstLabel = m_LabelObjectContainer.begin()->first; if (lastLabel != NumericTraits::max() && lastLabel + 1 != m_BackgroundValue) { labelObject->SetLabel(lastLabel + 1); diff --git a/Modules/Filtering/LabelMap/include/itkLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkLabelMapFilter.hxx index fdfeb26ee15..aaa7ebb668f 100644 --- a/Modules/Filtering/LabelMap/include/itkLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkLabelMapFilter.hxx @@ -47,7 +47,7 @@ LabelMapFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (!input) { diff --git a/Modules/Filtering/LabelMap/include/itkLabelMapMaskImageFilter.hxx b/Modules/Filtering/LabelMap/include/itkLabelMapMaskImageFilter.hxx index 6d0b4107459..8e6af7928f1 100644 --- a/Modules/Filtering/LabelMap/include/itkLabelMapMaskImageFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkLabelMapMaskImageFilter.hxx @@ -46,7 +46,7 @@ LabelMapMaskImageFilter::GenerateInputRequestedRegion Superclass::GenerateInputRequestedRegion(); // We need the whole input - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (!input) { return; @@ -115,7 +115,7 @@ LabelMapMaskImageFilter::GenerateOutputInformation() while (!lit.IsAtEnd()) { const IndexType & idx = lit.GetLine().GetIndex(); - LengthType length = lit.GetLine().GetLength(); + const LengthType length = lit.GetLine().GetLength(); // Update the mins and maxs for (unsigned int i = 0; i < ImageDimension; ++i) @@ -173,7 +173,7 @@ LabelMapMaskImageFilter::GenerateOutputInformation() while (!lit.IsAtEnd()) { const IndexType & idx = lit.GetLine().GetIndex(); - LengthType length = lit.GetLine().GetLength(); + const LengthType length = lit.GetLine().GetLength(); // Update the mins and maxs for (unsigned int i = 0; i < ImageDimension; ++i) @@ -279,8 +279,8 @@ LabelMapMaskImageFilter::GenerateData() // And mark the label object as background // Should we take care to not write outside the image ? - bool testIdxIsInside = m_Crop && (inImage->GetBackgroundValue() == m_Label) ^ m_Negated; - RegionType outputRegion = output->GetLargestPossibleRegion(); + const bool testIdxIsInside = m_Crop && (inImage->GetBackgroundValue() == m_Label) ^ m_Negated; + const RegionType outputRegion = output->GetLargestPossibleRegion(); typename LabelObjectType::ConstIndexIterator it(labelObject); while (!it.IsAtEnd()) @@ -344,8 +344,8 @@ LabelMapMaskImageFilter::ThreadedProcessLabelObject(L // equals the label given by the user. The other pixels are set to the background value. // Should we take care to not write outside the image ? - bool testIdxIsInside = m_Crop && (input->GetBackgroundValue() == m_Label) ^ m_Negated; - RegionType outputRegion = output->GetLargestPossibleRegion(); + const bool testIdxIsInside = m_Crop && (input->GetBackgroundValue() == m_Label) ^ m_Negated; + const RegionType outputRegion = output->GetLargestPossibleRegion(); // The user wants the mask to be the background of the label collection image typename LabelObjectType::ConstIndexIterator it(labelObject); diff --git a/Modules/Filtering/LabelMap/include/itkLabelMapToAttributeImageFilter.hxx b/Modules/Filtering/LabelMap/include/itkLabelMapToAttributeImageFilter.hxx index a69800f85b9..abc41f78b72 100644 --- a/Modules/Filtering/LabelMap/include/itkLabelMapToAttributeImageFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkLabelMapToAttributeImageFilter.hxx @@ -39,7 +39,7 @@ LabelMapToAttributeImageFilter::G Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (!input) { return; @@ -67,7 +67,7 @@ LabelMapToAttributeImageFilter::G const InputImageType * input = this->GetInput(); ProgressReporter progress(this, 0, output->GetRequestedRegion().GetNumberOfPixels()); - AttributeAccessorType accessor; + const AttributeAccessorType accessor; output->FillBuffer(m_BackgroundValue); diff --git a/Modules/Filtering/LabelMap/include/itkLabelMapToBinaryImageFilter.hxx b/Modules/Filtering/LabelMap/include/itkLabelMapToBinaryImageFilter.hxx index 192a705a9c3..0553691ffd5 100644 --- a/Modules/Filtering/LabelMap/include/itkLabelMapToBinaryImageFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkLabelMapToBinaryImageFilter.hxx @@ -41,7 +41,7 @@ LabelMapToBinaryImageFilter::GenerateInputRequestedRe Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { diff --git a/Modules/Filtering/LabelMap/include/itkLabelObject.h b/Modules/Filtering/LabelMap/include/itkLabelObject.h index 7c005e321d5..bfc5b9df944 100644 --- a/Modules/Filtering/LabelMap/include/itkLabelObject.h +++ b/Modules/Filtering/LabelMap/include/itkLabelObject.h @@ -245,7 +245,7 @@ class ITK_TEMPLATE_EXPORT LabelObject : public LightObject ConstLineIterator operator++(int) { - ConstLineIterator tmp = *this; + const ConstLineIterator tmp = *this; ++(*this); return tmp; } diff --git a/Modules/Filtering/LabelMap/include/itkLabelObject.hxx b/Modules/Filtering/LabelMap/include/itkLabelObject.hxx index 633ad683466..975d5defa87 100644 --- a/Modules/Filtering/LabelMap/include/itkLabelObject.hxx +++ b/Modules/Filtering/LabelMap/include/itkLabelObject.hxx @@ -104,8 +104,8 @@ LabelObject::RemoveIndex(const IndexType & idx) { if (it->HasIndex(idx)) { - IndexType orgLineIndex = it->GetIndex(); - LengthType orgLineLength = it->GetLength(); + IndexType orgLineIndex = it->GetIndex(); + const LengthType orgLineLength = it->GetLength(); if (orgLineLength == 1) { @@ -134,7 +134,7 @@ LabelObject::RemoveIndex(const IndexType & idx) it->SetLength(idx[0] - orgLineIndex[0]); IndexType newIdx = idx; ++newIdx[0]; - LengthType newLength = orgLineLength - it->GetLength() - 1; + const LengthType newLength = orgLineLength - it->GetLength() - 1; m_LineContainer.push_back(LineType(newIdx, newLength)); return true; } @@ -173,7 +173,7 @@ template void LabelObject::AddLine(const IndexType & idx, const LengthType & length) { - LineType line(idx, length); + const LineType line(idx, length); this->AddLine(line); } @@ -239,7 +239,7 @@ LabelObject::GetIndex(SizeValueType offset) const -> In while (it != m_LineContainer.end()) { - SizeValueType size = it->GetLength(); + const SizeValueType size = it->GetLength(); if (o >= size) { @@ -310,7 +310,7 @@ LabelObject::Optimize() m_LineContainer.clear(); // reorder the lines - typename Functor::LabelObjectLineComparator comparator; + const typename Functor::LabelObjectLineComparator comparator; std::sort(lineContainer.begin(), lineContainer.end(), comparator); // then check the lines consistency @@ -324,7 +324,7 @@ LabelObject::Optimize() { const LineType & line = *it; IndexType idx = line.GetIndex(); - LengthType length = line.GetLength(); + const LengthType length = line.GetLength(); // check the index to be sure that we are still in the same line idx bool sameIdx = true; @@ -340,7 +340,7 @@ LabelObject::Optimize() if (sameIdx && currentIdx[0] + (OffsetValueType)currentLength >= idx[0]) { // we may expand the line - LengthType newLength = idx[0] + (OffsetValueType)length - currentIdx[0]; + const LengthType newLength = idx[0] + (OffsetValueType)length - currentIdx[0]; currentLength = std::max(newLength, currentLength); } else diff --git a/Modules/Filtering/LabelMap/include/itkLabelShapeKeepNObjectsImageFilter.hxx b/Modules/Filtering/LabelMap/include/itkLabelShapeKeepNObjectsImageFilter.hxx index 49559e1af8d..935fef0d7dd 100644 --- a/Modules/Filtering/LabelMap/include/itkLabelShapeKeepNObjectsImageFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkLabelShapeKeepNObjectsImageFilter.hxx @@ -39,7 +39,7 @@ LabelShapeKeepNObjectsImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/LabelMap/include/itkLabelShapeOpeningImageFilter.hxx b/Modules/Filtering/LabelMap/include/itkLabelShapeOpeningImageFilter.hxx index 5b2e47bc363..5dd603c0cd2 100644 --- a/Modules/Filtering/LabelMap/include/itkLabelShapeOpeningImageFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkLabelShapeOpeningImageFilter.hxx @@ -39,7 +39,7 @@ LabelShapeOpeningImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/LabelMap/include/itkLabelStatisticsKeepNObjectsImageFilter.hxx b/Modules/Filtering/LabelMap/include/itkLabelStatisticsKeepNObjectsImageFilter.hxx index 97ce0fc83cd..1a76b444d64 100644 --- a/Modules/Filtering/LabelMap/include/itkLabelStatisticsKeepNObjectsImageFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkLabelStatisticsKeepNObjectsImageFilter.hxx @@ -40,7 +40,7 @@ LabelStatisticsKeepNObjectsImageFilter::GenerateInpu Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/LabelMap/include/itkLabelStatisticsOpeningImageFilter.hxx b/Modules/Filtering/LabelMap/include/itkLabelStatisticsOpeningImageFilter.hxx index 1b3cdb08cb0..0c70c8f0fc9 100644 --- a/Modules/Filtering/LabelMap/include/itkLabelStatisticsOpeningImageFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkLabelStatisticsOpeningImageFilter.hxx @@ -40,7 +40,7 @@ LabelStatisticsOpeningImageFilter::GenerateInputRequ Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/LabelMap/include/itkMergeLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkMergeLabelMapFilter.hxx index 15599ba5e12..2130a9b2d36 100644 --- a/Modules/Filtering/LabelMap/include/itkMergeLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkMergeLabelMapFilter.hxx @@ -81,8 +81,8 @@ MergeLabelMapFilter::MergeWithKeep() typename ImageType::ConstIterator it2(this->GetInput(i)); while (!it2.IsAtEnd()) { - const LabelObjectType * lo = it2.GetLabelObject(); - LabelObjectPointer newLo = LabelObjectType::New(); + const LabelObjectType * lo = it2.GetLabelObject(); + const LabelObjectPointer newLo = LabelObjectType::New(); newLo->template CopyAllFrom(lo); if ((output->GetBackgroundValue() != newLo->GetLabel()) && (!output->HasLabel(newLo->GetLabel()))) @@ -124,8 +124,8 @@ MergeLabelMapFilter::MergeWithStrict() typename ImageType::ConstIterator it2(this->GetInput(i)); while (!it2.IsAtEnd()) { - const LabelObjectType * lo = it2.GetLabelObject(); - LabelObjectPointer newLo = LabelObjectType::New(); + const LabelObjectType * lo = it2.GetLabelObject(); + const LabelObjectPointer newLo = LabelObjectType::New(); newLo->template CopyAllFrom(lo); if (output->GetBackgroundValue() != newLo->GetLabel()) @@ -171,11 +171,11 @@ MergeLabelMapFilter::MergeWithAggregate() { const LabelObjectType * lo = it2.GetLabelObject(); - bool hasLabel = output->HasLabel(lo->GetLabel()); + const bool hasLabel = output->HasLabel(lo->GetLabel()); if (!hasLabel && (lo->GetLabel() != output->GetBackgroundValue())) { // we can keep the label - LabelObjectPointer newLo = LabelObjectType::New(); + const LabelObjectPointer newLo = LabelObjectType::New(); newLo->template CopyAllFrom(lo); output->AddLabelObject(newLo); } @@ -235,8 +235,8 @@ MergeLabelMapFilter::MergeWithPack() typename ImageType::ConstIterator it2(this->GetInput(i)); while (!it2.IsAtEnd()) { - const LabelObjectType * lo = it2.GetLabelObject(); - LabelObjectPointer newLo = LabelObjectType::New(); + const LabelObjectType * lo = it2.GetLabelObject(); + const LabelObjectPointer newLo = LabelObjectType::New(); newLo->template CopyAllFrom(lo); output->PushLabelObject(newLo); diff --git a/Modules/Filtering/LabelMap/include/itkObjectByObjectLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkObjectByObjectLabelMapFilter.hxx index 0645fbf4c40..5cb4133330e 100644 --- a/Modules/Filtering/LabelMap/include/itkObjectByObjectLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkObjectByObjectLabelMapFilter.hxx @@ -194,12 +194,12 @@ ObjectByObjectLabelMapFilterSetCropBorder(m_PadSize); - SizeType zero{}; + const SizeType zero{}; m_Pad->SetPadSize(zero); } else { - SizeType zero{}; + const SizeType zero{}; m_Crop->SetCropBorder(zero); m_Pad->SetPadSize(m_PadSize); } @@ -265,7 +265,7 @@ ObjectByObjectLabelMapFilterGetLabelObject(m_Label); + const typename LabelObjectType::Pointer lotmp = output->GetLabelObject(m_Label); output->RemoveLabelObject(lotmp); outLo->SetLabel(m_Label); outLo->template CopyAttributesFrom(inLo); diff --git a/Modules/Filtering/LabelMap/include/itkPadLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkPadLabelMapFilter.hxx index 6c7673f1682..f52da600d22 100644 --- a/Modules/Filtering/LabelMap/include/itkPadLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkPadLabelMapFilter.hxx @@ -45,10 +45,10 @@ PadLabelMapFilter::GenerateOutputInformation() SizeType size; IndexType index; - SizeType inputSize = inputPtr->GetLargestPossibleRegion().GetSize(); - IndexType inputIndex = inputPtr->GetLargestPossibleRegion().GetIndex(); + const SizeType inputSize = inputPtr->GetLargestPossibleRegion().GetSize(); + const IndexType inputIndex = inputPtr->GetLargestPossibleRegion().GetIndex(); - SizeType originalPadSize = m_UpperBoundaryPadSize + m_LowerBoundaryPadSize; + const SizeType originalPadSize = m_UpperBoundaryPadSize + m_LowerBoundaryPadSize; index = inputIndex - m_LowerBoundaryPadSize; size = inputSize + (originalPadSize); diff --git a/Modules/Filtering/LabelMap/include/itkShapeKeepNObjectsLabelMapFilter.h b/Modules/Filtering/LabelMap/include/itkShapeKeepNObjectsLabelMapFilter.h index e026d429ab1..c70c37e88cb 100644 --- a/Modules/Filtering/LabelMap/include/itkShapeKeepNObjectsLabelMapFilter.h +++ b/Modules/Filtering/LabelMap/include/itkShapeKeepNObjectsLabelMapFilter.h @@ -153,12 +153,12 @@ class ITK_TEMPLATE_EXPORT ShapeKeepNObjectsLabelMapFilter : public InPlaceLabelM auto end = labelObjects.begin() + m_NumberOfObjects; if (m_ReverseOrdering) { - Functor::LabelObjectReverseComparator comparator; + const Functor::LabelObjectReverseComparator comparator{}; std::nth_element(labelObjects.begin(), end, labelObjects.end(), comparator); } else { - Functor::LabelObjectComparator comparator; + const Functor::LabelObjectComparator comparator{}; std::nth_element(labelObjects.begin(), end, labelObjects.end(), comparator); } progress.CompletedPixel(); diff --git a/Modules/Filtering/LabelMap/include/itkShapeLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkShapeLabelMapFilter.hxx index c05bbc22151..939d71eaf96 100644 --- a/Modules/Filtering/LabelMap/include/itkShapeLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkShapeLabelMapFilter.hxx @@ -109,7 +109,7 @@ ShapeLabelMapFilter::ThreadedProcessLabelObject(LabelObject while (!lit.IsAtEnd()) { const IndexType & idx = lit.GetLine().GetIndex(); - LengthType length = lit.GetLine().GetLength(); + const LengthType length = lit.GetLine().GetLength(); // Update the nbOfPixels nbOfPixels += length; @@ -233,7 +233,7 @@ ShapeLabelMapFilter::ThreadedProcessLabelObject(LabelObject // piece of code gives the same result in an efficient way, by // using expended formulae allowed by the binary case instead of // loops. - IndexValueType endIdx0 = idx[0] + length; + const IndexValueType endIdx0 = idx[0] + length; for (IndexType iidx = idx; iidx[0] < endIdx0; iidx[0]++) { typename LabelObjectType::CentroidType pP; @@ -300,8 +300,8 @@ ShapeLabelMapFilter::ThreadedProcessLabelObject(LabelObject centralMoments[i][j] /= nbOfPixels; } } - typename LabelObjectType::RegionType boundingBox(mins, boundingBoxSize); - typename LabelObjectType::CentroidType physicalCentroid; + const typename LabelObjectType::RegionType boundingBox(mins, boundingBoxSize); + typename LabelObjectType::CentroidType physicalCentroid; output->TransformContinuousIndexToPhysicalPoint(centroid, physicalCentroid); // Center the second order moments @@ -314,9 +314,9 @@ ShapeLabelMapFilter::ThreadedProcessLabelObject(LabelObject } // Compute principal moments and axes - VectorType principalMoments; - vnl_symmetric_eigensystem eigen{ centralMoments.GetVnlMatrix().as_matrix() }; - vnl_diag_matrix pm = eigen.D; + VectorType principalMoments; + const vnl_symmetric_eigensystem eigen{ centralMoments.GetVnlMatrix().as_matrix() }; + vnl_diag_matrix pm = eigen.D; for (unsigned int i = 0; i < ImageDimension; ++i) { principalMoments[i] = pm(i); @@ -325,7 +325,7 @@ ShapeLabelMapFilter::ThreadedProcessLabelObject(LabelObject // Add a final reflection if needed for a proper rotation, // by multiplying the last row by the determinant - vnl_real_eigensystem eigenrot{ principalAxes.GetVnlMatrix().as_matrix() }; + const vnl_real_eigensystem eigenrot{ principalAxes.GetVnlMatrix().as_matrix() }; vnl_diag_matrix> eigenval{ eigenrot.D }; std::complex det(1.0, 0.0); @@ -368,9 +368,9 @@ ShapeLabelMapFilter::ThreadedProcessLabelObject(LabelObject } } - double physicalSize = nbOfPixels * sizePerPixel; - double equivalentRadius = GeometryUtilities::HyperSphereRadiusFromVolume(ImageDimension, physicalSize); - double equivalentPerimeter = GeometryUtilities::HyperSpherePerimeter(ImageDimension, equivalentRadius); + const double physicalSize = nbOfPixels * sizePerPixel; + const double equivalentRadius = GeometryUtilities::HyperSphereRadiusFromVolume(ImageDimension, physicalSize); + const double equivalentPerimeter = GeometryUtilities::HyperSpherePerimeter(ImageDimension, equivalentRadius); // Compute equivalent ellipsoid radius VectorType ellipsoidDiameter; @@ -500,7 +500,7 @@ ShapeLabelMapFilter::ComputePerimeter(LabelObjectType * lab auto lineImage = LineImageType::New(); typename LineImageType::IndexType lIdx; typename LineImageType::SizeType lSize; - RegionType boundingBox = labelObject->GetBoundingBox(); + const RegionType boundingBox = labelObject->GetBoundingBox(); for (unsigned int i = 0; i < ImageDimension - 1; ++i) { lIdx[i] = boundingBox.GetIndex()[i + 1]; @@ -595,9 +595,9 @@ ShapeLabelMapFilter::ComputePerimeter(LabelObjectType * lab auto li = ls.begin(); auto ni = ns.begin(); - IndexValueType lZero = 0; - IndexValueType lMin = 0; - IndexValueType lMax = 0; + const IndexValueType lZero = 0; + IndexValueType lMin = 0; + IndexValueType lMax = 0; IndexValueType nMin = NumericTraits::NonpositiveMin() + 1; IndexValueType nMax = ni->GetIndex()[0] - 1; @@ -648,7 +648,7 @@ ShapeLabelMapFilter::ComputePerimeter(LabelObjectType * lab } // compute the perimeter based on the intercept counts - double perimeter = PerimeterFromInterceptCount(intercepts, this->GetOutput()->GetSpacing()); + const double perimeter = PerimeterFromInterceptCount(intercepts, this->GetOutput()->GetSpacing()); labelObject->SetPerimeter(perimeter); labelObject->SetRoundness(labelObject->GetEquivalentSphericalPerimeter() / perimeter); labelObject->SetPerimeterOnBorderRatio(labelObject->GetPerimeterOnBorder() / perimeter); @@ -689,12 +689,12 @@ ShapeLabelMapFilter::PerimeterFromInterceptCount(MapInterce const Spacing2Type spacing) { // std::cout << "PerimeterFromInterceptCount2" << std::endl; - double dx = spacing[0]; - double dy = spacing[1]; + const double dx = spacing[0]; + const double dy = spacing[1]; - Offset2Type nx = { { 1, 0 } }; - Offset2Type ny = { { 0, 1 } }; - Offset2Type nxy = { { 1, 1 } }; + const Offset2Type nx = { { 1, 0 } }; + const Offset2Type ny = { { 0, 1 } }; + const Offset2Type nxy = { { 1, 1 } }; // std::cout << "nx: " << intercepts[nx] << std::endl; // std::cout << "ny: " << intercepts[ny] << std::endl; @@ -714,34 +714,34 @@ ShapeLabelMapFilter::PerimeterFromInterceptCount(MapInterce const Spacing3Type spacing) { // std::cout << "PerimeterFromInterceptCount3" << std::endl; - double dx = spacing[0]; - double dy = spacing[1]; - double dz = spacing[2]; - double dxy = std::sqrt(spacing[0] * spacing[0] + spacing[1] * spacing[1]); - double dxz = std::sqrt(spacing[0] * spacing[0] + spacing[2] * spacing[2]); - double dyz = std::sqrt(spacing[1] * spacing[1] + spacing[2] * spacing[2]); - double dxyz = std::sqrt(spacing[0] * spacing[0] + spacing[1] * spacing[1] + spacing[2] * spacing[2]); - double vol = spacing[0] * spacing[1] * spacing[2]; + const double dx = spacing[0]; + const double dy = spacing[1]; + const double dz = spacing[2]; + const double dxy = std::sqrt(spacing[0] * spacing[0] + spacing[1] * spacing[1]); + const double dxz = std::sqrt(spacing[0] * spacing[0] + spacing[2] * spacing[2]); + const double dyz = std::sqrt(spacing[1] * spacing[1] + spacing[2] * spacing[2]); + const double dxyz = std::sqrt(spacing[0] * spacing[0] + spacing[1] * spacing[1] + spacing[2] * spacing[2]); + const double vol = spacing[0] * spacing[1] * spacing[2]; // 'magical numbers', corresponding to area of voronoi partition on the // unit sphere, when germs are the 26 directions on the unit cube // Sum of (c1+c2+c3 + c4*2+c5*2+c6*2 + c7*4) equals 1. - double c1 = 0.04577789120476 * 2; // Ox - double c2 = 0.04577789120476 * 2; // Oy - double c3 = 0.04577789120476 * 2; // Oz - double c4 = 0.03698062787608 * 2; // Oxy - double c5 = 0.03698062787608 * 2; // Oxz - double c6 = 0.03698062787608 * 2; // Oyz - double c7 = 0.03519563978232 * 2; // Oxyz - // TODO - recompute those values if the spacing is non isotropic - - Offset3Type nx = { { 1, 0, 0 } }; - Offset3Type ny = { { 0, 1, 0 } }; - Offset3Type nz = { { 0, 0, 1 } }; - Offset3Type nxy = { { 1, 1, 0 } }; - Offset3Type nxz = { { 1, 0, 1 } }; - Offset3Type nyz = { { 0, 1, 1 } }; - Offset3Type nxyz = { { 1, 1, 1 } }; + const double c1 = 0.04577789120476 * 2; // Ox + const double c2 = 0.04577789120476 * 2; // Oy + const double c3 = 0.04577789120476 * 2; // Oz + const double c4 = 0.03698062787608 * 2; // Oxy + const double c5 = 0.03698062787608 * 2; // Oxz + const double c6 = 0.03698062787608 * 2; // Oyz + const double c7 = 0.03519563978232 * 2; // Oxyz + // TODO - recompute those values if the spacing is non isotropic + + const Offset3Type nx = { { 1, 0, 0 } }; + const Offset3Type ny = { { 0, 1, 0 } }; + const Offset3Type nz = { { 0, 0, 1 } }; + const Offset3Type nxy = { { 1, 1, 0 } }; + const Offset3Type nxz = { { 1, 0, 1 } }; + const Offset3Type nyz = { { 0, 1, 1 } }; + const Offset3Type nxyz = { { 1, 1, 1 } }; // std::cout << "nx: " << intercepts[nx] << std::endl; // std::cout << "ny: " << intercepts[ny] << std::endl; @@ -786,7 +786,7 @@ ShapeLabelMapFilter::ComputeOrientedBoundingBox(LabelObject VNLMatrixType pixelLocations(ImageDimension, labelObject->GetNumberOfLines() * 2); for (unsigned int l = 0; l < numLines; ++l) { - typename LabelObjectType::LineType line = labelObject->GetLine(l); + const typename LabelObjectType::LineType line = labelObject->GetLine(l); // add start index of line as physical point relative to centroid IndexType idx = line.GetIndex(); diff --git a/Modules/Filtering/LabelMap/include/itkShapeLabelObject.h b/Modules/Filtering/LabelMap/include/itkShapeLabelObject.h index 6c486308751..28fbc050d93 100644 --- a/Modules/Filtering/LabelMap/include/itkShapeLabelObject.h +++ b/Modules/Filtering/LabelMap/include/itkShapeLabelObject.h @@ -669,7 +669,7 @@ class ITK_TEMPLATE_EXPORT ShapeLabelObject : public LabelObjectSetMatrix(matrix); result->SetOffset(offset); diff --git a/Modules/Filtering/LabelMap/include/itkShapeOpeningLabelMapFilter.h b/Modules/Filtering/LabelMap/include/itkShapeOpeningLabelMapFilter.h index c08124cb475..762873ffc03 100644 --- a/Modules/Filtering/LabelMap/include/itkShapeOpeningLabelMapFilter.h +++ b/Modules/Filtering/LabelMap/include/itkShapeOpeningLabelMapFilter.h @@ -143,8 +143,8 @@ class ITK_TEMPLATE_EXPORT ShapeOpeningLabelMapFilter : public InPlaceLabelMapFil typename ImageType::Iterator it(output); while (!it.IsAtEnd()) { - typename LabelObjectType::LabelType label = it.GetLabel(); - LabelObjectType * labelObject = it.GetLabelObject(); + const typename LabelObjectType::LabelType label = it.GetLabel(); + LabelObjectType * labelObject = it.GetLabelObject(); if ((!m_ReverseOrdering && accessor(labelObject) < m_Lambda) || (m_ReverseOrdering && accessor(labelObject) > m_Lambda)) diff --git a/Modules/Filtering/LabelMap/include/itkShapePositionLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkShapePositionLabelMapFilter.hxx index e3b880320a5..1b155db20fd 100644 --- a/Modules/Filtering/LabelMap/include/itkShapePositionLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkShapePositionLabelMapFilter.hxx @@ -40,7 +40,7 @@ ShapePositionLabelMapFilter::ThreadedProcessLabelObject(LabelObjectType case LabelObjectType::CENTROID: { using AccessorType = typename Functor::CentroidLabelObjectAccessor; - AccessorType accessor; + const AccessorType accessor; this->TemplatedThreadedProcessLabelObject(accessor, true, labelObject); break; } diff --git a/Modules/Filtering/LabelMap/include/itkShapeRelabelImageFilter.hxx b/Modules/Filtering/LabelMap/include/itkShapeRelabelImageFilter.hxx index be91893fed3..267b352543f 100644 --- a/Modules/Filtering/LabelMap/include/itkShapeRelabelImageFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkShapeRelabelImageFilter.hxx @@ -38,7 +38,7 @@ ShapeRelabelImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/LabelMap/include/itkShapeUniqueLabelMapFilter.h b/Modules/Filtering/LabelMap/include/itkShapeUniqueLabelMapFilter.h index f46d987b940..70bbebf3e0a 100644 --- a/Modules/Filtering/LabelMap/include/itkShapeUniqueLabelMapFilter.h +++ b/Modules/Filtering/LabelMap/include/itkShapeUniqueLabelMapFilter.h @@ -123,7 +123,7 @@ class ITK_TEMPLATE_EXPORT ShapeUniqueLabelMapFilter : public InPlaceLabelMapFilt typename std::priority_queue, LineOfLabelObjectComparator>; PriorityQueueType priorityQueue; - ProgressReporter progress(this, 0, 1); + const ProgressReporter progress(this, 0, 1); // TODO: really report the progress for (typename ImageType::Iterator it(this->GetLabelMap()); !it.IsAtEnd(); ++it) @@ -186,8 +186,8 @@ class ITK_TEMPLATE_EXPORT ShapeUniqueLabelMapFilter : public InPlaceLabelMapFilt } else { - OffsetValueType prevLength = prev.line.GetLength(); - OffsetValueType length = l.line.GetLength(); + OffsetValueType prevLength = prev.line.GetLength(); + const OffsetValueType length = l.line.GetLength(); if (prevIdx[0] + prevLength > idx[0]) { @@ -197,9 +197,9 @@ class ITK_TEMPLATE_EXPORT ShapeUniqueLabelMapFilter : public InPlaceLabelMapFilt // which line to keep. This is necessary to avoid the case where a // part of a label is over // a second label, and below in another part of the image. - bool keepCurrent; - typename TAttributeAccessor::AttributeValueType prevAttr = accessor(prev.labelObject); - typename TAttributeAccessor::AttributeValueType attr = accessor(l.labelObject); + bool keepCurrent; + const typename TAttributeAccessor::AttributeValueType prevAttr = accessor(prev.labelObject); + const typename TAttributeAccessor::AttributeValueType attr = accessor(l.labelObject); // this may be changed to a single boolean expression, but may become // quite difficult to read if (Math::ExactlyEquals(attr, prevAttr)) @@ -239,7 +239,7 @@ class ITK_TEMPLATE_EXPORT ShapeUniqueLabelMapFilter : public InPlaceLabelMapFilt // add it to the priority queue IndexType newIdx = idx; newIdx[0] = idx[0] + length; - OffsetValueType newLength = prevIdx[0] + prevLength - newIdx[0]; + const OffsetValueType newLength = prevIdx[0] + prevLength - newIdx[0]; priorityQueue.push(LineOfLabelObject(LineType(newIdx, newLength), prev.labelObject)); } // truncate the previous line to let some place for the current one @@ -270,7 +270,7 @@ class ITK_TEMPLATE_EXPORT ShapeUniqueLabelMapFilter : public InPlaceLabelMapFilt { IndexType newIdx = idx; newIdx[0] = prevIdx[0] + prevLength; - OffsetValueType newLength = idx[0] + length - newIdx[0]; + const OffsetValueType newLength = idx[0] + length - newIdx[0]; if (newLength > 0) { l.line.SetIndex(newIdx); @@ -305,8 +305,8 @@ class ITK_TEMPLATE_EXPORT ShapeUniqueLabelMapFilter : public InPlaceLabelMapFilt typename ImageType::Iterator it(this->GetLabelMap()); while (!it.IsAtEnd()) { - typename LabelObjectType::LabelType label = it.GetLabel(); - LabelObjectType * labelObject = it.GetLabelObject(); + const typename LabelObjectType::LabelType label = it.GetLabel(); + LabelObjectType * labelObject = it.GetLabelObject(); if (labelObject->Empty()) { diff --git a/Modules/Filtering/LabelMap/include/itkStatisticsLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkStatisticsLabelMapFilter.hxx index e12a3171fbd..e87aca32665 100644 --- a/Modules/Filtering/LabelMap/include/itkStatisticsLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkStatisticsLabelMapFilter.hxx @@ -141,7 +141,7 @@ StatisticsLabelMapFilter::ThreadedProcessLabelObject(Labe centralMoments[i][i] += v * physicalPosition[i] * physicalPosition[i]; for (unsigned int j = i + 1; j < ImageDimension; ++j) { - double weight = v * physicalPosition[i] * physicalPosition[j]; + const double weight = v * physicalPosition[i] * physicalPosition[j]; centralMoments[i][j] += weight; centralMoments[j][i] += weight; } @@ -235,8 +235,8 @@ StatisticsLabelMapFilter::ThreadedProcessLabelObject(Labe } // Compute principal moments and axes - vnl_symmetric_eigensystem eigen{ centralMoments.GetVnlMatrix().as_matrix() }; - vnl_diag_matrix pm{ eigen.D }; + const vnl_symmetric_eigensystem eigen{ centralMoments.GetVnlMatrix().as_matrix() }; + vnl_diag_matrix pm{ eigen.D }; for (unsigned int i = 0; i < ImageDimension; ++i) { // principalMoments[i] = 4 * std::sqrt( pm(i,i) ); @@ -246,7 +246,7 @@ StatisticsLabelMapFilter::ThreadedProcessLabelObject(Labe // Add a final reflection if needed for a proper rotation, // by multiplying the last row by the determinant - vnl_real_eigensystem eigenrot{ principalAxes.GetVnlMatrix().as_matrix() }; + const vnl_real_eigensystem eigenrot{ principalAxes.GetVnlMatrix().as_matrix() }; vnl_diag_matrix> eigenval{ eigenrot.D }; std::complex det(1.0, 0.0); diff --git a/Modules/Filtering/LabelMap/include/itkStatisticsPositionLabelMapFilter.hxx b/Modules/Filtering/LabelMap/include/itkStatisticsPositionLabelMapFilter.hxx index fb8af46b3b5..31dbffc9802 100644 --- a/Modules/Filtering/LabelMap/include/itkStatisticsPositionLabelMapFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkStatisticsPositionLabelMapFilter.hxx @@ -41,21 +41,21 @@ StatisticsPositionLabelMapFilter::ThreadedProcessLabelObject(LabelObject case LabelObjectType::MAXIMUM_INDEX: { using AccessorType = typename Functor::MaximumIndexLabelObjectAccessor; - AccessorType accessor; + const AccessorType accessor; this->TemplatedThreadedProcessLabelObject(accessor, false, labelObject); break; } case LabelObjectType::MINIMUM_INDEX: { using AccessorType = typename Functor::MinimumIndexLabelObjectAccessor; - AccessorType accessor; + const AccessorType accessor; this->TemplatedThreadedProcessLabelObject(accessor, false, labelObject); break; } case LabelObjectType::CENTER_OF_GRAVITY: { using AccessorType = typename Functor::CenterOfGravityLabelObjectAccessor; - AccessorType accessor; + const AccessorType accessor; this->TemplatedThreadedProcessLabelObject(accessor, true, labelObject); break; } diff --git a/Modules/Filtering/LabelMap/include/itkStatisticsRelabelImageFilter.hxx b/Modules/Filtering/LabelMap/include/itkStatisticsRelabelImageFilter.hxx index f4f45190f81..fd40d51334e 100644 --- a/Modules/Filtering/LabelMap/include/itkStatisticsRelabelImageFilter.hxx +++ b/Modules/Filtering/LabelMap/include/itkStatisticsRelabelImageFilter.hxx @@ -39,7 +39,7 @@ StatisticsRelabelImageFilter::GenerateInputRequested Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/LabelMap/test/itkAggregateLabelMapFilterTest.cxx b/Modules/Filtering/LabelMap/test/itkAggregateLabelMapFilterTest.cxx index 64b8e8befd9..8887b750749 100644 --- a/Modules/Filtering/LabelMap/test/itkAggregateLabelMapFilterTest.cxx +++ b/Modules/Filtering/LabelMap/test/itkAggregateLabelMapFilterTest.cxx @@ -54,7 +54,7 @@ itkAggregateLabelMapFilterTest(int argc, char * argv[]) using ChangeType = itk::AggregateLabelMapFilter; auto change = ChangeType::New(); change->SetInput(i2l->GetOutput()); - itk::SimpleFilterWatcher watcher6(change, "filter"); + const itk::SimpleFilterWatcher watcher6(change, "filter"); using L2IType = itk::LabelMapToLabelImageFilter; auto l2i = L2IType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkAttributeKeepNObjectsLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkAttributeKeepNObjectsLabelMapFilterTest1.cxx index 17356ab987d..62efb3414dd 100644 --- a/Modules/Filtering/LabelMap/test/itkAttributeKeepNObjectsLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkAttributeKeepNObjectsLabelMapFilterTest1.cxx @@ -62,7 +62,7 @@ itkAttributeKeepNObjectsLabelMapFilterTest1(int argc, char * argv[]) // Now we will valuate the attributes. The attribute will be the object position // in the label map - LabelMapType::Pointer labelMap = i2l->GetOutput(); + const LabelMapType::Pointer labelMap = i2l->GetOutput(); int pos = 0; for (LabelMapType::Iterator it(labelMap); !it.IsAtEnd(); ++it) @@ -76,7 +76,7 @@ itkAttributeKeepNObjectsLabelMapFilterTest1(int argc, char * argv[]) auto opening = LabelKeepNObjectsType::New(); // testing get and set macros for NumberOfObjects - unsigned long nbOfObjects = std::stoi(argv[3]); + const unsigned long nbOfObjects = std::stoi(argv[3]); opening->SetNumberOfObjects(nbOfObjects); ITK_TEST_SET_GET_VALUE(nbOfObjects, opening->GetNumberOfObjects()); @@ -88,13 +88,13 @@ itkAttributeKeepNObjectsLabelMapFilterTest1(int argc, char * argv[]) opening->ReverseOrderingOff(); ITK_TEST_SET_GET_VALUE(false, opening->GetReverseOrdering()); - bool reverseOrdering = std::stoi(argv[4]); + const bool reverseOrdering = std::stoi(argv[4]); opening->SetReverseOrdering(reverseOrdering); ITK_TEST_SET_GET_VALUE(reverseOrdering, opening->GetReverseOrdering()); opening->SetInput(labelMap); - itk::SimpleFilterWatcher watcher(opening, "filter"); + const itk::SimpleFilterWatcher watcher(opening, "filter"); using L2IType = itk::LabelMapToLabelImageFilter; auto l2i = L2IType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkAttributeLabelObjectAccessorsTest1.cxx b/Modules/Filtering/LabelMap/test/itkAttributeLabelObjectAccessorsTest1.cxx index 360f30727cd..d8912adc879 100644 --- a/Modules/Filtering/LabelMap/test/itkAttributeLabelObjectAccessorsTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkAttributeLabelObjectAccessorsTest1.cxx @@ -68,7 +68,7 @@ itkAttributeLabelObjectAccessorsTest1(int argc, char * argv[]) // values in the 2nd image. The StatisticsLabelObject can give us that value, without // having to code that by hand - that's an example. - LabelMapType::Pointer labelMap = i2l->GetOutput(); + const LabelMapType::Pointer labelMap = i2l->GetOutput(); for (LabelMapType::Iterator it(labelMap); !it.IsAtEnd(); ++it) { // the label is there if we need it, but it can also be found at labelObject->GetLabel(). diff --git a/Modules/Filtering/LabelMap/test/itkAttributeOpeningLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkAttributeOpeningLabelMapFilterTest1.cxx index 86edc31ca0d..67f9258c361 100644 --- a/Modules/Filtering/LabelMap/test/itkAttributeOpeningLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkAttributeOpeningLabelMapFilterTest1.cxx @@ -62,7 +62,7 @@ itkAttributeOpeningLabelMapFilterTest1(int argc, char * argv[]) // Now we will valuate the attributes. The attribute will be the object position // in the label map - LabelMapType::Pointer labelMap = imageToLabel->GetOutput(); + const LabelMapType::Pointer labelMap = imageToLabel->GetOutput(); int pos = 0; for (LabelMapType::Iterator it(labelMap); !it.IsAtEnd(); ++it) @@ -88,13 +88,13 @@ itkAttributeOpeningLabelMapFilterTest1(int argc, char * argv[]) opening->ReverseOrderingOff(); ITK_TEST_SET_GET_VALUE(false, opening->GetReverseOrdering()); - bool reverseOrdering = std::stoi(argv[4]); + const bool reverseOrdering = std::stoi(argv[4]); opening->SetReverseOrdering(reverseOrdering); ITK_TEST_SET_GET_VALUE(reverseOrdering, opening->GetReverseOrdering()); opening->SetInput(labelMap); - itk::SimpleFilterWatcher watcher(opening, "filter"); + const itk::SimpleFilterWatcher watcher(opening, "filter"); using LabelToImageType = itk::LabelMapToLabelImageFilter; auto labelToImage = LabelToImageType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkAttributePositionLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkAttributePositionLabelMapFilterTest1.cxx index f0fd43be471..5b6351a1c1a 100644 --- a/Modules/Filtering/LabelMap/test/itkAttributePositionLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkAttributePositionLabelMapFilterTest1.cxx @@ -76,7 +76,7 @@ itkAttributePositionLabelMapFilterTest1(int argc, char * argv[]) true>; auto opening = OpeningType::New(); opening->SetInput(i2l->GetOutput()); - itk::SimpleFilterWatcher watcher(opening, "filter"); + const itk::SimpleFilterWatcher watcher(opening, "filter"); // the label map is then converted back to an label image. using L2IType = itk::LabelMapToLabelImageFilter; diff --git a/Modules/Filtering/LabelMap/test/itkAttributeRelabelLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkAttributeRelabelLabelMapFilterTest1.cxx index 8a68aeefd68..05bd63157e9 100644 --- a/Modules/Filtering/LabelMap/test/itkAttributeRelabelLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkAttributeRelabelLabelMapFilterTest1.cxx @@ -62,7 +62,7 @@ itkAttributeRelabelLabelMapFilterTest1(int argc, char * argv[]) // Now we will valuate the attributes. The attribute will be the object position // in the label map - LabelMapType::Pointer labelMap = i2l->GetOutput(); + const LabelMapType::Pointer labelMap = i2l->GetOutput(); int pos = 0; for (LabelMapType::Iterator it(labelMap); !it.IsAtEnd(); ++it) @@ -83,13 +83,13 @@ itkAttributeRelabelLabelMapFilterTest1(int argc, char * argv[]) relabel->ReverseOrderingOff(); ITK_TEST_SET_GET_VALUE(false, relabel->GetReverseOrdering()); - bool reverseOrdering = std::stoi(argv[3]); + const bool reverseOrdering = std::stoi(argv[3]); relabel->SetReverseOrdering(reverseOrdering); ITK_TEST_SET_GET_VALUE(reverseOrdering, relabel->GetReverseOrdering()); relabel->SetInput(labelMap); - itk::SimpleFilterWatcher watcher(relabel, "filter"); + const itk::SimpleFilterWatcher watcher(relabel, "filter"); using L2IType = itk::LabelMapToLabelImageFilter; auto l2i = L2IType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkAttributeUniqueLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkAttributeUniqueLabelMapFilterTest1.cxx index 08a058c9237..0a7a2bccbac 100644 --- a/Modules/Filtering/LabelMap/test/itkAttributeUniqueLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkAttributeUniqueLabelMapFilterTest1.cxx @@ -80,7 +80,7 @@ itkAttributeUniqueLabelMapFilterTest1(int argc, char * argv[]) unique->SetInput(oi->GetOutput()); - itk::SimpleFilterWatcher watcher(unique, "filter"); + const itk::SimpleFilterWatcher watcher(unique, "filter"); using L2IType = itk::LabelMapToLabelImageFilter; auto l2i = L2IType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkAutoCropLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkAutoCropLabelMapFilterTest1.cxx index 9e00a484926..f189276098f 100644 --- a/Modules/Filtering/LabelMap/test/itkAutoCropLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkAutoCropLabelMapFilterTest1.cxx @@ -63,7 +63,7 @@ itkAutoCropLabelMapFilterTest1(int argc, char * argv[]) auto imageToLabelMapFilter = ImageToLabelMapFilterType::New(); imageToLabelMapFilter->SetInput(reader->GetOutput()); - PixelType backgroundValue = std::stoi(argv[3]); + const PixelType backgroundValue = std::stoi(argv[3]); imageToLabelMapFilter->SetBackgroundValue(backgroundValue); @@ -80,7 +80,7 @@ itkAutoCropLabelMapFilterTest1(int argc, char * argv[]) autoCropFilter->SetCropBorder(size); ITK_TEST_SET_GET_VALUE(size, autoCropFilter->GetCropBorder()); - itk::SimpleFilterWatcher watcher(autoCropFilter, "AutoCropLabelMapFilter"); + const itk::SimpleFilterWatcher watcher(autoCropFilter, "AutoCropLabelMapFilter"); using LabelMapToLabelImageFilterType = itk::LabelMapToLabelImageFilter; auto labelMapToLabelImageFilter = LabelMapToLabelImageFilterType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkAutoCropLabelMapFilterTest2.cxx b/Modules/Filtering/LabelMap/test/itkAutoCropLabelMapFilterTest2.cxx index 82d190e7d03..cd049ae321b 100644 --- a/Modules/Filtering/LabelMap/test/itkAutoCropLabelMapFilterTest2.cxx +++ b/Modules/Filtering/LabelMap/test/itkAutoCropLabelMapFilterTest2.cxx @@ -63,12 +63,12 @@ itkAutoCropLabelMapFilterTest2(int argc, char * argv[]) using ImageToLabelMapFilterType = itk::LabelImageToLabelMapFilter; auto imageToLabelMapFilter = ImageToLabelMapFilterType::New(); imageToLabelMapFilter->SetInput(reader->GetOutput()); - itk::SimpleFilterWatcher watcher(imageToLabelMapFilter, "LabelImageToLabelMapFilter"); + const itk::SimpleFilterWatcher watcher(imageToLabelMapFilter, "LabelImageToLabelMapFilter"); using SelectionType = itk::LabelSelectionLabelMapFilter; auto select = SelectionType::New(); select->SetInput(imageToLabelMapFilter->GetOutput()); - itk::SimpleFilterWatcher watcher2(select, "LabelSelectionLabelMapFilter"); + const itk::SimpleFilterWatcher watcher2(select, "LabelSelectionLabelMapFilter"); using AutoCropLabelMapFilterType = itk::AutoCropLabelMapFilter; auto autoCropFilter = AutoCropLabelMapFilterType::New(); @@ -76,7 +76,7 @@ itkAutoCropLabelMapFilterTest2(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(autoCropFilter, AutoCropLabelMapFilter, ChangeRegionLabelMapFilter); autoCropFilter->SetInput(select->GetOutput()); - itk::SimpleFilterWatcher watcher3(autoCropFilter, "AutoCropLabelMapFilter"); + const itk::SimpleFilterWatcher watcher3(autoCropFilter, "AutoCropLabelMapFilter"); using LabelMapToLabelImageFilterType = itk::LabelMapToLabelImageFilter; auto labelMapToLabelImageFilter = LabelMapToLabelImageFilterType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkBinaryFillholeImageFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkBinaryFillholeImageFilterTest1.cxx index 8d3c2908b32..1d369b3f925 100644 --- a/Modules/Filtering/LabelMap/test/itkBinaryFillholeImageFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkBinaryFillholeImageFilterTest1.cxx @@ -45,12 +45,12 @@ DoIt(char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, BinaryFillholeImageFilter, ImageToImageFilter); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); auto fullyConnected = static_cast(std::stoi(argv[3])); ITK_TEST_SET_GET_BOOLEAN(filter, FullyConnected, fullyConnected); - typename FilterType::InputImagePixelType foregroundValue = std::stoi(argv[4]); + const typename FilterType::InputImagePixelType foregroundValue = std::stoi(argv[4]); filter->SetForegroundValue(foregroundValue); ITK_TEST_SET_GET_VALUE(foregroundValue, filter->GetForegroundValue()); @@ -86,7 +86,7 @@ itkBinaryFillholeImageFilterTest1(int argc, char * argv[]) reader->SetFileName(argv[1]); ITK_TRY_EXPECT_NO_EXCEPTION(reader->UpdateOutputInformation()); - unsigned dim = reader->GetImageIO()->GetNumberOfDimensions(); + const unsigned dim = reader->GetImageIO()->GetNumberOfDimensions(); switch (dim) { case 2: diff --git a/Modules/Filtering/LabelMap/test/itkBinaryGrindPeakImageFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkBinaryGrindPeakImageFilterTest1.cxx index bdbd9363c07..6badc2ab4fe 100644 --- a/Modules/Filtering/LabelMap/test/itkBinaryGrindPeakImageFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkBinaryGrindPeakImageFilterTest1.cxx @@ -53,7 +53,7 @@ itkBinaryGrindPeakImageFilterTest1(int argc, char * argv[]) binaryGrindPeakImageFilter->SetInput(reader->GetOutput()); - bool fullyConnected = std::stoi(argv[3]) != 0; + const bool fullyConnected = std::stoi(argv[3]) != 0; binaryGrindPeakImageFilter->SetFullyConnected(fullyConnected); ITK_TEST_SET_GET_VALUE(fullyConnected, binaryGrindPeakImageFilter->GetFullyConnected()); @@ -77,7 +77,7 @@ itkBinaryGrindPeakImageFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(backgroundValue, binaryGrindPeakImageFilter->GetBackgroundValue()); - itk::SimpleFilterWatcher watcher(binaryGrindPeakImageFilter, "BinaryGrindPeakImageFilter"); + const itk::SimpleFilterWatcher watcher(binaryGrindPeakImageFilter, "BinaryGrindPeakImageFilter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkBinaryImageToLabelMapFilterTest.cxx b/Modules/Filtering/LabelMap/test/itkBinaryImageToLabelMapFilterTest.cxx index 5f1bf61b91c..453d077cee2 100644 --- a/Modules/Filtering/LabelMap/test/itkBinaryImageToLabelMapFilterTest.cxx +++ b/Modules/Filtering/LabelMap/test/itkBinaryImageToLabelMapFilterTest.cxx @@ -65,15 +65,15 @@ itkBinaryImageToLabelMapFilterTest(int argc, char * argv[]) auto fullyConnected = static_cast(std::stoi(argv[3])); ITK_TEST_SET_GET_BOOLEAN(imageToLabel, FullyConnected, fullyConnected); - typename ImageToLabelType::InputPixelType inputForegroundValue = std::stoi(argv[4]); + const typename ImageToLabelType::InputPixelType inputForegroundValue = std::stoi(argv[4]); imageToLabel->SetInputForegroundValue(inputForegroundValue); ITK_TEST_SET_GET_VALUE(inputForegroundValue, imageToLabel->GetInputForegroundValue()); - typename ImageToLabelType::OutputPixelType outputBackgroundValue = std::stoi(argv[5]); + const typename ImageToLabelType::OutputPixelType outputBackgroundValue = std::stoi(argv[5]); imageToLabel->SetOutputBackgroundValue(outputBackgroundValue); ITK_TEST_SET_GET_VALUE(outputBackgroundValue, imageToLabel->GetOutputBackgroundValue()); - itk::SimpleFilterWatcher watcher(imageToLabel); + const itk::SimpleFilterWatcher watcher(imageToLabel); using LabelToImageType = itk::LabelMapToLabelImageFilter; auto labelToImage = LabelToImageType::New(); @@ -89,7 +89,7 @@ itkBinaryImageToLabelMapFilterTest(int argc, char * argv[]) labelToImage->SetInput(imageToLabel->GetOutput()); writer->SetInput(labelToImage->GetOutput()); - bool expectfailure = std::stoi(argv[6]); + const bool expectfailure = std::stoi(argv[6]); if (expectfailure) { diff --git a/Modules/Filtering/LabelMap/test/itkBinaryImageToShapeLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkBinaryImageToShapeLabelMapFilterTest1.cxx index 38a8a739d5e..86dcff8be69 100644 --- a/Modules/Filtering/LabelMap/test/itkBinaryImageToShapeLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkBinaryImageToShapeLabelMapFilterTest1.cxx @@ -57,12 +57,12 @@ itkBinaryImageToShapeLabelMapFilterTest1(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(i2l, BinaryImageToShapeLabelMapFilter, ImageToImageFilter); - itk::SimpleFilterWatcher watcher1(i2l); + const itk::SimpleFilterWatcher watcher1(i2l); i2l->SetInput(reader->GetOutput()); // testing get/set FullyConnected macro - bool fullyConnected = std::stoi(argv[3]); + const bool fullyConnected = std::stoi(argv[3]); i2l->SetFullyConnected(fullyConnected); ITK_TEST_SET_GET_VALUE(fullyConnected, i2l->GetFullyConnected()); @@ -74,28 +74,28 @@ itkBinaryImageToShapeLabelMapFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(true, i2l->GetFullyConnected()); // testing get/set InputForegroundValue macro - int inputForegroundValue = (std::stoi(argv[4])); + const int inputForegroundValue = (std::stoi(argv[4])); i2l->SetInputForegroundValue(inputForegroundValue); ITK_TEST_SET_GET_VALUE(inputForegroundValue, i2l->GetInputForegroundValue()); // testing get/set OutputBackgroundValue macro - int outputBackgroundValue = (std::stoi(argv[5])); + const int outputBackgroundValue = (std::stoi(argv[5])); i2l->SetOutputBackgroundValue(outputBackgroundValue); ITK_TEST_SET_GET_VALUE(outputBackgroundValue, i2l->GetOutputBackgroundValue()); - bool computeFeretDiameter = (std::stoi(argv[6])); + const bool computeFeretDiameter = (std::stoi(argv[6])); ITK_TEST_SET_GET_BOOLEAN(i2l, ComputeFeretDiameter, computeFeretDiameter); - bool computePerimeter = std::stoi(argv[7]); + const bool computePerimeter = std::stoi(argv[7]); ITK_TEST_SET_GET_BOOLEAN(i2l, ComputePerimeter, computePerimeter); - bool computeOrientedBoundingBox = std::stoi(argv[8]); + const bool computeOrientedBoundingBox = std::stoi(argv[8]); ITK_TEST_SET_GET_BOOLEAN(i2l, ComputeOrientedBoundingBox, computeOrientedBoundingBox); using L2IType = itk::LabelMapToLabelImageFilter; - auto l2i = L2IType::New(); - itk::SimpleFilterWatcher watcher2(l2i); + auto l2i = L2IType::New(); + const itk::SimpleFilterWatcher watcher2(l2i); l2i->SetInput(i2l->GetOutput()); diff --git a/Modules/Filtering/LabelMap/test/itkBinaryImageToStatisticsLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkBinaryImageToStatisticsLabelMapFilterTest1.cxx index ad631c34b1e..2e8e6bfe01a 100644 --- a/Modules/Filtering/LabelMap/test/itkBinaryImageToStatisticsLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkBinaryImageToStatisticsLabelMapFilterTest1.cxx @@ -53,19 +53,19 @@ itkBinaryImageToStatisticsLabelMapFilterTest1(int argc, char * argv[]) // converting binary image to Statistics label map // don't set the output type to test the default value of the template parameter using I2LType = itk::BinaryImageToStatisticsLabelMapFilter; - auto i2l = I2LType::New(); - itk::SimpleFilterWatcher watcher1(i2l); + auto i2l = I2LType::New(); + const itk::SimpleFilterWatcher watcher1(i2l); i2l->SetInput(reader->GetOutput()); // test all the possible ways to set the feature image. Be sure they can work with const images. - ImageType::ConstPointer constOutput = reader2->GetOutput(); + const ImageType::ConstPointer constOutput = reader2->GetOutput(); i2l->SetInput2(constOutput); i2l->SetFeatureImage(constOutput); i2l->SetInput(1, constOutput); // testing get/set FullyConnected macro - bool fullyConnected = std::stoi(argv[4]); + const bool fullyConnected = std::stoi(argv[4]); i2l->SetFullyConnected(fullyConnected); ITK_TEST_SET_GET_VALUE(fullyConnected, i2l->GetFullyConnected()); @@ -77,17 +77,17 @@ itkBinaryImageToStatisticsLabelMapFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(true, i2l->GetFullyConnected()); // testing get/set InputForegroundValue macro - int inputForegroundValue = (std::stoi(argv[5])); + const int inputForegroundValue = (std::stoi(argv[5])); i2l->SetInputForegroundValue(inputForegroundValue); ITK_TEST_SET_GET_VALUE(inputForegroundValue, i2l->GetInputForegroundValue()); // testing get/set OutputBackgroundValue macro - unsigned int outputBackgroundValue = (std::stoi(argv[6])); + const unsigned int outputBackgroundValue = (std::stoi(argv[6])); i2l->SetOutputBackgroundValue(outputBackgroundValue); ITK_TEST_SET_GET_VALUE(outputBackgroundValue, i2l->GetOutputBackgroundValue()); // testing get/set ComputeFeretDiameter macro - bool computeFeretDiameter = (std::stoi(argv[7])); + const bool computeFeretDiameter = (std::stoi(argv[7])); i2l->SetComputeFeretDiameter(computeFeretDiameter); ITK_TEST_SET_GET_VALUE(computeFeretDiameter, i2l->GetComputeFeretDiameter()); @@ -99,7 +99,7 @@ itkBinaryImageToStatisticsLabelMapFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(true, i2l->GetComputeFeretDiameter()); // testing get/set ComputePerimeter macro - bool computePerimeter = std::stoi(argv[8]); + const bool computePerimeter = std::stoi(argv[8]); i2l->SetComputePerimeter(computePerimeter); ITK_TEST_SET_GET_VALUE(computePerimeter, i2l->GetComputePerimeter()); @@ -111,7 +111,7 @@ itkBinaryImageToStatisticsLabelMapFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(true, i2l->GetComputePerimeter()); // testing get/set ComputeHistogram macro - bool computeHistogram = (std::stoi(argv[9])); + const bool computeHistogram = (std::stoi(argv[9])); i2l->SetComputeHistogram(computeHistogram); ITK_TEST_SET_GET_VALUE(computeHistogram, i2l->GetComputeHistogram()); @@ -123,13 +123,13 @@ itkBinaryImageToStatisticsLabelMapFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(true, i2l->GetComputeHistogram()); // testing get/set NumberOfBins macro - unsigned int numberOfBins = (std::stoi(argv[10])); + const unsigned int numberOfBins = (std::stoi(argv[10])); i2l->SetNumberOfBins(numberOfBins); ITK_TEST_SET_GET_VALUE(numberOfBins, i2l->GetNumberOfBins()); using L2IType = itk::LabelMapToLabelImageFilter; - auto l2i = L2IType::New(); - itk::SimpleFilterWatcher watcher2(l2i); + auto l2i = L2IType::New(); + const itk::SimpleFilterWatcher watcher2(l2i); l2i->SetInput(i2l->GetOutput()); diff --git a/Modules/Filtering/LabelMap/test/itkBinaryReconstructionByDilationImageFilterTest.cxx b/Modules/Filtering/LabelMap/test/itkBinaryReconstructionByDilationImageFilterTest.cxx index fb17311ed00..9305ced0dae 100644 --- a/Modules/Filtering/LabelMap/test/itkBinaryReconstructionByDilationImageFilterTest.cxx +++ b/Modules/Filtering/LabelMap/test/itkBinaryReconstructionByDilationImageFilterTest.cxx @@ -53,11 +53,11 @@ itkBinaryReconstructionByDilationImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(reconstruction, BinaryReconstructionByDilationImageFilter, ImageToImageFilter); // testing get and set macros for Lambda - int fg = std::stoi(argv[4]); + const int fg = std::stoi(argv[4]); reconstruction->SetForegroundValue(fg); ITK_TEST_SET_GET_VALUE(fg, reconstruction->GetForegroundValue()); - int bg = std::stoi(argv[5]); + const int bg = std::stoi(argv[5]); reconstruction->SetBackgroundValue(bg); ITK_TEST_SET_GET_VALUE(bg, reconstruction->GetBackgroundValue()); @@ -69,7 +69,7 @@ itkBinaryReconstructionByDilationImageFilterTest(int argc, char * argv[]) reconstruction->SetMarkerImage(reader2->GetOutput()); reconstruction->SetInput("MarkerImage", reader2->GetOutput()); - itk::SimpleFilterWatcher watcher(reconstruction, "filter"); + const itk::SimpleFilterWatcher watcher(reconstruction, "filter"); using WriterType = itk::ImageFileWriter; diff --git a/Modules/Filtering/LabelMap/test/itkBinaryReconstructionByErosionImageFilterTest.cxx b/Modules/Filtering/LabelMap/test/itkBinaryReconstructionByErosionImageFilterTest.cxx index 144a11f2745..8c2b53f8bee 100644 --- a/Modules/Filtering/LabelMap/test/itkBinaryReconstructionByErosionImageFilterTest.cxx +++ b/Modules/Filtering/LabelMap/test/itkBinaryReconstructionByErosionImageFilterTest.cxx @@ -53,11 +53,11 @@ itkBinaryReconstructionByErosionImageFilterTest(int argc, char * argv[]) // testing get and set macros for Lambda - int fg = std::stoi(argv[4]); + const int fg = std::stoi(argv[4]); reconstruction->SetForegroundValue(fg); ITK_TEST_SET_GET_VALUE(fg, reconstruction->GetForegroundValue()); - int bg = std::stoi(argv[5]); + const int bg = std::stoi(argv[5]); reconstruction->SetBackgroundValue(bg); ITK_TEST_SET_GET_VALUE(bg, reconstruction->GetBackgroundValue()); @@ -70,7 +70,7 @@ itkBinaryReconstructionByErosionImageFilterTest(int argc, char * argv[]) reconstruction->SetMarkerImage(reader2->GetOutput()); reconstruction->SetInput("MarkerImage", reader2->GetOutput()); - itk::SimpleFilterWatcher watcher(reconstruction, "filter"); + const itk::SimpleFilterWatcher watcher(reconstruction, "filter"); using WriterType = itk::ImageFileWriter; diff --git a/Modules/Filtering/LabelMap/test/itkBinaryReconstructionLabelMapFilterTest.cxx b/Modules/Filtering/LabelMap/test/itkBinaryReconstructionLabelMapFilterTest.cxx index bb362cd6891..97ff2b55db3 100644 --- a/Modules/Filtering/LabelMap/test/itkBinaryReconstructionLabelMapFilterTest.cxx +++ b/Modules/Filtering/LabelMap/test/itkBinaryReconstructionLabelMapFilterTest.cxx @@ -63,14 +63,14 @@ itkBinaryReconstructionLabelMapFilterTest(int argc, char * argv[]) using LabelReconstructionType = itk::BinaryReconstructionLabelMapFilter; auto reconstruction = LabelReconstructionType::New(); - int fg = std::stoi(argv[4]); + const int fg = std::stoi(argv[4]); reconstruction->SetForegroundValue(fg); ITK_TEST_SET_GET_VALUE(fg, reconstruction->GetForegroundValue()); reconstruction->SetInput(i2l->GetOutput()); reconstruction->SetMarkerImage(reader2->GetOutput()); - itk::SimpleFilterWatcher watcher(reconstruction, "filter"); + const itk::SimpleFilterWatcher watcher(reconstruction, "filter"); reconstruction->Update(); reconstruction->GetOutput()->PrintLabelObjects(); diff --git a/Modules/Filtering/LabelMap/test/itkBinaryShapeKeepNObjectsImageFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkBinaryShapeKeepNObjectsImageFilterTest1.cxx index b77961a7fb8..bf039787490 100644 --- a/Modules/Filtering/LabelMap/test/itkBinaryShapeKeepNObjectsImageFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkBinaryShapeKeepNObjectsImageFilterTest1.cxx @@ -51,17 +51,17 @@ itkBinaryShapeKeepNObjectsImageFilterTest1(int argc, char * argv[]) KeepNObjects->SetInput(reader->GetOutput()); // testing get/set ForegroundValue macro - int ForegroundValue = (std::stoi(argv[3])); + const int ForegroundValue = (std::stoi(argv[3])); KeepNObjects->SetForegroundValue(ForegroundValue); ITK_TEST_SET_GET_VALUE(ForegroundValue, KeepNObjects->GetForegroundValue()); // testing get/set BackgroundValue macro - int BackgroundValue = (std::stoi(argv[4])); + const int BackgroundValue = (std::stoi(argv[4])); KeepNObjects->SetBackgroundValue(BackgroundValue); ITK_TEST_SET_GET_VALUE(BackgroundValue, KeepNObjects->GetBackgroundValue()); // testing get and set macros for Lambda - unsigned int numberOfObjects = std::stoi(argv[5]); + const unsigned int numberOfObjects = std::stoi(argv[5]); KeepNObjects->SetNumberOfObjects(numberOfObjects); ITK_TEST_SET_GET_VALUE(numberOfObjects, KeepNObjects->GetNumberOfObjects()); @@ -73,7 +73,7 @@ itkBinaryShapeKeepNObjectsImageFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(false, KeepNObjects->GetReverseOrdering()); // testing get and set macros or ReverseOrdering - bool reverseOrdering = std::stoi(argv[6]); + const bool reverseOrdering = std::stoi(argv[6]); KeepNObjects->SetReverseOrdering(reverseOrdering); ITK_TEST_SET_GET_VALUE(reverseOrdering, KeepNObjects->GetReverseOrdering()); @@ -85,7 +85,7 @@ itkBinaryShapeKeepNObjectsImageFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(false, KeepNObjects->GetFullyConnected()); // testing get and set macros or FullyConnected - bool fullyConnected = std::stoi(argv[7]); + const bool fullyConnected = std::stoi(argv[7]); KeepNObjects->SetFullyConnected(fullyConnected); ITK_TEST_SET_GET_VALUE(fullyConnected, KeepNObjects->GetFullyConnected()); @@ -99,7 +99,7 @@ itkBinaryShapeKeepNObjectsImageFilterTest1(int argc, char * argv[]) const BinaryKeepNObjectsType::AttributeType attributeByCode = BinaryKeepNObjectsType::LabelObjectType::LABEL; ITK_TEST_SET_GET_VALUE(attributeByCode, KeepNObjects->GetAttribute()); - itk::SimpleFilterWatcher watcher(KeepNObjects, "filter"); + const itk::SimpleFilterWatcher watcher(KeepNObjects, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkBinaryShapeOpeningImageFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkBinaryShapeOpeningImageFilterTest1.cxx index 3067f865b76..6997b0d47a0 100644 --- a/Modules/Filtering/LabelMap/test/itkBinaryShapeOpeningImageFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkBinaryShapeOpeningImageFilterTest1.cxx @@ -51,17 +51,17 @@ itkBinaryShapeOpeningImageFilterTest1(int argc, char * argv[]) opening->SetInput(reader->GetOutput()); // testing get/set ForegroundValue macro - int ForegroundValue = (std::stoi(argv[3])); + const int ForegroundValue = (std::stoi(argv[3])); opening->SetForegroundValue(ForegroundValue); ITK_TEST_SET_GET_VALUE(ForegroundValue, opening->GetForegroundValue()); // testing get/set BackgroundValue macro - int BackgroundValue = (std::stoi(argv[4])); + const int BackgroundValue = (std::stoi(argv[4])); opening->SetBackgroundValue(BackgroundValue); ITK_TEST_SET_GET_VALUE(BackgroundValue, opening->GetBackgroundValue()); // testing get and set macros for Lambda - double lambda = std::stod(argv[5]); + const double lambda = std::stod(argv[5]); opening->SetLambda(lambda); ITK_TEST_SET_GET_VALUE(lambda, opening->GetLambda()); @@ -73,7 +73,7 @@ itkBinaryShapeOpeningImageFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(false, opening->GetReverseOrdering()); // testing get and set macros or ReverseOrdering - bool reverseOrdering = std::stoi(argv[6]); + const bool reverseOrdering = std::stoi(argv[6]); opening->SetReverseOrdering(reverseOrdering); ITK_TEST_SET_GET_VALUE(reverseOrdering, opening->GetReverseOrdering()); @@ -85,16 +85,16 @@ itkBinaryShapeOpeningImageFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(false, opening->GetFullyConnected()); // testing get and set macros or FullyConnected - bool fullyConnected = std::stoi(argv[7]); + const bool fullyConnected = std::stoi(argv[7]); opening->SetFullyConnected(fullyConnected); ITK_TEST_SET_GET_VALUE(fullyConnected, opening->GetFullyConnected()); // testing get and set macros for Attribute - BinaryOpeningType::AttributeType attribute = std::stoi(argv[8]); + const BinaryOpeningType::AttributeType attribute = std::stoi(argv[8]); opening->SetAttribute(attribute); ITK_TEST_SET_GET_VALUE(attribute, opening->GetAttribute()); - itk::SimpleFilterWatcher watcher(opening, "filter"); + const itk::SimpleFilterWatcher watcher(opening, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkBinaryStatisticsKeepNObjectsImageFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkBinaryStatisticsKeepNObjectsImageFilterTest1.cxx index 36240c4ba2e..ec0d219e7fe 100644 --- a/Modules/Filtering/LabelMap/test/itkBinaryStatisticsKeepNObjectsImageFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkBinaryStatisticsKeepNObjectsImageFilterTest1.cxx @@ -55,17 +55,17 @@ itkBinaryStatisticsKeepNObjectsImageFilterTest1(int argc, char * argv[]) KeepNObjects->SetFeatureImage(reader2->GetOutput()); // testing get/set ForegroundValue macro - int ForegroundValue = (std::stoi(argv[4])); + const int ForegroundValue = (std::stoi(argv[4])); KeepNObjects->SetForegroundValue(ForegroundValue); ITK_TEST_SET_GET_VALUE(ForegroundValue, KeepNObjects->GetForegroundValue()); // testing get/set BackgroundValue macro - int BackgroundValue = (std::stoi(argv[5])); + const int BackgroundValue = (std::stoi(argv[5])); KeepNObjects->SetBackgroundValue(BackgroundValue); ITK_TEST_SET_GET_VALUE(BackgroundValue, KeepNObjects->GetBackgroundValue()); // testing get and set macros for NumberOfObjects - unsigned int numberOfObjects = std::stoi(argv[6]); + const unsigned int numberOfObjects = std::stoi(argv[6]); KeepNObjects->SetNumberOfObjects(numberOfObjects); ITK_TEST_SET_GET_VALUE(numberOfObjects, KeepNObjects->GetNumberOfObjects()); @@ -77,7 +77,7 @@ itkBinaryStatisticsKeepNObjectsImageFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(false, KeepNObjects->GetReverseOrdering()); // testing get and set macros or ReverseOrdering - bool reverseOrdering = std::stoi(argv[7]); + const bool reverseOrdering = std::stoi(argv[7]); KeepNObjects->SetReverseOrdering(reverseOrdering); ITK_TEST_SET_GET_VALUE(reverseOrdering, KeepNObjects->GetReverseOrdering()); @@ -89,16 +89,16 @@ itkBinaryStatisticsKeepNObjectsImageFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(false, KeepNObjects->GetFullyConnected()); // testing get and set macros or FullyConnected - bool fullyConnected = std::stoi(argv[8]); + const bool fullyConnected = std::stoi(argv[8]); KeepNObjects->SetFullyConnected(fullyConnected); ITK_TEST_SET_GET_VALUE(fullyConnected, KeepNObjects->GetFullyConnected()); // testing get and set macros for Attribute - BinaryKeepNObjectsType::AttributeType attribute = std::stoi(argv[9]); + const BinaryKeepNObjectsType::AttributeType attribute = std::stoi(argv[9]); KeepNObjects->SetAttribute(attribute); ITK_TEST_SET_GET_VALUE(attribute, KeepNObjects->GetAttribute()); - itk::SimpleFilterWatcher watcher(KeepNObjects, "filter"); + const itk::SimpleFilterWatcher watcher(KeepNObjects, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkBinaryStatisticsOpeningImageFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkBinaryStatisticsOpeningImageFilterTest1.cxx index ae6fcde65e7..b97e7deb1a6 100644 --- a/Modules/Filtering/LabelMap/test/itkBinaryStatisticsOpeningImageFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkBinaryStatisticsOpeningImageFilterTest1.cxx @@ -55,17 +55,17 @@ itkBinaryStatisticsOpeningImageFilterTest1(int argc, char * argv[]) opening->SetFeatureImage(reader2->GetOutput()); // testing get/set ForegroundValue macro - int ForegroundValue = (std::stoi(argv[4])); + const int ForegroundValue = (std::stoi(argv[4])); opening->SetForegroundValue(ForegroundValue); ITK_TEST_SET_GET_VALUE(ForegroundValue, opening->GetForegroundValue()); // testing get/set BackgroundValue macro - int BackgroundValue = (std::stoi(argv[5])); + const int BackgroundValue = (std::stoi(argv[5])); opening->SetBackgroundValue(BackgroundValue); ITK_TEST_SET_GET_VALUE(BackgroundValue, opening->GetBackgroundValue()); // testing get and set macros for Lambda - double lambda = std::stod(argv[6]); + const double lambda = std::stod(argv[6]); opening->SetLambda(lambda); ITK_TEST_SET_GET_VALUE(lambda, opening->GetLambda()); @@ -77,7 +77,7 @@ itkBinaryStatisticsOpeningImageFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(false, opening->GetReverseOrdering()); // testing get and set macros or ReverseOrdering - bool reverseOrdering = std::stoi(argv[7]); + const bool reverseOrdering = std::stoi(argv[7]); opening->SetReverseOrdering(reverseOrdering); ITK_TEST_SET_GET_VALUE(reverseOrdering, opening->GetReverseOrdering()); @@ -89,16 +89,16 @@ itkBinaryStatisticsOpeningImageFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(false, opening->GetFullyConnected()); // testing get and set macros or FullyConnected - bool fullyConnected = std::stoi(argv[8]); + const bool fullyConnected = std::stoi(argv[8]); opening->SetFullyConnected(fullyConnected); ITK_TEST_SET_GET_VALUE(fullyConnected, opening->GetFullyConnected()); // testing get and set macros for Attribute - BinaryOpeningType::AttributeType attribute = std::stoi(argv[9]); + const BinaryOpeningType::AttributeType attribute = std::stoi(argv[9]); opening->SetAttribute(attribute); ITK_TEST_SET_GET_VALUE(attribute, opening->GetAttribute()); - itk::SimpleFilterWatcher watcher(opening, "filter"); + const itk::SimpleFilterWatcher watcher(opening, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkChangeLabelLabelMapFilterTest.cxx b/Modules/Filtering/LabelMap/test/itkChangeLabelLabelMapFilterTest.cxx index 66dbe81ddb3..2cc0cbf76ba 100644 --- a/Modules/Filtering/LabelMap/test/itkChangeLabelLabelMapFilterTest.cxx +++ b/Modules/Filtering/LabelMap/test/itkChangeLabelLabelMapFilterTest.cxx @@ -78,7 +78,7 @@ itkChangeLabelLabelMapFilterTest(int argc, char * argv[]) changeFilter->SetChange(oldLabel, newLabel); } - itk::SimpleFilterWatcher watcher6(changeFilter, "filter"); + const itk::SimpleFilterWatcher watcher6(changeFilter, "filter"); using L2IType = itk::LabelMapToLabelImageFilter; auto l2i = L2IType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkChangeRegionLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkChangeRegionLabelMapFilterTest1.cxx index 5fa8765bbf9..eaefad7728b 100644 --- a/Modules/Filtering/LabelMap/test/itkChangeRegionLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkChangeRegionLabelMapFilterTest1.cxx @@ -61,9 +61,9 @@ itkChangeRegionLabelMapFilterTest1(int argc, char * argv[]) ChangeType::SizeType size; size[0] = std::stoi(argv[5]); size[1] = std::stoi(argv[6]); - ChangeType::RegionType region{ idx, size }; + const ChangeType::RegionType region{ idx, size }; change->SetRegion(region); - itk::SimpleFilterWatcher watcher6(change, "filter"); + const itk::SimpleFilterWatcher watcher6(change, "filter"); using L2IType = itk::LabelMapToLabelImageFilter; auto l2i = L2IType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkConvertLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkConvertLabelMapFilterTest1.cxx index 6908bbc4c4e..3670d4a822c 100644 --- a/Modules/Filtering/LabelMap/test/itkConvertLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkConvertLabelMapFilterTest1.cxx @@ -56,7 +56,7 @@ itkConvertLabelMapFilterTest1(int argc, char * argv[]) using CastType = itk::ConvertLabelMapFilter; auto cast = CastType::New(); cast->SetInput(l2s->GetOutput()); - itk::SimpleFilterWatcher watcher(cast, "cast"); + const itk::SimpleFilterWatcher watcher(cast, "cast"); using L2IType = itk::LabelMapToLabelImageFilter; auto l2i = L2IType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkConvertLabelMapFilterTest2.cxx b/Modules/Filtering/LabelMap/test/itkConvertLabelMapFilterTest2.cxx index b99922042dc..e4d4a231b9a 100644 --- a/Modules/Filtering/LabelMap/test/itkConvertLabelMapFilterTest2.cxx +++ b/Modules/Filtering/LabelMap/test/itkConvertLabelMapFilterTest2.cxx @@ -74,7 +74,7 @@ itkConvertLabelMapFilterTest2(int argc, char * argv[]) for (InputShapeLabelMapType::ConstIterator it(l2s->GetOutput()); !it.IsAtEnd(); ++it) { const InputShapeLabelMapType::LabelObjectType * labelObject = it.GetLabelObject(); - InputShapeLabelMapType::LabelType label = labelObject->GetLabel(); + const InputShapeLabelMapType::LabelType label = labelObject->GetLabel(); if (!castShape->GetOutput()->HasLabel(label)) // verify label first { @@ -158,7 +158,7 @@ itkConvertLabelMapFilterTest2(int argc, char * argv[]) for (InputStatisticsLabelMapType::ConstIterator it(l2stat->GetOutput()); !it.IsAtEnd(); ++it) { const InputStatisticsLabelMapType::LabelObjectType * labelObject = it.GetLabelObject(); - InputStatisticsLabelMapType::LabelType label = labelObject->GetLabel(); + const InputStatisticsLabelMapType::LabelType label = labelObject->GetLabel(); if (!castStatistics->GetOutput()->HasLabel(label)) // verify label first { @@ -251,7 +251,7 @@ itkConvertLabelMapFilterTest2(int argc, char * argv[]) using CastType = itk::ConvertLabelMapFilter; auto cast = CastType::New(); cast->SetInput(l2m->GetOutput()); - itk::SimpleFilterWatcher watcher(cast, "cast"); + const itk::SimpleFilterWatcher watcher(cast, "cast"); using L2IType = itk::LabelMapToLabelImageFilter; auto l2i = L2IType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkCropLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkCropLabelMapFilterTest1.cxx index eaf1b86b74d..9e17772f762 100644 --- a/Modules/Filtering/LabelMap/test/itkCropLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkCropLabelMapFilterTest1.cxx @@ -77,7 +77,7 @@ itkCropLabelMapFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(size, crop->GetUpperBoundaryCropSize()); ITK_TEST_SET_GET_VALUE(size, crop->GetLowerBoundaryCropSize()); - itk::SimpleFilterWatcher watcher6(crop, "filter"); + const itk::SimpleFilterWatcher watcher6(crop, "filter"); using L2IType = itk::LabelMapToLabelImageFilter; auto l2i = L2IType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkLabelImageToLabelMapFilterTest.cxx b/Modules/Filtering/LabelMap/test/itkLabelImageToLabelMapFilterTest.cxx index 8717865374e..849c9622bc2 100644 --- a/Modules/Filtering/LabelMap/test/itkLabelImageToLabelMapFilterTest.cxx +++ b/Modules/Filtering/LabelMap/test/itkLabelImageToLabelMapFilterTest.cxx @@ -112,7 +112,7 @@ itkLabelImageToLabelMapFilterTest(int, char *[]) IndexType index; index[0] = ctrI; index[1] = ctrJ; - unsigned long val = map->GetPixel(index); + const unsigned long val = map->GetPixel(index); std::cout << "Pixel[" << ctrI << ',' << ctrJ << "]: " << val << std::endl; if (((ctrI == 5) || (ctrJ == 5)) && (ctrI != 7) && (ctrJ != 7)) { diff --git a/Modules/Filtering/LabelMap/test/itkLabelImageToStatisticsLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkLabelImageToStatisticsLabelMapFilterTest1.cxx index f6f8621e301..b128e077900 100644 --- a/Modules/Filtering/LabelMap/test/itkLabelImageToStatisticsLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkLabelImageToStatisticsLabelMapFilterTest1.cxx @@ -53,24 +53,24 @@ itkLabelImageToStatisticsLabelMapFilterTest1(int argc, char * argv[]) // converting Label image to Statistics label map // don't set the output type to test the default value of the template parameter using I2LType = itk::LabelImageToStatisticsLabelMapFilter; - auto i2l = I2LType::New(); - itk::SimpleFilterWatcher watcher1(i2l); + auto i2l = I2LType::New(); + const itk::SimpleFilterWatcher watcher1(i2l); i2l->SetInput(reader->GetOutput()); // test all the possible ways to set the feature image. Be sure they can work with const images. - ImageType::ConstPointer constOutput = reader2->GetOutput(); + const ImageType::ConstPointer constOutput = reader2->GetOutput(); i2l->SetInput2(constOutput); i2l->SetFeatureImage(constOutput); i2l->SetInput(1, constOutput); // testing get/set BackgroundValue macro - int BackgroundValue = (std::stoi(argv[4])); + const int BackgroundValue = (std::stoi(argv[4])); i2l->SetBackgroundValue(BackgroundValue); ITK_TEST_SET_GET_VALUE(BackgroundValue, i2l->GetBackgroundValue()); // testing get/set ComputeFeretDiameter macro - bool computeFeretDiameter = (std::stoi(argv[5])); + const bool computeFeretDiameter = (std::stoi(argv[5])); i2l->SetComputeFeretDiameter(computeFeretDiameter); ITK_TEST_SET_GET_VALUE(computeFeretDiameter, i2l->GetComputeFeretDiameter()); @@ -82,7 +82,7 @@ itkLabelImageToStatisticsLabelMapFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(true, i2l->GetComputeFeretDiameter()); // testing get/set ComputePerimeter macro - bool computePerimeter = std::stoi(argv[6]); + const bool computePerimeter = std::stoi(argv[6]); i2l->SetComputePerimeter(computePerimeter); ITK_TEST_SET_GET_VALUE(computePerimeter, i2l->GetComputePerimeter()); @@ -94,7 +94,7 @@ itkLabelImageToStatisticsLabelMapFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(true, i2l->GetComputePerimeter()); // testing get/set ComputeHistogram macro - bool computeHistogram = (std::stoi(argv[7])); + const bool computeHistogram = (std::stoi(argv[7])); i2l->SetComputeHistogram(computeHistogram); ITK_TEST_SET_GET_VALUE(computeHistogram, i2l->GetComputeHistogram()); @@ -106,13 +106,13 @@ itkLabelImageToStatisticsLabelMapFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(true, i2l->GetComputeHistogram()); // testing get/set NumberOfBins macro - unsigned int numberOfBins = (std::stoi(argv[8])); + const unsigned int numberOfBins = (std::stoi(argv[8])); i2l->SetNumberOfBins(numberOfBins); ITK_TEST_SET_GET_VALUE(numberOfBins, i2l->GetNumberOfBins()); using L2IType = itk::LabelMapToLabelImageFilter; - auto l2i = L2IType::New(); - itk::SimpleFilterWatcher watcher2(l2i); + auto l2i = L2IType::New(); + const itk::SimpleFilterWatcher watcher2(l2i); l2i->SetInput(i2l->GetOutput()); diff --git a/Modules/Filtering/LabelMap/test/itkLabelMapMaskImageFilterTest.cxx b/Modules/Filtering/LabelMap/test/itkLabelMapMaskImageFilterTest.cxx index 2e3b3d43b7f..1dbfac468e1 100644 --- a/Modules/Filtering/LabelMap/test/itkLabelMapMaskImageFilterTest.cxx +++ b/Modules/Filtering/LabelMap/test/itkLabelMapMaskImageFilterTest.cxx @@ -83,11 +83,11 @@ itkLabelMapMaskImageFilterTest(int argc, char * argv[]) maskFilter->SetFeatureImage(reader2->GetOutput()); - MaskFilterType::InputImagePixelType label = std::stoi(argv[4]); + const MaskFilterType::InputImagePixelType label = std::stoi(argv[4]); maskFilter->SetLabel(label); ITK_TEST_SET_GET_VALUE(label, maskFilter->GetLabel()); - MaskFilterType::OutputImagePixelType backgroundValue = std::stoi(argv[5]); + const MaskFilterType::OutputImagePixelType backgroundValue = std::stoi(argv[5]); maskFilter->SetBackgroundValue(backgroundValue); ITK_TEST_SET_GET_VALUE(backgroundValue, maskFilter->GetBackgroundValue()); @@ -123,7 +123,7 @@ itkLabelMapMaskImageFilterTest(int argc, char * argv[]) maskFilter->SetCropBorder(border); ITK_TEST_SET_GET_VALUE(border, maskFilter->GetCropBorder()); - itk::SimpleFilterWatcher watcher(maskFilter, "LabelMapMaskImageFilter"); + const itk::SimpleFilterWatcher watcher(maskFilter, "LabelMapMaskImageFilter"); // Finally, save the output image. using WriterType = itk::ImageFileWriter; diff --git a/Modules/Filtering/LabelMap/test/itkLabelMapToAttributeImageFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkLabelMapToAttributeImageFilterTest1.cxx index 7c563d6f9e0..d9d7823d709 100644 --- a/Modules/Filtering/LabelMap/test/itkLabelMapToAttributeImageFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkLabelMapToAttributeImageFilterTest1.cxx @@ -71,7 +71,7 @@ itkLabelMapToAttributeImageFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(backgroundValue, l2i->GetBackgroundValue()); l2i->SetInput(i2l->GetOutput()); - itk::SimpleFilterWatcher watcher(l2i, "filter"); + const itk::SimpleFilterWatcher watcher(l2i, "filter"); using WriterType = itk::ImageFileWriter; diff --git a/Modules/Filtering/LabelMap/test/itkLabelMapToBinaryImageFilterTest.cxx b/Modules/Filtering/LabelMap/test/itkLabelMapToBinaryImageFilterTest.cxx index c7f9bd173b5..ba3e20cd89d 100644 --- a/Modules/Filtering/LabelMap/test/itkLabelMapToBinaryImageFilterTest.cxx +++ b/Modules/Filtering/LabelMap/test/itkLabelMapToBinaryImageFilterTest.cxx @@ -65,7 +65,7 @@ itkLabelMapToBinaryImageFilterTest(int argc, char * argv[]) l2i->SetBackgroundValue(std::stoi(argv[4])); ITK_TEST_SET_GET_VALUE(std::stoi(argv[4]), l2i->GetBackgroundValue()); - itk::SimpleFilterWatcher watcher(l2i); + const itk::SimpleFilterWatcher watcher(l2i); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkLabelMapToLabelImageFilterTest.cxx b/Modules/Filtering/LabelMap/test/itkLabelMapToLabelImageFilterTest.cxx index 88e2fe97e9b..743803edd5a 100644 --- a/Modules/Filtering/LabelMap/test/itkLabelMapToLabelImageFilterTest.cxx +++ b/Modules/Filtering/LabelMap/test/itkLabelMapToLabelImageFilterTest.cxx @@ -82,7 +82,7 @@ itkLabelMapToLabelImageFilterTest(int argc, char * argv[]) IndexType index; index[0] = ctrI; index[1] = ctrJ; - unsigned char val = image->GetPixel(index); + const unsigned char val = image->GetPixel(index); if ((ctrI == 5) || (ctrJ == 5)) { itkAssertOrThrowMacro((val == 1), "Error in Label Image."); diff --git a/Modules/Filtering/LabelMap/test/itkLabelObjectLineComparatorTest.cxx b/Modules/Filtering/LabelMap/test/itkLabelObjectLineComparatorTest.cxx index c7f57e463ee..b35bf2885a2 100644 --- a/Modules/Filtering/LabelMap/test/itkLabelObjectLineComparatorTest.cxx +++ b/Modules/Filtering/LabelMap/test/itkLabelObjectLineComparatorTest.cxx @@ -27,7 +27,7 @@ itkLabelObjectLineComparatorTest(int, char *[]) using IndexType = itk::LabelObjectLine<2>::IndexType; using ComparatorType = itk::Functor::LabelObjectLineComparator; - ComparatorType lessThan; + const ComparatorType lessThan; IndexType lowIndex; lowIndex[0] = 3; @@ -37,9 +37,9 @@ itkLabelObjectLineComparatorTest(int, char *[]) highIndex[0] = 14; highIndex[1] = 7; - LabelObjectLineType low(lowIndex, 11); - LabelObjectLineType high(highIndex, 11); - LabelObjectLineType lowlong(lowIndex, 15); + const LabelObjectLineType low(lowIndex, 11); + const LabelObjectLineType high(highIndex, 11); + const LabelObjectLineType lowlong(lowIndex, 15); if (lessThan(high, low)) { diff --git a/Modules/Filtering/LabelMap/test/itkLabelSelectionLabelMapFilterTest.cxx b/Modules/Filtering/LabelMap/test/itkLabelSelectionLabelMapFilterTest.cxx index dfa89ed3534..78b7ff26de5 100644 --- a/Modules/Filtering/LabelMap/test/itkLabelSelectionLabelMapFilterTest.cxx +++ b/Modules/Filtering/LabelMap/test/itkLabelSelectionLabelMapFilterTest.cxx @@ -57,7 +57,7 @@ itkLabelSelectionLabelMapFilterTest(int argc, char * argv[]) change->SetInput(i2l->GetOutput()); change->SetExclude(std::stoi(argv[3])); change->SetLabel(std::stoi(argv[4])); - itk::SimpleFilterWatcher watcher6(change, "filter"); + const itk::SimpleFilterWatcher watcher6(change, "filter"); using L2IType = itk::LabelMapToLabelImageFilter; auto l2i = L2IType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkLabelShapeKeepNObjectsImageFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkLabelShapeKeepNObjectsImageFilterTest1.cxx index 43d29937d2d..90d36151a37 100644 --- a/Modules/Filtering/LabelMap/test/itkLabelShapeKeepNObjectsImageFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkLabelShapeKeepNObjectsImageFilterTest1.cxx @@ -51,12 +51,12 @@ itkLabelShapeKeepNObjectsImageFilterTest1(int argc, char * argv[]) KeepNObjects->SetInput(reader->GetOutput()); // testing get/set BackgroundValue macro - int BackgroundValue = (std::stoi(argv[3])); + const int BackgroundValue = (std::stoi(argv[3])); KeepNObjects->SetBackgroundValue(BackgroundValue); ITK_TEST_SET_GET_VALUE(BackgroundValue, KeepNObjects->GetBackgroundValue()); // testing get and set macros for NumberOfObjects - unsigned int numberOfObjects = std::stoi(argv[4]); + const unsigned int numberOfObjects = std::stoi(argv[4]); KeepNObjects->SetNumberOfObjects(numberOfObjects); ITK_TEST_SET_GET_VALUE(numberOfObjects, KeepNObjects->GetNumberOfObjects()); @@ -68,7 +68,7 @@ itkLabelShapeKeepNObjectsImageFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(false, KeepNObjects->GetReverseOrdering()); // testing get and set macros or ReverseOrdering - bool reverseOrdering = std::stoi(argv[5]); + const bool reverseOrdering = std::stoi(argv[5]); KeepNObjects->SetReverseOrdering(reverseOrdering); ITK_TEST_SET_GET_VALUE(reverseOrdering, KeepNObjects->GetReverseOrdering()); @@ -81,7 +81,7 @@ itkLabelShapeKeepNObjectsImageFilterTest1(int argc, char * argv[]) const LabelKeepNObjectsType::AttributeType attributeByCode = LabelKeepNObjectsType::LabelObjectType::LABEL; ITK_TEST_SET_GET_VALUE(attributeByCode, KeepNObjects->GetAttribute()); - itk::SimpleFilterWatcher watcher(KeepNObjects, "filter"); + const itk::SimpleFilterWatcher watcher(KeepNObjects, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkLabelShapeOpeningImageFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkLabelShapeOpeningImageFilterTest1.cxx index b4bb2366d8b..4171e58716d 100644 --- a/Modules/Filtering/LabelMap/test/itkLabelShapeOpeningImageFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkLabelShapeOpeningImageFilterTest1.cxx @@ -50,22 +50,22 @@ itkLabelShapeOpeningImageFilterTest1(int argc, char * argv[]) opening->SetInput(reader->GetOutput()); - int BackgroundValue = (std::stoi(argv[3])); + const int BackgroundValue = (std::stoi(argv[3])); opening->SetBackgroundValue(BackgroundValue); ITK_TEST_SET_GET_VALUE(BackgroundValue, opening->GetBackgroundValue()); - double lambda = std::stod(argv[4]); + const double lambda = std::stod(argv[4]); opening->SetLambda(lambda); ITK_TEST_SET_GET_VALUE(lambda, opening->GetLambda()); - bool reverseOrdering = std::stoi(argv[5]); + const bool reverseOrdering = std::stoi(argv[5]); ITK_TEST_SET_GET_BOOLEAN(opening, ReverseOrdering, reverseOrdering); - LabelOpeningType::AttributeType attribute = std::stoi(argv[6]); + const LabelOpeningType::AttributeType attribute = std::stoi(argv[6]); opening->SetAttribute(attribute); ITK_TEST_SET_GET_VALUE(attribute, opening->GetAttribute()); - itk::SimpleFilterWatcher watcher(opening, "filter"); + const itk::SimpleFilterWatcher watcher(opening, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkLabelStatisticsKeepNObjectsImageFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkLabelStatisticsKeepNObjectsImageFilterTest1.cxx index 5f58b535ea4..0393627405e 100644 --- a/Modules/Filtering/LabelMap/test/itkLabelStatisticsKeepNObjectsImageFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkLabelStatisticsKeepNObjectsImageFilterTest1.cxx @@ -55,12 +55,12 @@ itkLabelStatisticsKeepNObjectsImageFilterTest1(int argc, char * argv[]) KeepNObjects->SetFeatureImage(reader2->GetOutput()); // testing get/set BackgroundValue macro - int BackgroundValue = (std::stoi(argv[4])); + const int BackgroundValue = (std::stoi(argv[4])); KeepNObjects->SetBackgroundValue(BackgroundValue); ITK_TEST_SET_GET_VALUE(BackgroundValue, KeepNObjects->GetBackgroundValue()); // testing get and set macros for Lambda - unsigned int numberOfObjects = std::stoi(argv[5]); + const unsigned int numberOfObjects = std::stoi(argv[5]); KeepNObjects->SetNumberOfObjects(numberOfObjects); ITK_TEST_SET_GET_VALUE(numberOfObjects, KeepNObjects->GetNumberOfObjects()); @@ -72,16 +72,16 @@ itkLabelStatisticsKeepNObjectsImageFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(false, KeepNObjects->GetReverseOrdering()); // testing get and set macros or ReverseOrdering - bool reverseOrdering = std::stoi(argv[6]); + const bool reverseOrdering = std::stoi(argv[6]); KeepNObjects->SetReverseOrdering(reverseOrdering); ITK_TEST_SET_GET_VALUE(reverseOrdering, KeepNObjects->GetReverseOrdering()); // testing get and set macros for Attribute - LabelKeepNObjectsType::AttributeType attribute = std::stoi(argv[7]); + const LabelKeepNObjectsType::AttributeType attribute = std::stoi(argv[7]); KeepNObjects->SetAttribute(attribute); ITK_TEST_SET_GET_VALUE(attribute, KeepNObjects->GetAttribute()); - itk::SimpleFilterWatcher watcher(KeepNObjects, "filter"); + const itk::SimpleFilterWatcher watcher(KeepNObjects, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkLabelStatisticsOpeningImageFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkLabelStatisticsOpeningImageFilterTest1.cxx index a7c3e85f2d8..28f68aab6f5 100644 --- a/Modules/Filtering/LabelMap/test/itkLabelStatisticsOpeningImageFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkLabelStatisticsOpeningImageFilterTest1.cxx @@ -58,12 +58,12 @@ itkLabelStatisticsOpeningImageFilterTest1(int argc, char * argv[]) opening->SetInput2(reader2->GetOutput()); // testing get/set BackgroundValue macro - int BackgroundValue = (std::stoi(argv[4])); + const int BackgroundValue = (std::stoi(argv[4])); opening->SetBackgroundValue(BackgroundValue); ITK_TEST_SET_GET_VALUE(BackgroundValue, opening->GetBackgroundValue()); // testing get and set macros for Lambda - double lambda = std::stod(argv[5]); + const double lambda = std::stod(argv[5]); opening->SetLambda(lambda); ITK_TEST_SET_GET_VALUE(lambda, opening->GetLambda()); @@ -75,7 +75,7 @@ itkLabelStatisticsOpeningImageFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(false, opening->GetReverseOrdering()); // testing get and set macros or ReverseOrdering - bool reverseOrdering = std::stoi(argv[6]); + const bool reverseOrdering = std::stoi(argv[6]); opening->SetReverseOrdering(reverseOrdering); ITK_TEST_SET_GET_VALUE(reverseOrdering, opening->GetReverseOrdering()); @@ -88,7 +88,7 @@ itkLabelStatisticsOpeningImageFilterTest1(int argc, char * argv[]) const LabelOpeningType::AttributeType attributeByCode = LabelOpeningType::LabelObjectType::LABEL; ITK_TEST_SET_GET_VALUE(attributeByCode, opening->GetAttribute()); - itk::SimpleFilterWatcher watcher(opening, "filter"); + const itk::SimpleFilterWatcher watcher(opening, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkLabelUniqueLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkLabelUniqueLabelMapFilterTest1.cxx index 5b076ac08a6..6c545038dbe 100644 --- a/Modules/Filtering/LabelMap/test/itkLabelUniqueLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkLabelUniqueLabelMapFilterTest1.cxx @@ -71,7 +71,7 @@ itkLabelUniqueLabelMapFilterTest1(int argc, char * argv[]) auto unique = UniqueType::New(); unique->SetInput(oi->GetOutput()); unique->SetReverseOrdering(std::stoi(argv[3])); - itk::SimpleFilterWatcher watcher(unique, "filter"); + const itk::SimpleFilterWatcher watcher(unique, "filter"); using L2IType = itk::LabelMapToLabelImageFilter; auto l2i = L2IType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkMergeLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkMergeLabelMapFilterTest1.cxx index 2076a976c94..b4cc1a8a1cc 100644 --- a/Modules/Filtering/LabelMap/test/itkMergeLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkMergeLabelMapFilterTest1.cxx @@ -81,7 +81,7 @@ itkMergeLabelMapFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(itk::ChoiceMethodEnum::KEEP, change->GetMethod()); change->SetMethod(method); - itk::SimpleFilterWatcher watcher6(change, "filter"); + const itk::SimpleFilterWatcher watcher6(change, "filter"); using L2IType = itk::LabelMapToLabelImageFilter; auto l2i = L2IType::New(); @@ -93,7 +93,7 @@ itkMergeLabelMapFilterTest1(int argc, char * argv[]) writer->SetFileName(argv[3]); writer->UseCompressionOn(); - bool expectfailure = std::stoi(argv[7]); + const bool expectfailure = std::stoi(argv[7]); if (expectfailure) { diff --git a/Modules/Filtering/LabelMap/test/itkObjectByObjectLabelMapFilterTest.cxx b/Modules/Filtering/LabelMap/test/itkObjectByObjectLabelMapFilterTest.cxx index 88968a143ea..1938de00a33 100644 --- a/Modules/Filtering/LabelMap/test/itkObjectByObjectLabelMapFilterTest.cxx +++ b/Modules/Filtering/LabelMap/test/itkObjectByObjectLabelMapFilterTest.cxx @@ -77,18 +77,18 @@ itkObjectByObjectLabelMapFilterTest(int argc, char * argv[]) auto keepLabels = static_cast(std::stoi(argv[3])); ITK_TEST_SET_GET_BOOLEAN(obo, KeepLabels, keepLabels); - bool binaryInternalOutput = static_cast(std::stoi(argv[4])); + const bool binaryInternalOutput = static_cast(std::stoi(argv[4])); ITK_TEST_SET_GET_BOOLEAN(obo, BinaryInternalOutput, binaryInternalOutput); - bool constrainPaddingToImage = static_cast(std::stoi(argv[5])); + const bool constrainPaddingToImage = static_cast(std::stoi(argv[5])); ITK_TEST_SET_GET_BOOLEAN(obo, ConstrainPaddingToImage, constrainPaddingToImage); - ObOType::InternalOutputPixelType internalForegroundValue = + const ObOType::InternalOutputPixelType internalForegroundValue = itk::NumericTraits::max(); obo->SetInternalForegroundValue(internalForegroundValue); ITK_TEST_SET_GET_VALUE(internalForegroundValue, obo->GetInternalForegroundValue()); - itk::SimpleFilterWatcher watcher(obo, "filter"); + const itk::SimpleFilterWatcher watcher(obo, "filter"); using L2IType = itk::LabelMapToLabelImageFilter; auto l2i = L2IType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkPadLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkPadLabelMapFilterTest1.cxx index 98a533e1e51..353f254e074 100644 --- a/Modules/Filtering/LabelMap/test/itkPadLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkPadLabelMapFilterTest1.cxx @@ -70,11 +70,11 @@ itkPadLabelMapFilterTest1(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(padLabelMapFilter, PadLabelMapFilter, ChangeRegionLabelMapFilter); - PadLabelMapFilterType::SizeType upperBoundaryPadSize = { { 0 } }; + const PadLabelMapFilterType::SizeType upperBoundaryPadSize = { { 0 } }; padLabelMapFilter->SetPadSize(upperBoundaryPadSize); ITK_TEST_SET_GET_VALUE(upperBoundaryPadSize, padLabelMapFilter->GetUpperBoundaryPadSize()); - PadLabelMapFilterType::SizeType lowerBoundaryPadSize = { { 0 } }; + const PadLabelMapFilterType::SizeType lowerBoundaryPadSize = { { 0 } }; padLabelMapFilter->SetPadSize(lowerBoundaryPadSize); ITK_TEST_SET_GET_VALUE(upperBoundaryPadSize, padLabelMapFilter->GetLowerBoundaryPadSize()); @@ -87,7 +87,7 @@ itkPadLabelMapFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(size, padLabelMapFilter->GetLowerBoundaryPadSize()); ITK_TEST_SET_GET_VALUE(size, padLabelMapFilter->GetUpperBoundaryPadSize()); - itk::SimpleFilterWatcher watcher(padLabelMapFilter, "filter"); + const itk::SimpleFilterWatcher watcher(padLabelMapFilter, "filter"); ITK_TRY_EXPECT_NO_EXCEPTION(padLabelMapFilter->Update()); diff --git a/Modules/Filtering/LabelMap/test/itkRegionFromReferenceLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkRegionFromReferenceLabelMapFilterTest1.cxx index 8ed434e0cec..dd6823c0ec3 100644 --- a/Modules/Filtering/LabelMap/test/itkRegionFromReferenceLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkRegionFromReferenceLabelMapFilterTest1.cxx @@ -69,7 +69,7 @@ itkRegionFromReferenceLabelMapFilterTest1(int argc, char * argv[]) auto change = ChangeType::New(); change->SetInput(i2l->GetOutput()); change->SetReferenceImage(reader2->GetOutput()); - itk::SimpleFilterWatcher watcher6(change, "filter"); + const itk::SimpleFilterWatcher watcher6(change, "filter"); change->UpdateLargestPossibleRegion(); using L2IType = itk::LabelMapToLabelImageFilter; diff --git a/Modules/Filtering/LabelMap/test/itkRelabelLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkRelabelLabelMapFilterTest1.cxx index 013ac83d79f..6aa11797ce7 100644 --- a/Modules/Filtering/LabelMap/test/itkRelabelLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkRelabelLabelMapFilterTest1.cxx @@ -56,7 +56,7 @@ itkRelabelLabelMapFilterTest1(int argc, char * argv[]) using ChangeType = itk::RelabelLabelMapFilter; auto change = ChangeType::New(); change->SetInput(i2l->GetOutput()); - itk::SimpleFilterWatcher watcher6(change, "filter"); + const itk::SimpleFilterWatcher watcher6(change, "filter"); using L2IType = itk::LabelMapToLabelImageFilter; auto l2i = L2IType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkShapeKeepNObjectsLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkShapeKeepNObjectsLabelMapFilterTest1.cxx index 1e987d45506..ee805a01271 100644 --- a/Modules/Filtering/LabelMap/test/itkShapeKeepNObjectsLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkShapeKeepNObjectsLabelMapFilterTest1.cxx @@ -66,12 +66,12 @@ itkShapeKeepNObjectsLabelMapFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(false, opening->GetReverseOrdering()); // testing get and set macros or ReverseOrdering - bool reverseOrdering = std::stoi(argv[3]); + const bool reverseOrdering = std::stoi(argv[3]); opening->SetReverseOrdering(reverseOrdering); ITK_TEST_SET_GET_VALUE(reverseOrdering, opening->GetReverseOrdering()); // testing get and set macros for Attribute - LabelOpeningType::AttributeType attribute = std::stoi(argv[4]); + const LabelOpeningType::AttributeType attribute = std::stoi(argv[4]); ITK_TRY_EXPECT_NO_EXCEPTION(opening->SetAttribute(attribute)); try { @@ -85,7 +85,7 @@ itkShapeKeepNObjectsLabelMapFilterTest1(int argc, char * argv[]) opening->SetNumberOfObjects(std::stoi(argv[5])); opening->SetInput(i2l->GetOutput()); - itk::SimpleFilterWatcher watcher(opening, "filter"); + const itk::SimpleFilterWatcher watcher(opening, "filter"); using L2IType = itk::LabelMapToLabelImageFilter; auto l2i = L2IType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkShapeLabelMapFilterGTest.cxx b/Modules/Filtering/LabelMap/test/itkShapeLabelMapFilterGTest.cxx index 9ac1df59b6f..20657a0d73c 100644 --- a/Modules/Filtering/LabelMap/test/itkShapeLabelMapFilterGTest.cxx +++ b/Modules/Filtering/LabelMap/test/itkShapeLabelMapFilterGTest.cxx @@ -138,11 +138,11 @@ TEST_F(ShapeLabelMapFixture, 3D_T1x1x1) using Utils = FixtureUtilities<3>; - Utils::ImageType::Pointer image(Utils::CreateImage()); + const Utils::ImageType::Pointer image(Utils::CreateImage()); image->SetPixel(itk::MakeIndex(5, 7, 9), 1); - Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(image); + const Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(image); ITK_EXPECT_VECTOR_NEAR(itk::MakeIndex(5, 7, 9), labelObject->GetBoundingBox().GetIndex(), 1e-99); @@ -180,7 +180,7 @@ TEST_F(ShapeLabelMapFixture, 3D_T3x2x1) using Utils = FixtureUtilities<3>; - Utils::ImageType::Pointer image(Utils::CreateImage()); + const Utils::ImageType::Pointer image(Utils::CreateImage()); for (unsigned int i = 5; i < 8; ++i) { @@ -188,7 +188,7 @@ TEST_F(ShapeLabelMapFixture, 3D_T3x2x1) image->SetPixel(itk::MakeIndex(i, 10, 11), 1); } - Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(image); + const Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(image); ITK_EXPECT_VECTOR_NEAR(itk::MakeIndex(5, 9, 11), labelObject->GetBoundingBox().GetIndex(), 1e-99); @@ -227,7 +227,7 @@ TEST_F(ShapeLabelMapFixture, 3D_T3x2x1_Direction) using Utils = FixtureUtilities<3>; - Utils::ImageType::Pointer image(Utils::CreateImage()); + const Utils::ImageType::Pointer image(Utils::CreateImage()); for (unsigned int i = 5; i < 8; ++i) { @@ -245,7 +245,7 @@ TEST_F(ShapeLabelMapFixture, 3D_T3x2x1_Direction) image->SetDirection(direction); - Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(image); + const Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(image); ITK_EXPECT_VECTOR_NEAR(itk::MakeIndex(5, 9, 11), labelObject->GetBoundingBox().GetIndex(), 1e-99); @@ -283,7 +283,7 @@ TEST_F(ShapeLabelMapFixture, 3D_T2x2x2_Spacing) using Utils = FixtureUtilities<3>; - Utils::ImageType::Pointer image(Utils::CreateImage()); + const Utils::ImageType::Pointer image(Utils::CreateImage()); for (unsigned int i = 0; i < 2; ++i) { @@ -296,7 +296,7 @@ TEST_F(ShapeLabelMapFixture, 3D_T2x2x2_Spacing) image->SetSpacing(itk::MakeVector(1.0, 1.1, 2.2)); - Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(image); + const Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(image); ITK_EXPECT_VECTOR_NEAR(itk::MakeIndex(5, 9, 11), labelObject->GetBoundingBox().GetIndex(), 1e-99); @@ -337,7 +337,7 @@ TEST_F(ShapeLabelMapFixture, 3D_T2x2x2_Spacing_Direction) using Utils = FixtureUtilities<3>; - Utils::ImageType::Pointer image(Utils::CreateImage()); + const Utils::ImageType::Pointer image(Utils::CreateImage()); DirectionType direction; @@ -360,7 +360,7 @@ TEST_F(ShapeLabelMapFixture, 3D_T2x2x2_Spacing_Direction) image->SetSpacing(itk::MakeVector(1.0, 1.1, 2.2)); - Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(image); + const Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(image); ITK_EXPECT_VECTOR_NEAR(itk::MakeIndex(5, 9, 11), labelObject->GetBoundingBox().GetIndex(), 1e-99); @@ -400,11 +400,11 @@ TEST_F(ShapeLabelMapFixture, 2D_T1x1) using Utils = FixtureUtilities<2>; - Utils::ImageType::Pointer image(Utils::CreateImage()); + const Utils::ImageType::Pointer image(Utils::CreateImage()); image->SetPixel(itk::MakeIndex(5, 7), 1); - Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(image); + const Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(image); ITK_EXPECT_VECTOR_NEAR(itk::MakeVector(1.0, 1.0), labelObject->GetOrientedBoundingBoxSize(), 1e-10); ITK_EXPECT_VECTOR_NEAR(itk::MakePoint(4.5, 6.5), labelObject->GetOrientedBoundingBoxOrigin(), 1e-4); @@ -422,12 +422,12 @@ TEST_F(ShapeLabelMapFixture, 2D_T1_1) using Utils = FixtureUtilities<2>; - Utils::ImageType::Pointer image(Utils::CreateImage()); + const Utils::ImageType::Pointer image(Utils::CreateImage()); image->SetPixel(itk::MakeIndex(5, 7), 1); image->SetPixel(itk::MakeIndex(6, 8), 1); - Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(image); + const Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(image); ITK_EXPECT_VECTOR_NEAR(itk::MakeSize(2, 2), labelObject->GetBoundingBox().GetSize(), 1e-99); ITK_EXPECT_VECTOR_NEAR( @@ -447,7 +447,7 @@ TEST_F(ShapeLabelMapFixture, 2D_T1_1_FlipDirection) using Utils = FixtureUtilities<2>; - Utils::ImageType::Pointer image(Utils::CreateImage()); + const Utils::ImageType::Pointer image(Utils::CreateImage()); image->SetPixel(itk::MakeIndex(5, 7), 1); image->SetPixel(itk::MakeIndex(6, 8), 1); @@ -461,7 +461,7 @@ TEST_F(ShapeLabelMapFixture, 2D_T1_1_FlipDirection) image->SetDirection(direction); - Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(image); + const Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(image); ITK_EXPECT_VECTOR_NEAR( itk::MakeVector(Math::sqrt2, 2.0 * Math::sqrt2), labelObject->GetOrientedBoundingBoxSize(), 1e-4); @@ -481,7 +481,7 @@ TEST_F(ShapeLabelMapFixture, 2D_T1_2_Direction) using Utils = FixtureUtilities<2>; - Utils::ImageType::Pointer image(Utils::CreateImage()); + const Utils::ImageType::Pointer image(Utils::CreateImage()); image->SetPixel(itk::MakeIndex(5, 7), 1); image->SetPixel(itk::MakeIndex(5, 8), 1); @@ -495,7 +495,7 @@ TEST_F(ShapeLabelMapFixture, 2D_T1_2_Direction) image->SetDirection(direction); - Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(image); + const Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(image); auto obbVertices = labelObject->GetOrientedBoundingBoxVertices(); @@ -521,7 +521,7 @@ TEST_F(ShapeLabelMapFixture, 2D_T2x4) using Utils = FixtureUtilities<2>; - Utils::ImageType::Pointer image(Utils::CreateImage()); + const Utils::ImageType::Pointer image(Utils::CreateImage()); for (unsigned int i = 4; i < 6; ++i) { @@ -531,7 +531,7 @@ TEST_F(ShapeLabelMapFixture, 2D_T2x4) } } - Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(image); + const Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(image); ITK_EXPECT_VECTOR_NEAR(itk::MakeVector(2.0, 4.0), labelObject->GetOrientedBoundingBoxSize(), 1e-10); ITK_EXPECT_VECTOR_NEAR(itk::MakePoint(3.5, 2.5), labelObject->GetOrientedBoundingBoxOrigin(), 1e-4); diff --git a/Modules/Filtering/LabelMap/test/itkShapeLabelObjectAccessorsTest1.cxx b/Modules/Filtering/LabelMap/test/itkShapeLabelObjectAccessorsTest1.cxx index 1aba8fbc10c..db1bb76423e 100644 --- a/Modules/Filtering/LabelMap/test/itkShapeLabelObjectAccessorsTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkShapeLabelObjectAccessorsTest1.cxx @@ -251,112 +251,113 @@ itkShapeLabelObjectAccessorsTest1(int argc, char * argv[]) for (unsigned int n = 0; n < labelMap->GetNumberOfLabelObjects(); ++n) { - itk::Functor::LabelLabelObjectAccessor accessorLabel; - ShapeLabelObjectType * l = labelMap->GetNthLabelObject(n); + const itk::Functor::LabelLabelObjectAccessor accessorLabel; + ShapeLabelObjectType * l = labelMap->GetNthLabelObject(n); if (l->GetLabel() != accessorLabel(l)) { std::cout << "l->GetLabel2() != accessorLabel(l)" << std::endl; status = EXIT_FAILURE; } - itk::Functor::BoundingBoxLabelObjectAccessor accessorBoundingBox; + const itk::Functor::BoundingBoxLabelObjectAccessor accessorBoundingBox; if (l->GetBoundingBox() != accessorBoundingBox(l)) { std::cout << "l->GetBoundingBox() != accessorBoundingBox(l)" << std::endl; status = EXIT_FAILURE; } - itk::Functor::NumberOfPixelsLabelObjectAccessor accessorSize; + const itk::Functor::NumberOfPixelsLabelObjectAccessor accessorSize; if (l->GetNumberOfPixels() != accessorSize(l)) { std::cout << "l->GetNumberOfPixels() != accessorSize(l)" << std::endl; status = EXIT_FAILURE; } - itk::Functor::PhysicalSizeLabelObjectAccessor accessorPhysicalSize; + const itk::Functor::PhysicalSizeLabelObjectAccessor accessorPhysicalSize; if (itk::Math::NotExactlyEquals(l->GetPhysicalSize(), accessorPhysicalSize(l))) { std::cout << "l->GetPhysicalSize() != accessorPhysicalSize(l)" << std::endl; status = EXIT_FAILURE; } - itk::Functor::CentroidLabelObjectAccessor accessorCentroid; + const itk::Functor::CentroidLabelObjectAccessor accessorCentroid; if (l->GetCentroid() != accessorCentroid(l)) { std::cout << "l->GetCentroid() != accessorCentroid(l)" << std::endl; status = EXIT_FAILURE; } - itk::Functor::NumberOfPixelsOnBorderLabelObjectAccessor accessorSizeOnBorder; + const itk::Functor::NumberOfPixelsOnBorderLabelObjectAccessor accessorSizeOnBorder; if (l->GetNumberOfPixelsOnBorder() != accessorSizeOnBorder(l)) { std::cout << "l->GetNumberOfPixelsOnBorder() != accessorSizeOnBorder(l)" << std::endl; status = EXIT_FAILURE; } - itk::Functor::PerimeterOnBorderLabelObjectAccessor accessorPerimeterOnBorder; + const itk::Functor::PerimeterOnBorderLabelObjectAccessor accessorPerimeterOnBorder; if (itk::Math::NotExactlyEquals(l->GetPerimeterOnBorder(), accessorPerimeterOnBorder(l))) { std::cout << "l->GetPerimeterOnBorder() != accessorPerimeterOnBorder(l)" << std::endl; status = EXIT_FAILURE; } - itk::Functor::FeretDiameterLabelObjectAccessor accessorFeretDiameter; + const itk::Functor::FeretDiameterLabelObjectAccessor accessorFeretDiameter; if (itk::Math::NotExactlyEquals(l->GetFeretDiameter(), accessorFeretDiameter(l))) { std::cout << "l->GetFeretDiameter() != accessorFeretDiameter(l)" << std::endl; status = EXIT_FAILURE; } - itk::Functor::PrincipalMomentsLabelObjectAccessor accessorPrincipalMoments; + const itk::Functor::PrincipalMomentsLabelObjectAccessor accessorPrincipalMoments; if (l->GetPrincipalMoments() != accessorPrincipalMoments(l)) { std::cout << "l->GetPrincipalMoments() != accessorPrincipalMoments(l)" << std::endl; status = EXIT_FAILURE; } - itk::Functor::PrincipalAxesLabelObjectAccessor accessorPrincipalAxes; + const itk::Functor::PrincipalAxesLabelObjectAccessor accessorPrincipalAxes; if (l->GetPrincipalAxes() != accessorPrincipalAxes(l)) { std::cout << "l->GetPrincipalAxes() != accessorPrincipalAxes(l)" << std::endl; status = EXIT_FAILURE; } - itk::Functor::ElongationLabelObjectAccessor accessorElongation; + const itk::Functor::ElongationLabelObjectAccessor accessorElongation; if (itk::Math::NotExactlyEquals(l->GetElongation(), accessorElongation(l))) { std::cout << "l->GetElongation() != accessorElongation(l)" << std::endl; status = EXIT_FAILURE; } - itk::Functor::PerimeterLabelObjectAccessor accessorPerimeter; + const itk::Functor::PerimeterLabelObjectAccessor accessorPerimeter; if (itk::Math::NotExactlyEquals(l->GetPerimeter(), accessorPerimeter(l))) { std::cout << "l->GetPerimeter() != accessorPerimeter(l)" << std::endl; status = EXIT_FAILURE; } - itk::Functor::RoundnessLabelObjectAccessor accessorRoundness; + const itk::Functor::RoundnessLabelObjectAccessor accessorRoundness; if (itk::Math::NotExactlyEquals(l->GetRoundness(), accessorRoundness(l))) { std::cout << "l->GetRoundness() != accessorRoundness(l)" << std::endl; status = EXIT_FAILURE; } - itk::Functor::EquivalentSphericalRadiusLabelObjectAccessor accessorEquivalentSphericalRadius; + const itk::Functor::EquivalentSphericalRadiusLabelObjectAccessor + accessorEquivalentSphericalRadius; if (itk::Math::NotExactlyEquals(l->GetEquivalentSphericalRadius(), accessorEquivalentSphericalRadius(l))) { std::cout << "l->GetEquivalentSphericalRadius() != accessorEquivalentSphericalRadius(l)" << std::endl; status = EXIT_FAILURE; } - itk::Functor::EquivalentSphericalPerimeterLabelObjectAccessor + const itk::Functor::EquivalentSphericalPerimeterLabelObjectAccessor accessorEquivalentSphericalPerimeter; if (itk::Math::NotExactlyEquals(l->GetEquivalentSphericalPerimeter(), accessorEquivalentSphericalPerimeter(l))) { std::cout << "l->GetEquivalentSphericalPerimeter() != accessorEquivalentSphericalPerimeter(l)" << std::endl; status = EXIT_FAILURE; } - itk::Functor::EquivalentEllipsoidDiameterLabelObjectAccessor + const itk::Functor::EquivalentEllipsoidDiameterLabelObjectAccessor accessorEquivalentEllipsoidDiameter; if (l->GetEquivalentEllipsoidDiameter() != accessorEquivalentEllipsoidDiameter(l)) { std::cout << "l->GetEquivalentEllipsoidDiameter() != accessorEquivalentEllipsoidDiameter(l)" << std::endl; status = EXIT_FAILURE; } - itk::Functor::FlatnessLabelObjectAccessor accessorFlatness; + const itk::Functor::FlatnessLabelObjectAccessor accessorFlatness; if (itk::Math::NotExactlyEquals(l->GetFlatness(), accessorFlatness(l))) { std::cout << "l->GetFlatness() != accessorFlatness(l)" << std::endl; status = EXIT_FAILURE; } - itk::Functor::PerimeterOnBorderRatioLabelObjectAccessor accessorPerimeterOnBorderRatio; + const itk::Functor::PerimeterOnBorderRatioLabelObjectAccessor accessorPerimeterOnBorderRatio; if (itk::Math::NotExactlyEquals(l->GetPerimeterOnBorderRatio(), accessorPerimeterOnBorderRatio(l))) { std::cout << "l->GetPerimeterOnBorderRatio() != accessorPerimeterOnBorderRatio(l)" << std::endl; @@ -375,12 +376,14 @@ itkShapeLabelObjectAccessorsTest1(int argc, char * argv[]) // Check transforms for (unsigned int n = 0; n < labelMap->GetNumberOfLabelObjects(); ++n) { - ShapeLabelObjectType * l = labelMap->GetNthLabelObject(n); - ShapeLabelObjectType::AffineTransformPointer principleToPhysical = l->GetPrincipalAxesToPhysicalAxesTransform(); + ShapeLabelObjectType * l = labelMap->GetNthLabelObject(n); + const ShapeLabelObjectType::AffineTransformPointer principleToPhysical = + l->GetPrincipalAxesToPhysicalAxesTransform(); std::cout << "Print principleToPhysical " << n << std::endl; principleToPhysical->Print(std::cout); - ShapeLabelObjectType::AffineTransformPointer physicalToPrinciple = l->GetPhysicalAxesToPrincipalAxesTransform(); + const ShapeLabelObjectType::AffineTransformPointer physicalToPrinciple = + l->GetPhysicalAxesToPrincipalAxesTransform(); std::cout << "Print physicalToPrinciple " << n << std::endl; physicalToPrinciple->Print(std::cout); } diff --git a/Modules/Filtering/LabelMap/test/itkShapeOpeningLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkShapeOpeningLabelMapFilterTest1.cxx index 5bd6311d497..0889c26da82 100644 --- a/Modules/Filtering/LabelMap/test/itkShapeOpeningLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkShapeOpeningLabelMapFilterTest1.cxx @@ -61,12 +61,12 @@ itkShapeOpeningLabelMapFilterTest1(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(opening, ShapeOpeningLabelMapFilter, InPlaceLabelMapFilter); // testing get and set macros for Lambda - double lambda = std::stod(argv[3]); + const double lambda = std::stod(argv[3]); opening->SetLambda(lambda); ITK_TEST_SET_GET_VALUE(lambda, opening->GetLambda()); // testing get and set macros for ReverseOrdering - bool reverseOrdering = std::stoi(argv[4]); + const bool reverseOrdering = std::stoi(argv[4]); opening->SetReverseOrdering(reverseOrdering); ITK_TEST_SET_GET_VALUE(reverseOrdering, opening->GetReverseOrdering()); @@ -78,13 +78,13 @@ itkShapeOpeningLabelMapFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(false, opening->GetReverseOrdering()); // testing get and set macros for Attribute - LabelOpeningType::AttributeType attribute = std::stoi(argv[5]); + const LabelOpeningType::AttributeType attribute = std::stoi(argv[5]); opening->SetAttribute(attribute); ITK_TEST_SET_GET_VALUE(attribute, opening->GetAttribute()); opening->SetInput(i2l->GetOutput()); - itk::SimpleFilterWatcher watcher(opening, "filter"); + const itk::SimpleFilterWatcher watcher(opening, "filter"); using L2IType = itk::LabelMapToLabelImageFilter; auto l2i = L2IType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkShapePositionLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkShapePositionLabelMapFilterTest1.cxx index 02f2c0da811..0524706f448 100644 --- a/Modules/Filtering/LabelMap/test/itkShapePositionLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkShapePositionLabelMapFilterTest1.cxx @@ -57,14 +57,14 @@ itkShapePositionLabelMapFilterTest1(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(opening, ShapePositionLabelMapFilter, InPlaceLabelMapFilter); - std::string attribute = argv[3]; + const std::string attribute = argv[3]; opening->SetAttribute(attribute); - typename OpeningType::AttributeType attributeStr = opening->GetAttribute(); + const typename OpeningType::AttributeType attributeStr = opening->GetAttribute(); ITK_TEST_SET_GET_VALUE(attributeStr, opening->GetAttribute()); opening->SetInput(i2l->GetOutput()); - itk::SimpleFilterWatcher watcher(opening, "filter"); + const itk::SimpleFilterWatcher watcher(opening, "filter"); // the label map is then converted back to an label image. using L2IType = itk::LabelMapToLabelImageFilter; diff --git a/Modules/Filtering/LabelMap/test/itkShapeRelabelImageFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkShapeRelabelImageFilterTest1.cxx index 7c6f55653d9..84c757d93e5 100644 --- a/Modules/Filtering/LabelMap/test/itkShapeRelabelImageFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkShapeRelabelImageFilterTest1.cxx @@ -50,7 +50,7 @@ itkShapeRelabelImageFilterTest1(int argc, char * argv[]) opening->SetInput(reader->GetOutput()); // testing get/set BackgroundValue macro - int BackgroundValue = (std::stoi(argv[3])); + const int BackgroundValue = (std::stoi(argv[3])); opening->SetBackgroundValue(BackgroundValue); ITK_TEST_SET_GET_VALUE(BackgroundValue, opening->GetBackgroundValue()); @@ -62,7 +62,7 @@ itkShapeRelabelImageFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(false, opening->GetReverseOrdering()); // testing get and set macros or ReverseOrdering - bool reverseOrdering = std::stoi(argv[4]); + const bool reverseOrdering = std::stoi(argv[4]); opening->SetReverseOrdering(reverseOrdering); ITK_TEST_SET_GET_VALUE(reverseOrdering, opening->GetReverseOrdering()); @@ -75,7 +75,7 @@ itkShapeRelabelImageFilterTest1(int argc, char * argv[]) const RelabelType::AttributeType attributeByCode = RelabelType::LabelObjectType::LABEL; ITK_TEST_SET_GET_VALUE(attributeByCode, opening->GetAttribute()); - itk::SimpleFilterWatcher watcher(opening, "filter"); + const itk::SimpleFilterWatcher watcher(opening, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkShapeRelabelLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkShapeRelabelLabelMapFilterTest1.cxx index 20c1e759794..022539af7a5 100644 --- a/Modules/Filtering/LabelMap/test/itkShapeRelabelLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkShapeRelabelLabelMapFilterTest1.cxx @@ -61,7 +61,7 @@ itkShapeRelabelLabelMapFilterTest1(int argc, char * argv[]) auto relabel = RelabelType::New(); // testing get and set macros for ReverseOrdering - bool reverseOrdering = std::stoi(argv[3]); + const bool reverseOrdering = std::stoi(argv[3]); relabel->SetReverseOrdering(reverseOrdering); ITK_TEST_SET_GET_VALUE(reverseOrdering, relabel->GetReverseOrdering()); @@ -73,16 +73,16 @@ itkShapeRelabelLabelMapFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(true, relabel->GetReverseOrdering()); // testing get and set macros for Attribute - unsigned int attribute = std::stoi(argv[4]); + const unsigned int attribute = std::stoi(argv[4]); relabel->SetAttribute(attribute); ITK_TEST_SET_GET_VALUE(attribute, relabel->GetAttribute()); - std::string attributeName = ShapeLabelObjectType::GetNameFromAttribute(attribute); + const std::string attributeName = ShapeLabelObjectType::GetNameFromAttribute(attribute); relabel->SetAttribute(attributeName); relabel->SetInput(i2l->GetOutput()); - itk::SimpleFilterWatcher watcher(relabel, "filter"); + const itk::SimpleFilterWatcher watcher(relabel, "filter"); using L2ImageType = itk::LabelMapToLabelImageFilter; auto l2i = L2ImageType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkShapeUniqueLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkShapeUniqueLabelMapFilterTest1.cxx index 41f1ffc4411..dae142d011a 100644 --- a/Modules/Filtering/LabelMap/test/itkShapeUniqueLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkShapeUniqueLabelMapFilterTest1.cxx @@ -59,7 +59,7 @@ itkShapeUniqueLabelMapFilterTest1(int argc, char * argv[]) auto Unique = LabelUniqueType::New(); // testing get and set macros for ReverseOrdering - bool reverseOrdering = std::stoi(argv[3]); + const bool reverseOrdering = std::stoi(argv[3]); Unique->SetReverseOrdering(reverseOrdering); ITK_TEST_SET_GET_VALUE(reverseOrdering, Unique->GetReverseOrdering()); @@ -71,13 +71,13 @@ itkShapeUniqueLabelMapFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(false, Unique->GetReverseOrdering()); // testing get and set macros for Attribute - LabelUniqueType::AttributeType attribute = std::stoi(argv[4]); + const LabelUniqueType::AttributeType attribute = std::stoi(argv[4]); Unique->SetAttribute(attribute); ITK_TEST_SET_GET_VALUE(attribute, Unique->GetAttribute()); Unique->SetInput(i2l->GetOutput()); - itk::SimpleFilterWatcher watcher(Unique, "filter"); + const itk::SimpleFilterWatcher watcher(Unique, "filter"); using L2IType = itk::LabelMapToLabelImageFilter; auto l2i = L2IType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkShiftLabelObjectTest.cxx b/Modules/Filtering/LabelMap/test/itkShiftLabelObjectTest.cxx index 72b06193329..b6f1bbbea15 100644 --- a/Modules/Filtering/LabelMap/test/itkShiftLabelObjectTest.cxx +++ b/Modules/Filtering/LabelMap/test/itkShiftLabelObjectTest.cxx @@ -86,7 +86,7 @@ itkShiftLabelObjectTest(int argc, char * argv[]) IndexType index; index[0] = ctrI; index[1] = ctrJ; - unsigned long val = map->GetPixel(index); + const unsigned long val = map->GetPixel(index); std::cout << "Pixel[" << ctrI << ',' << ctrJ << "]: " << val << std::endl; if ((ctrI == 5) || (ctrJ == 5)) { diff --git a/Modules/Filtering/LabelMap/test/itkShiftScaleLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkShiftScaleLabelMapFilterTest1.cxx index 308336a66e0..6cd5bc811af 100644 --- a/Modules/Filtering/LabelMap/test/itkShiftScaleLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkShiftScaleLabelMapFilterTest1.cxx @@ -87,7 +87,7 @@ itkShiftScaleLabelMapFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(true, change->GetChangeBackgroundValue()); - itk::SimpleFilterWatcher watcher6(change, "filter"); + const itk::SimpleFilterWatcher watcher6(change, "filter"); using L2IType = itk::LabelMapToLabelImageFilter; auto l2i = L2IType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkStatisticsKeepNObjectsLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkStatisticsKeepNObjectsLabelMapFilterTest1.cxx index 6e5388c4b7a..8444a908ab9 100644 --- a/Modules/Filtering/LabelMap/test/itkStatisticsKeepNObjectsLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkStatisticsKeepNObjectsLabelMapFilterTest1.cxx @@ -73,19 +73,19 @@ itkStatisticsKeepNObjectsLabelMapFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(false, opening->GetReverseOrdering()); // testing get and set macros or ReverseOrdering - bool reverseOrdering = std::stoi(argv[4]); + const bool reverseOrdering = std::stoi(argv[4]); opening->SetReverseOrdering(reverseOrdering); ITK_TEST_SET_GET_VALUE(reverseOrdering, opening->GetReverseOrdering()); // testing get and set macros for Attribute - LabelOpeningType::AttributeType attribute = std::stoi(argv[5]); + const LabelOpeningType::AttributeType attribute = std::stoi(argv[5]); opening->SetAttribute(attribute); ITK_TEST_SET_GET_VALUE(attribute, opening->GetAttribute()); opening->SetNumberOfObjects(std::stoi(argv[6])); opening->SetInput(i2l->GetOutput()); - itk::SimpleFilterWatcher watcher(opening, "filter"); + const itk::SimpleFilterWatcher watcher(opening, "filter"); using L2IType = itk::LabelMapToLabelImageFilter; auto l2i = L2IType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkStatisticsLabelMapFilterGTest.cxx b/Modules/Filtering/LabelMap/test/itkStatisticsLabelMapFilterGTest.cxx index 6d766b1c0bb..353298dd1b5 100644 --- a/Modules/Filtering/LabelMap/test/itkStatisticsLabelMapFilterGTest.cxx +++ b/Modules/Filtering/LabelMap/test/itkStatisticsLabelMapFilterGTest.cxx @@ -164,11 +164,11 @@ TEST_F(StatisticsLabelMapFixture, 2D_zero) auto image = Utils::CreateImage(); auto labelImage = Utils ::CreateLabelImage(); - Utils::LabelPixelType label = 1; + const Utils::LabelPixelType label = 1; labelImage->FillBuffer(label); - Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(labelImage, image, 1, 1 << 8); + const Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(labelImage, image, 1, 1 << 8); ASSERT_GT(labelObject->Size(), 0); EXPECT_NEAR(0.0, labelObject->GetMinimum(), 1e-12); @@ -190,8 +190,8 @@ TEST_F(StatisticsLabelMapFixture, 2D_ones_with_outliers) using Utils = FixtureUtilities<2, short>; using namespace itk::GTest::TypedefsAndConstructors::Dimension2; - auto image = Utils::CreateImage(); - Utils::PixelType value = 1; + auto image = Utils::CreateImage(); + const Utils::PixelType value = 1; image->FillBuffer(value); // Test with outliers outside the label. @@ -199,13 +199,13 @@ TEST_F(StatisticsLabelMapFixture, 2D_ones_with_outliers) image->SetPixel(itk::MakeIndex(0, 1), -32000); - auto labelImage = Utils ::CreateLabelImage(); - Utils::LabelPixelType label = 1; + auto labelImage = Utils ::CreateLabelImage(); + const Utils::LabelPixelType label = 1; labelImage->FillBuffer(label); labelImage->SetPixel(itk::MakeIndex(0, 0), 0); labelImage->SetPixel(itk::MakeIndex(0, 1), 0); - Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(labelImage, image, label, 1 << 16); + const Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(labelImage, image, label, 1 << 16); ASSERT_GT(labelObject->Size(), 0); EXPECT_NEAR(value, labelObject->GetMinimum(), 1e-12); @@ -236,13 +236,13 @@ TEST_F(StatisticsLabelMapFixture, 2D_rand_with_outliers) image->SetPixel(itk::MakeIndex(0, 2), 0); image->SetPixel(itk::MakeIndex(0, 3), 500); - Utils::LabelPixelType label = 1; + const Utils::LabelPixelType label = 1; labelImage->FillBuffer(label); labelImage->SetPixel(itk::MakeIndex(0, 0), 0); labelImage->SetPixel(itk::MakeIndex(0, 1), 0); - Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(labelImage, image, label, 1 << 16); + const Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(labelImage, image, label, 1 << 16); ASSERT_GT(labelObject->Size(), 0); EXPECT_NEAR(0.0, labelObject->GetMinimum(), 1e-12); @@ -270,14 +270,14 @@ TEST_F(StatisticsLabelMapFixture, 2D_even) image->SetPixel(itk::MakeIndex(0, 2), 1); image->SetPixel(itk::MakeIndex(0, 3), 200); - Utils::LabelPixelType label = 1; + const Utils::LabelPixelType label = 1; labelImage->SetPixel(itk::MakeIndex(0, 0), label); labelImage->SetPixel(itk::MakeIndex(0, 1), label); labelImage->SetPixel(itk::MakeIndex(0, 2), label); labelImage->SetPixel(itk::MakeIndex(0, 3), label); - Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(labelImage, image, label, 1 << 8); + const Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(labelImage, image, label, 1 << 8); ASSERT_GT(labelObject->Size(), 0); EXPECT_NEAR(1.0, labelObject->GetMinimum(), 1e-12); @@ -307,13 +307,13 @@ TEST_F(StatisticsLabelMapFixture, 2D_three) image->SetPixel(itk::MakeIndex(0, 1), 3); image->SetPixel(itk::MakeIndex(0, 2), 10); - Utils::LabelPixelType label = 1; + const Utils::LabelPixelType label = 1; labelImage->SetPixel(itk::MakeIndex(0, 0), label); labelImage->SetPixel(itk::MakeIndex(0, 1), label); labelImage->SetPixel(itk::MakeIndex(0, 2), label); - Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(labelImage, image, label, 1 << 8); + const Utils::LabelObjectType::ConstPointer labelObject = Utils::ComputeLabelObject(labelImage, image, label, 1 << 8); ASSERT_GT(labelObject->Size(), 0); EXPECT_NEAR(1.0, labelObject->GetMinimum(), 1e-12); diff --git a/Modules/Filtering/LabelMap/test/itkStatisticsOpeningLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkStatisticsOpeningLabelMapFilterTest1.cxx index 3cddb987561..b85c1fd8bf3 100644 --- a/Modules/Filtering/LabelMap/test/itkStatisticsOpeningLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkStatisticsOpeningLabelMapFilterTest1.cxx @@ -66,12 +66,12 @@ itkStatisticsOpeningLabelMapFilterTest1(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(opening, StatisticsOpeningLabelMapFilter, ShapeOpeningLabelMapFilter); // Testing get and set macros for Lambda - double lambda = std::stod(argv[4]); + const double lambda = std::stod(argv[4]); opening->SetLambda(lambda); ITK_TEST_SET_GET_VALUE(lambda, opening->GetLambda()); // Testing get and set macros for ReverseOrdering - bool reverseOrdering = std::stoi(argv[5]); + const bool reverseOrdering = std::stoi(argv[5]); opening->SetReverseOrdering(reverseOrdering); ITK_TEST_SET_GET_VALUE(reverseOrdering, opening->GetReverseOrdering()); @@ -83,13 +83,13 @@ itkStatisticsOpeningLabelMapFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(false, opening->GetReverseOrdering()); // Testing get and set macros for Attribute - LabelOpeningType::AttributeType attribute = std::stoi(argv[6]); + const LabelOpeningType::AttributeType attribute = std::stoi(argv[6]); opening->SetAttribute(attribute); ITK_TEST_SET_GET_VALUE(attribute, opening->GetAttribute()); opening->SetInput(i2l->GetOutput()); - itk::SimpleFilterWatcher watcher(opening, "filter"); + const itk::SimpleFilterWatcher watcher(opening, "filter"); using L2IType = itk::LabelMapToLabelImageFilter; auto l2i = L2IType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkStatisticsPositionLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkStatisticsPositionLabelMapFilterTest1.cxx index 2963bedc704..9137a4494a9 100644 --- a/Modules/Filtering/LabelMap/test/itkStatisticsPositionLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkStatisticsPositionLabelMapFilterTest1.cxx @@ -64,7 +64,7 @@ itkStatisticsPositionLabelMapFilterTest1(int argc, char * argv[]) opening->SetInput(i2l->GetOutput()); opening->SetAttribute(argv[4]); - itk::SimpleFilterWatcher watcher(opening, "filter"); + const itk::SimpleFilterWatcher watcher(opening, "filter"); // the label map is then converted back to an label image. using L2IType = itk::LabelMapToLabelImageFilter; diff --git a/Modules/Filtering/LabelMap/test/itkStatisticsRelabelImageFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkStatisticsRelabelImageFilterTest1.cxx index ba6341dc2d9..2d939a224c5 100644 --- a/Modules/Filtering/LabelMap/test/itkStatisticsRelabelImageFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkStatisticsRelabelImageFilterTest1.cxx @@ -55,7 +55,7 @@ itkStatisticsRelabelImageFilterTest1(int argc, char * argv[]) statisticsRelabel->SetFeatureImage(reader2->GetOutput()); // testing get/set BackgroundValue macro - int BackgroundValue = (std::stoi(argv[4])); + const int BackgroundValue = (std::stoi(argv[4])); statisticsRelabel->SetBackgroundValue(BackgroundValue); ITK_TEST_SET_GET_VALUE(BackgroundValue, statisticsRelabel->GetBackgroundValue()); @@ -67,16 +67,16 @@ itkStatisticsRelabelImageFilterTest1(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(false, statisticsRelabel->GetReverseOrdering()); // testing get and set macros or ReverseOrdering - bool reverseOrdering = std::stoi(argv[5]); + const bool reverseOrdering = std::stoi(argv[5]); statisticsRelabel->SetReverseOrdering(reverseOrdering); ITK_TEST_SET_GET_VALUE(reverseOrdering, statisticsRelabel->GetReverseOrdering()); // testing get and set macros for Attribute - RelabelType::AttributeType attribute = std::stoi(argv[6]); + const RelabelType::AttributeType attribute = std::stoi(argv[6]); statisticsRelabel->SetAttribute(attribute); ITK_TEST_SET_GET_VALUE(attribute, statisticsRelabel->GetAttribute()); - itk::SimpleFilterWatcher watcher(statisticsRelabel, "filter"); + const itk::SimpleFilterWatcher watcher(statisticsRelabel, "filter"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkStatisticsRelabelLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkStatisticsRelabelLabelMapFilterTest1.cxx index a6c81e547ca..2833d84f03c 100644 --- a/Modules/Filtering/LabelMap/test/itkStatisticsRelabelLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkStatisticsRelabelLabelMapFilterTest1.cxx @@ -66,20 +66,20 @@ itkStatisticsRelabelLabelMapFilterTest1(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(relabel, StatisticsRelabelLabelMapFilter, ShapeRelabelLabelMapFilter); - bool reverseOrdering = std::stoi(argv[4]); + const bool reverseOrdering = std::stoi(argv[4]); relabel->SetReverseOrdering(reverseOrdering); ITK_TEST_SET_GET_BOOLEAN(relabel, ReverseOrdering, reverseOrdering); - unsigned int attribute = std::stoi(argv[5]); + const unsigned int attribute = std::stoi(argv[5]); relabel->SetAttribute(attribute); ITK_TEST_SET_GET_VALUE(attribute, relabel->GetAttribute()); - std::string attributeName = StatisticsLabelObjectType::GetNameFromAttribute(attribute); + const std::string attributeName = StatisticsLabelObjectType::GetNameFromAttribute(attribute); relabel->SetAttribute(attributeName); relabel->SetInput(i2l->GetOutput()); - itk::SimpleFilterWatcher watcher(relabel, "filter"); + const itk::SimpleFilterWatcher watcher(relabel, "filter"); using L2ImageType = itk::LabelMapToLabelImageFilter; auto l2i = L2ImageType::New(); diff --git a/Modules/Filtering/LabelMap/test/itkStatisticsUniqueLabelMapFilterTest1.cxx b/Modules/Filtering/LabelMap/test/itkStatisticsUniqueLabelMapFilterTest1.cxx index 9690347f309..12d97f48a81 100644 --- a/Modules/Filtering/LabelMap/test/itkStatisticsUniqueLabelMapFilterTest1.cxx +++ b/Modules/Filtering/LabelMap/test/itkStatisticsUniqueLabelMapFilterTest1.cxx @@ -107,7 +107,7 @@ itkStatisticsUniqueLabelMapFilterTest1(int argc, char * argv[]) using StructuringElementType = itk::FlatStructuringElement; auto radius = itk::MakeFilled(radiusValue); - StructuringElementType structuringElement = StructuringElementType::Box(radius); + const StructuringElementType structuringElement = StructuringElementType::Box(radius); using MorphologicalFilterType = itk::GrayscaleDilateImageFilter; auto grayscaleDilateFilter = MorphologicalFilterType::New(); @@ -150,11 +150,11 @@ itkStatisticsUniqueLabelMapFilterTest1(int argc, char * argv[]) unique->SetInput(statisticsFilter->GetOutput()); - itk::SimpleFilterWatcher watcher(unique, "filter"); + const itk::SimpleFilterWatcher watcher(unique, "filter"); ITK_TRY_EXPECT_NO_EXCEPTION(unique->Update()); - int exitCode = CheckLabelMapOverlap(unique->GetOutput()); + const int exitCode = CheckLabelMapOverlap(unique->GetOutput()); if (exitCode == EXIT_FAILURE) { diff --git a/Modules/Filtering/MathematicalMorphology/include/itkAnchorErodeDilateImageFilter.hxx b/Modules/Filtering/MathematicalMorphology/include/itkAnchorErodeDilateImageFilter.hxx index cfd51e155a6..98b69a9f106 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkAnchorErodeDilateImageFilter.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkAnchorErodeDilateImageFilter.hxx @@ -60,10 +60,10 @@ AnchorErodeDilateImageFilter::DynamicThreadedGenera auto internalbuffer = InputImageType::New(); internalbuffer->SetRegions(IReg); internalbuffer->Allocate(); - InputImagePointer output = internalbuffer; + const InputImagePointer output = internalbuffer; // get the region size - InputImageRegionType OReg = outputRegionForThread; + const InputImageRegionType OReg = outputRegionForThread; // maximum buffer length is sum of dimensions unsigned int bufflength = 0; for (unsigned int i = 0; i < TImage::ImageDimension; ++i) @@ -83,8 +83,8 @@ AnchorErodeDilateImageFilter::DynamicThreadedGenera for (unsigned int i = 0; i < decomposition.size(); ++i) { - typename KernelType::LType ThisLine = decomposition[i]; - typename BresType::OffsetArray TheseOffsets = BresLine.BuildLine(ThisLine, bufflength); + const typename KernelType::LType ThisLine = decomposition[i]; + const typename BresType::OffsetArray TheseOffsets = BresLine.BuildLine(ThisLine, bufflength); using KernelLType = typename KernelType::LType; @@ -96,7 +96,7 @@ AnchorErodeDilateImageFilter::DynamicThreadedGenera ++SELength; } - InputImageRegionType BigFace = MakeEnlargedFace(input, IReg, ThisLine); + const InputImageRegionType BigFace = MakeEnlargedFace(input, IReg, ThisLine); AnchorLine.SetSize(SELength); diff --git a/Modules/Filtering/MathematicalMorphology/include/itkAnchorErodeDilateLine.hxx b/Modules/Filtering/MathematicalMorphology/include/itkAnchorErodeDilateLine.hxx index 20efcd26be0..ea25e0cea03 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkAnchorErodeDilateLine.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkAnchorErodeDilateLine.hxx @@ -62,7 +62,7 @@ AnchorErodeDilateLine::DoLine(std::vector & buff return; } - int middle = static_cast(m_Size) / 2; + const int middle = static_cast(m_Size) / 2; int outLeftP = 0; int outRightP = static_cast(bufflength) - 1; diff --git a/Modules/Filtering/MathematicalMorphology/include/itkAnchorOpenCloseImageFilter.hxx b/Modules/Filtering/MathematicalMorphology/include/itkAnchorOpenCloseImageFilter.hxx index 6b707c8e510..0602a3f2a5b 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkAnchorOpenCloseImageFilter.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkAnchorOpenCloseImageFilter.hxx @@ -69,10 +69,10 @@ AnchorOpenCloseImageFilter::DynamicThread auto internalbuffer = InputImageType::New(); internalbuffer->SetRegions(IReg); internalbuffer->Allocate(); - InputImagePointer output = internalbuffer; + const InputImagePointer output = internalbuffer; // get the region size - InputImageRegionType OReg = outputRegionForThread; + const InputImageRegionType OReg = outputRegionForThread; // maximum buffer length is sum of dimensions unsigned int bufflength = 0; for (unsigned int i = 0; i < TImage::ImageDimension; ++i) @@ -93,9 +93,9 @@ AnchorOpenCloseImageFilter::DynamicThread // first stage -- all of the erosions if we are doing an opening for (unsigned int i = 0; i < decomposition.size() - 1; ++i) { - KernelLType ThisLine = decomposition[i]; - BresOffsetArray TheseOffsets = BresLine.BuildLine(ThisLine, bufflength); - unsigned int SELength = GetLinePixels(ThisLine); + const KernelLType ThisLine = decomposition[i]; + const BresOffsetArray TheseOffsets = BresLine.BuildLine(ThisLine, bufflength); + unsigned int SELength = GetLinePixels(ThisLine); // want lines to be odd if (!(SELength % 2)) { @@ -103,7 +103,7 @@ AnchorOpenCloseImageFilter::DynamicThread } AnchorLineErode.SetSize(SELength); - InputImageRegionType BigFace = MakeEnlargedFace(input, IReg, ThisLine); + const InputImageRegionType BigFace = MakeEnlargedFace(input, IReg, ThisLine); DoAnchorFace( input, output, m_Boundary1, ThisLine, AnchorLineErode, TheseOffsets, inbuffer, buffer, IReg, BigFace); @@ -112,10 +112,10 @@ AnchorOpenCloseImageFilter::DynamicThread } // now do the opening in the middle of the chain { - unsigned int i = static_cast(decomposition.size()) - 1; - KernelLType ThisLine = decomposition[i]; - typename BresType::OffsetArray TheseOffsets = BresLine.BuildLine(ThisLine, bufflength); - unsigned int SELength = GetLinePixels(ThisLine); + const unsigned int i = static_cast(decomposition.size()) - 1; + const KernelLType ThisLine = decomposition[i]; + const typename BresType::OffsetArray TheseOffsets = BresLine.BuildLine(ThisLine, bufflength); + unsigned int SELength = GetLinePixels(ThisLine); // want lines to be odd if (!(SELength % 2)) { @@ -123,7 +123,7 @@ AnchorOpenCloseImageFilter::DynamicThread } AnchorLineOpen.SetSize(SELength); - InputImageRegionType BigFace = MakeEnlargedFace(input, IReg, ThisLine); + const InputImageRegionType BigFace = MakeEnlargedFace(input, IReg, ThisLine); // Now figure out which faces of the image we should be starting // from with this line @@ -134,9 +134,9 @@ AnchorOpenCloseImageFilter::DynamicThread // Now for the rest of the dilations -- note that i needs to be signed for (int i = static_cast(decomposition.size()) - 2; i >= 0; --i) { - KernelLType ThisLine = decomposition[i]; - typename BresType::OffsetArray TheseOffsets = BresLine.BuildLine(ThisLine, bufflength); - unsigned int SELength = GetLinePixels(ThisLine); + const KernelLType ThisLine = decomposition[i]; + const typename BresType::OffsetArray TheseOffsets = BresLine.BuildLine(ThisLine, bufflength); + unsigned int SELength = GetLinePixels(ThisLine); // want lines to be odd if (!(SELength % 2)) { @@ -145,7 +145,7 @@ AnchorOpenCloseImageFilter::DynamicThread AnchorLineDilate.SetSize(SELength); - InputImageRegionType BigFace = MakeEnlargedFace(input, IReg, ThisLine); + const InputImageRegionType BigFace = MakeEnlargedFace(input, IReg, ThisLine); DoAnchorFace( input, output, m_Boundary2, ThisLine, AnchorLineDilate, TheseOffsets, inbuffer, buffer, IReg, BigFace); } @@ -192,12 +192,12 @@ AnchorOpenCloseImageFilter::DoFaceOpen( KernelLType NormLine = line; NormLine.Normalize(); // set a generous tolerance - float tol = 1.0 / LineOffsets.size(); + const float tol = 1.0 / LineOffsets.size(); for (unsigned int it = 0; it < face.GetNumberOfPixels(); ++it) { - typename TImage::IndexType Ind = dumbImg->ComputeIndex(it); - unsigned int start; - unsigned int end; + const typename TImage::IndexType Ind = dumbImg->ComputeIndex(it); + unsigned int start; + unsigned int end; if (FillLineBuffer( input, Ind, NormLine, tol, LineOffsets, AllImage, outbuffer, start, end)) { diff --git a/Modules/Filtering/MathematicalMorphology/include/itkAnchorOpenCloseLine.hxx b/Modules/Filtering/MathematicalMorphology/include/itkAnchorOpenCloseLine.hxx index 401a95c5fc4..328ee809f19 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkAnchorOpenCloseLine.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkAnchorOpenCloseLine.hxx @@ -129,7 +129,7 @@ AnchorOpenCloseLine::StartLine(std::vector outRightP) { // finish @@ -141,7 +141,7 @@ AnchorOpenCloseLine::StartLine(std::vector::StartLine(std::vector::StartLine(std::vectorComputeIndex(it); - unsigned int start; - unsigned int end; + const typename TImage::IndexType Ind = dumbImg->ComputeIndex(it); + unsigned int start; + unsigned int end; if (FillLineBuffer(input, Ind, NormLine, tol, LineOffsets, AllImage, inbuffer, start, end)) { const unsigned int len = end - start + 1; diff --git a/Modules/Filtering/MathematicalMorphology/include/itkClosingByReconstructionImageFilter.hxx b/Modules/Filtering/MathematicalMorphology/include/itkClosingByReconstructionImageFilter.hxx index a6443bf4988..6330cae129d 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkClosingByReconstructionImageFilter.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkClosingByReconstructionImageFilter.hxx @@ -41,7 +41,7 @@ ClosingByReconstructionImageFilter::Generate Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/MathematicalMorphology/include/itkDoubleThresholdImageFilter.hxx b/Modules/Filtering/MathematicalMorphology/include/itkDoubleThresholdImageFilter.hxx index cc2b436fb16..41577f9ca5b 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkDoubleThresholdImageFilter.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkDoubleThresholdImageFilter.hxx @@ -47,7 +47,7 @@ DoubleThresholdImageFilter::GenerateInputRequestedReg Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/MathematicalMorphology/include/itkFlatStructuringElement.hxx b/Modules/Filtering/MathematicalMorphology/include/itkFlatStructuringElement.hxx index a2d82a053f7..c5d20c0c85a 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkFlatStructuringElement.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkFlatStructuringElement.hxx @@ -138,7 +138,7 @@ FlatStructuringElement::GeneratePolygon(itk::FlatStructuringElement< // std::cout << "3 dimensions" << std::endl; unsigned int rr = 0; int iterations = 1; - int faces = lines * 2; + const int faces = lines * 2; for (unsigned int i = 0; i < 3; ++i) { if (radius[i] > rr) @@ -151,10 +151,10 @@ FlatStructuringElement::GeneratePolygon(itk::FlatStructuringElement< case 12: { // dodecahedron - float phi = (1.0 + std::sqrt(5.0)) / 2.0; - float b = 1.0 / phi; - float c = 2.0 - phi; - unsigned int facets = 12; + const float phi = (1.0 + std::sqrt(5.0)) / 2.0; + float b = 1.0 / phi; + float c = 2.0 - phi; + const unsigned int facets = 12; using FacetArrayType = std::vector; FacetArrayType FacetArray; FacetArray.resize(facets); @@ -406,10 +406,10 @@ FlatStructuringElement::GeneratePolygon(itk::FlatStructuringElement< case 20: { // Icosahedron - float phi = (1.0 + std::sqrt(5.0)) / 2.0; - float a = 0.5; - float b = 1.0 / (2.0 * phi); - unsigned int facets = 20; + const float phi = (1.0 + std::sqrt(5.0)) / 2.0; + const float a = 0.5; + const float b = 1.0 / (2.0 * phi); + const unsigned int facets = 20; using FacetArrayType = std::vector; FacetArrayType FacetArray; FacetArray.resize(facets); @@ -727,8 +727,8 @@ FlatStructuringElement::GeneratePolygon(itk::FlatStructuringElement< // create triangular facet approximation to a sphere - begin with // unit sphere // total number of facets is 8 * (4^iterations) - unsigned int facets = 8 * static_cast(std::pow(4.0, iterations)); - double sqrt2 = std::sqrt(2.0); + const unsigned int facets = 8 * static_cast(std::pow(4.0, iterations)); + const double sqrt2 = std::sqrt(2.0); using FacetArrayType = std::vector; FacetArrayType FacetArray; @@ -806,7 +806,7 @@ FlatStructuringElement::GeneratePolygon(itk::FlatStructuringElement< for (unsigned int it = 0; it < static_cast(iterations); ++it) { // Bisect edges and move to sphere - unsigned int ntold = pos; + const unsigned int ntold = pos; for (unsigned int i = 0; i < ntold; ++i) { LType3 Pa; @@ -1162,7 +1162,7 @@ FlatStructuringElement::CheckParallel(LType NewVec) const { LType LL = m_Lines[i]; LL.Normalize(); - float L = NN * LL; + const float L = NN * LL; if ((1.0 - itk::Math::abs(L)) < 0.000001) { return (true); diff --git a/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleConnectedClosingImageFilter.hxx b/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleConnectedClosingImageFilter.hxx index 42a6585c76d..879db0439ec 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleConnectedClosingImageFilter.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleConnectedClosingImageFilter.hxx @@ -41,7 +41,7 @@ GrayscaleConnectedClosingImageFilter::GenerateInputRe Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); @@ -77,10 +77,10 @@ GrayscaleConnectedClosingImageFilter::GenerateData() calculator->SetImage(inputImage); calculator->ComputeMaximum(); - InputImagePixelType maxValue = calculator->GetMaximum(); + const InputImagePixelType maxValue = calculator->GetMaximum(); // compare this maximum value to the value at the seed pixel. - InputImagePixelType seedValue = inputImage->GetPixel(m_Seed); + const InputImagePixelType seedValue = inputImage->GetPixel(m_Seed); if (maxValue == seedValue) { @@ -92,7 +92,7 @@ GrayscaleConnectedClosingImageFilter::GenerateData() } // allocate a marker image - InputImagePointer markerPtr = InputImageType::New(); + const InputImagePointer markerPtr = InputImageType::New(); markerPtr->SetRegions(inputImage->GetRequestedRegion()); markerPtr->CopyInformation(inputImage); markerPtr->Allocate(); diff --git a/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleConnectedOpeningImageFilter.hxx b/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleConnectedOpeningImageFilter.hxx index c0eba26517f..9d1e0e3d2fa 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleConnectedOpeningImageFilter.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleConnectedOpeningImageFilter.hxx @@ -41,7 +41,7 @@ GrayscaleConnectedOpeningImageFilter::GenerateInputRe Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); @@ -77,10 +77,10 @@ GrayscaleConnectedOpeningImageFilter::GenerateData() calculator->SetImage(inputImage); calculator->ComputeMinimum(); - InputImagePixelType minValue = calculator->GetMinimum(); + const InputImagePixelType minValue = calculator->GetMinimum(); // compare this minimum value to the value at the seed pixel. - InputImagePixelType seedValue = inputImage->GetPixel(m_Seed); + const InputImagePixelType seedValue = inputImage->GetPixel(m_Seed); if (minValue == seedValue) { @@ -91,7 +91,7 @@ GrayscaleConnectedOpeningImageFilter::GenerateData() } // allocate a marker image - InputImagePointer markerPtr = InputImageType::New(); + const InputImagePointer markerPtr = InputImageType::New(); markerPtr->SetRegions(inputImage->GetRequestedRegion()); markerPtr->CopyInformation(inputImage); markerPtr->Allocate(); diff --git a/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleFillholeImageFilter.hxx b/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleFillholeImageFilter.hxx index abff526750a..ee861f69764 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleFillholeImageFilter.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleFillholeImageFilter.hxx @@ -41,7 +41,7 @@ GrayscaleFillholeImageFilter::GenerateInputRequestedR Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); @@ -74,10 +74,10 @@ GrayscaleFillholeImageFilter::GenerateData() calculator->SetImage(this->GetInput()); calculator->ComputeMaximum(); - InputImagePixelType maxValue = calculator->GetMaximum(); + const InputImagePixelType maxValue = calculator->GetMaximum(); // allocate a marker image - InputImagePointer markerPtr = InputImageType::New(); + const InputImagePointer markerPtr = InputImageType::New(); markerPtr->SetRegions(this->GetInput()->GetRequestedRegion()); markerPtr->CopyInformation(this->GetInput()); markerPtr->Allocate(); diff --git a/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleGeodesicDilateImageFilter.hxx b/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleGeodesicDilateImageFilter.hxx index 15ae3e8106f..3dc8c02afb9 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleGeodesicDilateImageFilter.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleGeodesicDilateImageFilter.hxx @@ -80,9 +80,9 @@ GrayscaleGeodesicDilateImageFilter::GenerateInputRequ Superclass::GenerateInputRequestedRegion(); // get pointers to the inputs - MarkerImagePointer markerPtr = const_cast(this->GetInput(0)); + const MarkerImagePointer markerPtr = const_cast(this->GetInput(0)); - MaskImagePointer maskPtr = const_cast(this->GetInput(1)); + const MaskImagePointer maskPtr = const_cast(this->GetInput(1)); if (!markerPtr || !maskPtr) { @@ -227,7 +227,7 @@ GrayscaleGeodesicDilateImageFilter::GenerateData() if (!done) { // disconnect the current output from the singleIteration object - MarkerImagePointer marker = singleIteration->GetOutput(); + const MarkerImagePointer marker = singleIteration->GetOutput(); marker->DisconnectPipeline(); // assign the old output as the input singleIteration->SetMarkerImage(marker); @@ -242,7 +242,7 @@ GrayscaleGeodesicDilateImageFilter::GenerateData() // Convert the output of singleIteration to an TOutputImage type // (could use a CastImageFilter here to thread the copy) - typename OutputImageType::Pointer outputPtr = this->GetOutput(); + const typename OutputImageType::Pointer outputPtr = this->GetOutput(); outputPtr->SetBufferedRegion(outputPtr->GetRequestedRegion()); outputPtr->Allocate(); @@ -288,7 +288,7 @@ GrayscaleGeodesicDilateImageFilter::DynamicThreadedGe NeighborhoodAlgorithm::ImageBoundaryFacesCalculator fC; auto kernelRadius = MakeFilled::RadiusType>(1); - typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = + const typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = fC(this->GetMarkerImage(), outputRegionForThread, kernelRadius); // Iterate over the faces @@ -339,7 +339,7 @@ GrayscaleGeodesicDilateImageFilter::DynamicThreadedGe for (sIt = markerIt.Begin(); !sIt.IsAtEnd(); ++sIt) { // a pixel in the neighborhood - MarkerImagePixelType value = sIt.Get(); + const MarkerImagePixelType value = sIt.Get(); // dilation is a max operation if (value > dilateValue) @@ -351,7 +351,7 @@ GrayscaleGeodesicDilateImageFilter::DynamicThreadedGe // Mask operation. For geodesic dilation, the mask operation is // a pixelwise min operator with the elementary dilated image and // the mask image - MarkerImagePixelType maskValue = maskIt.Get(); + const MarkerImagePixelType maskValue = maskIt.Get(); if (maskValue < dilateValue) { diff --git a/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleGeodesicErodeImageFilter.hxx b/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleGeodesicErodeImageFilter.hxx index d8b5e5b1d57..3320d07e3a4 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleGeodesicErodeImageFilter.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleGeodesicErodeImageFilter.hxx @@ -80,9 +80,9 @@ GrayscaleGeodesicErodeImageFilter::GenerateInputReque Superclass::GenerateInputRequestedRegion(); // get pointers to the inputs - MarkerImagePointer markerPtr = const_cast(this->GetInput(0)); + const MarkerImagePointer markerPtr = const_cast(this->GetInput(0)); - MaskImagePointer maskPtr = const_cast(this->GetInput(1)); + const MaskImagePointer maskPtr = const_cast(this->GetInput(1)); if (!markerPtr || !maskPtr) { @@ -227,7 +227,7 @@ GrayscaleGeodesicErodeImageFilter::GenerateData() if (!done) { // disconnect the current output from the singleIteration object - MarkerImagePointer marker = singleIteration->GetOutput(); + const MarkerImagePointer marker = singleIteration->GetOutput(); marker->DisconnectPipeline(); // assign the old output as the input singleIteration->SetMarkerImage(marker); @@ -242,7 +242,7 @@ GrayscaleGeodesicErodeImageFilter::GenerateData() // Convert the output of singleIteration to an TOutputImage type // (could use a CastImageFilter here to thread the copy) - typename OutputImageType::Pointer outputPtr = this->GetOutput(); + const typename OutputImageType::Pointer outputPtr = this->GetOutput(); outputPtr->SetBufferedRegion(outputPtr->GetRequestedRegion()); outputPtr->Allocate(); @@ -284,7 +284,7 @@ GrayscaleGeodesicErodeImageFilter::DynamicThreadedGen NeighborhoodAlgorithm::ImageBoundaryFacesCalculator fC; auto kernelRadius = MakeFilled::RadiusType>(1); - typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = + const typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = fC(this->GetMarkerImage(), outputRegionForThread, kernelRadius); // Iterate over the faces @@ -321,7 +321,7 @@ GrayscaleGeodesicErodeImageFilter::DynamicThreadedGen { markerIt.ActivateOffset(markerIt.GetOffset(nd)); } - typename NeighborhoodIteratorType::OffsetType offset{}; + const typename NeighborhoodIteratorType::OffsetType offset{}; markerIt.DeactivateOffset(offset); } @@ -335,7 +335,7 @@ GrayscaleGeodesicErodeImageFilter::DynamicThreadedGen for (sIt = markerIt.Begin(); !sIt.IsAtEnd(); ++sIt) { // a pixel in the neighborhood - MarkerImagePixelType value = sIt.Get(); + const MarkerImagePixelType value = sIt.Get(); // erosion is a min operation if (value < erodeValue) @@ -347,7 +347,7 @@ GrayscaleGeodesicErodeImageFilter::DynamicThreadedGen // Mask operation. For geodesic erosion, the mask operation is // a pixelwise max operator with the elementary eroded image and // the mask image - MarkerImagePixelType maskValue = maskIt.Get(); + const MarkerImagePixelType maskValue = maskIt.Get(); if (maskValue > erodeValue) { diff --git a/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleGrindPeakImageFilter.hxx b/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleGrindPeakImageFilter.hxx index 177b98a2f2d..6872a95887b 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleGrindPeakImageFilter.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkGrayscaleGrindPeakImageFilter.hxx @@ -51,7 +51,7 @@ GrayscaleGrindPeakImageFilter::GenerateInputRequested Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); @@ -84,10 +84,10 @@ GrayscaleGrindPeakImageFilter::GenerateData() calculator->SetImage(this->GetInput()); calculator->ComputeMinimum(); - InputImagePixelType minValue = calculator->GetMinimum(); + const InputImagePixelType minValue = calculator->GetMinimum(); // allocate a marker image - InputImagePointer markerPtr = InputImageType::New(); + const InputImagePointer markerPtr = InputImageType::New(); markerPtr->SetRegions(this->GetInput()->GetRequestedRegion()); markerPtr->CopyInformation(this->GetInput()); markerPtr->Allocate(); diff --git a/Modules/Filtering/MathematicalMorphology/include/itkHConcaveImageFilter.hxx b/Modules/Filtering/MathematicalMorphology/include/itkHConcaveImageFilter.hxx index 35d8d063f1e..92a6556cd25 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkHConcaveImageFilter.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkHConcaveImageFilter.hxx @@ -38,7 +38,7 @@ HConcaveImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/MathematicalMorphology/include/itkHConvexImageFilter.hxx b/Modules/Filtering/MathematicalMorphology/include/itkHConvexImageFilter.hxx index 5e8f0f5c673..79e8d389b04 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkHConvexImageFilter.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkHConvexImageFilter.hxx @@ -38,7 +38,7 @@ HConvexImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/MathematicalMorphology/include/itkHMaximaImageFilter.hxx b/Modules/Filtering/MathematicalMorphology/include/itkHMaximaImageFilter.hxx index 6ef9b6a8f36..87529ceda21 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkHMaximaImageFilter.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkHMaximaImageFilter.hxx @@ -40,7 +40,7 @@ HMaximaImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/MathematicalMorphology/include/itkHMinimaImageFilter.hxx b/Modules/Filtering/MathematicalMorphology/include/itkHMinimaImageFilter.hxx index 26799f75a01..e18124d8d3d 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkHMinimaImageFilter.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkHMinimaImageFilter.hxx @@ -40,7 +40,7 @@ HMinimaImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/MathematicalMorphology/include/itkMaskedMovingHistogramImageFilter.hxx b/Modules/Filtering/MathematicalMorphology/include/itkMaskedMovingHistogramImageFilter.hxx index 39f1e6e73fd..79e77f34054 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkMaskedMovingHistogramImageFilter.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkMaskedMovingHistogramImageFilter.hxx @@ -63,7 +63,7 @@ MaskedMovingHistogramImageFilterSetNumberOfRequiredOutputs(2); - typename MaskImageType::Pointer maskout = TMaskImage::New(); + const typename MaskImageType::Pointer maskout = TMaskImage::New(); this->SetNthOutput(1, maskout.GetPointer()); } else @@ -81,11 +81,11 @@ MaskedMovingHistogramImageFilterm_GenerateOutputMask) { // Allocate the output image. - typename TOutputImage::Pointer output = this->GetOutput(); + const typename TOutputImage::Pointer output = this->GetOutput(); output->SetBufferedRegion(output->GetRequestedRegion()); output->Allocate(); // Allocate the output mask image. - typename TMaskImage::Pointer mask = this->GetOutputMask(); + const typename TMaskImage::Pointer mask = this->GetOutputMask(); mask->SetBufferedRegion(mask->GetRequestedRegion()); mask->Allocate(); } @@ -119,7 +119,7 @@ auto MaskedMovingHistogramImageFilter::GetOutputMask() -> MaskImageType * { - typename MaskImageType::Pointer res = dynamic_cast(this->ProcessObject::GetOutput(1)); + const typename MaskImageType::Pointer res = dynamic_cast(this->ProcessObject::GetOutput(1)); return res; } @@ -139,14 +139,14 @@ MaskedMovingHistogramImageFilterGetInput(); const MaskImageType * maskImage = this->GetMaskImage(); - RegionType inputRegion = inputImage->GetRequestedRegion(); + const RegionType inputRegion = inputImage->GetRequestedRegion(); TotalProgressReporter progress(this, inputRegion.GetNumberOfPixels()); // initialize the histogram for (auto listIt = this->m_KernelOffsets.begin(); listIt != this->m_KernelOffsets.end(); ++listIt) { - IndexType idx = outputRegionForThread.GetIndex() + (*listIt); + const IndexType idx = outputRegionForThread.GetIndex() + (*listIt); if (inputRegion.IsInside(idx) && maskImage->GetPixel(idx) == m_MaskValue) { histogram.AddPixel(inputImage->GetPixel(idx)); @@ -159,7 +159,7 @@ MaskedMovingHistogramImageFilter>(1); - int axis = ImageDimension - 1; + const int axis = ImageDimension - 1; OffsetType offset{}; RegionType stRegion; stRegion.SetSize(this->m_Kernel.GetSize()); @@ -172,8 +172,8 @@ MaskedMovingHistogramImageFilterm_Axes[axis]; - int LineLength = inputRegion.GetSize()[BestDirection]; + const int BestDirection = this->m_Axes[axis]; + const int LineLength = inputRegion.GetSize()[BestDirection]; // init the offset and get the lists for the best axis offset[BestDirection] = direction[BestDirection]; @@ -206,11 +206,11 @@ MaskedMovingHistogramImageFilterGetPixel(currentIdx) == m_MaskValue && histRef.IsValid()) { @@ -253,7 +253,7 @@ MaskedMovingHistogramImageFilterGetDirAndOffset(LineStart, PrevLineStart, LineOffset, Changes, LineDirection); ++(Steps[LineDirection]); - IndexType PrevLineStartHist = LineStart - LineOffset; + const IndexType PrevLineStartHist = LineStart - LineOffset; const OffsetListType * addedListLine = &this->m_AddedOffsets[LineOffset]; const OffsetListType * removedListLine = &this->m_RemovedOffsets[LineOffset]; HistogramType & tmpHist = HistVec[LineDirection]; @@ -294,7 +294,7 @@ MaskedMovingHistogramImageFilterbegin(); addedIt != addedList->end(); ++addedIt) { - typename InputImageType::IndexType idx = currentIdx + (*addedIt); + const typename InputImageType::IndexType idx = currentIdx + (*addedIt); if (maskImage->GetPixel(idx) == m_MaskValue) { histogram.AddPixel(inputImage->GetPixel(idx)); @@ -306,7 +306,7 @@ MaskedMovingHistogramImageFilterbegin(); removedIt != removedList->end(); ++removedIt) { - typename InputImageType::IndexType idx = currentIdx + (*removedIt); + const typename InputImageType::IndexType idx = currentIdx + (*removedIt); if (maskImage->GetPixel(idx) == m_MaskValue) { histogram.RemovePixel(inputImage->GetPixel(idx)); @@ -322,7 +322,7 @@ MaskedMovingHistogramImageFilterbegin(); addedIt != addedList->end(); ++addedIt) { - IndexType idx = currentIdx + (*addedIt); + const IndexType idx = currentIdx + (*addedIt); if (inputRegion.IsInside(idx) && maskImage->GetPixel(idx) == m_MaskValue) { histogram.AddPixel(inputImage->GetPixel(idx)); @@ -334,7 +334,7 @@ MaskedMovingHistogramImageFilterbegin(); removedIt != removedList->end(); ++removedIt) { - IndexType idx = currentIdx + (*removedIt); + const IndexType idx = currentIdx + (*removedIt); if (inputRegion.IsInside(idx) && maskImage->GetPixel(idx) == m_MaskValue) { histogram.RemovePixel(inputImage->GetPixel(idx)); diff --git a/Modules/Filtering/MathematicalMorphology/include/itkMorphologyImageFilter.hxx b/Modules/Filtering/MathematicalMorphology/include/itkMorphologyImageFilter.hxx index 262f2139164..92ba66aa7e0 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkMorphologyImageFilter.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkMorphologyImageFilter.hxx @@ -44,8 +44,8 @@ MorphologyImageFilter::DynamicThreadedGenera NeighborhoodIteratorType b_iter; // Find the boundary "faces" - NeighborhoodAlgorithm::ImageBoundaryFacesCalculator fC; - typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = + NeighborhoodAlgorithm::ImageBoundaryFacesCalculator fC; + const typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = fC(this->GetInput(), outputRegionForThread, this->GetKernel().GetRadius()); TotalProgressReporter progress(this, this->GetOutput()->GetRequestedRegion().GetNumberOfPixels()); diff --git a/Modules/Filtering/MathematicalMorphology/include/itkOpeningByReconstructionImageFilter.hxx b/Modules/Filtering/MathematicalMorphology/include/itkOpeningByReconstructionImageFilter.hxx index fa16b0fc7b8..0f925f76130 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkOpeningByReconstructionImageFilter.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkOpeningByReconstructionImageFilter.hxx @@ -42,7 +42,7 @@ OpeningByReconstructionImageFilter::Generate Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); diff --git a/Modules/Filtering/MathematicalMorphology/include/itkRankHistogram.h b/Modules/Filtering/MathematicalMorphology/include/itkRankHistogram.h index 536a5b5e3db..20c7c6e33e5 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkRankHistogram.h +++ b/Modules/Filtering/MathematicalMorphology/include/itkRankHistogram.h @@ -155,10 +155,10 @@ class RankHistogram TInputPixel GetValue(const TInputPixel &) { - SizeValueType target = (SizeValueType)(m_Rank * (m_Entries - 1)) + 1; - SizeValueType total = m_Below; - SizeValueType ThisBin; - bool eraseFlag = false; + const SizeValueType target = (SizeValueType)(m_Rank * (m_Entries - 1)) + 1; + SizeValueType total = m_Below; + SizeValueType ThisBin; + bool eraseFlag = false; if (total < target) { @@ -203,7 +203,7 @@ class RankHistogram while (searchIt != m_Map.begin()) { ThisBin = searchIt->second; - unsigned int tbelow = total - ThisBin; + const unsigned int tbelow = total - ThisBin; if (tbelow < target) // we've overshot { break; @@ -305,8 +305,8 @@ class VectorRankHistogram TInputPixel GetValueBruteForce() { - SizeValueType count = 0; - SizeValueType target = (SizeValueType)(m_Rank * (m_Entries - 1)) + 1; + SizeValueType count = 0; + const SizeValueType target = (SizeValueType)(m_Rank * (m_Entries - 1)) + 1; for (SizeValueType i = 0; i < m_Size; ++i) { count += m_Vec[i]; @@ -327,7 +327,7 @@ class VectorRankHistogram void AddPixel(const TInputPixel & p) { - OffsetValueType q = (OffsetValueType)p - NumericTraits::NonpositiveMin(); + const OffsetValueType q = (OffsetValueType)p - NumericTraits::NonpositiveMin(); m_Vec[q]++; if (m_Compare(p, m_RankValue) || p == m_RankValue) diff --git a/Modules/Filtering/MathematicalMorphology/include/itkReconstructionImageFilter.hxx b/Modules/Filtering/MathematicalMorphology/include/itkReconstructionImageFilter.hxx index 35c2d36991a..72b355ae84b 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkReconstructionImageFilter.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkReconstructionImageFilter.hxx @@ -45,9 +45,9 @@ ReconstructionImageFilter::GenerateInputReq Superclass::GenerateInputRequestedRegion(); // get pointers to the inputs - MarkerImagePointer markerPtr = const_cast(this->GetInput(0)); + const MarkerImagePointer markerPtr = const_cast(this->GetInput(0)); - MaskImagePointer maskPtr = const_cast(this->GetInput(1)); + const MaskImagePointer maskPtr = const_cast(this->GetInput(1)); if (!markerPtr || !maskPtr) { @@ -79,9 +79,9 @@ ReconstructionImageFilter::GenerateData() TCompare compare; - MarkerImageConstPointer markerImage = this->GetMarkerImage(); - MaskImageConstPointer maskImage = this->GetMaskImage(); - OutputImagePointer output = this->GetOutput(); + const MarkerImageConstPointer markerImage = this->GetMarkerImage(); + const MaskImageConstPointer maskImage = this->GetMaskImage(); + const OutputImagePointer output = this->GetOutput(); // mask and marker must have the same size if (this->GetMarkerImage()->GetRequestedRegion().GetSize() != this->GetMaskImage()->GetRequestedRegion().GetSize()) @@ -126,7 +126,7 @@ ReconstructionImageFilter::GenerateData() // copy marker to output - isn't there a better way? while (!outIt.IsAtEnd()) { - MarkerImagePixelType currentValue = inIt.Get(); + const MarkerImagePixelType currentValue = inIt.Get(); outIt.Set(static_cast(currentValue)); ++inIt; ++outIt; @@ -152,22 +152,22 @@ ReconstructionImageFilter::GenerateData() // we will only be processing the body region fit = faceList.begin(); // must be a better way of doing this - NOutputIterator tt(kernelRadius, markerImageP, *fit); + const NOutputIterator tt(kernelRadius, markerImageP, *fit); outNIt = tt; - InputIteratorType ttt(maskImageP, *fit); + const InputIteratorType ttt(maskImageP, *fit); mskIt = ttt; - CNInputIterator tttt(kernelRadius, maskImageP, *fit); + const CNInputIterator tttt(kernelRadius, maskImageP, *fit); mskNIt = tttt; } else { - NOutputIterator tt(kernelRadius, markerImageP, output->GetRequestedRegion()); + const NOutputIterator tt(kernelRadius, markerImageP, output->GetRequestedRegion()); outNIt = tt; - InputIteratorType ttt(maskImageP, output->GetRequestedRegion()); + const InputIteratorType ttt(maskImageP, output->GetRequestedRegion()); mskIt = ttt; - CNInputIterator tttt(kernelRadius, maskImageP, output->GetRequestedRegion()); + const CNInputIterator tttt(kernelRadius, maskImageP, output->GetRequestedRegion()); mskNIt = tttt; } @@ -201,7 +201,7 @@ ReconstructionImageFilter::GenerateData() typename NOutputIterator::ConstIterator sIt; for (sIt = outNIt.Begin(); !sIt.IsAtEnd(); ++sIt) { - InputImagePixelType VN = sIt.Get(); + const InputImagePixelType VN = sIt.Get(); if (compare(VN, V)) { outNIt.SetCenterPixel(VN); @@ -243,14 +243,14 @@ ReconstructionImageFilter::GenerateData() typename NOutputIterator::ConstIterator sIt; for (sIt = outNIt.Begin(); !sIt.IsAtEnd(); ++sIt) { - InputImagePixelType VN = sIt.Get(); + const InputImagePixelType VN = sIt.Get(); if (compare(VN, V)) { outNIt.SetCenterPixel(VN); V = VN; } } - InputImagePixelType iV = mskNIt.GetCenterPixel(); + const InputImagePixelType iV = mskNIt.GetCenterPixel(); if (compare(V, iV)) { outNIt.SetCenterPixel(iV); @@ -263,8 +263,8 @@ ReconstructionImageFilter::GenerateData() for (typename NOutputIterator::IndexListType::const_iterator oLIt = oIndexList.begin(); oLIt != oIndexList.end(); ++oLIt, ++mLIt) { - InputImagePixelType VN = outNIt.GetPixel(*oLIt); - InputImagePixelType iN = mskNIt.GetPixel(*mLIt); + const InputImagePixelType VN = outNIt.GetPixel(*oLIt); + const InputImagePixelType iN = mskNIt.GetPixel(*mLIt); if (compare(V, VN) && compare(iN, VN)) { IndexFifo.push(outNIt.GetIndex()); @@ -284,22 +284,22 @@ ReconstructionImageFilter::GenerateData() // now process the fifo - this fill the parts that weren't dealt // with by the raster and anti-raster passes // typename NOutputIterator::Iterator sIt; - typename CNInputIterator::ConstIterator mIt; + const typename CNInputIterator::ConstIterator mIt; while (!IndexFifo.empty()) { - InputImageIndexType I = IndexFifo.front(); + const InputImageIndexType I = IndexFifo.front(); IndexFifo.pop(); // reposition the iterators outNIt += I - outNIt.GetIndex(); mskNIt += I - mskNIt.GetIndex(); - InputImagePixelType V = outNIt.GetCenterPixel(); + const InputImagePixelType V = outNIt.GetCenterPixel(); typename NOutputIterator::IndexListType::const_iterator mLIt = mIndexList.begin(); for (typename NOutputIterator::IndexListType::const_iterator oLIt = oIndexList.begin(); oLIt != oIndexList.end(); ++oLIt, ++mLIt) { - InputImagePixelType VN = outNIt.GetPixel(*oLIt); - InputImagePixelType iN = mskNIt.GetPixel(*mLIt); + const InputImagePixelType VN = outNIt.GetPixel(*oLIt); + const InputImagePixelType iN = mskNIt.GetPixel(*mLIt); // candidate for dilation via flooding if (compare(V, VN) && Math::NotAlmostEquals(iN, VN)) { diff --git a/Modules/Filtering/MathematicalMorphology/include/itkSharedMorphologyUtilities.hxx b/Modules/Filtering/MathematicalMorphology/include/itkSharedMorphologyUtilities.hxx index da529969084..7fba71e96ac 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkSharedMorphologyUtilities.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkSharedMorphologyUtilities.hxx @@ -57,8 +57,8 @@ NeedToDoFace(const TRegion AllImage, const TRegion face, const TLine line) break; } } - IndexValueType startI = ISt[smallDim]; - IndexValueType facePos = FSt[smallDim] + FSz[smallDim] - 1; + const IndexValueType startI = ISt[smallDim]; + const IndexValueType facePos = FSt[smallDim] + FSz[smallDim] - 1; if (facePos == startI) { // at the start of dimension - vector must be positive @@ -277,7 +277,7 @@ CopyLineToImage(const typename TImage::Pointer output, const unsigned int start, const unsigned int end) { - unsigned int size = end - start + 1; + const unsigned int size = end - start + 1; for (unsigned int i = 0; i < size; ++i) { @@ -386,7 +386,7 @@ MakeEnlargedFace(const typename TInputImage::ConstPointer itkNotUsed(input), // figure out how much extra each other dimension needs to be extended typename TInputImage::SizeType NewSize = RelevantRegion.GetSize(); typename TInputImage::IndexType NewStart = RelevantRegion.GetIndex(); - unsigned int NonFaceLen = AllImage.GetSize()[NonFaceDim]; + const unsigned int NonFaceLen = AllImage.GetSize()[NonFaceDim]; for (unsigned int i = 0; i < TInputImage::RegionType::ImageDimension; ++i) { if (i != NonFaceDim) @@ -428,12 +428,12 @@ FillLineBuffer(typename TImage::ConstPointer input, unsigned int & start, unsigned int & end) { - int status = ComputeStartEnd(StartIndex, line, tol, LineOffsets, AllImage, start, end); + const int status = ComputeStartEnd(StartIndex, line, tol, LineOffsets, AllImage, start, end); if (!status) { return (status); } - unsigned int size = end - start + 1; + const unsigned int size = end - start + 1; // compat for (unsigned int i = 0; i < size; ++i) { diff --git a/Modules/Filtering/MathematicalMorphology/include/itkValuedRegionalExtremaImageFilter.hxx b/Modules/Filtering/MathematicalMorphology/include/itkValuedRegionalExtremaImageFilter.hxx index 8d54d0b2b0a..2eea01d1fcc 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkValuedRegionalExtremaImageFilter.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkValuedRegionalExtremaImageFilter.hxx @@ -81,12 +81,12 @@ ValuedRegionalExtremaImageFilterGetRequestedRegion()); OutputIterator outIt(output, output->GetRequestedRegion()); - InputImagePixelType firstValue = inIt.Get(); + const InputImagePixelType firstValue = inIt.Get(); this->m_Flat = true; while (!outIt.IsAtEnd()) { - InputImagePixelType currentValue = inIt.Get(); + const InputImagePixelType currentValue = inIt.Get(); outIt.Set(static_cast(currentValue)); if (currentValue != firstValue) { @@ -131,7 +131,7 @@ ValuedRegionalExtremaImageFilter::DynamicThre InputImageConstPointer input = this->GetInput(); - SizeValueType totalPixels = + const SizeValueType totalPixels = this->GetKernel().GetLines().size() * this->GetOutput()->GetRequestedRegion().GetNumberOfPixels(); TotalProgressReporter progress(this, totalPixels); @@ -66,10 +66,10 @@ VanHerkGilWermanErodeDilateImageFilter::DynamicThre auto internalbuffer = InputImageType::New(); internalbuffer->SetRegions(IReg); internalbuffer->Allocate(); - InputImagePointer output = internalbuffer; + const InputImagePointer output = internalbuffer; // get the region size - InputImageRegionType OReg = outputRegionForThread; + const InputImageRegionType OReg = outputRegionForThread; // maximum buffer length is sum of dimensions unsigned int bufflength = 0; for (unsigned int i = 0; i < TImage::ImageDimension; ++i) @@ -91,16 +91,16 @@ VanHerkGilWermanErodeDilateImageFilter::DynamicThre for (unsigned int i = 0; i < decomposition.size(); ++i) { - typename KernelType::LType ThisLine = decomposition[i]; - typename BresType::OffsetArray TheseOffsets = BresLine.BuildLine(ThisLine, bufflength); - unsigned int SELength = GetLinePixels(ThisLine); + const typename KernelType::LType ThisLine = decomposition[i]; + const typename BresType::OffsetArray TheseOffsets = BresLine.BuildLine(ThisLine, bufflength); + unsigned int SELength = GetLinePixels(ThisLine); // want lines to be odd if (!(SELength % 2)) { ++SELength; } - InputImageRegionType BigFace = MakeEnlargedFace(input, IReg, ThisLine); + const InputImageRegionType BigFace = MakeEnlargedFace(input, IReg, ThisLine); DoFace( input, output, m_Boundary, ThisLine, TheseOffsets, SELength, buffer, forward, reverse, IReg, BigFace); diff --git a/Modules/Filtering/MathematicalMorphology/include/itkVanHerkGilWermanUtilities.hxx b/Modules/Filtering/MathematicalMorphology/include/itkVanHerkGilWermanUtilities.hxx index ded6ef3ce92..16d9a85fa30 100644 --- a/Modules/Filtering/MathematicalMorphology/include/itkVanHerkGilWermanUtilities.hxx +++ b/Modules/Filtering/MathematicalMorphology/include/itkVanHerkGilWermanUtilities.hxx @@ -43,10 +43,10 @@ FillForwardExt(std::vector & pixbuffer, const unsigned int KernLen, unsigned int len) { - unsigned int size = len; - unsigned int blocks = size / KernLen; - unsigned int i = 0; - TFunction m_TF; + const unsigned int size = len; + const unsigned int blocks = size / KernLen; + unsigned int i = 0; + TFunction m_TF; for (unsigned int j = 0; j < blocks; ++j) { @@ -82,10 +82,10 @@ FillReverseExt(std::vector & pixbuffer, const unsigned int KernLen, unsigned int len) { - auto size = (IndexValueType)(len); - IndexValueType blocks = size / static_cast(KernLen); - IndexValueType i = size - 1; - TFunction m_TF; + auto size = (IndexValueType)(len); + const IndexValueType blocks = size / static_cast(KernLen); + IndexValueType i = size - 1; + TFunction m_TF; if (i > blocks * static_cast(KernLen) - 1) { @@ -145,13 +145,13 @@ DoFace(typename TImage::ConstPointer input, TLine NormLine = line; NormLine.Normalize(); // set a generous tolerance - float tol = 1.0 / LineOffsets.size(); - TFunction m_TF; + const float tol = 1.0 / LineOffsets.size(); + TFunction m_TF; for (unsigned int it = 0; it < face.GetNumberOfPixels(); ++it) { - typename TImage::IndexType Ind = dumbImg->ComputeIndex(it); - unsigned int start; /*one-line-declaration*/ - unsigned int end; /*one-line-declaration*/ + const typename TImage::IndexType Ind = dumbImg->ComputeIndex(it); + unsigned int start; /*one-line-declaration*/ + unsigned int end; /*one-line-declaration*/ if (FillLineBuffer(input, Ind, NormLine, tol, LineOffsets, AllImage, pixbuffer, start, end)) { const unsigned int len = end - start + 1; @@ -161,7 +161,7 @@ DoFace(typename TImage::ConstPointer input, FillForwardExt(pixbuffer, fExtBuffer, KernLen, len + 2); FillReverseExt(pixbuffer, rExtBuffer, KernLen, len + 2); // now compute result - unsigned int size = len + 2; + const unsigned int size = len + 2; if (size <= KernLen / 2) { for (unsigned int j = 0; j < size; ++j) @@ -196,8 +196,8 @@ DoFace(typename TImage::ConstPointer input, j++, k++, l++) { - typename TImage::PixelType V1 = fExtBuffer[k]; - typename TImage::PixelType V2 = rExtBuffer[l]; + const typename TImage::PixelType V1 = fExtBuffer[k]; + const typename TImage::PixelType V2 = rExtBuffer[l]; pixbuffer[j] = m_TF(V1, V2); } // line end -- involves resetting the end of the reverse diff --git a/Modules/Filtering/MathematicalMorphology/test/itkAnchorErodeDilateImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkAnchorErodeDilateImageFilterTest.cxx index 230f9673bef..aac464a98be 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkAnchorErodeDilateImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkAnchorErodeDilateImageFilterTest.cxx @@ -38,7 +38,7 @@ itkAnchorErodeDilateImageFilterTest(int, char ** const) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, AnchorErodeDilateImageFilter, KernelImageFilter); - typename FilterType::InputImagePixelType boundary = 255; + const typename FilterType::InputImagePixelType boundary = 255; filter->SetBoundary(boundary); ITK_TEST_SET_GET_VALUE(boundary, filter->GetBoundary()); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkClosingByReconstructionImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkClosingByReconstructionImageFilterTest.cxx index dcd78bc8b8d..1a61ab8736e 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkClosingByReconstructionImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkClosingByReconstructionImageFilterTest.cxx @@ -68,10 +68,10 @@ itkClosingByReconstructionImageFilterTest(int argc, char * argv[]) filter->SetKernel(structuringElement); ITK_TEST_SET_GET_VALUE(structuringElement, filter->GetKernel()); - bool preserveIntensities = static_cast(std::stoi(argv[4])); + const bool preserveIntensities = static_cast(std::stoi(argv[4])); ITK_TEST_SET_GET_BOOLEAN(filter, PreserveIntensities, preserveIntensities); - bool fullyConnected = static_cast(std::stoi(argv[5])); + const bool fullyConnected = static_cast(std::stoi(argv[5])); ITK_TEST_SET_GET_BOOLEAN(filter, FullyConnected, fullyConnected); filter->SetInput(reader->GetOutput()); @@ -92,7 +92,7 @@ itkClosingByReconstructionImageFilterTest(int argc, char * argv[]) // Create a difference image if one is requested if (argc == 7) { - itk::SubtractImageFilter::Pointer subtract = + const itk::SubtractImageFilter::Pointer subtract = itk::SubtractImageFilter::New(); subtract->SetInput(1, reader->GetOutput()); subtract->SetInput(0, filter->GetOutput()); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkDoubleThresholdImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkDoubleThresholdImageFilterTest.cxx index a6fa3204147..0fde2d6245d 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkDoubleThresholdImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkDoubleThresholdImageFilterTest.cxx @@ -73,7 +73,7 @@ itkDoubleThresholdImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(threshold, DoubleThresholdImageFilter, ImageToImageFilter); - itk::SimpleFilterWatcher watcher(threshold, "threshold"); + const itk::SimpleFilterWatcher watcher(threshold, "threshold"); // Setup the input and output files reader->SetFileName(argv[1]); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkFlatStructuringElementTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkFlatStructuringElementTest.cxx index c191fb66f4d..3440688f7bd 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkFlatStructuringElementTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkFlatStructuringElementTest.cxx @@ -27,9 +27,9 @@ ComputeAreaError(const SEType & k, unsigned int thickness = 0); int itkFlatStructuringElementTest(int, char *[]) { - int scalarRadius = 5; - int scalarThickness = 2; - bool radiusIsParametric = true; + const int scalarRadius = 5; + const int scalarThickness = 2; + const bool radiusIsParametric = true; using SE2Type = itk::FlatStructuringElement<2>; auto r2 = itk::MakeFilled(scalarRadius); @@ -222,7 +222,7 @@ ComputeAreaError(const SEType & k, unsigned int thickness) expectedInnerForegroundArea *= (k.GetRadius()[i] - thickness); } - float expectedForegroundArea = expectedOuterForegroundArea - expectedInnerForegroundArea; + const float expectedForegroundArea = expectedOuterForegroundArea - expectedInnerForegroundArea; // Show the neighborhood if it is 2D. typename SEType::ConstIterator SEIt; diff --git a/Modules/Filtering/MathematicalMorphology/test/itkFlatStructuringElementTest2.cxx b/Modules/Filtering/MathematicalMorphology/test/itkFlatStructuringElementTest2.cxx index 6db3835d359..368ac9bf51a 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkFlatStructuringElementTest2.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkFlatStructuringElementTest2.cxx @@ -92,7 +92,7 @@ itkFlatStructuringElementTest2(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(reader->UpdateLargestPossibleRegion()); - ImageUCType::Pointer testImg = reader->GetOutput(); + const ImageUCType::Pointer testImg = reader->GetOutput(); using FSEType = itk::FlatStructuringElement; @@ -110,10 +110,10 @@ itkFlatStructuringElementTest2(int argc, char * argv[]) auto cast = castFilterType::New(); cast->SetInput(rescale->GetOutput()); cast->Update(); - ImageBoolType::Pointer testImgBool = cast->GetOutput(); + const ImageBoolType::Pointer testImgBool = cast->GetOutput(); - FSEType flatStructure = FSEType::FromImage(testImgBool); - ImageUCType::Pointer imgFromStructure = GetImage(flatStructure); + const FSEType flatStructure = FSEType::FromImage(testImgBool); + const ImageUCType::Pointer imgFromStructure = GetImage(flatStructure); // Write result from GetImage for comparison with input image @@ -135,13 +135,13 @@ itkFlatStructuringElementTest2(int argc, char * argv[]) lowerExtendRegion[0] = 1; lowerExtendRegion[1] = 1; padFilter->SetPadLowerBound(lowerExtendRegion); - ImageBoolType::PixelType constPixel = true; + const ImageBoolType::PixelType constPixel = true; padFilter->SetConstant(constPixel); ITK_TRY_EXPECT_NO_EXCEPTION(padFilter->Update()); - ImageBoolType::Pointer evenBoolImg = padFilter->GetOutput(); + const ImageBoolType::Pointer evenBoolImg = padFilter->GetOutput(); ITK_TRY_EXPECT_EXCEPTION(FSEType::FromImage(evenBoolImg)); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkFlatStructuringElementTest3.cxx b/Modules/Filtering/MathematicalMorphology/test/itkFlatStructuringElementTest3.cxx index 4a5793b77a5..e99d2fbc74e 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkFlatStructuringElementTest3.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkFlatStructuringElementTest3.cxx @@ -31,7 +31,7 @@ SEToFile(const TSEType & e, const std::string & fname) auto img = ImageType::New(); - typename ImageType::IndexType start{}; + const typename ImageType::IndexType start{}; typename ImageType::SizeType size; for (unsigned int i = 0; i < Dimension; ++i) @@ -40,7 +40,7 @@ SEToFile(const TSEType & e, const std::string & fname) } - typename ImageType::RegionType region(start, size); + const typename ImageType::RegionType region(start, size); img->SetRegions(region); img->Allocate(); img->FillBuffer(0); @@ -72,10 +72,10 @@ itkFlatStructuringElementTest3(int argc, char * argv[]) return EXIT_FAILURE; } - int dimension = 2; - std::string outputImage = argv[1]; - int radius = std::stoi(argv[2]); - int lines = std::stoi(argv[3]); + int dimension = 2; + const std::string outputImage = argv[1]; + const int radius = std::stoi(argv[2]); + const int lines = std::stoi(argv[3]); if (argc > 4) { dimension = std::stoi(argv[4]); @@ -85,16 +85,16 @@ itkFlatStructuringElementTest3(int argc, char * argv[]) { using SE2Type = itk::FlatStructuringElement<2>; - auto r2 = itk::MakeFilled(radius); - SE2Type P = SE2Type::Polygon(r2, lines); + auto r2 = itk::MakeFilled(radius); + const SE2Type P = SE2Type::Polygon(r2, lines); SEToFile(P, outputImage); } else if (dimension == 3) { using SE3Type = itk::FlatStructuringElement<3>; - auto r3 = itk::MakeFilled(radius); - SE3Type P = SE3Type::Polygon(r3, lines); + auto r3 = itk::MakeFilled(radius); + const SE3Type P = SE3Type::Polygon(r3, lines); SEToFile(P, outputImage); } else diff --git a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleConnectedClosingImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleConnectedClosingImageFilterTest.cxx index fdd257446ce..b43b29aaa92 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleConnectedClosingImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleConnectedClosingImageFilterTest.cxx @@ -61,7 +61,7 @@ itkGrayscaleConnectedClosingImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(connectedClosing, GrayscaleConnectedClosingImageFilter, ImageToImageFilter); - itk::SimpleFilterWatcher watcher(connectedClosing, "connectedClosing"); + const itk::SimpleFilterWatcher watcher(connectedClosing, "connectedClosing"); using ReaderType = itk::ImageFileReader; auto reader = ReaderType::New(); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleDilateImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleDilateImageFilterTest.cxx index e0f1d2375b1..e3f57bc79ee 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleDilateImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleDilateImageFilterTest.cxx @@ -59,7 +59,7 @@ itkGrayscaleDilateImageFilterTest(int argc, char * argv[]) filter->SetInput(reader->GetOutput()); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using RadiusType = FilterType::RadiusType; diff --git a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleErodeImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleErodeImageFilterTest.cxx index bb45d0125c0..4d0429f1dd8 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleErodeImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleErodeImageFilterTest.cxx @@ -59,7 +59,7 @@ itkGrayscaleErodeImageFilterTest(int argc, char * argv[]) filter->SetInput(reader->GetOutput()); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using RadiusType = FilterType::RadiusType; diff --git a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleFunctionDilateImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleFunctionDilateImageFilterTest.cxx index dab2a524327..67054cd6e89 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleFunctionDilateImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleFunctionDilateImageFilterTest.cxx @@ -57,7 +57,7 @@ itkGrayscaleFunctionDilateImageFilterTest(int argc, char * argv[]) start[0] = 0; start[1] = 0; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; // Initialize Image inputImage->SetRegions(region); @@ -122,7 +122,7 @@ itkGrayscaleFunctionDilateImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, GrayscaleFunctionDilateImageFilter, MorphologyImageFilter); - itk::SimpleFilterWatcher filterWatcher(filter); + const itk::SimpleFilterWatcher filterWatcher(filter); // Create the structuring element myKernelType ball; @@ -137,7 +137,7 @@ itkGrayscaleFunctionDilateImageFilterTest(int argc, char * argv[]) filter->SetKernel(ball); // Get the Smart Pointer to the Filter Output - myImageType::Pointer outputImage = filter->GetOutput(); + const myImageType::Pointer outputImage = filter->GetOutput(); // Execute the filter ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleFunctionErodeImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleFunctionErodeImageFilterTest.cxx index c9aba14f5f5..4a756e55d01 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleFunctionErodeImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleFunctionErodeImageFilterTest.cxx @@ -57,7 +57,7 @@ itkGrayscaleFunctionErodeImageFilterTest(int argc, char * argv[]) start[0] = 0; start[1] = 0; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; // Initialize Image inputImage->SetRegions(region); @@ -122,7 +122,7 @@ itkGrayscaleFunctionErodeImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, GrayscaleFunctionErodeImageFilter, MorphologyImageFilter); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); // Create the structuring element myKernelType ball; @@ -137,7 +137,7 @@ itkGrayscaleFunctionErodeImageFilterTest(int argc, char * argv[]) filter->SetKernel(ball); // Get the Smart Pointer to the Filter Output - myImageType::Pointer outputImage = filter->GetOutput(); + const myImageType::Pointer outputImage = filter->GetOutput(); // Execute the filter ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleGeodesicErodeDilateImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleGeodesicErodeDilateImageFilterTest.cxx index 0f0ec5f4584..0164e03819c 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleGeodesicErodeDilateImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleGeodesicErodeDilateImageFilterTest.cxx @@ -104,8 +104,8 @@ itkGrayscaleGeodesicErodeDilateImageFilterTest(int argc, char * argv[]) writer->SetInput(erode->GetOutput()); - itk::SimpleFilterWatcher watchDilate(dilate); - itk::SimpleFilterWatcher watchErode(erode); + const itk::SimpleFilterWatcher watchDilate(dilate); + const itk::SimpleFilterWatcher watchErode(erode); ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update()); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalClosingImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalClosingImageFilterTest.cxx index f17b958994c..224c8f9e6c5 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalClosingImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalClosingImageFilterTest.cxx @@ -66,7 +66,7 @@ itkGrayscaleMorphologicalClosingImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, GrayscaleMorphologicalClosingImageFilter, KernelImageFilter); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); auto safeBorder = static_cast(std::stoi(argv[3])); ITK_TEST_SET_GET_BOOLEAN(filter, SafeBorder, safeBorder); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalClosingImageFilterTest2.cxx b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalClosingImageFilterTest2.cxx index 8742812cf3c..d706b5f9260 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalClosingImageFilterTest2.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalClosingImageFilterTest2.cxx @@ -52,7 +52,7 @@ itkGrayscaleMorphologicalClosingImageFilterTest2(int argc, char * argv[]) auto filter = FilterType::New(); filter->SetInput(reader->GetOutput()); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using RadiusType = FilterType::RadiusType; @@ -64,7 +64,7 @@ itkGrayscaleMorphologicalClosingImageFilterTest2(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(true, filter->GetSafeBorder()); - itk::SizeValueType radiusValue{ static_cast(std::stoi(argv[2])) }; + const itk::SizeValueType radiusValue{ static_cast(std::stoi(argv[2])) }; filter->SetRadius(radiusValue); RadiusType radius{}; radius.Fill(radiusValue); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalOpeningImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalOpeningImageFilterTest.cxx index 5b869df9a83..22811fa9b1b 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalOpeningImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalOpeningImageFilterTest.cxx @@ -66,7 +66,7 @@ itkGrayscaleMorphologicalOpeningImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, GrayscaleMorphologicalOpeningImageFilter, KernelImageFilter); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); auto safeBorder = static_cast(std::stoi(argv[3])); ITK_TEST_SET_GET_BOOLEAN(filter, SafeBorder, safeBorder); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalOpeningImageFilterTest2.cxx b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalOpeningImageFilterTest2.cxx index 66d192b9540..48a400dc6e3 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalOpeningImageFilterTest2.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkGrayscaleMorphologicalOpeningImageFilterTest2.cxx @@ -52,7 +52,7 @@ itkGrayscaleMorphologicalOpeningImageFilterTest2(int argc, char * argv[]) auto filter = FilterType::New(); filter->SetInput(reader->GetOutput()); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using RadiusType = FilterType::RadiusType; @@ -65,7 +65,7 @@ itkGrayscaleMorphologicalOpeningImageFilterTest2(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(true, filter->GetSafeBorder()); - itk::SizeValueType radiusValue{ static_cast(std::stoi(argv[2])) }; + const itk::SizeValueType radiusValue{ static_cast(std::stoi(argv[2])) }; filter->SetRadius(radiusValue); RadiusType radius{}; radius.Fill(radiusValue); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkHConcaveImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkHConcaveImageFilterTest.cxx index 156397c7895..a72bf12c12c 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkHConcaveImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkHConcaveImageFilterTest.cxx @@ -64,7 +64,7 @@ itkHConcaveImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(hConcaveFilter, HConcaveImageFilter, ImageToImageFilter); - itk::SimpleFilterWatcher watchConcave(hConcaveFilter, "HConcaveImageFilter"); + const itk::SimpleFilterWatcher watchConcave(hConcaveFilter, "HConcaveImageFilter"); // Set up the filter auto height = static_cast(std::stod(argv[3])); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkHConvexConcaveImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkHConvexConcaveImageFilterTest.cxx index f814bda8f57..97884de2030 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkHConvexConcaveImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkHConvexConcaveImageFilterTest.cxx @@ -72,8 +72,8 @@ itkHConvexConcaveImageFilterTest(int argc, char * argv[]) auto hConvexFilter = HConvexFilterType::New(); auto hConcaveFilter = HConcaveFilterType::New(); - itk::SimpleFilterWatcher watchConvex(hConvexFilter, "HConvexImageFilter"); - itk::SimpleFilterWatcher watchConcave(hConcaveFilter, "HConcaveImageFilter"); + const itk::SimpleFilterWatcher watchConvex(hConvexFilter, "HConvexImageFilter"); + const itk::SimpleFilterWatcher watchConcave(hConcaveFilter, "HConcaveImageFilter"); // Set up the input and output files reader->SetFileName(argv[1]); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkHConvexImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkHConvexImageFilterTest.cxx index 5cc4e828414..4849484e3ba 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkHConvexImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkHConvexImageFilterTest.cxx @@ -64,7 +64,7 @@ itkHConvexImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(hConvexFilter, HConvexImageFilter, ImageToImageFilter); - itk::SimpleFilterWatcher watchConvex(hConvexFilter, "HConvexImageFilter"); + const itk::SimpleFilterWatcher watchConvex(hConvexFilter, "HConvexImageFilter"); // Set up the filter auto height = static_cast(std::stod(argv[3])); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkHMaximaImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkHMaximaImageFilterTest.cxx index 2eb215fd35d..3a8999cc038 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkHMaximaImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkHMaximaImageFilterTest.cxx @@ -64,7 +64,7 @@ itkHMaximaImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(hMaximaFilter, HMaximaImageFilter, ImageToImageFilter); - itk::SimpleFilterWatcher watchHMaxima(hMaximaFilter, "HMaximaImageFilter"); + const itk::SimpleFilterWatcher watchHMaxima(hMaximaFilter, "HMaximaImageFilter"); // Set up the filter auto height = static_cast(std::stod(argv[3])); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkHMaximaMinimaImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkHMaximaMinimaImageFilterTest.cxx index 6f87b6a6abc..3d69cfdfe78 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkHMaximaMinimaImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkHMaximaMinimaImageFilterTest.cxx @@ -67,8 +67,8 @@ itkHMaximaMinimaImageFilterTest(int argc, char * argv[]) auto hMaximaFilter = HMaximaFilterType::New(); auto hMinimaFilter = HMinimaFilterType::New(); - itk::SimpleFilterWatcher watchHmaxima(hMaximaFilter, "HMaximaImageFilter"); - itk::SimpleFilterWatcher watchHminima(hMinimaFilter, "HMinimaImageFilter"); + const itk::SimpleFilterWatcher watchHmaxima(hMaximaFilter, "HMaximaImageFilter"); + const itk::SimpleFilterWatcher watchHminima(hMinimaFilter, "HMinimaImageFilter"); // Set up the input and output files reader->SetFileName(argv[1]); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkHMinimaImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkHMinimaImageFilterTest.cxx index 9156b24d738..0823c6ed40a 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkHMinimaImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkHMinimaImageFilterTest.cxx @@ -64,7 +64,7 @@ itkHMinimaImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(hMinimaFilter, HMinimaImageFilter, ImageToImageFilter); - itk::SimpleFilterWatcher watchHMinima(hMinimaFilter, "HMinimaImageFilter"); + const itk::SimpleFilterWatcher watchHMinima(hMinimaFilter, "HMinimaImageFilter"); // Set up the filter auto height = static_cast(std::stod(argv[3])); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkMapGrayscaleDilateImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkMapGrayscaleDilateImageFilterTest.cxx index 9817bd349d1..26f8fd5c85b 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkMapGrayscaleDilateImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkMapGrayscaleDilateImageFilterTest.cxx @@ -50,7 +50,7 @@ itkMapGrayscaleDilateImageFilterTest(int argc, char * argv[]) auto filter = FilterType::New(); filter->SetInput(reader->GetOutput()); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using RadiusType = FilterType::RadiusType; diff --git a/Modules/Filtering/MathematicalMorphology/test/itkMapGrayscaleErodeImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkMapGrayscaleErodeImageFilterTest.cxx index be38bb10ac1..91b6b3bf05a 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkMapGrayscaleErodeImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkMapGrayscaleErodeImageFilterTest.cxx @@ -50,7 +50,7 @@ itkMapGrayscaleErodeImageFilterTest(int argc, char * argv[]) auto filter = FilterType::New(); filter->SetInput(reader->GetOutput()); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using RadiusType = FilterType::RadiusType; diff --git a/Modules/Filtering/MathematicalMorphology/test/itkMapGrayscaleMorphologicalClosingImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkMapGrayscaleMorphologicalClosingImageFilterTest.cxx index 3a821d50f29..0d144f13d53 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkMapGrayscaleMorphologicalClosingImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkMapGrayscaleMorphologicalClosingImageFilterTest.cxx @@ -51,7 +51,7 @@ itkMapGrayscaleMorphologicalClosingImageFilterTest(int argc, char * argv[]) auto filter = FilterType::New(); filter->SetInput(reader->GetOutput()); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using RadiusType = FilterType::RadiusType; diff --git a/Modules/Filtering/MathematicalMorphology/test/itkMapGrayscaleMorphologicalOpeningImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkMapGrayscaleMorphologicalOpeningImageFilterTest.cxx index f95addc9d69..156cb4b6ede 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkMapGrayscaleMorphologicalOpeningImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkMapGrayscaleMorphologicalOpeningImageFilterTest.cxx @@ -51,7 +51,7 @@ itkMapGrayscaleMorphologicalOpeningImageFilterTest(int argc, char * argv[]) auto filter = FilterType::New(); filter->SetInput(reader->GetOutput()); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); using RadiusType = FilterType::RadiusType; diff --git a/Modules/Filtering/MathematicalMorphology/test/itkMapMaskedRankImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkMapMaskedRankImageFilterTest.cxx index 858671c1676..048459ff17a 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkMapMaskedRankImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkMapMaskedRankImageFilterTest.cxx @@ -49,8 +49,8 @@ itkMapMaskedRankImageFilterTest(int argc, char * argv[]) // Create a filter using SEType = itk::FlatStructuringElement<2>; using FilterType = itk::MaskedRankImageFilter; - auto filter = FilterType::New(); - itk::SimpleFilterWatcher filterWatch(filter); + auto filter = FilterType::New(); + const itk::SimpleFilterWatcher filterWatch(filter); using RadiusType = FilterType::RadiusType; @@ -130,7 +130,7 @@ itkMapMaskedRankImageFilterTest(int argc, char * argv[]) try { - int r = std::stoi(argv[4]); + const int r = std::stoi(argv[4]); filter->SetInput(input->GetOutput()); filter->SetMaskImage(input2->GetOutput()); filter->SetRadius(r); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkMapRankImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkMapRankImageFilterTest.cxx index 852b50d9223..206c08e8973 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkMapRankImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkMapRankImageFilterTest.cxx @@ -46,8 +46,8 @@ itkMapRankImageFilterTest(int argc, char * argv[]) using SEType = itk::FlatStructuringElement<2>; using FilterType = itk::RankImageFilter; - auto filter = FilterType::New(); - itk::SimpleFilterWatcher filterWatch(filter); + auto filter = FilterType::New(); + const itk::SimpleFilterWatcher filterWatch(filter); using RadiusType = FilterType::RadiusType; @@ -90,7 +90,7 @@ itkMapRankImageFilterTest(int argc, char * argv[]) try { - int r = std::stoi(argv[3]); + const int r = std::stoi(argv[3]); filter->SetInput(input->GetOutput()); filter->SetRadius(r); filter->SetRank(0.5); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkMaskedRankImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkMaskedRankImageFilterTest.cxx index db7994afdae..ca750771f37 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkMaskedRankImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkMaskedRankImageFilterTest.cxx @@ -48,8 +48,8 @@ itkMaskedRankImageFilterTest(int argc, char * argv[]) // Create a filter using FilterType = itk::MaskedRankImageFilter; - auto filter = FilterType::New(); - itk::SimpleFilterWatcher filterWatch(filter); + auto filter = FilterType::New(); + const itk::SimpleFilterWatcher filterWatch(filter); using RadiusType = FilterType::RadiusType; @@ -129,7 +129,7 @@ itkMaskedRankImageFilterTest(int argc, char * argv[]) try { - int r = std::stoi(argv[4]); + const int r = std::stoi(argv[4]); filter->SetInput(input->GetOutput()); filter->SetMaskImage(input2->GetOutput()); filter->SetRadius(r); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkMorphologicalGradientImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkMorphologicalGradientImageFilterTest.cxx index e4e35b0fd48..0b6c5c61fbf 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkMorphologicalGradientImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkMorphologicalGradientImageFilterTest.cxx @@ -52,7 +52,7 @@ itkMorphologicalGradientImageFilterTest(int argc, char * argv[]) gradient->SetInput(reader->GetOutput()); gradient->SetKernel(structuringElement); - itk::SimpleFilterWatcher watcher(gradient); + const itk::SimpleFilterWatcher watcher(gradient); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkMorphologicalGradientImageFilterTest2.cxx b/Modules/Filtering/MathematicalMorphology/test/itkMorphologicalGradientImageFilterTest2.cxx index 6262f0055bc..18d22f7b28f 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkMorphologicalGradientImageFilterTest2.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkMorphologicalGradientImageFilterTest2.cxx @@ -52,7 +52,7 @@ itkMorphologicalGradientImageFilterTest2(int argc, char * argv[]) auto gradient = GradientType::New(); gradient->SetInput(reader->GetOutput()); gradient->SetKernel(structuringElement); - itk::SimpleFilterWatcher watcher(gradient); + const itk::SimpleFilterWatcher watcher(gradient); const GradientType::AlgorithmEnum algorithmType = gradient->GetAlgorithm(); std::cout << "algorithmType : " << algorithmType << std::endl; @@ -76,8 +76,8 @@ itkMorphologicalGradientImageFilterTest2(int argc, char * argv[]) using SRType = itk::FlatStructuringElement; - auto elementRadius = itk::MakeFilled(4); - SRType structuringElement2 = SRType::Box(elementRadius); + auto elementRadius = itk::MakeFilled(4); + const SRType structuringElement2 = SRType::Box(elementRadius); using Gradient1Type = itk::MorphologicalGradientImageFilter; auto gradient1 = Gradient1Type::New(); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkMovingHistogramMorphologyImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkMovingHistogramMorphologyImageFilterTest.cxx index 3f3a26b0777..6b80de449aa 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkMovingHistogramMorphologyImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkMovingHistogramMorphologyImageFilterTest.cxx @@ -38,7 +38,7 @@ itkMovingHistogramMorphologyImageFilterTest(int, char ** const) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, MovingHistogramMorphologyImageFilter, MovingHistogramImageFilter); - typename FilterType::InputImagePixelType boundary = 255; + const typename FilterType::InputImagePixelType boundary = 255; filter->SetBoundary(boundary); ITK_TEST_SET_GET_VALUE(boundary, filter->GetBoundary()); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkOpeningByReconstructionImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkOpeningByReconstructionImageFilterTest.cxx index 80c5181ac31..e715d666879 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkOpeningByReconstructionImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkOpeningByReconstructionImageFilterTest.cxx @@ -71,10 +71,10 @@ itkOpeningByReconstructionImageFilterTest(int argc, char * argv[]) filter->SetKernel(structuringElement); ITK_TEST_SET_GET_VALUE(structuringElement, filter->GetKernel()); - bool preserveIntensities = static_cast(std::stoi(argv[4])); + const bool preserveIntensities = static_cast(std::stoi(argv[4])); ITK_TEST_SET_GET_BOOLEAN(filter, PreserveIntensities, preserveIntensities); - bool fullyConnected = static_cast(std::stoi(argv[5])); + const bool fullyConnected = static_cast(std::stoi(argv[5])); ITK_TEST_SET_GET_BOOLEAN(filter, FullyConnected, fullyConnected); filter->SetInput(reader->GetOutput()); @@ -95,7 +95,7 @@ itkOpeningByReconstructionImageFilterTest(int argc, char * argv[]) // Create a difference image if one is requested if (argc == 7) { - itk::SubtractImageFilter::Pointer subtract = + const itk::SubtractImageFilter::Pointer subtract = itk::SubtractImageFilter::New(); subtract->SetInput(0, reader->GetOutput()); subtract->SetInput(1, filter->GetOutput()); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkOpeningByReconstructionImageFilterTest2.cxx b/Modules/Filtering/MathematicalMorphology/test/itkOpeningByReconstructionImageFilterTest2.cxx index 00a6dff380a..b59b900fe68 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkOpeningByReconstructionImageFilterTest2.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkOpeningByReconstructionImageFilterTest2.cxx @@ -56,9 +56,9 @@ itkOpeningByReconstructionImageFilterTest2(int argc, char * argv[]) auto inputImage = InputImageType::New(); // Define regions of input image - RegionType region; - auto size = SizeType::Filled(std::stoi(argv[2])); - IndexType index{}; + RegionType region; + auto size = SizeType::Filled(std::stoi(argv[2])); + const IndexType index{}; region.SetSize(size); region.SetIndex(index); @@ -96,10 +96,10 @@ itkOpeningByReconstructionImageFilterTest2(int argc, char * argv[]) filter->SetKernel(structuringElement); ITK_TEST_SET_GET_VALUE(structuringElement, filter->GetKernel()); - bool preserveIntensities = static_cast(std::stoi(argv[3])); + const bool preserveIntensities = static_cast(std::stoi(argv[3])); ITK_TEST_SET_GET_BOOLEAN(filter, PreserveIntensities, preserveIntensities); - bool fullyConnected = static_cast(std::stoi(argv[4])); + const bool fullyConnected = static_cast(std::stoi(argv[4])); ITK_TEST_SET_GET_BOOLEAN(filter, FullyConnected, fullyConnected); filter->SetInput(inputImage); @@ -120,7 +120,7 @@ itkOpeningByReconstructionImageFilterTest2(int argc, char * argv[]) // Create a difference image if one is requested if (argc == 10) { - itk::SubtractImageFilter::Pointer subtract = + const itk::SubtractImageFilter::Pointer subtract = itk::SubtractImageFilter::New(); subtract->SetInput(0, inputImage); subtract->SetInput(1, filter->GetOutput()); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkRankImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkRankImageFilterTest.cxx index 575f41cbcd7..30ad90d06e8 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkRankImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkRankImageFilterTest.cxx @@ -44,8 +44,8 @@ itkRankImageFilterTest(int argc, char * argv[]) // Create a filter using FilterType = itk::RankImageFilter; - auto filter = FilterType::New(); - itk::SimpleFilterWatcher filterWatch(filter); + auto filter = FilterType::New(); + const itk::SimpleFilterWatcher filterWatch(filter); using RadiusType = FilterType::RadiusType; @@ -88,7 +88,7 @@ itkRankImageFilterTest(int argc, char * argv[]) try { - int r = std::stoi(argv[3]); + const int r = std::stoi(argv[3]); filter->SetInput(input->GetOutput()); filter->SetRadius(r); filter->SetRank(0.5); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkRegionalMaximaImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkRegionalMaximaImageFilterTest.cxx index c030c23622a..6ba052747a0 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkRegionalMaximaImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkRegionalMaximaImageFilterTest.cxx @@ -49,17 +49,17 @@ RegionalMaximaImageFilterTestHelper(std::string inputImageFile, ITK_TEST_SET_GET_BOOLEAN(filter, FlatIsMaxima, flatIsMaxima); - typename FilterType::OutputImagePixelType foregroundValue = + const typename FilterType::OutputImagePixelType foregroundValue = itk::NumericTraits::max(); filter->SetForegroundValue(foregroundValue); ITK_TEST_SET_GET_VALUE(foregroundValue, filter->GetForegroundValue()); - typename FilterType::OutputImagePixelType backgroundValue = + const typename FilterType::OutputImagePixelType backgroundValue = itk::NumericTraits::NonpositiveMin(); filter->SetBackgroundValue(backgroundValue); ITK_TEST_SET_GET_VALUE(backgroundValue, filter->GetBackgroundValue()); - itk::SimpleFilterWatcher watcher(filter, "RegionalMaximaImageFilter"); + const itk::SimpleFilterWatcher watcher(filter, "RegionalMaximaImageFilter"); // Write the output images using WriterType = itk::ImageFileWriter; @@ -111,14 +111,14 @@ itkRegionalMaximaImageFilterTest(int argc, char * argv[]) return EXIT_FAILURE; } - std::string inputImageFile = argv[1]; - std::string outputImageFile = argv[2]; - std::string outputImageFile2 = argv[3]; + const std::string inputImageFile = argv[1]; + const std::string outputImageFile = argv[2]; + const std::string outputImageFile2 = argv[3]; - unsigned int dimension = std::stoi(argv[4]); + const unsigned int dimension = std::stoi(argv[4]); - bool fullyConnected = std::stoi(argv[5]); - bool flatIsMaxima = std::stoi(argv[6]); + const bool fullyConnected = std::stoi(argv[5]); + const bool flatIsMaxima = std::stoi(argv[6]); // Exercise basic object methods // Done outside the helper function in the test because GCC is limited diff --git a/Modules/Filtering/MathematicalMorphology/test/itkRegionalMinimaImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkRegionalMinimaImageFilterTest.cxx index 9c6c9523e9d..2d8152ca3e6 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkRegionalMinimaImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkRegionalMinimaImageFilterTest.cxx @@ -49,17 +49,17 @@ RegionalMinimaImageFilterTestHelper(std::string inputImageFile, ITK_TEST_SET_GET_BOOLEAN(filter, FlatIsMinima, flatIsMinima); - typename FilterType::OutputImagePixelType foregroundValue = + const typename FilterType::OutputImagePixelType foregroundValue = itk::NumericTraits::max(); filter->SetForegroundValue(foregroundValue); ITK_TEST_SET_GET_VALUE(foregroundValue, filter->GetForegroundValue()); - typename FilterType::OutputImagePixelType backgroundValue = + const typename FilterType::OutputImagePixelType backgroundValue = itk::NumericTraits::NonpositiveMin(); filter->SetBackgroundValue(backgroundValue); ITK_TEST_SET_GET_VALUE(backgroundValue, filter->GetBackgroundValue()); - itk::SimpleFilterWatcher watcher(filter, "RegionalMinimaImageFilter"); + const itk::SimpleFilterWatcher watcher(filter, "RegionalMinimaImageFilter"); // Write the output images using WriterType = itk::ImageFileWriter; @@ -111,14 +111,14 @@ itkRegionalMinimaImageFilterTest(int argc, char * argv[]) return EXIT_FAILURE; } - std::string inputImageFile = argv[1]; - std::string outputImageFile = argv[2]; - std::string outputImageFile2 = argv[3]; + const std::string inputImageFile = argv[1]; + const std::string outputImageFile = argv[2]; + const std::string outputImageFile2 = argv[3]; - unsigned int dimension = std::stoi(argv[4]); + const unsigned int dimension = std::stoi(argv[4]); - bool fullyConnected = std::stoi(argv[5]); - bool flatIsMinima = std::stoi(argv[6]); + const bool fullyConnected = std::stoi(argv[5]); + const bool flatIsMinima = std::stoi(argv[6]); // Exercise basic object methods // Done outside the helper function in the test because GCC is limited diff --git a/Modules/Filtering/MathematicalMorphology/test/itkShapedIteratorFromStructuringElementTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkShapedIteratorFromStructuringElementTest.cxx index c4bba3bada8..cbcf9232c11 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkShapedIteratorFromStructuringElementTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkShapedIteratorFromStructuringElementTest.cxx @@ -22,11 +22,11 @@ using LocalImageType = itk::Image; void CreateImagex(LocalImageType::Pointer & image) { - LocalImageType::IndexType start{}; + const LocalImageType::IndexType start{}; auto size = LocalImageType::SizeType::Filled(10); - LocalImageType::RegionType region(start, size); + const LocalImageType::RegionType region(start, size); image->SetRegions(region); image->AllocateInitialized(); @@ -71,7 +71,7 @@ itkShapedIteratorFromStructuringElementTest(int, char *[]) unsigned int col = 0; while (!imit.IsAtEnd()) { - PixelType value = imit.Get(); + const PixelType value = imit.Get(); ++imit; ++col; std::cout << value << ' '; diff --git a/Modules/Filtering/MathematicalMorphology/test/itkTopHatImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkTopHatImageFilterTest.cxx index f474bf89062..15fc22ceeea 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkTopHatImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkTopHatImageFilterTest.cxx @@ -41,7 +41,7 @@ itkTopHatImageFilterTestHelper(TKernelImageFilter * auto reader = ReaderType::New(); reader->SetFileName(inputFileName); - itk::SimpleFilterWatcher watcher(filter, "filter"); + const itk::SimpleFilterWatcher watcher(filter, "filter"); ITK_TEST_SET_GET_BOOLEAN(filter, SafeBorder, safeBorder); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkValuedRegionalMaximaImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkValuedRegionalMaximaImageFilterTest.cxx index f81e2a5f2c0..06f06066997 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkValuedRegionalMaximaImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkValuedRegionalMaximaImageFilterTest.cxx @@ -55,11 +55,11 @@ itkValuedRegionalMaximaImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, ValuedRegionalMaximaImageFilter, ValuedRegionalExtremaImageFilter); - bool fullyConnected = std::stoi(argv[4]); + const bool fullyConnected = std::stoi(argv[4]); ITK_TEST_SET_GET_BOOLEAN(filter, FullyConnected, fullyConnected); - itk::SimpleFilterWatcher watcher(filter, "ValuedRegionalMaximaImageFilter"); + const itk::SimpleFilterWatcher watcher(filter, "ValuedRegionalMaximaImageFilter"); filter->SetInput(reader->GetOutput()); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkValuedRegionalMinimaImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkValuedRegionalMinimaImageFilterTest.cxx index 1211a21d077..2d60f9b005b 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkValuedRegionalMinimaImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkValuedRegionalMinimaImageFilterTest.cxx @@ -57,11 +57,11 @@ itkValuedRegionalMinimaImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, ValuedRegionalMinimaImageFilter, ValuedRegionalExtremaImageFilter); - bool fullyConnected = std::stoi(argv[4]); + const bool fullyConnected = std::stoi(argv[4]); ITK_TEST_SET_GET_BOOLEAN(filter, FullyConnected, fullyConnected); - itk::SimpleFilterWatcher watcher(filter, "ValuedRegionalMinimaImageFilter"); + const itk::SimpleFilterWatcher watcher(filter, "ValuedRegionalMinimaImageFilter"); filter->SetInput(reader->GetOutput()); diff --git a/Modules/Filtering/MathematicalMorphology/test/itkVanHerkGilWermanErodeDilateImageFilterTest.cxx b/Modules/Filtering/MathematicalMorphology/test/itkVanHerkGilWermanErodeDilateImageFilterTest.cxx index 99d1987bd43..9ce7920903b 100644 --- a/Modules/Filtering/MathematicalMorphology/test/itkVanHerkGilWermanErodeDilateImageFilterTest.cxx +++ b/Modules/Filtering/MathematicalMorphology/test/itkVanHerkGilWermanErodeDilateImageFilterTest.cxx @@ -37,7 +37,7 @@ itkVanHerkGilWermanErodeDilateImageFilterTest(int, char ** const) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, VanHerkGilWermanErodeDilateImageFilter, KernelImageFilter); - typename FilterType::InputImagePixelType boundary = 255; + const typename FilterType::InputImagePixelType boundary = 255; filter->SetBoundary(boundary); ITK_TEST_SET_GET_VALUE(boundary, filter->GetBoundary()); diff --git a/Modules/Filtering/Path/include/itkChainCodeToFourierSeriesPathFilter.hxx b/Modules/Filtering/Path/include/itkChainCodeToFourierSeriesPathFilter.hxx index 7c331d014c1..cd622fc8104 100644 --- a/Modules/Filtering/Path/include/itkChainCodeToFourierSeriesPathFilter.hxx +++ b/Modules/Filtering/Path/include/itkChainCodeToFourierSeriesPathFilter.hxx @@ -42,10 +42,10 @@ ChainCodeToFourierSeriesPathFilterGetInput(); - typename Superclass::OutputPathPointer outputPtr = this->GetOutput(0); + const typename Superclass::InputPathConstPointer inputPtr = this->GetInput(); + const typename Superclass::OutputPathPointer outputPtr = this->GetOutput(0); // outputPtr->SetRequestedRegion( inputPtr->GetRequestedRegion() ); // outputPtr->SetBufferedRegion( inputPtr->GetBufferedRegion() ); diff --git a/Modules/Filtering/Path/include/itkContourExtractor2DImageFilter.hxx b/Modules/Filtering/Path/include/itkContourExtractor2DImageFilter.hxx index deeeedc0212..a0d9d0cf6c9 100644 --- a/Modules/Filtering/Path/include/itkContourExtractor2DImageFilter.hxx +++ b/Modules/Filtering/Path/include/itkContourExtractor2DImageFilter.hxx @@ -347,7 +347,7 @@ ContourExtractor2DImageFilter::GenerateDataForLabels() inputRegion.GetIndex()[1] + static_cast(inputRegion.GetSize()[1]) - 1 } }; std::unordered_map labelBoundingBoxes; - for (InputPixelType label : allLabels) + for (const InputPixelType label : allLabels) { labelBoundingBoxes[label] = BoundingBoxType{ right_bot, left_top }; } @@ -362,7 +362,7 @@ ContourExtractor2DImageFilter::GenerateDataForLabels() bbox.max[1] = std::max(bbox.max[1], inputIt.GetIndex()[1]); } // Build the extended regions from the bounding boxes - for (InputPixelType label : allLabels) + for (const InputPixelType label : allLabels) { const BoundingBoxType & bbox = labelBoundingBoxes[label]; // Compute an extendedRegion that includes one-pixel border on all @@ -382,7 +382,7 @@ ContourExtractor2DImageFilter::GenerateDataForLabels() } } - itk::MultiThreaderBase::Pointer mt = this->GetMultiThreader(); + const itk::MultiThreaderBase::Pointer mt = this->GetMultiThreader(); mt->ParallelizeArray( 0, allLabels.size(), @@ -565,7 +565,7 @@ ContourExtractor2DImageFilter::FillOutputs( std::unordered_map & labelsContoursOutput) { ContourContainerType allContours; - for (InputPixelType label : allLabels) + for (const InputPixelType label : allLabels) { allContours.splice(allContours.end(), labelsContoursOutput[label]); } @@ -580,7 +580,7 @@ ContourExtractor2DImageFilter::FillOutputs( output = dynamic_cast(this->MakeOutput(NumberOutputsWritten).GetPointer()); this->SetNthOutput(NumberOutputsWritten, output.GetPointer()); } - typename VertexListType::Pointer path{ const_cast(output->GetVertexList()) }; + const typename VertexListType::Pointer path{ const_cast(output->GetVertexList()) }; path->Initialize(); // use std::vector version of 'reserve()' instead of // VectorContainer::Reserve() to work around the fact that the latter is diff --git a/Modules/Filtering/Path/include/itkExtractOrthogonalSwath2DImageFilter.hxx b/Modules/Filtering/Path/include/itkExtractOrthogonalSwath2DImageFilter.hxx index eecbf29b527..9a8d127e8c1 100644 --- a/Modules/Filtering/Path/include/itkExtractOrthogonalSwath2DImageFilter.hxx +++ b/Modules/Filtering/Path/include/itkExtractOrthogonalSwath2DImageFilter.hxx @@ -134,7 +134,7 @@ template void ExtractOrthogonalSwath2DImageFilter::GenerateOutputInformation() { - ImagePointer outputPtr = this->GetOutput(0); + const ImagePointer outputPtr = this->GetOutput(0); const ImageRegionType outputRegion(this->m_Size); outputPtr->SetLargestPossibleRegion(outputRegion); @@ -149,12 +149,12 @@ template void ExtractOrthogonalSwath2DImageFilter::GenerateData() { - ImageConstPointer inputImagePtr = this->GetImageInput(); - PathConstPointer inputPathPtr = this->GetPathInput(); - ImagePointer outputPtr = this->GetOutput(0); + const ImageConstPointer inputImagePtr = this->GetImageInput(); + const PathConstPointer inputPathPtr = this->GetPathInput(); + const ImagePointer outputPtr = this->GetOutput(0); // Generate the output image - ImageRegionType outputRegion = outputPtr->GetRequestedRegion(); + const ImageRegionType outputRegion = outputPtr->GetRequestedRegion(); outputPtr->SetBufferedRegion(outputRegion); outputPtr->Allocate(); diff --git a/Modules/Filtering/Path/include/itkFourierSeriesPath.hxx b/Modules/Filtering/Path/include/itkFourierSeriesPath.hxx index ceeb79da622..e01633d5f0f 100644 --- a/Modules/Filtering/Path/include/itkFourierSeriesPath.hxx +++ b/Modules/Filtering/Path/include/itkFourierSeriesPath.hxx @@ -28,7 +28,7 @@ FourierSeriesPath::Evaluate(const InputType & input) const -> Output { InputType theta; OutputType output; - int numHarmonics = m_CosCoefficients->Size(); + const int numHarmonics = m_CosCoefficients->Size(); output.Fill(0); const double PI = 4.0 * std::atan(1.0); @@ -55,7 +55,7 @@ FourierSeriesPath::EvaluateDerivative(const InputType & input) const { InputType theta; VectorType output; - int numHarmonics = m_CosCoefficients->Size(); + const int numHarmonics = m_CosCoefficients->Size(); output.Fill(0); const double PI = 4.0 * std::atan(1.0); @@ -75,7 +75,7 @@ template void FourierSeriesPath::AddHarmonic(const VectorType & CosCoefficients, const VectorType & SinCoefficients) { - unsigned int numHarmonics = m_CosCoefficients->Size(); + const unsigned int numHarmonics = m_CosCoefficients->Size(); m_CosCoefficients->InsertElement(numHarmonics, CosCoefficients); m_SinCoefficients->InsertElement(numHarmonics, SinCoefficients); diff --git a/Modules/Filtering/Path/include/itkHilbertPath.hxx b/Modules/Filtering/Path/include/itkHilbertPath.hxx index ed4e54b943a..937e2f4ff49 100644 --- a/Modules/Filtering/Path/include/itkHilbertPath.hxx +++ b/Modules/Filtering/Path/include/itkHilbertPath.hxx @@ -57,12 +57,12 @@ HilbertPath::TransformPathIndexToMultiDimensionalIndex( for (PathIndexType i = 0; i < this->m_HilbertOrder; ++i) { - PathIndexType w = this->GetBitRange(id, Dimension * this->m_HilbertOrder, i * Dimension, (i + 1) * Dimension); - PathIndexType l = this->GetGrayCode(w); + const PathIndexType w = this->GetBitRange(id, Dimension * this->m_HilbertOrder, i * Dimension, (i + 1) * Dimension); + PathIndexType l = this->GetGrayCode(w); l = this->GetInverseTransform(e, d, Dimension, l); for (PathIndexType j = 0; j < Dimension; ++j) { - PathIndexType b = this->GetBitRange(l, Dimension, j, j + 1); + const PathIndexType b = this->GetBitRange(l, Dimension, j, j + 1); index[j] = this->SetBit(index[j], this->m_HilbertOrder, i, b); } e ^= this->GetLeftBitRotation(this->GetEntry(w), d + 1, Dimension); @@ -86,11 +86,11 @@ HilbertPath::TransformMultiDimensionalIndexToPathIndex( PathIndexType l = 0; for (PathIndexType j = 0; j < Dimension; ++j) { - PathIndexType b = this->GetBitRange(index[Dimension - j - 1], this->m_HilbertOrder, i, i + 1); + const PathIndexType b = this->GetBitRange(index[Dimension - j - 1], this->m_HilbertOrder, i, i + 1); l |= b << j; } l = this->GetTransform(e, d, Dimension, l); - PathIndexType w = this->GetInverseGrayCode(l); + const PathIndexType w = this->GetInverseGrayCode(l); e ^= this->GetLeftBitRotation(this->GetEntry(w), d + 1, Dimension); d = (d + this->GetDirection(w, Dimension) + 1) % Dimension; id = (id << Dimension) | w; @@ -177,7 +177,7 @@ HilbertPath::GetInverseGrayCode(const PathIndexType x) return x; } - PathIndexType m = static_cast(std::ceil(std::log(static_cast(x)) / std::log(2.0))) + 1; + const PathIndexType m = static_cast(std::ceil(std::log(static_cast(x)) / std::log(2.0))) + 1; PathIndexType i = x; PathIndexType j = 1; diff --git a/Modules/Filtering/Path/include/itkOrthogonalSwath2DPathFilter.h b/Modules/Filtering/Path/include/itkOrthogonalSwath2DPathFilter.h index 493cea72f30..ef1818b10d2 100644 --- a/Modules/Filtering/Path/include/itkOrthogonalSwath2DPathFilter.h +++ b/Modules/Filtering/Path/include/itkOrthogonalSwath2DPathFilter.h @@ -120,7 +120,7 @@ class ITK_TEMPLATE_EXPORT OrthogonalSwath2DPathFilter inline int & StepValue(int f, int l, int x) { - int rows = m_SwathSize[1]; + const int rows = m_SwathSize[1]; return m_StepValues[(x * rows * rows) + (f * rows) + (l)]; } @@ -128,7 +128,7 @@ class ITK_TEMPLATE_EXPORT OrthogonalSwath2DPathFilter inline double & MeritValue(int f, int l, int x) { - int rows = m_SwathSize[1]; + const int rows = m_SwathSize[1]; return m_MeritValues[(x * rows * rows) + (f * rows) + (l)]; } diff --git a/Modules/Filtering/Path/include/itkOrthogonalSwath2DPathFilter.hxx b/Modules/Filtering/Path/include/itkOrthogonalSwath2DPathFilter.hxx index 3c52b290921..e5b90084bc7 100644 --- a/Modules/Filtering/Path/include/itkOrthogonalSwath2DPathFilter.hxx +++ b/Modules/Filtering/Path/include/itkOrthogonalSwath2DPathFilter.hxx @@ -33,7 +33,7 @@ void OrthogonalSwath2DPathFilter::GenerateData() { // Get a convenience pointer - ImageConstPointer swathMeritImage = this->GetImageInput(); + const ImageConstPointer swathMeritImage = this->GetImageInput(); // Re-initialize the member variables m_SwathSize = swathMeritImage->GetLargestPossibleRegion().GetSize(); @@ -105,7 +105,7 @@ OrthogonalSwath2DPathFilter::GenerateData() { for (unsigned int L = 0; L < m_SwathSize[1]; ++L) { - int bestL = FindAndStoreBestErrorStep(x, F, L); + const int bestL = FindAndStoreBestErrorStep(x, F, L); index[0] = x + 1; index[1] = L; MeritValue(F, L, x + 1) = MeritValue(F, bestL, x) + static_cast(swathMeritImage->GetPixel(index)); @@ -124,7 +124,7 @@ OrthogonalSwath2DPathFilter::GenerateData() { if (itk::Math::abs(F - L) <= 1) // only accept closed paths { - double meritTemp = MeritValue(F, L, m_SwathSize[0] - 1); + const double meritTemp = MeritValue(F, L, m_SwathSize[0] - 1); if (meritTemp > meritMax) { meritMax = meritTemp; @@ -155,7 +155,7 @@ OrthogonalSwath2DPathFilter::GenerateData() } // setup the output path - OutputPathPointer outputPtr = this->GetOutput(0); + const OutputPathPointer outputPtr = this->GetOutput(0); outputPtr->SetOriginalPath(this->GetPathInput()); outputPtr->SetOrthogonalCorrectionTable(m_FinalOffsetValues); } diff --git a/Modules/Filtering/Path/include/itkPathFunctions.h b/Modules/Filtering/Path/include/itkPathFunctions.h index 46804c2a07a..4e2896ac241 100644 --- a/Modules/Filtering/Path/include/itkPathFunctions.h +++ b/Modules/Filtering/Path/include/itkPathFunctions.h @@ -36,9 +36,9 @@ MakeChainCodeTracePath(TChainCodePath & chainPath, const TPathInput & inPath, bo using ChainInputType = typename TChainCodePath::InputType; using InPathInputType = typename TPathInput::InputType; - int dimension = OffsetType::GetOffsetDimension(); + const int dimension = OffsetType::GetOffsetDimension(); - OffsetType zeroOffset{}; + const OffsetType zeroOffset{}; chainPath.Clear(); InPathInputType inPathInput = inPath.StartOfInput(); @@ -87,8 +87,8 @@ MakeFourierSeriesPathTraceChainCode(TFourierSeriesPath & FSPath, using FSInputType = typename TFourierSeriesPath::InputType; using ChainInputType = typename TChainCodePath::InputType; - int dimension = OffsetType::GetOffsetDimension(); - size_t numSteps = chainPath.NumberOfSteps(); + const int dimension = OffsetType::GetOffsetDimension(); + const size_t numSteps = chainPath.NumberOfSteps(); const double PI = 4.0 * std::atan(1.0); @@ -113,7 +113,7 @@ MakeFourierSeriesPathTraceChainCode(TFourierSeriesPath & FSPath, for (ChainInputType step = 0; step < numSteps; ++step) { index += chainPath.Evaluate(step); - FSInputType theta = 2 * n * PI * (static_cast(step + 1)) / numSteps; + const FSInputType theta = 2 * n * PI * (static_cast(step + 1)) / numSteps; // turn the current index into a vector VectorType indexVector; diff --git a/Modules/Filtering/Path/include/itkPathSource.hxx b/Modules/Filtering/Path/include/itkPathSource.hxx index 36916ee6906..8a5fdea2b28 100644 --- a/Modules/Filtering/Path/include/itkPathSource.hxx +++ b/Modules/Filtering/Path/include/itkPathSource.hxx @@ -29,7 +29,7 @@ PathSource::PathSource() { // Create the output. We use static_cast<> here because we know the default // output must be of type TOutputPath - OutputPathPointer output = static_cast(this->MakeOutput(0).GetPointer()); + const OutputPathPointer output = static_cast(this->MakeOutput(0).GetPointer()); this->ProcessObject::SetNumberOfRequiredOutputs(1); this->ProcessObject::SetNthOutput(0, output.GetPointer()); diff --git a/Modules/Filtering/Path/include/itkPathToChainCodePathFilter.hxx b/Modules/Filtering/Path/include/itkPathToChainCodePathFilter.hxx index 9bfe7641095..306d152ea77 100644 --- a/Modules/Filtering/Path/include/itkPathToChainCodePathFilter.hxx +++ b/Modules/Filtering/Path/include/itkPathToChainCodePathFilter.hxx @@ -33,16 +33,16 @@ template void PathToChainCodePathFilter::GenerateData() { - OffsetType offset; - OffsetType tempOffset; - OffsetType zeroOffset{}; + OffsetType offset; + OffsetType tempOffset; + const OffsetType zeroOffset{}; InputPathInputType inputPathInput; - int dimension = OffsetType::GetOffsetDimension(); + const int dimension = OffsetType::GetOffsetDimension(); - typename Superclass::InputPathConstPointer inputPtr = this->GetInput(); - typename Superclass::OutputPathPointer outputPtr = this->GetOutput(0); + const typename Superclass::InputPathConstPointer inputPtr = this->GetInput(); + const typename Superclass::OutputPathPointer outputPtr = this->GetOutput(0); // outputPtr->SetRequestedRegion( inputPtr->GetRequestedRegion() ); // outputPtr->SetBufferedRegion( inputPtr->GetBufferedRegion() ); diff --git a/Modules/Filtering/Path/include/itkPathToImageFilter.hxx b/Modules/Filtering/Path/include/itkPathToImageFilter.hxx index 0dcd1d12f0b..11755443d54 100644 --- a/Modules/Filtering/Path/include/itkPathToImageFilter.hxx +++ b/Modules/Filtering/Path/include/itkPathToImageFilter.hxx @@ -189,8 +189,8 @@ PathToImageFilter::GenerateData() itkDebugMacro("PathToImageFilter::GenerateData() called"); // Get the input and output pointers - const InputPathType * InputPath = this->GetInput(); - OutputImagePointer OutputImage = this->GetOutput(); + const InputPathType * InputPath = this->GetInput(); + const OutputImagePointer OutputImage = this->GetOutput(); // Generate the image double origin[OutputImageDimension]; diff --git a/Modules/Filtering/Path/src/itkOrthogonallyCorrected2DParametricPath.cxx b/Modules/Filtering/Path/src/itkOrthogonallyCorrected2DParametricPath.cxx index 6c956ab7863..d70659acef7 100644 --- a/Modules/Filtering/Path/src/itkOrthogonallyCorrected2DParametricPath.cxx +++ b/Modules/Filtering/Path/src/itkOrthogonallyCorrected2DParametricPath.cxx @@ -22,7 +22,7 @@ namespace itk OrthogonallyCorrected2DParametricPath::OutputType OrthogonallyCorrected2DParametricPath::Evaluate(const InputType & inputValue) const { - OrthogonalCorrectionTableSizeType numOrthogonalCorrections = m_OrthogonalCorrectionTable->Size(); + const OrthogonalCorrectionTableSizeType numOrthogonalCorrections = m_OrthogonalCorrectionTable->Size(); // If the original path is closed, then tail input is remapped to head input InputType input = inputValue; // we may want to remap the input @@ -36,16 +36,17 @@ OrthogonallyCorrected2DParametricPath::Evaluate(const InputType & inputValue) co } } - InputType inputRange = m_OriginalPath->EndOfInput() - m_OriginalPath->StartOfInput(); - InputType normalizedInput = (input - m_OriginalPath->StartOfInput()) / inputRange; - OutputType output{}; + const InputType inputRange = m_OriginalPath->EndOfInput() - m_OriginalPath->StartOfInput(); + const InputType normalizedInput = (input - m_OriginalPath->StartOfInput()) / inputRange; + OutputType output{}; // Find the linearly interpolated offset error value for this exact time. - double softOrthogonalCorrectionTableIndex = normalizedInput * numOrthogonalCorrections; - double Correction1 = m_OrthogonalCorrectionTable->ElementAt(static_cast(softOrthogonalCorrectionTableIndex)); - double Correction2 = m_OrthogonalCorrectionTable->ElementAt(static_cast(softOrthogonalCorrectionTableIndex + 1) % - numOrthogonalCorrections); - double Correction = + const double softOrthogonalCorrectionTableIndex = normalizedInput * numOrthogonalCorrections; + const double Correction1 = + m_OrthogonalCorrectionTable->ElementAt(static_cast(softOrthogonalCorrectionTableIndex)); + const double Correction2 = m_OrthogonalCorrectionTable->ElementAt( + static_cast(softOrthogonalCorrectionTableIndex + 1) % numOrthogonalCorrections); + const double Correction = Correction1 + (Correction2 - Correction1) * (softOrthogonalCorrectionTableIndex - static_cast(softOrthogonalCorrectionTableIndex)); diff --git a/Modules/Filtering/Path/test/itkChainCodePathTest.cxx b/Modules/Filtering/Path/test/itkChainCodePathTest.cxx index fbe7b09bdea..b5f79e78213 100644 --- a/Modules/Filtering/Path/test/itkChainCodePathTest.cxx +++ b/Modules/Filtering/Path/test/itkChainCodePathTest.cxx @@ -89,7 +89,7 @@ itkChainCodePathTest(int, char *[]) index = path->GetStart(); std::cout << "Starting at index: " << index << std::endl; - PathType::InputType endOfInput = path->EndOfInput(); + const PathType::InputType endOfInput = path->EndOfInput(); std::cout << "End of input: " << itk::NumericTraits::PrintType(endOfInput) << std::endl; for (unsigned int input = 0;;) diff --git a/Modules/Filtering/Path/test/itkChainCodeToFourierSeriesPathFilterTest.cxx b/Modules/Filtering/Path/test/itkChainCodeToFourierSeriesPathFilterTest.cxx index 92fb69f5b65..533c29fa0a1 100644 --- a/Modules/Filtering/Path/test/itkChainCodeToFourierSeriesPathFilterTest.cxx +++ b/Modules/Filtering/Path/test/itkChainCodeToFourierSeriesPathFilterTest.cxx @@ -62,7 +62,7 @@ itkChainCodeToFourierSeriesPathFilterTest(int, char *[]) auto pathToChainCodePathFilter = PathToChainCodePathFilterType::New(); pathToChainCodePathFilter->SetInput(inputPath); - ChainPathType::Pointer chainPath = pathToChainCodePathFilter->GetOutput(); + const ChainPathType::Pointer chainPath = pathToChainCodePathFilter->GetOutput(); // Set up the second filter auto chainCodeToFSPathFilter = ChainCodeToFSPathFilterType::New(); @@ -71,7 +71,7 @@ itkChainCodeToFourierSeriesPathFilterTest(int, char *[]) chainCodeToFSPathFilter->SetInput(pathToChainCodePathFilter->GetOutput()); - FSPathType::Pointer outputPath = chainCodeToFSPathFilter->GetOutput(); + const FSPathType::Pointer outputPath = chainCodeToFSPathFilter->GetOutput(); chainCodeToFSPathFilter->Update(); diff --git a/Modules/Filtering/Path/test/itkContourExtractor2DImageFilterTest.cxx b/Modules/Filtering/Path/test/itkContourExtractor2DImageFilterTest.cxx index c416e18e974..af6a9f2299e 100644 --- a/Modules/Filtering/Path/test/itkContourExtractor2DImageFilterTest.cxx +++ b/Modules/Filtering/Path/test/itkContourExtractor2DImageFilterTest.cxx @@ -460,7 +460,7 @@ ShowExtractorAsVariables(itkContourExtractor2DImageFilterTestNamespace::Extracto { for (unsigned long i = 0; i < extractor->GetNumberOfIndexedOutputs(); ++i) { - itkContourExtractor2DImageFilterTestNamespace::ExtractorType::VertexListConstPointer vertices = + const itkContourExtractor2DImageFilterTestNamespace::ExtractorType::VertexListConstPointer vertices = extractor->GetOutput(i)->GetVertexList(); std::cout << "itkContourExtractor2DImageFilterTestNamespace::MyVertexType _" << name << i << "[] = {" << std::endl; for (unsigned int j = 0; j < vertices->Size(); ++j) @@ -526,7 +526,7 @@ HasCorrectOutput(itkContourExtractor2DImageFilterTestNamespace::ExtractorType::P for (unsigned int i = 0; i < correct.size(); ++i) { - itkContourExtractor2DImageFilterTestNamespace::ExtractorType::VertexListConstPointer vertices = + const itkContourExtractor2DImageFilterTestNamespace::ExtractorType::VertexListConstPointer vertices = extractor->GetOutput(i)->GetVertexList(); itkContourExtractor2DImageFilterTestNamespace::MyVertexListType & correctVertices = correct[i]; @@ -564,11 +564,11 @@ itkContourExtractor2DImageFilterTest(int argc, char * argv[]) return 1; } - itkContourExtractor2DImageFilterTestNamespace::ReaderType::Pointer reader = + const itkContourExtractor2DImageFilterTestNamespace::ReaderType::Pointer reader = itkContourExtractor2DImageFilterTestNamespace::ReaderType::New(); reader->SetFileName(argv[1]); - itkContourExtractor2DImageFilterTestNamespace::ExtractorType::Pointer extractor = + const itkContourExtractor2DImageFilterTestNamespace::ExtractorType::Pointer extractor = itkContourExtractor2DImageFilterTestNamespace::ExtractorType::New(); extractor->SetInput(reader->GetOutput()); @@ -657,7 +657,7 @@ itkContourExtractor2DImageFilterTest(int argc, char * argv[]) extractor->ReverseContourOrientationOff(); extractor->LabelContoursOff(); // Move the region to evaluate in by one on the top and bottom - itkContourExtractor2DImageFilterTestNamespace::ImageType::RegionType region = + const itkContourExtractor2DImageFilterTestNamespace::ImageType::RegionType region = reader->GetOutput()->GetLargestPossibleRegion(); using IndexType = itkContourExtractor2DImageFilterTestNamespace::ImageType::IndexType; diff --git a/Modules/Filtering/Path/test/itkExtractOrthogonalSwath2DImageFilterTest.cxx b/Modules/Filtering/Path/test/itkExtractOrthogonalSwath2DImageFilterTest.cxx index e951abf2854..317148cf6cd 100644 --- a/Modules/Filtering/Path/test/itkExtractOrthogonalSwath2DImageFilterTest.cxx +++ b/Modules/Filtering/Path/test/itkExtractOrthogonalSwath2DImageFilterTest.cxx @@ -61,7 +61,7 @@ itkExtractOrthogonalSwath2DImageFilterTest(int argc, char * argv[]) ImageType::SizeType size; size[0] = 128; size[1] = 128; - ImageType::RegionType region{ start, size }; + const ImageType::RegionType region{ start, size }; inputImage->SetRegions(region); double spacing[ImageType::ImageDimension]; spacing[0] = 1.0; @@ -108,24 +108,24 @@ itkExtractOrthogonalSwath2DImageFilterTest(int argc, char * argv[]) // Set up the first filter auto pathToChainCodePathFilter = PathToChainCodePathFilterType::New(); pathToChainCodePathFilter->SetInput(inputPath); - ChainCodePathType::Pointer chainPath = pathToChainCodePathFilter->GetOutput(); + const ChainCodePathType::Pointer chainPath = pathToChainCodePathFilter->GetOutput(); // Set up the second filter - ChainCodeToFourierSeriesPathFilterType::Pointer chainCodeToFourierSeriesPathFilte = + const ChainCodeToFourierSeriesPathFilterType::Pointer chainCodeToFourierSeriesPathFilte = ChainCodeToFourierSeriesPathFilterType::New(); chainCodeToFourierSeriesPathFilte->SetInput(pathToChainCodePathFilter->GetOutput()); chainCodeToFourierSeriesPathFilte->SetNumberOfHarmonics(7); // make a nice, round, path for the swath - FourierSeriesPathType::Pointer outputPath = chainCodeToFourierSeriesPathFilte->GetOutput(); + const FourierSeriesPathType::Pointer outputPath = chainCodeToFourierSeriesPathFilte->GetOutput(); // Set up the third filter; THIS IS THE MAIN FILTER TO BE TESTED - ExtractOrthogonalSwath2DImageFilterType::Pointer extractOrthogonalSwath2DImageFilter = + const ExtractOrthogonalSwath2DImageFilterType::Pointer extractOrthogonalSwath2DImageFilter = ExtractOrthogonalSwath2DImageFilterType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS( extractOrthogonalSwath2DImageFilter, ExtractOrthogonalSwath2DImageFilter, ImageAndPathToImageFilter); - typename ImageType::PixelType defaultPixelValue{}; + const typename ImageType::PixelType defaultPixelValue{}; extractOrthogonalSwath2DImageFilter->SetDefaultPixelValue(defaultPixelValue); extractOrthogonalSwath2DImageFilter->SetImageInput(inputImage); @@ -136,7 +136,7 @@ itkExtractOrthogonalSwath2DImageFilterTest(int argc, char * argv[]) extractOrthogonalSwath2DImageFilter->SetSize(size); // Set up the output - ImageType::Pointer outputImage = extractOrthogonalSwath2DImageFilter->GetOutput(); + const ImageType::Pointer outputImage = extractOrthogonalSwath2DImageFilter->GetOutput(); // Test spacing double pathImageSpacing[ImageType::ImageDimension]; @@ -207,7 +207,7 @@ itkExtractOrthogonalSwath2DImageFilterTest(int argc, char * argv[]) } } - itk::ImageFileWriter::Pointer writer = itk::ImageFileWriter::New(); + const itk::ImageFileWriter::Pointer writer = itk::ImageFileWriter::New(); writer->SetInput(extractOrthogonalSwath2DImageFilter->GetOutput()); writer->SetFileName(argv[1]); diff --git a/Modules/Filtering/Path/test/itkHilbertPathTest.cxx b/Modules/Filtering/Path/test/itkHilbertPathTest.cxx index 4c32b35062b..d043fb5d7a1 100644 --- a/Modules/Filtering/Path/test/itkHilbertPathTest.cxx +++ b/Modules/Filtering/Path/test/itkHilbertPathTest.cxx @@ -41,13 +41,13 @@ HilbertPathTestHelper(unsigned int maxHilbertPathOder) typename PathType::InputType input = 0; ITK_TRY_EXPECT_EXCEPTION(path->IncrementInput(input)); - typename PathType::InputType endOfInput = path->EndOfInput(); + const typename PathType::InputType endOfInput = path->EndOfInput(); std::cout << "End of input: " << typename itk::NumericTraits::PrintType(endOfInput) << std::endl; for (unsigned int d = 0; d < path->NumberOfSteps(); ++d) { - IndexType index = path->Evaluate(d); + const IndexType index = path->Evaluate(d); if (d != path->EvaluateInverse(index)) { @@ -62,7 +62,7 @@ HilbertPathTestHelper(unsigned int maxHilbertPathOder) for (unsigned int d = 0; d < 10; ++d) { - IndexType index = path->TransformPathIndexToMultiDimensionalIndex(d); + const IndexType index = path->TransformPathIndexToMultiDimensionalIndex(d); if (d != path->EvaluateInverse(index)) { diff --git a/Modules/Filtering/Path/test/itkOrthogonalSwath2DPathFilterTest.cxx b/Modules/Filtering/Path/test/itkOrthogonalSwath2DPathFilterTest.cxx index b62d508505b..194fc472842 100644 --- a/Modules/Filtering/Path/test/itkOrthogonalSwath2DPathFilterTest.cxx +++ b/Modules/Filtering/Path/test/itkOrthogonalSwath2DPathFilterTest.cxx @@ -91,7 +91,7 @@ itkOrthogonalSwath2DPathFilterTest(int, char *[]) pathToChainCodePathFilter->SetInput(inputPath); // Set up the second path filter - ChainCodeToFourierSeriesPathFilterType::Pointer chainCodeToFourierSeriesPathFilter = + const ChainCodeToFourierSeriesPathFilterType::Pointer chainCodeToFourierSeriesPathFilter = ChainCodeToFourierSeriesPathFilterType::New(); chainCodeToFourierSeriesPathFilter->SetInput(pathToChainCodePathFilter->GetOutput()); chainCodeToFourierSeriesPathFilter->SetNumberOfHarmonics(7); // make a nice, round, path for the swath @@ -105,7 +105,7 @@ itkOrthogonalSwath2DPathFilterTest(int, char *[]) UCharImageType::SizeType size; size[0] = 128; size[1] = 128; - UCharImageType::RegionType region{ start, size }; + const UCharImageType::RegionType region{ start, size }; inputImage->SetRegions(region); double spacing[UCharImageType::ImageDimension]; spacing[0] = 1.0; @@ -142,13 +142,13 @@ itkOrthogonalSwath2DPathFilterTest(int, char *[]) // Smooth the (double pixel type) input image auto smoothFilter = SmoothFilterType::New(); smoothFilter->SetInput(castFilter->GetOutput()); - double gaussianVariance = 1.0; + const double gaussianVariance = 1.0; // We want a fast 3x3 kernel. A Gaussian operator will not truncate its kernel // width to any less than a 5x5 kernel (kernel width of 3 for 1 center pixel + // 2 edge pixels). However, a Gaussian operator always uses at least a 3x3 // kernel, and so setting the maximum error to 1.0 (no limit) will make it // stop growing the kernel at the desired 3x3 size. - double maxError = 0.9; + const double maxError = 0.9; smoothFilter->UseImageSpacingOff(); smoothFilter->SetVariance(gaussianVariance); smoothFilter->SetMaximumError(maxError); @@ -174,13 +174,13 @@ itkOrthogonalSwath2DPathFilterTest(int, char *[]) orthogonalSwath2DPathFilter->SetPathInput(chainCodeToFourierSeriesPathFilter->GetOutput()); orthogonalSwath2DPathFilter->SetImageInput(meritFilter->GetOutput()); - OutputPathType::Pointer outPath = orthogonalSwath2DPathFilter->GetOutput(); + const OutputPathType::Pointer outPath = orthogonalSwath2DPathFilter->GetOutput(); // Set up the input & output path images - FourierSeriesPathToImageFilterType::Pointer fourierSeriesPathToImageFilter = + const FourierSeriesPathToImageFilterType::Pointer fourierSeriesPathToImageFilter = FourierSeriesPathToImageFilterType::New(); - OrthogonallyCorrected2DParametricPathToImageFilterType::Pointer orthogonallyCorrected2DParametricPathToImageFilter = - OrthogonallyCorrected2DParametricPathToImageFilterType::New(); + const OrthogonallyCorrected2DParametricPathToImageFilterType::Pointer + orthogonallyCorrected2DParametricPathToImageFilter = OrthogonallyCorrected2DParametricPathToImageFilterType::New(); size[0] = 128; size[1] = 128; fourierSeriesPathToImageFilter->SetSize(size); // same size as the input image @@ -191,15 +191,15 @@ itkOrthogonalSwath2DPathFilterTest(int, char *[]) orthogonallyCorrected2DParametricPathToImageFilter->SetPathValue(255); orthogonallyCorrected2DParametricPathToImageFilter->SetInput(orthogonalSwath2DPathFilter->GetOutput()); - UCharImageType::Pointer inputPathImage = fourierSeriesPathToImageFilter->GetOutput(); - UCharImageType::Pointer outputImage = orthogonallyCorrected2DParametricPathToImageFilter->GetOutput(); + const UCharImageType::Pointer inputPathImage = fourierSeriesPathToImageFilter->GetOutput(); + const UCharImageType::Pointer outputImage = orthogonallyCorrected2DParametricPathToImageFilter->GetOutput(); // Setup the swath merit output image auto rescaleIntensityImageFilter = RescaleIntensityImageFilterType::New(); rescaleIntensityImageFilter->SetInput(meritFilter->GetOutput()); rescaleIntensityImageFilter->SetOutputMinimum(0); rescaleIntensityImageFilter->SetOutputMaximum(255); - UCharImageType::Pointer swathMeritImage = rescaleIntensityImageFilter->GetOutput(); + const UCharImageType::Pointer swathMeritImage = rescaleIntensityImageFilter->GetOutput(); // Update the pipeline diff --git a/Modules/Filtering/Path/test/itkOrthogonallyCorrected2DParametricPathTest.cxx b/Modules/Filtering/Path/test/itkOrthogonallyCorrected2DParametricPathTest.cxx index 44e89f53e3e..b104825abe8 100644 --- a/Modules/Filtering/Path/test/itkOrthogonallyCorrected2DParametricPathTest.cxx +++ b/Modules/Filtering/Path/test/itkOrthogonallyCorrected2DParametricPathTest.cxx @@ -57,7 +57,7 @@ itkOrthogonallyCorrected2DParametricPathTest(int, char *[]) originalPath->AddVertex(v); // 24 Alternating offsets - OrthogonalCorrectionTablePointer correctionTable = OrthogonalCorrectionTableType::New(); + const OrthogonalCorrectionTablePointer correctionTable = OrthogonalCorrectionTableType::New(); for (int i = 0; i < 24; ++i) { correctionTable->InsertElement(i, 1 - (i % 2)); // alternates 1, 0 diff --git a/Modules/Filtering/Path/test/itkPathFunctionsTest.cxx b/Modules/Filtering/Path/test/itkPathFunctionsTest.cxx index 4a925e6767c..0fec4db07e7 100644 --- a/Modules/Filtering/Path/test/itkPathFunctionsTest.cxx +++ b/Modules/Filtering/Path/test/itkPathFunctionsTest.cxx @@ -52,7 +52,7 @@ itkPathFunctionsTest(int, char *[]) ImageType::SizeType size; size[0] = 128; size[1] = 128; - ImageType::RegionType region{ start, size }; + const ImageType::RegionType region{ start, size }; image->SetRegions(region); double spacing[ImageType::ImageDimension]; spacing[0] = 1.0; diff --git a/Modules/Filtering/Path/test/itkPathIteratorTest.cxx b/Modules/Filtering/Path/test/itkPathIteratorTest.cxx index d3bf0f8776a..ba4108f006e 100644 --- a/Modules/Filtering/Path/test/itkPathIteratorTest.cxx +++ b/Modules/Filtering/Path/test/itkPathIteratorTest.cxx @@ -48,7 +48,7 @@ itkPathIteratorTest(int, char *[]) ImageType::SizeType size; size[0] = 128; size[1] = 128; - ImageType::RegionType region{ start, size }; + const ImageType::RegionType region{ start, size }; image->SetRegions(region); double spacing[ImageType::ImageDimension]; spacing[0] = 1.0; diff --git a/Modules/Filtering/Path/test/itkPathToImageFilterTest.cxx b/Modules/Filtering/Path/test/itkPathToImageFilterTest.cxx index dbc8d9e14ed..9d529344a61 100644 --- a/Modules/Filtering/Path/test/itkPathToImageFilterTest.cxx +++ b/Modules/Filtering/Path/test/itkPathToImageFilterTest.cxx @@ -60,11 +60,11 @@ itkPathToImageFilterTest(int, char *[]) pathToImageFilter->SetInput(path); - PathToImageFilterType::ValueType pathValue = 1; + const PathToImageFilterType::ValueType pathValue = 1; pathToImageFilter->SetPathValue(pathValue); ITK_TEST_SET_GET_VALUE(pathValue, pathToImageFilter->GetPathValue()); - PathToImageFilterType::ValueType backgroundValue = 0; + const PathToImageFilterType::ValueType backgroundValue = 0; pathToImageFilter->SetBackgroundValue(backgroundValue); ITK_TEST_SET_GET_VALUE(backgroundValue, pathToImageFilter->GetBackgroundValue()); @@ -115,7 +115,7 @@ itkPathToImageFilterTest(int, char *[]) // Update the filter ITK_TRY_EXPECT_NO_EXCEPTION(pathToImageFilter->Update()); - ImageType::Pointer image = pathToImageFilter->GetOutput(); + const ImageType::Pointer image = pathToImageFilter->GetOutput(); // Test the output image // diff --git a/Modules/Filtering/Path/test/itkPolyLineParametricPathTest.cxx b/Modules/Filtering/Path/test/itkPolyLineParametricPathTest.cxx index a042ecb7f51..7d4e81427f8 100644 --- a/Modules/Filtering/Path/test/itkPolyLineParametricPathTest.cxx +++ b/Modules/Filtering/Path/test/itkPolyLineParametricPathTest.cxx @@ -98,7 +98,7 @@ itkPolyLineParametricPathTest(int, char *[]) path2->AddVertex(v); PathType::InputType path2Input = path2->StartOfInput(); - PathType::OffsetType zeroOffset{}; + const PathType::OffsetType zeroOffset{}; std::cout << "Starting degenerate path test" << std::endl; while (true) diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkBorderQuadEdgeMeshFilter.hxx b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkBorderQuadEdgeMeshFilter.hxx index 68c729315e3..a0d6b4f88cf 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkBorderQuadEdgeMeshFilter.hxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkBorderQuadEdgeMeshFilter.hxx @@ -66,9 +66,9 @@ BorderQuadEdgeMeshFilter::ComputeBoundary() break; } - InputPointIdentifier i = 0; - InputIteratorGeom it = bdryEdge->BeginGeomLnext(); - InputIteratorGeom end = bdryEdge->EndGeomLnext(); + InputPointIdentifier i = 0; + InputIteratorGeom it = bdryEdge->BeginGeomLnext(); + const InputIteratorGeom end = bdryEdge->EndGeomLnext(); while (it != end) { @@ -95,9 +95,9 @@ template auto BorderQuadEdgeMeshFilter::ComputeLongestBorder() -> InputQEType * { - BoundaryRepresentativeEdgesPointer boundaryRepresentativeEdges = BoundaryRepresentativeEdgesType::New(); + const BoundaryRepresentativeEdgesPointer boundaryRepresentativeEdges = BoundaryRepresentativeEdgesType::New(); - InputMeshConstPointer input = this->GetInput(); + const InputMeshConstPointer input = this->GetInput(); InputEdgeListPointerType list; list.TakeOwnership(boundaryRepresentativeEdges->Evaluate(*input)); @@ -107,21 +107,21 @@ BorderQuadEdgeMeshFilter::ComputeLongestBorder() -> Inp itkGenericExceptionMacro("This filter requires at least one boundary"); } - InputCoordRepType max_length(0.0); - auto oborder_it = list->begin(); + InputCoordinateType max_length(0.0); + auto oborder_it = list->begin(); for (auto b_it = list->begin(); b_it != list->end(); ++b_it) { - InputCoordRepType length(0.0); + InputCoordinateType length(0.0); for (InputIteratorGeom e_it = (*b_it)->BeginGeomLnext(); e_it != (*b_it)->EndGeomLnext(); ++e_it) { InputQEType * t_edge = e_it.Value(); - InputPointIdentifier id_org = t_edge->GetOrigin(); - InputPointIdentifier id_dest = t_edge->GetDestination(); + const InputPointIdentifier id_org = t_edge->GetOrigin(); + const InputPointIdentifier id_dest = t_edge->GetDestination(); - InputPointType org = input->GetPoint(id_org); - InputPointType dest = input->GetPoint(id_dest); + const InputPointType org = input->GetPoint(id_org); + const InputPointType dest = input->GetPoint(id_dest); length += org.EuclideanDistanceTo(dest); } @@ -144,9 +144,9 @@ template auto BorderQuadEdgeMeshFilter::ComputeLargestBorder() -> InputQEType * { - BoundaryRepresentativeEdgesPointer boundaryRepresentativeEdges = BoundaryRepresentativeEdgesType::New(); + const BoundaryRepresentativeEdgesPointer boundaryRepresentativeEdges = BoundaryRepresentativeEdgesType::New(); - InputMeshConstPointer input = this->GetInput(); + const InputMeshConstPointer input = this->GetInput(); InputEdgeListPointerType list; list.TakeOwnership(boundaryRepresentativeEdges->Evaluate(*input)); @@ -188,14 +188,14 @@ template void BorderQuadEdgeMeshFilter::DiskTransform() { - InputMeshConstPointer input = this->GetInput(); + const InputMeshConstPointer input = this->GetInput(); auto NbBoundaryPt = static_cast(this->m_BoundaryPtMap.size()); - InputCoordinateType r = this->RadiusMaxSquare(); + const InputCoordinateType r = this->RadiusMaxSquare(); - InputCoordinateType two_r = 2.0 * r; - InputCoordinateType inv_two_r = 1.0 / two_r; + const InputCoordinateType two_r = 2.0 * r; + const InputCoordinateType inv_two_r = 1.0 / two_r; InputPointIdentifier id = this->m_BoundaryPtMap.begin()->first; InputPointType pt1 = input->GetPoint(id); @@ -229,8 +229,7 @@ BorderQuadEdgeMeshFilter::DiskTransform() ++BoundaryPtIterator; } - InputCoordinateType a = (2.0 * itk::Math::pi) / tetas[NbBoundaryPt - 1]; - + const InputCoordinateType a = (2.0 * itk::Math::pi) / tetas[NbBoundaryPt - 1]; if (this->m_Radius == 0.0) { this->m_Radius = std::pow(std::sqrt(r), a); @@ -255,16 +254,16 @@ template auto BorderQuadEdgeMeshFilter::RadiusMaxSquare() -> InputCoordinateType { - InputMeshConstPointer input = this->GetInput(); + const InputMeshConstPointer input = this->GetInput(); - InputPointType center = this->GetMeshBarycentre(); + const InputPointType center = this->GetMeshBarycentre(); - InputCoordRepType oRmax(0.); + InputCoordinateType oRmax(0.); for (auto BoundaryPtIterator = this->m_BoundaryPtMap.begin(); BoundaryPtIterator != this->m_BoundaryPtMap.end(); ++BoundaryPtIterator) { - InputCoordRepType r = - static_cast(center.SquaredEuclideanDistanceTo(input->GetPoint(BoundaryPtIterator->first))); + const InputCoordinateType r = + static_cast(center.SquaredEuclideanDistanceTo(input->GetPoint(BoundaryPtIterator->first))); if (r > oRmax) { oRmax = r; @@ -281,7 +280,7 @@ template auto BorderQuadEdgeMeshFilter::GetMeshBarycentre() -> InputPointType { - InputMeshConstPointer input = this->GetInput(); + const InputMeshConstPointer input = this->GetInput(); InputPointType oCenter{}; @@ -302,8 +301,7 @@ BorderQuadEdgeMeshFilter::GetMeshBarycentre() -> InputP ++PointIterator; } - InputCoordinateType invNbOfPoints = 1.0 / static_cast(input->GetNumberOfPoints()); - + const InputCoordinateType invNbOfPoints = 1.0 / static_cast(input->GetNumberOfPoints()); for (i = 0; i < PointDimension; ++i) { oCenter[i] *= invNbOfPoints; @@ -340,9 +338,9 @@ template void BorderQuadEdgeMeshFilter::ArcLengthSquareTransform() { - BoundaryRepresentativeEdgesPointer boundaryRepresentativeEdges = BoundaryRepresentativeEdgesType::New(); + const BoundaryRepresentativeEdgesPointer boundaryRepresentativeEdges = BoundaryRepresentativeEdgesType::New(); - InputMeshConstPointer input = this->GetInput(); + const InputMeshConstPointer input = this->GetInput(); InputEdgeListPointerType list; list.TakeOwnership(boundaryRepresentativeEdges->Evaluate(*input)); @@ -353,18 +351,18 @@ BorderQuadEdgeMeshFilter::ArcLengthSquareTransform() std::vector Length(NbBoundaryPt + 1, 0.0); - InputCoordRepType TotalLength(0.0); + InputCoordinateType TotalLength(0.0); { InputPointIdentifier i(0); for (InputIteratorGeom it = bdryEdge->BeginGeomLnext(); it != bdryEdge->EndGeomLnext(); ++it, ++i) { - InputPointIdentifier org = it.Value()->GetOrigin(); - InputPointIdentifier dest = it.Value()->GetDestination(); + const InputPointIdentifier org = it.Value()->GetOrigin(); + const InputPointIdentifier dest = it.Value()->GetDestination(); - InputPointType PtOrg = input->GetPoint(org); - InputPointType PtDest = input->GetPoint(dest); + const InputPointType PtOrg = input->GetPoint(org); + const InputPointType PtDest = input->GetPoint(dest); - InputCoordRepType distance = PtOrg.EuclideanDistanceTo(PtDest); + const InputCoordinateType distance = PtOrg.EuclideanDistanceTo(PtDest); TotalLength += distance; Length[i] = TotalLength; } @@ -374,9 +372,8 @@ BorderQuadEdgeMeshFilter::ArcLengthSquareTransform() this->m_Radius = 1000.; } - InputCoordinateType EdgeLength = 2.0 * this->m_Radius; - InputCoordinateType ratio = 4.0 * EdgeLength / TotalLength; - + const InputCoordinateType EdgeLength = 2.0 * this->m_Radius; + const InputCoordinateType ratio = 4.0 * EdgeLength / TotalLength; for (InputPointIdentifier i = 0; i < NbBoundaryPt + 1; ++i) { diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkCleanQuadEdgeMeshFilter.hxx b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkCleanQuadEdgeMeshFilter.hxx index 1b733d5fa8e..c726d0ebc1c 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkCleanQuadEdgeMeshFilter.hxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkCleanQuadEdgeMeshFilter.hxx @@ -43,7 +43,7 @@ template void CleanQuadEdgeMeshFilter::GenerateData() { - InputCoordinateType zeroValue{}; + const InputCoordinateType zeroValue{}; InputCoordinateType absoluteToleranceSquared = this->m_AbsoluteTolerance * this->m_AbsoluteTolerance; if ((Math::ExactlyEquals(this->m_AbsoluteTolerance, zeroValue)) && @@ -65,17 +65,17 @@ template void CleanQuadEdgeMeshFilter::MergePoints(const InputCoordinateType absoluteToleranceSquared) { - OutputMeshPointer output = this->GetOutput(); + const OutputMeshPointer output = this->GetOutput(); this->m_Criterion->SetMeasureBound(absoluteToleranceSquared); this->m_Decimation->SetInput(this->GetInput()); this->m_Decimation->Update(); - InputMeshPointer decimatedMesh = this->m_Decimation->GetOutput(); + const InputMeshPointer decimatedMesh = this->m_Decimation->GetOutput(); - InputPointsContainerIterator pointsIt = decimatedMesh->GetPoints()->Begin(); - InputPointsContainerIterator pointsItEnd = decimatedMesh->GetPoints()->End(); + InputPointsContainerIterator pointsIt = decimatedMesh->GetPoints()->Begin(); + const InputPointsContainerIterator pointsItEnd = decimatedMesh->GetPoints()->End(); OutputPointType outputPoint; @@ -129,11 +129,11 @@ template void CleanQuadEdgeMeshFilter::CleanPoints() { - OutputMeshPointer output = this->GetOutput(); + const OutputMeshPointer output = this->GetOutput(); - OutputPointsContainerIterator p_it = output->GetPoints()->Begin(); - OutputPointsContainerIterator p_end = output->GetPoints()->End(); - OutputPointIdentifier id(0); + OutputPointsContainerIterator p_it = output->GetPoints()->Begin(); + const OutputPointsContainerIterator p_end = output->GetPoints()->End(); + OutputPointIdentifier id(0); while (p_it != p_end) { diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDelaunayConformingQuadEdgeMeshFilter.h b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDelaunayConformingQuadEdgeMeshFilter.h index 1c5818fa342..00707712dfd 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDelaunayConformingQuadEdgeMeshFilter.h +++ b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDelaunayConformingQuadEdgeMeshFilter.h @@ -158,26 +158,26 @@ class ITK_TEMPLATE_EXPORT DelaunayConformingQuadEdgeMeshFilter inline CriterionValueType Dyer07Criterion(OutputMeshType * iMesh, OutputQEType * iEdge) const { - OutputPointIdentifier id1 = iEdge->GetOrigin(); - OutputPointIdentifier id2 = iEdge->GetDestination(); - - OutputPointIdentifier idA = iEdge->GetLnext()->GetDestination(); - OutputPointIdentifier idB = iEdge->GetRnext()->GetOrigin(); - - OutputPointType pt1 = iMesh->GetPoint(id1); - OutputPointType pt2 = iMesh->GetPoint(id2); - OutputPointType ptA = iMesh->GetPoint(idA); - OutputPointType ptB = iMesh->GetPoint(idB); - - OutputVectorType v1A = ptA - pt1; - OutputVectorType v1B = ptB - pt1; - OutputVectorType v2A = ptA - pt2; - OutputVectorType v2B = ptB - pt2; - - OutputCoordinateType sq_norm1A = v1A * v1A; - OutputCoordinateType sq_norm1B = v1B * v1B; - OutputCoordinateType sq_norm2A = v2A * v2A; - OutputCoordinateType sq_norm2B = v2B * v2B; + const OutputPointIdentifier id1 = iEdge->GetOrigin(); + const OutputPointIdentifier id2 = iEdge->GetDestination(); + + const OutputPointIdentifier idA = iEdge->GetLnext()->GetDestination(); + const OutputPointIdentifier idB = iEdge->GetRnext()->GetOrigin(); + + const OutputPointType pt1 = iMesh->GetPoint(id1); + const OutputPointType pt2 = iMesh->GetPoint(id2); + const OutputPointType ptA = iMesh->GetPoint(idA); + const OutputPointType ptB = iMesh->GetPoint(idB); + + const OutputVectorType v1A = ptA - pt1; + const OutputVectorType v1B = ptB - pt1; + const OutputVectorType v2A = ptA - pt2; + const OutputVectorType v2B = ptB - pt2; + + const OutputCoordinateType sq_norm1A = v1A * v1A; + const OutputCoordinateType sq_norm1B = v1B * v1B; + const OutputCoordinateType sq_norm2A = v2A * v2A; + const OutputCoordinateType sq_norm2B = v2B * v2B; auto dotA = static_cast(v1A * v2A); auto dotB = static_cast(v1B * v2B); diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDiscreteCurvatureQuadEdgeMeshFilter.h b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDiscreteCurvatureQuadEdgeMeshFilter.h index b2f046b0d17..c4c66bc3ffa 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDiscreteCurvatureQuadEdgeMeshFilter.h +++ b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDiscreteCurvatureQuadEdgeMeshFilter.h @@ -103,10 +103,10 @@ class ITK_TEMPLATE_EXPORT DiscreteCurvatureQuadEdgeMeshFilter { this->CopyInputMeshToOutputMesh(); - OutputMeshPointer output = this->GetOutput(); + const OutputMeshPointer output = this->GetOutput(); - OutputPointsContainerPointer points = output->GetPoints(); - OutputPointsContainerIterator p_it = points->Begin(); + const OutputPointsContainerPointer points = output->GetPoints(); + OutputPointsContainerIterator p_it = points->Begin(); OutputCurvatureType curvature; diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDiscreteGaussianCurvatureQuadEdgeMeshFilter.h b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDiscreteGaussianCurvatureQuadEdgeMeshFilter.h index b443e9caae7..a24dacdc010 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDiscreteGaussianCurvatureQuadEdgeMeshFilter.h +++ b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDiscreteGaussianCurvatureQuadEdgeMeshFilter.h @@ -82,7 +82,7 @@ class ITK_TEMPLATE_EXPORT DiscreteGaussianCurvatureQuadEdgeMeshFilter OutputCurvatureType EstimateCurvature(const OutputPointType & iP) override { - OutputMeshPointer output = this->GetOutput(); + const OutputMeshPointer output = this->GetOutput(); OutputQEType * qe = iP.GetEdge(); @@ -96,9 +96,9 @@ class ITK_TEMPLATE_EXPORT DiscreteGaussianCurvatureQuadEdgeMeshFilter do { // cell_id = qe_it->GetLeft(); - OutputQEType * qe_it2 = qe_it->GetOnext(); - OutputPointType q0 = output->GetPoint(qe_it->GetDestination()); - OutputPointType q1 = output->GetPoint(qe_it2->GetDestination()); + OutputQEType * qe_it2 = qe_it->GetOnext(); + const OutputPointType q0 = output->GetPoint(qe_it->GetDestination()); + const OutputPointType q1 = output->GetPoint(qe_it2->GetDestination()); // Compute Angle; sum_theta += static_cast(TriangleType::ComputeAngle(q0, iP, q1)); diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDiscreteMeanCurvatureQuadEdgeMeshFilter.h b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDiscreteMeanCurvatureQuadEdgeMeshFilter.h index 1c26f22341a..7711298bbc8 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDiscreteMeanCurvatureQuadEdgeMeshFilter.h +++ b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDiscreteMeanCurvatureQuadEdgeMeshFilter.h @@ -83,7 +83,7 @@ class ITK_TEMPLATE_EXPORT DiscreteMeanCurvatureQuadEdgeMeshFilter OutputCurvatureType EstimateCurvature(const OutputPointType & iP) override { - OutputMeshPointer output = this->GetOutput(); + const OutputMeshPointer output = this->GetOutput(); OutputQEType * qe = iP.GetEdge(); @@ -98,23 +98,23 @@ class ITK_TEMPLATE_EXPORT DiscreteMeanCurvatureQuadEdgeMeshFilter { if (qe != qe->GetOnext()) { - CoefficientType coefficent; + const CoefficientType coefficent; OutputQEType * qe_it = qe; do { - OutputQEType * qe_it2 = qe_it->GetOnext(); - OutputPointType q0 = output->GetPoint(qe_it->GetDestination()); - OutputPointType q1 = output->GetPoint(qe_it2->GetDestination()); + OutputQEType * qe_it2 = qe_it->GetOnext(); + const OutputPointType q0 = output->GetPoint(qe_it->GetDestination()); + const OutputPointType q1 = output->GetPoint(qe_it2->GetDestination()); - OutputCoordType temp_coeff = coefficent(output, qe_it); + const OutputCoordType temp_coeff = coefficent(output, qe_it); Laplace += temp_coeff * (iP - q0); - OutputCurvatureType temp_area = this->ComputeMixedArea(qe_it, qe_it2); + const OutputCurvatureType temp_area = this->ComputeMixedArea(qe_it, qe_it2); area += temp_area; - OutputVectorType face_normal = TriangleType::ComputeNormal(q0, iP, q1); + const OutputVectorType face_normal = TriangleType::ComputeNormal(q0, iP, q1); normal += face_normal; qe_it = qe_it2; diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDiscretePrincipalCurvaturesQuadEdgeMeshFilter.h b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDiscretePrincipalCurvaturesQuadEdgeMeshFilter.h index 4883a807902..2d6d39d5224 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDiscretePrincipalCurvaturesQuadEdgeMeshFilter.h +++ b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDiscretePrincipalCurvaturesQuadEdgeMeshFilter.h @@ -83,7 +83,7 @@ class DiscretePrincipalCurvaturesQuadEdgeMeshFilter void ComputeMeanAndGaussianCurvatures(const OutputPointType & iP) { - OutputMeshPointer output = this->GetOutput(); + const OutputMeshPointer output = this->GetOutput(); OutputQEType * qe = iP.GetEdge(); @@ -103,24 +103,24 @@ class DiscretePrincipalCurvaturesQuadEdgeMeshFilter { qe_it = qe; - OutputVectorType normal{}; - CoefficientType coefficent; + OutputVectorType normal{}; + const CoefficientType coefficent; do { - OutputQEType * qe_it2 = qe_it->GetOnext(); - OutputPointType q0 = output->GetPoint(qe_it->GetDestination()); - OutputPointType q1 = output->GetPoint(qe_it2->GetDestination()); + OutputQEType * qe_it2 = qe_it->GetOnext(); + const OutputPointType q0 = output->GetPoint(qe_it->GetDestination()); + const OutputPointType q1 = output->GetPoint(qe_it2->GetDestination()); - OutputCoordType temp_coeff = coefficent(output, qe_it); + const OutputCoordType temp_coeff = coefficent(output, qe_it); Laplace += temp_coeff * (iP - q0); // Compute Angle; sum_theta += static_cast(TriangleType::ComputeAngle(q0, iP, q1)); - OutputCurvatureType temp_area = this->ComputeMixedArea(qe_it, qe_it2); + const OutputCurvatureType temp_area = this->ComputeMixedArea(qe_it, qe_it2); area += temp_area; - OutputVectorType face_normal = TriangleType::ComputeNormal(q0, iP, q1); + const OutputVectorType face_normal = TriangleType::ComputeNormal(q0, iP, q1); normal += face_normal; qe_it = qe_it2; diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkEdgeDecimationQuadEdgeMeshFilter.hxx b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkEdgeDecimationQuadEdgeMeshFilter.hxx index f6ad7949855..eed9fbe9f79 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkEdgeDecimationQuadEdgeMeshFilter.hxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkEdgeDecimationQuadEdgeMeshFilter.hxx @@ -51,12 +51,12 @@ template void EdgeDecimationQuadEdgeMeshFilter::FillPriorityQueue() { - OutputMeshPointer output = this->GetOutput(); + const OutputMeshPointer output = this->GetOutput(); m_JoinVertexFunction->SetInput(output); - OutputCellsContainerIterator it = output->GetEdgeCells()->Begin(); - OutputCellsContainerIterator end = output->GetEdgeCells()->End(); + OutputCellsContainerIterator it = output->GetEdgeCells()->Begin(); + const OutputCellsContainerIterator end = output->GetEdgeCells()->End(); OutputEdgeCellType * edge; @@ -79,11 +79,11 @@ template void EdgeDecimationQuadEdgeMeshFilter::PushElement(OutputQEType * iEdge) { - OutputPointIdentifier id_org = iEdge->GetOrigin(); - OutputPointIdentifier id_dest = iEdge->GetDestination(); + const OutputPointIdentifier id_org = iEdge->GetOrigin(); + const OutputPointIdentifier id_dest = iEdge->GetDestination(); - OutputQEType * temp = (id_org < id_dest) ? iEdge : iEdge->GetSym(); - MeasureType measure = MeasureEdge(temp); + OutputQEType * temp = (id_org < id_dest) ? iEdge : iEdge->GetSym(); + const MeasureType measure = MeasureEdge(temp); auto * qi = new PriorityQueueItemType(temp, PriorityType(false, measure)); @@ -107,14 +107,14 @@ EdgeDecimationQuadEdgeMeshFilter:: return false; } - OutputPointIdentifier id_org = iEdge->GetOrigin(); + const OutputPointIdentifier id_org = iEdge->GetOrigin(); if (id_org == iEdge->m_NoPoint) { itkDebugMacro("id_org == iEdge->m_NoPoint, at iteration: " << this->m_Iteration); return false; } - OutputMeshPointer output = this->GetOutput(); + const OutputMeshPointer output = this->GetOutput(); if (output->FindEdge(id_org) == nullptr) { itkDebugMacro("output->FindEdge( id_org ) == 0, at iteration: " << this->m_Iteration); @@ -126,7 +126,7 @@ EdgeDecimationQuadEdgeMeshFilter:: return false; } - OutputPointIdentifier id_dest = iEdge->GetDestination(); + const OutputPointIdentifier id_dest = iEdge->GetDestination(); if (id_dest == iEdge->m_NoPoint) { itkDebugMacro("id_dest == iEdge->m_NoPoint, at iteration: " << this->m_Iteration); @@ -151,7 +151,7 @@ template void EdgeDecimationQuadEdgeMeshFilter::Extract() { - OutputMeshPointer output = this->GetOutput(); + const OutputMeshPointer output = this->GetOutput(); do { @@ -200,7 +200,7 @@ EdgeDecimationQuadEdgeMeshFilter::PushOrUpdateEleme auto map_it = m_QueueMapper.find(temp); - MeasureType measure = MeasureEdge(temp); + const MeasureType measure = MeasureEdge(temp); if (map_it != m_QueueMapper.end()) { if (!map_it->second->m_Priority.first) @@ -221,7 +221,7 @@ template void EdgeDecimationQuadEdgeMeshFilter::JoinVertexFailed() { - typename OperatorType::EdgeStatusType status = m_JoinVertexFunction->GetEdgeStatus(); + const typename OperatorType::EdgeStatusType status = m_JoinVertexFunction->GetEdgeStatus(); switch (status) { default: @@ -286,11 +286,11 @@ EdgeDecimationQuadEdgeMeshFilter::ProcessWithoutAny { OutputPointType pt; - OutputPointIdentifier id_org = m_Element->GetOrigin(); - OutputPointIdentifier id_dest = m_Element->GetDestination(); - OutputPointIdentifier idx = (id_org < id_dest) ? id_org : id_dest; + const OutputPointIdentifier id_org = m_Element->GetOrigin(); + const OutputPointIdentifier id_dest = m_Element->GetDestination(); + const OutputPointIdentifier idx = (id_org < id_dest) ? id_org : id_dest; - bool to_be_processed(true); + const bool to_be_processed(true); if (m_Relocate) { @@ -348,9 +348,9 @@ EdgeDecimationQuadEdgeMeshFilter::ProcessWithoutAny } else { - OutputPointIdentifier old_id = m_JoinVertexFunction->GetOldPointID(); + const OutputPointIdentifier old_id = m_JoinVertexFunction->GetOldPointID(); - OutputPointIdentifier new_id = (old_id == id_dest) ? id_org : id_dest; + const OutputPointIdentifier new_id = (old_id == id_dest) ? id_org : id_dest; DeletePoint(old_id, new_id); OutputQEType * edge = this->m_OutputMesh->FindEdge(new_id); @@ -384,16 +384,16 @@ EdgeDecimationQuadEdgeMeshFilter::CheckQEProcessing OutputQEType * qe = m_Element; OutputQEType * qe_sym = qe->GetSym(); - bool LeftIsTriangle = qe->IsLnextOfTriangle(); - bool RightIsTriangle = qe->GetSym()->IsLnextOfTriangle(); + const bool LeftIsTriangle = qe->IsLnextOfTriangle(); + const bool RightIsTriangle = qe->GetSym()->IsLnextOfTriangle(); if (LeftIsTriangle || RightIsTriangle) { if (LeftIsTriangle && RightIsTriangle) { // two triangles - bool OriginOrderIsTwo = (qe->GetOrder() == 2); - bool DestinationOrderIsTwo = (qe_sym->GetOrder() == 2); + const bool OriginOrderIsTwo = (qe->GetOrder() == 2); + const bool DestinationOrderIsTwo = (qe_sym->GetOrder() == 2); if (OriginOrderIsTwo || DestinationOrderIsTwo) { diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkLaplacianDeformationQuadEdgeMeshFilter.hxx b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkLaplacianDeformationQuadEdgeMeshFilter.hxx index 6ef846fb8a3..89e4776ffff 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkLaplacianDeformationQuadEdgeMeshFilter.hxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkLaplacianDeformationQuadEdgeMeshFilter.hxx @@ -86,7 +86,7 @@ LaplacianDeformationQuadEdgeMeshFilter:: p[i] = points->GetElement(vId[i]); } - OutputCoordinateType area = TriangleType::ComputeMixedArea(p[0], p[1], p[2]); + const OutputCoordinateType area = TriangleType::ComputeMixedArea(p[0], p[1], p[2]); if (area < itk::Math::eps) { return OutputCoordinateType{}; @@ -198,8 +198,8 @@ LaplacianDeformationQuadEdgeMeshFilter:: t = todo.back(); todo.pop_back(); - OutputPointIdentifier vId = t.m_Id; - unsigned int degree = t.m_Degree; + const OutputPointIdentifier vId = t.m_Id; + const unsigned int degree = t.m_Degree; if (degree == 0) { @@ -226,7 +226,7 @@ LaplacianDeformationQuadEdgeMeshFilter:: do { - CoefficientMapConstIterator coeffIt = m_CoefficientMap.find(temp); + const CoefficientMapConstIterator coeffIt = m_CoefficientMap.find(temp); if (coeffIt != m_CoefficientMap.end()) { @@ -242,8 +242,8 @@ LaplacianDeformationQuadEdgeMeshFilter:: { if (m_AreaComputationType != AreaEnum::NONE) { - AreaMapConstIterator mixedIt = m_MixedAreaMap.find(vId); - OutputCoordinateType mixedArea = NumericTraits::OneValue(); + const AreaMapConstIterator mixedIt = m_MixedAreaMap.find(vId); + OutputCoordinateType mixedArea = NumericTraits::OneValue(); if (mixedIt != m_MixedAreaMap.end()) { diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkLaplacianDeformationQuadEdgeMeshFilterWithHardConstraints.hxx b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkLaplacianDeformationQuadEdgeMeshFilterWithHardConstraints.hxx index 3cc662777c8..393a6ab9d4d 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkLaplacianDeformationQuadEdgeMeshFilterWithHardConstraints.hxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkLaplacianDeformationQuadEdgeMeshFilterWithHardConstraints.hxx @@ -76,7 +76,7 @@ LaplacianDeformationQuadEdgeMeshFilterWithHardConstraintsfirst; const OutputCoordinateType weight = rIt->second; - ConstraintMapConstIterator cIt = this->m_Constraints.find(vId2); + const ConstraintMapConstIterator cIt = this->m_Constraints.find(vId2); if (cIt != this->m_Constraints.end()) { iBx[internalId1] -= weight * (cIt->second)[0]; diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkLaplacianDeformationQuadEdgeMeshFilterWithSoftConstraints.hxx b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkLaplacianDeformationQuadEdgeMeshFilterWithSoftConstraints.hxx index 2af09c8bbe7..1909d59b4dc 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkLaplacianDeformationQuadEdgeMeshFilterWithSoftConstraints.hxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkLaplacianDeformationQuadEdgeMeshFilterWithSoftConstraints.hxx @@ -70,8 +70,8 @@ LaplacianDeformationQuadEdgeMeshFilterWithSoftConstraintsGetOutput(); - OutputMapPointIdentifierConstIterator it = this->m_InternalMap.begin(); - OutputMapPointIdentifierConstIterator end = this->m_InternalMap.end(); + OutputMapPointIdentifierConstIterator it = this->m_InternalMap.begin(); + const OutputMapPointIdentifierConstIterator end = this->m_InternalMap.end(); while (it != end) { @@ -81,8 +81,8 @@ LaplacianDeformationQuadEdgeMeshFilterWithSoftConstraintsFillMatrixRow(vId1, this->m_Order, NumericTraits::OneValue(), row); - RowConstIterator rIt = row.begin(); - RowConstIterator rEnd = row.end(); + RowConstIterator rIt = row.begin(); + const RowConstIterator rEnd = row.end(); while (rIt != rEnd) { @@ -135,7 +135,7 @@ LaplacianDeformationQuadEdgeMeshFilterWithSoftConstraintsFillMatrix(M, Bx, By, Bz); - MatrixType Mt(M.transpose()); + const MatrixType Mt(M.transpose()); MatrixType A(Mt * M); @@ -158,7 +158,7 @@ LaplacianDeformationQuadEdgeMeshFilterWithSoftConstraints::const_iterator lambdaIt = + const typename std::unordered_map::const_iterator lambdaIt = this->m_LocalLambdaSquare.find(vId); if (lambdaIt != this->m_LocalLambdaSquare.end()) { @@ -183,8 +183,8 @@ LaplacianDeformationQuadEdgeMeshFilterWithSoftConstraintsSolveLinearSystems(A, Cx, Cy, Cz, X, Y, Z); - OutputMapPointIdentifierConstIterator it = this->m_InternalMap.begin(); - OutputMapPointIdentifierConstIterator end = this->m_InternalMap.end(); + OutputMapPointIdentifierConstIterator it = this->m_InternalMap.begin(); + const OutputMapPointIdentifierConstIterator end = this->m_InternalMap.end(); while (it != end) { diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkNormalQuadEdgeMeshFilter.hxx b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkNormalQuadEdgeMeshFilter.hxx index bc1f620689d..bc34c670425 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkNormalQuadEdgeMeshFilter.hxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkNormalQuadEdgeMeshFilter.hxx @@ -32,7 +32,7 @@ template auto NormalQuadEdgeMeshFilter::ComputeFaceNormal(OutputPolygonType * iPoly) -> OutputFaceNormalType { - OutputMeshPointer output = this->GetOutput(); + const OutputMeshPointer output = this->GetOutput(); OutputPointType pt[3]; int k(0); @@ -53,8 +53,8 @@ template void NormalQuadEdgeMeshFilter::ComputeAllFaceNormals() { - OutputMeshPointer output = this->GetOutput(); - OutputPolygonType * poly; + const OutputMeshPointer output = this->GetOutput(); + OutputPolygonType * poly; for (OutputCellsContainerConstIterator cell_it = output->GetCells()->Begin(); cell_it != output->GetCells()->End(); ++cell_it) @@ -75,9 +75,9 @@ template void NormalQuadEdgeMeshFilter::ComputeAllVertexNormals() { - OutputMeshPointer output = this->GetOutput(); - OutputPointsContainerPointer points = output->GetPoints(); - OutputPointIdentifier id; + const OutputMeshPointer output = this->GetOutput(); + const OutputPointsContainerPointer points = output->GetPoints(); + OutputPointIdentifier id; OutputMeshType * outputMesh = this->GetOutput(); diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkParameterizationQuadEdgeMeshFilter.hxx b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkParameterizationQuadEdgeMeshFilter.hxx index 7c386f0efc0..81a823c9d81 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkParameterizationQuadEdgeMeshFilter.hxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkParameterizationQuadEdgeMeshFilter.hxx @@ -47,9 +47,9 @@ template void ParameterizationQuadEdgeMeshFilter::ComputeListOfInteriorVertices() { - InputMeshConstPointer input = this->GetInput(); + const InputMeshConstPointer input = this->GetInput(); - typename InputPointsContainer::ConstPointer points = input->GetPoints(); + const typename InputPointsContainer::ConstPointer points = input->GetPoints(); InputPointIdentifier k(0); InputPointIdentifier id(0); @@ -86,36 +86,36 @@ ParameterizationQuadEdgeMeshFilter::Fill VectorType & ioBx, VectorType & ioBy) { - InputMeshConstPointer input = this->GetInput(); - OutputMeshPointer output = this->GetOutput(); + const InputMeshConstPointer input = this->GetInput(); + const OutputMeshPointer output = this->GetOutput(); for (auto InternalPtIterator = m_InternalPtMap.begin(); InternalPtIterator != m_InternalPtMap.end(); ++InternalPtIterator) { - InputPointIdentifier id1 = InternalPtIterator->first; - InputPointIdentifier InternalId1 = InternalPtIterator->second; - ValueType k[2]{}; + const InputPointIdentifier id1 = InternalPtIterator->first; + const InputPointIdentifier InternalId1 = InternalPtIterator->second; + ValueType k[2]{}; InputQEType * edge = input->FindEdge(id1); InputQEType * temp = edge; do { - InputPointIdentifier id2 = temp->GetDestination(); - InputMapPointIdentifierIterator it = m_BoundaryPtMap.find(id2); + const InputPointIdentifier id2 = temp->GetDestination(); + const InputMapPointIdentifierIterator it = m_BoundaryPtMap.find(id2); if (it != m_BoundaryPtMap.end()) { - InputCoordinateType value = (*m_CoefficientsMethod)(input, temp); - OutputPointType pt2 = output->GetPoint(it->first); + const InputCoordinateType value = (*m_CoefficientsMethod)(input, temp); + OutputPointType pt2 = output->GetPoint(it->first); SolverTraits::AddToMatrix(iM, InternalId1, InternalId1, value); k[0] += static_cast(pt2[0] * value); k[1] += static_cast(pt2[1] * value); } else { - InputPointIdentifier InternalId2 = m_InternalPtMap[id2]; + const InputPointIdentifier InternalId2 = m_InternalPtMap[id2]; if (InternalId1 < InternalId2) { - InputCoordinateType value = (*m_CoefficientsMethod)(input, temp); + const InputCoordinateType value = (*m_CoefficientsMethod)(input, temp); SolverTraits::FillMatrix(iM, InternalId1, InternalId2, -value); SolverTraits::FillMatrix(iM, InternalId2, InternalId1, -value); SolverTraits::AddToMatrix(iM, InternalId1, InternalId1, value); @@ -138,8 +138,8 @@ ParameterizationQuadEdgeMeshFilter::Gene { this->CopyInputMeshToOutputMesh(); - InputMeshConstPointer input = this->GetInput(); - OutputMeshType * output = this->GetOutput(); + const InputMeshConstPointer input = this->GetInput(); + OutputMeshType * output = this->GetOutput(); if (m_BorderTransform.IsNotNull()) { diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkQuadEdgeMeshDecimationQuadricElementHelper.h b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkQuadEdgeMeshDecimationQuadricElementHelper.h index 1fcb1f82d1d..ae766b8e891 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkQuadEdgeMeshDecimationQuadricElementHelper.h +++ b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkQuadEdgeMeshDecimationQuadricElementHelper.h @@ -102,7 +102,7 @@ class QuadEdgeMeshDecimationQuadricElementHelper // ComputeAMatrixAndBVector(); vnl_svd svd(m_A, m_SVDAbsoluteThreshold); svd.zero_out_relative(m_SVDRelativeThreshold); - CoordType oError = inner_product(iP.GetVnlVector(), svd.recompose() * iP.GetVnlVector()); + const CoordType oError = inner_product(iP.GetVnlVector(), svd.recompose() * iP.GetVnlVector()); return this->m_Coefficients.back() - oError; /* @@ -174,7 +174,7 @@ class QuadEdgeMeshDecimationQuadricElementHelper const PointType & iP3, const CoordType & iWeight = static_cast(1.)) { - VectorType N = TriangleType::ComputeNormal(iP1, iP2, iP3); + const VectorType N = TriangleType::ComputeNormal(iP1, iP2, iP3); AddPoint(iP1, N, iWeight); } @@ -182,8 +182,8 @@ class QuadEdgeMeshDecimationQuadricElementHelper void AddPoint(const PointType & iP, const VectorType & iN, const CoordType & iWeight = static_cast(1.)) { - unsigned int k(0); /*one-line-declaration*/ - CoordType d = -iN * iP.GetVectorFromOrigin(); + unsigned int k(0); /*one-line-declaration*/ + const CoordType d = -iN * iP.GetVectorFromOrigin(); for (unsigned int dim1 = 0; dim1 < PointDimension; ++dim1) { for (unsigned int dim2 = dim1; dim2 < PointDimension; ++dim2) diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkQuadEdgeMeshParamMatrixCoefficients.h b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkQuadEdgeMeshParamMatrixCoefficients.h index c276db145dc..fa381187e3f 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkQuadEdgeMeshParamMatrixCoefficients.h +++ b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkQuadEdgeMeshParamMatrixCoefficients.h @@ -115,13 +115,13 @@ class ITK_TEMPLATE_EXPORT InverseEuclideanDistanceMatrixCoefficients : public Ma InputCoordinateType operator()(const InputMeshType * iMesh, InputQEType * iEdge) const override { - InputPointIdentifier id1 = iEdge->GetOrigin(); - InputPointIdentifier id2 = iEdge->GetDestination(); + const InputPointIdentifier id1 = iEdge->GetOrigin(); + const InputPointIdentifier id2 = iEdge->GetDestination(); - InputPointType pt1 = iMesh->GetPoint(id1); - InputPointType pt2 = iMesh->GetPoint(id2); + const InputPointType pt1 = iMesh->GetPoint(id1); + const InputPointType pt2 = iMesh->GetPoint(id2); - InputCoordinateType oValue = 1.0 / pt1.EuclideanDistanceTo(pt2); + const InputCoordinateType oValue = 1.0 / pt1.EuclideanDistanceTo(pt2); return oValue; } @@ -160,23 +160,23 @@ class ITK_TEMPLATE_EXPORT ConformalMatrixCoefficients : public MatrixCoefficient InputCoordinateType operator()(const InputMeshType * iMesh, InputQEType * iEdge) const override { - InputPointIdentifier id1 = iEdge->GetOrigin(); - InputPointIdentifier id2 = iEdge->GetDestination(); - InputPointType pt1 = iMesh->GetPoint(id1); - InputPointType pt2 = iMesh->GetPoint(id2); + const InputPointIdentifier id1 = iEdge->GetOrigin(); + const InputPointIdentifier id2 = iEdge->GetDestination(); + const InputPointType pt1 = iMesh->GetPoint(id1); + const InputPointType pt2 = iMesh->GetPoint(id2); InputCoordinateType oValue(0.0); if (iEdge->IsLeftSet()) { - InputPointIdentifier idA = iEdge->GetLnext()->GetDestination(); - InputPointType ptA = iMesh->GetPoint(idA); + const InputPointIdentifier idA = iEdge->GetLnext()->GetDestination(); + const InputPointType ptA = iMesh->GetPoint(idA); oValue += TriangleHelper::Cotangent(pt1, ptA, pt2); } if (iEdge->IsRightSet()) { - InputPointIdentifier idB = iEdge->GetRnext()->GetOrigin(); - InputPointType ptB = iMesh->GetPoint(idB); + const InputPointIdentifier idB = iEdge->GetRnext()->GetOrigin(); + const InputPointType ptB = iMesh->GetPoint(idB); oValue += TriangleHelper::Cotangent(pt1, ptB, pt2); } @@ -219,25 +219,25 @@ class ITK_TEMPLATE_EXPORT AuthalicMatrixCoefficients : public MatrixCoefficients InputCoordinateType operator()(const InputMeshType * iMesh, InputQEType * iEdge) const override { - InputPointIdentifier id1 = iEdge->GetOrigin(); - InputPointType pt1 = iMesh->GetPoint(id1); + const InputPointIdentifier id1 = iEdge->GetOrigin(); + const InputPointType pt1 = iMesh->GetPoint(id1); - InputPointIdentifier id2 = iEdge->GetDestination(); - InputPointType pt2 = iMesh->GetPoint(id2); + const InputPointIdentifier id2 = iEdge->GetDestination(); + const InputPointType pt2 = iMesh->GetPoint(id2); InputCoordinateType oValue{}; if (iEdge->IsLeftSet()) { - InputPointIdentifier idA = iEdge->GetLnext()->GetDestination(); - InputPointType ptA = iMesh->GetPoint(idA); + const InputPointIdentifier idA = iEdge->GetLnext()->GetDestination(); + const InputPointType ptA = iMesh->GetPoint(idA); oValue += TriangleHelper::Cotangent(pt1, pt2, ptA); } if (iEdge->IsRightSet()) { - InputPointIdentifier idB = iEdge->GetRnext()->GetOrigin(); - InputPointType ptB = iMesh->GetPoint(idB); + const InputPointIdentifier idB = iEdge->GetRnext()->GetOrigin(); + const InputPointType ptB = iMesh->GetPoint(idB); oValue += TriangleHelper::Cotangent(pt1, pt2, ptB); } @@ -315,34 +315,34 @@ class ITK_TEMPLATE_EXPORT HarmonicMatrixCoefficients : public MatrixCoefficients InputCoordinateType operator()(const InputMeshType * iMesh, InputQEType * iEdge) const override { - InputPointIdentifier id1 = iEdge->GetOrigin(); - InputPointIdentifier id2 = iEdge->GetDestination(); + const InputPointIdentifier id1 = iEdge->GetOrigin(); + const InputPointIdentifier id2 = iEdge->GetDestination(); - InputPointIdentifier idA = iEdge->GetLnext()->GetDestination(); - InputPointIdentifier idB = iEdge->GetRnext()->GetOrigin(); + const InputPointIdentifier idA = iEdge->GetLnext()->GetDestination(); + const InputPointIdentifier idB = iEdge->GetRnext()->GetOrigin(); - InputPointType pt1 = iMesh->GetPoint(id1); - InputPointType pt2 = iMesh->GetPoint(id2); - InputPointType ptA = iMesh->GetPoint(idA); - InputPointType ptB = iMesh->GetPoint(idB); + const InputPointType pt1 = iMesh->GetPoint(id1); + const InputPointType pt2 = iMesh->GetPoint(id2); + const InputPointType ptA = iMesh->GetPoint(idA); + const InputPointType ptB = iMesh->GetPoint(idB); - InputVectorType v1A = ptA - pt1; - InputVectorType v1B = ptB - pt1; - InputVectorType v12 = pt2 - pt1; + const InputVectorType v1A = ptA - pt1; + const InputVectorType v1B = ptB - pt1; + const InputVectorType v12 = pt2 - pt1; - InputCoordinateType L1A = v1A * v1A; - InputCoordinateType L1B = v1B * v1B; - InputCoordinateType L12 = v12 * v12; + const InputCoordinateType L1A = v1A * v1A; + const InputCoordinateType L1B = v1B * v1B; + const InputCoordinateType L12 = v12 * v12; - InputCoordinateType L2A = pt2.SquaredEuclideanDistanceTo(ptA); - InputCoordinateType L2B = pt2.SquaredEuclideanDistanceTo(ptB); + const InputCoordinateType L2A = pt2.SquaredEuclideanDistanceTo(ptA); + const InputCoordinateType L2B = pt2.SquaredEuclideanDistanceTo(ptB); - CrossHelper cross; + const CrossHelper cross; - InputCoordinateType AreaA = 0.5 * (cross(v1A, v12).GetNorm()); - InputCoordinateType AreaB = 0.5 * (cross(v1B, v12).GetNorm()); + const InputCoordinateType AreaA = 0.5 * (cross(v1A, v12).GetNorm()); + const InputCoordinateType AreaB = 0.5 * (cross(v1B, v12).GetNorm()); - InputCoordinateType oValue = (L1A + L2A - L12) / AreaA + (L1B + L2B - L12) / AreaB; + const InputCoordinateType oValue = (L1A + L2A - L12) / AreaA + (L1B + L2B - L12) / AreaB; return oValue; } diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkQuadricDecimationQuadEdgeMeshFilter.h b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkQuadricDecimationQuadEdgeMeshFilter.h index c084936db68..2dd570af54e 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkQuadricDecimationQuadEdgeMeshFilter.h +++ b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkQuadricDecimationQuadEdgeMeshFilter.h @@ -120,17 +120,17 @@ class ITK_TEMPLATE_EXPORT QuadricDecimationQuadEdgeMeshFilter MeasureType MeasureEdge(OutputQEType * iEdge) override { - OutputPointIdentifier id_org = iEdge->GetOrigin(); - OutputPointIdentifier id_dest = iEdge->GetDestination(); - QuadricElementType Q = m_Quadric[id_org] + m_Quadric[id_dest]; + const OutputPointIdentifier id_org = iEdge->GetOrigin(); + const OutputPointIdentifier id_dest = iEdge->GetDestination(); + QuadricElementType Q = m_Quadric[id_org] + m_Quadric[id_dest]; - OutputPointType org = this->m_OutputMesh->GetPoint(id_org); - OutputPointType dest = this->m_OutputMesh->GetPoint(id_dest); + const OutputPointType org = this->m_OutputMesh->GetPoint(id_org); + const OutputPointType dest = this->m_OutputMesh->GetPoint(id_dest); OutputPointType mid; mid.SetToMidPoint(org, dest); - OutputPointType p = Q.ComputeOptimalLocation(mid); + const OutputPointType p = Q.ComputeOptimalLocation(mid); return static_cast(Q.ComputeError(p)); } diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkQuadricDecimationQuadEdgeMeshFilter.hxx b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkQuadricDecimationQuadEdgeMeshFilter.hxx index f38593ce963..50c5e3d8d20 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkQuadricDecimationQuadEdgeMeshFilter.hxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkQuadricDecimationQuadEdgeMeshFilter.hxx @@ -26,12 +26,12 @@ template void QuadricDecimationQuadEdgeMeshFilter::Initialize() { - OutputMeshPointer output = this->GetOutput(); - OutputPointsContainerPointer points = output->GetPoints(); - OutputPointsContainerIterator it = points->Begin(); - OutputPointIdentifier p_id; - OutputQEType * qe; - OutputQEType * qe_it; + const OutputMeshPointer output = this->GetOutput(); + const OutputPointsContainerPointer points = output->GetPoints(); + OutputPointsContainerIterator it = points->Begin(); + OutputPointIdentifier p_id; + OutputQEType * qe; + OutputQEType * qe_it; OutputMeshType * outputMesh = this->GetOutput(); while (it != points->End()) @@ -69,14 +69,14 @@ template auto QuadricDecimationQuadEdgeMeshFilter::Relocate(OutputQEType * iEdge) -> OutputPointType { - OutputPointIdentifier id_org = iEdge->GetOrigin(); - OutputPointIdentifier id_dest = iEdge->GetDestination(); - QuadricElementType Q = m_Quadric[id_org] + m_Quadric[id_dest]; + const OutputPointIdentifier id_org = iEdge->GetOrigin(); + const OutputPointIdentifier id_dest = iEdge->GetDestination(); + QuadricElementType Q = m_Quadric[id_org] + m_Quadric[id_dest]; - OutputMeshPointer output = this->GetOutput(); + const OutputMeshPointer output = this->GetOutput(); - OutputPointType org = output->GetPoint(id_org); - OutputPointType dest = output->GetPoint(id_dest); + const OutputPointType org = output->GetPoint(id_org); + const OutputPointType dest = output->GetPoint(id_dest); OutputPointType mid; diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkSmoothingQuadEdgeMeshFilter.hxx b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkSmoothingQuadEdgeMeshFilter.hxx index c17d69a2349..d2457a07bdb 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkSmoothingQuadEdgeMeshFilter.hxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkSmoothingQuadEdgeMeshFilter.hxx @@ -49,13 +49,13 @@ template void SmoothingQuadEdgeMeshFilter::GenerateData() { - OutputPointIdentifier numberOfPoints = this->GetInput()->GetNumberOfPoints(); + const OutputPointIdentifier numberOfPoints = this->GetInput()->GetNumberOfPoints(); ProgressReporter progress(this, 0, m_NumberOfIterations * (numberOfPoints + 1), 100); OutputMeshPointer mesh = OutputMeshType::New(); - OutputPointsContainerPointer temp = OutputPointsContainer::New(); + const OutputPointsContainerPointer temp = OutputPointsContainer::New(); temp->Reserve(numberOfPoints); OutputPointsContainerPointer points; diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkSquaredEdgeLengthDecimationQuadEdgeMeshFilter.h b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkSquaredEdgeLengthDecimationQuadEdgeMeshFilter.h index 522f700b638..ec190deb4c0 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkSquaredEdgeLengthDecimationQuadEdgeMeshFilter.h +++ b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkSquaredEdgeLengthDecimationQuadEdgeMeshFilter.h @@ -84,11 +84,11 @@ class ITK_TEMPLATE_EXPORT SquaredEdgeLengthDecimationQuadEdgeMeshFilter MeasureType MeasureEdge(OutputQEType * iEdge) override { - OutputPointIdentifier id_org = iEdge->GetOrigin(); - OutputPointIdentifier id_dest = iEdge->GetDestination(); + const OutputPointIdentifier id_org = iEdge->GetOrigin(); + const OutputPointIdentifier id_dest = iEdge->GetDestination(); - OutputPointType org = this->m_OutputMesh->GetPoint(id_org); - OutputPointType dest = this->m_OutputMesh->GetPoint(id_dest); + const OutputPointType org = this->m_OutputMesh->GetPoint(id_org); + const OutputPointType dest = this->m_OutputMesh->GetPoint(id_dest); return static_cast(org.SquaredEuclideanDistanceTo(dest)); } diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkSquaredEdgeLengthDecimationQuadEdgeMeshFilter.hxx b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkSquaredEdgeLengthDecimationQuadEdgeMeshFilter.hxx index 4c6630b76e0..741d212e501 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkSquaredEdgeLengthDecimationQuadEdgeMeshFilter.hxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkSquaredEdgeLengthDecimationQuadEdgeMeshFilter.hxx @@ -32,9 +32,9 @@ auto SquaredEdgeLengthDecimationQuadEdgeMeshFilter::Relocate(OutputQEType * iEdge) -> OutputPointType { - OutputMeshPointer output = this->GetOutput(); - OutputPointIdentifier id_org = iEdge->GetOrigin(); - OutputPointIdentifier id_dest = iEdge->GetDestination(); + const OutputMeshPointer output = this->GetOutput(); + const OutputPointIdentifier id_org = iEdge->GetOrigin(); + const OutputPointIdentifier id_dest = iEdge->GetDestination(); OutputPointType oPt; diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkAutomaticTopologyQuadEdgeMeshSourceTest.cxx b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkAutomaticTopologyQuadEdgeMeshSourceTest.cxx index 33103a8e3a6..8b68e52ef10 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkAutomaticTopologyQuadEdgeMeshSourceTest.cxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkAutomaticTopologyQuadEdgeMeshSourceTest.cxx @@ -214,8 +214,8 @@ itkAutomaticTopologyQuadEdgeMeshSourceTest(int, char *[]) std::cout << mesh->GetNumberOfPoints() << " points:" << std::endl; for (i = 0; i < mesh->GetNumberOfPoints(); ++i) { - PointType point; - bool dummy = mesh->GetPoint(i, &point); + PointType point; + const bool dummy = mesh->GetPoint(i, &point); if (dummy) { std::cout << i << ": " << point << std::endl; diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkBinaryMask3DQuadEdgeMeshSourceTest.cxx b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkBinaryMask3DQuadEdgeMeshSourceTest.cxx index 368ffa9582a..1951fb20446 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkBinaryMask3DQuadEdgeMeshSourceTest.cxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkBinaryMask3DQuadEdgeMeshSourceTest.cxx @@ -55,9 +55,9 @@ itkBinaryMask3DQuadEdgeMeshSourceTest(int, char *[]) size[1] = 128; size[2] = 128; - IndexType start{}; + const IndexType start{}; - RegionType region{ start, size }; + const RegionType region{ start, size }; auto image = ImageType::New(); diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkBorderQuadEdgeMeshFilterTest.cxx b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkBorderQuadEdgeMeshFilterTest.cxx index f92050cec5e..5089f517e42 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkBorderQuadEdgeMeshFilterTest.cxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkBorderQuadEdgeMeshFilterTest.cxx @@ -60,7 +60,7 @@ itkBorderQuadEdgeMeshFilterTest(int argc, char * argv[]) return EXIT_FAILURE; } - MeshType::Pointer mesh = reader->GetOutput(); + const MeshType::Pointer mesh = reader->GetOutput(); // ** CHOSE< COMPUTE AND SET BORDER TRANSFORM ** auto border_transform = BorderTransformType::New(); @@ -69,7 +69,7 @@ itkBorderQuadEdgeMeshFilterTest(int argc, char * argv[]) border_transform->SetRadius(border_transform->GetRadius()); border_transform->GetNameOfClass(); - int border = std::stoi(argv[2]); + const int border = std::stoi(argv[2]); switch (border) // choose border type { case 0: // square shaped domain @@ -86,7 +86,7 @@ itkBorderQuadEdgeMeshFilterTest(int argc, char * argv[]) std::cout << "Transform type is: " << border_transform->GetTransformType(); std::cout << std::endl; - int pick = std::stoi(argv[3]); + const int pick = std::stoi(argv[3]); switch (pick) { case 0: @@ -103,7 +103,7 @@ itkBorderQuadEdgeMeshFilterTest(int argc, char * argv[]) std::cout << "Border picked is: " << border_transform->GetBorderPick(); std::cout << std::endl; - MeshType::Pointer output = border_transform->GetOutput(); + const MeshType::Pointer output = border_transform->GetOutput(); // ** WRITE OUTPUT ** auto writer = WriterType::New(); diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkCleanQuadEdgeMeshFilterTest.cxx b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkCleanQuadEdgeMeshFilterTest.cxx index 84d0869f5c4..89e13e0cfb3 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkCleanQuadEdgeMeshFilterTest.cxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkCleanQuadEdgeMeshFilterTest.cxx @@ -52,7 +52,7 @@ itkCleanQuadEdgeMeshFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); - MeshType::Pointer mesh = reader->GetOutput(); + const MeshType::Pointer mesh = reader->GetOutput(); Coord tol; std::stringstream ssout(argv[2]); @@ -66,13 +66,13 @@ itkCleanQuadEdgeMeshFilterTest(int argc, char * argv[]) filter->SetInput(mesh); - typename CleanFilterType::InputCoordinateType absTol{}; + const typename CleanFilterType::InputCoordinateType absTol{}; filter->SetAbsoluteTolerance(absTol); ITK_TEST_SET_GET_VALUE(absTol, filter->GetAbsoluteTolerance()); filter->SetRelativeTolerance(tol); const Coord epsilon = 1e-6; - Coord obtainedValue = filter->GetRelativeTolerance(); + const Coord obtainedValue = filter->GetRelativeTolerance(); if (!itk::Math::FloatAlmostEqual(tol, obtainedValue, 10, epsilon)) { std::cerr.precision(static_cast(itk::Math::abs(std::log10(epsilon)))); diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDelaunayConformingQuadEdgeMeshFilterTest.cxx b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDelaunayConformingQuadEdgeMeshFilterTest.cxx index 107daccace2..e87e1e83f45 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDelaunayConformingQuadEdgeMeshFilterTest.cxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDelaunayConformingQuadEdgeMeshFilterTest.cxx @@ -43,7 +43,7 @@ itkDelaunayConformingQuadEdgeMeshFilterTestHelper(const std::string & input, reader->SetFileName(input); ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); - MeshType::Pointer mesh = reader->GetOutput(); + const MeshType::Pointer mesh = reader->GetOutput(); using GeneratorType = itk::Statistics::NormalVariateGenerator; const auto generator = GeneratorType::New(); diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteGaussianCurvatureQuadEdgeMeshFilterTest.cxx b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteGaussianCurvatureQuadEdgeMeshFilterTest.cxx index 12f86227d14..098f2190e31 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteGaussianCurvatureQuadEdgeMeshFilterTest.cxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteGaussianCurvatureQuadEdgeMeshFilterTest.cxx @@ -48,7 +48,7 @@ itkDiscreteGaussianCurvatureQuadEdgeMeshFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); - MeshType::Pointer mesh = reader->GetOutput(); + const MeshType::Pointer mesh = reader->GetOutput(); auto gaussianCurvatureFilter = CurvatureFilterType::New(); @@ -59,7 +59,7 @@ itkDiscreteGaussianCurvatureQuadEdgeMeshFilterTest(int argc, char * argv[]) gaussianCurvatureFilter->SetInput(mesh); gaussianCurvatureFilter->Update(); - MeshType::Pointer output = gaussianCurvatureFilter->GetOutput(); + const MeshType::Pointer output = gaussianCurvatureFilter->GetOutput(); using WriterType = itk::MeshFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteMaximumCurvatureQuadEdgeMeshFilterTest.cxx b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteMaximumCurvatureQuadEdgeMeshFilterTest.cxx index 949352dcfe1..8db3f39675c 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteMaximumCurvatureQuadEdgeMeshFilterTest.cxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteMaximumCurvatureQuadEdgeMeshFilterTest.cxx @@ -55,7 +55,7 @@ itkDiscreteMaximumCurvatureQuadEdgeMeshFilterTest(int argc, char * argv[]) return EXIT_FAILURE; } - MeshType::Pointer mesh = reader->GetOutput(); + const MeshType::Pointer mesh = reader->GetOutput(); auto max_curvature = CurvatureFilterType::New(); @@ -66,7 +66,7 @@ itkDiscreteMaximumCurvatureQuadEdgeMeshFilterTest(int argc, char * argv[]) max_curvature->SetInput(mesh); max_curvature->Update(); - MeshType::Pointer output = max_curvature->GetOutput(); + const MeshType::Pointer output = max_curvature->GetOutput(); using WriterType = itk::MeshFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteMeanCurvatureQuadEdgeMeshFilterTest.cxx b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteMeanCurvatureQuadEdgeMeshFilterTest.cxx index 4d9b0b60b1c..74560d5a05f 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteMeanCurvatureQuadEdgeMeshFilterTest.cxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteMeanCurvatureQuadEdgeMeshFilterTest.cxx @@ -55,7 +55,7 @@ itkDiscreteMeanCurvatureQuadEdgeMeshFilterTest(int argc, char * argv[]) return EXIT_FAILURE; } - MeshType::Pointer mesh = reader->GetOutput(); + const MeshType::Pointer mesh = reader->GetOutput(); auto mean_curvature = CurvatureFilterType::New(); @@ -66,7 +66,7 @@ itkDiscreteMeanCurvatureQuadEdgeMeshFilterTest(int argc, char * argv[]) mean_curvature->SetInput(mesh); mean_curvature->Update(); - MeshType::Pointer output = mean_curvature->GetOutput(); + const MeshType::Pointer output = mean_curvature->GetOutput(); using WriterType = itk::MeshFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteMinimumCurvatureQuadEdgeMeshFilterTest.cxx b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteMinimumCurvatureQuadEdgeMeshFilterTest.cxx index c5e7efba35a..a78344936c4 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteMinimumCurvatureQuadEdgeMeshFilterTest.cxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDiscreteMinimumCurvatureQuadEdgeMeshFilterTest.cxx @@ -55,7 +55,7 @@ itkDiscreteMinimumCurvatureQuadEdgeMeshFilterTest(int argc, char * argv[]) return EXIT_FAILURE; } - MeshType::Pointer mesh = reader->GetOutput(); + const MeshType::Pointer mesh = reader->GetOutput(); auto min_curvature = CurvatureFilterType::New(); @@ -66,7 +66,7 @@ itkDiscreteMinimumCurvatureQuadEdgeMeshFilterTest(int argc, char * argv[]) min_curvature->SetInput(mesh); min_curvature->Update(); - MeshType::Pointer output = min_curvature->GetOutput(); + const MeshType::Pointer output = min_curvature->GetOutput(); using WriterType = itk::MeshFileWriter; auto writer = WriterType::New(); diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkLaplacianDeformationQuadEdgeMeshFilterWithHardConstraintsTest.cxx b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkLaplacianDeformationQuadEdgeMeshFilterWithHardConstraintsTest.cxx index 7ca444e3b26..20a35c976b1 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkLaplacianDeformationQuadEdgeMeshFilterWithHardConstraintsTest.cxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkLaplacianDeformationQuadEdgeMeshFilterWithHardConstraintsTest.cxx @@ -56,7 +56,7 @@ itkLaplacianDeformationQuadEdgeMeshFilterWithHardConstraintsTest(int argc, char filter->SetInput(reader->GetOutput()); - unsigned int order = 2; + const unsigned int order = 2; filter->SetOrder(order); ITK_TEST_SET_GET_VALUE(order, filter->GetOrder()); @@ -114,16 +114,16 @@ itkLaplacianDeformationQuadEdgeMeshFilterWithHardConstraintsTest(int argc, char writer->SetFileName(argv[2]); writer->Update(); - MeshType::Pointer inputMesh = reader->GetOutput(); - MeshType::Pointer outputMesh = filter->GetOutput(); + const MeshType::Pointer inputMesh = reader->GetOutput(); + const MeshType::Pointer outputMesh = filter->GetOutput(); it = constraints.begin(); while (it != constraints.end()) { - MeshType::PointType iPt = inputMesh->GetPoint(it->first); - MeshType::PointType oPt = outputMesh->GetPoint(it->first); - MeshType::VectorType displacement = oPt - iPt; + const MeshType::PointType iPt = inputMesh->GetPoint(it->first); + const MeshType::PointType oPt = outputMesh->GetPoint(it->first); + const MeshType::VectorType displacement = oPt - iPt; if ((displacement - it->second).GetNorm() > 1e-6) { @@ -134,9 +134,9 @@ itkLaplacianDeformationQuadEdgeMeshFilterWithHardConstraintsTest(int argc, char ++it; } - MeshType::PointType iPt = inputMesh->GetPoint(0); - MeshType::PointType oPt = outputMesh->GetPoint(0); - MeshType::VectorType displacement = oPt - iPt; + const MeshType::PointType iPt = inputMesh->GetPoint(0); + const MeshType::PointType oPt = outputMesh->GetPoint(0); + const MeshType::VectorType displacement = oPt - iPt; if (displacement.GetNorm() < 1e-6) { std::cerr << "No displacement" << std::endl; diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkLaplacianDeformationQuadEdgeMeshFilterWithSoftConstraintsTest.cxx b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkLaplacianDeformationQuadEdgeMeshFilterWithSoftConstraintsTest.cxx index 2bc3af3c137..efab87b1a2d 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkLaplacianDeformationQuadEdgeMeshFilterWithSoftConstraintsTest.cxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkLaplacianDeformationQuadEdgeMeshFilterWithSoftConstraintsTest.cxx @@ -57,7 +57,7 @@ itkLaplacianDeformationQuadEdgeMeshFilterWithSoftConstraintsTest(int argc, char filter->SetInput(reader->GetOutput()); filter->SetOrder(1); - typename FilterType::OutputCoordinateType lambda = 1.0; + const typename FilterType::OutputCoordinateType lambda = 1.0; filter->SetLambda(lambda); ITK_TEST_SET_GET_VALUE(lambda, filter->GetLambda()); @@ -124,15 +124,15 @@ itkLaplacianDeformationQuadEdgeMeshFilterWithSoftConstraintsTest(int argc, char writer->SetFileName(argv[2]); writer->Update(); - MeshType::Pointer inputMesh = reader->GetOutput(); - MeshType::Pointer outputMesh = filter->GetOutput(); + const MeshType::Pointer inputMesh = reader->GetOutput(); + const MeshType::Pointer outputMesh = filter->GetOutput(); it = constraints.begin(); while (it != constraints.end()) { - MeshType::PointType iPt = inputMesh->GetPoint(it->first); - MeshType::PointType oPt = outputMesh->GetPoint(it->first); - MeshType::VectorType displacement = oPt - iPt; + const MeshType::PointType iPt = inputMesh->GetPoint(it->first); + const MeshType::PointType oPt = outputMesh->GetPoint(it->first); + const MeshType::VectorType displacement = oPt - iPt; if (it->second.GetNorm() > 1e-6) { diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkNormalQuadEdgeMeshFilterTest.cxx b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkNormalQuadEdgeMeshFilterTest.cxx index 6d486a294e8..f46f827c62a 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkNormalQuadEdgeMeshFilterTest.cxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkNormalQuadEdgeMeshFilterTest.cxx @@ -52,7 +52,7 @@ itkNormalQuadEdgeMeshFilterTest(int argc, char * argv[]) using NormalFilterType = itk::NormalQuadEdgeMeshFilter; NormalFilterType::WeightEnum weight_type; - int param = std::stoi(argv[2]); + const int param = std::stoi(argv[2]); if ((param < 0) || (param > 2)) { @@ -93,7 +93,7 @@ itkNormalQuadEdgeMeshFilterTest(int argc, char * argv[]) return EXIT_FAILURE; } - InputMeshType::Pointer mesh = reader->GetOutput(); + const InputMeshType::Pointer mesh = reader->GetOutput(); auto normals = NormalFilterType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(normals, NormalQuadEdgeMeshFilter, QuadEdgeMeshToQuadEdgeMeshFilter); @@ -106,7 +106,7 @@ itkNormalQuadEdgeMeshFilterTest(int argc, char * argv[]) normals->Update(); - OutputMeshType::Pointer output = normals->GetOutput(); + const OutputMeshType::Pointer output = normals->GetOutput(); // // FIXME diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkParameterizationQuadEdgeMeshFilterTest.cxx b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkParameterizationQuadEdgeMeshFilterTest.cxx index 9c0c2a92692..c6fb739f58d 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkParameterizationQuadEdgeMeshFilterTest.cxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkParameterizationQuadEdgeMeshFilterTest.cxx @@ -55,7 +55,7 @@ ParameterizationQuadEdgeMeshFilterTest(const char * inputFilename, return EXIT_FAILURE; } - typename MeshType::Pointer mesh = reader->GetOutput(); + const typename MeshType::Pointer mesh = reader->GetOutput(); // ** CHOSE< COMPUTE AND SET BORDER TRANSFORM ** auto border_transform = BorderTransformType::New(); @@ -125,7 +125,7 @@ ParameterizationQuadEdgeMeshFilterTest(const char * inputFilename, // ** PROCESS ** param->Update(); - typename MeshType::Pointer output = param->GetOutput(); + const typename MeshType::Pointer output = param->GetOutput(); // ** WRITE OUTPUT ** auto writer = WriterType::New(); diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkRegularSphereQuadEdgeMeshSourceTest.cxx b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkRegularSphereQuadEdgeMeshSourceTest.cxx index 8e19eef4983..85f37338d6b 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkRegularSphereQuadEdgeMeshSourceTest.cxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkRegularSphereQuadEdgeMeshSourceTest.cxx @@ -41,7 +41,7 @@ itkRegularSphereQuadEdgeMeshSourceTest(int argc, char * argv[]) using PointType = SphereMeshSourceType::PointType; using VectorType = SphereMeshSourceType::VectorType; - PointType center{}; + const PointType center{}; auto scale = itk::MakeFilled(1.0); @@ -56,7 +56,7 @@ itkRegularSphereQuadEdgeMeshSourceTest(int argc, char * argv[]) std::cout << "mySphereMeshSource: " << mySphereMeshSource; - MeshType::Pointer myMesh = mySphereMeshSource->GetOutput(); + const MeshType::Pointer myMesh = mySphereMeshSource->GetOutput(); PointType pt{}; diff --git a/Modules/Filtering/Smoothing/include/itkBinomialBlurImageFilter.hxx b/Modules/Filtering/Smoothing/include/itkBinomialBlurImageFilter.hxx index 8e5809f91c8..75e0d1582f6 100644 --- a/Modules/Filtering/Smoothing/include/itkBinomialBlurImageFilter.hxx +++ b/Modules/Filtering/Smoothing/include/itkBinomialBlurImageFilter.hxx @@ -44,8 +44,8 @@ BinomialBlurImageFilter::GenerateInputRequestedRegion Superclass::GenerateInputRequestedRegion(); - InputImagePointer inputPtr = const_cast(this->GetInput(0)); - OutputImagePointer outputPtr = this->GetOutput(0); + const InputImagePointer inputPtr = const_cast(this->GetInput(0)); + const OutputImagePointer outputPtr = this->GetOutput(0); if (!inputPtr || !outputPtr) { @@ -93,8 +93,8 @@ BinomialBlurImageFilter::GenerateData() itkDebugMacro("BinomialBlurImageFilter::GenerateData() called"); // Get the input and output pointers - InputImageConstPointer inputPtr = this->GetInput(0); - OutputImagePointer outputPtr = this->GetOutput(0); + const InputImageConstPointer inputPtr = this->GetInput(0); + const OutputImagePointer outputPtr = this->GetOutput(0); // Allocate the output outputPtr->SetBufferedRegion(outputPtr->GetRequestedRegion()); @@ -106,7 +106,7 @@ BinomialBlurImageFilter::GenerateData() using TTempImage = Image; auto tempPtr = TTempImage::New(); - typename TTempImage::RegionType tempRegion = inputPtr->GetRequestedRegion(); + const typename TTempImage::RegionType tempRegion = inputPtr->GetRequestedRegion(); tempPtr->SetRegions(tempRegion); tempPtr->Allocate(); diff --git a/Modules/Filtering/Smoothing/include/itkBoxUtilities.h b/Modules/Filtering/Smoothing/include/itkBoxUtilities.h index 19cc14f5b2d..85db578e016 100644 --- a/Modules/Filtering/Smoothing/include/itkBoxUtilities.h +++ b/Modules/Filtering/Smoothing/include/itkBoxUtilities.h @@ -64,7 +64,7 @@ setConnectivityEarlyBox(TIterator * it, bool fullyConnected = false) { // activate all neighbors that are face+edge+vertex // connected to the current pixel. do not include the center pixel - unsigned int centerIndex = it->GetCenterNeighborhoodIndex(); + const unsigned int centerIndex = it->GetCenterNeighborhoodIndex(); for (unsigned int d = 0; d < centerIndex; ++d) { offset = it->GetOffset(d); @@ -165,8 +165,8 @@ CornerOffsets(const TImage * im) { using NIterator = ShapedNeighborhoodIterator; auto unitradius = TImage::SizeType::Filled(1); - NIterator n1(unitradius, im, im->GetRequestedRegion()); - unsigned int centerIndex = n1.GetCenterNeighborhoodIndex(); + const NIterator n1(unitradius, im, im->GetRequestedRegion()); + const unsigned int centerIndex = n1.GetCenterNeighborhoodIndex(); typename NIterator::OffsetType offset; std::vector result; for (unsigned int d = 0; d < centerIndex * 2 + 1; ++d) @@ -211,7 +211,7 @@ BoxMeanCalculatorFunction(const TInputImage * accImage, using FaceListType = typename FaceCalculatorType::FaceListType; FaceCalculatorType faceCalculator; - ZeroFluxNeumannBoundaryCondition nbc; + const ZeroFluxNeumannBoundaryCondition nbc; // this process is actually slightly asymmetric because we need to // subtract rectangles that are next to our kernel, not overlapping it @@ -312,16 +312,16 @@ BoxMeanCalculatorFunction(const TInputImage * accImage, RegionType currentKernelRegion; currentKernelRegion.SetSize(kernelSize); // compute the region's index - IndexType kernelRegionIdx = oIt.GetIndex(); - IndexType centIndex = kernelRegionIdx; + IndexType kernelRegionIdx = oIt.GetIndex(); + const IndexType centIndex = kernelRegionIdx; for (unsigned int i = 0; i < TInputImage::ImageDimension; ++i) { kernelRegionIdx[i] -= radius[i]; } currentKernelRegion.SetIndex(kernelRegionIdx); currentKernelRegion.Crop(inputRegion); - OffsetValueType edgepixelscount = currentKernelRegion.GetNumberOfPixels(); - AccPixType sum = 0; + const OffsetValueType edgepixelscount = currentKernelRegion.GetNumberOfPixels(); + AccPixType sum = 0; // rules are : for each corner, // for each dimension // if dimension offset is positive -> this is @@ -385,7 +385,7 @@ BoxSigmaCalculatorFunction(const TInputImage * accImage, using FaceListType = typename FaceCalculatorType::FaceListType; FaceCalculatorType faceCalculator; - ZeroFluxNeumannBoundaryCondition nbc; + const ZeroFluxNeumannBoundaryCondition nbc; // this process is actually slightly asymmetric because we need to // subtract rectangles that are next to our kernel, not overlapping it @@ -489,17 +489,17 @@ BoxSigmaCalculatorFunction(const TInputImage * accImage, RegionType currentKernelRegion; currentKernelRegion.SetSize(kernelSize); // compute the region's index - IndexType kernelRegionIdx = oIt.GetIndex(); - IndexType centIndex = kernelRegionIdx; + IndexType kernelRegionIdx = oIt.GetIndex(); + const IndexType centIndex = kernelRegionIdx; for (unsigned int i = 0; i < TInputImage::ImageDimension; ++i) { kernelRegionIdx[i] -= radius[i]; } currentKernelRegion.SetIndex(kernelRegionIdx); currentKernelRegion.Crop(inputRegion); - SizeValueType edgepixelscount = currentKernelRegion.GetNumberOfPixels(); - AccPixType sum = 0; - AccPixType squareSum = 0; + const SizeValueType edgepixelscount = currentKernelRegion.GetNumberOfPixels(); + AccPixType sum = 0; + AccPixType squareSum = 0; // rules are : for each corner, // for each dimension // if dimension offset is positive -> this is diff --git a/Modules/Filtering/Smoothing/include/itkDiscreteGaussianImageFilter.hxx b/Modules/Filtering/Smoothing/include/itkDiscreteGaussianImageFilter.hxx index eeaad943976..6fa8bb92785 100644 --- a/Modules/Filtering/Smoothing/include/itkDiscreteGaussianImageFilter.hxx +++ b/Modules/Filtering/Smoothing/include/itkDiscreteGaussianImageFilter.hxx @@ -115,7 +115,7 @@ DiscreteGaussianImageFilter::GenerateInputRequestedRe Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); + const typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); if (!inputPtr) { @@ -215,7 +215,7 @@ DiscreteGaussianImageFilter::GenerateData() { // we reverse the direction to minimize computation while, because // the largest dimension will be split slice wise for streaming - unsigned int reverse_i = filterDimensionality - i - 1; + const unsigned int reverse_i = filterDimensionality - i - 1; this->GenerateKernel(i, oper[reverse_i]); } @@ -227,7 +227,7 @@ DiscreteGaussianImageFilter::GenerateData() if (filterDimensionality == 1) { // Use just a single filter - SingleFilterPointer singleFilter = SingleFilterType::New(); + const SingleFilterPointer singleFilter = SingleFilterType::New(); singleFilter->SetOperator(oper[0]); singleFilter->SetInput(localInput); singleFilter->OverrideBoundaryCondition(m_InputBoundaryCondition); @@ -253,7 +253,7 @@ DiscreteGaussianImageFilter::GenerateData() const unsigned int numberOfStages = filterDimensionality; // First filter convolves and changes type from input type to real type - FirstFilterPointer firstFilter = FirstFilterType::New(); + const FirstFilterPointer firstFilter = FirstFilterType::New(); firstFilter->SetOperator(oper[0]); firstFilter->ReleaseDataFlagOn(); firstFilter->SetInput(localInput); @@ -266,7 +266,7 @@ DiscreteGaussianImageFilter::GenerateData() { for (i = 1; i < filterDimensionality - 1; ++i) { - IntermediateFilterPointer f = IntermediateFilterType::New(); + const IntermediateFilterPointer f = IntermediateFilterType::New(); f->SetOperator(oper[i]); f->ReleaseDataFlagOn(); @@ -288,7 +288,7 @@ DiscreteGaussianImageFilter::GenerateData() } // Last filter convolves and changes type from real type to output type - LastFilterPointer lastFilter = LastFilterType::New(); + const LastFilterPointer lastFilter = LastFilterType::New(); lastFilter->SetOperator(oper[filterDimensionality - 1]); lastFilter->OverrideBoundaryCondition(m_RealBoundaryCondition); if (filterDimensionality > 2) diff --git a/Modules/Filtering/Smoothing/include/itkFFTDiscreteGaussianImageFilter.hxx b/Modules/Filtering/Smoothing/include/itkFFTDiscreteGaussianImageFilter.hxx index cdf6a373606..26761fe2551 100644 --- a/Modules/Filtering/Smoothing/include/itkFFTDiscreteGaussianImageFilter.hxx +++ b/Modules/Filtering/Smoothing/include/itkFFTDiscreteGaussianImageFilter.hxx @@ -39,7 +39,7 @@ FFTDiscreteGaussianImageFilter::GenerateInputRequeste ImageToImageFilter::GenerateInputRequestedRegion(); // Get pointer to input - typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); + const typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); if (inputPtr.IsNull()) { return; @@ -88,8 +88,8 @@ FFTDiscreteGaussianImageFilter::GenerateKernelImage() } // Set up kernel image - typename RealImageType::IndexType index{}; - typename RealImageType::RegionType region; + const typename RealImageType::IndexType index{}; + typename RealImageType::RegionType region; region.SetSize(kernelSize); region.SetIndex(index); m_KernelImage->SetRegions(region); @@ -140,7 +140,7 @@ FFTDiscreteGaussianImageFilter::GenerateKernelImage() KernelMeanType mean; for (size_t dim = 0; dim < ImageDimension; ++dim) { - double radius = (kernelSize[dim] - 1) / 2; + const double radius = (kernelSize[dim] - 1) / 2; mean[dim] = inputSpacing[dim] * radius + inputOrigin[dim]; // center pixel pos } kernelSource->SetMean(mean); diff --git a/Modules/Filtering/Smoothing/include/itkMeanImageFilter.hxx b/Modules/Filtering/Smoothing/include/itkMeanImageFilter.hxx index 520b32ba18e..c54367e10ff 100644 --- a/Modules/Filtering/Smoothing/include/itkMeanImageFilter.hxx +++ b/Modules/Filtering/Smoothing/include/itkMeanImageFilter.hxx @@ -40,8 +40,8 @@ void MeanImageFilter::DynamicThreadedGenerateData( const OutputImageRegionType & outputRegionForThread) { - typename OutputImageType::Pointer output = this->GetOutput(); - typename InputImageType::ConstPointer input = this->GetInput(); + const typename OutputImageType::Pointer output = this->GetOutput(); + const typename InputImageType::ConstPointer input = this->GetInput(); const auto radius = this->GetRadius(); diff --git a/Modules/Filtering/Smoothing/include/itkRecursiveGaussianImageFilter.hxx b/Modules/Filtering/Smoothing/include/itkRecursiveGaussianImageFilter.hxx index 730def2e1f4..3e07f2effa0 100644 --- a/Modules/Filtering/Smoothing/include/itkRecursiveGaussianImageFilter.hxx +++ b/Modules/Filtering/Smoothing/include/itkRecursiveGaussianImageFilter.hxx @@ -133,7 +133,7 @@ RecursiveGaussianImageFilter::SetUp(ScalarRealType sp ComputeNCoefficients( sigmad, A1[0], B1[0], W1, L1, A2[0], B2[0], W2, L2, this->m_N0, this->m_N1, this->m_N2, this->m_N3, SN, DN, EN); - ScalarRealType alpha0 = 2 * SN / SD - this->m_N0; + const ScalarRealType alpha0 = 2 * SN / SD - this->m_N0; this->m_N0 *= across_scale_normalization / alpha0; this->m_N1 *= across_scale_normalization / alpha0; this->m_N2 *= across_scale_normalization / alpha0; @@ -190,7 +190,7 @@ RecursiveGaussianImageFilter::SetUp(ScalarRealType sp ComputeNCoefficients(sigmad, A1[0], B1[0], W1, L1, A2[0], B2[0], W2, L2, N0_0, N1_0, N2_0, N3_0, SN0, DN0, EN0); ComputeNCoefficients(sigmad, A1[2], B1[2], W1, L1, A2[2], B2[2], W2, L2, N0_2, N1_2, N2_2, N3_2, SN2, DN2, EN2); - ScalarRealType beta = -(2 * SN2 - SD * N0_2) / (2 * SN0 - SD * N0_0); + const ScalarRealType beta = -(2 * SN2 - SD * N0_2) / (2 * SN0 - SD * N0_0); this->m_N0 = N0_2 + beta * N0_0; this->m_N1 = N1_2 + beta * N1_0; this->m_N2 = N2_2 + beta * N2_0; @@ -240,12 +240,12 @@ RecursiveGaussianImageFilter::ComputeNCoefficients(Sc ScalarRealType & DN, ScalarRealType & EN) { - ScalarRealType Sin1 = std::sin(W1 / sigmad); - ScalarRealType Sin2 = std::sin(W2 / sigmad); - ScalarRealType Cos1 = std::cos(W1 / sigmad); - ScalarRealType Cos2 = std::cos(W2 / sigmad); - ScalarRealType Exp1 = std::exp(L1 / sigmad); - ScalarRealType Exp2 = std::exp(L2 / sigmad); + const ScalarRealType Sin1 = std::sin(W1 / sigmad); + const ScalarRealType Sin2 = std::sin(W2 / sigmad); + const ScalarRealType Cos1 = std::cos(W1 / sigmad); + const ScalarRealType Cos2 = std::cos(W2 / sigmad); + const ScalarRealType Exp1 = std::exp(L1 / sigmad); + const ScalarRealType Exp2 = std::exp(L2 / sigmad); N0 = A1 + A2; N1 = Exp2 * (B2 * Sin2 - (A2 + 2 * A1) * Cos2); diff --git a/Modules/Filtering/Smoothing/include/itkSmoothingRecursiveGaussianImageFilter.hxx b/Modules/Filtering/Smoothing/include/itkSmoothingRecursiveGaussianImageFilter.hxx index a09344b49b9..29a493d1fba 100644 --- a/Modules/Filtering/Smoothing/include/itkSmoothingRecursiveGaussianImageFilter.hxx +++ b/Modules/Filtering/Smoothing/include/itkSmoothingRecursiveGaussianImageFilter.hxx @@ -111,7 +111,7 @@ template void SmoothingRecursiveGaussianImageFilter::SetSigma(ScalarRealType sigma) { - SigmaArrayType sigmas(sigma); + const SigmaArrayType sigmas(sigma); this->SetSigmaArray(sigmas); } @@ -175,7 +175,7 @@ SmoothingRecursiveGaussianImageFilter::GenerateInputR Superclass::GenerateInputRequestedRegion(); // This filter needs all of the input - typename SmoothingRecursiveGaussianImageFilter::InputImagePointer image = + const typename SmoothingRecursiveGaussianImageFilter::InputImagePointer image = const_cast(this->GetInput()); if (image) { diff --git a/Modules/Filtering/Smoothing/test/itkBoxMeanImageFilterTest.cxx b/Modules/Filtering/Smoothing/test/itkBoxMeanImageFilterTest.cxx index f623e456ed4..cd187b2f189 100644 --- a/Modules/Filtering/Smoothing/test/itkBoxMeanImageFilterTest.cxx +++ b/Modules/Filtering/Smoothing/test/itkBoxMeanImageFilterTest.cxx @@ -44,8 +44,8 @@ itkBoxMeanImageFilterTest(int argc, char * argv[]) // Create a filter using FilterType = itk::BoxMeanImageFilter; - auto filter = FilterType::New(); - itk::SimpleFilterWatcher filterWatch(filter); + auto filter = FilterType::New(); + const itk::SimpleFilterWatcher filterWatch(filter); using RadiusType = FilterType::RadiusType; @@ -76,7 +76,7 @@ itkBoxMeanImageFilterTest(int argc, char * argv[]) try { - int r = std::stoi(argv[3]); + const int r = std::stoi(argv[3]); filter->SetInput(input->GetOutput()); filter->SetRadius(r); filter->Update(); diff --git a/Modules/Filtering/Smoothing/test/itkBoxSigmaImageFilterTest.cxx b/Modules/Filtering/Smoothing/test/itkBoxSigmaImageFilterTest.cxx index 966a54f6fa3..2d621b8b117 100644 --- a/Modules/Filtering/Smoothing/test/itkBoxSigmaImageFilterTest.cxx +++ b/Modules/Filtering/Smoothing/test/itkBoxSigmaImageFilterTest.cxx @@ -44,8 +44,8 @@ itkBoxSigmaImageFilterTest(int argc, char * argv[]) // Create a filter using FilterType = itk::BoxSigmaImageFilter; - auto filter = FilterType::New(); - itk::SimpleFilterWatcher filterWatch(filter); + auto filter = FilterType::New(); + const itk::SimpleFilterWatcher filterWatch(filter); using RadiusType = FilterType::RadiusType; @@ -76,7 +76,7 @@ itkBoxSigmaImageFilterTest(int argc, char * argv[]) try { - int r = std::stoi(argv[3]); + const int r = std::stoi(argv[3]); filter->SetInput(input->GetOutput()); filter->SetRadius(r); filter->Update(); diff --git a/Modules/Filtering/Smoothing/test/itkDiscreteGaussianImageFilterTest.cxx b/Modules/Filtering/Smoothing/test/itkDiscreteGaussianImageFilterTest.cxx index e47ea4393ba..1b83fd6c1a7 100644 --- a/Modules/Filtering/Smoothing/test/itkDiscreteGaussianImageFilterTest.cxx +++ b/Modules/Filtering/Smoothing/test/itkDiscreteGaussianImageFilterTest.cxx @@ -50,7 +50,7 @@ itkDiscreteGaussianImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, DiscreteGaussianImageFilter, ImageToImageFilter); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); // Test other set/get functions ArrayType array; @@ -63,8 +63,8 @@ itkDiscreteGaussianImageFilterTest(int argc, char * argv[]) filter->SetMaximumError(array.GetDataPointer()); // Set the value of the standard deviation of the Gaussian used for smoothing - FilterType::SigmaArrayType::ValueType sigmaValue = 1.0; - auto sigma = itk::MakeFilled(sigmaValue); + const FilterType::SigmaArrayType::ValueType sigmaValue = 1.0; + auto sigma = itk::MakeFilled(sigmaValue); filter->SetSigma(sigmaValue); ITK_TEST_SET_GET_VALUE(sigmaValue, filter->GetSigma()); @@ -84,17 +84,17 @@ itkDiscreteGaussianImageFilterTest(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(&constantBoundaryCondition, filter->GetRealBoundaryCondition()); // Set other filter properties - FilterType::ArrayType::ValueType varianceValue = 1.0; - auto variance = itk::MakeFilled(varianceValue); + const FilterType::ArrayType::ValueType varianceValue = 1.0; + auto variance = itk::MakeFilled(varianceValue); filter->SetVariance(variance); ITK_TEST_SET_GET_VALUE(variance, filter->GetVariance()); - FilterType::ArrayType::ValueType maximumErrorValue = 0.01; - auto maximumError = itk::MakeFilled(maximumErrorValue); + const FilterType::ArrayType::ValueType maximumErrorValue = 0.01; + auto maximumError = itk::MakeFilled(maximumErrorValue); filter->SetMaximumError(maximumError); ITK_TEST_SET_GET_VALUE(maximumError, filter->GetMaximumError()); - unsigned int maximumKernelWidth = 32; + const unsigned int maximumKernelWidth = 32; filter->SetMaximumKernelWidth(maximumKernelWidth); ITK_TEST_SET_GET_VALUE(maximumKernelWidth, filter->GetMaximumKernelWidth()); diff --git a/Modules/Filtering/Smoothing/test/itkDiscreteGaussianImageFilterTest2.cxx b/Modules/Filtering/Smoothing/test/itkDiscreteGaussianImageFilterTest2.cxx index a3088f13cfd..eb6830e8a21 100644 --- a/Modules/Filtering/Smoothing/test/itkDiscreteGaussianImageFilterTest2.cxx +++ b/Modules/Filtering/Smoothing/test/itkDiscreteGaussianImageFilterTest2.cxx @@ -72,24 +72,24 @@ itkDiscreteGaussianImageFilterTest2(int argc, char * argv[]) return EXIT_FAILURE; } - unsigned int img_dim = std::stoi(argv[1]); + const unsigned int img_dim = std::stoi(argv[1]); if (img_dim < 2 || img_dim > 3) { std::cerr << "This test only supports 2D or 3D images for demo! exiting ..." << std::endl; return EXIT_FAILURE; } - unsigned int vec_dim = std::stoi(argv[2]); + const unsigned int vec_dim = std::stoi(argv[2]); if (vec_dim != 1 && vec_dim != 3) { std::cerr << "This test only supports 3-channel image or 1-channel image for demo! Exiting ... " << std::endl; return EXIT_FAILURE; } - float sigma = (argc > 5) ? std::stof(argv[5]) : 0.0; - float kernelError = (argc > 6) ? std::stof(argv[6]) : 0.01; - unsigned int kernelWidth = (argc > 7) ? static_cast(std::stoi(argv[7])) : 32; - unsigned int filterDimensionality = (argc > 8) ? static_cast(std::stoi(argv[8])) : img_dim; + const float sigma = (argc > 5) ? std::stof(argv[5]) : 0.0; + const float kernelError = (argc > 6) ? std::stof(argv[6]) : 0.01; + const unsigned int kernelWidth = (argc > 7) ? static_cast(std::stoi(argv[7])) : 32; + const unsigned int filterDimensionality = (argc > 8) ? static_cast(std::stoi(argv[8])) : img_dim; using ScalarPixelType = float; using VectorPixelType = itk::Vector; diff --git a/Modules/Filtering/Smoothing/test/itkFFTDiscreteGaussianImageFilterFactoryTest.cxx b/Modules/Filtering/Smoothing/test/itkFFTDiscreteGaussianImageFilterFactoryTest.cxx index 5f7bfc37139..0f3f1a0247e 100644 --- a/Modules/Filtering/Smoothing/test/itkFFTDiscreteGaussianImageFilterFactoryTest.cxx +++ b/Modules/Filtering/Smoothing/test/itkFFTDiscreteGaussianImageFilterFactoryTest.cxx @@ -45,7 +45,7 @@ itkFFTDiscreteGaussianImageFilterFactoryTest(int, char *[]) // Register factory and verify instantiation override using FactoryType = itk::FFTDiscreteGaussianImageFilterFactory; - FactoryType::Pointer overrideFactory = FactoryType::New(); + const FactoryType::Pointer overrideFactory = FactoryType::New(); itk::ObjectFactoryBase::RegisterFactory(overrideFactory); ITK_TRY_EXPECT_NO_EXCEPTION(baseFilter = BaseFilterType::New()); diff --git a/Modules/Filtering/Smoothing/test/itkFFTDiscreteGaussianImageFilterTest.cxx b/Modules/Filtering/Smoothing/test/itkFFTDiscreteGaussianImageFilterTest.cxx index d7ef4fee2cf..6fd760cd952 100644 --- a/Modules/Filtering/Smoothing/test/itkFFTDiscreteGaussianImageFilterTest.cxx +++ b/Modules/Filtering/Smoothing/test/itkFFTDiscreteGaussianImageFilterTest.cxx @@ -28,13 +28,13 @@ template int itkFFTDiscreteGaussianImageFilterTestProcedure(int argc, char ** argv) { - float sigma = (argc > 4) ? std::stof(argv[4]) : 0.0; - float kernelError = (argc > 5) ? std::stof(argv[5]) : 0.01; - unsigned int kernelWidth = (argc > 6) ? std::stoi(argv[6]) : 32; - unsigned int filterDimensionality = (argc > 7) ? std::stoi(argv[7]) : ImageType::ImageDimension; - unsigned int kernelSource = (argc > 8) ? std::stoi(argv[8]) : 0; + const float sigma = (argc > 4) ? std::stof(argv[4]) : 0.0; + const float kernelError = (argc > 5) ? std::stof(argv[5]) : 0.01; + const unsigned int kernelWidth = (argc > 6) ? std::stoi(argv[6]) : 32; + const unsigned int filterDimensionality = (argc > 7) ? std::stoi(argv[7]) : ImageType::ImageDimension; + const unsigned int kernelSource = (argc > 8) ? std::stoi(argv[8]) : 0; - typename ImageType::Pointer inputImage = itk::ReadImage(argv[2]); + const typename ImageType::Pointer inputImage = itk::ReadImage(argv[2]); using FilterType = itk::FFTDiscreteGaussianImageFilter; auto filter = FilterType::New(); @@ -51,7 +51,7 @@ itkFFTDiscreteGaussianImageFilterTestProcedure(int argc, char ** argv) } for (auto & param : filter->GetVariance()) { - double tolerance = 1e-6; + const double tolerance = 1e-6; ITK_TEST_EXPECT_TRUE(std::fabs((sigma * sigma) - param) < tolerance); } diff --git a/Modules/Filtering/Smoothing/test/itkMeanImageFilterGTest.cxx b/Modules/Filtering/Smoothing/test/itkMeanImageFilterGTest.cxx index 58b231aa9f5..a0de03cc6ef 100644 --- a/Modules/Filtering/Smoothing/test/itkMeanImageFilterGTest.cxx +++ b/Modules/Filtering/Smoothing/test/itkMeanImageFilterGTest.cxx @@ -105,8 +105,8 @@ TEST(MeanImageFilter, OutputSameAsInputForUniformImage) Expect_output_pixels_have_same_value_as_input_when_input_image_is_uniform>( itk::Size<3>{ { 3, 4, 5 } }, 0.5f); - float array[] = { 3.14f, 2.71f, 1.41f }; - itk::VariableLengthVector v{ array, 3 }; + float array[] = { 3.14f, 2.71f, 1.41f }; + const itk::VariableLengthVector v{ array, 3 }; Expect_output_pixels_have_same_value_as_input_when_input_image_is_uniform>( itk::Size<3>{ { 3, 4, 5 } }, v); } diff --git a/Modules/Filtering/Smoothing/test/itkMeanImageFilterTest.cxx b/Modules/Filtering/Smoothing/test/itkMeanImageFilterTest.cxx index a6bce1d1081..df81047b798 100644 --- a/Modules/Filtering/Smoothing/test/itkMeanImageFilterTest.cxx +++ b/Modules/Filtering/Smoothing/test/itkMeanImageFilterTest.cxx @@ -52,7 +52,7 @@ itkMeanImageFilterTest(int, char *[]) random->SetOrigin(origin); // Create a mean image - itk::MeanImageFilter::Pointer mean = + const itk::MeanImageFilter::Pointer mean = itk::MeanImageFilter::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(mean, MeanImageFilter, BoxImageFilter); diff --git a/Modules/Filtering/Smoothing/test/itkMedianImageFilterTest.cxx b/Modules/Filtering/Smoothing/test/itkMedianImageFilterTest.cxx index ed7398d9a76..6fc002f411c 100644 --- a/Modules/Filtering/Smoothing/test/itkMedianImageFilterTest.cxx +++ b/Modules/Filtering/Smoothing/test/itkMedianImageFilterTest.cxx @@ -56,7 +56,7 @@ itkMedianImageFilterTest(int, char *[]) neighRadius[1] = 5; median->SetRadius(neighRadius); - itk::SimpleFilterWatcher watcher(median, "To watch progress updates"); + const itk::SimpleFilterWatcher watcher(median, "To watch progress updates"); // run the algorithm median->Update(); diff --git a/Modules/Filtering/Smoothing/test/itkRecursiveGaussianImageFilterOnTensorsTest.cxx b/Modules/Filtering/Smoothing/test/itkRecursiveGaussianImageFilterOnTensorsTest.cxx index 19da5c7d11b..6827dfd1d44 100644 --- a/Modules/Filtering/Smoothing/test/itkRecursiveGaussianImageFilterOnTensorsTest.cxx +++ b/Modules/Filtering/Smoothing/test/itkRecursiveGaussianImageFilterOnTensorsTest.cxx @@ -32,8 +32,8 @@ itkRecursiveGaussianImageFilterOnTensorsTest(int, char *[]) // Create ON and OFF tensors. using Double3DTensorType = itk::SymmetricSecondRankTensor; - Double3DTensorType tensor0(0.0); - Double3DTensorType tensor1; + const Double3DTensorType tensor0(0.0); + Double3DTensorType tensor1; tensor1(0, 0) = 1.0; tensor1(0, 1) = 0.0; tensor1(0, 2) = 0.0; @@ -49,10 +49,10 @@ itkRecursiveGaussianImageFilterOnTensorsTest(int, char *[]) using ConstIteratorType = itk::ImageLinearConstIteratorWithIndex; // Create the 9x9 input image - auto size = ImageType::SizeType::Filled(9); - ImageType::IndexType index{}; - ImageType::RegionType region{ index, size }; - auto inputImage = ImageType::New(); + auto size = ImageType::SizeType::Filled(9); + ImageType::IndexType index{}; + const ImageType::RegionType region{ index, size }; + auto inputImage = ImageType::New(); inputImage->SetRegions(region); inputImage->Allocate(); inputImage->FillBuffer(tensor0); @@ -92,8 +92,8 @@ itkRecursiveGaussianImageFilterOnTensorsTest(int, char *[]) // Test a few pixels of the fitlered image // - ImageType::Pointer filteredImage = filterY->GetOutput(); - ConstIteratorType cit(filteredImage, filteredImage->GetRequestedRegion()); + const ImageType::Pointer filteredImage = filterY->GetOutput(); + ConstIteratorType cit(filteredImage, filteredImage->GetRequestedRegion()); cit.SetDirection(0); /* Print out all Tensor values. diff --git a/Modules/Filtering/Smoothing/test/itkRecursiveGaussianImageFilterOnVectorImageTest.cxx b/Modules/Filtering/Smoothing/test/itkRecursiveGaussianImageFilterOnVectorImageTest.cxx index f8346f6128c..1fbea297c93 100644 --- a/Modules/Filtering/Smoothing/test/itkRecursiveGaussianImageFilterOnVectorImageTest.cxx +++ b/Modules/Filtering/Smoothing/test/itkRecursiveGaussianImageFilterOnVectorImageTest.cxx @@ -47,10 +47,10 @@ itkRecursiveGaussianImageFilterOnVectorImageTest(int, char *[]) vector1.Fill(1.0); // Create the 9x9 input image - auto size = ImageType::SizeType::Filled(9); - ImageType::IndexType index{}; - ImageType::RegionType region{ index, size }; - auto inputImage = ImageType::New(); + auto size = ImageType::SizeType::Filled(9); + ImageType::IndexType index{}; + const ImageType::RegionType region{ index, size }; + auto inputImage = ImageType::New(); inputImage->SetRegions(region); inputImage->SetNumberOfComponentsPerPixel(NumberOfComponents); inputImage->Allocate(); @@ -91,8 +91,8 @@ itkRecursiveGaussianImageFilterOnVectorImageTest(int, char *[]) // Test a few pixels of the fitlered image // - ImageType::Pointer filteredImage = filterY->GetOutput(); - ConstIteratorType cit(filteredImage, filteredImage->GetRequestedRegion()); + const ImageType::Pointer filteredImage = filterY->GetOutput(); + ConstIteratorType cit(filteredImage, filteredImage->GetRequestedRegion()); cit.SetDirection(0); index[0] = 4; diff --git a/Modules/Filtering/Smoothing/test/itkRecursiveGaussianImageFilterTest.cxx b/Modules/Filtering/Smoothing/test/itkRecursiveGaussianImageFilterTest.cxx index c15ee9a9061..a9841c75d9a 100644 --- a/Modules/Filtering/Smoothing/test/itkRecursiveGaussianImageFilterTest.cxx +++ b/Modules/Filtering/Smoothing/test/itkRecursiveGaussianImageFilterTest.cxx @@ -110,7 +110,7 @@ itkRecursiveGaussianImageFilterTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, RecursiveGaussianImageFilter, RecursiveSeparableImageFilter); - unsigned int direction = 2; // apply along Z + const unsigned int direction = 2; // apply along Z filter->SetDirection(direction); ITK_TEST_SET_GET_VALUE(direction, filter->GetDirection()); @@ -285,11 +285,11 @@ itkRecursiveGaussianImageFilterTest(int, char *[]) // sort from smallest to largest for best numerical precision std::sort(values.begin(), values.end()); - double total = std::accumulate(values.begin(), values.end(), 0.0); + const double total = std::accumulate(values.begin(), values.end(), 0.0); // 1000.0 is the value of the impulse // compute absolute normalized error - double error = itk::Math::abs(total - 1000.0) / 1000.0; + const double error = itk::Math::abs(total - 1000.0) / 1000.0; if (error > 1e-3) { std::cout << "FAILED !" << std::endl; @@ -412,7 +412,7 @@ itkRecursiveGaussianImageFilterTest(int, char *[]) filter->SetNormalizeAcrossScale(false); filter->SetSigma(2.0); - ImageType::ConstPointer outputImage = filter->GetOutput(); + const ImageType::ConstPointer outputImage = filter->GetOutput(); using IteratorType = itk::ImageRegionConstIterator; IteratorType it(outputImage, outputImage->GetBufferedRegion()); @@ -509,7 +509,7 @@ itkRecursiveGaussianImageFilterTest(int, char *[]) filter->InPlaceOn(); filter->Update(); - ImageType::ConstPointer outputImage = filter->GetOutput(); + const ImageType::ConstPointer outputImage = filter->GetOutput(); using IteratorType = itk::ImageRegionConstIterator; IteratorType it(outputImage, outputImage->GetBufferedRegion()); diff --git a/Modules/Filtering/Smoothing/test/itkRecursiveGaussianScaleSpaceTest1.cxx b/Modules/Filtering/Smoothing/test/itkRecursiveGaussianScaleSpaceTest1.cxx index 87512aeeb5d..60a27d366d7 100644 --- a/Modules/Filtering/Smoothing/test/itkRecursiveGaussianScaleSpaceTest1.cxx +++ b/Modules/Filtering/Smoothing/test/itkRecursiveGaussianScaleSpaceTest1.cxx @@ -34,13 +34,13 @@ NormalizeSineWave(double frequencyPerImage, unsigned int order, double pixelSpac constexpr unsigned int imageSize = 1024; const double tol = std::pow(.000001, 1.0 / order); - double frequency = frequencyPerImage * 2.0 * itk::Math::pi / (imageSize * pixelSpacing); + const double frequency = frequencyPerImage * 2.0 * itk::Math::pi / (imageSize * pixelSpacing); // The theoretical maximal value should occur at this sigma - double sigma_max = std::sqrt(static_cast(order)) / frequency; + const double sigma_max = std::sqrt(static_cast(order)) / frequency; // the theoreical maximal value of the derivative, obtained at sigma_max - double expected_max = std::pow(static_cast(order), order * 0.5) * std::exp(-0.5 * order); + const double expected_max = std::pow(static_cast(order), order * 0.5) * std::exp(-0.5 * order); using ImageType = itk::Image; auto image = ImageType::New(); @@ -62,7 +62,7 @@ NormalizeSineWave(double frequencyPerImage, unsigned int order, double pixelSpac ImageType::PointType p; image->TransformIndexToPhysicalPoint(iter.GetIndex(), p); const double x = p[0]; - double value = std::sin(x * frequency); + const double value = std::sin(x * frequency); iter.Set(value); ++iter; @@ -93,7 +93,7 @@ NormalizeSineWave(double frequencyPerImage, unsigned int order, double pixelSpac // All .Get() methods should be multiplied by this const double scaleFactor = std::pow(1.0 / pixelSpacing, static_cast(order)); - ImageType::Pointer outputImage = filter->GetOutput(); + const ImageType::Pointer outputImage = filter->GetOutput(); outputImage->Update(); // maximal value of the first derivative diff --git a/Modules/Filtering/Smoothing/test/itkSmoothingRecursiveGaussianImageFilterOnImageAdaptorTest.cxx b/Modules/Filtering/Smoothing/test/itkSmoothingRecursiveGaussianImageFilterOnImageAdaptorTest.cxx index ef0a838a8c7..87b661bc0be 100644 --- a/Modules/Filtering/Smoothing/test/itkSmoothingRecursiveGaussianImageFilterOnImageAdaptorTest.cxx +++ b/Modules/Filtering/Smoothing/test/itkSmoothingRecursiveGaussianImageFilterOnImageAdaptorTest.cxx @@ -115,8 +115,8 @@ itkSmoothingRecursiveGaussianImageFilterOnImageAdaptorTest(int, char *[]) // Create a Filter - auto filter = myFilterType::New(); - itk::SimpleFilterWatcher watchit(filter); + auto filter = myFilterType::New(); + const itk::SimpleFilterWatcher watchit(filter); // Connect the input images filter->SetInput(adaptor); @@ -141,7 +141,7 @@ itkSmoothingRecursiveGaussianImageFilterOnImageAdaptorTest(int, char *[]) // It is important to do it AFTER the filter is Updated // Because the object connected to the output may be changed // by another during GenerateData() call - myGradientImageType::Pointer outputImage = filter->GetOutput(); + const myGradientImageType::Pointer outputImage = filter->GetOutput(); // Declare Iterator type for the output image using myOutputIteratorType = itk::ImageRegionIteratorWithIndex; diff --git a/Modules/Filtering/Smoothing/test/itkSmoothingRecursiveGaussianImageFilterOnImageOfVectorTest.cxx b/Modules/Filtering/Smoothing/test/itkSmoothingRecursiveGaussianImageFilterOnImageOfVectorTest.cxx index 0ff56cdbd02..c2b59338cd2 100644 --- a/Modules/Filtering/Smoothing/test/itkSmoothingRecursiveGaussianImageFilterOnImageOfVectorTest.cxx +++ b/Modules/Filtering/Smoothing/test/itkSmoothingRecursiveGaussianImageFilterOnImageOfVectorTest.cxx @@ -106,8 +106,8 @@ itkSmoothingRecursiveGaussianImageFilterOnImageOfVectorTest(int, char *[]) // Create a Filter - auto filter = myFilterType::New(); - itk::SimpleFilterWatcher watchit(filter); + auto filter = myFilterType::New(); + const itk::SimpleFilterWatcher watchit(filter); // Connect the input images filter->SetInput(inputImage); @@ -132,7 +132,7 @@ itkSmoothingRecursiveGaussianImageFilterOnImageOfVectorTest(int, char *[]) // It is important to do it AFTER the filter is Updated // Because the object connected to the output may be changed // by another during GenerateData() call - myGradientImageType::Pointer outputImage = filter->GetOutput(); + const myGradientImageType::Pointer outputImage = filter->GetOutput(); // Declare Iterator type for the output image using myOutputIteratorType = itk::ImageRegionIteratorWithIndex; diff --git a/Modules/Filtering/Smoothing/test/itkSmoothingRecursiveGaussianImageFilterOnVectorImageTest.cxx b/Modules/Filtering/Smoothing/test/itkSmoothingRecursiveGaussianImageFilterOnVectorImageTest.cxx index a1c13762898..4d651383dbd 100644 --- a/Modules/Filtering/Smoothing/test/itkSmoothingRecursiveGaussianImageFilterOnVectorImageTest.cxx +++ b/Modules/Filtering/Smoothing/test/itkSmoothingRecursiveGaussianImageFilterOnVectorImageTest.cxx @@ -104,8 +104,8 @@ itkSmoothingRecursiveGaussianImageFilterOnVectorImageTest(int, char *[]) // Create a Filter - auto filter = myFilterType::New(); - itk::SimpleFilterWatcher watchit(filter); + auto filter = myFilterType::New(); + const itk::SimpleFilterWatcher watchit(filter); // Connect the input images filter->SetInput(inputImage); @@ -130,7 +130,7 @@ itkSmoothingRecursiveGaussianImageFilterOnVectorImageTest(int, char *[]) // It is important to do it AFTER the filter is Updated // Because the object connected to the output may be changed // by another during GenerateData() call - myGradientImageType::Pointer outputImage = filter->GetOutput(); + const myGradientImageType::Pointer outputImage = filter->GetOutput(); // Declare Iterator type for the output image using myOutputIteratorType = itk::ImageRegionIteratorWithIndex; diff --git a/Modules/Filtering/Smoothing/test/itkSmoothingRecursiveGaussianImageFilterTest.cxx b/Modules/Filtering/Smoothing/test/itkSmoothingRecursiveGaussianImageFilterTest.cxx index 4269f10eeef..05ef2e0341e 100644 --- a/Modules/Filtering/Smoothing/test/itkSmoothingRecursiveGaussianImageFilterTest.cxx +++ b/Modules/Filtering/Smoothing/test/itkSmoothingRecursiveGaussianImageFilterTest.cxx @@ -55,7 +55,7 @@ InPlaceTest(char * inputFilename, bool normalizeAcrossScale, typename TFilter::S ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); - typename TFilter::OutputImageType::Pointer outputImage1 = filter->GetOutput(); + const typename TFilter::OutputImageType::Pointer outputImage1 = filter->GetOutput(); outputImage1->DisconnectPipeline(); @@ -63,7 +63,7 @@ InPlaceTest(char * inputFilename, bool normalizeAcrossScale, typename TFilter::S filter->InPlaceOn(); ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); - typename TFilter::OutputImageType::Pointer outputImage2 = filter->GetOutput(); + const typename TFilter::OutputImageType::Pointer outputImage2 = filter->GetOutput(); outputImage2->DisconnectPipeline(); using IteratorType = itk::ImageRegionConstIterator; @@ -73,7 +73,7 @@ InPlaceTest(char * inputFilename, bool normalizeAcrossScale, typename TFilter::S // Check whether the values of the in-place and not in-place executions are the same it1.GoToBegin(); it2.GoToBegin(); - double epsilon = itk::NumericTraits::epsilon(); + const double epsilon = itk::NumericTraits::epsilon(); while (!it1.IsAtEnd()) { if (!itk::Math::FloatAlmostEqual(static_cast(it1.Get()), static_cast(it2.Get()), 10, epsilon)) @@ -131,15 +131,15 @@ itkSmoothingRecursiveGaussianImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, SmoothingRecursiveGaussianImageFilter, InPlaceImageFilter); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); // Set the scale normalization flag - bool normalizeAcrossScale = std::stoi(argv[3]); + const bool normalizeAcrossScale = std::stoi(argv[3]); ITK_TEST_SET_GET_BOOLEAN(filter, NormalizeAcrossScale, normalizeAcrossScale); // Set the value of the standard deviation of the Gaussian used for smoothing - SmoothingRecursiveGaussianImageFilterType::SigmaArrayType::ValueType sigmaValue = std::stod(argv[4]); + const SmoothingRecursiveGaussianImageFilterType::SigmaArrayType::ValueType sigmaValue = std::stod(argv[4]); auto sigma = itk::MakeFilled(sigmaValue); filter->SetSigma(sigmaValue); diff --git a/Modules/Filtering/SpatialFunction/include/itkSpatialFunctionImageEvaluatorFilter.hxx b/Modules/Filtering/SpatialFunction/include/itkSpatialFunctionImageEvaluatorFilter.hxx index 28859af9398..f91702c3eac 100644 --- a/Modules/Filtering/SpatialFunction/include/itkSpatialFunctionImageEvaluatorFilter.hxx +++ b/Modules/Filtering/SpatialFunction/include/itkSpatialFunctionImageEvaluatorFilter.hxx @@ -38,7 +38,7 @@ SpatialFunctionImageEvaluatorFilter itkDebugMacro("SpatialFunctionImageEvaluatorFilter::GenerateData() called"); // Allocate the output image - typename TOutputImage::Pointer outputPtr = this->GetOutput(); + const typename TOutputImage::Pointer outputPtr = this->GetOutput(); outputPtr->SetBufferedRegion(outputPtr->GetRequestedRegion()); outputPtr->Allocate(); @@ -58,7 +58,7 @@ SpatialFunctionImageEvaluatorFilter // Walk the output image, evaluating the spatial function at each pixel for (; !outIt.IsAtEnd(); ++outIt) { - typename TOutputImage::IndexType index = outIt.GetIndex(); + const typename TOutputImage::IndexType index = outIt.GetIndex(); outputPtr->TransformIndexToPhysicalPoint(index, evalPoint); value = m_PixelFunction->Evaluate(evalPoint); diff --git a/Modules/Filtering/SpatialFunction/test/itkSpatialFunctionImageEvaluatorFilterTest.cxx b/Modules/Filtering/SpatialFunction/test/itkSpatialFunctionImageEvaluatorFilterTest.cxx index 82975e9c424..b76d71413ba 100644 --- a/Modules/Filtering/SpatialFunction/test/itkSpatialFunctionImageEvaluatorFilterTest.cxx +++ b/Modules/Filtering/SpatialFunction/test/itkSpatialFunctionImageEvaluatorFilterTest.cxx @@ -66,7 +66,7 @@ itkSpatialFunctionImageEvaluatorFilterTest(int, char *[]) filter->SetInput(sourceImage); filter->SetFunction(func); - ImageType::Pointer outputImage = filter->GetOutput(); + const ImageType::Pointer outputImage = filter->GetOutput(); filter->Update(); diff --git a/Modules/Filtering/Thresholding/include/itkBinaryThresholdImageFilter.hxx b/Modules/Filtering/Thresholding/include/itkBinaryThresholdImageFilter.hxx index a4e65e027b4..14aea8f99a5 100644 --- a/Modules/Filtering/Thresholding/include/itkBinaryThresholdImageFilter.hxx +++ b/Modules/Filtering/Thresholding/include/itkBinaryThresholdImageFilter.hxx @@ -88,7 +88,7 @@ template auto BinaryThresholdImageFilter::GetLowerThreshold() const -> InputPixelType { - typename InputPixelObjectType::Pointer lower = const_cast(this)->GetLowerThresholdInput(); + const typename InputPixelObjectType::Pointer lower = const_cast(this)->GetLowerThresholdInput(); return lower->Get(); } @@ -167,7 +167,7 @@ template auto BinaryThresholdImageFilter::GetUpperThreshold() const -> InputPixelType { - typename InputPixelObjectType::Pointer upper = const_cast(this)->GetUpperThresholdInput(); + const typename InputPixelObjectType::Pointer upper = const_cast(this)->GetUpperThresholdInput(); return upper->Get(); } @@ -213,8 +213,8 @@ void BinaryThresholdImageFilter::BeforeThreadedGenerateData() { // Set up the functor values - typename InputPixelObjectType::Pointer lowerThreshold = this->GetLowerThresholdInput(); - typename InputPixelObjectType::Pointer upperThreshold = this->GetUpperThresholdInput(); + const typename InputPixelObjectType::Pointer lowerThreshold = this->GetLowerThresholdInput(); + const typename InputPixelObjectType::Pointer upperThreshold = this->GetUpperThresholdInput(); if (lowerThreshold->Get() > upperThreshold->Get()) { diff --git a/Modules/Filtering/Thresholding/include/itkHistogramThresholdImageFilter.hxx b/Modules/Filtering/Thresholding/include/itkHistogramThresholdImageFilter.hxx index 41eb9343306..bf489895d41 100644 --- a/Modules/Filtering/Thresholding/include/itkHistogramThresholdImageFilter.hxx +++ b/Modules/Filtering/Thresholding/include/itkHistogramThresholdImageFilter.hxx @@ -73,7 +73,7 @@ HistogramThresholdImageFilter::GenerateDa auto progress = ProgressAccumulator::New(); progress->SetMiniPipelineFilter(this); - HistogramGeneratorPointer histogramGenerator = HistogramGeneratorType::New(); + const HistogramGeneratorPointer histogramGenerator = HistogramGeneratorType::New(); using MaskedHistogramGeneratorType = Statistics::MaskedImageToHistogramFilter; auto maskedHistogramGenerator = MaskedHistogramGeneratorType::New(); diff --git a/Modules/Filtering/Thresholding/include/itkHuangThresholdCalculator.hxx b/Modules/Filtering/Thresholding/include/itkHuangThresholdCalculator.hxx index 4f78c522223..20b266e7d72 100644 --- a/Modules/Filtering/Thresholding/include/itkHuangThresholdCalculator.hxx +++ b/Modules/Filtering/Thresholding/include/itkHuangThresholdCalculator.hxx @@ -31,13 +31,13 @@ HuangThresholdCalculator::GenerateData() { const HistogramType * histogram = this->GetInput(); - TotalAbsoluteFrequencyType total = histogram->GetTotalFrequency(); + const TotalAbsoluteFrequencyType total = histogram->GetTotalFrequency(); if (total == TotalAbsoluteFrequencyType{}) { itkExceptionMacro("Histogram is empty"); } m_Size = histogram->GetSize(0); - ProgressReporter progress(this, 0, m_Size); + const ProgressReporter progress(this, 0, m_Size); if (m_Size == 1) { this->GetOutput()->Set(static_cast(histogram->GetMeasurement(0, 0))); @@ -79,7 +79,7 @@ HuangThresholdCalculator::GenerateData() for (size_t i = 1; i < Smu.size(); ++i) { - double mu = 1. / (1. + static_cast(i) / C); + const double mu = 1. / (1. + static_cast(i) / C); Smu[i] = -mu * std::log(mu) - (1. - mu) * std::log(1. - mu); } @@ -124,7 +124,7 @@ HuangThresholdCalculator::GenerateData() mu = Math::Round((W[m_LastBin] - W[threshold]) / (S[m_LastBin] - S[threshold])); v[0] = mu; - bool status = histogram->GetIndex(v, muFullIdx); + const bool status = histogram->GetIndex(v, muFullIdx); if (!status) { itkExceptionMacro("Failed looking up histogram"); diff --git a/Modules/Filtering/Thresholding/include/itkIntermodesThresholdCalculator.hxx b/Modules/Filtering/Thresholding/include/itkIntermodesThresholdCalculator.hxx index a015020dc81..079d6df0fdf 100644 --- a/Modules/Filtering/Thresholding/include/itkIntermodesThresholdCalculator.hxx +++ b/Modules/Filtering/Thresholding/include/itkIntermodesThresholdCalculator.hxx @@ -55,7 +55,7 @@ IntermodesThresholdCalculator::GenerateData() { itkExceptionMacro("Histogram is empty"); } - SizeValueType size = histogram->GetSize(0); + const SizeValueType size = histogram->GetSize(0); ProgressReporter progress(this, 0, size); if (size == 1) diff --git a/Modules/Filtering/Thresholding/include/itkIsoDataThresholdCalculator.hxx b/Modules/Filtering/Thresholding/include/itkIsoDataThresholdCalculator.hxx index 0e968ffae4f..926630c0c6e 100644 --- a/Modules/Filtering/Thresholding/include/itkIsoDataThresholdCalculator.hxx +++ b/Modules/Filtering/Thresholding/include/itkIsoDataThresholdCalculator.hxx @@ -35,8 +35,8 @@ IsoDataThresholdCalculator::GenerateData() { itkExceptionMacro("Histogram is empty"); } - SizeValueType size = histogram->GetSize(0); - ProgressReporter progress(this, 0, size); + const SizeValueType size = histogram->GetSize(0); + ProgressReporter progress(this, 0, size); if (size == 1) { this->GetOutput()->Set(static_cast(histogram->GetMeasurement(0, 0))); diff --git a/Modules/Filtering/Thresholding/include/itkKittlerIllingworthThresholdCalculator.hxx b/Modules/Filtering/Thresholding/include/itkKittlerIllingworthThresholdCalculator.hxx index 8d38c2cad16..1ac89544b1a 100644 --- a/Modules/Filtering/Thresholding/include/itkKittlerIllingworthThresholdCalculator.hxx +++ b/Modules/Filtering/Thresholding/include/itkKittlerIllingworthThresholdCalculator.hxx @@ -37,14 +37,14 @@ KittlerIllingworthThresholdCalculator::Mean() { sum += static_cast(data->GetMeasurement(i, 0) * data->GetFrequency(i, 0)); } - double mean = sum / tot; + const double mean = sum / tot; // search the bin corresponding to the mean value typename HistogramType::MeasurementVectorType v(1); v[0] = mean; typename HistogramType::IndexType idx; - bool status = data->GetIndex(v, idx); + const bool status = data->GetIndex(v, idx); itkAssertInDebugAndIgnoreInReleaseMacro(status); if (!status) { @@ -104,8 +104,8 @@ KittlerIllingworthThresholdCalculator::GenerateData() { itkExceptionMacro("Histogram is empty"); } - SizeValueType size = histogram->GetSize(0); - ProgressReporter progress(this, 0, size); + const SizeValueType size = histogram->GetSize(0); + const ProgressReporter progress(this, 0, size); if (size == 1) { this->GetOutput()->Set(static_cast(histogram->GetMeasurement(0, 0))); @@ -115,9 +115,9 @@ KittlerIllingworthThresholdCalculator::GenerateData() IndexValueType threshold = Mean(); // threshold is a histogram index IndexValueType Tprev = -2; - double As1 = A(size - 1); - double Bs1 = B(size - 1); - double Cs1 = C(size - 1); + const double As1 = A(size - 1); + const double Bs1 = B(size - 1); + const double Cs1 = C(size - 1); if (itk::Math::abs(As1) < itk::Math::eps) { @@ -127,15 +127,15 @@ KittlerIllingworthThresholdCalculator::GenerateData() while (threshold != Tprev) { // Calculate some statistics. - double At = A(threshold); - double Bt = B(threshold); - double Ct = C(threshold); + const double At = A(threshold); + const double Bt = B(threshold); + const double Ct = C(threshold); if (itk::Math::abs(At) < itk::Math::eps) { itkGenericExceptionMacro("At = 0."); } - double mu = Bt / At; + const double mu = Bt / At; if (itk::Math::abs(As1 - At) < itk::Math::eps) { @@ -143,12 +143,12 @@ KittlerIllingworthThresholdCalculator::GenerateData() break; } - double nu = (Bs1 - Bt) / (As1 - At); + const double nu = (Bs1 - Bt) / (As1 - At); - double p = At / As1; - double q = (As1 - At) / As1; - double sigma2 = Ct / At - (mu * mu); - double tau2 = (Cs1 - Ct) / (As1 - At) - (nu * nu); + const double p = At / As1; + const double q = (As1 - At) / As1; + const double sigma2 = Ct / At - (mu * mu); + const double tau2 = (Cs1 - Ct) / (As1 - At) - (nu * nu); if (sigma2 < itk::Math::eps) { @@ -166,12 +166,12 @@ KittlerIllingworthThresholdCalculator::GenerateData() } // The terms of the quadratic equation to be solved. - double w0 = 1.0 / sigma2 - 1.0 / tau2; - double w1 = mu / sigma2 - nu / tau2; - double w2 = (mu * mu) / sigma2 - (nu * nu) / tau2 + std::log10((sigma2 * (q * q)) / (tau2 * p * p)); + const double w0 = 1.0 / sigma2 - 1.0 / tau2; + const double w1 = mu / sigma2 - nu / tau2; + const double w2 = (mu * mu) / sigma2 - (nu * nu) / tau2 + std::log10((sigma2 * (q * q)) / (tau2 * p * p)); // If the next threshold would be imaginary, return with the current one. - double sqterm = w1 * w1 - w0 * w2; + const double sqterm = w1 * w1 - w0 * w2; if (sqterm < itk::Math::eps) { itkWarningMacro("KittlerIllingworthThresholdCalculator: not converging."); @@ -180,12 +180,12 @@ KittlerIllingworthThresholdCalculator::GenerateData() if (itk::Math::abs(w0) < itk::Math::eps) { - double temp = -w2 / w1; + const double temp = -w2 / w1; typename HistogramType::MeasurementVectorType v(1); typename HistogramType::IndexType idx; v[0] = temp; - bool status = histogram->GetIndex(v, idx); + const bool status = histogram->GetIndex(v, idx); itkAssertInDebugAndIgnoreInReleaseMacro(status); if (status) { @@ -200,7 +200,7 @@ KittlerIllingworthThresholdCalculator::GenerateData() { // The updated threshold is the integer part of the solution of the quadratic equation. Tprev = threshold; - double temp = (w1 + std::sqrt(sqterm)) / w0; + const double temp = (w1 + std::sqrt(sqterm)) / w0; // Not sure if this condition is really useful if (itk::Math::isnan(temp)) @@ -214,7 +214,7 @@ KittlerIllingworthThresholdCalculator::GenerateData() typename HistogramType::MeasurementVectorType v(1); typename HistogramType::IndexType idx; v[0] = temp; - bool status = histogram->GetIndex(v, idx); + const bool status = histogram->GetIndex(v, idx); itkAssertInDebugAndIgnoreInReleaseMacro(status); if (status) { diff --git a/Modules/Filtering/Thresholding/include/itkLiThresholdCalculator.hxx b/Modules/Filtering/Thresholding/include/itkLiThresholdCalculator.hxx index ddfbf4b3092..60e71e39937 100644 --- a/Modules/Filtering/Thresholding/include/itkLiThresholdCalculator.hxx +++ b/Modules/Filtering/Thresholding/include/itkLiThresholdCalculator.hxx @@ -36,13 +36,13 @@ LiThresholdCalculator::GenerateData() { itkExceptionMacro("Histogram is empty"); } - ProgressReporter progress(this, 0, histogram->GetSize(0)); + const ProgressReporter progress(this, 0, histogram->GetSize(0)); if (histogram->GetSize(0) == 1) { this->GetOutput()->Set(static_cast(histogram->GetMeasurement(0, 0))); } - unsigned int size = histogram->GetSize(0); + const unsigned int size = histogram->GetSize(0); long histthresh; int ih; @@ -130,7 +130,7 @@ LiThresholdCalculator::GenerateData() mean_obj -= bin_min; temp = (mean_back - mean_obj) / (std::log(mean_back) - std::log(mean_obj)); - double epsilon = itk::NumericTraits::epsilon(); + const double epsilon = itk::NumericTraits::epsilon(); if (temp < -epsilon) { new_thresh = static_cast(temp - 0.5); diff --git a/Modules/Filtering/Thresholding/include/itkMaximumEntropyThresholdCalculator.hxx b/Modules/Filtering/Thresholding/include/itkMaximumEntropyThresholdCalculator.hxx index 8ed8d80a958..41075d254b6 100644 --- a/Modules/Filtering/Thresholding/include/itkMaximumEntropyThresholdCalculator.hxx +++ b/Modules/Filtering/Thresholding/include/itkMaximumEntropyThresholdCalculator.hxx @@ -35,18 +35,18 @@ MaximumEntropyThresholdCalculator::GenerateData() { itkExceptionMacro("Histogram is empty"); } - ProgressReporter progress(this, 0, histogram->GetSize(0)); + const ProgressReporter progress(this, 0, histogram->GetSize(0)); if (histogram->GetSize(0) == 1) { this->GetOutput()->Set(static_cast(histogram->GetMeasurement(0, 0))); } - unsigned int size = histogram->GetSize(0); + const unsigned int size = histogram->GetSize(0); typename HistogramType::InstanceIdentifier threshold = 0; const double tolerance = itk::NumericTraits::epsilon(); - int total = histogram->GetTotalFrequency(); + const int total = histogram->GetTotalFrequency(); std::vector norm_histo(size); // normalized histogram for (int ih = 0; static_cast(ih) < size; ++ih) @@ -111,7 +111,7 @@ MaximumEntropyThresholdCalculator::GenerateData() } } - double tot_ent = ent_back + ent_obj; // total entropy + const double tot_ent = ent_back + ent_obj; // total entropy // IJ.log(""+max_ent+" "+tot_ent); constexpr double tol = 0.00001; diff --git a/Modules/Filtering/Thresholding/include/itkMomentsThresholdCalculator.hxx b/Modules/Filtering/Thresholding/include/itkMomentsThresholdCalculator.hxx index fe637608523..3bf2878ca90 100644 --- a/Modules/Filtering/Thresholding/include/itkMomentsThresholdCalculator.hxx +++ b/Modules/Filtering/Thresholding/include/itkMomentsThresholdCalculator.hxx @@ -41,9 +41,9 @@ MomentsThresholdCalculator::GenerateData() this->GetOutput()->Set(static_cast(histogram->GetMeasurement(0, 0))); } - unsigned int size = histogram->GetSize(0); + const unsigned int size = histogram->GetSize(0); - double total = histogram->GetTotalFrequency(); + const double total = histogram->GetTotalFrequency(); typename HistogramType::InstanceIdentifier threshold = 0; std::vector histo(size); @@ -53,13 +53,13 @@ MomentsThresholdCalculator::GenerateData() } // Calculate the first, second, and third order moments - double m0 = 1.0; - double m1 = 0.0; - double m2 = 0.0; - double m3 = 0.0; + const double m0 = 1.0; + double m1 = 0.0; + double m2 = 0.0; + double m3 = 0.0; for (unsigned int i = 0; i < size; ++i) { - double m = histogram->GetMeasurement(i, 0); + const double m = histogram->GetMeasurement(i, 0); m1 += m * histo[i]; m2 += m * m * histo[i]; m3 += m * m * m * histo[i]; @@ -70,12 +70,12 @@ MomentsThresholdCalculator::GenerateData() // of the target binary image. This leads to 4 equalities whose solutions // are given in the Appendix of Ref. 1 // - double cd = m0 * m2 - m1 * m1; - double c0 = (-m2 * m2 + m1 * m3) / cd; - double c1 = (m0 * -m3 + m2 * m1) / cd; - double z0 = 0.5 * (-c1 - std::sqrt(c1 * c1 - 4.0 * c0)); - double z1 = 0.5 * (-c1 + std::sqrt(c1 * c1 - 4.0 * c0)); - double p0 = (z1 - m1) / (z1 - z0); // Fraction of the object pixels in the target binary image + const double cd = m0 * m2 - m1 * m1; + const double c0 = (-m2 * m2 + m1 * m3) / cd; + const double c1 = (m0 * -m3 + m2 * m1) / cd; + const double z0 = 0.5 * (-c1 - std::sqrt(c1 * c1 - 4.0 * c0)); + const double z1 = 0.5 * (-c1 + std::sqrt(c1 * c1 - 4.0 * c0)); + const double p0 = (z1 - m1) / (z1 - z0); // Fraction of the object pixels in the target binary image // The threshold is the gray-level closest to the p0-tile of the normalized // histogram diff --git a/Modules/Filtering/Thresholding/include/itkOtsuMultipleThresholdsCalculator.hxx b/Modules/Filtering/Thresholding/include/itkOtsuMultipleThresholdsCalculator.hxx index 4f5c86614a8..8c79401046b 100644 --- a/Modules/Filtering/Thresholding/include/itkOtsuMultipleThresholdsCalculator.hxx +++ b/Modules/Filtering/Thresholding/include/itkOtsuMultipleThresholdsCalculator.hxx @@ -44,7 +44,7 @@ OtsuMultipleThresholdsCalculator::IncrementThresholds(InstanceI MeanVectorType & classMean, FrequencyVectorType & classFrequency) { - typename TInputHistogram::ConstPointer histogram = this->GetInputHistogram(); + const typename TInputHistogram::ConstPointer histogram = this->GetInputHistogram(); const SizeValueType numberOfHistogramBins = histogram->Size(); const auto numberOfClasses = static_cast(classMean.size()); @@ -136,7 +136,7 @@ template void OtsuMultipleThresholdsCalculator::Compute() { - typename TInputHistogram::ConstPointer histogram = this->GetInputHistogram(); + const typename TInputHistogram::ConstPointer histogram = this->GetInputHistogram(); // TODO: as an improvement, the class could accept multi-dimensional // histograms @@ -147,8 +147,8 @@ OtsuMultipleThresholdsCalculator::Compute() } // Compute global mean - typename TInputHistogram::ConstIterator iter = histogram->Begin(); - typename TInputHistogram::ConstIterator end = histogram->End(); + typename TInputHistogram::ConstIterator iter = histogram->Begin(); + const typename TInputHistogram::ConstIterator end = histogram->End(); MeanType globalMean{}; const FrequencyType globalFrequency = histogram->GetTotalFrequency(); @@ -159,7 +159,7 @@ OtsuMultipleThresholdsCalculator::Compute() } globalMean /= static_cast(globalFrequency); - SizeValueType numberOfClasses = m_NumberOfThresholds + 1; + const SizeValueType numberOfClasses = m_NumberOfThresholds + 1; // Initialize thresholds InstanceIdentifierVectorType thresholdIndexes(m_NumberOfThresholds); @@ -183,8 +183,8 @@ OtsuMultipleThresholdsCalculator::Compute() classFrequency[numberOfClasses - 1] = globalFrequency - freqSum; // Convert the frequencies to probabilities (i.e. normalize the histogram). - SizeValueType histSize = histogram->GetSize()[0]; - WeightVectorType imgPDF(histSize); + const SizeValueType histSize = histogram->GetSize()[0]; + WeightVectorType imgPDF(histSize); for (j = 0; j < histSize; ++j) { imgPDF[j] = (WeightType)histogram->GetFrequency(j) / (WeightType)globalFrequency; diff --git a/Modules/Filtering/Thresholding/include/itkRenyiEntropyThresholdCalculator.hxx b/Modules/Filtering/Thresholding/include/itkRenyiEntropyThresholdCalculator.hxx index 542ca32cae5..a2a56ca8c4e 100644 --- a/Modules/Filtering/Thresholding/include/itkRenyiEntropyThresholdCalculator.hxx +++ b/Modules/Filtering/Thresholding/include/itkRenyiEntropyThresholdCalculator.hxx @@ -31,13 +31,13 @@ RenyiEntropyThresholdCalculator::GenerateData() { const HistogramType * histogram = this->GetInput(); - TotalAbsoluteFrequencyType total = histogram->GetTotalFrequency(); + const TotalAbsoluteFrequencyType total = histogram->GetTotalFrequency(); if (total == TotalAbsoluteFrequencyType{}) { itkExceptionMacro("Histogram is empty"); } m_Size = histogram->GetSize(0); - ProgressReporter progress(this, 0, m_Size); + const ProgressReporter progress(this, 0, m_Size); if (m_Size == 1) { this->GetOutput()->Set(static_cast(histogram->GetMeasurement(0, 0))); @@ -154,12 +154,12 @@ RenyiEntropyThresholdCalculator::GenerateData() itkAssertInDebugAndIgnoreInReleaseMacro(t_star2 < m_Size); itkAssertInDebugAndIgnoreInReleaseMacro(t_star3 < m_Size); - double omega = P1[t_star3] - P1[t_star1]; + const double omega = P1[t_star3] - P1[t_star1]; // Determine the optimal threshold value - double realOptThreshold = static_cast(t_star1) * (P1[t_star1] + 0.25 * omega * beta1) + - static_cast(t_star2) * 0.25 * omega * beta2 + - static_cast(t_star3) * (P2[t_star3] + 0.25 * omega * beta3); + const double realOptThreshold = static_cast(t_star1) * (P1[t_star1] + 0.25 * omega * beta1) + + static_cast(t_star2) * 0.25 * omega * beta2 + + static_cast(t_star3) * (P2[t_star3] + 0.25 * omega * beta3); auto opt_threshold = static_cast(realOptThreshold); @@ -190,7 +190,7 @@ RenyiEntropyThresholdCalculator::MaxEntropyThresholding(con { if (histogram->GetFrequency(ih, 0) != AbsoluteFrequencyType{}) { - double x = (normHisto[ih] / P1[it]); + const double x = (normHisto[ih] / P1[it]); ent_back -= x * std::log(x); } } @@ -201,13 +201,13 @@ RenyiEntropyThresholdCalculator::MaxEntropyThresholding(con { if (histogram->GetFrequency(ih, 0) != AbsoluteFrequencyType{}) { - double x = (normHisto[ih] / P2[it]); + const double x = (normHisto[ih] / P2[it]); ent_obj -= x * std::log(x); } } // Total entropy - double tot_ent = ent_back + ent_obj; + const double tot_ent = ent_back + ent_obj; // IJ.log(""+max_ent+" "+tot_ent); @@ -231,9 +231,9 @@ RenyiEntropyThresholdCalculator::MaxEntropyThresholding2( InstanceIdentifier threshold = 0; // was MIN_INT in original code, but if an empty image is processed it gives an error later on. - double max_ent = NumericTraits::min(); - double alpha = 0.5; - double term = 1.0 / (1.0 - alpha); + double max_ent = NumericTraits::min(); + const double alpha = 0.5; + const double term = 1.0 / (1.0 - alpha); for (InstanceIdentifier it = m_FirstBin; it <= m_LastBin; ++it) { @@ -252,8 +252,8 @@ RenyiEntropyThresholdCalculator::MaxEntropyThresholding2( } // Total entropy - double product = ent_back * ent_obj; - double tot_ent = 0.; + const double product = ent_back * ent_obj; + double tot_ent = 0.; if (product > 0.0) { @@ -280,16 +280,16 @@ RenyiEntropyThresholdCalculator::MaxEntropyThresholding3( { InstanceIdentifier threshold = 0; // was MIN_INT in original code, but if an empty image is processed it gives an error later on. - double max_ent = 0.0; - double alpha = 2.0; - double term = 1.0 / (1.0 - alpha); + double max_ent = 0.0; + const double alpha = 2.0; + const double term = 1.0 / (1.0 - alpha); for (InstanceIdentifier it = m_FirstBin; it <= m_LastBin; ++it) { // Entropy of the background pixels double ent_back = 0.0; for (InstanceIdentifier ih = 0; ih <= it; ++ih) { - double x = normHisto[ih] / P1[it]; + const double x = normHisto[ih] / P1[it]; ent_back += x * x; } @@ -297,13 +297,13 @@ RenyiEntropyThresholdCalculator::MaxEntropyThresholding3( double ent_obj = 0.0; for (InstanceIdentifier ih = it + 1; ih < m_Size; ++ih) { - double x = normHisto[ih] / P2[it]; + const double x = normHisto[ih] / P2[it]; ent_obj += x * x; } // Total entropy - double tot_ent = 0.0; - double product = ent_back * ent_obj; + double tot_ent = 0.0; + const double product = ent_back * ent_obj; if (product > 0.0) { tot_ent = term * std::log(product); diff --git a/Modules/Filtering/Thresholding/include/itkShanbhagThresholdCalculator.hxx b/Modules/Filtering/Thresholding/include/itkShanbhagThresholdCalculator.hxx index df99fd4b045..da9d0a5b695 100644 --- a/Modules/Filtering/Thresholding/include/itkShanbhagThresholdCalculator.hxx +++ b/Modules/Filtering/Thresholding/include/itkShanbhagThresholdCalculator.hxx @@ -35,20 +35,20 @@ ShanbhagThresholdCalculator::GenerateData() { itkExceptionMacro("Histogram is empty"); } - ProgressReporter progress(this, 0, histogram->GetSize(0)); + const ProgressReporter progress(this, 0, histogram->GetSize(0)); if (histogram->GetSize(0) == 1) { this->GetOutput()->Set(static_cast(histogram->GetMeasurement(0, 0))); } - unsigned int size = histogram->GetSize(0); + const unsigned int size = histogram->GetSize(0); const double tolerance = 2.220446049250313E-16; typename HistogramType::InstanceIdentifier threshold = 0; std::vector norm_histo(size); // normalized histogram - int total = histogram->GetTotalFrequency(); + const int total = histogram->GetTotalFrequency(); for (int ih = 0; static_cast(ih) < size; ++ih) { @@ -111,7 +111,7 @@ ShanbhagThresholdCalculator::GenerateData() ent_obj *= term; // Total entropy - double tot_ent = itk::Math::abs(ent_back - ent_obj); + const double tot_ent = itk::Math::abs(ent_back - ent_obj); if (tot_ent < min_ent) { diff --git a/Modules/Filtering/Thresholding/include/itkThresholdImageFilter.hxx b/Modules/Filtering/Thresholding/include/itkThresholdImageFilter.hxx index 96b381eb323..7575c59db63 100644 --- a/Modules/Filtering/Thresholding/include/itkThresholdImageFilter.hxx +++ b/Modules/Filtering/Thresholding/include/itkThresholdImageFilter.hxx @@ -95,8 +95,8 @@ void ThresholdImageFilter::DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) { // Get the input and output pointers - InputImagePointer inputPtr = this->GetInput(); - OutputImagePointer outputPtr = this->GetOutput(0); + const InputImagePointer inputPtr = this->GetInput(); + const OutputImagePointer outputPtr = this->GetOutput(0); TotalProgressReporter progress(this, outputPtr->GetRequestedRegion().GetNumberOfPixels()); diff --git a/Modules/Filtering/Thresholding/include/itkTriangleThresholdCalculator.hxx b/Modules/Filtering/Thresholding/include/itkTriangleThresholdCalculator.hxx index 2da111a3c9d..e00a863425f 100644 --- a/Modules/Filtering/Thresholding/include/itkTriangleThresholdCalculator.hxx +++ b/Modules/Filtering/Thresholding/include/itkTriangleThresholdCalculator.hxx @@ -36,13 +36,13 @@ TriangleThresholdCalculator::GenerateData() { itkExceptionMacro("Histogram is empty"); } - ProgressReporter progress(this, 0, histogram->GetSize(0)); + const ProgressReporter progress(this, 0, histogram->GetSize(0)); if (histogram->GetSize(0) == 1) { this->GetOutput()->Set(static_cast(histogram->GetMeasurement(0, 0))); } - SizeValueType size = histogram->GetSize(0); + const SizeValueType size = histogram->GetSize(0); // Create a histogram std::vector cumSum(size, 0.0); @@ -86,10 +86,10 @@ TriangleThresholdCalculator::GenerateData() itk::Math::abs(static_cast(MxIdx) - static_cast(nnPCIdx))) { // line to 1 % - double slope = Mx / (MxIdx - onePCIdx); + const double slope = Mx / (MxIdx - onePCIdx); for (IndexValueType k = onePCIdx; k < MxIdx; ++k) { - float line = slope * (k - onePCIdx); + const float line = slope * (k - onePCIdx); triangle[k] = line - histogram->GetFrequency(k); } @@ -99,10 +99,10 @@ TriangleThresholdCalculator::GenerateData() else { // line to 99 % - double slope = -Mx / (nnPCIdx - MxIdx); + const double slope = -Mx / (nnPCIdx - MxIdx); for (IndexValueType k = MxIdx; k < nnPCIdx; ++k) { - float line = slope * (k - MxIdx) + Mx; + const float line = slope * (k - MxIdx) + Mx; triangle[k] = line - histogram->GetFrequency(k); } ThreshIdx = MxIdx + std::distance(&(triangle[MxIdx]), std::max_element(&(triangle[MxIdx]), &(triangle[nnPCIdx]))); diff --git a/Modules/Filtering/Thresholding/include/itkYenThresholdCalculator.hxx b/Modules/Filtering/Thresholding/include/itkYenThresholdCalculator.hxx index 5fedbb862f6..2bd17c809a9 100644 --- a/Modules/Filtering/Thresholding/include/itkYenThresholdCalculator.hxx +++ b/Modules/Filtering/Thresholding/include/itkYenThresholdCalculator.hxx @@ -35,18 +35,18 @@ YenThresholdCalculator::GenerateData() { itkExceptionMacro("Histogram is empty"); } - ProgressReporter progress(this, 0, histogram->GetSize(0)); + const ProgressReporter progress(this, 0, histogram->GetSize(0)); if (histogram->GetSize(0) == 1) { this->GetOutput()->Set(static_cast(histogram->GetMeasurement(0, 0))); } - unsigned int size = histogram->GetSize(0); + const unsigned int size = histogram->GetSize(0); typename HistogramType::InstanceIdentifier threshold = 0; std::vector norm_histo(size); // normalized histogram - int total = histogram->GetTotalFrequency(); + const int total = histogram->GetTotalFrequency(); for (int ih = 0; static_cast(ih) < size; ++ih) { @@ -76,8 +76,8 @@ YenThresholdCalculator::GenerateData() double max_crit = itk::NumericTraits::NonpositiveMin(); for (int it = 0; static_cast(it) < size; ++it) { - double crit = -1.0 * ((P1_sq[it] * P2_sq[it]) > 0.0 ? std::log(P1_sq[it] * P2_sq[it]) : 0.0) + - 2 * ((P1[it] * (1.0 - P1[it])) > 0.0 ? std::log(P1[it] * (1.0 - P1[it])) : 0.0); + const double crit = -1.0 * ((P1_sq[it] * P2_sq[it]) > 0.0 ? std::log(P1_sq[it] * P2_sq[it]) : 0.0) + + 2 * ((P1[it] * (1.0 - P1[it])) > 0.0 ? std::log(P1[it] * (1.0 - P1[it])) : 0.0); if (crit > max_crit) { max_crit = crit; diff --git a/Modules/Filtering/Thresholding/test/itkBinaryThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkBinaryThresholdImageFilterTest.cxx index a3bec08e9c0..da34969b3eb 100644 --- a/Modules/Filtering/Thresholding/test/itkBinaryThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkBinaryThresholdImageFilterTest.cxx @@ -59,8 +59,8 @@ itkBinaryThresholdImageFilterTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, BinaryThresholdImageFilter, UnaryFunctorImageFilter); // Set up ivars - InputPixelType lower = 64; - InputPixelType upper = 128; + const InputPixelType lower = 64; + const InputPixelType upper = 128; // No input set: check that thresholds are created using the input @@ -68,7 +68,7 @@ itkBinaryThresholdImageFilterTest(int, char *[]) // // Lower threshold - FilterType::InputPixelObjectType::Pointer lowerThreshold1 = filter->GetLowerThresholdInput(); + const FilterType::InputPixelObjectType::Pointer lowerThreshold1 = filter->GetLowerThresholdInput(); if (lowerThreshold1->Get() != itk::NumericTraits::NonpositiveMin()) { @@ -82,7 +82,7 @@ itkBinaryThresholdImageFilterTest(int, char *[]) return EXIT_FAILURE; } - FilterType::InputPixelObjectType::Pointer lowerThreshold2 = FilterType::InputPixelObjectType::New(); + const FilterType::InputPixelObjectType::Pointer lowerThreshold2 = FilterType::InputPixelObjectType::New(); filter->SetLowerThresholdInput(lowerThreshold2); if (lowerThreshold2->Get() != itk::NumericTraits::NonpositiveMin()) @@ -98,7 +98,7 @@ itkBinaryThresholdImageFilterTest(int, char *[]) } // Upper threshold - FilterType::InputPixelObjectType::Pointer upperThreshold1 = filter->GetUpperThresholdInput(); + const FilterType::InputPixelObjectType::Pointer upperThreshold1 = filter->GetUpperThresholdInput(); if (lowerThreshold1->Get() != itk::NumericTraits::NonpositiveMin()) { @@ -112,7 +112,7 @@ itkBinaryThresholdImageFilterTest(int, char *[]) return EXIT_FAILURE; } - FilterType::InputPixelObjectType::Pointer upperThreshold2 = FilterType::InputPixelObjectType::New(); + const FilterType::InputPixelObjectType::Pointer upperThreshold2 = FilterType::InputPixelObjectType::New(); filter->SetUpperThresholdInput(upperThreshold2); if (upperThreshold2->Get() != itk::NumericTraits::NonpositiveMin()) @@ -128,7 +128,7 @@ itkBinaryThresholdImageFilterTest(int, char *[]) } // Exercise the const variants - FilterType::ConstPointer constFilter = (const FilterType *)(filter.GetPointer()); + const FilterType::ConstPointer constFilter = (const FilterType *)(filter.GetPointer()); const typename FilterType::InputPixelObjectType * lowerThresholdInput = constFilter->GetLowerThresholdInput(); ITK_TEST_SET_GET_VALUE(lowerThresholdInput->Get(), lowerThreshold2->Get()); @@ -151,11 +151,11 @@ itkBinaryThresholdImageFilterTest(int, char *[]) filter->SetUpperThreshold(upper); ITK_TEST_SET_GET_VALUE(upper, filter->GetUpperThreshold()); - OutputPixelType inside = -0.5; + const OutputPixelType inside = -0.5; filter->SetInsideValue(inside); ITK_TEST_SET_GET_VALUE(inside, filter->GetInsideValue()); - OutputPixelType outside = 0.5; + const OutputPixelType outside = 0.5; filter->SetOutsideValue(outside); ITK_TEST_SET_GET_VALUE(outside, filter->GetOutsideValue()); @@ -168,7 +168,7 @@ itkBinaryThresholdImageFilterTest(int, char *[]) ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); // Get the filter output - OutputImageType::Pointer outputImage = filter->GetOutput(); + const OutputImageType::Pointer outputImage = filter->GetOutput(); // Create an iterator for going through the image output InputIteratorType it(source->GetOutput(), source->GetOutput()->GetRequestedRegion()); diff --git a/Modules/Filtering/Thresholding/test/itkBinaryThresholdProjectionImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkBinaryThresholdProjectionImageFilterTest.cxx index 00fd5632209..4229648a4b8 100644 --- a/Modules/Filtering/Thresholding/test/itkBinaryThresholdProjectionImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkBinaryThresholdProjectionImageFilterTest.cxx @@ -53,20 +53,20 @@ itkBinaryThresholdProjectionImageFilterTest(int argc, char * argv[]) using FilterType = itk::BinaryThresholdProjectionImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, BinaryThresholdProjectionImageFilter, ProjectionImageFilter); - FilterType::InputPixelType thresholdValue = std::stoi(argv[3]); + const FilterType::InputPixelType thresholdValue = std::stoi(argv[3]); filter->SetThresholdValue(thresholdValue); ITK_TEST_SET_GET_VALUE(thresholdValue, filter->GetThresholdValue()); - FilterType::OutputPixelType foregroundValue = std::stoi(argv[4]); + const FilterType::OutputPixelType foregroundValue = std::stoi(argv[4]); filter->SetForegroundValue(foregroundValue); ITK_TEST_SET_GET_VALUE(foregroundValue, filter->GetForegroundValue()); - FilterType::OutputPixelType backgroundValue = std::stoi(argv[5]); + const FilterType::OutputPixelType backgroundValue = std::stoi(argv[5]); filter->SetBackgroundValue(backgroundValue); ITK_TEST_SET_GET_VALUE(backgroundValue, filter->GetBackgroundValue()); diff --git a/Modules/Filtering/Thresholding/test/itkBinaryThresholdSpatialFunctionTest.cxx b/Modules/Filtering/Thresholding/test/itkBinaryThresholdSpatialFunctionTest.cxx index 80ef7c009cb..d0b4c0cf1ee 100644 --- a/Modules/Filtering/Thresholding/test/itkBinaryThresholdSpatialFunctionTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkBinaryThresholdSpatialFunctionTest.cxx @@ -71,8 +71,8 @@ itkBinaryThresholdSpatialFunctionTest(int, char *[]) function->SetFunction(sphere); // Set the thresholds - double lowerThreshold = -3.0; - double upperThreshold = 4.0; + const double lowerThreshold = -3.0; + const double upperThreshold = 4.0; function->SetLowerThreshold(lowerThreshold); ITK_TEST_SET_GET_VALUE(lowerThreshold, function->GetLowerThreshold()); function->SetUpperThreshold(upperThreshold); @@ -83,14 +83,14 @@ itkBinaryThresholdSpatialFunctionTest(int, char *[]) for (double p = 0.0; p < 10.0; p += 1.0) { point.Fill(p); - FunctionType::OutputType output = function->Evaluate(point); + const FunctionType::OutputType output = function->Evaluate(point); std::cout << "f(" << point << ") = " << output; std::cerr << " [" << function->GetFunction()->Evaluate(point); std::cout << "] " << std::endl; // Check results - CoordRep val = p * std::sqrt(2.0) - parameters[0]; - bool expected = (lowerThreshold <= val && upperThreshold >= val); + const CoordRep val = p * std::sqrt(2.0) - parameters[0]; + const bool expected = (lowerThreshold <= val && upperThreshold >= val); if (output != expected) { std::cerr << "Test failed!" << std::endl; @@ -141,7 +141,7 @@ itkBinaryThresholdSpatialFunctionTest(int, char *[]) { index = iterator.GetIndex(); image->TransformIndexToPhysicalPoint(index, point); - double value = sphere->Evaluate(point); + const double value = sphere->Evaluate(point); // Check if value is within range if (value < lowerThreshold || value > upperThreshold) diff --git a/Modules/Filtering/Thresholding/test/itkHuangMaskedThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkHuangMaskedThresholdImageFilterTest.cxx index a9c4e364d91..b19aaea69cc 100644 --- a/Modules/Filtering/Thresholding/test/itkHuangMaskedThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkHuangMaskedThresholdImageFilterTest.cxx @@ -63,7 +63,7 @@ itkHuangMaskedThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::HuangThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, HuangThresholdImageFilter, HistogramThresholdImageFilter); @@ -76,7 +76,7 @@ itkHuangMaskedThresholdImageFilterTest(int argc, char * argv[]) filter->SetOutsideValue(outsideValue); ITK_TEST_SET_GET_VALUE(outsideValue, filter->GetOutsideValue()); - bool maskOutput = static_cast(std::stoi(argv[4])); + const bool maskOutput = static_cast(std::stoi(argv[4])); ITK_TEST_SET_GET_BOOLEAN(filter, MaskOutput, maskOutput); auto maskValue = static_cast(std::stod(argv[5])); @@ -92,8 +92,8 @@ itkHuangMaskedThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); // Regression test: compare computed threshold - FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + const FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkHuangThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkHuangThresholdImageFilterTest.cxx index 60fd3e45ec7..730b6f8fb6c 100644 --- a/Modules/Filtering/Thresholding/test/itkHuangThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkHuangThresholdImageFilterTest.cxx @@ -57,7 +57,7 @@ itkHuangThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::HuangThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, HuangThresholdImageFilter, HistogramThresholdImageFilter); @@ -87,7 +87,7 @@ itkHuangThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_EXCEPTION(filter->Update()); - FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); + const FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); filter->SetCalculator(calculator); ITK_TEST_SET_GET_VALUE(calculator, filter->GetCalculator()); @@ -96,8 +96,8 @@ itkHuangThresholdImageFilterTest(int argc, char * argv[]) // Regression test: compare computed threshold - auto expectedThreshold = static_cast(std::stod(argv[5])); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + auto expectedThreshold = static_cast(std::stod(argv[5])); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkIntermodesMaskedThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkIntermodesMaskedThresholdImageFilterTest.cxx index c57959510bf..e32d3326e5f 100644 --- a/Modules/Filtering/Thresholding/test/itkIntermodesMaskedThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkIntermodesMaskedThresholdImageFilterTest.cxx @@ -67,7 +67,7 @@ itkIntermodesMaskedThresholdImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, IntermodesThresholdImageFilter, HistogramThresholdImageFilter); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); auto insideValue = static_cast(255); filter->SetInsideValue(insideValue); @@ -77,18 +77,18 @@ itkIntermodesMaskedThresholdImageFilterTest(int argc, char * argv[]) filter->SetOutsideValue(outsideValue); ITK_TEST_SET_GET_VALUE(outsideValue, filter->GetOutsideValue()); - bool maskOutput = static_cast(std::stoi(argv[4])); + const bool maskOutput = static_cast(std::stoi(argv[4])); ITK_TEST_SET_GET_BOOLEAN(filter, MaskOutput, maskOutput); auto maskValue = static_cast(std::stod(argv[5])); filter->SetMaskValue(maskValue); ITK_TEST_SET_GET_VALUE(maskValue, filter->GetMaskValue()); - unsigned long maximumSmoothingIterations = std::stoi(argv[6]); + const unsigned long maximumSmoothingIterations = std::stoi(argv[6]); filter->SetMaximumSmoothingIterations(maximumSmoothingIterations); ITK_TEST_SET_GET_VALUE(maximumSmoothingIterations, filter->GetMaximumSmoothingIterations()); - bool useInterMode = static_cast(std::stoi(argv[7])); + const bool useInterMode = static_cast(std::stoi(argv[7])); ITK_TEST_SET_GET_BOOLEAN(filter, UseInterMode, useInterMode); @@ -100,8 +100,8 @@ itkIntermodesMaskedThresholdImageFilterTest(int argc, char * argv[]) // Regression test: compare computed threshold - FilterType::InputPixelType expectedThreshold = std::stod(argv[8]); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + const FilterType::InputPixelType expectedThreshold = std::stod(argv[8]); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkIntermodesThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkIntermodesThresholdImageFilterTest.cxx index 72153b2410d..89cbf30592b 100644 --- a/Modules/Filtering/Thresholding/test/itkIntermodesThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkIntermodesThresholdImageFilterTest.cxx @@ -59,7 +59,7 @@ itkIntermodesThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::IntermodesThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, IntermodesThresholdImageFilter, HistogramThresholdImageFilter); @@ -90,7 +90,7 @@ itkIntermodesThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_EXCEPTION(filter->Update()); - FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); + const FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); filter->SetCalculator(calculator); ITK_TEST_SET_GET_VALUE(calculator, filter->GetCalculator()); @@ -99,19 +99,19 @@ itkIntermodesThresholdImageFilterTest(int argc, char * argv[]) filter->SetMaximumSmoothingIterations(10); ITK_TRY_EXPECT_EXCEPTION(filter->Update()); - unsigned long maximumSmoothingIterations = std::stoi(argv[5]); + const unsigned long maximumSmoothingIterations = std::stoi(argv[5]); filter->SetMaximumSmoothingIterations(maximumSmoothingIterations); ITK_TEST_SET_GET_VALUE(maximumSmoothingIterations, filter->GetMaximumSmoothingIterations()); - bool useInterMode = static_cast(std::stoi(argv[6])); + const bool useInterMode = static_cast(std::stoi(argv[6])); ITK_TEST_SET_GET_BOOLEAN(filter, UseInterMode, useInterMode); ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); // Regression test: compare computed threshold - FilterType::InputPixelType expectedThreshold = std::stod(argv[7]); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + const FilterType::InputPixelType expectedThreshold = std::stod(argv[7]); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkIsoDataMaskedThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkIsoDataMaskedThresholdImageFilterTest.cxx index 8ff3d6c520f..36b9903f069 100644 --- a/Modules/Filtering/Thresholding/test/itkIsoDataMaskedThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkIsoDataMaskedThresholdImageFilterTest.cxx @@ -64,7 +64,7 @@ itkIsoDataMaskedThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::IsoDataThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, IsoDataThresholdImageFilter, HistogramThresholdImageFilter); @@ -77,7 +77,7 @@ itkIsoDataMaskedThresholdImageFilterTest(int argc, char * argv[]) filter->SetOutsideValue(outsideValue); ITK_TEST_SET_GET_VALUE(outsideValue, filter->GetOutsideValue()); - bool maskOutput = static_cast(std::stoi(argv[4])); + const bool maskOutput = static_cast(std::stoi(argv[4])); ITK_TEST_SET_GET_BOOLEAN(filter, MaskOutput, maskOutput); auto maskValue = static_cast(std::stod(argv[5])); @@ -92,8 +92,8 @@ itkIsoDataMaskedThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); // Regression test: compare computed threshold - FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + const FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkIsoDataThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkIsoDataThresholdImageFilterTest.cxx index b99bd9b1b8e..4afe2c16e2b 100644 --- a/Modules/Filtering/Thresholding/test/itkIsoDataThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkIsoDataThresholdImageFilterTest.cxx @@ -56,7 +56,7 @@ itkIsoDataThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::IsoDataThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, IsoDataThresholdImageFilter, HistogramThresholdImageFilter); @@ -87,7 +87,7 @@ itkIsoDataThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_EXCEPTION(filter->Update()); - FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); + const FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); filter->SetCalculator(calculator); ITK_TEST_SET_GET_VALUE(calculator, filter->GetCalculator()); @@ -95,8 +95,8 @@ itkIsoDataThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); - auto expectedThreshold = static_cast(std::stod(argv[5])); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + auto expectedThreshold = static_cast(std::stod(argv[5])); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkKappaSigmaThresholdImageCalculatorTest.cxx b/Modules/Filtering/Thresholding/test/itkKappaSigmaThresholdImageCalculatorTest.cxx index 6f4a86bd7e5..460f34cbb71 100644 --- a/Modules/Filtering/Thresholding/test/itkKappaSigmaThresholdImageCalculatorTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkKappaSigmaThresholdImageCalculatorTest.cxx @@ -72,9 +72,9 @@ itkKappaSigmaThresholdImageCalculatorTest(int argc, char * argv[]) calculator->Compute(); // Regression test: compare computed threshold - CalculatorType::InputPixelType expectedThreshold = std::stod(argv[5]); - CalculatorType::InputPixelType resultThreshold = calculator->GetOutput(); - double tolerance = 1e-3; + const CalculatorType::InputPixelType expectedThreshold = std::stod(argv[5]); + const CalculatorType::InputPixelType resultThreshold = calculator->GetOutput(); + const double tolerance = 1e-3; if (!itk::Math::FloatAlmostEqual( static_cast(expectedThreshold), static_cast(resultThreshold), 10, tolerance)) { diff --git a/Modules/Filtering/Thresholding/test/itkKappaSigmaThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkKappaSigmaThresholdImageFilterTest.cxx index b07f9befcef..fd16c9d0024 100644 --- a/Modules/Filtering/Thresholding/test/itkKappaSigmaThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkKappaSigmaThresholdImageFilterTest.cxx @@ -59,7 +59,7 @@ itkKappaSigmaThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::KappaSigmaThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, KappaSigmaThresholdImageFilter, ImageToImageFilter); @@ -76,7 +76,7 @@ itkKappaSigmaThresholdImageFilterTest(int argc, char * argv[]) filter->SetMaskValue(maskValue); ITK_TEST_SET_GET_VALUE(maskValue, filter->GetMaskValue()); - double sigmaFactor = std::stod(argv[4]); + const double sigmaFactor = std::stod(argv[4]); filter->SetSigmaFactor(sigmaFactor); ITK_TEST_SET_GET_VALUE(sigmaFactor, filter->GetSigmaFactor()); @@ -91,8 +91,8 @@ itkKappaSigmaThresholdImageFilterTest(int argc, char * argv[]) // Regression test: compare computed threshold - FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + const FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkKittlerIllingworthMaskedThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkKittlerIllingworthMaskedThresholdImageFilterTest.cxx index 12bdcd09fd3..76e0981b406 100644 --- a/Modules/Filtering/Thresholding/test/itkKittlerIllingworthMaskedThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkKittlerIllingworthMaskedThresholdImageFilterTest.cxx @@ -64,7 +64,7 @@ itkKittlerIllingworthMaskedThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::KittlerIllingworthThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, KittlerIllingworthThresholdImageFilter, HistogramThresholdImageFilter); @@ -77,7 +77,7 @@ itkKittlerIllingworthMaskedThresholdImageFilterTest(int argc, char * argv[]) filter->SetOutsideValue(outsideValue); ITK_TEST_SET_GET_VALUE(outsideValue, filter->GetOutsideValue()); - bool maskOutput = static_cast(std::stoi(argv[4])); + const bool maskOutput = static_cast(std::stoi(argv[4])); ITK_TEST_SET_GET_BOOLEAN(filter, MaskOutput, maskOutput); auto maskValue = static_cast(std::stod(argv[5])); @@ -92,8 +92,8 @@ itkKittlerIllingworthMaskedThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); // Regression test: compare computed threshold - FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + const FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkKittlerIllingworthThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkKittlerIllingworthThresholdImageFilterTest.cxx index 87019394708..9063fe180a6 100644 --- a/Modules/Filtering/Thresholding/test/itkKittlerIllingworthThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkKittlerIllingworthThresholdImageFilterTest.cxx @@ -56,7 +56,7 @@ itkKittlerIllingworthThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::KittlerIllingworthThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, KittlerIllingworthThresholdImageFilter, HistogramThresholdImageFilter); @@ -87,7 +87,7 @@ itkKittlerIllingworthThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_EXCEPTION(filter->Update()); - FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); + const FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); filter->SetCalculator(calculator); ITK_TEST_SET_GET_VALUE(calculator, filter->GetCalculator()); @@ -95,8 +95,8 @@ itkKittlerIllingworthThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); // Regression test: compare computed threshold - auto expectedThreshold = static_cast(std::stod(argv[5])); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + auto expectedThreshold = static_cast(std::stod(argv[5])); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkLiMaskedThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkLiMaskedThresholdImageFilterTest.cxx index 6109ad02af7..c33413400d8 100644 --- a/Modules/Filtering/Thresholding/test/itkLiMaskedThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkLiMaskedThresholdImageFilterTest.cxx @@ -64,7 +64,7 @@ itkLiMaskedThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::LiThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, LiThresholdImageFilter, HistogramThresholdImageFilter); @@ -77,7 +77,7 @@ itkLiMaskedThresholdImageFilterTest(int argc, char * argv[]) filter->SetOutsideValue(outsideValue); ITK_TEST_SET_GET_VALUE(outsideValue, filter->GetOutsideValue()); - bool maskOutput = static_cast(std::stoi(argv[4])); + const bool maskOutput = static_cast(std::stoi(argv[4])); ITK_TEST_SET_GET_BOOLEAN(filter, MaskOutput, maskOutput); auto maskValue = static_cast(std::stod(argv[5])); @@ -92,8 +92,8 @@ itkLiMaskedThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); // Regression test: compare computed threshold - FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + const FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkLiThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkLiThresholdImageFilterTest.cxx index 2094b90a28c..1bd7142f840 100644 --- a/Modules/Filtering/Thresholding/test/itkLiThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkLiThresholdImageFilterTest.cxx @@ -56,7 +56,7 @@ itkLiThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::LiThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, LiThresholdImageFilter, HistogramThresholdImageFilter); @@ -87,7 +87,7 @@ itkLiThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_EXCEPTION(filter->Update()); - FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); + const FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); filter->SetCalculator(calculator); ITK_TEST_SET_GET_VALUE(calculator, filter->GetCalculator()); @@ -95,8 +95,8 @@ itkLiThresholdImageFilterTest(int argc, char * argv[]) // Regression test: compare computed threshold - auto expectedThreshold = static_cast(std::stod(argv[5])); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + auto expectedThreshold = static_cast(std::stod(argv[5])); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkMaximumEntropyMaskedThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkMaximumEntropyMaskedThresholdImageFilterTest.cxx index a0d9a8f3f60..b106ef8975a 100644 --- a/Modules/Filtering/Thresholding/test/itkMaximumEntropyMaskedThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkMaximumEntropyMaskedThresholdImageFilterTest.cxx @@ -65,7 +65,7 @@ itkMaximumEntropyMaskedThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::MaximumEntropyThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, MaximumEntropyThresholdImageFilter, HistogramThresholdImageFilter); @@ -78,7 +78,7 @@ itkMaximumEntropyMaskedThresholdImageFilterTest(int argc, char * argv[]) filter->SetOutsideValue(outsideValue); ITK_TEST_SET_GET_VALUE(outsideValue, filter->GetOutsideValue()); - bool maskOutput = static_cast(std::stoi(argv[4])); + const bool maskOutput = static_cast(std::stoi(argv[4])); ITK_TEST_SET_GET_BOOLEAN(filter, MaskOutput, maskOutput); auto maskValue = static_cast(std::stod(argv[5])); @@ -94,8 +94,8 @@ itkMaximumEntropyMaskedThresholdImageFilterTest(int argc, char * argv[]) // Regression test: compare computed threshold - FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + const FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkMaximumEntropyThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkMaximumEntropyThresholdImageFilterTest.cxx index 795d1fb8076..9a1833ddb27 100644 --- a/Modules/Filtering/Thresholding/test/itkMaximumEntropyThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkMaximumEntropyThresholdImageFilterTest.cxx @@ -56,7 +56,7 @@ itkMaximumEntropyThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::MaximumEntropyThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, MaximumEntropyThresholdImageFilter, HistogramThresholdImageFilter); @@ -87,7 +87,7 @@ itkMaximumEntropyThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_EXCEPTION(filter->Update()); - FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); + const FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); filter->SetCalculator(calculator); ITK_TEST_SET_GET_VALUE(calculator, filter->GetCalculator()); @@ -96,8 +96,8 @@ itkMaximumEntropyThresholdImageFilterTest(int argc, char * argv[]) // Regression test: compare computed threshold - auto expectedThreshold = static_cast(std::stod(argv[5])); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + auto expectedThreshold = static_cast(std::stod(argv[5])); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkMomentsMaskedThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkMomentsMaskedThresholdImageFilterTest.cxx index 632adb59220..b8aac5a312b 100644 --- a/Modules/Filtering/Thresholding/test/itkMomentsMaskedThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkMomentsMaskedThresholdImageFilterTest.cxx @@ -65,7 +65,7 @@ itkMomentsMaskedThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::MomentsThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, MomentsThresholdImageFilter, HistogramThresholdImageFilter); @@ -78,7 +78,7 @@ itkMomentsMaskedThresholdImageFilterTest(int argc, char * argv[]) filter->SetOutsideValue(outsideValue); ITK_TEST_SET_GET_VALUE(outsideValue, filter->GetOutsideValue()); - bool maskOutput = static_cast(std::stoi(argv[4])); + const bool maskOutput = static_cast(std::stoi(argv[4])); ITK_TEST_SET_GET_BOOLEAN(filter, MaskOutput, maskOutput); auto maskValue = static_cast(std::stod(argv[5])); @@ -94,8 +94,8 @@ itkMomentsMaskedThresholdImageFilterTest(int argc, char * argv[]) // Regression test: compare computed threshold - FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + const FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkMomentsThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkMomentsThresholdImageFilterTest.cxx index d8915485772..d789b4d3c9f 100644 --- a/Modules/Filtering/Thresholding/test/itkMomentsThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkMomentsThresholdImageFilterTest.cxx @@ -56,7 +56,7 @@ itkMomentsThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::MomentsThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, MomentsThresholdImageFilter, HistogramThresholdImageFilter); @@ -87,7 +87,7 @@ itkMomentsThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_EXCEPTION(filter->Update()); - FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); + const FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); filter->SetCalculator(calculator); ITK_TEST_SET_GET_VALUE(calculator, filter->GetCalculator()); @@ -96,8 +96,8 @@ itkMomentsThresholdImageFilterTest(int argc, char * argv[]) // Regression test: compare computed threshold - auto expectedThreshold = static_cast(std::stod(argv[5])); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + auto expectedThreshold = static_cast(std::stod(argv[5])); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkOtsuMaskedThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkOtsuMaskedThresholdImageFilterTest.cxx index 15e42435717..3a9d83c1062 100644 --- a/Modules/Filtering/Thresholding/test/itkOtsuMaskedThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkOtsuMaskedThresholdImageFilterTest.cxx @@ -64,7 +64,7 @@ itkOtsuMaskedThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::OtsuThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, OtsuThresholdImageFilter, HistogramThresholdImageFilter); @@ -77,7 +77,7 @@ itkOtsuMaskedThresholdImageFilterTest(int argc, char * argv[]) filter->SetOutsideValue(outsideValue); ITK_TEST_SET_GET_VALUE(outsideValue, filter->GetOutsideValue()); - bool maskOutput = static_cast(std::stoi(argv[4])); + const bool maskOutput = static_cast(std::stoi(argv[4])); ITK_TEST_SET_GET_BOOLEAN(filter, MaskOutput, maskOutput); auto maskValue = static_cast(std::stod(argv[5])); @@ -93,8 +93,8 @@ itkOtsuMaskedThresholdImageFilterTest(int argc, char * argv[]) // Regression test: compare computed threshold - FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + const FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkOtsuMultipleThresholdsCalculatorTest.cxx b/Modules/Filtering/Thresholding/test/itkOtsuMultipleThresholdsCalculatorTest.cxx index b935e6ea940..69932a5b0fb 100644 --- a/Modules/Filtering/Thresholding/test/itkOtsuMultipleThresholdsCalculatorTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkOtsuMultipleThresholdsCalculatorTest.cxx @@ -58,12 +58,12 @@ itkOtsuMultipleThresholdsCalculatorTest(int argc, char * argv[]) values.push_back(32.0); values.push_back(48.0); - MeasurementType range = 2.0; + const MeasurementType range = 2.0; // Create histogram with samples at values +- range for (HistogramType::Iterator iter = histogram->Begin(); iter != histogram->End(); ++iter) { - HistogramType::MeasurementType measurement = iter.GetMeasurementVector()[0]; + const HistogramType::MeasurementType measurement = iter.GetMeasurementVector()[0]; for (ValuesVectorType::const_iterator viter = values.begin(); viter != values.end(); ++viter) { @@ -91,10 +91,10 @@ itkOtsuMultipleThresholdsCalculatorTest(int argc, char * argv[]) otsuThresholdCalculator->SetNumberOfThresholds(numberOfThresholds); ITK_TEST_SET_GET_VALUE(numberOfThresholds, otsuThresholdCalculator->GetNumberOfThresholds()); - bool valleyEmphasis = std::stoi(argv[1]); + const bool valleyEmphasis = std::stoi(argv[1]); ITK_TEST_SET_GET_BOOLEAN(otsuThresholdCalculator, ValleyEmphasis, valleyEmphasis); - bool returnBinMidpoint = std::stoi(argv[2]); + const bool returnBinMidpoint = std::stoi(argv[2]); ITK_TEST_SET_GET_BOOLEAN(otsuThresholdCalculator, ReturnBinMidpoint, returnBinMidpoint); ITK_TRY_EXPECT_NO_EXCEPTION(otsuThresholdCalculator->Compute()); diff --git a/Modules/Filtering/Thresholding/test/itkOtsuMultipleThresholdsImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkOtsuMultipleThresholdsImageFilterTest.cxx index 6bbc2c559fb..b700b8dc466 100644 --- a/Modules/Filtering/Thresholding/test/itkOtsuMultipleThresholdsImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkOtsuMultipleThresholdsImageFilterTest.cxx @@ -66,7 +66,7 @@ itkOtsuMultipleThresholdsImageFilterTest(int argc, char * argv[]) using FilterType = itk::OtsuMultipleThresholdsImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, OtsuMultipleThresholdsImageFilter, ImageToImageFilter); @@ -90,13 +90,13 @@ itkOtsuMultipleThresholdsImageFilterTest(int argc, char * argv[]) if (argc > 6) { - bool valleyEmphasis = static_cast(std::stoi(argv[6])); + const bool valleyEmphasis = static_cast(std::stoi(argv[6])); ITK_TEST_SET_GET_BOOLEAN(filter, ValleyEmphasis, valleyEmphasis); } if (argc > 7) { - bool returnBinMidpoint = static_cast(std::stoi(argv[7])); + const bool returnBinMidpoint = static_cast(std::stoi(argv[7])); ITK_TEST_SET_GET_BOOLEAN(filter, ReturnBinMidpoint, returnBinMidpoint); } diff --git a/Modules/Filtering/Thresholding/test/itkOtsuThresholdCalculatorTest.cxx b/Modules/Filtering/Thresholding/test/itkOtsuThresholdCalculatorTest.cxx index 86a9e88065d..c9e19b663a3 100644 --- a/Modules/Filtering/Thresholding/test/itkOtsuThresholdCalculatorTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkOtsuThresholdCalculatorTest.cxx @@ -41,7 +41,7 @@ itkOtsuThresholdCalculatorTest(int, char *[]) ImageType::RegionType region; // Define the image size and physical coordinates - SizeType size = { { 20, 20, 20 } }; + const SizeType size = { { 20, 20, 20 } }; region.SetSize(size); image->SetRegions(region); @@ -53,15 +53,15 @@ itkOtsuThresholdCalculatorTest(int, char *[]) image->SetOrigin(origin); image->SetSpacing(spacing); - unsigned long numPixels = region.GetNumberOfPixels(); + const unsigned long numPixels = region.GetNumberOfPixels(); using IteratorType = itk::ImageRegionIterator; IteratorType iter(image, image->GetBufferedRegion()); - ImageType::PixelType value1 = 10; - ImageType::PixelType value2 = 50; - ImageType::PixelType range = 5; - ImageType::PixelType r2 = range * 2 + 1; + const ImageType::PixelType value1 = 10; + const ImageType::PixelType value2 = 50; + const ImageType::PixelType range = 5; + const ImageType::PixelType r2 = range * 2 + 1; // Fill one half of with values of value1 +- 2 unsigned long i; @@ -98,7 +98,7 @@ itkOtsuThresholdCalculatorTest(int, char *[]) calculator->Update(); // Return minimum of intensity - double thresholdResult = calculator->GetThreshold(); + const double thresholdResult = calculator->GetThreshold(); std::cout << "The threshold intensity value is : " << thresholdResult << std::endl; if (thresholdResult < static_cast(value1) || thresholdResult > static_cast(value2)) diff --git a/Modules/Filtering/Thresholding/test/itkOtsuThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkOtsuThresholdImageFilterTest.cxx index e1dad12a688..1fdaa6abf7a 100644 --- a/Modules/Filtering/Thresholding/test/itkOtsuThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkOtsuThresholdImageFilterTest.cxx @@ -58,7 +58,7 @@ itkOtsuThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::OtsuThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, OtsuThresholdImageFilter, HistogramThresholdImageFilter); @@ -75,7 +75,7 @@ itkOtsuThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_EXCEPTION(filter->Update()); - FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); + const FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); filter->SetCalculator(calculator); ITK_TEST_SET_GET_VALUE(calculator, filter->GetCalculator()); @@ -84,19 +84,19 @@ itkOtsuThresholdImageFilterTest(int argc, char * argv[]) if (argc > 5) { - bool flipOutputIntensities = std::stoi(argv[6]); + const bool flipOutputIntensities = std::stoi(argv[6]); if (flipOutputIntensities) { // Flip the inside and outside values - FilterType::OutputPixelType outsideValue = filter->GetInsideValue(); - FilterType::OutputPixelType insideValue = filter->GetOutsideValue(); + const FilterType::OutputPixelType outsideValue = filter->GetInsideValue(); + const FilterType::OutputPixelType insideValue = filter->GetOutsideValue(); filter->SetInsideValue(insideValue); filter->SetOutsideValue(outsideValue); } } if (argc > 6) { - bool returnBinMidpoint = static_cast(std::stoi(argv[6])); + const bool returnBinMidpoint = static_cast(std::stoi(argv[6])); ITK_TEST_SET_GET_BOOLEAN(filter, ReturnBinMidpoint, returnBinMidpoint); } @@ -104,8 +104,8 @@ itkOtsuThresholdImageFilterTest(int argc, char * argv[]) // Regression test: compare computed threshold - auto expectedThreshold = static_cast(std::stod(argv[5])); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + auto expectedThreshold = static_cast(std::stod(argv[5])); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkRenyiEntropyMaskedThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkRenyiEntropyMaskedThresholdImageFilterTest.cxx index a56a2eb2330..f49b62f8b1c 100644 --- a/Modules/Filtering/Thresholding/test/itkRenyiEntropyMaskedThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkRenyiEntropyMaskedThresholdImageFilterTest.cxx @@ -61,7 +61,7 @@ itkRenyiEntropyMaskedThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::RenyiEntropyThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, RenyiEntropyThresholdImageFilter, HistogramThresholdImageFilter); @@ -74,7 +74,7 @@ itkRenyiEntropyMaskedThresholdImageFilterTest(int argc, char * argv[]) filter->SetOutsideValue(outsideValue); ITK_TEST_SET_GET_VALUE(outsideValue, filter->GetOutsideValue()); - bool maskOutput = static_cast(std::stoi(argv[4])); + const bool maskOutput = static_cast(std::stoi(argv[4])); ITK_TEST_SET_GET_BOOLEAN(filter, MaskOutput, maskOutput); auto maskValue = static_cast(std::stod(argv[5])); @@ -92,8 +92,8 @@ itkRenyiEntropyMaskedThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); // Regression test: compare computed threshold - FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + const FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkRenyiEntropyThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkRenyiEntropyThresholdImageFilterTest.cxx index ef90651c57c..7a874e12b01 100644 --- a/Modules/Filtering/Thresholding/test/itkRenyiEntropyThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkRenyiEntropyThresholdImageFilterTest.cxx @@ -56,7 +56,7 @@ itkRenyiEntropyThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::RenyiEntropyThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, RenyiEntropyThresholdImageFilter, HistogramThresholdImageFilter); @@ -87,7 +87,7 @@ itkRenyiEntropyThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_EXCEPTION(filter->Update()); - FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); + const FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); filter->SetCalculator(calculator); ITK_TEST_SET_GET_VALUE(calculator, filter->GetCalculator()); @@ -96,8 +96,8 @@ itkRenyiEntropyThresholdImageFilterTest(int argc, char * argv[]) // Regression test: compare computed threshold - auto expectedThreshold = static_cast(std::stod(argv[5])); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + auto expectedThreshold = static_cast(std::stod(argv[5])); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkShanbhagMaskedThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkShanbhagMaskedThresholdImageFilterTest.cxx index 61a5838c9d0..fb1edae8e5e 100644 --- a/Modules/Filtering/Thresholding/test/itkShanbhagMaskedThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkShanbhagMaskedThresholdImageFilterTest.cxx @@ -64,7 +64,7 @@ itkShanbhagMaskedThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::ShanbhagThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, ShanbhagThresholdImageFilter, HistogramThresholdImageFilter); @@ -77,7 +77,7 @@ itkShanbhagMaskedThresholdImageFilterTest(int argc, char * argv[]) filter->SetOutsideValue(outsideValue); ITK_TEST_SET_GET_VALUE(outsideValue, filter->GetOutsideValue()); - bool maskOutput = static_cast(std::stoi(argv[4])); + const bool maskOutput = static_cast(std::stoi(argv[4])); ITK_TEST_SET_GET_BOOLEAN(filter, MaskOutput, maskOutput); auto maskValue = static_cast(std::stod(argv[5])); @@ -93,8 +93,8 @@ itkShanbhagMaskedThresholdImageFilterTest(int argc, char * argv[]) // Regression test: compare computed threshold - FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + const FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkShanbhagThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkShanbhagThresholdImageFilterTest.cxx index fdc4bda4038..d7826c02d8f 100644 --- a/Modules/Filtering/Thresholding/test/itkShanbhagThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkShanbhagThresholdImageFilterTest.cxx @@ -56,7 +56,7 @@ itkShanbhagThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::ShanbhagThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, ShanbhagThresholdImageFilter, HistogramThresholdImageFilter); @@ -87,7 +87,7 @@ itkShanbhagThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_EXCEPTION(filter->Update()); - FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); + const FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); filter->SetCalculator(calculator); ITK_TEST_SET_GET_VALUE(calculator, filter->GetCalculator()); @@ -96,8 +96,8 @@ itkShanbhagThresholdImageFilterTest(int argc, char * argv[]) // Regression test: compare computed threshold - auto expectedThreshold = static_cast(std::stod(argv[5])); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + auto expectedThreshold = static_cast(std::stod(argv[5])); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkThresholdImageFilterTest.cxx index 3ca7935e07c..46e026602e1 100644 --- a/Modules/Filtering/Thresholding/test/itkThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkThresholdImageFilterTest.cxx @@ -142,29 +142,29 @@ itkThresholdImageFilterTest(int, char *[]) input->SetSpacing(inputSpacing); IntImage1DType::PointValueType inputOrigin[1] = { 15 }; input->SetOrigin(inputOrigin); - IntImage1DType::SizeValueType inputSize = 1; - IntImage1DType::RegionType inputRegion; + const IntImage1DType::SizeValueType inputSize = 1; + IntImage1DType::RegionType inputRegion; inputRegion.SetSize(0, inputSize); input->SetRegions(inputRegion); input->Allocate(); // The inputValue can be any random value. - PixelType inputValue = 9; + const PixelType inputValue = 9; input->FillBuffer(inputValue); itk::ThresholdImageFilter::Pointer threshold; threshold = itk::ThresholdImageFilter::New(); threshold->SetInput(input); - PixelType outsideValue = 99; + const PixelType outsideValue = 99; threshold->SetOutsideValue(outsideValue); ITK_TEST_SET_GET_VALUE(outsideValue, threshold->GetOutsideValue()); - IntImage1DType::IndexType index{}; + const IntImage1DType::IndexType index{}; - PixelType lower = itk::NumericTraits::NonpositiveMin(); + const PixelType lower = itk::NumericTraits::NonpositiveMin(); threshold->SetLower(lower); ITK_TEST_SET_GET_VALUE(lower, threshold->GetLower()); - PixelType upper = itk::NumericTraits::max(); + const PixelType upper = itk::NumericTraits::max(); threshold->SetUpper(upper); ITK_TEST_SET_GET_VALUE(upper, threshold->GetUpper()); diff --git a/Modules/Filtering/Thresholding/test/itkThresholdLabelerImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkThresholdLabelerImageFilterTest.cxx index 189007516e2..311569f9dd9 100644 --- a/Modules/Filtering/Thresholding/test/itkThresholdLabelerImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkThresholdLabelerImageFilterTest.cxx @@ -67,7 +67,7 @@ ThresholdLabelerImageFilterTestHelper(bool useRealTypeThresholds) values.push_back(3.5); // Set the value for the offset - unsigned long offset = 4; + const unsigned long offset = 4; // Set the labels vector std::vector labels; diff --git a/Modules/Filtering/Thresholding/test/itkTriangleMaskedThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkTriangleMaskedThresholdImageFilterTest.cxx index 8f9ff0fd659..d78913a71d0 100644 --- a/Modules/Filtering/Thresholding/test/itkTriangleMaskedThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkTriangleMaskedThresholdImageFilterTest.cxx @@ -64,7 +64,7 @@ itkTriangleMaskedThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::TriangleThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, TriangleThresholdImageFilter, HistogramThresholdImageFilter); @@ -77,7 +77,7 @@ itkTriangleMaskedThresholdImageFilterTest(int argc, char * argv[]) filter->SetOutsideValue(outsideValue); ITK_TEST_SET_GET_VALUE(outsideValue, filter->GetOutsideValue()); - bool maskOutput = static_cast(std::stoi(argv[4])); + const bool maskOutput = static_cast(std::stoi(argv[4])); ITK_TEST_SET_GET_BOOLEAN(filter, MaskOutput, maskOutput); auto maskValue = static_cast(std::stod(argv[5])); @@ -93,8 +93,8 @@ itkTriangleMaskedThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); // Regression test: compare computed threshold - FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + const FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkTriangleThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkTriangleThresholdImageFilterTest.cxx index 2a54a010753..0af102f0733 100644 --- a/Modules/Filtering/Thresholding/test/itkTriangleThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkTriangleThresholdImageFilterTest.cxx @@ -54,7 +54,7 @@ itkTriangleThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::TriangleThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, TriangleThresholdImageFilter, HistogramThresholdImageFilter); @@ -85,7 +85,7 @@ itkTriangleThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_EXCEPTION(filter->Update()); - FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); + const FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); filter->SetCalculator(calculator); ITK_TEST_SET_GET_VALUE(calculator, filter->GetCalculator()); @@ -94,8 +94,8 @@ itkTriangleThresholdImageFilterTest(int argc, char * argv[]) // Regression test: compare computed threshold - auto expectedThreshold = static_cast(std::stod(argv[5])); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + auto expectedThreshold = static_cast(std::stod(argv[5])); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkYenMaskedThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkYenMaskedThresholdImageFilterTest.cxx index 5da05e272b1..b8334539050 100644 --- a/Modules/Filtering/Thresholding/test/itkYenMaskedThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkYenMaskedThresholdImageFilterTest.cxx @@ -64,7 +64,7 @@ itkYenMaskedThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::YenThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, YenThresholdImageFilter, HistogramThresholdImageFilter); @@ -77,7 +77,7 @@ itkYenMaskedThresholdImageFilterTest(int argc, char * argv[]) filter->SetOutsideValue(outsideValue); ITK_TEST_SET_GET_VALUE(outsideValue, filter->GetOutsideValue()); - bool maskOutput = static_cast(std::stoi(argv[4])); + const bool maskOutput = static_cast(std::stoi(argv[4])); ITK_TEST_SET_GET_BOOLEAN(filter, MaskOutput, maskOutput); auto maskValue = static_cast(std::stod(argv[5])); @@ -93,8 +93,8 @@ itkYenMaskedThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); // Regression test: compare computed threshold - FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + const FilterType::InputPixelType expectedThreshold = std::stod(argv[6]); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/Filtering/Thresholding/test/itkYenThresholdImageFilterTest.cxx b/Modules/Filtering/Thresholding/test/itkYenThresholdImageFilterTest.cxx index 13d2be3ea32..6fbdcb14dab 100644 --- a/Modules/Filtering/Thresholding/test/itkYenThresholdImageFilterTest.cxx +++ b/Modules/Filtering/Thresholding/test/itkYenThresholdImageFilterTest.cxx @@ -56,7 +56,7 @@ itkYenThresholdImageFilterTest(int argc, char * argv[]) using FilterType = itk::YenThresholdImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, YenThresholdImageFilter, HistogramThresholdImageFilter); @@ -87,7 +87,7 @@ itkYenThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_EXCEPTION(filter->Update()); - FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); + const FilterType::CalculatorType::Pointer calculator = FilterType::CalculatorType::New(); filter->SetCalculator(calculator); ITK_TEST_SET_GET_VALUE(calculator, filter->GetCalculator()); @@ -95,8 +95,8 @@ itkYenThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); // Regression test: compare computed threshold - auto expectedThreshold = static_cast(std::stod(argv[5])); - FilterType::InputPixelType resultThreshold = filter->GetThreshold(); + auto expectedThreshold = static_cast(std::stod(argv[5])); + const FilterType::InputPixelType resultThreshold = filter->GetThreshold(); if (itk::Math::NotAlmostEquals(expectedThreshold, resultThreshold)) { std::cerr << "Test failed!" << std::endl; diff --git a/Modules/IO/BMP/src/itkBMPImageIO.cxx b/Modules/IO/BMP/src/itkBMPImageIO.cxx index 65edec47b4f..2d353151ccf 100644 --- a/Modules/IO/BMP/src/itkBMPImageIO.cxx +++ b/Modules/IO/BMP/src/itkBMPImageIO.cxx @@ -56,7 +56,7 @@ bool BMPImageIO::CanReadFile(const char * filename) { // First check the filename - std::string fname = filename; + const std::string fname = filename; if (fname.empty()) { @@ -64,7 +64,7 @@ BMPImageIO::CanReadFile(const char * filename) } - bool extensionFound = this->HasSupportedReadExtension(filename, false); + const bool extensionFound = this->HasSupportedReadExtension(filename, false); if (!extensionFound) { @@ -96,7 +96,7 @@ BMPImageIO::CanReadFile(const char * filename) // get the size of the file - ::size_t sizeLong = sizeof(long); + const size_t sizeLong = sizeof(long); if (sizeLong == 4) { long tmp; @@ -134,7 +134,7 @@ BMPImageIO::CanReadFile(const char * filename) int iinfoSize; // in case we are on a 64bit machine inputStream.read((char *)&iinfoSize, 4); ByteSwapper::SwapFromSystemToLittleEndian(&iinfoSize); - long infoSize = iinfoSize; + const long infoSize = iinfoSize; // error checking if ((infoSize != 40) && (infoSize != 12)) @@ -151,14 +151,14 @@ BMPImageIO::CanReadFile(const char * filename) bool BMPImageIO::CanWriteFile(const char * name) { - std::string filename = name; + const std::string filename = name; if (filename.empty()) { itkDebugMacro("No filename specified."); } - bool extensionFound = this->HasSupportedWriteExtension(name, false); + const bool extensionFound = this->HasSupportedWriteExtension(name, false); if (!extensionFound) { @@ -191,9 +191,9 @@ BMPImageIO::Read(void * buffer) SizeValueType line = m_Dimensions[1] - 1; for (unsigned int i = 0; i < m_BMPDataSize; ++i) { - unsigned char byte1 = value[i]; + const unsigned char byte1 = value[i]; ++i; - unsigned char byte2 = value[i]; + const unsigned char byte2 = value[i]; if (byte1 == 0) { if (byte2 == 0) @@ -212,9 +212,9 @@ BMPImageIO::Read(void * buffer) { // Delta ++i; - unsigned char dx = value[i]; + const unsigned char dx = value[i]; ++i; - unsigned char dy = value[i]; + const unsigned char dy = value[i]; posLine += dx; line -= dy; continue; @@ -227,7 +227,7 @@ BMPImageIO::Read(void * buffer) for (unsigned long j = 0; j < byte2; ++j) { ++i; - RGBPixelType rgb = this->GetColorPaletteEntry(value[i]); + const RGBPixelType rgb = this->GetColorPaletteEntry(value[i]); l = 3 * (line * m_Dimensions[0] + posLine); p[l] = rgb.GetBlue(); p[l + 1] = rgb.GetGreen(); @@ -257,7 +257,7 @@ BMPImageIO::Read(void * buffer) // Encoded run if (!this->GetIsReadAsScalarPlusPalette()) { - RGBPixelType rgb = this->GetColorPaletteEntry(byte2); + const RGBPixelType rgb = this->GetColorPaletteEntry(byte2); for (unsigned long j = 0; j < byte1; ++j) { l = 3 * (line * m_Dimensions[0] + posLine); @@ -283,9 +283,9 @@ BMPImageIO::Read(void * buffer) { // File is not compressed // Read one row at a time - long streamRead = m_Dimensions[0] * m_Depth / 8; - long paddedStreamRead = streamRead; - unsigned long step = this->GetNumberOfComponents(); + const long streamRead = m_Dimensions[0] * m_Depth / 8; + long paddedStreamRead = streamRead; + const unsigned long step = this->GetNumberOfComponents(); if (streamRead % 4) { paddedStreamRead = ((streamRead / 4) + 1) * 4; @@ -324,7 +324,7 @@ BMPImageIO::Read(void * buffer) } else { - RGBPixelType rgb = this->GetColorPaletteEntry(value[i]); + const RGBPixelType rgb = this->GetColorPaletteEntry(value[i]); p[l++] = rgb.GetBlue(); p[l++] = rgb.GetGreen(); p[l++] = rgb.GetRed(); @@ -360,7 +360,7 @@ BMPImageIO::ReadImageInformation() } // get the size of the file - ::size_t sizeLong = sizeof(long); + const size_t sizeLong = sizeof(long); if (sizeLong == 4) { long tmp; @@ -708,7 +708,7 @@ BMPImageIO::WriteImageInformation() void BMPImageIO::Write(const void * buffer) { - unsigned int nDims = this->GetNumberOfDimensions(); + const unsigned int nDims = this->GetNumberOfDimensions(); if (nDims != 2) { @@ -862,7 +862,7 @@ BMPImageIO::Write(const void * buffer) { for (unsigned int n = 0; n < 256; ++n) { - char tmp2 = static_cast(n); + const char tmp2 = static_cast(n); m_Ofstream.write(&tmp2, sizeof(char)); m_Ofstream.write(&tmp2, sizeof(char)); m_Ofstream.write(&tmp2, sizeof(char)); diff --git a/Modules/IO/BMP/test/itkBMPImageIOTest.cxx b/Modules/IO/BMP/test/itkBMPImageIOTest.cxx index 4f4b361404a..698be812428 100644 --- a/Modules/IO/BMP/test/itkBMPImageIOTest.cxx +++ b/Modules/IO/BMP/test/itkBMPImageIOTest.cxx @@ -38,7 +38,7 @@ itkBMPImageIOTest(int argc, char * argv[]) using PixelType = itk::RGBPixel; using ImageType = itk::Image; - itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); reader->SetFileName(argv[1]); @@ -52,11 +52,11 @@ itkBMPImageIOTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); - ImageType::Pointer image = reader->GetOutput(); + const ImageType::Pointer image = reader->GetOutput(); image->Print(std::cout); - ImageType::RegionType region = image->GetLargestPossibleRegion(); + const ImageType::RegionType region = image->GetLargestPossibleRegion(); std::cout << "LargestPossibleRegion " << region; // Print the IO diff --git a/Modules/IO/BMP/test/itkBMPImageIOTest2.cxx b/Modules/IO/BMP/test/itkBMPImageIOTest2.cxx index 4e460c777b0..4af743514b5 100644 --- a/Modules/IO/BMP/test/itkBMPImageIOTest2.cxx +++ b/Modules/IO/BMP/test/itkBMPImageIOTest2.cxx @@ -54,12 +54,12 @@ itkBMPImageIOTest2(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); - ImageType::Pointer image = reader->GetOutput(); + const ImageType::Pointer image = reader->GetOutput(); image->Print(std::cout); - ImageType::RegionType region = image->GetLargestPossibleRegion(); + const ImageType::RegionType region = image->GetLargestPossibleRegion(); std::cout << "LargestPossibleRegion " << region; // Print the IO diff --git a/Modules/IO/BMP/test/itkBMPImageIOTest3.cxx b/Modules/IO/BMP/test/itkBMPImageIOTest3.cxx index 675edc88846..10c7bf65b0c 100644 --- a/Modules/IO/BMP/test/itkBMPImageIOTest3.cxx +++ b/Modules/IO/BMP/test/itkBMPImageIOTest3.cxx @@ -48,7 +48,7 @@ itkBMPImageIOTest3(int argc, char * argv[]) auto lowerLeftImageReader = ReaderType::New(); - itk::BMPImageIO::Pointer lowerLeftImageIO = itk::BMPImageIO::New(); + const itk::BMPImageIO::Pointer lowerLeftImageIO = itk::BMPImageIO::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(lowerLeftImageIO, BMPImageIO, ImageIOBase); @@ -57,7 +57,7 @@ itkBMPImageIOTest3(int argc, char * argv[]) auto upperLeftImageReader = ReaderType::New(); - itk::BMPImageIO::Pointer upperLeftImageIO = itk::BMPImageIO::New(); + const itk::BMPImageIO::Pointer upperLeftImageIO = itk::BMPImageIO::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(lowerLeftImageIO, BMPImageIO, ImageIOBase); @@ -84,8 +84,8 @@ itkBMPImageIOTest3(int argc, char * argv[]) } - ImageType::RegionType loweLeftImageRegion = lowerLeftImageReader->GetOutput()->GetLargestPossibleRegion(); - ImageType::RegionType upperLeftImageRegion = upperLeftImageReader->GetOutput()->GetLargestPossibleRegion(); + const ImageType::RegionType loweLeftImageRegion = lowerLeftImageReader->GetOutput()->GetLargestPossibleRegion(); + const ImageType::RegionType upperLeftImageRegion = upperLeftImageReader->GetOutput()->GetLargestPossibleRegion(); if (loweLeftImageRegion != upperLeftImageRegion) { diff --git a/Modules/IO/BMP/test/itkBMPImageIOTest4.cxx b/Modules/IO/BMP/test/itkBMPImageIOTest4.cxx index 0c19b419228..76ec3666ddd 100644 --- a/Modules/IO/BMP/test/itkBMPImageIOTest4.cxx +++ b/Modules/IO/BMP/test/itkBMPImageIOTest4.cxx @@ -50,7 +50,7 @@ itkBMPImageIOTest4(int argc, char * argv[]) auto lowerLeftImageReader = ReaderType::New(); - itk::BMPImageIO::Pointer lowerLeftImageIO = itk::BMPImageIO::New(); + const itk::BMPImageIO::Pointer lowerLeftImageIO = itk::BMPImageIO::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(lowerLeftImageIO, BMPImageIO, ImageIOBase); @@ -59,7 +59,7 @@ itkBMPImageIOTest4(int argc, char * argv[]) auto upperLeftImageReader = ReaderType::New(); - itk::BMPImageIO::Pointer upperLeftImageIO = itk::BMPImageIO::New(); + const itk::BMPImageIO::Pointer upperLeftImageIO = itk::BMPImageIO::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(lowerLeftImageIO, BMPImageIO, ImageIOBase); @@ -86,8 +86,8 @@ itkBMPImageIOTest4(int argc, char * argv[]) } - ImageType::RegionType lowerLeftImageRegion = lowerLeftImageReader->GetOutput()->GetLargestPossibleRegion(); - ImageType::RegionType upperLeftImageRegion = upperLeftImageReader->GetOutput()->GetLargestPossibleRegion(); + const ImageType::RegionType lowerLeftImageRegion = lowerLeftImageReader->GetOutput()->GetLargestPossibleRegion(); + const ImageType::RegionType upperLeftImageRegion = upperLeftImageReader->GetOutput()->GetLargestPossibleRegion(); if (lowerLeftImageRegion != upperLeftImageRegion) { diff --git a/Modules/IO/BMP/test/itkBMPImageIOTest5.cxx b/Modules/IO/BMP/test/itkBMPImageIOTest5.cxx index 99f0227f06e..63dc9edd080 100644 --- a/Modules/IO/BMP/test/itkBMPImageIOTest5.cxx +++ b/Modules/IO/BMP/test/itkBMPImageIOTest5.cxx @@ -51,7 +51,7 @@ itkBMPImageIOTest5(int argc, char * argv[]) auto compressedImageReader = ReaderType::New(); - itk::BMPImageIO::Pointer compressedImageIO = itk::BMPImageIO::New(); + const itk::BMPImageIO::Pointer compressedImageIO = itk::BMPImageIO::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(compressedImageIO, BMPImageIO, ImageIOBase); @@ -61,7 +61,7 @@ itkBMPImageIOTest5(int argc, char * argv[]) auto uncompressedImageReader = ReaderType::New(); - itk::BMPImageIO::Pointer uncompressedImageIO = itk::BMPImageIO::New(); + const itk::BMPImageIO::Pointer uncompressedImageIO = itk::BMPImageIO::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(uncompressedImageIO, BMPImageIO, ImageIOBase); @@ -121,8 +121,9 @@ itkBMPImageIOTest5(int argc, char * argv[]) } - ImageType::RegionType compressedImageRegion = compressedImageReader->GetOutput()->GetLargestPossibleRegion(); - ImageType::RegionType uncompressedImageRegion = uncompressedImageReader->GetOutput()->GetLargestPossibleRegion(); + const ImageType::RegionType compressedImageRegion = compressedImageReader->GetOutput()->GetLargestPossibleRegion(); + const ImageType::RegionType uncompressedImageRegion = + uncompressedImageReader->GetOutput()->GetLargestPossibleRegion(); if (compressedImageRegion != uncompressedImageRegion) { diff --git a/Modules/IO/BMP/test/itkBMPImageIOTestPalette.cxx b/Modules/IO/BMP/test/itkBMPImageIOTestPalette.cxx index b9a3d45d6cd..7c0ca84bdd1 100644 --- a/Modules/IO/BMP/test/itkBMPImageIOTestPalette.cxx +++ b/Modules/IO/BMP/test/itkBMPImageIOTestPalette.cxx @@ -60,7 +60,7 @@ itkBMPImageIOTestPalette(int argc, char * argv[]) ITK_TEST_SET_GET_BOOLEAN(io, ExpandRGBPalette, expandRGBPalette); // Exercise exception cases - size_t sizeOfActualIORegion = + const size_t sizeOfActualIORegion = io->GetIORegion().GetNumberOfPixels() * (io->GetComponentSize() * io->GetNumberOfComponents()); auto * loadBuffer = new char[sizeOfActualIORegion]; @@ -163,7 +163,7 @@ itkBMPImageIOTestPalette(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update()); // Exercise other methods - itk::ImageIOBase::SizeType pixelStride = io->GetPixelStride(); + const itk::ImageIOBase::SizeType pixelStride = io->GetPixelStride(); std::cout << "PixelStride: " << itk::NumericTraits::PrintType(pixelStride) << std::endl; // ToDo diff --git a/Modules/IO/BioRad/src/itkBioRadImageIO.cxx b/Modules/IO/BioRad/src/itkBioRadImageIO.cxx index 909761d03bc..b6320a06568 100644 --- a/Modules/IO/BioRad/src/itkBioRadImageIO.cxx +++ b/Modules/IO/BioRad/src/itkBioRadImageIO.cxx @@ -132,8 +132,8 @@ BioRadImageIO::~BioRadImageIO() = default; bool BioRadImageIO::CanReadFile(const char * filename) { - std::ifstream file; - std::string fname(filename); + std::ifstream file; + const std::string fname(filename); if (fname.empty()) { @@ -142,7 +142,7 @@ BioRadImageIO::CanReadFile(const char * filename) } - bool extensionFound = this->HasSupportedReadExtension(filename, false); + const bool extensionFound = this->HasSupportedReadExtension(filename, false); if (!extensionFound) { @@ -311,7 +311,7 @@ BioRadImageIO::InternalReadImageInformation(std::ifstream & file) if (note.type == NOTE_TYPE_VARIABLE) { punt = false; - std::string note_text(note.text); + const std::string note_text(note.text); std::istringstream ss(note_text); std::string label; ss >> label; @@ -375,7 +375,7 @@ BioRadImageIO::ReadImageInformation() bool BioRadImageIO::CanWriteFile(const char * name) { - std::string filename = name; + const std::string filename = name; if (filename.empty()) { @@ -383,7 +383,7 @@ BioRadImageIO::CanWriteFile(const char * name) return false; } - bool extensionFound = this->HasSupportedWriteExtension(name, false); + const bool extensionFound = this->HasSupportedWriteExtension(name, false); if (!extensionFound) { @@ -402,7 +402,7 @@ BioRadImageIO::Write(const void * buffer) this->OpenFileForWriting(file, m_FileName); // Check the image region for proper dimensions, etc. - unsigned int numDims = this->GetNumberOfDimensions(); + const unsigned int numDims = this->GetNumberOfDimensions(); if (numDims != 3 && numDims != 2) { itkExceptionMacro("BioRad Writer can only write 2 or 3-dimensional images"); @@ -469,7 +469,7 @@ BioRadImageIO::Write(const void * buffer) // 3. FileName.pic // or simply // 4. FileName - std::string filename = itksys::SystemTools::GetFilenameName(m_FileName); + const std::string filename = itksys::SystemTools::GetFilenameName(m_FileName); // The buffer is at most 32 bytes, but must be null-terminated. // Here we copy at most 31 bytes and terminate it explicitly strncpy(header.filename, filename.c_str(), sizeof(header.filename) - 1); diff --git a/Modules/IO/Bruker/src/itkBruker2dseqImageIO.cxx b/Modules/IO/Bruker/src/itkBruker2dseqImageIO.cxx index cc2c86cba83..d0615b8dfa5 100644 --- a/Modules/IO/Bruker/src/itkBruker2dseqImageIO.cxx +++ b/Modules/IO/Bruker/src/itkBruker2dseqImageIO.cxx @@ -64,7 +64,7 @@ Rescale(T * buffer, { for (SizeType v = 0; v < frameSize; ++v, ++i) { - double tmp = static_cast(buffer[i]) * slopes[f] + offsets[f]; + const double tmp = static_cast(buffer[i]) * slopes[f] + offsets[f]; buffer[i] = static_cast(tmp); } } @@ -195,14 +195,14 @@ ReadJCAMPDX(const std::string & filename, MetaDataDictionary & dict) itkGenericExceptionMacro("Failed to parse Bruker JCAMPDX: " + line); } - std::string::size_type epos = line.find('=', 3); + const std::string::size_type epos = line.find('=', 3); if (epos == std::string::npos) { itkGenericExceptionMacro("Invalid Bruker JCAMPDX parameter line (Missing =): " << line); } - std::string parname = line.substr(3, epos - 3); - std::string par = line.substr(epos + 1); + const std::string parname = line.substr(3, epos - 3); + std::string par = line.substr(epos + 1); if (par[0] == '(') { // Array value @@ -227,7 +227,7 @@ ReadJCAMPDX(const std::string & filename, MetaDataDictionary & dict) std::vector stringArray; while (left != std::string::npos) { - std::string::size_type right = lines.find('>', left + 1); + const std::string::size_type right = lines.find('>', left + 1); stringArray.push_back(lines.substr(left + 1, right - (left + 1))); left = lines.find('<', right + 1); } @@ -545,12 +545,12 @@ Bruker2dseqImageIO::Read(void * buffer) this->SwapBytesIfNecessary(charBuffer, numberOfComponents); } - MetaDataDictionary & dict = this->GetMetaDataDictionary(); - const std::vector slopes = GetParameter>(dict, "VisuCoreDataSlope"); - const std::vector offsets = GetParameter>(dict, "VisuCoreDataOffs"); - const SizeType frameCount = static_cast(GetParameter(dict, "VisuCoreFrameCount")); - const SizeType frameDim = static_cast(GetParameter(dict, "VisuCoreDim")); - SizeType frameSize = this->GetDimensions(0) * this->GetDimensions(1); + const MetaDataDictionary & dict = this->GetMetaDataDictionary(); + const std::vector slopes = GetParameter>(dict, "VisuCoreDataSlope"); + const std::vector offsets = GetParameter>(dict, "VisuCoreDataOffs"); + const SizeType frameCount = static_cast(GetParameter(dict, "VisuCoreFrameCount")); + const SizeType frameDim = static_cast(GetParameter(dict, "VisuCoreDim")); + SizeType frameSize = this->GetDimensions(0) * this->GetDimensions(1); if (frameDim == 3) { @@ -698,7 +698,7 @@ Bruker2dseqImageIO::CanReadFile(const char * FileNameToRead) { std::string file2Dseq = itksys::SystemTools::CollapseFullPath(FileNameToRead); itksys::SystemTools::ConvertToUnixSlashes(file2Dseq); - std::string fileVisu = itksys::SystemTools::GetFilenamePath(file2Dseq) + "/visu_pars"; + const std::string fileVisu = itksys::SystemTools::GetFilenamePath(file2Dseq) + "/visu_pars"; if (!itksys::SystemTools::FileExists(file2Dseq)) { @@ -720,12 +720,12 @@ Bruker2dseqImageIO::ReadImageInformation() std::string path2Dseq = itksys::SystemTools::CollapseFullPath(this->m_FileName); itksys::SystemTools::ConvertToUnixSlashes(path2Dseq); - std::string pathVisu = itksys::SystemTools::GetFilenamePath(path2Dseq) + "/visu_pars"; + const std::string pathVisu = itksys::SystemTools::GetFilenamePath(path2Dseq) + "/visu_pars"; ReadJCAMPDX(pathVisu, dict); // If the method file exists, read it in case user wants the meta-data // However, visu_pars contains everything needed to read so make this optional - std::string methodFilename = itksys::SystemTools::GetFilenamePath(path2Dseq) + "/../../method"; + const std::string methodFilename = itksys::SystemTools::GetFilenamePath(path2Dseq) + "/../../method"; if (itksys::SystemTools::FileExists(methodFilename)) { ReadJCAMPDX(methodFilename, dict); @@ -828,9 +828,9 @@ Bruker2dseqImageIO::ReadImageInformation() // You would think that we could use the SliceDist field for multi-slice, but ParaVision // has a bug that sometimes sets SliceDist to 0 // So - calculate this manually from the SlicePosition field - vnl_vector slice1(&position[0], 3); - vnl_vector slice2(&position[3], 3); - vnl_vector diff = slice2 - slice1; + const vnl_vector slice1(&position[0], 3); + const vnl_vector slice2(&position[3], 3); + const vnl_vector diff = slice2 - slice1; spacingZ = diff.magnitude(); } if (dict.HasKey("VisuFGOrderDesc")) @@ -859,9 +859,9 @@ Bruker2dseqImageIO::ReadImageInformation() // The acquisition orientation is not stored in visu_pars so work out if // this is coronal by checking if the Y component of the slice positions is // changing. - vnl_vector corner1(&position[0], 3); - vnl_vector corner2(&position[3], 3); - vnl_vector diff = corner2 - corner1; + const vnl_vector corner1(&position[0], 3); + const vnl_vector corner2(&position[3], 3); + vnl_vector diff = corner2 - corner1; if (diff[1] != 0) { reverseZ = -1; @@ -903,15 +903,15 @@ Bruker2dseqImageIO::ReadImageInformation() // equivalent to a matrix transpose, which because these are direction // matrices with determinant +/-1, is equivalent to an inverse. So this // gives the correct orientations. - vnl_matrix dirMatrix(&orient[0], 3, 3); + const vnl_matrix dirMatrix(&orient[0], 3, 3); this->SetDirection(0, dirMatrix.get_row(0)); this->SetDirection(1, dirMatrix.get_row(1)); // See note above for apparent bug in 2D coronal acquisitions this->SetDirection(2, reverseZ * dirMatrix.get_row(2)); // Now work out the correct ITK origin including the half-voxel offset - vnl_vector corner(&position[0], 3); - vnl_vector origin = corner + dirMatrix * halfStep; + const vnl_vector corner(&position[0], 3); + vnl_vector origin = corner + dirMatrix * halfStep; this->SetOrigin(0, origin[0]); this->SetOrigin(1, origin[1]); diff --git a/Modules/IO/Bruker/test/itkBrukerImageTest.cxx b/Modules/IO/Bruker/test/itkBrukerImageTest.cxx index 8629e90d2a3..874c5ac8f40 100644 --- a/Modules/IO/Bruker/test/itkBrukerImageTest.cxx +++ b/Modules/IO/Bruker/test/itkBrukerImageTest.cxx @@ -42,12 +42,12 @@ itkBrukerImageTest(int argc, char * argv[]) itk::Bruker2dseqImageIOFactory::RegisterOneFactory(); - itk::Bruker2dseqImageIO::Pointer brukerImageIO = itk::Bruker2dseqImageIO::New(); + const itk::Bruker2dseqImageIO::Pointer brukerImageIO = itk::Bruker2dseqImageIO::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(brukerImageIO, Bruker2dseqImageIO, ImageIOBase); const char * inputFilename = argv[1]; - bool canReadFile = brukerImageIO->CanReadFile(inputFilename); + const bool canReadFile = brukerImageIO->CanReadFile(inputFilename); if (canReadFile) { using ReaderType = itk::ImageFileReader; diff --git a/Modules/IO/CSV/include/itkCSVArray2DDataObject.hxx b/Modules/IO/CSV/include/itkCSVArray2DDataObject.hxx index 83cf39585ed..e919ac47876 100644 --- a/Modules/IO/CSV/include/itkCSVArray2DDataObject.hxx +++ b/Modules/IO/CSV/include/itkCSVArray2DDataObject.hxx @@ -81,13 +81,13 @@ template auto CSVArray2DDataObject::GetRow(const unsigned int row_index) const -> NumericVectorType { - NumericVectorType row; - unsigned int max_rows = this->m_Matrix.rows() - 1; + NumericVectorType row; + const unsigned int max_rows = this->m_Matrix.rows() - 1; if (row_index > max_rows) { itkExceptionMacro(" Row index: " << row_index << " exceeds matrix dimension: " << max_rows); } - unsigned int vector_size = this->m_Matrix.cols(); + const unsigned int vector_size = this->m_Matrix.cols(); for (unsigned int i = 0; i < vector_size; ++i) { row.push_back(this->m_Matrix[row_index][i]); @@ -99,8 +99,8 @@ template auto CSVArray2DDataObject::GetRow(const std::string & row_name) const -> NumericVectorType { - NumericVectorType row; - unsigned int index = this->GetRowIndexByName(row_name); + NumericVectorType row; + const unsigned int index = this->GetRowIndexByName(row_name); row = this->GetRow(index); return row; } @@ -109,13 +109,13 @@ template auto CSVArray2DDataObject::GetColumn(const unsigned int column_index) const -> NumericVectorType { - NumericVectorType column; - unsigned int max_columns = this->m_Matrix.columns() - 1; + NumericVectorType column; + const unsigned int max_columns = this->m_Matrix.columns() - 1; if (column_index > max_columns) { itkExceptionMacro("Column index: " << column_index << " exceeds matrix dimension: " << max_columns); } - unsigned int vector_size = this->m_Matrix.rows(); + const unsigned int vector_size = this->m_Matrix.rows(); for (unsigned int i = 0; i < vector_size; ++i) { column.push_back(this->m_Matrix[i][column_index]); @@ -127,8 +127,8 @@ template auto CSVArray2DDataObject::GetColumn(const std::string & column_name) const -> NumericVectorType { - NumericVectorType column; - unsigned int index = this->GetColumnIndexByName(column_name); + NumericVectorType column; + const unsigned int index = this->GetColumnIndexByName(column_name); column = this->GetColumn(index); return column; } @@ -153,8 +153,8 @@ template TData CSVArray2DDataObject::GetData(const std::string & row_name, const std::string & column_name) const { - unsigned int row_index = this->GetRowIndexByName(row_name); - unsigned int column_index = this->GetColumnIndexByName(column_name); + const unsigned int row_index = this->GetRowIndexByName(row_name); + const unsigned int column_index = this->GetColumnIndexByName(column_name); return this->GetData(row_index, column_index); } @@ -163,7 +163,7 @@ template TData CSVArray2DDataObject::GetRowData(const std::string & row_name, const unsigned int column_index) const { - unsigned int row_index = this->GetRowIndexByName(row_name); + const unsigned int row_index = this->GetRowIndexByName(row_name); return this->GetData(row_index, column_index); } @@ -171,7 +171,7 @@ template TData CSVArray2DDataObject::GetColumnData(const std::string & column_name, const unsigned int row_index) const { - unsigned int column_index = this->GetColumnIndexByName(column_name); + const unsigned int column_index = this->GetColumnIndexByName(column_name); return this->GetData(row_index, column_index); } diff --git a/Modules/IO/CSV/test/itkCSVArray2DFileReaderTest.cxx b/Modules/IO/CSV/test/itkCSVArray2DFileReaderTest.cxx index 250d79b9675..f0abde607f0 100644 --- a/Modules/IO/CSV/test/itkCSVArray2DFileReaderTest.cxx +++ b/Modules/IO/CSV/test/itkCSVArray2DFileReaderTest.cxx @@ -118,7 +118,7 @@ itkCSVArray2DFileReaderTest(int argc, char * argv[]) return EXIT_FAILURE; } - double nan = std::numeric_limits::quiet_NaN(); + const double nan = std::numeric_limits::quiet_NaN(); // Read and Parse the data using ReaderType = itk::CSVArray2DFileReader; @@ -168,11 +168,11 @@ itkCSVArray2DFileReaderTest(int argc, char * argv[]) reader->Print(std::cout); using DataFrameObjectType = itk::CSVArray2DDataObject; - DataFrameObjectType::Pointer dfo = reader->GetOutput(); + const DataFrameObjectType::Pointer dfo = reader->GetOutput(); // Test the matrix using MatrixType = itk::Array2D; - MatrixType test_matrix = dfo->GetMatrix(); + const MatrixType test_matrix = dfo->GetMatrix(); MatrixType matrix(4, 6); matrix[0][0] = nan; @@ -207,7 +207,7 @@ itkCSVArray2DFileReaderTest(int argc, char * argv[]) } // Test Row Names - std::vector test_row_names = dfo->GetRowHeaders(); + const std::vector test_row_names = dfo->GetRowHeaders(); std::vector row_names; row_names.emplace_back("Jan"); @@ -224,7 +224,7 @@ itkCSVArray2DFileReaderTest(int argc, char * argv[]) PrintVector(test_row_names); // Test Column Names - std::vector test_col_names = dfo->GetColumnHeaders(); + const std::vector test_col_names = dfo->GetColumnHeaders(); std::vector col_names; col_names.emplace_back("Africa"); @@ -242,7 +242,7 @@ itkCSVArray2DFileReaderTest(int argc, char * argv[]) // Test a row (using index access) - std::vector test_row_1 = dfo->GetRow(1); + const std::vector test_row_1 = dfo->GetRow(1); std::vector row_1; row_1.push_back(99); @@ -259,7 +259,7 @@ itkCSVArray2DFileReaderTest(int argc, char * argv[]) PrintVector(test_row_1); // Test a row (using string access) - std::vector test_row_Jan = dfo->GetRow("Jan"); + const std::vector test_row_Jan = dfo->GetRow("Jan"); std::vector row_Jan; row_Jan.push_back(nan); @@ -277,7 +277,7 @@ itkCSVArray2DFileReaderTest(int argc, char * argv[]) PrintVector(test_row_Jan); // Test a column (using index) - std::vector test_col_2 = dfo->GetColumn(2); + const std::vector test_col_2 = dfo->GetColumn(2); std::vector col_2; col_2.push_back(5); @@ -294,7 +294,7 @@ itkCSVArray2DFileReaderTest(int argc, char * argv[]) PrintVector(col_2); // Test a column (using string access) - std::vector test_col_Africa = dfo->GetColumn("Africa"); + const std::vector test_col_Africa = dfo->GetColumn("Africa"); std::vector col_Africa; col_Africa.push_back(nan); @@ -313,7 +313,7 @@ itkCSVArray2DFileReaderTest(int argc, char * argv[]) // Test a row that does not exist try { - std::vector test_row_Oct = dfo->GetRow("Oct"); + const std::vector test_row_Oct = dfo->GetRow("Oct"); if (!test_row_Oct.empty()) { std::cerr << "Row should be empty! Test Failed!"; @@ -329,7 +329,7 @@ itkCSVArray2DFileReaderTest(int argc, char * argv[]) try { // Test column that does not exist - std::vector test_col_Eur = dfo->GetColumn("Eur"); + const std::vector test_col_Eur = dfo->GetColumn("Eur"); if (!test_col_Eur.empty()) { std::cerr << "Column should be empty! Test Failed!"; @@ -399,7 +399,7 @@ itkCSVArray2DFileReaderTest(int argc, char * argv[]) try { - double test_item1 = dfo->GetData("Feb", "Europe"); + const double test_item1 = dfo->GetData("Feb", "Europe"); if (!testValue(test_item1, nan)) { std::cerr << "Wrong value! Test failed!"; diff --git a/Modules/IO/CSV/test/itkCSVArray2DFileReaderWriterTest.cxx b/Modules/IO/CSV/test/itkCSVArray2DFileReaderWriterTest.cxx index bdbd96f1bbe..0f0f6c6c3b7 100644 --- a/Modules/IO/CSV/test/itkCSVArray2DFileReaderWriterTest.cxx +++ b/Modules/IO/CSV/test/itkCSVArray2DFileReaderWriterTest.cxx @@ -46,8 +46,8 @@ testArray(const itk::Array2D & m1, const itk::Array2D & m2) // Without such a test, the comparison of the difference being greater than epsilon will pass. // The equality and inequality predicates are non-signaling so x = x returning false can be used to test if x is a // quiet NaN. - bool m1_isNaN = (itk::Math::ExactlyEquals(m1[i][j], m1[i][j])); - bool m2_isNaN = (itk::Math::ExactlyEquals(m2[i][j], m2[i][j])); + const bool m1_isNaN = (itk::Math::ExactlyEquals(m1[i][j], m1[i][j])); + const bool m2_isNaN = (itk::Math::ExactlyEquals(m2[i][j], m2[i][j])); if ((m1_isNaN && !m2_isNaN) || (!m1_isNaN && m2_isNaN)) { pass = false; @@ -66,7 +66,7 @@ testArray(const itk::Array2D & m1, const itk::Array2D & m2) int itkCSVFileReaderWriterTest_Func(int argc, char * argv[], bool headers) { - double nan = std::numeric_limits::quiet_NaN(); + const double nan = std::numeric_limits::quiet_NaN(); using MatrixType = itk::Array2D; constexpr unsigned int ARows = 3; @@ -157,8 +157,8 @@ itkCSVFileReaderWriterTest_Func(int argc, char * argv[], bool headers) reader->Print(std::cout); using DataFrameObjectType = itk::CSVArray2DDataObject; - DataFrameObjectType::Pointer dfo = reader->GetOutput(); - MatrixType test_matrix = dfo->GetMatrix(); + const DataFrameObjectType::Pointer dfo = reader->GetOutput(); + const MatrixType test_matrix = dfo->GetMatrix(); std::cout << "Actual array: " << std::endl; std::cout << matrix << std::endl; @@ -190,11 +190,11 @@ itkCSVArray2DFileReaderWriterTest(int argc, char * argv[]) // test reading and writing data without headers std::cout << std::endl << "Test Without Headers" << std::endl; - int fail1 = itkCSVFileReaderWriterTest_Func(argc, argv, false); + const int fail1 = itkCSVFileReaderWriterTest_Func(argc, argv, false); // test reading and writing data with headers std::cout << std::endl << "Test With Headers." << std::endl; - int fail2 = itkCSVFileReaderWriterTest_Func(argc, argv, true); + const int fail2 = itkCSVFileReaderWriterTest_Func(argc, argv, true); if (fail1 || fail2) { diff --git a/Modules/IO/CSV/test/itkCSVNumericObjectFileWriterTest.cxx b/Modules/IO/CSV/test/itkCSVNumericObjectFileWriterTest.cxx index 092c15a1311..664767c8ec1 100644 --- a/Modules/IO/CSV/test/itkCSVNumericObjectFileWriterTest.cxx +++ b/Modules/IO/CSV/test/itkCSVNumericObjectFileWriterTest.cxx @@ -29,7 +29,7 @@ itkCSVNumericObjectFileWriterTest(int argc, char * argv[]) return EXIT_FAILURE; } - double nan = std::numeric_limits::quiet_NaN(); + const double nan = std::numeric_limits::quiet_NaN(); constexpr unsigned int ARows = 3; constexpr unsigned int ACols = 6; @@ -84,7 +84,7 @@ itkCSVNumericObjectFileWriterTest(int argc, char * argv[]) return EXIT_FAILURE; } - std::string filename = argv[1]; + const std::string filename = argv[1]; array_writer->SetFileName(filename); // should throw an exception as there is no input object diff --git a/Modules/IO/GDCM/src/itkGDCMImageIO.cxx b/Modules/IO/GDCM/src/itkGDCMImageIO.cxx index db3878a4fe8..51a158088a8 100644 --- a/Modules/IO/GDCM/src/itkGDCMImageIO.cxx +++ b/Modules/IO/GDCM/src/itkGDCMImageIO.cxx @@ -330,7 +330,7 @@ GDCMImageIO::Read(void * pointer) image = icpc.GetOutput(); } - gdcm::PhotometricInterpretation pi = image.GetPhotometricInterpretation(); + const gdcm::PhotometricInterpretation pi = image.GetPhotometricInterpretation(); if (m_SingleBit) { @@ -406,8 +406,8 @@ GDCMImageIO::Read(void * pointer) r.SetIntercept(m_RescaleIntercept); r.SetSlope(m_RescaleSlope); r.SetPixelFormat(pixeltype); - gdcm::PixelFormat outputpt = r.ComputeInterceptSlopePixelType(); - const auto copy = make_unique_for_overwrite(len); + const gdcm::PixelFormat outputpt = r.ComputeInterceptSlopePixelType(); + const auto copy = make_unique_for_overwrite(len); memcpy(copy.get(), (char *)pointer, len); r.Rescale((char *)pointer, copy.get(), len); // WARNING: sizeof(Real World Value) != sizeof(Stored Pixel) @@ -647,14 +647,14 @@ GDCMImageIO::InternalReadImageInformation() case gdcm::MediaStorage::UltrasoundMultiFrameImageStorageRetired: { std::vector sp; - gdcm::Tag spacingTag(0x0028, 0x0030); + const gdcm::Tag spacingTag(0x0028, 0x0030); if (const gdcm::DataElement & de = ds.GetDataElement(spacingTag); !de.IsEmpty()) { std::stringstream m_Ss; gdcm::Element m_El; const gdcm::ByteValue * bv = de.GetByteValue(); assert(bv); - std::string s(bv->GetPointer(), bv->GetLength()); + const std::string s(bv->GetPointer(), bv->GetLength()); m_Ss.str(s); // Erroneous file CT-MONO2-8-abdo.dcm, // The spacing is something like that [0.2\0\0.200000], @@ -748,7 +748,7 @@ GDCMImageIO::InternalReadImageInformation() const gdcm::DataElement & ref = *it; const gdcm::Tag & tag = ref.GetTag(); // Compute VR from the toplevel file, and the currently processed dataset: - gdcm::VR vr = gdcm::DataSetHelper::ComputeVR(f, ds, tag); + const gdcm::VR vr = gdcm::DataSetHelper::ComputeVR(f, ds, tag); // Process binary field and encode them as mime64: only when we do not know // of any better @@ -776,7 +776,7 @@ GDCMImageIO::InternalReadImageInformation() static_cast(bv->GetLength()), (unsigned char *)bin.get(), 0)); - std::string encodedValue(bin.get(), encodedLengthActual); + const std::string encodedValue(bin.get(), encodedLengthActual); EncapsulateMetaData(dico, tag.PrintAsPipeSeparatedString(), encodedValue); } } @@ -801,7 +801,7 @@ GDCMImageIO::ReadImageInformation() bool GDCMImageIO::CanWriteFile(const char * name) { - std::string filename = name; + const std::string filename = name; if (filename.empty()) { @@ -859,15 +859,15 @@ GDCMImageIO::Write(const void * buffer) // currently ignored, same tag appears twice in the dictionary // once with comma separator and once with pipe. The last one // encountered is the one used to set the tag value. - gdcm::Tag tag; - bool b = tag.ReadFromPipeSeparatedString(key.c_str()) || tag.ReadFromCommaSeparatedString(key.c_str()); + gdcm::Tag tag; + const bool b = tag.ReadFromPipeSeparatedString(key.c_str()) || tag.ReadFromCommaSeparatedString(key.c_str()); // Anything that has been changed in the MetaData Dict will be pushed // into the DICOM header: if (b /*tag != gdcm::Tag(0xffff,0xffff)*/ /*dictEntry*/) { const gdcm::DictEntry & dictEntry = pubdict.GetDictEntry(tag); - gdcm::VR::VRType vrtype = dictEntry.GetVR(); + const gdcm::VR::VRType vrtype = dictEntry.GetVR(); if (dictEntry.GetVR() == gdcm::VR::SQ) { // How did we reach here ? @@ -1003,8 +1003,8 @@ GDCMImageIO::Write(const void * buffer) << problematicKeys[0] + std::accumulate(problematicKeys.begin() + 1, problematicKeys.end(), std::string(", "))); } - gdcm::SmartPointer simage = new gdcm::Image; - gdcm::Image & image = *simage; + const gdcm::SmartPointer simage = new gdcm::Image; + gdcm::Image & image = *simage; image.SetNumberOfDimensions(2); // good default image.SetDimension(0, static_cast(m_Dimensions[0])); image.SetDimension(1, static_cast(m_Dimensions[1])); @@ -1023,7 +1023,7 @@ GDCMImageIO::Write(const void * buffer) { double origin3D[3]; // save and reset old locale - std::locale currentLocale = std::locale::global(std::locale::classic()); + const std::locale currentLocale = std::locale::global(std::locale::classic()); sscanf(tempString.c_str(), "%lf\\%lf\\%lf", &(origin3D[0]), &(origin3D[1]), &(origin3D[2])); // reset locale std::locale::global(currentLocale); @@ -1058,7 +1058,7 @@ GDCMImageIO::Write(const void * buffer) { double directions[6]; // save and reset old locale - std::locale currentLocale = std::locale::global(std::locale::classic()); + const std::locale currentLocale = std::locale::global(std::locale::classic()); sscanf(tempString.c_str(), "%lf\\%lf\\%lf\\%lf\\%lf\\%lf", &(directions[0]), @@ -1099,7 +1099,7 @@ GDCMImageIO::Write(const void * buffer) image.SetDirectionCosines(5, 0); } } - gdcm::DirectionCosines gdcmDirection(image.GetDirectionCosines()); + const gdcm::DirectionCosines gdcmDirection(image.GetDirectionCosines()); if (!gdcmDirection.IsValid()) { itkExceptionMacro("Invalid direction cosines, non-orthogonal or unit length."); @@ -1323,7 +1323,7 @@ GDCMImageIO::Write(const void * buffer) itkExceptionMacro("Unknown compression type"); } change.SetInput(image); - bool b = change.Change(); + const bool b = change.Change(); if (!b) { itkExceptionMacro("Could not change the Transfer Syntax for Compression"); @@ -1393,7 +1393,7 @@ GDCMImageIO::Write(const void * buffer) bool GDCMImageIO::GetValueFromTag(const std::string & tag, std::string & value) { - MetaDataDictionary & dict = this->GetMetaDataDictionary(); + const MetaDataDictionary & dict = this->GetMetaDataDictionary(); std::string tag_lower = tag; std::transform(tag_lower.begin(), tag_lower.end(), tag_lower.begin(), static_cast(::tolower)); diff --git a/Modules/IO/GDCM/src/itkGDCMSeriesFileNames.cxx b/Modules/IO/GDCM/src/itkGDCMSeriesFileNames.cxx index 2051e99f797..04678dfcda9 100644 --- a/Modules/IO/GDCM/src/itkGDCMSeriesFileNames.cxx +++ b/Modules/IO/GDCM/src/itkGDCMSeriesFileNames.cxx @@ -40,7 +40,7 @@ GDCMSeriesFileNames::SetInputDirectory(const char * name) { itkExceptionMacro("SetInputDirectory() received a nullptr string"); } - std::string fname = name; + const std::string fname = name; this->SetInputDirectory(fname); } @@ -90,7 +90,7 @@ GDCMSeriesFileNames::GetSeriesUIDs() gdcm::File * file = (*flist)[0]; // for example take the first one // Create its unique series ID - std::string id = m_SerieHelper->CreateUniqueSeriesIdentifier(file).c_str(); + const std::string id = m_SerieHelper->CreateUniqueSeriesIdentifier(file).c_str(); m_SeriesUIDs.push_back(id.c_str()); } @@ -121,8 +121,8 @@ GDCMSeriesFileNames::GetFileNames(const std::string serie) { if (!flist->empty()) // make sure we have at leat one serie { - gdcm::File * file = (*flist)[0]; // for example take the first one - std::string id = m_SerieHelper->CreateUniqueSeriesIdentifier(file).c_str(); + gdcm::File * file = (*flist)[0]; // for example take the first one + const std::string id = m_SerieHelper->CreateUniqueSeriesIdentifier(file).c_str(); if (id == serie) { diff --git a/Modules/IO/GDCM/test/itkGDCMImageIO32bitsStoredTest.cxx b/Modules/IO/GDCM/test/itkGDCMImageIO32bitsStoredTest.cxx index 40f8649147a..0d6e3e997e3 100644 --- a/Modules/IO/GDCM/test/itkGDCMImageIO32bitsStoredTest.cxx +++ b/Modules/IO/GDCM/test/itkGDCMImageIO32bitsStoredTest.cxx @@ -41,8 +41,8 @@ itkGDCMImageIO32bitsStoredTest(int argc, char * argv[]) using ReaderType = itk::ImageFileReader; using ImageIOType = itk::GDCMImageIO; - auto dcmImageIO = ImageIOType::New(); - bool canRead = dcmImageIO->CanReadFile(argv[1]); + auto dcmImageIO = ImageIOType::New(); + const bool canRead = dcmImageIO->CanReadFile(argv[1]); std::cerr << "GDCM can read file: " << (canRead ? "yes" : "no") << std::endl; if (canRead) { diff --git a/Modules/IO/GDCM/test/itkGDCMImageIONoPreambleTest.cxx b/Modules/IO/GDCM/test/itkGDCMImageIONoPreambleTest.cxx index 04e8ec8dcf3..21495fafb55 100644 --- a/Modules/IO/GDCM/test/itkGDCMImageIONoPreambleTest.cxx +++ b/Modules/IO/GDCM/test/itkGDCMImageIONoPreambleTest.cxx @@ -41,8 +41,8 @@ itkGDCMImageIONoPreambleTest(int argc, char * argv[]) using ReaderType = itk::ImageFileReader; using ImageIOType = itk::GDCMImageIO; - auto dcmImageIO = ImageIOType::New(); - bool canRead = dcmImageIO->CanReadFile(argv[1]); + auto dcmImageIO = ImageIOType::New(); + const bool canRead = dcmImageIO->CanReadFile(argv[1]); if (!canRead) { std::cerr << "Cannot read file " << std::endl; diff --git a/Modules/IO/GDCM/test/itkGDCMImageIOTest.cxx b/Modules/IO/GDCM/test/itkGDCMImageIOTest.cxx index 10d712e7139..22b693da4ba 100644 --- a/Modules/IO/GDCM/test/itkGDCMImageIOTest.cxx +++ b/Modules/IO/GDCM/test/itkGDCMImageIOTest.cxx @@ -76,11 +76,11 @@ itkGDCMImageIOTest(int argc, char * argv[]) std::cout << "CompressionType: " << gdcmImageIO->GetCompressionType() << std::endl; // Test itk::GDCMImageIO::GetValueFromTag with upper and lower case tagkeys - std::string tagkeyLower = "0008|103e"; // Series Description - std::string valueFromLower; + const std::string tagkeyLower = "0008|103e"; // Series Description + std::string valueFromLower; gdcmImageIO->GetValueFromTag(tagkeyLower, valueFromLower); - std::string tagkeyUpper = "0008|103E"; // Series Description - std::string valueFromUpper; + const std::string tagkeyUpper = "0008|103E"; // Series Description + std::string valueFromUpper; gdcmImageIO->GetValueFromTag(tagkeyUpper, valueFromUpper); // We can't easily verify the content of the tag value against a known // baseline, as this test is run multiple times with different input images diff --git a/Modules/IO/GDCM/test/itkGDCMImageIOTest2.cxx b/Modules/IO/GDCM/test/itkGDCMImageIOTest2.cxx index 7f4d528c492..d594563df44 100644 --- a/Modules/IO/GDCM/test/itkGDCMImageIOTest2.cxx +++ b/Modules/IO/GDCM/test/itkGDCMImageIOTest2.cxx @@ -55,7 +55,7 @@ itkGDCMImageIOTest2(int argc, char * argv[]) return EXIT_FAILURE; } - itk::GDCMImageIO::Pointer dicomIO = itk::GDCMImageIO::New(); + const itk::GDCMImageIO::Pointer dicomIO = itk::GDCMImageIO::New(); // reader->GetOutput()->Print(std::cout); itk::MetaDataDictionary & dict = dicomIO->GetMetaDataDictionary(); @@ -78,8 +78,8 @@ itkGDCMImageIOTest2(int argc, char * argv[]) tagkey = "0020|1040"; // Position Reference Indicator value = ""; itk::EncapsulateMetaData(dict, tagkey, value); - std::string commatagkey = "0018,0020"; // Scanning Sequence - std::string commavalue = "GR"; + std::string commatagkey = "0018,0020"; // Scanning Sequence + const std::string commavalue = "GR"; itk::EncapsulateMetaData(dict, commatagkey, commavalue); tagkey = "0018|0021"; // Sequence Variant value = "SS\\SP"; @@ -181,7 +181,7 @@ itkGDCMImageIOTest2(int argc, char * argv[]) } else { - itk::MetaDataObject::ConstPointer tagvalue = + const itk::MetaDataObject::ConstPointer tagvalue = dynamic_cast *>(tagIt->second.GetPointer()); if (tagvalue) { diff --git a/Modules/IO/GDCM/test/itkGDCMImageOrientationPatientTest.cxx b/Modules/IO/GDCM/test/itkGDCMImageOrientationPatientTest.cxx index 4d241c8530c..3580bae2d3a 100644 --- a/Modules/IO/GDCM/test/itkGDCMImageOrientationPatientTest.cxx +++ b/Modules/IO/GDCM/test/itkGDCMImageOrientationPatientTest.cxx @@ -45,7 +45,7 @@ itkGDCMImageOrientationPatientTest(int argc, char * argv[]) using ImageIOType = itk::GDCMImageIO; using DictionaryType = itk::MetaDataDictionary; - DictionaryType dict; + const DictionaryType dict; // Create a 2D image Image2DType::SpacingType spacing2D; @@ -90,7 +90,7 @@ itkGDCMImageOrientationPatientTest(int argc, char * argv[]) itk::EncapsulateMetaData(dictionary, "0020|0037", value.str()); // GDCM will not write IPP unless the modality is one of CT, MR or RT. - std::string modality("MR"); + const std::string modality("MR"); itk::EncapsulateMetaData(dictionary, "0008|0060", modality); src2D->GetOutput()->SetMetaDataDictionary(dictionary); diff --git a/Modules/IO/GDCM/test/itkGDCMImagePositionPatientTest.cxx b/Modules/IO/GDCM/test/itkGDCMImagePositionPatientTest.cxx index e333998b1c4..13f1c8d8c8d 100644 --- a/Modules/IO/GDCM/test/itkGDCMImagePositionPatientTest.cxx +++ b/Modules/IO/GDCM/test/itkGDCMImagePositionPatientTest.cxx @@ -45,7 +45,7 @@ itkGDCMImagePositionPatientTest(int argc, char * argv[]) using ImageIOType = itk::GDCMImageIO; using DictionaryType = itk::MetaDataDictionary; - DictionaryType dict; + const DictionaryType dict; // Create a 2D image Image2DType::SpacingType spacing2D; @@ -80,7 +80,7 @@ itkGDCMImagePositionPatientTest(int argc, char * argv[]) itk::EncapsulateMetaData(dictionary, "0020|0032", value.str()); // GDCM will not write IPP unless the modality is one of CT, MR or RT. - std::string modality("CT"); + const std::string modality("CT"); itk::EncapsulateMetaData(dictionary, "0008|0060", modality); src2D->GetOutput()->SetMetaDataDictionary(dictionary); diff --git a/Modules/IO/GDCM/test/itkGDCMImageReadSeriesWriteTest.cxx b/Modules/IO/GDCM/test/itkGDCMImageReadSeriesWriteTest.cxx index a543444f1df..c4a770a1e07 100644 --- a/Modules/IO/GDCM/test/itkGDCMImageReadSeriesWriteTest.cxx +++ b/Modules/IO/GDCM/test/itkGDCMImageReadSeriesWriteTest.cxx @@ -82,9 +82,9 @@ itkGDCMImageReadSeriesWriteTest(int argc, char * argv[]) seriesWriter->SetImageIO(gdcmIO); ITK_TEST_SET_GET_VALUE(gdcmIO, seriesWriter->GetImageIO()); - ImageType::RegionType region = reader->GetOutput()->GetLargestPossibleRegion(); - ImageType::IndexType start = region.GetIndex(); - ImageType::SizeType size = region.GetSize(); + const ImageType::RegionType region = reader->GetOutput()->GetLargestPossibleRegion(); + ImageType::IndexType start = region.GetIndex(); + ImageType::SizeType size = region.GetSize(); std::string format = outputDirectory; diff --git a/Modules/IO/GDCM/test/itkGDCMImageReadWriteTest.cxx b/Modules/IO/GDCM/test/itkGDCMImageReadWriteTest.cxx index 0aa152eeacb..5a997f04b4b 100644 --- a/Modules/IO/GDCM/test/itkGDCMImageReadWriteTest.cxx +++ b/Modules/IO/GDCM/test/itkGDCMImageReadWriteTest.cxx @@ -62,7 +62,7 @@ internalMain(const std::string & inputImage, { const unsigned int numberOfComponents = gdcmImageIO->GetNumberOfComponents(); using IOPixelType = itk::IOPixelEnum; - IOPixelType pixelType = gdcmImageIO->GetPixelType(); + const IOPixelType pixelType = gdcmImageIO->GetPixelType(); switch (pixelType) { @@ -108,7 +108,7 @@ itkGDCMImageReadWriteTest(int argc, char * argv[]) std::cout << gdcmImageIO << std::endl; - unsigned int dimension = gdcmImageIO->GetNumberOfDimensions(); + const unsigned int dimension = gdcmImageIO->GetNumberOfDimensions(); switch (dimension) { diff --git a/Modules/IO/GDCM/test/itkGDCMLegacyMultiFrameTest.cxx b/Modules/IO/GDCM/test/itkGDCMLegacyMultiFrameTest.cxx index d732db85d59..20b141d63b7 100644 --- a/Modules/IO/GDCM/test/itkGDCMLegacyMultiFrameTest.cxx +++ b/Modules/IO/GDCM/test/itkGDCMLegacyMultiFrameTest.cxx @@ -43,8 +43,8 @@ itkGDCMLegacyMultiFrameTest(int argc, char * argv[]) using ImageType = itk::Image; using ReaderType = itk::ImageFileReader; - auto reader = ReaderType::New(); - itk::GDCMImageIO::Pointer imageIO = itk::GDCMImageIO::New(); + auto reader = ReaderType::New(); + const itk::GDCMImageIO::Pointer imageIO = itk::GDCMImageIO::New(); reader->SetImageIO(imageIO); reader->SetFileName(inputFileName); diff --git a/Modules/IO/GDCM/test/itkGDCMLoadImageSpacingTest.cxx b/Modules/IO/GDCM/test/itkGDCMLoadImageSpacingTest.cxx index 019e4e3c8ae..8761ab1525a 100644 --- a/Modules/IO/GDCM/test/itkGDCMLoadImageSpacingTest.cxx +++ b/Modules/IO/GDCM/test/itkGDCMLoadImageSpacingTest.cxx @@ -51,8 +51,8 @@ itkGDCMLoadImageSpacingTest(int argc, char * argv[]) using ImageType = itk::Image; using ReaderType = itk::ImageFileReader; - itk::GDCMImageIO::Pointer imageIO = itk::GDCMImageIO::New(); - auto reader = ReaderType::New(); + const itk::GDCMImageIO::Pointer imageIO = itk::GDCMImageIO::New(); + auto reader = ReaderType::New(); reader->SetImageIO(imageIO); reader->SetFileName(imageFilename); try @@ -64,7 +64,7 @@ itkGDCMLoadImageSpacingTest(int argc, char * argv[]) std::cerr << "Error when reading input: " << error << std::endl; } - ImageType::Pointer image = reader->GetOutput(); + const ImageType::Pointer image = reader->GetOutput(); std::cout << image << std::endl; ImageType::SpacingType spacing = image->GetSpacing(); if (itk::Math::abs(spacing[0] - spacing0) >= 0.000001 || itk::Math::abs(spacing[1] - spacing1) >= 0.000001) diff --git a/Modules/IO/GDCM/test/itkGDCMSeriesStreamReadImageWriteTest.cxx b/Modules/IO/GDCM/test/itkGDCMSeriesStreamReadImageWriteTest.cxx index 80fe64d621e..10d4cdee715 100644 --- a/Modules/IO/GDCM/test/itkGDCMSeriesStreamReadImageWriteTest.cxx +++ b/Modules/IO/GDCM/test/itkGDCMSeriesStreamReadImageWriteTest.cxx @@ -38,7 +38,7 @@ static bool IsEqualTolerant(const float lm, const float rm, double tol) { tol = itk::Math::abs(tol); - float temp = itk::Math::abs(lm - rm); + const float temp = itk::Math::abs(lm - rm); return temp <= tol * itk::Math::abs(lm) || temp <= tol * itk::Math::abs(rm) || (itk::Math::abs(lm) < std::numeric_limits::epsilon() && itk::Math::abs(rm) < std::numeric_limits::epsilon()); @@ -76,7 +76,7 @@ itkGDCMSeriesStreamReadImageWriteTest(int argc, char * argv[]) } } - bool expectedToStream = !forceNoStreaming; + const bool expectedToStream = !forceNoStreaming; using ImageIOType = itk::GDCMImageIO; using SeriesFileNames = itk::GDCMSeriesFileNames; diff --git a/Modules/IO/GE/src/itkGE4ImageIO.cxx b/Modules/IO/GE/src/itkGE4ImageIO.cxx index d979055dd8e..89cd4589b3e 100644 --- a/Modules/IO/GE/src/itkGE4ImageIO.cxx +++ b/Modules/IO/GE/src/itkGE4ImageIO.cxx @@ -284,7 +284,7 @@ GE4ImageIO::ReadHeader(const char * FileNameToRead) // hdr->offset = statBuf.st_size - (hdr->imageXsize * hdr->imageYsize * 2); // // find file length in line ... - SizeValueType file_length = itksys::SystemTools::FileLength(FileNameToRead); + const SizeValueType file_length = itksys::SystemTools::FileLength(FileNameToRead); hdr->offset = file_length - (hdr->imageXsize * hdr->imageYsize * 2); return hdr; @@ -299,10 +299,10 @@ GE4ImageIO::MvtSunf(int numb) constexpr auto smantissa = 037777777U; constexpr auto smantlen = 23U; ByteSwapper::SwapFromSystemToBigEndian(&numb); - unsigned int dg_exp = (numb >> 24) & dexponent; - unsigned int dg_sign = numb & signbit; - unsigned int dg_mantissa = (numb & dmantissa) << 8; - int sun_exp = 4 * (dg_exp - 64); + const unsigned int dg_exp = (numb >> 24) & dexponent; + const unsigned int dg_sign = numb & signbit; + unsigned int dg_mantissa = (numb & dmantissa) << 8; + int sun_exp = 4 * (dg_exp - 64); while ((dg_mantissa & signbit) == 0 && dg_mantissa != 0) { --sun_exp; diff --git a/Modules/IO/GE/src/itkGE5ImageIO.cxx b/Modules/IO/GE/src/itkGE5ImageIO.cxx index 48ebf2060fc..ce6fb4d8776 100644 --- a/Modules/IO/GE/src/itkGE5ImageIO.cxx +++ b/Modules/IO/GE/src/itkGE5ImageIO.cxx @@ -354,7 +354,7 @@ GE5ImageIO::ReadHeader(const char * FileNameToRead) curImage->imageXres = hdr2Float(buffer.get() + VOff(50, 52)); curImage->imageYres = hdr2Float(buffer.get() + VOff(54, 56)); - short GE_Plane(hdr2Short(buffer.get() + VOff(114, 116))); + const short GE_Plane(hdr2Short(buffer.get() + VOff(114, 116))); switch (GE_Plane) { case GE_CORONAL: @@ -478,7 +478,7 @@ GE5ImageIO::ModifyImageInformation() // coordinate system. If the computed slice direction is opposite // the direction in the header, the files have to be read in reverse // order. - vnl_vector sliceDirection = vnl_cross_3d(dirx, diry); + const vnl_vector sliceDirection = vnl_cross_3d(dirx, diry); if (dot_product(sliceDirection, dirz) < 0) { // Use the computed direction @@ -496,26 +496,26 @@ GE5ImageIO::ModifyImageInformation() auto it = m_FilenameList->begin(); // The first file - std::string file1 = (*it)->GetImageFileName(); + const std::string file1 = (*it)->GetImageFileName(); // The second file ++it; - std::string file2 = (*it)->GetImageFileName(); + const std::string file2 = (*it)->GetImageFileName(); const std::unique_ptr hdr1{ this->ReadHeader(file1.c_str()) }; const std::unique_ptr hdr2{ this->ReadHeader(file2.c_str()) }; - float origin1[3] = { hdr1->tlhcR, hdr1->tlhcA, hdr1->tlhcS }; + const float origin1[3] = { hdr1->tlhcR, hdr1->tlhcA, hdr1->tlhcS }; // Origin shopuld always come from the first slice this->SetOrigin(0, -hdr1->tlhcR); this->SetOrigin(1, -hdr1->tlhcA); this->SetOrigin(2, hdr1->tlhcS); - float origin2[3] = { hdr2->tlhcR, hdr2->tlhcA, hdr2->tlhcS }; + const float origin2[3] = { hdr2->tlhcR, hdr2->tlhcA, hdr2->tlhcS }; - float distanceBetweenTwoSlices = std::sqrt((origin1[0] - origin2[0]) * (origin1[0] - origin2[0]) + - (origin1[1] - origin2[1]) * (origin1[1] - origin2[1]) + - (origin1[2] - origin2[2]) * (origin1[2] - origin2[2])); + const float distanceBetweenTwoSlices = std::sqrt((origin1[0] - origin2[0]) * (origin1[0] - origin2[0]) + + (origin1[1] - origin2[1]) * (origin1[1] - origin2[1]) + + (origin1[2] - origin2[2]) * (origin1[2] - origin2[2])); this->SetSpacing(2, distanceBetweenTwoSlices); } diff --git a/Modules/IO/GE/test/itkGEImageIOTest.cxx b/Modules/IO/GE/test/itkGEImageIOTest.cxx index 38bc807e8cf..e29175846b7 100644 --- a/Modules/IO/GE/test/itkGEImageIOTest.cxx +++ b/Modules/IO/GE/test/itkGEImageIOTest.cxx @@ -87,10 +87,10 @@ itkGEImageIOTest(int argc, char * argv[]) { return EXIT_FAILURE; } - std::string failmode(argv[1]); - std::string filetype(argv[2]); - std::string filename(argv[3]); - bool Failmode = failmode == std::string("true"); + const std::string failmode(argv[1]); + const std::string filetype(argv[2]); + const std::string filename(argv[3]); + const bool Failmode = failmode == std::string("true"); itk::ImageIOBase::Pointer io; if (filetype == "GE4") { diff --git a/Modules/IO/GIPL/src/itkGiplImageIO.cxx b/Modules/IO/GIPL/src/itkGiplImageIO.cxx index 673a3ab7ddb..79b98f669ba 100644 --- a/Modules/IO/GIPL/src/itkGiplImageIO.cxx +++ b/Modules/IO/GIPL/src/itkGiplImageIO.cxx @@ -99,7 +99,7 @@ bool GiplImageIO::CanReadFile(const char * filename) { // First check the filename extension - bool extensionFound = CheckExtension(filename); + const bool extensionFound = CheckExtension(filename); if (!extensionFound) { @@ -177,14 +177,14 @@ GiplImageIO::CanReadFile(const char * filename) bool GiplImageIO::CanWriteFile(const char * name) { - std::string filename = name; + const std::string filename = name; if (filename.empty()) { itkDebugMacro("No filename specified."); } - bool extensionFound = CheckExtension(name); + const bool extensionFound = CheckExtension(name); if (!extensionFound) { @@ -703,7 +703,7 @@ GiplImageIO::Write(const void * buffer) { CheckExtension(m_FileName.c_str()); - unsigned int nDims = this->GetNumberOfDimensions(); + const unsigned int nDims = this->GetNumberOfDimensions(); if (m_IsCompressed) { @@ -1100,7 +1100,7 @@ GiplImageIO::PrintSelf(std::ostream & os, Indent indent) const bool GiplImageIO::CheckExtension(const char * filename) { - std::string fname = filename; + const std::string fname = filename; if (fname.empty()) { diff --git a/Modules/IO/GIPL/test/itkGiplImageIOTest.cxx b/Modules/IO/GIPL/test/itkGiplImageIOTest.cxx index e7e81787659..ab9630f5543 100644 --- a/Modules/IO/GIPL/test/itkGiplImageIOTest.cxx +++ b/Modules/IO/GIPL/test/itkGiplImageIOTest.cxx @@ -41,7 +41,7 @@ itkGiplImageIOTest(int argc, char * argv[]) using myImage = itk::Image; - itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); reader->SetFileName(argv[1]); @@ -56,11 +56,11 @@ itkGiplImageIOTest(int argc, char * argv[]) return EXIT_FAILURE; } - myImage::Pointer image = reader->GetOutput(); + const myImage::Pointer image = reader->GetOutput(); image->Print(std::cout); - myImage::RegionType region = image->GetLargestPossibleRegion(); + const myImage::RegionType region = image->GetLargestPossibleRegion(); std::cout << "region " << region; // Generate test image diff --git a/Modules/IO/HDF5/src/itkHDF5ImageIO.cxx b/Modules/IO/HDF5/src/itkHDF5ImageIO.cxx index b475e3e735f..9b3d5318a37 100644 --- a/Modules/IO/HDF5/src/itkHDF5ImageIO.cxx +++ b/Modules/IO/HDF5/src/itkHDF5ImageIO.cxx @@ -260,10 +260,10 @@ doesAttrExist(const H5::H5Object & object, const char * const name) void HDF5ImageIO::WriteScalar(const std::string & path, const bool value) { - hsize_t numScalars(1); - H5::DataSpace scalarSpace(1, &numScalars); - H5::PredType scalarType = H5::PredType::NATIVE_HBOOL; - H5::DataSet scalarSet = m_H5File->createDataSet(path, scalarType, scalarSpace); + const hsize_t numScalars(1); + const H5::DataSpace scalarSpace(1, &numScalars); + const H5::PredType scalarType = H5::PredType::NATIVE_HBOOL; + H5::DataSet scalarSet = m_H5File->createDataSet(path, scalarType, scalarSpace); // // HDF5 can't distinguish // between bool and int datasets @@ -282,11 +282,11 @@ HDF5ImageIO::WriteScalar(const std::string & path, const bool value) void HDF5ImageIO::WriteScalar(const std::string & path, const long value) { - hsize_t numScalars(1); - H5::DataSpace scalarSpace(1, &numScalars); - H5::PredType scalarType = H5::PredType::NATIVE_INT; - H5::PredType attrType = H5::PredType::NATIVE_HBOOL; - H5::DataSet scalarSet = m_H5File->createDataSet(path, scalarType, scalarSpace); + const hsize_t numScalars(1); + const H5::DataSpace scalarSpace(1, &numScalars); + const H5::PredType scalarType = H5::PredType::NATIVE_INT; + const H5::PredType attrType = H5::PredType::NATIVE_HBOOL; + H5::DataSet scalarSet = m_H5File->createDataSet(path, scalarType, scalarSpace); // // HDF5 can't distinguish // between long and int datasets @@ -305,11 +305,11 @@ HDF5ImageIO::WriteScalar(const std::string & path, const long value) void HDF5ImageIO::WriteScalar(const std::string & path, const unsigned long value) { - hsize_t numScalars(1); - H5::DataSpace scalarSpace(1, &numScalars); - H5::PredType scalarType = H5::PredType::NATIVE_UINT; - H5::PredType attrType = H5::PredType::NATIVE_HBOOL; - H5::DataSet scalarSet = m_H5File->createDataSet(path, scalarType, scalarSpace); + const hsize_t numScalars(1); + const H5::DataSpace scalarSpace(1, &numScalars); + const H5::PredType scalarType = H5::PredType::NATIVE_UINT; + const H5::PredType attrType = H5::PredType::NATIVE_HBOOL; + H5::DataSet scalarSet = m_H5File->createDataSet(path, scalarType, scalarSpace); // // HDF5 can't distinguish // between unsigned long and unsigned int datasets @@ -328,11 +328,11 @@ HDF5ImageIO::WriteScalar(const std::string & path, const unsigned long value) void HDF5ImageIO::WriteScalar(const std::string & path, const long long value) { - hsize_t numScalars(1); - H5::DataSpace scalarSpace(1, &numScalars); - H5::PredType scalarType = H5::PredType::STD_I64LE; - H5::PredType attrType = H5::PredType::NATIVE_HBOOL; - H5::DataSet scalarSet = m_H5File->createDataSet(path, scalarType, scalarSpace); + const hsize_t numScalars(1); + const H5::DataSpace scalarSpace(1, &numScalars); + const H5::PredType scalarType = H5::PredType::STD_I64LE; + const H5::PredType attrType = H5::PredType::NATIVE_HBOOL; + H5::DataSet scalarSet = m_H5File->createDataSet(path, scalarType, scalarSpace); // // HDF5 can't distinguish // between long and long long datasets @@ -350,11 +350,11 @@ HDF5ImageIO::WriteScalar(const std::string & path, const long long value) void HDF5ImageIO::WriteScalar(const std::string & path, const unsigned long long value) { - hsize_t numScalars(1); - H5::DataSpace scalarSpace(1, &numScalars); - H5::PredType scalarType = H5::PredType::STD_U64LE; - H5::PredType attrType = H5::PredType::NATIVE_HBOOL; - H5::DataSet scalarSet = m_H5File->createDataSet(path, scalarType, scalarSpace); + const hsize_t numScalars(1); + const H5::DataSpace scalarSpace(1, &numScalars); + const H5::PredType scalarType = H5::PredType::STD_U64LE; + const H5::PredType attrType = H5::PredType::NATIVE_HBOOL; + H5::DataSet scalarSet = m_H5File->createDataSet(path, scalarType, scalarSpace); // // HDF5 can't distinguish // between unsigned long and unsigned long long @@ -373,10 +373,10 @@ template void HDF5ImageIO::WriteScalar(const std::string & path, const TScalar & value) { - hsize_t numScalars(1); - H5::DataSpace scalarSpace(1, &numScalars); - H5::PredType scalarType = GetType(); - H5::DataSet scalarSet = m_H5File->createDataSet(path, scalarType, scalarSpace); + const hsize_t numScalars(1); + const H5::DataSpace scalarSpace(1, &numScalars); + const H5::PredType scalarType = GetType(); + H5::DataSet scalarSet = m_H5File->createDataSet(path, scalarType, scalarSpace); scalarSet.write(&value, scalarType); scalarSet.close(); } @@ -385,9 +385,9 @@ template TScalar HDF5ImageIO::ReadScalar(const std::string & DataSetName) { - hsize_t dim[1]; - H5::DataSet scalarSet = m_H5File->openDataSet(DataSetName); - H5::DataSpace Space = scalarSet.getSpace(); + hsize_t dim[1]; + H5::DataSet scalarSet = m_H5File->openDataSet(DataSetName); + const H5::DataSpace Space = scalarSet.getSpace(); if (Space.getSimpleExtentNdims() != 1) { @@ -398,8 +398,8 @@ HDF5ImageIO::ReadScalar(const std::string & DataSetName) { itkExceptionMacro("Elements > 1 for scalar type " << "in HDF5 File"); } - TScalar scalar; - H5::PredType scalarType = GetType(); + TScalar scalar; + const H5::PredType scalarType = GetType(); scalarSet.read(&scalar, scalarType); scalarSet.close(); return scalar; @@ -409,10 +409,10 @@ HDF5ImageIO::ReadScalar(const std::string & DataSetName) void HDF5ImageIO::WriteString(const std::string & path, const std::string & value) { - hsize_t numStrings(1); - H5::DataSpace strSpace(1, &numStrings); - H5::StrType strType(H5::PredType::C_S1, H5T_VARIABLE); - H5::DataSet strSet = m_H5File->createDataSet(path, strType, strSpace); + const hsize_t numStrings(1); + const H5::DataSpace strSpace(1, &numStrings); + const H5::StrType strType(H5::PredType::C_S1, H5T_VARIABLE); + H5::DataSet strSet = m_H5File->createDataSet(path, strType, strSpace); strSet.write(value, strType); strSet.close(); } @@ -420,18 +420,18 @@ HDF5ImageIO::WriteString(const std::string & path, const std::string & value) void HDF5ImageIO::WriteString(const std::string & path, const char * s) { - std::string _s(s); + const std::string _s(s); WriteString(path, _s); } std::string HDF5ImageIO::ReadString(const std::string & path) { - std::string rval; - hsize_t numStrings(1); - H5::DataSpace strSpace(1, &numStrings); - H5::StrType strType(H5::PredType::C_S1, H5T_VARIABLE); - H5::DataSet strSet = m_H5File->openDataSet(path); + std::string rval; + const hsize_t numStrings(1); + const H5::DataSpace strSpace(1, &numStrings); + const H5::StrType strType(H5::PredType::C_S1, H5T_VARIABLE); + H5::DataSet strSet = m_H5File->openDataSet(path); strSet.read(rval, strType, strSpace); strSet.close(); return rval; @@ -441,10 +441,10 @@ template void HDF5ImageIO::WriteVector(const std::string & path, const std::vector & vec) { - hsize_t dim(vec.size()); - H5::DataSpace vecSpace(1, &dim); - H5::PredType vecType = GetType(); - H5::DataSet vecSet = m_H5File->createDataSet(path, vecType, vecSpace); + const hsize_t dim(vec.size()); + const H5::DataSpace vecSpace(1, &dim); + const H5::PredType vecType = GetType(); + H5::DataSet vecSet = m_H5File->createDataSet(path, vecType, vecSpace); vecSet.write(vec.data(), vecType); vecSet.close(); } @@ -456,7 +456,7 @@ HDF5ImageIO::ReadVector(const std::string & DataSetName) std::vector vec; hsize_t dim[1]; H5::DataSet vecSet = m_H5File->openDataSet(DataSetName); - H5::DataSpace Space = vecSet.getSpace(); + const H5::DataSpace Space = vecSet.getSpace(); if (Space.getSimpleExtentNdims() != 1) { @@ -464,7 +464,7 @@ HDF5ImageIO::ReadVector(const std::string & DataSetName) } Space.getSimpleExtentDims(dim, nullptr); vec.resize(dim[0]); - H5::PredType vecType = GetType(); + const H5::PredType vecType = GetType(); vecSet.read(vec.data(), vecType); vecSet.close(); return vec; @@ -487,8 +487,8 @@ HDF5ImageIO::WriteDirections(const std::string & path, const std::vectorcreateDataSet(path, H5::PredType::NATIVE_DOUBLE, dirSpace); + const H5::DataSpace dirSpace(2, dim); + H5::DataSet dirSet = m_H5File->createDataSet(path, H5::PredType::NATIVE_DOUBLE, dirSpace); dirSet.write(buf.get(), H5::PredType::NATIVE_DOUBLE); dirSet.close(); } @@ -498,7 +498,7 @@ HDF5ImageIO::ReadDirections(const std::string & path) { std::vector> rval; H5::DataSet dirSet = m_H5File->openDataSet(path); - H5::DataSpace dirSpace = dirSet.getSpace(); + const H5::DataSpace dirSpace = dirSet.getSpace(); hsize_t dim[2]; if (dirSpace.getSimpleExtentNdims() != 2) { @@ -510,7 +510,7 @@ HDF5ImageIO::ReadDirections(const std::string & path) { rval[i].resize(dim[0]); } - H5::FloatType dirType = dirSet.getFloatType(); + const H5::FloatType dirType = dirSet.getFloatType(); if (dirType.getSize() == sizeof(double)) { const auto buf = make_unique_for_overwrite(dim[0] * dim[1]); @@ -596,14 +596,14 @@ HDF5ImageIO::CanReadFile(const char * FileNameToRead) try { - htri_t ishdf5 = H5Fis_hdf5(FileNameToRead); + const htri_t ishdf5 = H5Fis_hdf5(FileNameToRead); if (ishdf5 <= 0) { return false; } - H5::H5File h5file(FileNameToRead, H5F_ACC_RDONLY); + const H5::H5File h5file(FileNameToRead, H5F_ACC_RDONLY); #if (H5_VERS_MAJOR == 1) && (H5_VERS_MINOR < 10) // check the file has the ITK ImageGroup @@ -708,8 +708,8 @@ HDF5ImageIO::ReadImageInformation() std::string VoxelDataName(groupName); VoxelDataName += VoxelData; *(m_VoxelDataSet) = m_H5File->openDataSet(VoxelDataName); - H5::DataSet imageSet = *(m_VoxelDataSet); - H5::DataSpace imageSpace = imageSet.getSpace(); + H5::DataSet imageSet = *(m_VoxelDataSet); + const H5::DataSpace imageSpace = imageSet.getSpace(); // // set the componentType H5::DataType imageVoxelType = imageSet.getDataType(); @@ -719,8 +719,8 @@ HDF5ImageIO::ReadImageInformation() // by comparing the size of the Directions matrix with the // reported # of dimensions in the voxel dataset { - hsize_t nDims = imageSpace.getSimpleExtentNdims(); - const auto Dims = make_unique_for_overwrite(nDims); + const hsize_t nDims = imageSpace.getSimpleExtentNdims(); + const auto Dims = make_unique_for_overwrite(nDims); imageSpace.getSimpleExtentDims(Dims.get()); if (nDims > this->GetNumberOfDimensions()) { @@ -735,16 +735,16 @@ HDF5ImageIO::ReadImageInformation() std::string MetaDataGroupName(groupName); MetaDataGroupName += MetaDataName; MetaDataGroupName += "/"; - H5::Group metaGroup(m_H5File->openGroup(MetaDataGroupName)); + const H5::Group metaGroup(m_H5File->openGroup(MetaDataGroupName)); for (unsigned int i = 0; i < metaGroup.getNumObjs(); ++i) { - H5std_string name = metaGroup.getObjnameByIdx(i); + const H5std_string name = metaGroup.getObjnameByIdx(i); std::string localMetaDataName(MetaDataGroupName); localMetaDataName += name; - H5::DataSet metaDataSet = m_H5File->openDataSet(localMetaDataName); - H5::DataType metaDataType = metaDataSet.getDataType(); - H5::DataSpace metaDataSpace = metaDataSet.getSpace(); + const H5::DataSet metaDataSet = m_H5File->openDataSet(localMetaDataName); + const H5::DataType metaDataType = metaDataSet.getDataType(); + const H5::DataSpace metaDataSpace = metaDataSet.getSpace(); if (metaDataSpace.getSimpleExtentNdims() != 1) { // ignore > 1D metadata @@ -864,10 +864,10 @@ HDF5ImageIO::ReadImageInformation() } else { - H5::StrType strType(H5::PredType::C_S1, H5T_VARIABLE); + const H5::StrType strType(H5::PredType::C_S1, H5T_VARIABLE); if (metaDataType == strType) { - std::string val = this->ReadString(localMetaDataName); + const std::string val = this->ReadString(localMetaDataName); EncapsulateMetaData(metaDict, name, val); } } @@ -908,11 +908,11 @@ HDF5ImageIO::ReadImageInformation() void HDF5ImageIO::SetupStreaming(H5::DataSpace * imageSpace, H5::DataSpace * slabSpace) { - ImageIORegion regionToRead = this->GetIORegion(); + const ImageIORegion regionToRead = this->GetIORegion(); ImageIORegion::SizeType size = regionToRead.GetSize(); ImageIORegion::IndexType start = regionToRead.GetIndex(); // - int numComponents = this->GetNumberOfComponents(); + const int numComponents = this->GetNumberOfComponents(); const int HDFDim(this->GetNumberOfDimensions() + (numComponents > 1 ? 1 : 0)); @@ -950,12 +950,12 @@ HDF5ImageIO::SetupStreaming(H5::DataSpace * imageSpace, H5::DataSpace * slabSpac void HDF5ImageIO::Read(void * buffer) { - ImageIORegion regionToRead = this->GetIORegion(); - ImageIORegion::SizeType size = regionToRead.GetSize(); - ImageIORegion::IndexType start = regionToRead.GetIndex(); + const ImageIORegion regionToRead = this->GetIORegion(); + const ImageIORegion::SizeType size = regionToRead.GetSize(); + const ImageIORegion::IndexType start = regionToRead.GetIndex(); - H5::DataType voxelType = m_VoxelDataSet->getDataType(); - H5::DataSpace imageSpace = m_VoxelDataSet->getSpace(); + const H5::DataType voxelType = m_VoxelDataSet->getDataType(); + H5::DataSpace imageSpace = m_VoxelDataSet->getSpace(); H5::DataSpace dspace; this->SetupStreaming(&imageSpace, &dspace); @@ -1014,7 +1014,7 @@ HDF5ImageIO::WriteImageInformation() { this->ResetToInitialState(); - H5::FileAccPropList fapl; + const H5::FileAccPropList fapl; #if (H5_VERS_MAJOR > 1) || (H5_VERS_MAJOR == 1) && (H5_VERS_MINOR > 10) || \ (H5_VERS_MAJOR == 1) && (H5_VERS_MINOR == 10) && (H5_VERS_RELEASE >= 2) // File format which is backwards compatible with HDF5 version 1.8 @@ -1050,11 +1050,11 @@ HDF5ImageIO::WriteImageInformation() std::string VoxelTypeName(groupName); VoxelTypeName += VoxelType; - std::string typeVal(ComponentToString(this->GetComponentType())); + const std::string typeVal(ComponentToString(this->GetComponentType())); this->WriteString(VoxelTypeName, typeVal); - int numComponents = this->GetNumberOfComponents(); - int numDims = this->GetNumberOfDimensions(); + const int numComponents = this->GetNumberOfComponents(); + int numDims = this->GetNumberOfDimensions(); // HDF5 dimensions listed slowest moving first, ITK are fastest // moving first. auto dims = make_unique_for_overwrite(numDims + (numComponents == 1 ? 0 : 1)); @@ -1068,13 +1068,13 @@ HDF5ImageIO::WriteImageInformation() dims[numDims] = numComponents; ++numDims; } - H5::DataSpace imageSpace(numDims, dims.get()); - H5::PredType dataType = ComponentToPredType(this->GetComponentType()); + const H5::DataSpace imageSpace(numDims, dims.get()); + const H5::PredType dataType = ComponentToPredType(this->GetComponentType()); // set up properties for chunked, compressed writes. // in this case, set the chunk size to be the N-1 dimension // region - H5::DSetCreatPropList plist; + const H5::DSetCreatPropList plist; // we have implicit compression enabled here? plist.setDeflate(this->GetCompressionLevel()); @@ -1220,7 +1220,7 @@ HDF5ImageIO::WriteImageInformation() auto * stdStringObj = dynamic_cast *>(metaObj); if (stdStringObj != nullptr) { - std::string val = stdStringObj->GetMetaDataObjectValue(); + const std::string val = stdStringObj->GetMetaDataObjectValue(); this->WriteString(objName, val); continue; } @@ -1266,8 +1266,8 @@ HDF5ImageIO::Write(const void * buffer) this->WriteImageInformation(); try { - int numComponents = this->GetNumberOfComponents(); - int numDims = this->GetNumberOfDimensions(); + const int numComponents = this->GetNumberOfComponents(); + int numDims = this->GetNumberOfDimensions(); // HDF5 dimensions listed slowest moving first, ITK are fastest // moving first. const auto dims = make_unique_for_overwrite(numDims + (numComponents == 1 ? 0 : 1)); @@ -1281,9 +1281,9 @@ HDF5ImageIO::Write(const void * buffer) dims[numDims] = numComponents; ++numDims; } - H5::DataSpace imageSpace(numDims, dims.get()); - H5::PredType dataType = ComponentToPredType(this->GetComponentType()); - H5::DataSpace dspace; + H5::DataSpace imageSpace(numDims, dims.get()); + const H5::PredType dataType = ComponentToPredType(this->GetComponentType()); + H5::DataSpace dspace; this->SetupStreaming(&imageSpace, &dspace); m_VoxelDataSet->write(buffer, dataType, dspace, imageSpace); } diff --git a/Modules/IO/HDF5/test/itkHDF5ImageIOStreamingReadWriteTest.cxx b/Modules/IO/HDF5/test/itkHDF5ImageIOStreamingReadWriteTest.cxx index ea160bc1cc6..c839be80874 100644 --- a/Modules/IO/HDF5/test/itkHDF5ImageIOStreamingReadWriteTest.cxx +++ b/Modules/IO/HDF5/test/itkHDF5ImageIOStreamingReadWriteTest.cxx @@ -97,7 +97,7 @@ HDF5ReadWriteTest2(const char * fileName) size[2] = 5; size[1] = 5; size[0] = 5; - typename itk::DemoImageSource::Pointer imageSource = itk::DemoImageSource::New(); + const typename itk::DemoImageSource::Pointer imageSource = itk::DemoImageSource::New(); imageSource->SetValue(static_cast(23)); // Not used. imageSource->SetSize(size); diff --git a/Modules/IO/HDF5/test/itkHDF5ImageIOTest.cxx b/Modules/IO/HDF5/test/itkHDF5ImageIOTest.cxx index 2cd8df6d0e8..b828f8d29d6 100644 --- a/Modules/IO/HDF5/test/itkHDF5ImageIOTest.cxx +++ b/Modules/IO/HDF5/test/itkHDF5ImageIOTest.cxx @@ -45,7 +45,7 @@ HDF5ReadWriteTest(const char * fileName) } imageRegion.SetSize(size); imageRegion.SetIndex(index); - typename ImageType::Pointer im = + const typename ImageType::Pointer im = itk::IOTestHelper::AllocateImageFromRegionAndSpacing(imageRegion, spacing); itk::Matrix mat; @@ -61,43 +61,43 @@ HDF5ReadWriteTest(const char * fileName) // // add some unique metadata itk::MetaDataDictionary & metaDict(im->GetMetaDataDictionary()); - bool metaDataBool(false); + const bool metaDataBool(false); itk::EncapsulateMetaData(metaDict, "TestBool", metaDataBool); - char metaDataChar('c'); + const char metaDataChar('c'); itk::EncapsulateMetaData(metaDict, "TestChar", metaDataChar); - unsigned char metaDataUChar('u'); + const unsigned char metaDataUChar('u'); itk::EncapsulateMetaData(metaDict, "TestUChar", metaDataUChar); - short metaDataShort(1); + const short metaDataShort(1); itk::EncapsulateMetaData(metaDict, "TestShort", metaDataShort); - unsigned short metaDataUShort(3); + const unsigned short metaDataUShort(3); itk::EncapsulateMetaData(metaDict, "TestUShort", metaDataUShort); - int metaDataInt(5); + const int metaDataInt(5); itk::EncapsulateMetaData(metaDict, "TestInt", metaDataInt); - unsigned int metaDataUInt(7); + const unsigned int metaDataUInt(7); itk::EncapsulateMetaData(metaDict, "TestUInt", metaDataUInt); - long metaDataLong(5); + const long metaDataLong(5); itk::EncapsulateMetaData(metaDict, "TestLong", metaDataLong); - unsigned long metaDataULong(7); + const unsigned long metaDataULong(7); itk::EncapsulateMetaData(metaDict, "TestULong", metaDataULong); - long long metaDataLLong(-5); + const long long metaDataLLong(-5); itk::EncapsulateMetaData(metaDict, "TestLLong", metaDataLLong); - unsigned long long metaDataULLong(7ull); + const unsigned long long metaDataULLong(7ull); itk::EncapsulateMetaData(metaDict, "TestULLong", metaDataULLong); - float metaDataFloat(1.23456); + const float metaDataFloat(1.23456); itk::EncapsulateMetaData(metaDict, "TestFloat", metaDataFloat); - double metaDataDouble(1.23456); + const double metaDataDouble(1.23456); itk::EncapsulateMetaData(metaDict, "TestDouble", metaDataDouble); itk::Array metaDataCharArray(5); @@ -116,7 +116,7 @@ HDF5ReadWriteTest(const char * fileName) metaDataDoubleArray[4] = 2.0; itk::EncapsulateMetaData>(metaDict, "TestDoubleArray", metaDataDoubleArray); - std::string metaDataStdString("Test std::string"); + const std::string metaDataStdString("Test std::string"); itk::EncapsulateMetaData(metaDict, "StdString", metaDataStdString); // @@ -160,7 +160,7 @@ HDF5ReadWriteTest(const char * fileName) } // // Check MetaData - itk::MetaDataDictionary & metaDict2(im2->GetMetaDataDictionary()); + const itk::MetaDataDictionary & metaDict2(im2->GetMetaDataDictionary()); bool metaDataBool2(false); @@ -315,9 +315,9 @@ HDF5ReadWriteTest(const char * fileName) int HDF5ReuseReadWriteTest(const char * fileName) { - int success(EXIT_SUCCESS); + const int success(EXIT_SUCCESS); - itk::HDF5ImageIO::Pointer io = itk::HDF5ImageIO::New(); + const itk::HDF5ImageIO::Pointer io = itk::HDF5ImageIO::New(); io->SetFileName(fileName); // Is writing first an image should produce an error? @@ -349,7 +349,7 @@ itkHDF5ImageIOTest(int argc, char * argv[]) } itk::ObjectFactoryBase::RegisterFactory(itk::HDF5ImageIOFactory::New()); - itk::HDF5ImageIO::Pointer imageio = itk::HDF5ImageIO::New(); + const itk::HDF5ImageIO::Pointer imageio = itk::HDF5ImageIO::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(imageio, HDF5ImageIO, StreamingImageIOBase); int result(0); diff --git a/Modules/IO/IPL/src/itkIPLCommonImageIO.cxx b/Modules/IO/IPL/src/itkIPLCommonImageIO.cxx index 192b014ee58..2358821a85f 100644 --- a/Modules/IO/IPL/src/itkIPLCommonImageIO.cxx +++ b/Modules/IO/IPL/src/itkIPLCommonImageIO.cxx @@ -79,8 +79,8 @@ IPLCommonImageIO::Read(void * buffer) for (; it != itend; ++it) { - std::string curfilename = (*it)->GetImageFileName(); - std::ifstream f; + const std::string curfilename = (*it)->GetImageFileName(); + std::ifstream f; this->OpenFileForReading(f, curfilename); f.seekg((*it)->GetSliceOffset(), std::ios::beg); @@ -126,9 +126,9 @@ IPLCommonImageIO::ReadImageInformation() // GE images are stored in separate files per slice. // char imagePath[IOCommon::ITK_MAXPATHLEN+1]; // TODO -- use std::string instead of C strings - char imageMask[IOCommon::ITK_MAXPATHLEN + 1]; - char imagePath[IOCommon::ITK_MAXPATHLEN + 1]; - std::string _imagePath = itksys::SystemTools::CollapseFullPath(FileNameToRead.c_str()); + char imageMask[IOCommon::ITK_MAXPATHLEN + 1]; + char imagePath[IOCommon::ITK_MAXPATHLEN + 1]; + const std::string _imagePath = itksys::SystemTools::CollapseFullPath(FileNameToRead.c_str()); FileNameToRead = _imagePath; @@ -137,8 +137,8 @@ IPLCommonImageIO::ReadImageInformation() // if anything fails in the header read, just let // exceptions propagate up. - bool isCT = false; - std::string modality = m_ImageHeader->modality; + bool isCT = false; + const std::string modality = m_ImageHeader->modality; if (modality == "CT") { isCT = true; @@ -158,7 +158,7 @@ IPLCommonImageIO::ReadImageInformation() // Add header info to metadictionary itk::MetaDataDictionary & thisDic = this->GetMetaDataDictionary(); - std::string classname(this->GetNameOfClass()); + const std::string classname(this->GetNameOfClass()); itk::EncapsulateMetaData(thisDic, ITK_InputFilterName, classname); itk::EncapsulateMetaData(thisDic, ITK_OnDiskStorageTypeName, std::string("SHORT")); itk::EncapsulateMetaData(thisDic, ITK_OnDiskBitPerPixel, static_cast(16)); diff --git a/Modules/IO/ImageBase/include/itkConvertPixelBuffer.hxx b/Modules/IO/ImageBase/include/itkConvertPixelBuffer.hxx index 1f1918d18e2..0f4f59bcd6b 100644 --- a/Modules/IO/ImageBase/include/itkConvertPixelBuffer.hxx +++ b/Modules/IO/ImageBase/include/itkConvertPixelBuffer.hxx @@ -229,10 +229,10 @@ ConvertPixelBuffer::Conver // this is an ugly implementation of the simple equation // greyval = (.2125 * red + .7154 * green + .0721 * blue) / alpha // - double tempval = ((2125.0 * static_cast(*inputData) + 7154.0 * static_cast(*(inputData + 1)) + - 0721.0 * static_cast(*(inputData + 2))) / - 10000.0) * - static_cast(*(inputData + 3)) / maxAlpha; + const double tempval = ((2125.0 * static_cast(*inputData) + 7154.0 * static_cast(*(inputData + 1)) + + 0721.0 * static_cast(*(inputData + 2))) / + 10000.0) * + static_cast(*(inputData + 3)) / maxAlpha; inputData += 4; auto val = static_cast(tempval); OutputConvertTraits::SetNthComponent(0, *outputData++, val); @@ -261,7 +261,7 @@ ConvertPixelBuffer::Conver const InputPixelType * endInput = inputData + size * 2; while (inputData != endInput) { - OutputComponentType val = + const OutputComponentType val = static_cast(*inputData) * static_cast(*(inputData + 1) / maxAlpha); inputData += 2; OutputConvertTraits::SetNthComponent(0, *outputData++, val); @@ -278,10 +278,11 @@ ConvertPixelBuffer::Conver const InputPixelType * endInput = inputData + size * static_cast(inputNumberOfComponents); while (inputData != endInput) { - double tempval = ((2125.0 * static_cast(*inputData) + 7154.0 * static_cast(*(inputData + 1)) + - 0721.0 * static_cast(*(inputData + 2))) / - 10000.0) * - static_cast(*(inputData + 3)) / maxAlpha; + const double tempval = + ((2125.0 * static_cast(*inputData) + 7154.0 * static_cast(*(inputData + 1)) + + 0721.0 * static_cast(*(inputData + 2))) / + 10000.0) * + static_cast(*(inputData + 3)) / maxAlpha; auto val = static_cast(tempval); OutputConvertTraits::SetNthComponent(0, *outputData++, val); inputData += inputNumberOfComponents; @@ -361,7 +362,7 @@ ConvertPixelBuffer::Conver const InputPixelType * endInput = inputData + size * 2; while (inputData != endInput) { - OutputComponentType val = + const OutputComponentType val = static_cast(*inputData) * static_cast(*(inputData + 1)); inputData += 2; OutputConvertTraits::SetNthComponent(0, *outputData, val); @@ -497,8 +498,8 @@ ConvertPixelBuffer::Conver OutputPixelType * outputData, size_t size) { - int outputNumberOfComponents = OutputConvertTraits::GetNumberOfComponents(); - int componentCount = std::min(inputNumberOfComponents, outputNumberOfComponents); + const int outputNumberOfComponents = OutputConvertTraits::GetNumberOfComponents(); + const int componentCount = std::min(inputNumberOfComponents, outputNumberOfComponents); for (size_t i = 0; i < size; ++i) { @@ -621,7 +622,7 @@ ConvertPixelBuffer::Conver OutputPixelType * outputData, size_t size) { - size_t length = size * static_cast(inputNumberOfComponents); + const size_t length = size * static_cast(inputNumberOfComponents); for (size_t i = 0; i < length; ++i) { diff --git a/Modules/IO/ImageBase/include/itkImageFileReader.hxx b/Modules/IO/ImageBase/include/itkImageFileReader.hxx index 450830f2f1b..de1086f2e0f 100644 --- a/Modules/IO/ImageBase/include/itkImageFileReader.hxx +++ b/Modules/IO/ImageBase/include/itkImageFileReader.hxx @@ -72,7 +72,7 @@ template void ImageFileReader::GenerateOutputInformation() { - typename TOutputImage::Pointer output = this->GetOutput(); + const typename TOutputImage::Pointer output = this->GetOutput(); itkDebugMacro("Reading file for GenerateOutputInformation()" << this->GetFileName()); @@ -113,7 +113,7 @@ ImageFileReader::GenerateOutputInformation() } else { - std::list allobjects = ObjectFactoryBase::CreateAllInstance("itkImageIOBase"); + const std::list allobjects = ObjectFactoryBase::CreateAllInstance("itkImageIOBase"); if (!allobjects.empty()) { msg << " Tried to create one of the following:" << std::endl; @@ -292,14 +292,14 @@ void ImageFileReader::EnlargeOutputRequestedRegion(DataObject * output) { itkDebugMacro("Starting EnlargeOutputRequestedRegion() "); - typename TOutputImage::Pointer out = dynamic_cast(output); - typename TOutputImage::RegionType largestRegion = out->GetLargestPossibleRegion(); - ImageRegionType streamableRegion; + const typename TOutputImage::Pointer out = dynamic_cast(output); + const typename TOutputImage::RegionType largestRegion = out->GetLargestPossibleRegion(); + ImageRegionType streamableRegion; // The following code converts the ImageRegion (templated over dimension) // into an ImageIORegion (not templated over dimension). - ImageRegionType imageRequestedRegion = out->GetRequestedRegion(); - ImageIORegion ioRequestedRegion(TOutputImage::ImageDimension); + const ImageRegionType imageRequestedRegion = out->GetRequestedRegion(); + ImageIORegion ioRequestedRegion(TOutputImage::ImageDimension); using ImageIOAdaptor = ImageIORegionAdaptor; @@ -353,7 +353,7 @@ ImageFileReader::GenerateData() { this->UpdateProgress(0.0f); - typename TOutputImage::Pointer output = this->GetOutput(); + const typename TOutputImage::Pointer output = this->GetOutput(); itkDebugMacro("ImageFileReader::GenerateData() \n" << "Allocating the buffer with the EnlargedRequestedRegion \n" @@ -387,10 +387,10 @@ ImageFileReader::GenerateData() // the size of the buffer is computed based on the actual number of // pixels to be read and the actual size of the pixels to be read // (as opposed to the sizes of the output) - size_t sizeOfActualIORegion = + const size_t sizeOfActualIORegion = m_ActualIORegion.GetNumberOfPixels() * (m_ImageIO->GetComponentSize() * m_ImageIO->GetNumberOfComponents()); - IOComponentEnum ioType = ImageIOBase::MapPixelType::CType; + const IOComponentEnum ioType = ImageIOBase::MapPixelType::CType; if (m_ImageIO->GetComponentType() != ioType || (m_ImageIO->GetNumberOfComponents() != ConvertPixelTraits::GetNumberOfComponents())) { @@ -446,7 +446,7 @@ ImageFileReader::DoConvertBuffer(const void * { // get the pointer to the destination buffer OutputImagePixelType * outputData = this->GetOutput()->GetPixelContainer()->GetBufferPointer(); - bool isVectorImage(strcmp(this->GetOutput()->GetNameOfClass(), "VectorImage") == 0); + const bool isVectorImage(strcmp(this->GetOutput()->GetNameOfClass(), "VectorImage") == 0); // TODO: // Pass down the PixelType (RGB, VECTOR, etc.) so that any vector to // scalar conversion be type specific. i.e. RGB to scalar would use diff --git a/Modules/IO/ImageBase/include/itkImageFileWriter.hxx b/Modules/IO/ImageBase/include/itkImageFileWriter.hxx index 018aa5552b8..734f1b2cbae 100644 --- a/Modules/IO/ImageBase/include/itkImageFileWriter.hxx +++ b/Modules/IO/ImageBase/include/itkImageFileWriter.hxx @@ -114,9 +114,9 @@ ImageFileWriter::Write() if (m_ImageIO.IsNull()) { - ImageFileWriterException e(__FILE__, __LINE__); - std::ostringstream msg; - std::list allobjects = ObjectFactoryBase::CreateAllInstance("itkImageIOBase"); + ImageFileWriterException e(__FILE__, __LINE__); + std::ostringstream msg; + const std::list allobjects = ObjectFactoryBase::CreateAllInstance("itkImageIOBase"); msg << " Could not create IO object for writing file " << m_FileName.c_str() << std::endl; if (!allobjects.empty()) { @@ -167,7 +167,7 @@ ImageFileWriter::Write() // Setup the ImageIO // m_ImageIO->SetNumberOfDimensions(TInputImage::ImageDimension); - InputImageRegionType largestRegion = input->GetLargestPossibleRegion(); + const InputImageRegionType largestRegion = input->GetLargestPossibleRegion(); const typename TInputImage::SpacingType & spacing = input->GetSpacing(); const typename TInputImage::DirectionType & direction = input->GetDirection(); // BUG 8436: Wrong origin when writing a file with non-zero index @@ -295,7 +295,7 @@ ImageFileWriter::Write() // check to see if we tried to stream but got the largest possible region if (piece == 0 && streamRegion != largestRegion) { - InputImageRegionType bufferedRegion = input->GetBufferedRegion(); + const InputImageRegionType bufferedRegion = input->GetBufferedRegion(); if (bufferedRegion == largestRegion) { // if so, then just write the entire image @@ -328,9 +328,9 @@ template void ImageFileWriter::GenerateData() { - const InputImageType * input = this->GetInput(); - InputImageRegionType largestRegion = input->GetLargestPossibleRegion(); - InputImagePointer cacheImage; + const InputImageType * input = this->GetInput(); + const InputImageRegionType largestRegion = input->GetLargestPossibleRegion(); + InputImagePointer cacheImage; itkDebugMacro("Writing file: " << m_FileName); @@ -342,7 +342,7 @@ ImageFileWriter::GenerateData() InputImageRegionType ioRegion; ImageIORegionAdaptor::Convert( m_ImageIO->GetIORegion(), ioRegion, largestRegion.GetIndex()); - InputImageRegionType bufferedRegion = input->GetBufferedRegion(); + const InputImageRegionType bufferedRegion = input->GetBufferedRegion(); // before this test, bad stuff would happened when they don't match if (bufferedRegion != ioRegion) diff --git a/Modules/IO/ImageBase/include/itkImageSeriesReader.hxx b/Modules/IO/ImageBase/include/itkImageSeriesReader.hxx index facfa035847..584ded7c1c2 100644 --- a/Modules/IO/ImageBase/include/itkImageSeriesReader.hxx +++ b/Modules/IO/ImageBase/include/itkImageSeriesReader.hxx @@ -93,13 +93,13 @@ template void ImageSeriesReader::GenerateOutputInformation() { - typename TOutputImage::Pointer output = this->GetOutput(); + const typename TOutputImage::Pointer output = this->GetOutput(); using SpacingScalarType = typename TOutputImage::SpacingValueType; Array position1(TOutputImage::ImageDimension, 0.0f); Array positionN(TOutputImage::ImageDimension, 0.0f); - std::string key("ITK_ImageOrigin"); + const std::string key("ITK_ImageOrigin"); // Clear the previous content of the MetaDictionary array if (!m_MetaDataDictionaryArray.empty()) @@ -198,7 +198,7 @@ ImageSeriesReader::GenerateOutputInformation() { dirN[j] = positionN[j] - position1[j]; } - SpacingScalarType dirNnorm = dirN.GetNorm(); + const SpacingScalarType dirNnorm = dirN.GetNorm(); if (Math::AlmostEquals(dirNnorm, 0.0)) { spacing[this->m_NumberOfDimensionsInImage] = 1.0; @@ -235,9 +235,9 @@ template void ImageSeriesReader::EnlargeOutputRequestedRegion(DataObject * output) { - typename TOutputImage::Pointer out = dynamic_cast(output); - ImageRegionType requestedRegion = out->GetRequestedRegion(); - ImageRegionType largestRegion = out->GetLargestPossibleRegion(); + const typename TOutputImage::Pointer out = dynamic_cast(output); + const ImageRegionType requestedRegion = out->GetRequestedRegion(); + const ImageRegionType largestRegion = out->GetLargestPossibleRegion(); if (m_UseStreaming) { @@ -255,9 +255,9 @@ ImageSeriesReader::GenerateData() { TOutputImage * output = this->GetOutput(); - ImageRegionType requestedRegion = output->GetRequestedRegion(); - ImageRegionType largestRegion = output->GetLargestPossibleRegion(); - ImageRegionType sliceRegionToRequest = output->GetRequestedRegion(); + const ImageRegionType requestedRegion = output->GetRequestedRegion(); + const ImageRegionType largestRegion = output->GetLargestPossibleRegion(); + ImageRegionType sliceRegionToRequest = output->GetRequestedRegion(); // Each file must have the same size. SizeType validSize = largestRegion.GetSize(); @@ -354,7 +354,7 @@ ImageSeriesReader::GenerateData() } // get the size of the region to be read - SizeType readSize = readerOutput->GetRequestedRegion().GetSize(); + const SizeType readSize = readerOutput->GetRequestedRegion().GetSize(); if (readSize == sliceRegionToRequest.GetSize()) { @@ -427,7 +427,7 @@ ImageSeriesReader::GenerateData() { dirN[j] = static_cast(sliceOrigin[j]) - static_cast(prevSliceOrigin[j]); } - SpacingScalarType dirNnorm = dirN.GetNorm(); + const SpacingScalarType dirNnorm = dirN.GetNorm(); if (this->m_SpacingDefined && !Math::AlmostEquals( diff --git a/Modules/IO/ImageBase/include/itkImageSeriesWriter.hxx b/Modules/IO/ImageBase/include/itkImageSeriesWriter.hxx index e16eb2e8f02..dfd323f3249 100644 --- a/Modules/IO/ImageBase/include/itkImageSeriesWriter.hxx +++ b/Modules/IO/ImageBase/include/itkImageSeriesWriter.hxx @@ -126,7 +126,7 @@ ImageSeriesWriter::GenerateNumericFileNames() m_FileNames.clear(); // We need two regions. One for the input, one for the output. - ImageRegion inRegion = inputImage->GetRequestedRegion(); + const ImageRegion inRegion = inputImage->GetRequestedRegion(); SizeValueType fileNumber = this->m_StartIndex; char fileName[IOCommon::ITK_MAXPATHLEN + 1]; @@ -256,7 +256,7 @@ ImageSeriesWriter::WriteFiles() for (unsigned int slice = 0; slice < m_FileNames.size(); ++slice) { // Select a "slice" of the image. - Index inIndex = inputImage->ComputeIndex(offset); + const Index inIndex = inputImage->ComputeIndex(offset); inRegion.SetIndex(inIndex); inRegion.SetSize(inSize); diff --git a/Modules/IO/ImageBase/src/itkArchetypeSeriesFileNames.cxx b/Modules/IO/ImageBase/src/itkArchetypeSeriesFileNames.cxx index 614fa399290..e5d13b284e9 100644 --- a/Modules/IO/ImageBase/src/itkArchetypeSeriesFileNames.cxx +++ b/Modules/IO/ImageBase/src/itkArchetypeSeriesFileNames.cxx @@ -90,9 +90,9 @@ ArchetypeSeriesFileNames::Scan() } // Parse the fileNameName and fileNamePath - std::string origFileName = itksys::SystemTools::GetFilenameName(unixArchetype.c_str()); - std::string fileNamePath = itksys::SystemTools::GetFilenamePath(unixArchetype.c_str()); - std::string pathPrefix; + const std::string origFileName = itksys::SystemTools::GetFilenameName(unixArchetype.c_str()); + std::string fileNamePath = itksys::SystemTools::GetFilenamePath(unixArchetype.c_str()); + std::string pathPrefix; // "Clean" the filename by escaping any special characters with backslashes. // This allows us to pass in filenames that include these special characters. @@ -120,16 +120,16 @@ ArchetypeSeriesFileNames::Scan() pathPrefix = ""; } - StringVectorType regExpFileNameVector; - std::string regExpString = "([0-9]+)"; - IntVectorType numGroupStart; - IntVectorType numGroupLength; + StringVectorType regExpFileNameVector; + const std::string regExpString = "([0-9]+)"; + IntVectorType numGroupStart; + IntVectorType numGroupLength; for (std::string::iterator sit = fileName.begin(); sit < fileName.end(); ++sit) { // If the element is a number, find its starting index and length. if ((*sit) >= '0' && (*sit) <= '9') { - int sIndex = static_cast(sit - fileName.begin()); + const int sIndex = static_cast(sit - fileName.begin()); numGroupStart.push_back(sIndex); // Loop to one past the end of the group of numbers. @@ -183,7 +183,7 @@ ArchetypeSeriesFileNames::Scan() fit->NumericSortOn(); names = fit->GetFileNames(); - std::vector::iterator ait = std::find(names.begin(), names.end(), pathPrefix + unixArchetype); + const std::vector::iterator ait = std::find(names.begin(), names.end(), pathPrefix + unixArchetype); // Accept the list if it contains the archetype and is not the // "trivial" list (containing only the archetype) diff --git a/Modules/IO/ImageBase/src/itkImageIOBase.cxx b/Modules/IO/ImageBase/src/itkImageIOBase.cxx index 8d52e8ef180..147de59385f 100644 --- a/Modules/IO/ImageBase/src/itkImageIOBase.cxx +++ b/Modules/IO/ImageBase/src/itkImageIOBase.cxx @@ -1102,7 +1102,7 @@ ImageIOBase::GenerateStreamableReadRegionFromRequestedRegion(const ImageIORegion } // dimension size we use to represent the region - unsigned int maxDimension = + const unsigned int maxDimension = minIODimension > requested.GetImageDimension() ? minIODimension : requested.GetImageDimension(); // First: allocate with the correct dimensions diff --git a/Modules/IO/ImageBase/src/itkNumericSeriesFileNames.cxx b/Modules/IO/ImageBase/src/itkNumericSeriesFileNames.cxx index 34ee684e59e..c26fc293aaf 100644 --- a/Modules/IO/ImageBase/src/itkNumericSeriesFileNames.cxx +++ b/Modules/IO/ImageBase/src/itkNumericSeriesFileNames.cxx @@ -58,11 +58,11 @@ NumericSeriesFileNames::GetFileNames() nchars = static_cast(m_SeriesFormat.size() + sizeof(c)); // enough room for path + // absurdly long integer string. } - OffsetValueType bufflen = nchars + 1; - const auto temp = make_unique_for_overwrite(bufflen); + const OffsetValueType bufflen = nchars + 1; + const auto temp = make_unique_for_overwrite(bufflen); ITK_GCC_PRAGMA_PUSH ITK_GCC_SUPPRESS_Wformat_nonliteral - OffsetValueType result = snprintf(temp.get(), bufflen, m_SeriesFormat.c_str(), i); + const OffsetValueType result = snprintf(temp.get(), bufflen, m_SeriesFormat.c_str(), i); ITK_GCC_PRAGMA_POP if (result < 0 || result >= bufflen) { @@ -72,7 +72,7 @@ NumericSeriesFileNames::GetFileNames() << "nchars: " << nchars << " bufflen: " << bufflen << " result: " << result; itkExceptionMacro(<< message_cache.str()); } - std::string fileName(temp.get()); + const std::string fileName(temp.get()); m_FileNames.push_back(fileName); } return m_FileNames; diff --git a/Modules/IO/ImageBase/src/itkStreamingImageIOBase.cxx b/Modules/IO/ImageBase/src/itkStreamingImageIOBase.cxx index 042b419818e..cd2903c3e63 100644 --- a/Modules/IO/ImageBase/src/itkStreamingImageIOBase.cxx +++ b/Modules/IO/ImageBase/src/itkStreamingImageIOBase.cxx @@ -39,7 +39,7 @@ StreamingImageIOBase::StreamReadBufferAsBinary(std::istream & file, void * _buff auto * buffer = static_cast(_buffer); // Offset into file - std::streampos dataPos = this->GetDataPosition(); + const std::streampos dataPos = this->GetDataPosition(); itkDebugStatement(const std::streamsize sizeOfRegion = static_cast(m_IORegion.GetNumberOfPixels()) * this->GetPixelSize()); @@ -118,7 +118,7 @@ StreamingImageIOBase::ReadBufferAsBinary(std::istream & is, void * buffer, Strea while (bytesRemaining) { - std::streamsize bytesToRead = bytesRemaining > maxChunk ? maxChunk : bytesRemaining; + const std::streamsize bytesToRead = bytesRemaining > maxChunk ? maxChunk : bytesRemaining; itkDebugMacro("Reading " << bytesToRead << " of " << bytesRemaining << " bytes for " << m_FileName); @@ -145,7 +145,7 @@ StreamingImageIOBase::WriteBufferAsBinary(std::ostream & os, const void * buffer while (bytesRemaining) { - SizeType bytesToWrite = bytesRemaining > maxChunk ? maxChunk : bytesRemaining; + const SizeType bytesToWrite = bytesRemaining > maxChunk ? maxChunk : bytesRemaining; itkDebugMacro("Writing " << bytesToWrite << " of " << bytesRemaining << " bytes for " << m_FileName); @@ -169,7 +169,7 @@ StreamingImageIOBase::StreamWriteBufferAsBinary(std::ostream & file, const void const auto * buffer = static_cast(_buffer); // Offset into file - std::streampos dataPos = this->GetDataPosition(); + const std::streampos dataPos = this->GetDataPosition(); // compute the number of continuous bytes to be written std::streamsize sizeOfChunk = 1; @@ -265,8 +265,8 @@ StreamingImageIOBase::GetActualNumberOfSplitsForWriting(unsigned int nu // we are going to be pasting (may be streaming too) // need to check to see if the file is compatible - std::string errorMessage; - Pointer headerImageIOReader = dynamic_cast(this->CreateAnother().GetPointer()); + std::string errorMessage; + const Pointer headerImageIOReader = dynamic_cast(this->CreateAnother().GetPointer()); try { @@ -382,7 +382,8 @@ StreamingImageIOBase::RequestedToStream() const // This enables a 2D request from a 3D volume to get the first slice, // and a 4D with a 1-sized 4th dimension to equal the 3D volume // as well. - unsigned int maxNumberOfDimension = std::max(this->GetNumberOfDimensions(), this->GetIORegion().GetImageDimension()); + const unsigned int maxNumberOfDimension = + std::max(this->GetNumberOfDimensions(), this->GetIORegion().GetImageDimension()); ImageIORegion ioregion(maxNumberOfDimension); ImageIORegion largestRegion(maxNumberOfDimension); diff --git a/Modules/IO/ImageBase/test/itk64bitTest.cxx b/Modules/IO/ImageBase/test/itk64bitTest.cxx index 009345bab2f..fc826dfe145 100644 --- a/Modules/IO/ImageBase/test/itk64bitTest.cxx +++ b/Modules/IO/ImageBase/test/itk64bitTest.cxx @@ -29,7 +29,7 @@ int verifyContent(ImageType::Pointer image) { itk::ImageRegionConstIterator it(image, image->GetBufferedRegion()); - unsigned long long imageSize = 4 * 3 * 2; + const unsigned long long imageSize = 4 * 3 * 2; unsigned long long value = 1; while (!it.IsAtEnd() && value <= imageSize) { @@ -70,7 +70,7 @@ itk64bitTest(int argc, char * argv[]) { std::cout << "Reading " << argv[1] << std::endl; reader->Update(); - ImageType::Pointer image = reader->GetOutput(); + const ImageType::Pointer image = reader->GetOutput(); returnValue += verifyContent(image); std::cout << "Writing " << argv[2] << std::endl; @@ -83,7 +83,7 @@ itk64bitTest(int argc, char * argv[]) std::cout << "Reading " << argv[2] << std::endl; reader->SetFileName(argv[2]); reader->Update(); - ImageType::Pointer image2 = reader->GetOutput(); + const ImageType::Pointer image2 = reader->GetOutput(); returnValue += verifyContent(image2); } catch (const itk::ExceptionObject & exc) diff --git a/Modules/IO/ImageBase/test/itkArchetypeSeriesFileNamesTest.cxx b/Modules/IO/ImageBase/test/itkArchetypeSeriesFileNamesTest.cxx index ac3a9894aab..b36b91a8c58 100644 --- a/Modules/IO/ImageBase/test/itkArchetypeSeriesFileNamesTest.cxx +++ b/Modules/IO/ImageBase/test/itkArchetypeSeriesFileNamesTest.cxx @@ -37,11 +37,11 @@ itkArchetypeSeriesFileNamesTest(int argc, char * argv[]) std::cout << "Testing argument " << i << std::endl; std::cout << "Archetype name: " << argv[i] << std::endl; - itk::ArchetypeSeriesFileNames::Pointer fit = itk::ArchetypeSeriesFileNames::New(); + const itk::ArchetypeSeriesFileNames::Pointer fit = itk::ArchetypeSeriesFileNames::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(fit, ArchetypeSeriesFileNames, Object); - std::string archetype = argv[i]; + const std::string archetype = argv[i]; fit->SetArchetype(archetype); ITK_TEST_SET_GET_VALUE(archetype, fit->GetArchetype()); diff --git a/Modules/IO/ImageBase/test/itkConvertBufferTest.cxx b/Modules/IO/ImageBase/test/itkConvertBufferTest.cxx index ee2304b8ed9..ca2cdaf1777 100644 --- a/Modules/IO/ImageBase/test/itkConvertBufferTest.cxx +++ b/Modules/IO/ImageBase/test/itkConvertBufferTest.cxx @@ -23,10 +23,10 @@ int itkConvertBufferTest(int, char *[]) { - int piInit[3] = { 3, 1, 4 }; - itk::RGBPixel pi = piInit; - int piaInit[4] = { 3, 1, 4, 1 }; - itk::RGBAPixel pia = piaInit; + int piInit[3] = { 3, 1, 4 }; + const itk::RGBPixel pi = piInit; + int piaInit[4] = { 3, 1, 4, 1 }; + const itk::RGBAPixel pia = piaInit; std::cerr << "RGBPixel: " << pi << '\n'; std::cerr << "RGBAPixel: " << pia << '\n'; diff --git a/Modules/IO/ImageBase/test/itkIOCommonTest.cxx b/Modules/IO/ImageBase/test/itkIOCommonTest.cxx index 637b570fb36..c98bbbca578 100644 --- a/Modules/IO/ImageBase/test/itkIOCommonTest.cxx +++ b/Modules/IO/ImageBase/test/itkIOCommonTest.cxx @@ -30,7 +30,7 @@ CheckFileNameParsing(const std::string & fileName, std::cout << "(kwsys) Extracting...file name..."; char * nameOnly; { - std::string fileNameString = + const std::string fileNameString = itksys::SystemTools::GetFilenameWithoutLastExtension(itksys::SystemTools::GetFilenameName(fileName)); nameOnly = new char[fileNameString.size() + 1]; std::strncpy(nameOnly, fileNameString.c_str(), fileNameString.size() + 1); @@ -39,7 +39,7 @@ CheckFileNameParsing(const std::string & fileName, std::cout << "extension..."; char * extension; { - std::string extensionString = itksys::SystemTools::GetFilenameLastExtension(fileName); + const std::string extensionString = itksys::SystemTools::GetFilenameLastExtension(fileName); // NB: remove the period (kwsys leaves it on, ITK precedent was to // remove it) extension = new char[extensionString.size() + 1]; @@ -124,7 +124,7 @@ CheckFileNameParsing(const std::string & fileName, std::cout << "Path: (expected) \"" << correctPath << "\" (actual) \"" << static_cast(path) << '"' << " (correct) " << pathMatches << std::endl; - bool correctParse = nameMatches && extensionMatches && pathMatches; + const bool correctParse = nameMatches && extensionMatches && pathMatches; std::cout << "Parsing is " << (correctParse ? "correct" : "incorrect") << std::endl; // clean up diff --git a/Modules/IO/ImageBase/test/itkIOCommonTest2.cxx b/Modules/IO/ImageBase/test/itkIOCommonTest2.cxx index 0174bdd207f..b628a11ab07 100644 --- a/Modules/IO/ImageBase/test/itkIOCommonTest2.cxx +++ b/Modules/IO/ImageBase/test/itkIOCommonTest2.cxx @@ -23,7 +23,7 @@ itkIOCommonTest2(int, char *[]) { // Test the atomic pixel type to string conversions { - std::string unsignedCharPixelType = + const std::string unsignedCharPixelType = itk::IOCommon::AtomicPixelTypeToString(itk::IOCommon::AtomicPixelEnum::ITK_UCHAR); if (unsignedCharPixelType.compare("unsigned char") != 0) { @@ -31,14 +31,14 @@ itkIOCommonTest2(int, char *[]) return EXIT_FAILURE; } - std::string charPixelType = itk::IOCommon::AtomicPixelTypeToString(itk::IOCommon::AtomicPixelEnum::ITK_CHAR); + const std::string charPixelType = itk::IOCommon::AtomicPixelTypeToString(itk::IOCommon::AtomicPixelEnum::ITK_CHAR); if (charPixelType.compare("char") != 0) { std::cerr << "AtomicPixelTypeToString(ITK_CHAR) should return 'char"; return EXIT_FAILURE; } - std::string unsignedShortPixelType = + const std::string unsignedShortPixelType = itk::IOCommon::AtomicPixelTypeToString(itk::IOCommon::AtomicPixelEnum::ITK_USHORT); if (unsignedShortPixelType.compare("unsigned short") != 0) { @@ -46,28 +46,30 @@ itkIOCommonTest2(int, char *[]) return EXIT_FAILURE; } - std::string shortPixelType = itk::IOCommon::AtomicPixelTypeToString(itk::IOCommon::AtomicPixelEnum::ITK_SHORT); + const std::string shortPixelType = + itk::IOCommon::AtomicPixelTypeToString(itk::IOCommon::AtomicPixelEnum::ITK_SHORT); if (shortPixelType.compare("short") != 0) { std::cerr << "AtomicPixelTypeToString(ITK_SHORT) should return 'short'"; return EXIT_FAILURE; } - std::string unsignedIntPixelType = itk::IOCommon::AtomicPixelTypeToString(itk::IOCommon::AtomicPixelEnum::ITK_UINT); + const std::string unsignedIntPixelType = + itk::IOCommon::AtomicPixelTypeToString(itk::IOCommon::AtomicPixelEnum::ITK_UINT); if (unsignedIntPixelType.compare("unsigned int") != 0) { std::cerr << "AtomicPixelTypeToString(ITK_UINT) should return 'unsigned int'"; return EXIT_FAILURE; } - std::string intPixelType = itk::IOCommon::AtomicPixelTypeToString(itk::IOCommon::AtomicPixelEnum::ITK_INT); + const std::string intPixelType = itk::IOCommon::AtomicPixelTypeToString(itk::IOCommon::AtomicPixelEnum::ITK_INT); if (intPixelType.compare("int") != 0) { std::cerr << "AtomicPixelTypeToString(ITK_INT) should return 'int'"; return EXIT_FAILURE; } - std::string unsignedLongPixelType = + const std::string unsignedLongPixelType = itk::IOCommon::AtomicPixelTypeToString(itk::IOCommon::AtomicPixelEnum::ITK_ULONG); if (unsignedLongPixelType.compare("unsigned long") != 0) { @@ -75,21 +77,23 @@ itkIOCommonTest2(int, char *[]) return EXIT_FAILURE; } - std::string longPixelType = itk::IOCommon::AtomicPixelTypeToString(itk::IOCommon::AtomicPixelEnum::ITK_LONG); + const std::string longPixelType = itk::IOCommon::AtomicPixelTypeToString(itk::IOCommon::AtomicPixelEnum::ITK_LONG); if (longPixelType.compare("long") != 0) { std::cerr << "AtomicPixelTypeToString(ITK_LONG) should return 'long'"; return EXIT_FAILURE; } - std::string floatPixelType = itk::IOCommon::AtomicPixelTypeToString(itk::IOCommon::AtomicPixelEnum::ITK_FLOAT); + const std::string floatPixelType = + itk::IOCommon::AtomicPixelTypeToString(itk::IOCommon::AtomicPixelEnum::ITK_FLOAT); if (floatPixelType.compare("float") != 0) { std::cerr << "AtomicPixelTypeToString(ITK_FLOAT) should return 'float'"; return EXIT_FAILURE; } - std::string doublePixelType = itk::IOCommon::AtomicPixelTypeToString(itk::IOCommon::AtomicPixelEnum::ITK_DOUBLE); + const std::string doublePixelType = + itk::IOCommon::AtomicPixelTypeToString(itk::IOCommon::AtomicPixelEnum::ITK_DOUBLE); if (doublePixelType.compare("double") != 0) { std::cerr << "AtomicPixelTypeToString(ITK_DOUBLE) should return 'double'"; @@ -99,7 +103,7 @@ itkIOCommonTest2(int, char *[]) // Test the atomic pixel type size computation { - unsigned int unsignedCharPixelTypeSize = + const unsigned int unsignedCharPixelTypeSize = itk::IOCommon::ComputeSizeOfAtomicPixelType(itk::IOCommon::AtomicPixelEnum::ITK_UCHAR); if (unsignedCharPixelTypeSize != static_cast(sizeof(unsigned char))) { @@ -107,7 +111,7 @@ itkIOCommonTest2(int, char *[]) return EXIT_FAILURE; } - unsigned int charPixelTypeSize = + const unsigned int charPixelTypeSize = itk::IOCommon::ComputeSizeOfAtomicPixelType(itk::IOCommon::AtomicPixelEnum::ITK_CHAR); if (charPixelTypeSize != static_cast(sizeof(unsigned char))) { @@ -115,21 +119,21 @@ itkIOCommonTest2(int, char *[]) return EXIT_FAILURE; } - unsigned int unsignedShortPixelTypeSize = + const unsigned int unsignedShortPixelTypeSize = itk::IOCommon::ComputeSizeOfAtomicPixelType(itk::IOCommon::AtomicPixelEnum::ITK_USHORT); if (unsignedShortPixelTypeSize != static_cast(sizeof(unsigned short))) { std::cerr << "ComputeSizeOfAtomicPixelType(ITK_USHORT) is not returning the correct pixel size "; return EXIT_FAILURE; } - unsigned int shortPixelTypeSize = + const unsigned int shortPixelTypeSize = itk::IOCommon::ComputeSizeOfAtomicPixelType(itk::IOCommon::AtomicPixelEnum::ITK_SHORT); if (shortPixelTypeSize != static_cast(sizeof(short))) { std::cerr << "ComputeSizeOfAtomicPixelType(ITK_SHORT) is not returning the correct pixel size "; return EXIT_FAILURE; } - unsigned int unsignedIntPixelTypeSize = + const unsigned int unsignedIntPixelTypeSize = itk::IOCommon::ComputeSizeOfAtomicPixelType(itk::IOCommon::AtomicPixelEnum::ITK_UINT); if (unsignedIntPixelTypeSize != static_cast(sizeof(unsigned int))) { @@ -137,7 +141,7 @@ itkIOCommonTest2(int, char *[]) return EXIT_FAILURE; } - unsigned int intPixelTypeSize = + const unsigned int intPixelTypeSize = itk::IOCommon::ComputeSizeOfAtomicPixelType(itk::IOCommon::AtomicPixelEnum::ITK_INT); if (intPixelTypeSize != static_cast(sizeof(int))) { @@ -145,7 +149,7 @@ itkIOCommonTest2(int, char *[]) return EXIT_FAILURE; } - unsigned int unsignedLongPixelTypeSize = + const unsigned int unsignedLongPixelTypeSize = itk::IOCommon::ComputeSizeOfAtomicPixelType(itk::IOCommon::AtomicPixelEnum::ITK_ULONG); if (unsignedLongPixelTypeSize != static_cast(sizeof(unsigned long))) { @@ -153,7 +157,7 @@ itkIOCommonTest2(int, char *[]) return EXIT_FAILURE; } - unsigned int longPixelTypeSize = + const unsigned int longPixelTypeSize = itk::IOCommon::ComputeSizeOfAtomicPixelType(itk::IOCommon::AtomicPixelEnum::ITK_LONG); if (longPixelTypeSize != static_cast(sizeof(long))) { @@ -161,7 +165,7 @@ itkIOCommonTest2(int, char *[]) return EXIT_FAILURE; } - unsigned int floatPixelTypeSize = + const unsigned int floatPixelTypeSize = itk::IOCommon::ComputeSizeOfAtomicPixelType(itk::IOCommon::AtomicPixelEnum::ITK_FLOAT); if (floatPixelTypeSize != static_cast(sizeof(float))) { @@ -169,7 +173,7 @@ itkIOCommonTest2(int, char *[]) return EXIT_FAILURE; } - unsigned int doublePixelTypeSize = + const unsigned int doublePixelTypeSize = itk::IOCommon::ComputeSizeOfAtomicPixelType(itk::IOCommon::AtomicPixelEnum::ITK_DOUBLE); if (doublePixelTypeSize != static_cast(sizeof(double))) { diff --git a/Modules/IO/ImageBase/test/itkImageFileReaderDimensionsTest.cxx b/Modules/IO/ImageBase/test/itkImageFileReaderDimensionsTest.cxx index 4d641c47235..eba30463845 100644 --- a/Modules/IO/ImageBase/test/itkImageFileReaderDimensionsTest.cxx +++ b/Modules/IO/ImageBase/test/itkImageFileReaderDimensionsTest.cxx @@ -48,15 +48,15 @@ itkImageFileReaderDimensionsTest(int argc, char * argv[]) using Writer4DType = itk::ImageFileWriter; - std::string tempFile1 = + const std::string tempFile1 = std::string(argv[2]) + std::string("/itkImageFileReaderDimensionsTest_1.") + std::string(argv[3]); - std::string tempFile2 = + const std::string tempFile2 = std::string(argv[2]) + std::string("/itkImageFileReaderDimensionsTest_2.") + std::string(argv[3]); - std::string tempFile3 = + const std::string tempFile3 = std::string(argv[2]) + std::string("/itkImageFileReaderDimensionsTest_3.") + std::string(argv[3]); - std::string tempFile4 = + const std::string tempFile4 = std::string(argv[2]) + std::string("/itkImageFileReaderDimensionsTest_4.") + std::string(argv[3]); - std::string tempFile5 = + const std::string tempFile5 = std::string(argv[2]) + std::string("/itkImageFileReaderDimensionsTest_5.") + std::string(argv[3]); // we expect the filename to be 2 or 3 dimensions @@ -164,7 +164,7 @@ itkImageFileReaderDimensionsTest(int argc, char * argv[]) auto reader = Reader4DType::New(); reader->SetFileName(tempFile4); - Image4DType::RegionType region = reader->GetOutput()->GetLargestPossibleRegion(); + const Image4DType::RegionType region = reader->GetOutput()->GetLargestPossibleRegion(); // the dimension of this ioregion is an error, since it is one // less then the image file dimension diff --git a/Modules/IO/ImageBase/test/itkImageFileReaderPositiveSpacingTest.cxx b/Modules/IO/ImageBase/test/itkImageFileReaderPositiveSpacingTest.cxx index 51e93daa3d6..0a4d4357b7c 100644 --- a/Modules/IO/ImageBase/test/itkImageFileReaderPositiveSpacingTest.cxx +++ b/Modules/IO/ImageBase/test/itkImageFileReaderPositiveSpacingTest.cxx @@ -40,7 +40,7 @@ itkImageFileReaderPositiveSpacingTest(int argc, char * argv[]) auto reader = ReaderType::New(); reader->SetFileName(argv[1]); reader->Update(); - ImageNDType::Pointer image = reader->GetOutput(); + const ImageNDType::Pointer image = reader->GetOutput(); image->DisconnectPipeline(); ImageNDType::SpacingType spacing = image->GetSpacing(); for (unsigned int ii = 0; ii < image->GetImageDimension(); ++ii) @@ -52,7 +52,7 @@ itkImageFileReaderPositiveSpacingTest(int argc, char * argv[]) } } std::cout << "Spacing: " << spacing << std::endl; - ImageNDType::DirectionType direction = image->GetDirection(); + const ImageNDType::DirectionType direction = image->GetDirection(); std::cout << "Direction: " << '\n' << direction << std::endl; MetaImage metaImage; @@ -101,8 +101,8 @@ itkImageFileReaderPositiveSpacingTest(int argc, char * argv[]) IteratorType it(image, image->GetLargestPossibleRegion()); for (it.GoToBegin(); !it.IsAtEnd(); ++it) { - ImageNDType::IndexType index = it.GetIndex(); - ImageNDType::PointType point; + const ImageNDType::IndexType index = it.GetIndex(); + ImageNDType::PointType point; image->TransformIndexToPhysicalPoint(index, point); // Compute index from physical point in baseline ImageNDType::IndexType baselineIndex; diff --git a/Modules/IO/ImageBase/test/itkImageFileReaderStreamingTest.cxx b/Modules/IO/ImageBase/test/itkImageFileReaderStreamingTest.cxx index 5c44f918864..88d62be96d6 100644 --- a/Modules/IO/ImageBase/test/itkImageFileReaderStreamingTest.cxx +++ b/Modules/IO/ImageBase/test/itkImageFileReaderStreamingTest.cxx @@ -32,7 +32,7 @@ itkImageFileReaderStreamingTest(int argc, char * argv[]) return EXIT_FAILURE; } - unsigned int numberOfDataPieces = 4; + const unsigned int numberOfDataPieces = 4; bool expectedToStream = true; if (argc > 2) @@ -60,7 +60,7 @@ itkImageFileReaderStreamingTest(int argc, char * argv[]) auto reader = ReaderType::New(); reader->SetFileName(argv[1]); - bool useStreaming = true; + const bool useStreaming = true; ITK_TEST_SET_GET_BOOLEAN(reader, UseStreaming, useStreaming); using MonitorFilter = itk::PipelineMonitorImageFilter; diff --git a/Modules/IO/ImageBase/test/itkImageFileReaderStreamingTest2.cxx b/Modules/IO/ImageBase/test/itkImageFileReaderStreamingTest2.cxx index 11981fe1eea..5a518e71dcf 100644 --- a/Modules/IO/ImageBase/test/itkImageFileReaderStreamingTest2.cxx +++ b/Modules/IO/ImageBase/test/itkImageFileReaderStreamingTest2.cxx @@ -38,9 +38,9 @@ bool SameRegionImage(ImageConstPointer test, ImageConstPointer baseline) { - PixelType intensityTolerance = 0; - unsigned int radiusTolerance = 0; - unsigned int numberOfPixelTolerance = 0; + const PixelType intensityTolerance = 0; + const unsigned int radiusTolerance = 0; + const unsigned int numberOfPixelTolerance = 0; using ExtractImageFilter = itk::ExtractImageFilter; auto extractor = ExtractImageFilter::New(); @@ -57,7 +57,7 @@ SameRegionImage(ImageConstPointer test, ImageConstPointer baseline) diff->SetToleranceRadius(radiusTolerance); diff->UpdateLargestPossibleRegion(); - unsigned long status = diff->GetNumberOfPixelsWithDifferences(); + const unsigned long status = diff->GetNumberOfPixelsWithDifferences(); std::cout << "NumberOfPixelsWithDifferences: " << status << std::endl; if (status > numberOfPixelTolerance) @@ -86,7 +86,7 @@ itkImageFileReaderStreamingTest2(int argc, char * argv[]) baselineReader->SetFileName(argv[1]); baselineReader->UpdateLargestPossibleRegion(); - ImageType::ConstPointer baselineImage = baselineReader->GetOutput(); + const ImageType::ConstPointer baselineImage = baselineReader->GetOutput(); auto streamingReader = ReaderType::New(); streamingReader->SetFileName(argv[1]); diff --git a/Modules/IO/ImageBase/test/itkImageFileWriterPastingTest1.cxx b/Modules/IO/ImageBase/test/itkImageFileWriterPastingTest1.cxx index d6d955c78f0..a4a47777afd 100644 --- a/Modules/IO/ImageBase/test/itkImageFileWriterPastingTest1.cxx +++ b/Modules/IO/ImageBase/test/itkImageFileWriterPastingTest1.cxx @@ -45,7 +45,7 @@ itkImageFileWriterPastingTest1(int argc, char * argv[]) reader->SetFileName(argv[1]); reader->SetUseStreaming(true); - unsigned int m_NumberOfPieces = 10; + const unsigned int m_NumberOfPieces = 10; // We decide how we want to read the image and we split accordingly // The image is read slice by slice @@ -58,7 +58,7 @@ itkImageFileWriterPastingTest1(int argc, char * argv[]) size[1] = fullsize[1]; size[2] = 0; - unsigned int zsize = fullsize[2] / m_NumberOfPieces; + const unsigned int zsize = fullsize[2] / m_NumberOfPieces; // Setup the writer auto writer = WriterType::New(); diff --git a/Modules/IO/ImageBase/test/itkImageFileWriterPastingTest2.cxx b/Modules/IO/ImageBase/test/itkImageFileWriterPastingTest2.cxx index 4acefe1988e..351d142dc6b 100644 --- a/Modules/IO/ImageBase/test/itkImageFileWriterPastingTest2.cxx +++ b/Modules/IO/ImageBase/test/itkImageFileWriterPastingTest2.cxx @@ -31,9 +31,9 @@ using ImagePointer = ImageType::Pointer; bool SameImage(ImagePointer testImage, ImagePointer baselineImage) { - PixelType intensityTolerance = 0; - int radiusTolerance = 0; - unsigned long numberOfPixelTolerance = 0; + const PixelType intensityTolerance = 0; + const int radiusTolerance = 0; + const unsigned long numberOfPixelTolerance = 0; using DiffType = itk::Testing::ComparisonImageFilter; auto diff = DiffType::New(); @@ -43,7 +43,7 @@ SameImage(ImagePointer testImage, ImagePointer baselineImage) diff->SetToleranceRadius(radiusTolerance); diff->UpdateLargestPossibleRegion(); - unsigned long status = diff->GetNumberOfPixelsWithDifferences(); + const unsigned long status = diff->GetNumberOfPixelsWithDifferences(); if (status > numberOfPixelTolerance) { @@ -98,7 +98,7 @@ itkImageFileWriterPastingTest2(int argc, char * argv[]) pasteSize[0] = largestRegion.GetSize()[0] / 3; pasteSize[1] = largestRegion.GetSize()[1] / 3; pasteSize[2] = largestRegion.GetSize()[2] / 3; - ImageType::RegionType pasteRegion(pasteIndex, pasteSize); + const ImageType::RegionType pasteRegion(pasteIndex, pasteSize); using MonitorFilter = itk::PipelineMonitorImageFilter; auto monitor = MonitorFilter::New(); diff --git a/Modules/IO/ImageBase/test/itkImageFileWriterPastingTest3.cxx b/Modules/IO/ImageBase/test/itkImageFileWriterPastingTest3.cxx index 8633e7e3d01..dda7b4d2b69 100644 --- a/Modules/IO/ImageBase/test/itkImageFileWriterPastingTest3.cxx +++ b/Modules/IO/ImageBase/test/itkImageFileWriterPastingTest3.cxx @@ -33,9 +33,9 @@ namespace bool SameImage(ImagePointer testImage, ImagePointer baselineImage) { - PixelType intensityTolerance = 0; - int radiusTolerance = 0; - unsigned long numberOfPixelTolerance = 0; + const PixelType intensityTolerance = 0; + const int radiusTolerance = 0; + const unsigned long numberOfPixelTolerance = 0; using DiffType = itk::Testing::ComparisonImageFilter; auto diff = DiffType::New(); @@ -45,7 +45,7 @@ SameImage(ImagePointer testImage, ImagePointer baselineImage) diff->SetToleranceRadius(radiusTolerance); diff->UpdateLargestPossibleRegion(); - unsigned long status = diff->GetNumberOfPixelsWithDifferences(); + const unsigned long status = diff->GetNumberOfPixelsWithDifferences(); if (status > numberOfPixelTolerance) { @@ -94,7 +94,7 @@ itkImageFileWriterPastingTest3(int argc, char * argv[]) reader->SetUseStreaming(true); reader->UpdateOutputInformation(); - ImageType::RegionType largestRegion = reader->GetOutput()->GetLargestPossibleRegion(); + const ImageType::RegionType largestRegion = reader->GetOutput()->GetLargestPossibleRegion(); ImageType::RegionType ioRegion; ImageType::IndexType ioIndex; diff --git a/Modules/IO/ImageBase/test/itkImageFileWriterStreamingPastingCompressingTest1.cxx b/Modules/IO/ImageBase/test/itkImageFileWriterStreamingPastingCompressingTest1.cxx index e9ce076fd2a..87ef09f928c 100644 --- a/Modules/IO/ImageBase/test/itkImageFileWriterStreamingPastingCompressingTest1.cxx +++ b/Modules/IO/ImageBase/test/itkImageFileWriterStreamingPastingCompressingTest1.cxx @@ -38,9 +38,9 @@ namespace bool SameImage(ImagePointer testImage, ImagePointer baselineImage) { - PixelType intensityTolerance = 5; // need this for compression - int radiusTolerance = 0; - unsigned long numberOfPixelTolerance = 0; + const PixelType intensityTolerance = 5; // need this for compression + const int radiusTolerance = 0; + const unsigned long numberOfPixelTolerance = 0; // NOTE ALEX: it look slike this filter does not take the spacing // into account, to check later. @@ -52,7 +52,7 @@ SameImage(ImagePointer testImage, ImagePointer baselineImage) diff->SetToleranceRadius(radiusTolerance); diff->UpdateLargestPossibleRegion(); - unsigned long status = diff->GetNumberOfPixelsWithDifferences(); + const unsigned long status = diff->GetNumberOfPixelsWithDifferences(); if (status > numberOfPixelTolerance) { @@ -104,10 +104,10 @@ ActualTest(std::string inputFileName, outputFileNameStream << outputFileNameBase << streamWriting; outputFileNameStream << pasteWriting << compressWriting; outputFileNameStream << '.' << outputFileNameExtension; - std::string outputFileName = outputFileNameStream.str(); + const std::string outputFileName = outputFileNameStream.str(); std::cout << "Writing to File: " << outputFileName << std::endl; - unsigned int m_NumberOfPieces = 10; + const unsigned int m_NumberOfPieces = 10; // We remove the output file // NOTE ALEX: should we check it exists first? @@ -137,7 +137,7 @@ ActualTest(std::string inputFileName, pasteSize[0] = largestRegion.GetSize()[0] / 3; pasteSize[1] = largestRegion.GetSize()[1] / 3; pasteSize[2] = 1; - ImageType::RegionType pasteRegion(pasteIndex, pasteSize); + const ImageType::RegionType pasteRegion(pasteIndex, pasteSize); // TODO: drew, check and save the spacing of the input image here diff --git a/Modules/IO/ImageBase/test/itkImageFileWriterStreamingTest1.cxx b/Modules/IO/ImageBase/test/itkImageFileWriterStreamingTest1.cxx index e5ef46bfde3..b4fc55c4fc6 100644 --- a/Modules/IO/ImageBase/test/itkImageFileWriterStreamingTest1.cxx +++ b/Modules/IO/ImageBase/test/itkImageFileWriterStreamingTest1.cxx @@ -45,7 +45,7 @@ itkImageFileWriterStreamingTest1(int argc, char * argv[]) } - unsigned int numberOfDataPieces = 4; + const unsigned int numberOfDataPieces = 4; bool forceNoStreamingInput = false; diff --git a/Modules/IO/ImageBase/test/itkImageFileWriterStreamingTest2.cxx b/Modules/IO/ImageBase/test/itkImageFileWriterStreamingTest2.cxx index 7f07928778a..62e47c44218 100644 --- a/Modules/IO/ImageBase/test/itkImageFileWriterStreamingTest2.cxx +++ b/Modules/IO/ImageBase/test/itkImageFileWriterStreamingTest2.cxx @@ -34,9 +34,9 @@ bool SameImage(std::string output, std::string baseline) { - PixelType intensityTolerance = 0; - unsigned int radiusTolerance = 0; - unsigned int numberOfPixelTolerance = 0; + const PixelType intensityTolerance = 0; + const unsigned int radiusTolerance = 0; + const unsigned int numberOfPixelTolerance = 0; auto testReader = ReaderType::New(); auto baselineReader = ReaderType::New(); @@ -51,7 +51,7 @@ SameImage(std::string output, std::string baseline) diff->SetToleranceRadius(radiusTolerance); diff->UpdateLargestPossibleRegion(); - unsigned long status = diff->GetNumberOfPixelsWithDifferences(); + const unsigned long status = diff->GetNumberOfPixelsWithDifferences(); if (status > numberOfPixelTolerance) { @@ -79,7 +79,7 @@ itkImageFileWriterStreamingTest2(int argc, char * argv[]) // - unsigned int numberOfDataPieces = 4; + const unsigned int numberOfDataPieces = 4; auto reader = ReaderType::New(); reader->SetFileName(argv[1]); diff --git a/Modules/IO/ImageBase/test/itkImageFileWriterTest.cxx b/Modules/IO/ImageBase/test/itkImageFileWriterTest.cxx index f572e6509b4..ce32185dddd 100644 --- a/Modules/IO/ImageBase/test/itkImageFileWriterTest.cxx +++ b/Modules/IO/ImageBase/test/itkImageFileWriterTest.cxx @@ -33,11 +33,11 @@ itkImageFileWriterTest(int argc, char * argv[]) using ImageNDType = itk::Image; using WriterType = itk::ImageFileWriter; - auto image = ImageNDType::New(); - ImageNDType::IndexType index{}; - auto size = itk::MakeFilled(5); + auto image = ImageNDType::New(); + const ImageNDType::IndexType index{}; + auto size = itk::MakeFilled(5); - ImageNDType::RegionType region{ index, size }; + const ImageNDType::RegionType region{ index, size }; image->SetRegions(region); image->Allocate(); diff --git a/Modules/IO/ImageBase/test/itkImageFileWriterTest2.cxx b/Modules/IO/ImageBase/test/itkImageFileWriterTest2.cxx index c87556388cc..e676857d7e3 100644 --- a/Modules/IO/ImageBase/test/itkImageFileWriterTest2.cxx +++ b/Modules/IO/ImageBase/test/itkImageFileWriterTest2.cxx @@ -35,9 +35,9 @@ itkImageFileWriterTest2(int argc, char * argv[]) auto image = ImageNDType::New(); - auto size = itk::MakeFilled(5); - auto index = itk::MakeFilled(1); - ImageNDType::RegionType region{ index, size }; + auto size = itk::MakeFilled(5); + auto index = itk::MakeFilled(1); + const ImageNDType::RegionType region{ index, size }; image->SetRegions(region); image->AllocateInitialized(); diff --git a/Modules/IO/ImageBase/test/itkImageFileWriterUpdateLargestPossibleRegionTest.cxx b/Modules/IO/ImageBase/test/itkImageFileWriterUpdateLargestPossibleRegionTest.cxx index e100274a298..bb1b37da959 100644 --- a/Modules/IO/ImageBase/test/itkImageFileWriterUpdateLargestPossibleRegionTest.cxx +++ b/Modules/IO/ImageBase/test/itkImageFileWriterUpdateLargestPossibleRegionTest.cxx @@ -45,9 +45,9 @@ itkImageFileWriterUpdateLargestPossibleRegionTest(int argc, char * argv[]) writer->SetInput(reader->GetOutput()); writer->SetFileName(argv[2]); - ImageType::RegionType region = reader->GetOutput()->GetLargestPossibleRegion(); - ImageType::IndexType index = region.GetIndex(); - ImageType::SizeType size = region.GetSize(); + const ImageType::RegionType region = reader->GetOutput()->GetLargestPossibleRegion(); + ImageType::IndexType index = region.GetIndex(); + ImageType::SizeType size = region.GetSize(); itk::ImageIORegion ioregion(2); ioregion.SetIndex(0, index[0]); diff --git a/Modules/IO/ImageBase/test/itkImageIOBaseTest.cxx b/Modules/IO/ImageBase/test/itkImageIOBaseTest.cxx index 8aa6279a8b3..48bc20242d8 100644 --- a/Modules/IO/ImageBase/test/itkImageIOBaseTest.cxx +++ b/Modules/IO/ImageBase/test/itkImageIOBaseTest.cxx @@ -28,7 +28,7 @@ int itkImageIOBaseTest(int, char *[]) { - itk::MetaImageIO::Pointer reader = itk::MetaImageIO::New(); + const itk::MetaImageIO::Pointer reader = itk::MetaImageIO::New(); reader->SetNumberOfDimensions(3); bool gotException = false; @@ -119,49 +119,49 @@ itkImageIOBaseTest(int, char *[]) return EXIT_FAILURE; } { // Test string <-> type conversions - itk::IOComponentEnum listComponentType[] = { itk::IOComponentEnum::UNKNOWNCOMPONENTTYPE, - itk::IOComponentEnum::UCHAR, - itk::IOComponentEnum::CHAR, - itk::IOComponentEnum::USHORT, - itk::IOComponentEnum::SHORT, - itk::IOComponentEnum::UINT, - itk::IOComponentEnum::INT, - itk::IOComponentEnum::ULONG, - itk::IOComponentEnum::LONG, - itk::IOComponentEnum::ULONGLONG, - itk::IOComponentEnum::LONGLONG, - itk::IOComponentEnum::FLOAT, - itk::IOComponentEnum::DOUBLE }; - const char * listComponentTypeString[] = { "unknown", "unsigned_char", "char", "unsigned_short", - "short", "unsigned_int", "int", "unsigned_long", - "long", "unsigned_long_long", "long_long", "float", - "double" }; - itk::IOPixelEnum listIOPixelType[] = { itk::IOPixelEnum::UNKNOWNPIXELTYPE, - itk::IOPixelEnum::SCALAR, - itk::IOPixelEnum::RGB, - itk::IOPixelEnum::RGBA, - itk::IOPixelEnum::OFFSET, - itk::IOPixelEnum::VECTOR, - itk::IOPixelEnum::POINT, - itk::IOPixelEnum::COVARIANTVECTOR, - itk::IOPixelEnum::SYMMETRICSECONDRANKTENSOR, - itk::IOPixelEnum::DIFFUSIONTENSOR3D, - itk::IOPixelEnum::COMPLEX, - itk::IOPixelEnum::FIXEDARRAY, - itk::IOPixelEnum::MATRIX }; - const char * listIOPixelTypeString[] = { "unknown", - "scalar", - "rgb", - "rgba", - "offset", - "vector", - "point", - "covariant_vector", - "symmetric_second_rank_tensor", - "diffusion_tensor_3D", - "complex", - "fixed_array", - "matrix" }; + const itk::IOComponentEnum listComponentType[] = { itk::IOComponentEnum::UNKNOWNCOMPONENTTYPE, + itk::IOComponentEnum::UCHAR, + itk::IOComponentEnum::CHAR, + itk::IOComponentEnum::USHORT, + itk::IOComponentEnum::SHORT, + itk::IOComponentEnum::UINT, + itk::IOComponentEnum::INT, + itk::IOComponentEnum::ULONG, + itk::IOComponentEnum::LONG, + itk::IOComponentEnum::ULONGLONG, + itk::IOComponentEnum::LONGLONG, + itk::IOComponentEnum::FLOAT, + itk::IOComponentEnum::DOUBLE }; + const char * listComponentTypeString[] = { "unknown", "unsigned_char", "char", "unsigned_short", + "short", "unsigned_int", "int", "unsigned_long", + "long", "unsigned_long_long", "long_long", "float", + "double" }; + const itk::IOPixelEnum listIOPixelType[] = { itk::IOPixelEnum::UNKNOWNPIXELTYPE, + itk::IOPixelEnum::SCALAR, + itk::IOPixelEnum::RGB, + itk::IOPixelEnum::RGBA, + itk::IOPixelEnum::OFFSET, + itk::IOPixelEnum::VECTOR, + itk::IOPixelEnum::POINT, + itk::IOPixelEnum::COVARIANTVECTOR, + itk::IOPixelEnum::SYMMETRICSECONDRANKTENSOR, + itk::IOPixelEnum::DIFFUSIONTENSOR3D, + itk::IOPixelEnum::COMPLEX, + itk::IOPixelEnum::FIXEDARRAY, + itk::IOPixelEnum::MATRIX }; + const char * listIOPixelTypeString[] = { "unknown", + "scalar", + "rgb", + "rgba", + "offset", + "vector", + "point", + "covariant_vector", + "symmetric_second_rank_tensor", + "diffusion_tensor_3D", + "complex", + "fixed_array", + "matrix" }; // Compile time verification that the array lengths are correct for type and name static_assert(std::size(listComponentType) == std::size(listComponentTypeString), "listComponentType and listComponentTypeString must be same length"); @@ -173,7 +173,7 @@ itkImageIOBaseTest(int, char *[]) { // Test the static version of the string <-> type conversions for (size_t i = 0; i < listComponentSize; ++i) { - std::string componentTypeString = itk::ImageIOBase::GetComponentTypeAsString(listComponentType[i]); + const std::string componentTypeString = itk::ImageIOBase::GetComponentTypeAsString(listComponentType[i]); if (componentTypeString.compare(listComponentTypeString[i]) != 0) { std::cerr << "GetComponentTypeAsString(" << listComponentType[i] << ") should return '" @@ -183,7 +183,7 @@ itkImageIOBaseTest(int, char *[]) } for (size_t i = 0; i < listPixelSize; ++i) { - std::string pixelTypeString = itk::ImageIOBase::GetPixelTypeAsString(listIOPixelType[i]); + const std::string pixelTypeString = itk::ImageIOBase::GetPixelTypeAsString(listIOPixelType[i]); if (pixelTypeString.compare(listIOPixelTypeString[i]) != 0) { std::cerr << "GetPixelTypeAsString(" << listIOPixelType[i] << ") should return '" << listIOPixelTypeString[i] @@ -193,7 +193,8 @@ itkImageIOBaseTest(int, char *[]) } for (size_t i = 0; i < listComponentSize; ++i) { - itk::IOComponentEnum componentType = itk::ImageIOBase::GetComponentTypeFromString(listComponentTypeString[i]); + const itk::IOComponentEnum componentType = + itk::ImageIOBase::GetComponentTypeFromString(listComponentTypeString[i]); if (componentType != listComponentType[i]) { std::cerr << "GetComponentTypeFromString('" << listComponentTypeString[i] << "') should return " @@ -203,7 +204,7 @@ itkImageIOBaseTest(int, char *[]) } for (size_t i = 0; i < listPixelSize; ++i) { - itk::IOPixelEnum pixelType = itk::ImageIOBase::GetPixelTypeFromString(listIOPixelTypeString[i]); + const itk::IOPixelEnum pixelType = itk::ImageIOBase::GetPixelTypeFromString(listIOPixelTypeString[i]); if (pixelType != listIOPixelType[i]) { std::cerr << "GetPixelTypeFromString('" << listIOPixelTypeString[i] << "') should return " @@ -217,11 +218,11 @@ itkImageIOBaseTest(int, char *[]) { // Create an instance of ImageIOBase. It does not matter that 'test' is not a valid image to read, // we just want the ImageIOBase object. - itk::ImageIOBase::Pointer imageIOBase = + const itk::ImageIOBase::Pointer imageIOBase = itk::ImageIOFactory::CreateImageIO("test", itk::ImageIOFactory::IOFileModeEnum::ReadMode); for (size_t i = 0; i < listComponentSize; ++i) { - std::string componentTypeString = imageIOBase->GetComponentTypeAsString(listComponentType[i]); + const std::string componentTypeString = imageIOBase->GetComponentTypeAsString(listComponentType[i]); if (componentTypeString.compare(listComponentTypeString[i]) != 0) { std::cerr << "GetComponentTypeAsString(" << listComponentType[i] << ") should return '" @@ -231,7 +232,7 @@ itkImageIOBaseTest(int, char *[]) } for (size_t i = 0; i < listPixelSize; ++i) { - std::string pixelTypeString = imageIOBase->GetPixelTypeAsString(listIOPixelType[i]); + const std::string pixelTypeString = imageIOBase->GetPixelTypeAsString(listIOPixelType[i]); if (pixelTypeString.compare(listIOPixelTypeString[i]) != 0) { std::cerr << "GetPixelTypeAsString(" << listIOPixelType[i] << ") should return " << listIOPixelTypeString[i] @@ -241,7 +242,7 @@ itkImageIOBaseTest(int, char *[]) } for (size_t i = 0; i < listComponentSize; ++i) { - itk::IOComponentEnum componentType = imageIOBase->GetComponentTypeFromString(listComponentTypeString[i]); + const itk::IOComponentEnum componentType = imageIOBase->GetComponentTypeFromString(listComponentTypeString[i]); if (componentType != listComponentType[i]) { std::cerr << "GetComponentTypeFromString('" << listComponentTypeString[i] << "') should return " @@ -251,7 +252,7 @@ itkImageIOBaseTest(int, char *[]) } for (size_t i = 0; i < listPixelSize; ++i) { - itk::IOPixelEnum pixelType = imageIOBase->GetPixelTypeFromString(listIOPixelTypeString[i]); + const itk::IOPixelEnum pixelType = imageIOBase->GetPixelTypeFromString(listIOPixelTypeString[i]); if (pixelType != listIOPixelType[i]) { std::cerr << "GetPixelTypeFromString('" << listIOPixelTypeString[i] << "') should return " @@ -266,7 +267,7 @@ itkImageIOBaseTest(int, char *[]) using IOPixelEnum = itk::CommonEnums::IOPixel; using IOComponentEnum = itk::CommonEnums::IOComponent; - itk::MetaImageIO::Pointer imageIO = itk::MetaImageIO::New(); + const itk::MetaImageIO::Pointer imageIO = itk::MetaImageIO::New(); imageIO->SetPixelTypeInfo(static_cast(nullptr)); ITK_TEST_EXPECT_EQUAL(imageIO->GetNumberOfComponents(), 1); diff --git a/Modules/IO/ImageBase/test/itkImageIODirection2DTest.cxx b/Modules/IO/ImageBase/test/itkImageIODirection2DTest.cxx index 428bc2e1afd..58a982a6269 100644 --- a/Modules/IO/ImageBase/test/itkImageIODirection2DTest.cxx +++ b/Modules/IO/ImageBase/test/itkImageIODirection2DTest.cxx @@ -53,7 +53,7 @@ itkImageIODirection2DTest(int argc, char * argv[]) return EXIT_FAILURE; } - ImageType::ConstPointer image = reader->GetOutput(); + const ImageType::ConstPointer image = reader->GetOutput(); ImageType::DirectionType directionCosines = image->GetDirection(); diff --git a/Modules/IO/ImageBase/test/itkImageIODirection3DTest.cxx b/Modules/IO/ImageBase/test/itkImageIODirection3DTest.cxx index 96a66d3f274..5d521ef2ad6 100644 --- a/Modules/IO/ImageBase/test/itkImageIODirection3DTest.cxx +++ b/Modules/IO/ImageBase/test/itkImageIODirection3DTest.cxx @@ -53,7 +53,7 @@ itkImageIODirection3DTest(int argc, char * argv[]) return EXIT_FAILURE; } - ImageType::ConstPointer image = reader->GetOutput(); + const ImageType::ConstPointer image = reader->GetOutput(); ImageType::DirectionType directionCosines = image->GetDirection(); diff --git a/Modules/IO/ImageBase/test/itkImageSeriesReaderSamplingTest.cxx b/Modules/IO/ImageBase/test/itkImageSeriesReaderSamplingTest.cxx index c68b985adb4..56869ee9f8b 100644 --- a/Modules/IO/ImageBase/test/itkImageSeriesReaderSamplingTest.cxx +++ b/Modules/IO/ImageBase/test/itkImageSeriesReaderSamplingTest.cxx @@ -61,8 +61,8 @@ itkImageSeriesReaderSamplingTest(int argc, char * argv[]) // iterate over all slices to detect offending slice for (auto d : *reader->GetMetaDataDictionaryArray()) { - itk::MetaDataDictionary theMetadata = *d; - double samplingDeviation = 0.0; + const itk::MetaDataDictionary theMetadata = *d; + double samplingDeviation = 0.0; if (itk::ExposeMetaData(theMetadata, "ITK_non_uniform_sampling_deviation", samplingDeviation)) { std::cout << "slice ITK_non_uniform_sampling_deviation detected: " << samplingDeviation << std::endl; diff --git a/Modules/IO/ImageBase/test/itkImageSeriesWriterTest.cxx b/Modules/IO/ImageBase/test/itkImageSeriesWriterTest.cxx index b17665f2523..f81f0b8c74a 100644 --- a/Modules/IO/ImageBase/test/itkImageSeriesWriterTest.cxx +++ b/Modules/IO/ImageBase/test/itkImageSeriesWriterTest.cxx @@ -40,21 +40,21 @@ itkImageSeriesWriterTest(int argc, char * argv[]) using ImageNDType = itk::Image; using ReaderType = itk::ImageSeriesReader; - itk::GDCMImageIO::Pointer io = itk::GDCMImageIO::New(); + const itk::GDCMImageIO::Pointer io = itk::GDCMImageIO::New(); // Get the DICOM filenames from the directory - itk::GDCMSeriesFileNames::Pointer nameGenerator = itk::GDCMSeriesFileNames::New(); + const itk::GDCMSeriesFileNames::Pointer nameGenerator = itk::GDCMSeriesFileNames::New(); nameGenerator->SetDirectory(argv[1]); using SeriesIdContainer = std::vector; const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs(); - std::string seriesIdentifier = seriesUID.begin()->c_str(); + const std::string seriesIdentifier = seriesUID.begin()->c_str(); auto reader = ReaderType::New(); reader->SetFileNames(nameGenerator->GetFileNames(seriesIdentifier)); reader->SetImageIO(io); - itk::SimpleFilterWatcher watcher(reader); + const itk::SimpleFilterWatcher watcher(reader); ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); @@ -83,15 +83,15 @@ itkImageSeriesWriterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(writer, ImageSeriesWriter, ProcessObject); - itk::SimpleFilterWatcher watcher2(writer); + const itk::SimpleFilterWatcher watcher2(writer); writer->SetInput(rescaler->GetOutput()); - itk::SizeValueType startIndex = 1; + const itk::SizeValueType startIndex = 1; writer->SetStartIndex(startIndex); ITK_TEST_SET_GET_VALUE(startIndex, writer->GetStartIndex()); - itk::SizeValueType incrementIndex = 1; + const itk::SizeValueType incrementIndex = 1; writer->SetIncrementIndex(incrementIndex); ITK_TEST_SET_GET_VALUE(incrementIndex, writer->GetIncrementIndex()); @@ -117,7 +117,7 @@ itkImageSeriesWriterTest(int argc, char * argv[]) } { // This is the new API, using the NumericSeriesFileNames (or any other filename generator). - itk::NumericSeriesFileNames::Pointer fit = itk::NumericSeriesFileNames::New(); + const itk::NumericSeriesFileNames::Pointer fit = itk::NumericSeriesFileNames::New(); using WriterType = itk::ImageSeriesWriter; @@ -129,18 +129,18 @@ itkImageSeriesWriterTest(int argc, char * argv[]) std::cout << "Format = " << format << std::endl; - ImageNDType::RegionType region = reader->GetOutput()->GetBufferedRegion(); - ImageNDType::SizeType size = region.GetSize(); + const ImageNDType::RegionType region = reader->GetOutput()->GetBufferedRegion(); + ImageNDType::SizeType size = region.GetSize(); - itk::SizeValueType startIndex = 0; + const itk::SizeValueType startIndex = 0; fit->SetStartIndex(startIndex); ITK_TEST_SET_GET_VALUE(startIndex, fit->GetStartIndex()); - itk::SizeValueType endIndex = size[2] - 1; + const itk::SizeValueType endIndex = size[2] - 1; fit->SetEndIndex(endIndex); // The number of slices to write ITK_TEST_SET_GET_VALUE(endIndex, fit->GetEndIndex()); - itk::SizeValueType incrementIndex = 1; + const itk::SizeValueType incrementIndex = 1; fit->SetIncrementIndex(incrementIndex); ITK_TEST_SET_GET_VALUE(incrementIndex, fit->GetIncrementIndex()); @@ -156,7 +156,7 @@ itkImageSeriesWriterTest(int argc, char * argv[]) std::cerr << "Wrong default use compression value" << std::endl; return EXIT_FAILURE; } - bool useCompression = false; + const bool useCompression = false; ITK_TEST_SET_GET_BOOLEAN(writer, UseCompression, useCompression); ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update()); diff --git a/Modules/IO/ImageBase/test/itkLargeImageWriteConvertReadTest.cxx b/Modules/IO/ImageBase/test/itkLargeImageWriteConvertReadTest.cxx index 1261a58051f..d4887282695 100644 --- a/Modules/IO/ImageBase/test/itkLargeImageWriteConvertReadTest.cxx +++ b/Modules/IO/ImageBase/test/itkLargeImageWriteConvertReadTest.cxx @@ -45,10 +45,10 @@ itkLargeImageWriteConvertReadTest(int argc, char * argv[]) const size_t numberOfPixelsInOneDimension = atol(argv[2]); - auto size = itk::MakeFilled(numberOfPixelsInOneDimension); - OutputImageType::IndexType index{}; + auto size = itk::MakeFilled(numberOfPixelsInOneDimension); + const OutputImageType::IndexType index{}; - OutputImageType::RegionType region{ index, size }; + const OutputImageType::RegionType region{ index, size }; image->SetRegions(region); chronometer.Start("Allocate"); @@ -106,7 +106,7 @@ itkLargeImageWriteConvertReadTest(int argc, char * argv[]) return EXIT_FAILURE; } - InputImageType::ConstPointer readImage = reader->GetOutput(); + const InputImageType::ConstPointer readImage = reader->GetOutput(); chronometer.Report(std::cout); std::cout << std::endl; diff --git a/Modules/IO/ImageBase/test/itkLargeImageWriteReadTest.cxx b/Modules/IO/ImageBase/test/itkLargeImageWriteReadTest.cxx index b7ef46c1682..72496adeb36 100644 --- a/Modules/IO/ImageBase/test/itkLargeImageWriteReadTest.cxx +++ b/Modules/IO/ImageBase/test/itkLargeImageWriteReadTest.cxx @@ -39,8 +39,8 @@ ActualTest(std::string filename, typename TImageType::SizeType size) using IteratorType = itk::ImageRegionIterator; using ConstIteratorType = itk::ImageRegionConstIterator; - typename ImageType::IndexType index{}; - typename ImageType::RegionType region{ index, size }; + const typename ImageType::IndexType index{}; + const typename ImageType::RegionType region{ index, size }; { // begin write block auto image = ImageType::New(); @@ -113,7 +113,7 @@ ActualTest(std::string filename, typename TImageType::SizeType size) return EXIT_FAILURE; } - typename ImageType::ConstPointer readImage = reader->GetOutput(); + const typename ImageType::ConstPointer readImage = reader->GetOutput(); ConstIteratorType ritr(readImage, region); // IteratorType oitr( image, region ); diff --git a/Modules/IO/ImageBase/test/itkMatrixImageWriteReadTest.cxx b/Modules/IO/ImageBase/test/itkMatrixImageWriteReadTest.cxx index 966de654103..41ac3d9d538 100644 --- a/Modules/IO/ImageBase/test/itkMatrixImageWriteReadTest.cxx +++ b/Modules/IO/ImageBase/test/itkMatrixImageWriteReadTest.cxx @@ -38,9 +38,9 @@ itkMatrixImageWriteReadTest(int argc, char * argv[]) auto size = MatrixImageType::SizeType::Filled(10); - MatrixImageType::IndexType start{}; + const MatrixImageType::IndexType start{}; - MatrixImageType::RegionType region{ start, size }; + const MatrixImageType::RegionType region{ start, size }; matrixImage1->SetRegions(region); matrixImage1->Allocate(); @@ -110,7 +110,7 @@ itkMatrixImageWriteReadTest(int argc, char * argv[]) return EXIT_FAILURE; } - MatrixImageType::ConstPointer matrixImage2 = matrixReader->GetOutput(); + const MatrixImageType::ConstPointer matrixImage2 = matrixReader->GetOutput(); // Compare the read values to the original values const float tolerance = 1e-5; diff --git a/Modules/IO/ImageBase/test/itkNoiseImageFilterTest.cxx b/Modules/IO/ImageBase/test/itkNoiseImageFilterTest.cxx index 73623f3935c..01e196c6c6d 100644 --- a/Modules/IO/ImageBase/test/itkNoiseImageFilterTest.cxx +++ b/Modules/IO/ImageBase/test/itkNoiseImageFilterTest.cxx @@ -41,14 +41,14 @@ itkNoiseImageFilterTest(int argc, char * argv[]) using myImageIn = itk::Image; using myImageOut = itk::Image; using myImageChar = itk::Image; - itk::ImageFileReader::Pointer input = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer input = itk::ImageFileReader::New(); input->SetFileName(argv[1]); // Create a filter using FilterType = itk::NoiseImageFilter; - auto filter = FilterType::New(); - itk::SimpleFilterWatcher filterWatch(filter); + auto filter = FilterType::New(); + const itk::SimpleFilterWatcher filterWatch(filter); using RescaleFilterType = itk::RescaleIntensityImageFilter; diff --git a/Modules/IO/ImageBase/test/itkNumericSeriesFileNamesTest.cxx b/Modules/IO/ImageBase/test/itkNumericSeriesFileNamesTest.cxx index 9ac17aa1c2d..1ce384e27ba 100644 --- a/Modules/IO/ImageBase/test/itkNumericSeriesFileNamesTest.cxx +++ b/Modules/IO/ImageBase/test/itkNumericSeriesFileNamesTest.cxx @@ -24,7 +24,7 @@ int itkNumericSeriesFileNamesTest(int, char *[]) { - itk::NumericSeriesFileNames::Pointer fit = itk::NumericSeriesFileNames::New(); + const itk::NumericSeriesFileNames::Pointer fit = itk::NumericSeriesFileNames::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(fit, NumericSeriesFileNames, Object); @@ -59,7 +59,7 @@ itkNumericSeriesFileNamesTest(int, char *[]) fit->SetIncrementIndex(incrementIndex); ITK_TEST_SET_GET_VALUE(incrementIndex, fit->GetIncrementIndex()); - std::string format = "foo.%0200d.png"; + const std::string format = "foo.%0200d.png"; fit->SetSeriesFormat(format); ITK_TEST_SET_GET_VALUE(format, fit->GetSeriesFormat()); diff --git a/Modules/IO/ImageBase/test/itkReadWriteImageWithDictionaryTest.cxx b/Modules/IO/ImageBase/test/itkReadWriteImageWithDictionaryTest.cxx index 98aa6330c42..1fdea4f8654 100644 --- a/Modules/IO/ImageBase/test/itkReadWriteImageWithDictionaryTest.cxx +++ b/Modules/IO/ImageBase/test/itkReadWriteImageWithDictionaryTest.cxx @@ -38,9 +38,9 @@ itkReadWriteImageWithDictionaryTest(int argc, char * argv[]) // Create the 16x16 input image auto inputImage = ImageType::New(); - auto size = ImageType::SizeType::Filled(16); - ImageType::IndexType index{}; - ImageType::RegionType region{ index, size }; + auto size = ImageType::SizeType::Filled(16); + const ImageType::IndexType index{}; + const ImageType::RegionType region{ index, size }; inputImage->SetRegions(region); inputImage->Allocate(); inputImage->FillBuffer(0); @@ -49,13 +49,13 @@ itkReadWriteImageWithDictionaryTest(int argc, char * argv[]) // Add some metadata in the dictionary itk::MetaDataDictionary & inputDictionary = inputImage->GetMetaDataDictionary(); - std::string voxelunitstr = "mm. "; // try to follow analyze format (length matters) + const std::string voxelunitstr = "mm. "; // try to follow analyze format (length matters) itk::EncapsulateMetaData(inputDictionary, itk::ITK_VoxelUnits, voxelunitstr); - std::string datestr = "26-05-2010"; // try to follow analyze format (length matters) + const std::string datestr = "26-05-2010"; // try to follow analyze format (length matters) itk::EncapsulateMetaData(inputDictionary, itk::ITK_ExperimentDate, datestr); - std::string timestr = "13-44-00.0"; // try to follow analyze format (length matters) + const std::string timestr = "13-44-00.0"; // try to follow analyze format (length matters) itk::EncapsulateMetaData(inputDictionary, itk::ITK_ExperimentTime, timestr); - std::string patientstr = "patientid "; // try to follow analyze format (length matters) + const std::string patientstr = "patientid "; // try to follow analyze format (length matters) itk::EncapsulateMetaData(inputDictionary, itk::ITK_PatientID, patientstr); // Write the image down @@ -71,7 +71,7 @@ itkReadWriteImageWithDictionaryTest(int argc, char * argv[]) reader->SetFileName(argv[1]); reader->Update(); - ImageType::Pointer outputImage = reader->GetOutput(); + const ImageType::Pointer outputImage = reader->GetOutput(); // Compare the metadatas int numMissingMetaData = 0; @@ -168,7 +168,7 @@ itkReadWriteImageWithDictionaryTest(int argc, char * argv[]) } else { - itk::MetaDataDictionary::ConstIterator it2 = outputDictionary.Find(it->first); + const itk::MetaDataDictionary::ConstIterator it2 = outputDictionary.Find(it->first); if (it->second->GetMetaDataObjectTypeInfo() != it2->second->GetMetaDataObjectTypeInfo()) { std::cout << "input_meta=" << it->second; diff --git a/Modules/IO/ImageBase/test/itkRegularExpressionSeriesFileNamesTest.cxx b/Modules/IO/ImageBase/test/itkRegularExpressionSeriesFileNamesTest.cxx index a6d8dcf24b6..22a96586e66 100644 --- a/Modules/IO/ImageBase/test/itkRegularExpressionSeriesFileNamesTest.cxx +++ b/Modules/IO/ImageBase/test/itkRegularExpressionSeriesFileNamesTest.cxx @@ -30,7 +30,7 @@ itkRegularExpressionSeriesFileNamesTest(int argc, char * argv[]) } - itk::RegularExpressionSeriesFileNames::Pointer fit = itk::RegularExpressionSeriesFileNames::New(); + const itk::RegularExpressionSeriesFileNames::Pointer fit = itk::RegularExpressionSeriesFileNames::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(fit, RegularExpressionSeriesFileNames, Object); diff --git a/Modules/IO/ImageBase/test/itkVectorImageReadWriteTest.cxx b/Modules/IO/ImageBase/test/itkVectorImageReadWriteTest.cxx index 524f3c7b6f4..2b86ed5665d 100644 --- a/Modules/IO/ImageBase/test/itkVectorImageReadWriteTest.cxx +++ b/Modules/IO/ImageBase/test/itkVectorImageReadWriteTest.cxx @@ -50,8 +50,8 @@ itkVectorImageReadWriteTest(int argc, char * argv[]) // RecursiveGaussianImageFilter and compare a few filtered pixels. // // Create ON and OFF vectors - PixelType vector0{}; - PixelType vector1; + const PixelType vector0{}; + PixelType vector1; vector1[0] = 1.0; vector1[1] = 2.0; vector1[2] = 3.0; @@ -60,9 +60,9 @@ itkVectorImageReadWriteTest(int argc, char * argv[]) using ConstIteratorType = itk::ImageLinearConstIteratorWithIndex; // Create the 9x9 input image - auto size = ImageType::SizeType::Filled(9); - ImageType::IndexType index{}; - ImageType::RegionType region{ index, size }; + auto size = ImageType::SizeType::Filled(9); + ImageType::IndexType index{}; + const ImageType::RegionType region{ index, size }; inputImage->SetRegions(region); inputImage->Allocate(); inputImage->FillBuffer(vector0); @@ -85,7 +85,7 @@ itkVectorImageReadWriteTest(int argc, char * argv[]) reader->SetFileName(argv[1]); reader->Update(); - ImageType::Pointer outputImage = reader->GetOutput(); + const ImageType::Pointer outputImage = reader->GetOutput(); ConstIteratorType cit(outputImage, outputImage->GetLargestPossibleRegion()); index[0] = 4; @@ -105,7 +105,7 @@ itkVectorImageReadWriteTest(int argc, char * argv[]) return EXIT_FAILURE; } - itk::ImageIOBase::Pointer io = reader->GetModifiableImageIO(); + const itk::ImageIOBase::Pointer io = reader->GetModifiableImageIO(); std::cout << "ImageIO Pixel Information: " << io->GetPixelTypeAsString(io->GetPixelType()) << ' ' diff --git a/Modules/IO/ImageBase/test/itkWriteImageFunctionGTest.cxx b/Modules/IO/ImageBase/test/itkWriteImageFunctionGTest.cxx index 1e1233cc314..847ef7cd554 100644 --- a/Modules/IO/ImageBase/test/itkWriteImageFunctionGTest.cxx +++ b/Modules/IO/ImageBase/test/itkWriteImageFunctionGTest.cxx @@ -46,7 +46,7 @@ struct ITKWriteImageFunctionTest : public ::testing::Test { auto image = ImageType::New(); - RegionType region(SizeType{ { 3, 2 } }); + const RegionType region(SizeType{ { 3, 2 } }); image->SetRegions(region); @@ -66,7 +66,7 @@ TEST_F(ITKWriteImageFunctionTest, ImageTypes) itk::WriteImage(image_ptr, fileName); itk::WriteImage(std::move(image_ptr), fileName); - ImageType::ConstPointer image_cptr = MakeImage(); + const ImageType::ConstPointer image_cptr = MakeImage(); itk::WriteImage(image_cptr, fileName); itk::WriteImage(std::move(image_cptr), fileName); diff --git a/Modules/IO/JPEG/src/itkJPEGImageIO.cxx b/Modules/IO/JPEG/src/itkJPEGImageIO.cxx index 3be88ffa11d..cebfd001857 100644 --- a/Modules/IO/JPEG/src/itkJPEGImageIO.cxx +++ b/Modules/IO/JPEG/src/itkJPEGImageIO.cxx @@ -91,7 +91,7 @@ bool JPEGImageIO::CanReadFile(const char * file) { // First check the extension - std::string filename = file; + const std::string filename = file; if (filename.empty()) { @@ -99,7 +99,7 @@ JPEGImageIO::CanReadFile(const char * file) return false; } - bool extensionFound = this->HasSupportedReadExtension(file, false); + const bool extensionFound = this->HasSupportedReadExtension(file, false); if (!extensionFound) { @@ -108,7 +108,7 @@ JPEGImageIO::CanReadFile(const char * file) } // Now check the file header - JPEGFileWrapper JPEGfp(file, "rb"); + const JPEGFileWrapper JPEGfp(file, "rb"); if (JPEGfp.m_FilePointer == nullptr) { return false; @@ -165,8 +165,8 @@ void JPEGImageIO::Read(void * buffer) { // use this class so return will call close - JPEGFileWrapper JPEGfp(this->GetFileName(), "rb"); - FILE * fp = JPEGfp.m_FilePointer; + const JPEGFileWrapper JPEGfp(this->GetFileName(), "rb"); + FILE * fp = JPEGfp.m_FilePointer; if (!fp) { itkExceptionMacro("Error JPEGImageIO could not open file: " << this->GetFileName() << std::endl @@ -338,8 +338,8 @@ JPEGImageIO::ReadImageInformation() m_IsCMYK = false; // use this class so return will call close - JPEGFileWrapper JPEGfp(m_FileName.c_str(), "rb"); - FILE * fp = JPEGfp.m_FilePointer; + const JPEGFileWrapper JPEGfp(m_FileName.c_str(), "rb"); + FILE * fp = JPEGfp.m_FilePointer; if (!fp) { itkExceptionMacro("Error JPEGImageIO could not open file: " << this->GetFileName() << std::endl @@ -436,7 +436,7 @@ JPEGImageIO::ReadImageInformation() bool JPEGImageIO::CanWriteFile(const char * name) { - std::string filename = name; + const std::string filename = name; if (filename.empty()) { @@ -471,8 +471,8 @@ void JPEGImageIO::WriteSlice(const std::string & fileName, const void * const buffer) { // use this class so return will call close - JPEGFileWrapper JPEGfp(fileName.c_str(), "wb"); - FILE * fp = JPEGfp.m_FilePointer; + const JPEGFileWrapper JPEGfp(fileName.c_str(), "wb"); + FILE * fp = JPEGfp.m_FilePointer; if (!fp) { itkExceptionMacro("Unable to open file " << fileName << " for writing." << std::endl diff --git a/Modules/IO/JPEG/test/itkJPEGImageIOBrokenCasesTest.cxx b/Modules/IO/JPEG/test/itkJPEGImageIOBrokenCasesTest.cxx index c07e5031833..4d829db1a05 100644 --- a/Modules/IO/JPEG/test/itkJPEGImageIOBrokenCasesTest.cxx +++ b/Modules/IO/JPEG/test/itkJPEGImageIOBrokenCasesTest.cxx @@ -37,9 +37,9 @@ itkJPEGImageIOBrokenCasesTest(int argc, char * argv[]) using ImageType = itk::Image; - itk::JPEGImageIO::Pointer io = itk::JPEGImageIO::New(); + const itk::JPEGImageIO::Pointer io = itk::JPEGImageIO::New(); - itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); reader->SetFileName(argv[1]); reader->SetImageIO(io); diff --git a/Modules/IO/JPEG/test/itkJPEGImageIOCMYKTest.cxx b/Modules/IO/JPEG/test/itkJPEGImageIOCMYKTest.cxx index ba16dac1c63..a0a9c6a3948 100644 --- a/Modules/IO/JPEG/test/itkJPEGImageIOCMYKTest.cxx +++ b/Modules/IO/JPEG/test/itkJPEGImageIOCMYKTest.cxx @@ -36,9 +36,9 @@ itkJPEGImageIOCMYKTest(int argc, char * argv[]) using ImageType = itk::Image; { - itk::JPEGImageIO::Pointer io = itk::JPEGImageIO::New(); + const itk::JPEGImageIO::Pointer io = itk::JPEGImageIO::New(); - itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); reader->SetFileName(argv[1]); @@ -50,9 +50,9 @@ itkJPEGImageIOCMYKTest(int argc, char * argv[]) } { - itk::JPEGImageIO::Pointer io = itk::JPEGImageIO::New(); + const itk::JPEGImageIO::Pointer io = itk::JPEGImageIO::New(); - itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); auto cmykToRGB = false; ITK_TEST_SET_GET_BOOLEAN(io, CMYKtoRGB, cmykToRGB); diff --git a/Modules/IO/JPEG/test/itkJPEGImageIODegenerateCasesTest.cxx b/Modules/IO/JPEG/test/itkJPEGImageIODegenerateCasesTest.cxx index f1a87ea2343..7c27a6618ca 100644 --- a/Modules/IO/JPEG/test/itkJPEGImageIODegenerateCasesTest.cxx +++ b/Modules/IO/JPEG/test/itkJPEGImageIODegenerateCasesTest.cxx @@ -37,7 +37,7 @@ itkJPEGImageIODegenerateCasesTest(int argc, char * argv[]) using ImageType = itk::Image; - itk::JPEGImageIO::Pointer io = itk::JPEGImageIO::New(); + const itk::JPEGImageIO::Pointer io = itk::JPEGImageIO::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(io, JPEGImageIO, ImageIOBase); @@ -45,7 +45,7 @@ itkJPEGImageIODegenerateCasesTest(int argc, char * argv[]) auto progressive = true; ITK_TEST_SET_GET_BOOLEAN(io, Progressive, progressive); - itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); reader->SetFileName(argv[1]); reader->SetImageIO(io); diff --git a/Modules/IO/JPEG/test/itkJPEGImageIOTest.cxx b/Modules/IO/JPEG/test/itkJPEGImageIOTest.cxx index 9e3a6aa9ea1..d5ae3aa1f43 100644 --- a/Modules/IO/JPEG/test/itkJPEGImageIOTest.cxx +++ b/Modules/IO/JPEG/test/itkJPEGImageIOTest.cxx @@ -43,18 +43,18 @@ itkJPEGImageIOTest(int argc, char * argv[]) using myImage = itk::Image; - itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); reader->SetFileName(argv[1]); ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); - myImage::Pointer image = reader->GetOutput(); + const myImage::Pointer image = reader->GetOutput(); image->Print(std::cout); - myImage::RegionType region = image->GetLargestPossibleRegion(); + const myImage::RegionType region = image->GetLargestPossibleRegion(); std::cout << "region " << region; // Generate test image diff --git a/Modules/IO/JPEG2000/src/itkJPEG2000ImageIO.cxx b/Modules/IO/JPEG2000/src/itkJPEG2000ImageIO.cxx index e2604aad5fd..7999bedc90f 100644 --- a/Modules/IO/JPEG2000/src/itkJPEG2000ImageIO.cxx +++ b/Modules/IO/JPEG2000/src/itkJPEG2000ImageIO.cxx @@ -156,7 +156,7 @@ JPEG2000ImageIO::ReadImageInformation() /* decode the code-stream */ /* ---------------------- */ - std::string extension = itksys::SystemTools::GetFilenameLastExtension(this->m_FileName); + const std::string extension = itksys::SystemTools::GetFilenameLastExtension(this->m_FileName); if (extension == ".j2k") { @@ -452,8 +452,7 @@ JPEG2000ImageIO::Read(void * buffer) << "Reason: opj_read_header returns false"); } - - ImageIORegion regionToRead = this->GetIORegion(); + const ImageIORegion regionToRead = this->GetIORegion(); ImageIORegion::SizeType size = regionToRead.GetSize(); ImageIORegion::IndexType start = regionToRead.GetIndex(); @@ -507,17 +506,17 @@ JPEG2000ImageIO::Read(void * buffer) OPJ_UINT32 l_tile_index; OPJ_UINT32 l_data_size; - OPJ_UINT32 l_nb_comps; - OPJ_BOOL tileHeaderRead = opj_read_tile_header(this->m_Internal->m_Dinfo, - l_stream, - &l_tile_index, - &l_data_size, - &l_current_tile_x0, - &l_current_tile_y0, - &l_current_tile_x1, - &l_current_tile_y1, - &l_nb_comps, - &l_go_on); + OPJ_UINT32 l_nb_comps; + const OPJ_BOOL tileHeaderRead = opj_read_tile_header(this->m_Internal->m_Dinfo, + l_stream, + &l_tile_index, + &l_data_size, + &l_current_tile_x0, + &l_current_tile_y0, + &l_current_tile_x1, + &l_current_tile_y1, + &l_nb_comps, + &l_go_on); if (!tileHeaderRead) { @@ -558,7 +557,7 @@ JPEG2000ImageIO::Read(void * buffer) l_max_data_size = l_data_size; } - bool decodeTileData = + const bool decodeTileData = opj_decode_tile_data(this->m_Internal->m_Dinfo, l_tile_index, l_data, l_data_size, l_stream); if (!decodeTileData) @@ -713,7 +712,7 @@ JPEG2000ImageIO::Write(const void * buffer) opj_cparameters_t parameters; opj_set_default_encoder_parameters(¶meters); - std::string extension = itksys::SystemTools::GetFilenameLastExtension(this->m_FileName.c_str()); + const std::string extension = itksys::SystemTools::GetFilenameLastExtension(this->m_FileName.c_str()); if (extension == ".j2k") { parameters.cod_format = static_cast(JPEG2000ImageIOInternal::DecodingFormatEnum::J2K_CFMT); @@ -767,7 +766,7 @@ JPEG2000ImageIO::Write(const void * buffer) parameters.cp_comment = (char *)malloc(commentLength); snprintf(parameters.cp_comment, commentLength, "%s%s with JPWL", comment, version); #else - size_t commentLength = clen + strlen(version) + 11; + const size_t commentLength = clen + strlen(version) + 11; parameters.cp_comment = (char *)opj_malloc(commentLength); snprintf(parameters.cp_comment, commentLength, "%s%s", comment, version); #endif @@ -783,8 +782,8 @@ JPEG2000ImageIO::Write(const void * buffer) //-------------------------------------------------------- // Copy the contents into the image structure - int w = this->m_Dimensions[0]; - int h = this->m_Dimensions[1]; + const int w = this->m_Dimensions[0]; + const int h = this->m_Dimensions[1]; // Compute the proper number of resolutions to use. @@ -868,16 +867,16 @@ JPEG2000ImageIO::Write(const void * buffer) l_image->numcomps = this->GetNumberOfComponents(); - int subsampling_dx = parameters.subsampling_dx; - int subsampling_dy = parameters.subsampling_dy; + const int subsampling_dx = parameters.subsampling_dx; + const int subsampling_dy = parameters.subsampling_dy; l_image->x0 = parameters.image_offset_x0; l_image->y0 = parameters.image_offset_y0; l_image->x1 = !l_image->x0 ? (w - 1) * subsampling_dx + 1 : l_image->x0 + (w - 1) * subsampling_dx + 1; l_image->y1 = !l_image->y0 ? (h - 1) * subsampling_dy + 1 : l_image->y0 + (h - 1) * subsampling_dy + 1; // HERE, copy the buffer - SizeValueType index = 0; - SizeValueType numberOfPixels = SizeValueType(w) * SizeValueType(h); + SizeValueType index = 0; + const SizeValueType numberOfPixels = SizeValueType(w) * SizeValueType(h); itkDebugMacro(" START COPY BUFFER"); if (this->GetComponentType() == IOComponentEnum::UCHAR) { @@ -1050,13 +1049,13 @@ JPEG2000ImageIO::ComputeRegionInTileBoundaries(unsigned int dimension, SizeValueType tileSize, ImageIORegion & streamableRegion) const { - SizeValueType requestedSize = streamableRegion.GetSize(dimension); - IndexValueType requestedIndex = streamableRegion.GetIndex(dimension); + const SizeValueType requestedSize = streamableRegion.GetSize(dimension); + const IndexValueType requestedIndex = streamableRegion.GetIndex(dimension); - IndexValueType startQuantizedInTileSize = requestedIndex - (requestedIndex % tileSize); - IndexValueType requestedEnd = requestedIndex + requestedSize; - SizeValueType extendedSize = requestedEnd - startQuantizedInTileSize; - SizeValueType tileRemanent = extendedSize % tileSize; + const IndexValueType startQuantizedInTileSize = requestedIndex - (requestedIndex % tileSize); + const IndexValueType requestedEnd = requestedIndex + requestedSize; + const SizeValueType extendedSize = requestedEnd - startQuantizedInTileSize; + const SizeValueType tileRemanent = extendedSize % tileSize; SizeValueType sizeQuantizedInTileSize = extendedSize; @@ -1065,7 +1064,7 @@ JPEG2000ImageIO::ComputeRegionInTileBoundaries(unsigned int dimension, sizeQuantizedInTileSize += tileSize - tileRemanent; } - IndexValueType endQuantizedInTileSize = startQuantizedInTileSize + sizeQuantizedInTileSize - 1; + const IndexValueType endQuantizedInTileSize = startQuantizedInTileSize + sizeQuantizedInTileSize - 1; if (endQuantizedInTileSize > static_cast(this->GetDimensions(dimension))) { diff --git a/Modules/IO/JPEG2000/test/itkJPEG2000ImageIOFactoryTest01.cxx b/Modules/IO/JPEG2000/test/itkJPEG2000ImageIOFactoryTest01.cxx index 2501a016d05..2e7cc734103 100644 --- a/Modules/IO/JPEG2000/test/itkJPEG2000ImageIOFactoryTest01.cxx +++ b/Modules/IO/JPEG2000/test/itkJPEG2000ImageIOFactoryTest01.cxx @@ -25,14 +25,14 @@ itkJPEG2000ImageIOFactoryTest01(int /*argc */, char * /*argv*/[]) // Register the factory itk::JPEG2000ImageIOFactory::RegisterOneFactory(); - itk::JPEG2000ImageIOFactory::Pointer factory = itk::JPEG2000ImageIOFactory::New(); + const itk::JPEG2000ImageIOFactory::Pointer factory = itk::JPEG2000ImageIOFactory::New(); std::cout << "ITK Version = " << factory->GetITKSourceVersion() << std::endl; std::cout << "Description = " << factory->GetDescription() << std::endl; std::cout << "ClassName = " << factory->GetNameOfClass() << std::endl; - itk::JPEG2000ImageIOFactory::Pointer factory2 = itk::JPEG2000ImageIOFactory::FactoryNew(); + const itk::JPEG2000ImageIOFactory::Pointer factory2 = itk::JPEG2000ImageIOFactory::FactoryNew(); return EXIT_SUCCESS; } diff --git a/Modules/IO/JPEG2000/test/itkJPEG2000ImageIOTest00.cxx b/Modules/IO/JPEG2000/test/itkJPEG2000ImageIOTest00.cxx index 40e152c783a..86ff34dfa9f 100644 --- a/Modules/IO/JPEG2000/test/itkJPEG2000ImageIOTest00.cxx +++ b/Modules/IO/JPEG2000/test/itkJPEG2000ImageIOTest00.cxx @@ -23,7 +23,7 @@ int itkJPEG2000ImageIOTest00(int /*argc */, char * /*argv*/[]) { - itk::JPEG2000ImageIO::Pointer imageIO = itk::JPEG2000ImageIO::New(); + const itk::JPEG2000ImageIO::Pointer imageIO = itk::JPEG2000ImageIO::New(); std::cout << "ClassName = " << imageIO->GetNameOfClass() << std::endl; diff --git a/Modules/IO/JPEG2000/test/itkJPEG2000ImageIOTest05.cxx b/Modules/IO/JPEG2000/test/itkJPEG2000ImageIOTest05.cxx index 8f8019d03e9..d3e90ccbe5f 100644 --- a/Modules/IO/JPEG2000/test/itkJPEG2000ImageIOTest05.cxx +++ b/Modules/IO/JPEG2000/test/itkJPEG2000ImageIOTest05.cxx @@ -52,7 +52,7 @@ itkJPEG2000ImageIOTest05(int argc, char * argv[]) // Register the factory itk::JPEG2000ImageIOFactory::RegisterOneFactory(); - itk::NumericSeriesFileNames::Pointer fit = itk::NumericSeriesFileNames::New(); + const itk::NumericSeriesFileNames::Pointer fit = itk::NumericSeriesFileNames::New(); using WriterType = itk::ImageSeriesWriter; @@ -64,8 +64,8 @@ itkJPEG2000ImageIOTest05(int argc, char * argv[]) std::cout << "Format = " << format << std::endl; - ImageType::RegionType region = reader->GetOutput()->GetBufferedRegion(); - ImageType::SizeType size = region.GetSize(); + const ImageType::RegionType region = reader->GetOutput()->GetBufferedRegion(); + ImageType::SizeType size = region.GetSize(); fit->SetStartIndex(0); fit->SetEndIndex(size[2] - 1); // The number of slices to write diff --git a/Modules/IO/LSM/src/itkLSMImageIO.cxx b/Modules/IO/LSM/src/itkLSMImageIO.cxx index 66df472b477..cd69f76b96b 100644 --- a/Modules/IO/LSM/src/itkLSMImageIO.cxx +++ b/Modules/IO/LSM/src/itkLSMImageIO.cxx @@ -119,7 +119,7 @@ LSMImageIO::~LSMImageIO() = default; bool LSMImageIO::CanReadFile(const char * filename) { - std::string fname(filename); + const std::string fname(filename); if (fname.empty()) { @@ -192,7 +192,7 @@ LSMImageIO::ReadImageInformation() bool LSMImageIO::CanWriteFile(const char * name) { - std::string filename = name; + const std::string filename = name; if (filename.empty()) { @@ -238,15 +238,15 @@ LSMImageIO::Write(const void * buffer) { itkExceptionMacro("TIFF requires images to have at least 2 dimensions"); } - unsigned int width = m_Dimensions[0]; - unsigned int height = m_Dimensions[1]; + const unsigned int width = m_Dimensions[0]; + const unsigned int height = m_Dimensions[1]; if (m_NumberOfDimensions == 3) { pages = m_Dimensions[2]; } - uint16_t scomponents = this->GetNumberOfComponents(); - uint16_t bps; + const uint16_t scomponents = this->GetNumberOfComponents(); + uint16_t bps; switch (this->GetComponentType()) { case IOComponentEnum::UCHAR: @@ -261,16 +261,16 @@ LSMImageIO::Write(const void * buffer) itkExceptionMacro("TIFF supports unsigned char and unsigned short"); } - float resolution = -1; - TIFF * tif = TIFFOpen(m_FileName.c_str(), "w"); + const float resolution = -1; + TIFF * tif = TIFFOpen(m_FileName.c_str(), "w"); if (!tif) { itkDebugMacro("Returning"); return; } - uint32_t w = width; - uint32_t h = height; + const uint32_t w = width; + const uint32_t h = height; TIFFSetTagExtender(TagExtender); if (m_NumberOfDimensions == 3) @@ -298,8 +298,8 @@ LSMImageIO::Write(const void * buffer) { // if number of scalar components is greater than 3, that means we assume // there is alpha. - uint16_t extra_samples = scomponents - 3; - const auto sample_info = make_unique_for_overwrite(scomponents - 3); + const uint16_t extra_samples = scomponents - 3; + const auto sample_info = make_unique_for_overwrite(scomponents - 3); sample_info[0] = EXTRASAMPLE_ASSOCALPHA; for (int cc = 1; cc < scomponents - 3; ++cc) { diff --git a/Modules/IO/LSM/test/itkLSMImageIOTest.cxx b/Modules/IO/LSM/test/itkLSMImageIOTest.cxx index cb126121322..708f02eb828 100644 --- a/Modules/IO/LSM/test/itkLSMImageIOTest.cxx +++ b/Modules/IO/LSM/test/itkLSMImageIOTest.cxx @@ -57,8 +57,8 @@ itkLSMImageIOTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); - size_t bufferSize = reader->GetImageIO()->GetImageSizeInBytes(); - auto * buffer = new InputPixelType[bufferSize]; + const size_t bufferSize = reader->GetImageIO()->GetImageSizeInBytes(); + auto * buffer = new InputPixelType[bufferSize]; lsmImageIO->Read(buffer); diff --git a/Modules/IO/MINC/src/itkMINCImageIO.cxx b/Modules/IO/MINC/src/itkMINCImageIO.cxx index d5f4dba0eb4..d3f8d617548 100644 --- a/Modules/IO/MINC/src/itkMINCImageIO.cxx +++ b/Modules/IO/MINC/src/itkMINCImageIO.cxx @@ -46,7 +46,7 @@ extern "C" } for (unsigned int x = 0; x < size; ++x) { - [[maybe_unused]] int error = mifree_dimension_handle(ptr[x]); + [[maybe_unused]] const int error = mifree_dimension_handle(ptr[x]); #ifndef NDEBUG if (error != MI_NOERROR) { @@ -657,7 +657,7 @@ MINCImageIO::ReadImageInformation() MetaDataDictionary & thisDic = GetMetaDataDictionary(); thisDic.Clear(); - std::string classname(GetNameOfClass()); + const std::string classname(GetNameOfClass()); // EncapsulateMetaData(thisDic,ITK_InputFilterName, // classname); @@ -962,8 +962,8 @@ MINCImageIO::WriteImageInformation() for (unsigned int i = 0; i < nDims; ++i) { - unsigned int j = i + (nComp > 1 ? 1 : 0); - double dir_cos[3]; + const unsigned int j = i + (nComp > 1 ? 1 : 0); + double dir_cos[3]; for (unsigned int k = 0; k < 3; ++k) { if (k < nDims) @@ -1065,8 +1065,8 @@ MINCImageIO::WriteImageInformation() dimorder_good = true; for (unsigned int i = 0; i < minc_dimensions && dimorder_good; ++i) { - bool positive = (dimension_order[i * 2] == '+'); - int j = 0; + const bool positive = (dimension_order[i * 2] == '+'); + int j = 0; switch (dimension_order[i * 2 + 1]) { case 'v': @@ -1238,8 +1238,8 @@ MINCImageIO::WriteImageInformation() MetaDataObjectBase * bs = it->second; if (d) { - std::string var(it->first.c_str(), d - it->first.c_str()); - std::string att(d + 1); + const std::string var(it->first.c_str(), d - it->first.c_str()); + const std::string att(d + 1); // VF:THIS is not good OO style at all :( const char * tname = bs->GetMetaDataObjectTypeName(); diff --git a/Modules/IO/MINC/test/itkMINCImageIOTest.cxx b/Modules/IO/MINC/test/itkMINCImageIOTest.cxx index 524145bc5ec..9f049ca146f 100644 --- a/Modules/IO/MINC/test/itkMINCImageIOTest.cxx +++ b/Modules/IO/MINC/test/itkMINCImageIOTest.cxx @@ -276,7 +276,7 @@ abs_vector_diff(const itk::VariableLengthVector & pix1, const itk::Varia for (size_t i = 0; i < pix1.GetSize(); ++i) { - double d = itk::Math::abs(static_cast(pix1[i] - pix2[i])); + const double d = itk::Math::abs(static_cast(pix1[i] - pix2[i])); if (d > diff) { diff = d; @@ -323,7 +323,7 @@ MINCReadWriteTest(const char * fileName, const char * minc_storage_type, double auto im = ImageType::New(); - typename ImageType::RegionType region{ index, size }; + const typename ImageType::RegionType region{ index, size }; im->SetRegions(region); im->SetSpacing(spacing); im->SetOrigin(origin); @@ -373,7 +373,7 @@ MINCReadWriteTest(const char * fileName, const char * minc_storage_type, double metaDataIntArray[4] = 2; itk::EncapsulateMetaData>(metaDict, "acquisition:TestIntArray", metaDataIntArray); - std::string metaDataStdString("Test std::string"); + const std::string metaDataStdString("Test std::string"); itk::EncapsulateMetaData(metaDict, "acquisition:StdString", metaDataStdString); // @@ -435,7 +435,7 @@ MINCReadWriteTest(const char * fileName, const char * minc_storage_type, double // // Check MetaData - itk::MetaDataDictionary & metaDict2(im2->GetMetaDataDictionary()); + const itk::MetaDataDictionary & metaDict2(im2->GetMetaDataDictionary()); double metaDataDouble = 0.0; if (!itk::ExposeMetaData(metaDict2, "acquisition:TestDouble", metaDataDouble) || metaDataDouble != 1.23) @@ -587,7 +587,7 @@ MINCReadWriteTestVector(const char * fileName, auto im = ImageType::New(); // itk::IOTestHelper::AllocateImageFromRegionAndSpacing(imageRegion,spacing); - typename ImageType::RegionType region{ index, size }; + const typename ImageType::RegionType region{ index, size }; im->SetRegions(region); im->SetSpacing(spacing); im->SetOrigin(origin); @@ -629,7 +629,7 @@ MINCReadWriteTestVector(const char * fileName, metaDataIntArray[4] = 2; itk::EncapsulateMetaData>(metaDict, "acquisition:TestIntArray", metaDataIntArray); - std::string metaDataStdString("Test std::string"); + const std::string metaDataStdString("Test std::string"); itk::EncapsulateMetaData(metaDict, "acquisition:StdString", metaDataStdString); // @@ -691,7 +691,7 @@ MINCReadWriteTestVector(const char * fileName, } // Check MetaData - itk::MetaDataDictionary & metaDict2(im2->GetMetaDataDictionary()); + const itk::MetaDataDictionary & metaDict2(im2->GetMetaDataDictionary()); double metaDataDouble = 0.0; if (!itk::ExposeMetaData(metaDict2, "acquisition:TestDouble", metaDataDouble) || metaDataDouble != 1.23) @@ -741,8 +741,8 @@ MINCReadWriteTestVector(const char * fileName, { for (it.GoToBegin(), it2.GoToBegin(); !it.IsAtEnd() && !it2.IsAtEnd(); ++it, ++it2) { - InternalPixelType pix1 = it.Get(); - InternalPixelType pix2 = it2.Get(); + const InternalPixelType pix1 = it.Get(); + const InternalPixelType pix2 = it2.Get(); if (!equal(pix1, pix2)) { std::cout << "Original Pixel (" << pix1 << ") doesn't match read-in Pixel (" << pix2 << " ) " @@ -756,8 +756,8 @@ MINCReadWriteTestVector(const char * fileName, { // account for rounding errors for (it.GoToBegin(), it2.GoToBegin(); !it.IsAtEnd() && !it2.IsAtEnd(); ++it, ++it2) { - InternalPixelType pix1 = it.Get(); - InternalPixelType pix2 = it2.Get(); + const InternalPixelType pix1 = it.Get(); + const InternalPixelType pix2 = it2.Get(); if (abs_vector_diff(pix1, pix2) > tolerance) { std::cout << "Original Pixel (" << pix1 << ") doesn't match read-in Pixel (" << pix2 << " ) " diff --git a/Modules/IO/MINC/test/itkMINCImageIOTest2.cxx b/Modules/IO/MINC/test/itkMINCImageIOTest2.cxx index b03facbab8c..ce3e3f224fc 100644 --- a/Modules/IO/MINC/test/itkMINCImageIOTest2.cxx +++ b/Modules/IO/MINC/test/itkMINCImageIOTest2.cxx @@ -40,12 +40,12 @@ itkMINCImageIOTest2(int argc, char * argv[]) using ImageType = itk::Image; - itk::MINCImageIO::Pointer mincIO1 = itk::MINCImageIO::New(); + const itk::MINCImageIO::Pointer mincIO1 = itk::MINCImageIO::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(mincIO1, MINCImageIO, ImageIOBase); - unsigned int supportedDimCount = 4; // includes the degenerate 0-dimensional case + const unsigned int supportedDimCount = 4; // includes the degenerate 0-dimensional case std::vector supportedDims(supportedDimCount); std::iota(std::begin(supportedDims), std::end(supportedDims), 0); for (const auto & value : supportedDims) @@ -55,7 +55,7 @@ itkMINCImageIOTest2(int argc, char * argv[]) ITK_TEST_EXPECT_TRUE(!mincIO1->SupportsDimension(supportedDims.back() + 1)); - itk::MINCImageIO::Pointer mincIO2 = itk::MINCImageIO::New(); + const itk::MINCImageIO::Pointer mincIO2 = itk::MINCImageIO::New(); using ReaderType = itk::ImageFileReader; using WriterType = itk::ImageFileWriter; @@ -74,7 +74,7 @@ itkMINCImageIOTest2(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update()); - ImageType::ConstPointer image = reader->GetOutput(); + const ImageType::ConstPointer image = reader->GetOutput(); image->Print(std::cout); diff --git a/Modules/IO/MINC/test/itkMINCImageIOTest4.cxx b/Modules/IO/MINC/test/itkMINCImageIOTest4.cxx index da1197e7b3d..8c866b2136b 100644 --- a/Modules/IO/MINC/test/itkMINCImageIOTest4.cxx +++ b/Modules/IO/MINC/test/itkMINCImageIOTest4.cxx @@ -103,7 +103,7 @@ itkMINCImageIOTest4(int argc, char * argv[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope // scope. - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); if (argc < 3) { @@ -141,7 +141,7 @@ itkMINCImageIOTest4(int argc, char * argv[]) } } - double epsilon = 1e-3; + const double epsilon = 1e-3; try { diff --git a/Modules/IO/MINC/test/itkMINCImageIOTest_2D.cxx b/Modules/IO/MINC/test/itkMINCImageIOTest_2D.cxx index 5c5ad886de3..5ddf454d753 100644 --- a/Modules/IO/MINC/test/itkMINCImageIOTest_2D.cxx +++ b/Modules/IO/MINC/test/itkMINCImageIOTest_2D.cxx @@ -95,7 +95,7 @@ itkMINCImageIOTest_2D(int argc, char * argv[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope // scope. - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); if (argc < 3) { @@ -129,7 +129,7 @@ itkMINCImageIOTest_2D(int argc, char * argv[]) } } - double epsilon = 1e-3; + const double epsilon = 1e-3; try { diff --git a/Modules/IO/MINC/test/itkMINCImageIOTest_4D.cxx b/Modules/IO/MINC/test/itkMINCImageIOTest_4D.cxx index f20d81e86be..9b708523829 100644 --- a/Modules/IO/MINC/test/itkMINCImageIOTest_4D.cxx +++ b/Modules/IO/MINC/test/itkMINCImageIOTest_4D.cxx @@ -53,7 +53,7 @@ itkMINCImageIOTest_4D(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update()); - ImageType::ConstPointer image = reader->GetOutput(); + const ImageType::ConstPointer image = reader->GetOutput(); image->Print(std::cout); diff --git a/Modules/IO/MINC/test/itkMINCImageIOTest_Labels.cxx b/Modules/IO/MINC/test/itkMINCImageIOTest_Labels.cxx index 431bfeb753c..b25d2d6443b 100644 --- a/Modules/IO/MINC/test/itkMINCImageIOTest_Labels.cxx +++ b/Modules/IO/MINC/test/itkMINCImageIOTest_Labels.cxx @@ -54,7 +54,7 @@ itkMINCImageIOTest_Labels(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update()); - ImageType::ConstPointer image = reader->GetOutput(); + const ImageType::ConstPointer image = reader->GetOutput(); image->Print(std::cout); diff --git a/Modules/IO/MRC/src/itkMRCImageIO.cxx b/Modules/IO/MRC/src/itkMRCImageIO.cxx index 989a95af25c..54d3efa22e8 100644 --- a/Modules/IO/MRC/src/itkMRCImageIO.cxx +++ b/Modules/IO/MRC/src/itkMRCImageIO.cxx @@ -60,7 +60,7 @@ MRCImageIO::PrintSelf(std::ostream & os, Indent indent) const bool MRCImageIO::CanReadFile(const char * filename) { - std::string fname = filename; + const std::string fname = filename; if (this->HasSupportedReadExtension(filename)) { @@ -219,7 +219,7 @@ MRCImageIO::ReadImageInformation() // can be accessed MetaDataDictionary & thisDic = this->GetMetaDataDictionary(); - std::string classname(this->GetNameOfClass()); + const std::string classname(this->GetNameOfClass()); EncapsulateMetaData(thisDic, ITK_InputFilterName, classname); EncapsulateMetaData( thisDic, m_MetaDataHeaderName, MRCHeaderObject::ConstPointer(m_MRCHeader)); @@ -278,7 +278,7 @@ MRCImageIO::Read(void * buffer) this->OpenFileForReading(file, m_FileName); // seek base the header - std::streampos dataPos = static_cast(this->GetHeaderSize()); + const std::streampos dataPos = static_cast(this->GetHeaderSize()); file.seekg(dataPos, std::ios::beg); if (file.fail()) @@ -290,7 +290,7 @@ MRCImageIO::Read(void * buffer) this->ReadBufferAsBinary(file, buffer, this->GetImageSizeInBytes()); } - int size = this->GetComponentSize(); + const int size = this->GetComponentSize(); switch (size) { case 1: @@ -315,7 +315,7 @@ MRCImageIO::Read(void * buffer) bool MRCImageIO::CanWriteFile(const char * fname) { - std::string filename = fname; + const std::string filename = fname; return this->HasSupportedWriteExtension(fname); } @@ -330,9 +330,9 @@ MRCImageIO::UpdateHeaderWithMinMaxMean(const TPixelType * bufferBegin) // this could be replaced with std::min_element and // std::max_element, but that is slightly less efficient - std::pair mm = itk::min_max_element(bufferBegin, bufferEnd); + const std::pair mm = itk::min_max_element(bufferBegin, bufferEnd); - double mean = std::accumulate(bufferBegin, bufferEnd, 0.0) / std::distance(bufferBegin, bufferEnd); + const double mean = std::accumulate(bufferBegin, bufferEnd, 0.0) / std::distance(bufferBegin, bufferEnd); m_MRCHeader->m_Header.amin = static_cast(*mm.first); m_MRCHeader->m_Header.amax = static_cast(*mm.second); @@ -550,7 +550,7 @@ MRCImageIO::Write(const void * buffer) // write one byte at the end of the file to allocate (this is a // nifty trick which should not write the entire size of the file // just allocate it, if the system supports sparse files) - std::streampos seekPos = this->GetImageSizeInBytes() + this->GetHeaderSize() - 1; + const std::streampos seekPos = this->GetImageSizeInBytes() + this->GetHeaderSize() - 1; file.seekp(seekPos, std::ios::cur); file.write("\0", 1); file.seekp(0); @@ -594,7 +594,7 @@ MRCImageIO::Write(const void * buffer) this->OpenFileForWriting(file, m_FileName, false); // seek pass the header - std::streampos dataPos = static_cast(this->GetHeaderSize()); + const std::streampos dataPos = static_cast(this->GetHeaderSize()); file.seekp(dataPos, std::ios::beg); if (file.fail()) diff --git a/Modules/IO/MRC/test/itkMRCImageIOTest.cxx b/Modules/IO/MRC/test/itkMRCImageIOTest.cxx index 86464aba7d5..9cfb8f1510c 100644 --- a/Modules/IO/MRC/test/itkMRCImageIOTest.cxx +++ b/Modules/IO/MRC/test/itkMRCImageIOTest.cxx @@ -188,7 +188,7 @@ MRCImageIOTester::Read(const std::string & filePrefix, std::string & reader->SetFileName(m_OutputFileName.str()); // read the image - typename ImageType::Pointer image = reader->GetOutput(); + const typename ImageType::Pointer image = reader->GetOutput(); reader->Update(); // test the CanReadFile function after the fact (should always be true at @@ -199,9 +199,9 @@ MRCImageIOTester::Read(const std::string & filePrefix, std::string & } // check the size - typename ImageType::RegionType region = image->GetLargestPossibleRegion(); - typename ImageType::SizeType size = region.GetSize(); - bool sizeGood = true; + const typename ImageType::RegionType region = image->GetLargestPossibleRegion(); + typename ImageType::SizeType size = region.GetSize(); + bool sizeGood = true; for (unsigned int i = 0; i < ImageType::GetImageDimension(); ++i) { if (size[i] != 10) @@ -282,8 +282,8 @@ itkMRCImageIOTest(int argc, char * argv[]) return EXIT_FAILURE; } - std::string outputPath = argv[1]; - std::string filePrefix = argv[0]; + std::string outputPath = argv[1]; + const std::string filePrefix = argv[0]; // // test all usable pixeltypes diff --git a/Modules/IO/MRC/test/itkMRCImageIOTest2.cxx b/Modules/IO/MRC/test/itkMRCImageIOTest2.cxx index af909aeb647..9ceefea38fb 100644 --- a/Modules/IO/MRC/test/itkMRCImageIOTest2.cxx +++ b/Modules/IO/MRC/test/itkMRCImageIOTest2.cxx @@ -41,7 +41,7 @@ Test(const std::string & inFileName, const std::string & outFileName, const std: reader->SetFileName(inFileName); reader->UpdateLargestPossibleRegion(); - typename ImageType::Pointer image = reader->GetOutput(); + const typename ImageType::Pointer image = reader->GetOutput(); using DictionaryType = itk::MetaDataDictionary; using MetaDataStringType = itk::MetaDataObject; @@ -49,12 +49,12 @@ Test(const std::string & inFileName, const std::string & outFileName, const std: // prepare to iterate over the dictionary DictionaryType & dic = image->GetMetaDataDictionary(); - DictionaryType::ConstIterator itr = dic.Begin(); - DictionaryType::ConstIterator end = dic.End(); + DictionaryType::ConstIterator itr = dic.Begin(); + const DictionaryType::ConstIterator end = dic.End(); while (itr != end) { - std::string key = itr->first; + const std::string key = itr->first; // check to see if we have a MRC Header if (itr->first == itk::MRCImageIO::m_MetaDataHeaderName) @@ -66,20 +66,20 @@ Test(const std::string & inFileName, const std::string & outFileName, const std: std::cout << header; // Use DeepCopy method to improve coverage - itk::MRCHeaderObject::Pointer copyHeader = itk::MRCHeaderObject::New(); + const itk::MRCHeaderObject::Pointer copyHeader = itk::MRCHeaderObject::New(); copyHeader->DeepCopy(header); } } else { // just print the strings now - itk::MetaDataObjectBase::Pointer entry = itr->second; + const itk::MetaDataObjectBase::Pointer entry = itr->second; - MetaDataStringType::Pointer entryvalue = dynamic_cast(entry.GetPointer()); + const MetaDataStringType::Pointer entryvalue = dynamic_cast(entry.GetPointer()); if (entryvalue) { - std::string tagvalue = entryvalue->GetMetaDataObjectValue(); + const std::string tagvalue = entryvalue->GetMetaDataObjectValue(); std::cout << '(' << key << ") "; std::cout << " = " << tagvalue << std::endl; diff --git a/Modules/IO/Mesh/test/itkMeshFileReadWriteTest.cxx b/Modules/IO/Mesh/test/itkMeshFileReadWriteTest.cxx index 1135f32d2b9..ea5e38bf73a 100644 --- a/Modules/IO/Mesh/test/itkMeshFileReadWriteTest.cxx +++ b/Modules/IO/Mesh/test/itkMeshFileReadWriteTest.cxx @@ -31,7 +31,7 @@ itkMeshFileReadWriteTest(int argc, char * argv[]) return EXIT_FAILURE; } - bool IsBinary = (argc > 3); + const bool IsBinary = (argc > 3); constexpr unsigned int dimension = 3; using PixelType = float; diff --git a/Modules/IO/MeshBYU/include/itkBYUMeshIO.h b/Modules/IO/MeshBYU/include/itkBYUMeshIO.h index 1e05b85b37a..6b22113c999 100644 --- a/Modules/IO/MeshBYU/include/itkBYUMeshIO.h +++ b/Modules/IO/MeshBYU/include/itkBYUMeshIO.h @@ -118,7 +118,7 @@ class ITKIOMeshBYU_EXPORT BYUMeshIO : public MeshIOBase void WritePoints(T * buffer, std::ofstream & outputFile) { - Indent indent(1); + const Indent indent(1); SizeValueType index{}; for (SizeValueType ii = 0; ii < this->m_NumberOfPoints; ++ii) @@ -136,7 +136,7 @@ class ITKIOMeshBYU_EXPORT BYUMeshIO : public MeshIOBase void WriteCells(T * buffer, std::ofstream & outputFile) { - Indent indent(7); + const Indent indent(7); SizeValueType index{}; for (SizeValueType ii = 0; ii < this->m_NumberOfCells; ++ii) diff --git a/Modules/IO/MeshBYU/src/itkBYUMeshIO.cxx b/Modules/IO/MeshBYU/src/itkBYUMeshIO.cxx index 6b5dd033876..cc575e464c5 100644 --- a/Modules/IO/MeshBYU/src/itkBYUMeshIO.cxx +++ b/Modules/IO/MeshBYU/src/itkBYUMeshIO.cxx @@ -297,7 +297,7 @@ BYUMeshIO::WriteMeshInformation() } // Write BYU file header - Indent indent(7); + const Indent indent(7); outputFile << indent << 1 << indent << this->m_NumberOfPoints << indent << this->m_NumberOfCells << indent << this->m_CellBufferSize - 2 * this->m_NumberOfCells << std::endl << indent << 1 << indent << this->m_NumberOfCells << std::endl; diff --git a/Modules/IO/MeshBYU/test/itkBYUMeshIOTest.cxx b/Modules/IO/MeshBYU/test/itkBYUMeshIOTest.cxx index 303e372832e..5a11cc667b4 100644 --- a/Modules/IO/MeshBYU/test/itkBYUMeshIOTest.cxx +++ b/Modules/IO/MeshBYU/test/itkBYUMeshIOTest.cxx @@ -92,8 +92,8 @@ itkBYUMeshIOTest(int argc, char * argv[]) ITK_TEST_EXPECT_EQUAL(numberOfCellPixels, byuMeshIO->GetNumberOfCellPixels()); // Use sufficiently large buffer sizes - itk::SizeValueType pointBufferSize = 1000; - itk::SizeValueType cellBufferSize = 1000; + const itk::SizeValueType pointBufferSize = 1000; + const itk::SizeValueType cellBufferSize = 1000; const std::shared_ptr pointBuffer = itk::MeshIOTestHelper::AllocateBuffer(byuMeshIO->GetPointComponentType(), pointBufferSize); diff --git a/Modules/IO/MeshBYU/test/itkMeshFileReadWriteTest.cxx b/Modules/IO/MeshBYU/test/itkMeshFileReadWriteTest.cxx index 97744f5bcc5..51c3190c394 100644 --- a/Modules/IO/MeshBYU/test/itkMeshFileReadWriteTest.cxx +++ b/Modules/IO/MeshBYU/test/itkMeshFileReadWriteTest.cxx @@ -32,7 +32,7 @@ itkMeshFileReadWriteTest(int argc, char * argv[]) return EXIT_FAILURE; } - bool isBinary = (argc > 3); + const bool isBinary = (argc > 3); constexpr unsigned int dimension = 3; using PixelType = float; @@ -55,7 +55,7 @@ itkMeshFileReadWriteTest(int argc, char * argv[]) // Exercise other methods to improve coverage - itk::BYUMeshIO::Pointer byuMeshIO = itk::BYUMeshIO::New(); + const itk::BYUMeshIO::Pointer byuMeshIO = itk::BYUMeshIO::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(byuMeshIO, BYUMeshIO, MeshIOBase); diff --git a/Modules/IO/MeshBase/include/itkMeshFileReader.hxx b/Modules/IO/MeshBase/include/itkMeshFileReader.hxx index 11adb7c5c5c..91fde04f9c3 100644 --- a/Modules/IO/MeshBase/include/itkMeshFileReader.hxx +++ b/Modules/IO/MeshBase/include/itkMeshFileReader.hxx @@ -102,7 +102,7 @@ template void MeshFileReader::ReadPoints(T * buffer) { - typename TOutputMesh::Pointer output = this->GetOutput(); + const typename TOutputMesh::Pointer output = this->GetOutput(); output->GetPoints()->Reserve(m_MeshIO->GetNumberOfPoints()); OutputPointType point; @@ -122,7 +122,7 @@ template void MeshFileReader::ReadCells(T * buffer) { - typename TOutputMesh::Pointer output = this->GetOutput(); + const typename TOutputMesh::Pointer output = this->GetOutput(); SizeValueType index{}; OutputCellIdentifier id{}; @@ -344,7 +344,7 @@ template ::ReadPointData() { - typename TOutputMesh::Pointer output = this->GetOutput(); + const typename TOutputMesh::Pointer output = this->GetOutput(); const auto outputPointDataBuffer = make_unique_for_overwrite(m_MeshIO->GetNumberOfPointPixels()); @@ -386,7 +386,7 @@ template ::ReadCellData() { - typename TOutputMesh::Pointer output = this->GetOutput(); + const typename TOutputMesh::Pointer output = this->GetOutput(); const auto outputCellDataBuffer = make_unique_for_overwrite(m_MeshIO->GetNumberOfCellPixels()); @@ -478,7 +478,7 @@ MeshFileReader::Ge { m_MeshIO->SetPointDimension(OutputPointDimension); - typename TOutputMesh::Pointer output = this->GetOutput(); + const typename TOutputMesh::Pointer output = this->GetOutput(); // Test if the file exists and if it can be opened. // An exception will be thrown otherwise, since we can't diff --git a/Modules/IO/MeshBase/include/itkMeshFileTestHelper.h b/Modules/IO/MeshBase/include/itkMeshFileTestHelper.h index d5d1de5472d..602494ac214 100644 --- a/Modules/IO/MeshBase/include/itkMeshFileTestHelper.h +++ b/Modules/IO/MeshBase/include/itkMeshFileTestHelper.h @@ -257,7 +257,7 @@ test(char * inputFileName, char * outputFileName, bool isBinary) using MeshFileWriterType = itk::MeshFileWriter; using MeshFileWriterPointer = typename MeshFileWriterType::Pointer; - MeshFileReaderPointer reader = MeshFileReaderType::New(); + const MeshFileReaderPointer reader = MeshFileReaderType::New(); reader->SetFileName(inputFileName); try { @@ -277,7 +277,7 @@ test(char * inputFileName, char * outputFileName, bool isBinary) return EXIT_FAILURE; } - MeshFileWriterPointer writer = MeshFileWriterType::New(); + const MeshFileWriterPointer writer = MeshFileWriterType::New(); if (itksys::SystemTools::GetFilenameLastExtension(inputFileName) == itksys::SystemTools::GetFilenameLastExtension(outputFileName)) { diff --git a/Modules/IO/MeshBase/include/itkMeshFileWriter.hxx b/Modules/IO/MeshBase/include/itkMeshFileWriter.hxx index b327a622822..699dce9e9ff 100644 --- a/Modules/IO/MeshBase/include/itkMeshFileWriter.hxx +++ b/Modules/IO/MeshBase/include/itkMeshFileWriter.hxx @@ -239,7 +239,7 @@ MeshFileWriter::WritePoints() const InputMeshType * input = this->GetInput(); itkDebugMacro("Writing points: " << m_FileName); - SizeValueType pointsBufferSize = input->GetNumberOfPoints() * TInputMesh::PointDimension; + const SizeValueType pointsBufferSize = input->GetNumberOfPoints() * TInputMesh::PointDimension; using ValueType = typename TInputMesh::PointType::ValueType; const auto buffer = make_unique_for_overwrite(pointsBufferSize); CopyPointsToBuffer(buffer.get()); @@ -252,7 +252,7 @@ MeshFileWriter::WriteCells() { itkDebugMacro("Writing cells: " << m_FileName); - SizeValueType cellsBufferSize = m_MeshIO->GetCellBufferSize(); + const SizeValueType cellsBufferSize = m_MeshIO->GetCellBufferSize(); using PointIdentifierType = typename TInputMesh::PointIdentifier; const auto buffer = make_unique_for_overwrite(cellsBufferSize); CopyCellsToBuffer(buffer.get()); @@ -382,7 +382,7 @@ MeshFileWriter::CopyCellsToBuffer(Output * data) data[index++] = cellPtr->GetNumberOfPoints(); // Others are point identifiers in the cell ptIds = cellPtr->GetPointIds(); - unsigned int numberOfPoints = cellPtr->GetNumberOfPoints(); + const unsigned int numberOfPoints = cellPtr->GetNumberOfPoints(); for (unsigned int ii = 0; ii < numberOfPoints; ++ii) { data[index++] = static_cast(ptIds[ii]); @@ -404,7 +404,7 @@ MeshFileWriter::CopyPointDataToBuffer(Output * data) // TODO? NumericTraitsVariableLengthVectorPixel should define ZeroValue() // Should define NumericTraitsArrayPixel - unsigned int numberOfComponents = + const unsigned int numberOfComponents = MeshConvertPixelTraits::GetNumberOfComponents(pointData->Begin().Value()); SizeValueType index = 0; @@ -433,7 +433,7 @@ MeshFileWriter::CopyCellDataToBuffer(Output * data) // TODO? NumericTraitsVariableLengthVectorPixel should define ZeroValue() // Should define NumericTraitsArrayPixel - unsigned int numberOfComponents = + const unsigned int numberOfComponents = MeshConvertPixelTraits::GetNumberOfComponents(cellData->Begin().Value()); SizeValueType index = 0; typename TInputMesh::CellDataContainer::ConstIterator cter = cellData->Begin(); diff --git a/Modules/IO/MeshBase/include/itkMeshIOTestHelper.h b/Modules/IO/MeshBase/include/itkMeshIOTestHelper.h index 6f4143d46a6..c87aa261776 100644 --- a/Modules/IO/MeshBase/include/itkMeshIOTestHelper.h +++ b/Modules/IO/MeshBase/include/itkMeshIOTestHelper.h @@ -60,8 +60,8 @@ TestBaseClassMethodsMeshIO(typename TMeshIO::Pointer meshIO) { using FloatType = float; - FloatType floatValue = 1.0; - bool usePointPixel = true; + const FloatType floatValue = 1.0; + bool usePointPixel = true; meshIO->SetPixelType(floatValue, usePointPixel); LOCAL_ITK_TEST_SET_GET_VALUE(1, meshIO->GetNumberOfPointPixelComponents()); LOCAL_ITK_TEST_SET_GET_VALUE(itk::MeshIOBase::MapComponentType::CType, @@ -78,7 +78,7 @@ TestBaseClassMethodsMeshIO(typename TMeshIO::Pointer meshIO) using RGBPixelType = itk::RGBPixel; - RGBPixelType rgbValue{ 1.0 }; + const RGBPixelType rgbValue{ 1.0 }; usePointPixel = true; meshIO->SetPixelType(rgbValue, usePointPixel); LOCAL_ITK_TEST_SET_GET_VALUE(3, meshIO->GetNumberOfPointPixelComponents()); @@ -225,7 +225,7 @@ TestBaseClassMethodsMeshIO(typename TMeshIO::Pointer meshIO) using ComplexPixelType = std::complex; - ComplexPixelType complexPixelValue(1.0, 1.0); + const ComplexPixelType complexPixelValue(1.0, 1.0); usePointPixel = true; meshIO->SetPixelType(complexPixelValue, usePointPixel); LOCAL_ITK_TEST_SET_GET_VALUE(2, meshIO->GetNumberOfPointPixelComponents()); @@ -243,7 +243,7 @@ TestBaseClassMethodsMeshIO(typename TMeshIO::Pointer meshIO) using ArrayPixelType = itk::Array; - ArrayPixelType arrayPixelValue{}; + const ArrayPixelType arrayPixelValue{}; usePointPixel = true; meshIO->SetPixelType(arrayPixelValue, usePointPixel); LOCAL_ITK_TEST_SET_GET_VALUE(arrayPixelValue.Size(), meshIO->GetNumberOfPointPixelComponents()); @@ -261,7 +261,7 @@ TestBaseClassMethodsMeshIO(typename TMeshIO::Pointer meshIO) using VariableLengthVectorPixelType = itk::VariableLengthVector; - VariableLengthVectorPixelType variableLengthVectorValue{}; + const VariableLengthVectorPixelType variableLengthVectorValue{}; usePointPixel = true; meshIO->SetPixelType(variableLengthVectorValue, usePointPixel); LOCAL_ITK_TEST_SET_GET_VALUE(variableLengthVectorValue.Size(), meshIO->GetNumberOfPointPixelComponents()); @@ -279,7 +279,7 @@ TestBaseClassMethodsMeshIO(typename TMeshIO::Pointer meshIO) using VariableSizeMatrixType = itk::VariableSizeMatrix; - VariableSizeMatrixType matrix{}; + const VariableSizeMatrixType matrix{}; usePointPixel = true; meshIO->SetPixelType(matrix, usePointPixel); LOCAL_ITK_TEST_SET_GET_VALUE(matrix.Rows() * matrix.Cols(), meshIO->GetNumberOfPointPixelComponents()); @@ -297,66 +297,66 @@ TestBaseClassMethodsMeshIO(typename TMeshIO::Pointer meshIO) // ToDo see how the above change the below // Do this only for the last pixel type - itk::IOComponentEnum floatComponent = itk::IOComponentEnum::FLOAT; + const itk::IOComponentEnum floatComponent = itk::IOComponentEnum::FLOAT; std::cout << "ComponentSize: " << meshIO->GetComponentSize(floatComponent) << std::endl; std::cout << "ComponentTypeAsString: " << meshIO->GetComponentTypeAsString(floatComponent) << std::endl; - itk::CommonEnums::IOPixel pixelType = itk::CommonEnums::IOPixel::SCALAR; + const itk::CommonEnums::IOPixel pixelType = itk::CommonEnums::IOPixel::SCALAR; std::cout << "PixelTypeAsString: " << meshIO->GetPixelTypeAsString(pixelType) << std::endl; - itk::CommonEnums::IOComponent pointComponentType = itk::CommonEnums::IOComponent::FLOAT; + const itk::CommonEnums::IOComponent pointComponentType = itk::CommonEnums::IOComponent::FLOAT; meshIO->SetPointComponentType(pointComponentType); LOCAL_ITK_TEST_SET_GET_VALUE(pointComponentType, meshIO->GetPointComponentType()); - itk::CommonEnums::IOComponent cellComponentType = itk::CommonEnums::IOComponent::FLOAT; + const itk::CommonEnums::IOComponent cellComponentType = itk::CommonEnums::IOComponent::FLOAT; meshIO->SetCellComponentType(cellComponentType); LOCAL_ITK_TEST_SET_GET_VALUE(cellComponentType, meshIO->GetCellComponentType()); - unsigned int pointDimension = 2; + const unsigned int pointDimension = 2; meshIO->SetPointDimension(pointDimension); LOCAL_ITK_TEST_SET_GET_VALUE(pointDimension, meshIO->GetPointDimension()); - itk::MeshIOBase::SizeValueType numberOfPoints = 400; + const itk::MeshIOBase::SizeValueType numberOfPoints = 400; meshIO->SetNumberOfPoints(numberOfPoints); LOCAL_ITK_TEST_SET_GET_VALUE(numberOfPoints, meshIO->GetNumberOfPoints()); - itk::MeshIOBase::SizeValueType numberOfCells = 100; + const itk::MeshIOBase::SizeValueType numberOfCells = 100; meshIO->SetNumberOfCells(numberOfCells); LOCAL_ITK_TEST_SET_GET_VALUE(numberOfCells, meshIO->GetNumberOfCells()); - itk::MeshIOBase::SizeValueType numberOfPointPixels = 200; + const itk::MeshIOBase::SizeValueType numberOfPointPixels = 200; meshIO->SetNumberOfPointPixels(numberOfPointPixels); LOCAL_ITK_TEST_SET_GET_VALUE(numberOfPointPixels, meshIO->GetNumberOfPointPixels()); - itk::MeshIOBase::SizeValueType numberOfCellPixels = 600; + const itk::MeshIOBase::SizeValueType numberOfCellPixels = 600; meshIO->SetNumberOfCellPixels(numberOfCellPixels); LOCAL_ITK_TEST_SET_GET_VALUE(numberOfCellPixels, meshIO->GetNumberOfCellPixels()); - itk::MeshIOBase::SizeValueType cellBufferSize = 1000; + const itk::MeshIOBase::SizeValueType cellBufferSize = 1000; meshIO->SetCellBufferSize(cellBufferSize); LOCAL_ITK_TEST_SET_GET_VALUE(cellBufferSize, meshIO->GetCellBufferSize()); - itk::IOFileEnum fileType = itk::IOFileEnum::ASCII; + const itk::IOFileEnum fileType = itk::IOFileEnum::ASCII; meshIO->SetFileType(fileType); LOCAL_ITK_TEST_SET_GET_VALUE(fileType, meshIO->GetFileType()); std::cout << "FileTypeAsString: " << meshIO->GetFileTypeAsString(fileType) << std::endl; - itk::IOByteOrderEnum ioByteOrder = itk::IOByteOrderEnum::BigEndian; + const itk::IOByteOrderEnum ioByteOrder = itk::IOByteOrderEnum::BigEndian; meshIO->SetByteOrder(ioByteOrder); LOCAL_ITK_TEST_SET_GET_VALUE(ioByteOrder, meshIO->GetByteOrder()); std::cout << "ByteOrderAsString: " << meshIO->GetByteOrderAsString(ioByteOrder) << std::endl; - itk::MeshIOBase::ArrayOfExtensionsType supportedReadExtensions = meshIO->GetSupportedReadExtensions(); + const itk::MeshIOBase::ArrayOfExtensionsType supportedReadExtensions = meshIO->GetSupportedReadExtensions(); std::cout << "SupportedReadExtensions: " << std::endl; for (auto ext : supportedReadExtensions) { std::cout << ext << std::endl; } - itk::MeshIOBase::ArrayOfExtensionsType supportedWriteExtensions = meshIO->GetSupportedWriteExtensions(); + const itk::MeshIOBase::ArrayOfExtensionsType supportedWriteExtensions = meshIO->GetSupportedWriteExtensions(); std::cout << "SupportedWriteExtensions: " << std::endl; for (auto ext : supportedWriteExtensions) { diff --git a/Modules/IO/MeshFreeSurfer/src/itkFreeSurferBinaryMeshIO.cxx b/Modules/IO/MeshFreeSurfer/src/itkFreeSurferBinaryMeshIO.cxx index e50bb88cc35..633a97b38b7 100644 --- a/Modules/IO/MeshFreeSurfer/src/itkFreeSurferBinaryMeshIO.cxx +++ b/Modules/IO/MeshFreeSurfer/src/itkFreeSurferBinaryMeshIO.cxx @@ -301,7 +301,7 @@ FreeSurferBinaryMeshIO::WriteMeshInformation() const char buffer[3] = { static_cast(255), static_cast(255), static_cast(254) }; outputFile.write(buffer, 3); - std::string creator = "Created by ITK \n\n"; + const std::string creator = "Created by ITK \n\n"; outputFile.write(const_cast(creator.c_str()), creator.size()); auto numberOfPoints = static_cast(this->m_NumberOfPoints); @@ -315,9 +315,9 @@ FreeSurferBinaryMeshIO::WriteMeshInformation() const char buffer[3] = { static_cast(255), static_cast(255), static_cast(255) }; outputFile.write(buffer, 3); - auto numberOfPoints = static_cast(this->m_NumberOfPointPixels); - auto numberOfCells = static_cast(this->m_NumberOfCells); - itk::uint32_t numberOfValuesPerPoint = 1; + auto numberOfPoints = static_cast(this->m_NumberOfPointPixels); + auto numberOfCells = static_cast(this->m_NumberOfCells); + const itk::uint32_t numberOfValuesPerPoint = 1; itk::ByteSwapper::SwapWriteRangeFromSystemToBigEndian(&numberOfPoints, 1, &outputFile); itk::ByteSwapper::SwapWriteRangeFromSystemToBigEndian(&numberOfCells, 1, &outputFile); itk::ByteSwapper::SwapWriteRangeFromSystemToBigEndian(&numberOfValuesPerPoint, 1, &outputFile); diff --git a/Modules/IO/MeshFreeSurfer/test/itkFreeSurferMeshIOTest.cxx b/Modules/IO/MeshFreeSurfer/test/itkFreeSurferMeshIOTest.cxx index 946fe7ebbb0..cdd023a446b 100644 --- a/Modules/IO/MeshFreeSurfer/test/itkFreeSurferMeshIOTest.cxx +++ b/Modules/IO/MeshFreeSurfer/test/itkFreeSurferMeshIOTest.cxx @@ -73,8 +73,8 @@ itkFreeSurferMeshIOTestHelper(typename TMeshIO::Pointer fsMeshIO, ITK_TEST_EXPECT_EQUAL(numberOfCells, fsMeshIO->GetNumberOfCells()); ITK_TEST_EXPECT_EQUAL(numberOfCellPixels, fsMeshIO->GetNumberOfCellPixels()); - itk::SizeValueType pointBufferSize = 3 * sizeof(float) * fsMeshIO->GetNumberOfPoints(); - itk::SizeValueType cellBufferSize = 3 * sizeof(uint32_t) * fsMeshIO->GetNumberOfCells(); + const itk::SizeValueType pointBufferSize = 3 * sizeof(float) * fsMeshIO->GetNumberOfPoints(); + const itk::SizeValueType cellBufferSize = 3 * sizeof(uint32_t) * fsMeshIO->GetNumberOfCells(); const std::shared_ptr pointBuffer = itk::MeshIOTestHelper::AllocateBuffer(fsMeshIO->GetPointComponentType(), pointBufferSize); @@ -159,7 +159,7 @@ itkFreeSurferMeshIOTest(int argc, char * argv[]) auto numberOfCells = static_cast(std::stoi(argv[12])); auto numberOfCellPixels = static_cast(std::stoi(argv[13])); - bool isBinary = static_cast(std::stoi(argv[14])); + const bool isBinary = static_cast(std::stoi(argv[14])); if (!isBinary) { auto fsMeshIO = itk::FreeSurferAsciiMeshIO::New(); diff --git a/Modules/IO/MeshFreeSurfer/test/itkMeshFileReadWriteTest.cxx b/Modules/IO/MeshFreeSurfer/test/itkMeshFileReadWriteTest.cxx index f570afba572..fc2fdb68fdb 100644 --- a/Modules/IO/MeshFreeSurfer/test/itkMeshFileReadWriteTest.cxx +++ b/Modules/IO/MeshFreeSurfer/test/itkMeshFileReadWriteTest.cxx @@ -32,7 +32,7 @@ itkMeshFileReadWriteTest(int argc, char * argv[]) return EXIT_FAILURE; } - bool isBinary = (argc > 3); + const bool isBinary = (argc > 3); constexpr unsigned int dimension = 3; using PixelType = float; diff --git a/Modules/IO/MeshGifti/src/itkGiftiMeshIO.cxx b/Modules/IO/MeshGifti/src/itkGiftiMeshIO.cxx index 3ec05dee3e3..7d99a5ec624 100644 --- a/Modules/IO/MeshGifti/src/itkGiftiMeshIO.cxx +++ b/Modules/IO/MeshGifti/src/itkGiftiMeshIO.cxx @@ -359,7 +359,7 @@ GiftiMeshIO::ReadMeshInformation() MetaDataDictionary & metaDic = this->GetMetaDataDictionary(); if (m_GiftiImage->labeltable.rgba) { - LabelColorContainerPointer colorMap = LabelColorContainer::New(); + const LabelColorContainerPointer colorMap = LabelColorContainer::New(); for (int mm = 0; mm < m_GiftiImage->labeltable.length; ++mm) { RGBAPixelType pp; @@ -375,7 +375,7 @@ GiftiMeshIO::ReadMeshInformation() if (m_GiftiImage->labeltable.label) { - LabelNameContainerPointer labelMap = LabelNameContainer::New(); + const LabelNameContainerPointer labelMap = LabelNameContainer::New(); for (int mm = 0; mm < m_GiftiImage->labeltable.length; ++mm) { if (m_GiftiImage->labeltable.label[mm]) @@ -712,8 +712,8 @@ GiftiMeshIO::WriteMeshInformation() } // write labelTable using labelMap and colorMap - MetaDataDictionary & metaDic = this->GetMetaDataDictionary(); - LabelNameContainerPointer labelMap; + const MetaDataDictionary & metaDic = this->GetMetaDataDictionary(); + LabelNameContainerPointer labelMap; if (ExposeMetaData(metaDic, "labelContainer", labelMap)) { if (labelMap) @@ -775,7 +775,7 @@ GiftiMeshIO::WriteMeshInformation() } m_GiftiImage->darray[dalist[0]]->nvals = nvals; - int dtype = NIFTI_TYPE_FLOAT32; + const int dtype = NIFTI_TYPE_FLOAT32; // Set intent of data array gifti_set_atr_in_DAs(m_GiftiImage, "Intent", gifti_intent_to_string(NIFTI_INTENT_POINTSET), dalist, 1); @@ -847,7 +847,7 @@ GiftiMeshIO::WriteMeshInformation() } m_GiftiImage->darray[dalist[0]]->nvals = nvals; - int dtype = NIFTI_TYPE_INT32; + const int dtype = NIFTI_TYPE_INT32; // Set intent of data array gifti_set_atr_in_DAs(m_GiftiImage, "Intent", gifti_intent_to_string(NIFTI_INTENT_TRIANGLE), dalist, 1); diff --git a/Modules/IO/MeshGifti/test/itkGiftiMeshIOTest.cxx b/Modules/IO/MeshGifti/test/itkGiftiMeshIOTest.cxx index 57acd72ddad..33ba4fccd01 100644 --- a/Modules/IO/MeshGifti/test/itkGiftiMeshIOTest.cxx +++ b/Modules/IO/MeshGifti/test/itkGiftiMeshIOTest.cxx @@ -74,7 +74,7 @@ itkGiftiMeshIOTest(int argc, char * argv[]) itk::GiftiMeshIO::SizeValueType numberOfPoints = 0; // Test an inconsistent point/cell data count - bool requiresConsistency = std::stoul(argv[17]); + const bool requiresConsistency = std::stoul(argv[17]); if (requiresConsistency) { numberOfPoints = std::stoul(argv[11]) + 1; @@ -110,8 +110,8 @@ itkGiftiMeshIOTest(int argc, char * argv[]) giftiMeshIO->SetDirection(direction); ITK_TEST_SET_GET_VALUE(direction, giftiMeshIO->GetDirection()); - itk::GiftiMeshIO::LabelColorContainerPointer colorMap = giftiMeshIO->GetLabelColorTable(); - itk::GiftiMeshIO::LabelNameContainerPointer labelMap = giftiMeshIO->GetLabelNameTable(); + const itk::GiftiMeshIO::LabelColorContainerPointer colorMap = giftiMeshIO->GetLabelColorTable(); + const itk::GiftiMeshIO::LabelNameContainerPointer labelMap = giftiMeshIO->GetLabelNameTable(); giftiMeshIO->SetLabelColorTable(colorMap); ITK_TEST_SET_GET_VALUE(colorMap, giftiMeshIO->GetLabelColorTable()); @@ -135,11 +135,11 @@ itkGiftiMeshIOTest(int argc, char * argv[]) ITK_TEST_EXPECT_EQUAL(numberOfCellPixels, giftiMeshIO->GetNumberOfCellPixels()); // Use sufficiently large buffer sizes - itk::SizeValueType pointBufferSize = 1000000; - itk::SizeValueType pointDataBufferSize = 1000000; + const itk::SizeValueType pointBufferSize = 1000000; + const itk::SizeValueType pointDataBufferSize = 1000000; - itk::SizeValueType cellBufferSize = 1000000; - itk::SizeValueType cellDataBufferSize = 1000000; + const itk::SizeValueType cellBufferSize = 1000000; + const itk::SizeValueType cellDataBufferSize = 1000000; const std::shared_ptr pointBuffer = itk::MeshIOTestHelper::AllocateBuffer(giftiMeshIO->GetPointComponentType(), pointBufferSize); @@ -163,20 +163,20 @@ itkGiftiMeshIOTest(int argc, char * argv[]) giftiMeshIO->SetUpdatePointData(writeUpdatePointData); // Test writing exceptions - unsigned int numberOfPointPixelComponents = giftiMeshIO->GetNumberOfPointPixelComponents(); + const unsigned int numberOfPointPixelComponents = giftiMeshIO->GetNumberOfPointPixelComponents(); if (numberOfPointPixelComponents != 1 && numberOfPointPixelComponents != 3) { - bool localUpdatePointData = true; + const bool localUpdatePointData = true; giftiMeshIO->SetUpdatePointData(localUpdatePointData); ITK_TRY_EXPECT_EXCEPTION(giftiMeshIO->WriteMeshInformation()); giftiMeshIO->SetUpdatePointData(writeUpdatePointData); } - unsigned int numberOfCellPixelComponents = giftiMeshIO->GetNumberOfCellPixelComponents(); + const unsigned int numberOfCellPixelComponents = giftiMeshIO->GetNumberOfCellPixelComponents(); if (numberOfCellPixelComponents != 1 && numberOfCellPixelComponents != 3) { - bool localUpdateCellData = true; + const bool localUpdateCellData = true; giftiMeshIO->SetUpdateCellData(localUpdateCellData); ITK_TRY_EXPECT_EXCEPTION(giftiMeshIO->WriteMeshInformation()); diff --git a/Modules/IO/MeshGifti/test/itkMeshFileReadWriteTest.cxx b/Modules/IO/MeshGifti/test/itkMeshFileReadWriteTest.cxx index f570afba572..fc2fdb68fdb 100644 --- a/Modules/IO/MeshGifti/test/itkMeshFileReadWriteTest.cxx +++ b/Modules/IO/MeshGifti/test/itkMeshFileReadWriteTest.cxx @@ -32,7 +32,7 @@ itkMeshFileReadWriteTest(int argc, char * argv[]) return EXIT_FAILURE; } - bool isBinary = (argc > 3); + const bool isBinary = (argc > 3); constexpr unsigned int dimension = 3; using PixelType = float; diff --git a/Modules/IO/MeshOBJ/src/itkOBJMeshIO.cxx b/Modules/IO/MeshOBJ/src/itkOBJMeshIO.cxx index 11c8fed9fc0..e8816d33956 100644 --- a/Modules/IO/MeshOBJ/src/itkOBJMeshIO.cxx +++ b/Modules/IO/MeshOBJ/src/itkOBJMeshIO.cxx @@ -98,7 +98,7 @@ OBJMeshIO::CloseFile() bool OBJMeshIO::SplitLine(const std::string & line, std::string & type, std::string & content) { - std::locale loc; + const std::locale loc; std::string::const_iterator start = line.begin(); while (start != line.end() && std::isspace(*start, loc)) @@ -134,10 +134,10 @@ OBJMeshIO::ReadMeshInformation() this->m_NumberOfPoints = 0; this->m_NumberOfCells = 0; this->m_NumberOfPointPixels = 0; - std::string line; - std::string inputLine; - std::string type; - std::locale loc; + std::string line; + std::string inputLine; + std::string type; + const std::locale loc; while (std::getline(m_InputFile, line, '\n')) { if (SplitLine(line, type, inputLine) && !inputLine.empty()) @@ -220,10 +220,10 @@ OBJMeshIO::ReadPoints(void * buffer) SizeValueType index = 0; // Read and analyze the first line in the file - std::string line; - std::string inputLine; - std::string type; - std::locale loc; + std::string line; + std::string inputLine; + std::string type; + const std::locale loc; while (std::getline(m_InputFile, line, '\n')) { if (SplitLine(line, type, inputLine) && !inputLine.empty()) @@ -252,10 +252,10 @@ OBJMeshIO::ReadCells(void * buffer) const auto data = make_unique_for_overwrite(this->m_CellBufferSize - this->m_NumberOfCells); SizeValueType index = 0; - std::string line; - std::string inputLine; - std::string type; - std::locale loc; + std::string line; + std::string inputLine; + std::string type; + const std::locale loc; while (std::getline(m_InputFile, line, '\n')) { if (SplitLine(line, type, inputLine) && !inputLine.empty()) @@ -282,7 +282,7 @@ OBJMeshIO::ReadCells(void * buffer) } data[index++] = static_cast(idList.size()); - for (long it : idList) + for (const long it : idList) { data[index++] = (it - 1); } @@ -309,10 +309,10 @@ OBJMeshIO::ReadPointData(void * buffer) SizeValueType index = 0; // Read and analyze the first line in the file - std::string line; - std::string inputLine; - std::string type; - std::locale loc; + std::string line; + std::string inputLine; + std::string type; + const std::locale loc; while (std::getline(m_InputFile, line, '\n')) { if (SplitLine(line, type, inputLine) && !inputLine.empty()) diff --git a/Modules/IO/MeshOBJ/test/itkMeshFileReadWriteTest.cxx b/Modules/IO/MeshOBJ/test/itkMeshFileReadWriteTest.cxx index f570afba572..fc2fdb68fdb 100644 --- a/Modules/IO/MeshOBJ/test/itkMeshFileReadWriteTest.cxx +++ b/Modules/IO/MeshOBJ/test/itkMeshFileReadWriteTest.cxx @@ -32,7 +32,7 @@ itkMeshFileReadWriteTest(int argc, char * argv[]) return EXIT_FAILURE; } - bool isBinary = (argc > 3); + const bool isBinary = (argc > 3); constexpr unsigned int dimension = 3; using PixelType = float; diff --git a/Modules/IO/MeshOBJ/test/itkOBJMeshIOTest.cxx b/Modules/IO/MeshOBJ/test/itkOBJMeshIOTest.cxx index b51cf014a33..344682e2c21 100644 --- a/Modules/IO/MeshOBJ/test/itkOBJMeshIOTest.cxx +++ b/Modules/IO/MeshOBJ/test/itkOBJMeshIOTest.cxx @@ -96,10 +96,10 @@ itkOBJMeshIOTest(int argc, char * argv[]) ITK_TEST_EXPECT_EQUAL(numberOfCellPixels, objMeshIO->GetNumberOfCellPixels()); // Use sufficiently large buffer sizes - itk::SizeValueType pointBufferSize = 100000; - itk::SizeValueType pointDataBufferSize = 100000; + const itk::SizeValueType pointBufferSize = 100000; + const itk::SizeValueType pointDataBufferSize = 100000; - itk::SizeValueType cellBufferSize = 100000; + const itk::SizeValueType cellBufferSize = 100000; const std::shared_ptr pointBuffer = itk::MeshIOTestHelper::AllocateBuffer(objMeshIO->GetPointComponentType(), pointBufferSize); const std::shared_ptr pointDataBuffer = diff --git a/Modules/IO/MeshOFF/src/itkOFFMeshIO.cxx b/Modules/IO/MeshOFF/src/itkOFFMeshIO.cxx index 9aea1c22428..39714a40eb9 100644 --- a/Modules/IO/MeshOFF/src/itkOFFMeshIO.cxx +++ b/Modules/IO/MeshOFF/src/itkOFFMeshIO.cxx @@ -361,7 +361,7 @@ OFFMeshIO::WriteMeshInformation() outputFile << this->m_NumberOfCells << " "; // Write number of edges - unsigned int numberOfEdges = 0; + const unsigned int numberOfEdges = 0; outputFile << numberOfEdges << std::endl; } else if (this->m_FileType == IOFileEnum::BINARY) diff --git a/Modules/IO/MeshOFF/test/itkMeshFileReadWriteTest.cxx b/Modules/IO/MeshOFF/test/itkMeshFileReadWriteTest.cxx index 995fb276740..fd2a1f16c67 100644 --- a/Modules/IO/MeshOFF/test/itkMeshFileReadWriteTest.cxx +++ b/Modules/IO/MeshOFF/test/itkMeshFileReadWriteTest.cxx @@ -32,7 +32,7 @@ itkMeshFileReadWriteTest(int argc, char * argv[]) return EXIT_FAILURE; } - bool isBinary = (argc > 3); + const bool isBinary = (argc > 3); constexpr unsigned int dimension = 3; using PixelType = float; diff --git a/Modules/IO/MeshOFF/test/itkOFFMeshIOTest.cxx b/Modules/IO/MeshOFF/test/itkOFFMeshIOTest.cxx index dd68f3e89ec..d064ea8e911 100644 --- a/Modules/IO/MeshOFF/test/itkOFFMeshIOTest.cxx +++ b/Modules/IO/MeshOFF/test/itkOFFMeshIOTest.cxx @@ -95,8 +95,8 @@ itkOFFMeshIOTest(int argc, char * argv[]) ITK_TEST_EXPECT_EQUAL(numberOfCellPixels, offMeshIO->GetNumberOfCellPixels()); // Use sufficiently large buffer sizes - itk::SizeValueType pointBufferSize = 1000; - itk::SizeValueType cellBufferSize = 1000; + const itk::SizeValueType pointBufferSize = 1000; + const itk::SizeValueType cellBufferSize = 1000; const std::shared_ptr pointBuffer = itk::MeshIOTestHelper::AllocateBuffer(offMeshIO->GetPointComponentType(), pointBufferSize); diff --git a/Modules/IO/MeshVTK/include/itkVTKPolyDataMeshIO.h b/Modules/IO/MeshVTK/include/itkVTKPolyDataMeshIO.h index b00b614cfbd..3d44d31f4e2 100644 --- a/Modules/IO/MeshVTK/include/itkVTKPolyDataMeshIO.h +++ b/Modules/IO/MeshVTK/include/itkVTKPolyDataMeshIO.h @@ -224,7 +224,7 @@ class ITKIOMeshVTK_EXPORT VTKPolyDataMeshIO : public MeshIOBase if (line.find("POINTS") != std::string::npos) { /** Load the point coordinates into the itk::Mesh */ - SizeValueType numberOfComponents = this->m_NumberOfPoints * this->m_PointDimension; + const SizeValueType numberOfComponents = this->m_NumberOfPoints * this->m_PointDimension; inputFile.read(reinterpret_cast(buffer), numberOfComponents * sizeof(T)); if constexpr (itk::ByteSwapper::SystemIsLittleEndian()) { @@ -322,7 +322,7 @@ class ITKIOMeshVTK_EXPORT VTKPolyDataMeshIO : public MeshIOBase } /** for VECTORS or NORMALS or TENSORS, we could read them directly */ - SizeValueType numberOfComponents = this->m_NumberOfPointPixels * this->m_NumberOfPointPixelComponents; + const SizeValueType numberOfComponents = this->m_NumberOfPointPixels * this->m_NumberOfPointPixelComponents; inputFile.read(reinterpret_cast(buffer), numberOfComponents * sizeof(T)); if constexpr (itk::ByteSwapper::SystemIsLittleEndian()) { @@ -413,7 +413,7 @@ class ITKIOMeshVTK_EXPORT VTKPolyDataMeshIO : public MeshIOBase } } /** For VECTORS or NORMALS or TENSORS, we could read them directly */ - SizeValueType numberOfComponents = this->m_NumberOfCellPixels * this->m_NumberOfCellPixelComponents; + const SizeValueType numberOfComponents = this->m_NumberOfCellPixels * this->m_NumberOfCellPixelComponents; inputFile.read(reinterpret_cast(buffer), numberOfComponents * sizeof(T)); if constexpr (itk::ByteSwapper::SystemIsLittleEndian()) { @@ -503,9 +503,9 @@ class ITKIOMeshVTK_EXPORT VTKPolyDataMeshIO : public MeshIOBase if (numberOfLines) { numberOfLineIndices = 0; - SizeValueType numberOfPolylines = 0; - PolylinesContainerPointer polylines = PolylinesContainerType::New(); - PointIdVector pointIds; + SizeValueType numberOfPolylines = 0; + const PolylinesContainerPointer polylines = PolylinesContainerType::New(); + PointIdVector pointIds; for (SizeValueType ii = 0; ii < this->m_NumberOfCells; ++ii) { auto cellType = static_cast(static_cast(buffer[index++])); @@ -609,9 +609,9 @@ class ITKIOMeshVTK_EXPORT VTKPolyDataMeshIO : public MeshIOBase if (numberOfLines) { numberOfLineIndices = 0; - SizeValueType numberOfPolylines = 0; - PolylinesContainerPointer polylines = PolylinesContainerType::New(); - PointIdVector pointIds; + SizeValueType numberOfPolylines = 0; + const PolylinesContainerPointer polylines = PolylinesContainerType::New(); + PointIdVector pointIds; for (SizeValueType ii = 0; ii < this->m_NumberOfCells; ++ii) { auto cellType = static_cast(static_cast(buffer[index++])); @@ -676,8 +676,8 @@ class ITKIOMeshVTK_EXPORT VTKPolyDataMeshIO : public MeshIOBase void WritePointDataBufferAsASCII(std::ofstream & outputFile, T * buffer, const StringType & pointPixelComponentName) { - MetaDataDictionary & metaDic = this->GetMetaDataDictionary(); - StringType dataName; + const MetaDataDictionary & metaDic = this->GetMetaDataDictionary(); + StringType dataName; outputFile << "POINT_DATA " << this->m_NumberOfPointPixels << '\n'; switch (this->m_PointPixelType) @@ -730,7 +730,7 @@ class ITKIOMeshVTK_EXPORT VTKPolyDataMeshIO : public MeshIOBase outputFile << "LOOKUP_TABLE default" << '\n'; } - Indent indent(2); + const Indent indent(2); if (this->m_PointPixelType == IOPixelEnum::SYMMETRICSECONDRANKTENSOR) { T * ptr = buffer; @@ -807,8 +807,8 @@ class ITKIOMeshVTK_EXPORT VTKPolyDataMeshIO : public MeshIOBase void WritePointDataBufferAsBINARY(std::ofstream & outputFile, T * buffer, const StringType & pointPixelComponentName) { - MetaDataDictionary & metaDic = this->GetMetaDataDictionary(); - StringType dataName; + const MetaDataDictionary & metaDic = this->GetMetaDataDictionary(); + StringType dataName; outputFile << "POINT_DATA " << this->m_NumberOfPointPixels << '\n'; switch (this->m_PointPixelType) @@ -870,8 +870,8 @@ class ITKIOMeshVTK_EXPORT VTKPolyDataMeshIO : public MeshIOBase void WriteCellDataBufferAsASCII(std::ofstream & outputFile, T * buffer, const StringType & cellPixelComponentName) { - MetaDataDictionary & metaDic = this->GetMetaDataDictionary(); - StringType dataName; + const MetaDataDictionary & metaDic = this->GetMetaDataDictionary(); + StringType dataName; outputFile << "CELL_DATA " << this->m_NumberOfCellPixels << '\n'; switch (this->m_CellPixelType) @@ -923,7 +923,7 @@ class ITKIOMeshVTK_EXPORT VTKPolyDataMeshIO : public MeshIOBase outputFile << "LOOKUP_TABLE default" << '\n'; } - Indent indent(2); + const Indent indent(2); if (this->m_CellPixelType == IOPixelEnum::SYMMETRICSECONDRANKTENSOR) { T * ptr = buffer; @@ -997,8 +997,8 @@ class ITKIOMeshVTK_EXPORT VTKPolyDataMeshIO : public MeshIOBase void WriteCellDataBufferAsBINARY(std::ofstream & outputFile, T * buffer, const StringType & cellPixelComponentName) { - MetaDataDictionary & metaDic = this->GetMetaDataDictionary(); - StringType dataName; + const MetaDataDictionary & metaDic = this->GetMetaDataDictionary(); + StringType dataName; outputFile << "CELL_DATA " << this->m_NumberOfCellPixels << '\n'; switch (this->m_CellPixelType) @@ -1064,7 +1064,7 @@ class ITKIOMeshVTK_EXPORT VTKPolyDataMeshIO : public MeshIOBase SizeValueType numberOfPixels) { outputFile << numberOfPixelComponents << '\n'; - Indent indent(2); + const Indent indent(2); for (SizeValueType ii = 0; ii < numberOfPixels; ++ii) { for (unsigned int jj = 0; jj < numberOfPixelComponents; ++jj) @@ -1086,8 +1086,8 @@ class ITKIOMeshVTK_EXPORT VTKPolyDataMeshIO : public MeshIOBase SizeValueType numberOfPixels) { outputFile << numberOfPixelComponents << '\n'; - SizeValueType numberOfElements = numberOfPixelComponents * numberOfPixels; - const auto data = make_unique_for_overwrite(numberOfElements); + const SizeValueType numberOfElements = numberOfPixelComponents * numberOfPixels; + const auto data = make_unique_for_overwrite(numberOfElements); for (SizeValueType ii = 0; ii < numberOfElements; ++ii) { data[ii] = static_cast(buffer[ii]); diff --git a/Modules/IO/MeshVTK/src/itkVTKPolyDataMeshIO.cxx b/Modules/IO/MeshVTK/src/itkVTKPolyDataMeshIO.cxx index 697e043fd8c..e6e0f8ef43d 100644 --- a/Modules/IO/MeshVTK/src/itkVTKPolyDataMeshIO.cxx +++ b/Modules/IO/MeshVTK/src/itkVTKPolyDataMeshIO.cxx @@ -273,10 +273,10 @@ VTKPolyDataMeshIO::ReadMeshInformation() std::getline(inputFile, line, '\n'); ++numLine; - size_t versionPos = line.find("Version "); + const size_t versionPos = line.find("Version "); if (versionPos != std::string::npos) { - std::string versionString = line.substr(versionPos + 8); + const std::string versionString = line.substr(versionPos + 8); // Split the version string by "." std::vector versionTokens; std::istringstream iss(versionString); @@ -988,7 +988,7 @@ VTKPolyDataMeshIO::ReadCellsBufferAsASCII(std::ifstream & inputFile, void * buff SizeValueType index = 0; unsigned int numPoints; // number of point in each cell - MetaDataDictionary & metaDic = this->GetMetaDataDictionary(); + const MetaDataDictionary & metaDic = this->GetMetaDataDictionary(); using GeometryIntegerType = unsigned int; auto * data = static_cast(buffer); @@ -1225,9 +1225,9 @@ VTKPolyDataMeshIO::ReadCellsBufferAsBINARYConnectivityType(std::ifstream & input using ConnectivityType = TConnectivity; using GeometryIntegerType = unsigned int; - std::string line; - MetaDataDictionary & metaDic = this->GetMetaDataDictionary(); - unsigned int numPoints; // number of point in each cell + std::string line; + const MetaDataDictionary & metaDic = this->GetMetaDataDictionary(); + unsigned int numPoints; // number of point in each cell auto * outputBuffer = static_cast(buffer); while (!inputFile.eof()) @@ -1408,8 +1408,8 @@ VTKPolyDataMeshIO::ReadCellsBufferAsBINARYOffsetType(std::ifstream & inputFile, { using OffsetType = TOffset; - MetaDataDictionary & metaDic = this->GetMetaDataDictionary(); - std::string connectivityType; + const MetaDataDictionary & metaDic = this->GetMetaDataDictionary(); + std::string connectivityType; ExposeMetaData(metaDic, "connectivityType", connectivityType); const auto connectivityComponentType = this->GetComponentTypeFromString(connectivityType); switch (connectivityComponentType) @@ -1440,7 +1440,7 @@ VTKPolyDataMeshIO::ReadCellsBufferAsBINARY(std::ifstream & inputFile, void * buf } using GeometryIntegerType = unsigned int; - MetaDataDictionary & metaDic = this->GetMetaDataDictionary(); + const MetaDataDictionary & metaDic = this->GetMetaDataDictionary(); if (this->m_ReadMeshVersionMajor >= 5) { diff --git a/Modules/IO/MeshVTK/test/itkMeshFileReadWriteTest.cxx b/Modules/IO/MeshVTK/test/itkMeshFileReadWriteTest.cxx index b5be27d6134..08781613a6e 100644 --- a/Modules/IO/MeshVTK/test/itkMeshFileReadWriteTest.cxx +++ b/Modules/IO/MeshVTK/test/itkMeshFileReadWriteTest.cxx @@ -32,7 +32,7 @@ itkMeshFileReadWriteTest(int argc, char * argv[]) return EXIT_FAILURE; } - bool isBinary = (argc > 3); + const bool isBinary = (argc > 3); constexpr unsigned int Dimension = 3; using PixelType = float; diff --git a/Modules/IO/MeshVTK/test/itkMeshFileReadWriteVectorAttributeTest.cxx b/Modules/IO/MeshVTK/test/itkMeshFileReadWriteVectorAttributeTest.cxx index 4fd79f84e17..cb9908ea487 100644 --- a/Modules/IO/MeshVTK/test/itkMeshFileReadWriteVectorAttributeTest.cxx +++ b/Modules/IO/MeshVTK/test/itkMeshFileReadWriteVectorAttributeTest.cxx @@ -32,7 +32,7 @@ itkMeshFileReadWriteVectorAttributeTest(int argc, char * argv[]) return EXIT_FAILURE; } - bool isBinary = (argc > 3); + const bool isBinary = (argc > 3); constexpr unsigned int Dimension = 3; using PixelType = itk::CovariantVector; diff --git a/Modules/IO/MeshVTK/test/itkMeshFileWriteReadTensorTest.cxx b/Modules/IO/MeshVTK/test/itkMeshFileWriteReadTensorTest.cxx index 809a59ea8b6..b9104a76de8 100644 --- a/Modules/IO/MeshVTK/test/itkMeshFileWriteReadTensorTest.cxx +++ b/Modules/IO/MeshVTK/test/itkMeshFileWriteReadTensorTest.cxx @@ -48,7 +48,7 @@ itkMeshFileWriteReadTensorTest(int argc, char * argv[]) auto point2d = itk::MakeFilled(1); - Mesh2dType::PixelType pixel2d{}; + const Mesh2dType::PixelType pixel2d{}; auto mesh2d = Mesh2dType::New(); mesh2d->SetPoint(0, point2d); @@ -58,7 +58,7 @@ itkMeshFileWriteReadTensorTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(mesh2dWriter, MeshFileWriter, ProcessObject); - itk::VTKPolyDataMeshIO::Pointer vtkPolyDataMeshIO = itk::VTKPolyDataMeshIO::New(); + const itk::VTKPolyDataMeshIO::Pointer vtkPolyDataMeshIO = itk::VTKPolyDataMeshIO::New(); // Supported read extensions are empty by default ITK_TEST_EXPECT_TRUE(vtkPolyDataMeshIO->GetSupportedReadExtensions().empty()); @@ -72,7 +72,7 @@ itkMeshFileWriteReadTensorTest(int argc, char * argv[]) mesh2dWriter->SetFileName(outputMesh2D); ITK_TEST_SET_GET_VALUE(outputMesh2D, std::string(mesh2dWriter->GetFileName())); - bool useCompression = false; + const bool useCompression = false; ITK_TEST_SET_GET_BOOLEAN(mesh2dWriter, UseCompression, useCompression); mesh2dWriter->SetInput(mesh2d); @@ -88,7 +88,7 @@ itkMeshFileWriteReadTensorTest(int argc, char * argv[]) auto point3d = itk::MakeFilled(1); - Mesh3dType::PixelType pixel3d{}; + const Mesh3dType::PixelType pixel3d{}; auto mesh3d = Mesh3dType::New(); mesh3d->SetPoint(0, point3d); @@ -99,7 +99,7 @@ itkMeshFileWriteReadTensorTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(mesh3dWriter, MeshFileWriter, ProcessObject); - itk::VTKPolyDataMeshIO::Pointer vtkPolyDataMeshIO2 = itk::VTKPolyDataMeshIO::New(); + const itk::VTKPolyDataMeshIO::Pointer vtkPolyDataMeshIO2 = itk::VTKPolyDataMeshIO::New(); mesh3dWriter->SetMeshIO(vtkPolyDataMeshIO2); ITK_TEST_SET_GET_VALUE(vtkPolyDataMeshIO2, mesh3dWriter->GetMeshIO()); diff --git a/Modules/IO/MeshVTK/test/itkPolylineReadWriteTest.cxx b/Modules/IO/MeshVTK/test/itkPolylineReadWriteTest.cxx index c6f0872f467..71c0fcd7df3 100644 --- a/Modules/IO/MeshVTK/test/itkPolylineReadWriteTest.cxx +++ b/Modules/IO/MeshVTK/test/itkPolylineReadWriteTest.cxx @@ -32,7 +32,7 @@ itkPolylineReadWriteTest(int argc, char * argv[]) return EXIT_FAILURE; } - bool isBinary = (argc > 3); + const bool isBinary = (argc > 3); constexpr unsigned int Dimension = 3; using PixelType = itk::VariableLengthVector; diff --git a/Modules/IO/MeshVTK/test/itkVTKPolyDataMeshCanReadImageTest.cxx b/Modules/IO/MeshVTK/test/itkVTKPolyDataMeshCanReadImageTest.cxx index bf6de47878b..a05b4d04168 100644 --- a/Modules/IO/MeshVTK/test/itkVTKPolyDataMeshCanReadImageTest.cxx +++ b/Modules/IO/MeshVTK/test/itkVTKPolyDataMeshCanReadImageTest.cxx @@ -30,7 +30,7 @@ itkVTKPolyDataMeshCanReadImageTest(int argc, char * argv[]) return EXIT_FAILURE; } - itk::VTKPolyDataMeshIO::Pointer vtkMeshIO = itk::VTKPolyDataMeshIO::New(); + const itk::VTKPolyDataMeshIO::Pointer vtkMeshIO = itk::VTKPolyDataMeshIO::New(); // Ensure that the MeshIO does not claim to read a .vtk file with image // (Structured Grid) data ITK_TEST_EXPECT_EQUAL(vtkMeshIO->CanReadFile(argv[1]), false); diff --git a/Modules/IO/MeshVTK/test/itkVTKPolyDataMeshIOTest.cxx b/Modules/IO/MeshVTK/test/itkVTKPolyDataMeshIOTest.cxx index 394d397baaf..65150405ada 100644 --- a/Modules/IO/MeshVTK/test/itkVTKPolyDataMeshIOTest.cxx +++ b/Modules/IO/MeshVTK/test/itkVTKPolyDataMeshIOTest.cxx @@ -114,11 +114,11 @@ itkVTKPolyDataMeshIOTest(int argc, char * argv[]) // Use sufficiently large buffer sizes - itk::SizeValueType pointBufferSize = 1000; - itk::SizeValueType pointDataBufferSize = 1000; + const itk::SizeValueType pointBufferSize = 1000; + const itk::SizeValueType pointDataBufferSize = 1000; - itk::SizeValueType cellBufferSize = 2000; - itk::SizeValueType cellDataBufferSize = 2000; + const itk::SizeValueType cellBufferSize = 2000; + const itk::SizeValueType cellDataBufferSize = 2000; const std::shared_ptr pointBuffer = itk::MeshIOTestHelper::AllocateBuffer(vtkPolyDataMeshIO->GetPointComponentType(), pointBufferSize); diff --git a/Modules/IO/Meta/src/itkMetaImageIO.cxx b/Modules/IO/Meta/src/itkMetaImageIO.cxx index d695dbdc155..b24f1e1df63 100644 --- a/Modules/IO/Meta/src/itkMetaImageIO.cxx +++ b/Modules/IO/Meta/src/itkMetaImageIO.cxx @@ -83,7 +83,7 @@ bool MetaImageIO::CanReadFile(const char * filename) { // First check the extension - std::string fname = filename; + const std::string fname = filename; if (fname.empty()) { @@ -403,7 +403,7 @@ MetaImageIO::ReadImageInformation() this->SetDirection(ii, directionAxis); } - std::string classname(this->GetNameOfClass()); + const std::string classname(this->GetNameOfClass()); EncapsulateMetaData(thisMetaDict, ITK_InputFilterName, classname); // metaImage has a Modality tag which is not stored as part of its @@ -414,11 +414,11 @@ MetaImageIO::ReadImageInformation() // // save the metadatadictionary in the MetaImage header. // NOTE: The MetaIO library only supports typeless strings as metadata - int dictFields = m_MetaImage.GetNumberOfAdditionalReadFields(); + const int dictFields = m_MetaImage.GetNumberOfAdditionalReadFields(); for (int f = 0; f < dictFields; ++f) { - std::string key(m_MetaImage.GetAdditionalReadFieldName(f)); - std::string value(m_MetaImage.GetAdditionalReadFieldValue(f)); + const std::string key(m_MetaImage.GetAdditionalReadFieldName(f)); + const std::string value(m_MetaImage.GetAdditionalReadFieldValue(f)); EncapsulateMetaData(thisMetaDict, key, value); } @@ -683,7 +683,7 @@ MetaImageIO::Write(const void * buffer) binaryData = false; } - int nChannels = this->GetNumberOfComponents(); + const int nChannels = this->GetNumberOfComponents(); MET_ValueEnumType eType = MET_OTHER; switch (m_ComponentType) @@ -818,7 +818,7 @@ MetaImageIO::Write(const void * buffer) dir[ii][1] = diry[ii]; dir[ii][2] = dirz[ii]; } - AnatomicalOrientation coordOrient(dir); + const AnatomicalOrientation coordOrient(dir); // Mapping from DICOM CoordinateEnum defined as the increasing direction to // the MetaIO enum which has from/to orientation defined. @@ -953,8 +953,8 @@ MetaImageIO::GetActualNumberOfSplitsForWriting(unsigned int numberOfReq // we are going to be pasting (may be streaming too) // need to check to see if the file is compatible - std::string errorMessage; - Pointer headerImageIOReader = Self::New(); + std::string errorMessage; + const Pointer headerImageIOReader = Self::New(); try { diff --git a/Modules/IO/Meta/test/itkLargeMetaImageWriteReadTest.cxx b/Modules/IO/Meta/test/itkLargeMetaImageWriteReadTest.cxx index 98ab311a08f..5c3fdd83103 100644 --- a/Modules/IO/Meta/test/itkLargeMetaImageWriteReadTest.cxx +++ b/Modules/IO/Meta/test/itkLargeMetaImageWriteReadTest.cxx @@ -43,9 +43,9 @@ ActualTest(std::string filename, typename TImageType::SizeType size) using ConstIteratorType = itk::ImageRegionConstIterator; - typename ImageType::IndexType index{}; - typename ImageType::RegionType region{ index, size }; - itk::TimeProbesCollectorBase chronometer; + const typename ImageType::IndexType index{}; + const typename ImageType::RegionType region{ index, size }; + itk::TimeProbesCollectorBase chronometer; { // begin write block auto image = ImageType::New(); @@ -101,7 +101,7 @@ ActualTest(std::string filename, typename TImageType::SizeType size) auto reader = ReaderType::New(); reader->SetFileName(filename); - itk::MetaImageIO::Pointer io = itk::MetaImageIO::New(); + const itk::MetaImageIO::Pointer io = itk::MetaImageIO::New(); reader->SetImageIO(io); try @@ -116,7 +116,7 @@ ActualTest(std::string filename, typename TImageType::SizeType size) return EXIT_FAILURE; } - typename ImageType::ConstPointer readImage = reader->GetOutput(); + const typename ImageType::ConstPointer readImage = reader->GetOutput(); std::cout << "Comparing the pixel values..." << std::endl; diff --git a/Modules/IO/Meta/test/itkMetaImageIOGzTest.cxx b/Modules/IO/Meta/test/itkMetaImageIOGzTest.cxx index 6e147296b73..8ff6727b09d 100644 --- a/Modules/IO/Meta/test/itkMetaImageIOGzTest.cxx +++ b/Modules/IO/Meta/test/itkMetaImageIOGzTest.cxx @@ -60,10 +60,10 @@ itkMetaImageIOGzTest(int argc, char * argv[]) using PixelType = unsigned short; using myImage = itk::Image; - itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); reader->SetFileName(headerName.c_str()); - itk::MetaImageIO::Pointer io = itk::MetaImageIO::New(); + const itk::MetaImageIO::Pointer io = itk::MetaImageIO::New(); reader->SetImageIO(io); try diff --git a/Modules/IO/Meta/test/itkMetaImageIOMetaDataTest.cxx b/Modules/IO/Meta/test/itkMetaImageIOMetaDataTest.cxx index 356a128b13a..88f4f96ba3c 100644 --- a/Modules/IO/Meta/test/itkMetaImageIOMetaDataTest.cxx +++ b/Modules/IO/Meta/test/itkMetaImageIOMetaDataTest.cxx @@ -36,7 +36,7 @@ ReadImage(const std::string & fileName) auto reader = ReaderType::New(); reader->SetFileName(fileName.c_str()); - itk::MetaImageIO::Pointer io = itk::MetaImageIO::New(); + const itk::MetaImageIO::Pointer io = itk::MetaImageIO::New(); reader->SetImageIO(io); try @@ -68,7 +68,7 @@ WriteImage(typename ImageType::Pointer & image, const std::string & fileName) writer->SetFileName(fileName.c_str()); - itk::MetaImageIO::Pointer io = itk::MetaImageIO::New(); + const itk::MetaImageIO::Pointer io = itk::MetaImageIO::New(); writer->SetImageIO(io); writer->SetInput(image); @@ -176,8 +176,8 @@ itkMetaImageIOMetaDataTest(int argc, char * argv[]) // { // Add string key - std::string key("hello"); - std::string value("world"); + const std::string key("hello"); + const std::string value("world"); itk::EncapsulateMetaData(dict, key, value); } @@ -192,73 +192,73 @@ itkMetaImageIOMetaDataTest(int argc, char * argv[]) } { // Add double - std::string key("double"); - double value(7.891011); + const std::string key("double"); + const double value(7.891011); itk::EncapsulateMetaData(dict, key, value); } { // Add float - std::string key("float"); - float value(1.23456); + const std::string key("float"); + const float value(1.23456); itk::EncapsulateMetaData(dict, key, value); } { // Add long - std::string key("long"); - long value(-31415926); + const std::string key("long"); + const long value(-31415926); itk::EncapsulateMetaData(dict, key, value); } { // Add unsigned long - std::string key("unsigned_long"); - unsigned long value(27182818); + const std::string key("unsigned_long"); + const unsigned long value(27182818); itk::EncapsulateMetaData(dict, key, value); } { // Add long long - std::string key("long_long"); - long long value(-8589934592ll); + const std::string key("long_long"); + const long long value(-8589934592ll); itk::EncapsulateMetaData(dict, key, value); } { // Add unsigned long long - std::string key("unsigned_long_long"); - unsigned long long value(8589934592ull); + const std::string key("unsigned_long_long"); + const unsigned long long value(8589934592ull); itk::EncapsulateMetaData(dict, key, value); } { // Add int - std::string key("int"); - int value(-3141592); + const std::string key("int"); + const int value(-3141592); itk::EncapsulateMetaData(dict, key, value); } { // Add unsigned int - std::string key("unsigned_int"); - unsigned int value(2718281); + const std::string key("unsigned_int"); + const unsigned int value(2718281); itk::EncapsulateMetaData(dict, key, value); } { // Add short - std::string key("short"); - short value(-16384); + const std::string key("short"); + const short value(-16384); itk::EncapsulateMetaData(dict, key, value); } { // Add short - std::string key("unsigned_short"); - unsigned int value(8192); + const std::string key("unsigned_short"); + const unsigned int value(8192); itk::EncapsulateMetaData(dict, key, value); } { // Add char - std::string key("char"); - char value('c'); + const std::string key("char"); + const char value('c'); itk::EncapsulateMetaData(dict, key, value); } { - std::string key("bool"); - bool value(true); + const std::string key("bool"); + const bool value(true); itk::EncapsulateMetaData(dict, key, value); } @@ -267,11 +267,11 @@ itkMetaImageIOMetaDataTest(int argc, char * argv[]) // // Read the image just written and check if the key we added // persisted with the file. - ImageType::Pointer randImage2 = ReadImage(argv[1]); + const ImageType::Pointer randImage2 = ReadImage(argv[1]); dict = randImage2->GetMetaDataDictionary(); - std::string value("world"); + const std::string value("world"); if (!TestMatch(dict, "hello", value)) { return 1; // error diff --git a/Modules/IO/Meta/test/itkMetaImageIOTest.cxx b/Modules/IO/Meta/test/itkMetaImageIOTest.cxx index e637deaf620..126dd030ef9 100644 --- a/Modules/IO/Meta/test/itkMetaImageIOTest.cxx +++ b/Modules/IO/Meta/test/itkMetaImageIOTest.cxx @@ -41,7 +41,7 @@ itkMetaImageIOTest(int argc, char * argv[]) using PixelType = unsigned short; using myImage = itk::Image; - itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); // Force use of MetaIO using IOType = itk::MetaImageIO; @@ -61,8 +61,8 @@ itkMetaImageIOTest(int argc, char * argv[]) } // Test subsampling factor (change it then change it back) - unsigned int origSubSamplingFactor = metaIn->GetSubSamplingFactor(); - unsigned int subSamplingFactor = 2; + const unsigned int origSubSamplingFactor = metaIn->GetSubSamplingFactor(); + const unsigned int subSamplingFactor = 2; metaIn->SetSubSamplingFactor(subSamplingFactor); ITK_TEST_SET_GET_VALUE(subSamplingFactor, metaIn->GetSubSamplingFactor()); @@ -87,13 +87,13 @@ itkMetaImageIOTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); } - myImage::Pointer image = reader->GetOutput(); + const myImage::Pointer image = reader->GetOutput(); image->Print(std::cout); // MetaImage is expected to have a modality tag image->GetMetaDataDictionary().Get("Modality"); - myImage::RegionType region = image->GetLargestPossibleRegion(); + const myImage::RegionType region = image->GetLargestPossibleRegion(); std::cout << "region " << region; // Generate test image diff --git a/Modules/IO/Meta/test/itkMetaImageIOTest2.cxx b/Modules/IO/Meta/test/itkMetaImageIOTest2.cxx index abadf4799f9..63993f0b076 100644 --- a/Modules/IO/Meta/test/itkMetaImageIOTest2.cxx +++ b/Modules/IO/Meta/test/itkMetaImageIOTest2.cxx @@ -39,8 +39,8 @@ TestUnknowMetaDataBug(const std::string & fname) using PixelType = unsigned short; using ImageType = itk::Image; - ImageType::RegionType region; - ImageType::SizeType size = { { 32, 32 } }; + ImageType::RegionType region; + const ImageType::SizeType size = { { 32, 32 } }; region.SetSize(size); auto image = ImageType::New(); @@ -60,7 +60,7 @@ TestUnknowMetaDataBug(const std::string & fname) hasher->InPlaceOff(); hasher->Update(); - std::string originalHash = hasher->GetHash(); + const std::string originalHash = hasher->GetHash(); std::cout << "\tOriginal image hash: " << originalHash << std::endl; @@ -78,7 +78,7 @@ TestUnknowMetaDataBug(const std::string & fname) hasher->SetInput(reader->GetOutput()); hasher->Update(); - std::string readHash = hasher->GetHash(); + const std::string readHash = hasher->GetHash(); std::cout << "\tRead hash: " << readHash << std::endl; ITK_TEST_EXPECT_EQUAL(originalHash, readHash); diff --git a/Modules/IO/Meta/test/itkMetaImageStreamingWriterIOTest.cxx b/Modules/IO/Meta/test/itkMetaImageStreamingWriterIOTest.cxx index 5f102864e2b..aab9c4c08cb 100644 --- a/Modules/IO/Meta/test/itkMetaImageStreamingWriterIOTest.cxx +++ b/Modules/IO/Meta/test/itkMetaImageStreamingWriterIOTest.cxx @@ -38,7 +38,7 @@ itkMetaImageStreamingWriterIOTest(int argc, char * argv[]) using PixelType = unsigned char; using ImageType = itk::Image; - itk::MetaImageIO::Pointer metaImageIO = itk::MetaImageIO::New(); + const itk::MetaImageIO::Pointer metaImageIO = itk::MetaImageIO::New(); using ReaderType = itk::ImageFileReader; using WriterType = itk::ImageFileWriter; @@ -64,7 +64,7 @@ itkMetaImageStreamingWriterIOTest(int argc, char * argv[]) size[2] = 0; numberOfPieces = std::min(numberOfPieces, fullsize[2]); - unsigned int zsize = fullsize[2] / numberOfPieces; + const unsigned int zsize = fullsize[2] / numberOfPieces; // Setup the writer auto writer = WriterType::New(); @@ -87,7 +87,7 @@ itkMetaImageStreamingWriterIOTest(int argc, char * argv[]) size[2] = zsize; } - ImageType::RegionType region{ index, size }; + const ImageType::RegionType region{ index, size }; reader->GetOutput()->SetRequestedRegion(region); @@ -113,7 +113,6 @@ itkMetaImageStreamingWriterIOTest(int argc, char * argv[]) index2.push_back(index[2]); itk::ImageIORegion::SizeType size2; - size2.push_back(size[0]); size2.push_back(size[1]); size2.push_back(size[2]); diff --git a/Modules/IO/Meta/test/itkMetaTestLongFilename.cxx b/Modules/IO/Meta/test/itkMetaTestLongFilename.cxx index 49e2ba856bb..6ea0abcefaf 100644 --- a/Modules/IO/Meta/test/itkMetaTestLongFilename.cxx +++ b/Modules/IO/Meta/test/itkMetaTestLongFilename.cxx @@ -20,7 +20,7 @@ int itkMetaTestLongFilename(int, char *[]) { - itk::MetaImageIO::Pointer metaImageIO = itk::MetaImageIO::New(); + const itk::MetaImageIO::Pointer metaImageIO = itk::MetaImageIO::New(); // test if a very long filename // crashes in the metaIO library const char * doublePlusLongFilename = "01234597890123459789012345978901234597890123459789" diff --git a/Modules/IO/Meta/test/testMetaArray.cxx b/Modules/IO/Meta/test/testMetaArray.cxx index 01401ed3c0c..b9985e795a4 100644 --- a/Modules/IO/Meta/test/testMetaArray.cxx +++ b/Modules/IO/Meta/test/testMetaArray.cxx @@ -40,7 +40,7 @@ testMetaArray(int argc, char * argv[]) arr[4] = 1; // Write them - itk::MetaArrayWriter::Pointer arrayWriter = itk::MetaArrayWriter::New(); + const itk::MetaArrayWriter::Pointer arrayWriter = itk::MetaArrayWriter::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(arrayWriter, MetaArrayWriter, LightProcessObject); @@ -128,8 +128,8 @@ testMetaArray(int argc, char * argv[]) // Read them std::cout << "Read VariableLengthVector short" << std::endl; - itk::VariableLengthVector rvecs; - itk::MetaArrayReader::Pointer arrayReader = itk::MetaArrayReader::New(); + itk::VariableLengthVector rvecs; + const itk::MetaArrayReader::Pointer arrayReader = itk::MetaArrayReader::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(arrayReader, MetaArrayReader, LightProcessObject); diff --git a/Modules/IO/Meta/test/testMetaGroup.cxx b/Modules/IO/Meta/test/testMetaGroup.cxx index cc1a041208a..0f6d969b312 100644 --- a/Modules/IO/Meta/test/testMetaGroup.cxx +++ b/Modules/IO/Meta/test/testMetaGroup.cxx @@ -39,13 +39,13 @@ testMetaGroup(int argc, char * argv[]) std::cout << " [PASSED] " << std::endl; std::cout << "Testing Reading:"; - MetaGroup groupLoad("group.meta"); + const MetaGroup groupLoad("group.meta"); std::cout << " [PASSED] " << std::endl; groupLoad.PrintInfo(); std::cout << "Testing Copy:"; - MetaGroup groupCopy(&groupLoad); + const MetaGroup groupCopy(&groupLoad); std::cout << " [PASSED] " << std::endl; groupCopy.PrintInfo(); diff --git a/Modules/IO/Meta/test/testMetaImage.cxx b/Modules/IO/Meta/test/testMetaImage.cxx index 5f4460795f9..6e52671bcda 100644 --- a/Modules/IO/Meta/test/testMetaImage.cxx +++ b/Modules/IO/Meta/test/testMetaImage.cxx @@ -49,8 +49,9 @@ ReadWriteCompare(PixelType value, std::string type) origin[ii] = 3.2; size[ii] = 10; } - typename ImageType::RegionType region(size); - typename ImageType::Pointer img = itk::IOTestHelper::AllocateImageFromRegionAndSpacing(region, spacing); + const typename ImageType::RegionType region(size); + const typename ImageType::Pointer img = + itk::IOTestHelper::AllocateImageFromRegionAndSpacing(region, spacing); { // Fill in entire image itk::ImageRegionIterator ri(img, region); try @@ -99,7 +100,7 @@ ReadWriteCompare(PixelType value, std::string type) // Now compare the two images using DiffType = itk::Testing::ComparisonImageFilter; - typename DiffType::Pointer diff = DiffType::New(); + const typename DiffType::Pointer diff = DiffType::New(); diff->SetValidInput(img); diff->SetTestInput(input); diff->SetDifferenceThreshold(itk::NumericTraits::Zero); @@ -119,8 +120,8 @@ int testMetaImage(int, char *[]) { - MetaImage tIm(8, 8, 1, 2, MET_CHAR); - MetaImage tImCopy(&tIm); + MetaImage tIm(8, 8, 1, 2, MET_CHAR); + const MetaImage tImCopy(&tIm); for (int i = 0; i < 64; ++i) tIm.ElementData(i, i); @@ -216,7 +217,7 @@ testMetaImage(int, char *[]) // Testing copy std::cout << "Testing copy:"; - MetaImage imCopy(&tIm2); + const MetaImage imCopy(&tIm2); std::cout << " [PASSED]" << std::endl; diff --git a/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx b/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx index aaa94c1571c..11899966013 100644 --- a/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx +++ b/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx @@ -505,7 +505,7 @@ template void ConvertRASToFromLPS_CXYZT(TBuffer * buffer, size_t size) { - size_t numberOfVectors = size / 3; + const size_t numberOfVectors = size / 3; for (size_t i = 0; i < numberOfVectors; ++i) { buffer[0] *= -1; @@ -522,7 +522,7 @@ ConvertRASToFromLPS_XYZTC(TBuffer * buffer, size_t size) { // Flip the sign of the first two components (L<->R, P<->A) // and keep the third component (S) unchanged. - size_t numberOfComponents = size / 3 * 2; + const size_t numberOfComponents = size / 3 * 2; for (size_t i = 0; i < numberOfComponents; ++i) { buffer[i] *= -1; @@ -535,7 +535,7 @@ NiftiImageIO::Read(void * buffer) { void * data = nullptr; - ImageIORegion regionToRead = this->GetIORegion(); + const ImageIORegion regionToRead = this->GetIORegion(); ImageIORegion::SizeType size = regionToRead.GetSize(); ImageIORegion::IndexType start = regionToRead.GetIndex(); @@ -1340,8 +1340,8 @@ NiftiImageIO::ReadImageInformation() break; } // see http://www.grahamwideman.com/gw/brain/analyze/formatdoc.htm - bool ignore_negative_pixdim = this->m_NiftiImage->nifti_type == 0 && - this->GetLegacyAnalyze75Mode() == NiftiImageIOEnums::Analyze75Flavor::AnalyzeFSL; + const bool ignore_negative_pixdim = this->m_NiftiImage->nifti_type == 0 && + this->GetLegacyAnalyze75Mode() == NiftiImageIOEnums::Analyze75Flavor::AnalyzeFSL; const int dims = this->GetNumberOfDimensions(); switch (dims) @@ -1565,7 +1565,7 @@ NiftiImageIO::WriteImageInformation() } const unsigned int numComponents = this->GetNumberOfComponents(); - MetaDataDictionary & thisDic = this->GetMetaDataDictionary(); + const MetaDataDictionary & thisDic = this->GetMetaDataDictionary(); // TODO: Also need to check for RGB images where numComponets=3 if (numComponents > 1 && !(this->GetPixelType() == IOPixelEnum::COMPLEX && numComponents == 2) && @@ -1805,7 +1805,7 @@ Normalize(std::vector & x) { double sum = 0.0; - for (double i : x) + for (const double i : x) { sum += (i * i); } @@ -1964,8 +1964,8 @@ NiftiImageIO::SetImageIOOrientationFromNIfTI(unsigned short dims, double spacing // the 4x4 single precision sform fields, and that original representation // is converted (with lossy conversion) into the qform representation. const bool qform_sform_are_similar = [=]() -> bool { - vnl_matrix_fixed sto_xyz{ &(this->m_NiftiImage->sto_xyz.m[0][0]) }; - vnl_matrix_fixed qto_xyz{ &(this->m_NiftiImage->qto_xyz.m[0][0]) }; + const vnl_matrix_fixed sto_xyz{ &(this->m_NiftiImage->sto_xyz.m[0][0]) }; + const vnl_matrix_fixed qto_xyz{ &(this->m_NiftiImage->qto_xyz.m[0][0]) }; // First check rotation matrix components to ensure that they are similar; const auto srotation_scale = sto_xyz.extract(3, 3, 0, 0); @@ -2366,7 +2366,7 @@ NiftiImageIO::SetNIfTIOrientationFromImageIO(unsigned short origdims, unsigned s this->m_NiftiImage->sto_xyz = matrix; // // - unsigned int sto_limit = origdims > 3 ? 3 : origdims; + const unsigned int sto_limit = origdims > 3 ? 3 : origdims; for (unsigned int ii = 0; ii < sto_limit; ++ii) { for (unsigned int jj = 0; jj < sto_limit; ++jj) diff --git a/Modules/IO/NIFTI/test/itkExtractSlice.cxx b/Modules/IO/NIFTI/test/itkExtractSlice.cxx index 70c4fc2ba47..788deba8e98 100644 --- a/Modules/IO/NIFTI/test/itkExtractSlice.cxx +++ b/Modules/IO/NIFTI/test/itkExtractSlice.cxx @@ -44,7 +44,7 @@ itkExtractSlice(int argc, char * argv[]) reader->SetFileName(argv[1]); reader->UpdateOutputInformation(); - ImageType::RegionType inRegion = reader->GetOutput()->GetLargestPossibleRegion(); + const ImageType::RegionType inRegion = reader->GetOutput()->GetLargestPossibleRegion(); ImageType::SizeType outSize = inRegion.GetSize(); outSize[1] = 0; diff --git a/Modules/IO/NIFTI/test/itkNiftiImageIOTest.cxx b/Modules/IO/NIFTI/test/itkNiftiImageIOTest.cxx index 7213e2819eb..a02773efc0a 100644 --- a/Modules/IO/NIFTI/test/itkNiftiImageIOTest.cxx +++ b/Modules/IO/NIFTI/test/itkNiftiImageIOTest.cxx @@ -124,8 +124,8 @@ itkNiftiImageIOTest(int argc, char * argv[]) if (argc > 1) // This is a mechanism for reading unsigned char images for testing. { using ImageType = itk::Image; - ImageType::Pointer input; - itk::NiftiImageIO::Pointer imageIO = itk::NiftiImageIO::New(); + ImageType::Pointer input; + const itk::NiftiImageIO::Pointer imageIO = itk::NiftiImageIO::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(imageIO, NiftiImageIO, ImageIOBase); @@ -139,7 +139,7 @@ itkNiftiImageIOTest(int argc, char * argv[]) // The way the test is structured, we cannot know the expected file // type, so just print it - typename itk::NiftiImageIOEnums::NiftiFileEnum fileType = imageIO->DetermineFileType(fileName.c_str()); + const typename itk::NiftiImageIOEnums::NiftiFileEnum fileType = imageIO->DetermineFileType(fileName.c_str()); std::cout << "File type: " << fileType << std::endl; try @@ -233,7 +233,7 @@ itkNiftiImageIOTest(int argc, char * argv[]) } // Tests added to increase code coverage. { - itk::NiftiImageIOFactory::Pointer MyFactoryTest = itk::NiftiImageIOFactory::New(); + const itk::NiftiImageIOFactory::Pointer MyFactoryTest = itk::NiftiImageIOFactory::New(); if (MyFactoryTest.IsNull()) { return EXIT_FAILURE; diff --git a/Modules/IO/NIFTI/test/itkNiftiImageIOTest.h b/Modules/IO/NIFTI/test/itkNiftiImageIOTest.h index 813a11835f6..0360d45dfc9 100644 --- a/Modules/IO/NIFTI/test/itkNiftiImageIOTest.h +++ b/Modules/IO/NIFTI/test/itkNiftiImageIOTest.h @@ -72,10 +72,11 @@ MakeNiftiImage(const char * filename) const typename ImageType::SizeType size = { { 10, 10, 10 } }; auto spacing = itk::MakeFilled(1.0); - const typename ImageType::IndexType index = { { 0, 0, 0 } }; - typename ImageType::RegionType region(index, size); + const typename ImageType::IndexType index = { { 0, 0, 0 } }; + const typename ImageType::RegionType region(index, size); { - typename ImageType::Pointer img = itk::IOTestHelper::AllocateImageFromRegionAndSpacing(region, spacing); + const typename ImageType::Pointer img = + itk::IOTestHelper::AllocateImageFromRegionAndSpacing(region, spacing); { // Fill in entire image itk::ImageRegionIterator ri(img, region); @@ -95,10 +96,10 @@ MakeNiftiImage(const char * filename) } { // Fill in left half - const typename ImageType::IndexType RPIindex = { { 0, 0, 0 } }; - const typename ImageType::SizeType RPIsize = { { 5, 10, 10 } }; - typename ImageType::RegionType RPIregion = typename ImageType::RegionType(RPIindex, RPIsize); - itk::ImageRegionIterator RPIiterator = itk::ImageRegionIterator(img, RPIregion); + const typename ImageType::IndexType RPIindex = { { 0, 0, 0 } }; + const typename ImageType::SizeType RPIsize = { { 5, 10, 10 } }; + const typename ImageType::RegionType RPIregion = typename ImageType::RegionType(RPIindex, RPIsize); + itk::ImageRegionIterator RPIiterator = itk::ImageRegionIterator(img, RPIregion); while (!RPIiterator.IsAtEnd()) { RPIiterator.Set(RPIiterator.Get() + LEFT); @@ -106,10 +107,10 @@ MakeNiftiImage(const char * filename) } } { // Fill in anterior half - const typename ImageType::IndexType RPIindex = { { 0, 5, 0 } }; - const typename ImageType::SizeType RPIsize = { { 10, 5, 10 } }; - typename ImageType::RegionType RPIregion = typename ImageType::RegionType(RPIindex, RPIsize); - itk::ImageRegionIterator RPIiterator = itk::ImageRegionIterator(img, RPIregion); + const typename ImageType::IndexType RPIindex = { { 0, 5, 0 } }; + const typename ImageType::SizeType RPIsize = { { 10, 5, 10 } }; + const typename ImageType::RegionType RPIregion = typename ImageType::RegionType(RPIindex, RPIsize); + itk::ImageRegionIterator RPIiterator = itk::ImageRegionIterator(img, RPIregion); while (!RPIiterator.IsAtEnd()) { RPIiterator.Set(RPIiterator.Get() + ANTERIOR); @@ -117,10 +118,10 @@ MakeNiftiImage(const char * filename) } } { // Fill in superior half - const typename ImageType::IndexType RPIindex = { { 0, 0, 5 } }; - const typename ImageType::SizeType RPIsize = { { 10, 10, 5 } }; - typename ImageType::RegionType RPIregion = typename ImageType::RegionType(RPIindex, RPIsize); - itk::ImageRegionIterator RPIiterator = itk::ImageRegionIterator(img, RPIregion); + const typename ImageType::IndexType RPIindex = { { 0, 0, 5 } }; + const typename ImageType::SizeType RPIsize = { { 10, 10, 5 } }; + const typename ImageType::RegionType RPIregion = typename ImageType::RegionType(RPIindex, RPIsize); + itk::ImageRegionIterator RPIiterator = itk::ImageRegionIterator(img, RPIregion); while (!RPIiterator.IsAtEnd()) { RPIiterator.Set(RPIiterator.Get() + SUPERIOR); @@ -179,9 +180,9 @@ MakeNiftiImage(const char * filename) try { - typename ImageType::Pointer input = itk::IOTestHelper::ReadImage(std::string(filename)); + const typename ImageType::Pointer input = itk::IOTestHelper::ReadImage(std::string(filename)); // Get the sform and qform codes from the image - itk::MetaDataDictionary & thisDic = input->GetMetaDataDictionary(); + const itk::MetaDataDictionary & thisDic = input->GetMetaDataDictionary(); // std::cout << "DICTIONARY:\n" << std::endl; // thisDic.Print( std::cout ); std::string qform_temp = ""; @@ -290,7 +291,7 @@ TestImageOfSymMats(const std::string & fname) typename DtiImageType::RegionType imageRegion; imageRegion.SetSize(size); imageRegion.SetIndex(index); - typename DtiImageType::Pointer vi = + const typename DtiImageType::Pointer vi = itk::IOTestHelper::AllocateImageFromRegionAndSpacing(imageRegion, spacing); vi->SetOrigin(origin); vi->SetDirection(myDirection); @@ -494,7 +495,7 @@ RGBTest(int argc, char * argv[]) typename RGBImageType::RegionType imageRegion; imageRegion.SetSize(size); imageRegion.SetIndex(index); - typename RGBImageType::Pointer im = + const typename RGBImageType::Pointer im = itk::IOTestHelper::AllocateImageFromRegionAndSpacing(imageRegion, spacing); vnl_random randgen(12345678); itk::ImageRegionIterator it(im, im->GetLargestPossibleRegion()); diff --git a/Modules/IO/NIFTI/test/itkNiftiImageIOTest11.cxx b/Modules/IO/NIFTI/test/itkNiftiImageIOTest11.cxx index 2944c5fd2ac..037d7f48d0d 100644 --- a/Modules/IO/NIFTI/test/itkNiftiImageIOTest11.cxx +++ b/Modules/IO/NIFTI/test/itkNiftiImageIOTest11.cxx @@ -49,10 +49,10 @@ itkNiftiImageIOTest11(int argc, char * argv[]) size[1] = 1; size[2] = 1; - ImageType::IndexType index{}; - auto spacing = itk::MakeFilled(1.0); + const ImageType::IndexType index{}; + auto spacing = itk::MakeFilled(1.0); - ImageType::RegionType imageRegion{ index, size }; + const ImageType::RegionType imageRegion{ index, size }; const ImageType::Pointer im = itk::IOTestHelper::AllocateImageFromRegionAndSpacing(imageRegion, spacing); const ImageType::DirectionType dir(CORDirCosines()); std::cout << "itkNiftiImageIOTest11" << std::endl; diff --git a/Modules/IO/NIFTI/test/itkNiftiImageIOTest12.cxx b/Modules/IO/NIFTI/test/itkNiftiImageIOTest12.cxx index a377ff7f8af..7ad4ef78573 100644 --- a/Modules/IO/NIFTI/test/itkNiftiImageIOTest12.cxx +++ b/Modules/IO/NIFTI/test/itkNiftiImageIOTest12.cxx @@ -45,12 +45,12 @@ itkNiftiImageIOTest12(int argc, char * argv[]) // test is too slow with large image ImageType::SizeType size = { { 2024, 1024, 1024 } }; // make small RGB Image - ImageType::SizeType size = { { 24, 10, 11 } }; + const ImageType::SizeType size = { { 24, 10, 11 } }; region.SetSize(size); #if 0 // using non-zero start index exposes bug in ITK IO physical space preservation ImageType::IndexType startIndex = { { 200, 300, 400 } }; #else - ImageType::IndexType startIndex = { { 0, 0, 0 } }; + const ImageType::IndexType startIndex = { { 0, 0, 0 } }; #endif region.SetIndex(startIndex); @@ -94,15 +94,15 @@ itkNiftiImageIOTest12(int argc, char * argv[]) { itk::IOTestHelper::WriteImage(image, imgfilename); - ImageType::Pointer readImage = itk::IOTestHelper::ReadImage(imgfilename); + const ImageType::Pointer readImage = itk::IOTestHelper::ReadImage(imgfilename); const std::string readHash = myHasher(readImage); std::cout << "Read hash: " << readHash << std::endl; ITK_TEST_EXPECT_EQUAL(originalHash, readHash); - ImageType::IndexType threeIndex = { { 3, 3, 3 } }; - ImageType::PointType origPhysLocationIndexThree; + const ImageType::IndexType threeIndex = { { 3, 3, 3 } }; + ImageType::PointType origPhysLocationIndexThree; image->TransformIndexToPhysicalPoint(threeIndex, origPhysLocationIndexThree); ImageType::PointType readPhysLocationIndexThree; readImage->TransformIndexToPhysicalPoint(threeIndex, readPhysLocationIndexThree); diff --git a/Modules/IO/NIFTI/test/itkNiftiImageIOTest14.cxx b/Modules/IO/NIFTI/test/itkNiftiImageIOTest14.cxx index 84695ce3951..63f5e73c81c 100644 --- a/Modules/IO/NIFTI/test/itkNiftiImageIOTest14.cxx +++ b/Modules/IO/NIFTI/test/itkNiftiImageIOTest14.cxx @@ -106,10 +106,10 @@ itkNiftiImageIOTest14(int argc, char * argv[]) try { // read the image back in - ImageType::Pointer image_from_disk = itk::IOTestHelper::ReadImage(output_test_fn); + const ImageType::Pointer image_from_disk = itk::IOTestHelper::ReadImage(output_test_fn); // check the metadata for xyzt_units and toffset - itk::MetaDataDictionary & dictionary = image_from_disk->GetMetaDataDictionary(); + const itk::MetaDataDictionary & dictionary = image_from_disk->GetMetaDataDictionary(); std::string toffset; if (!itk::ExposeMetaData(dictionary, "toffset", toffset)) diff --git a/Modules/IO/NIFTI/test/itkNiftiImageIOTest2.cxx b/Modules/IO/NIFTI/test/itkNiftiImageIOTest2.cxx index 00d3031852e..80e8ee1f8e7 100644 --- a/Modules/IO/NIFTI/test/itkNiftiImageIOTest2.cxx +++ b/Modules/IO/NIFTI/test/itkNiftiImageIOTest2.cxx @@ -50,8 +50,8 @@ itkNiftiImageIOTest2(int argc, char * argv[]) try { using ImageReaderType = itk::ImageFileReader; - itk::NiftiImageIO::Pointer io = itk::NiftiImageIO::New(); - auto imageReader = ImageReaderType::New(); + const itk::NiftiImageIO::Pointer io = itk::NiftiImageIO::New(); + auto imageReader = ImageReaderType::New(); imageReader->SetImageIO(io); imageReader->SetFileName(arg2); imageReader->Update(); diff --git a/Modules/IO/NIFTI/test/itkNiftiImageIOTest3.cxx b/Modules/IO/NIFTI/test/itkNiftiImageIOTest3.cxx index f697c3e0322..ebf4ab57cb0 100644 --- a/Modules/IO/NIFTI/test/itkNiftiImageIOTest3.cxx +++ b/Modules/IO/NIFTI/test/itkNiftiImageIOTest3.cxx @@ -70,14 +70,14 @@ TestImageOfVectors(const std::string & fname, const std::string & intentCode = " std::cout << "======================== Initialized Direction" << std::endl; std::cout << myDirection << std::endl; - auto size = itk::MakeFilled(dimsize); - auto spacing = itk::MakeFilled(1.0); - typename VectorImageType::IndexType index{}; - typename VectorImageType::PointType origin{}; - typename VectorImageType::RegionType imageRegion; + auto size = itk::MakeFilled(dimsize); + auto spacing = itk::MakeFilled(1.0); + typename VectorImageType::IndexType index{}; + const typename VectorImageType::PointType origin{}; + typename VectorImageType::RegionType imageRegion; imageRegion.SetSize(size); imageRegion.SetIndex(index); - typename VectorImageType::Pointer vi = + const typename VectorImageType::Pointer vi = itk::IOTestHelper::AllocateImageFromRegionAndSpacing(imageRegion, spacing); vi->SetOrigin(origin); vi->SetDirection(myDirection); @@ -140,7 +140,7 @@ TestImageOfVectors(const std::string & fname, const std::string & intentCode = " itk::MetaDataDictionary & dictionary = vi->GetMetaDataDictionary(); itk::EncapsulateMetaData(dictionary, "intent_code", intentCode); } - std::string description("text description of file content"); + const std::string description("text description of file content"); itk::EncapsulateMetaData(vi->GetMetaDataDictionary(), "ITK_FileNotes", description); try { @@ -259,8 +259,8 @@ TestImageOfVectors(const std::string & fname, const std::string & intentCode = " { index[q] = _index[q]; } - FieldPixelType p1 = vi->GetPixel(index); - FieldPixelType p2 = readback->GetPixel(index); + const FieldPixelType p1 = vi->GetPixel(index); + const FieldPixelType p2 = readback->GetPixel(index); if (p1 != p2) { same = false; diff --git a/Modules/IO/NIFTI/test/itkNiftiImageIOTest4.cxx b/Modules/IO/NIFTI/test/itkNiftiImageIOTest4.cxx index 8cdf3a9c937..66b2f0f0b04 100644 --- a/Modules/IO/NIFTI/test/itkNiftiImageIOTest4.cxx +++ b/Modules/IO/NIFTI/test/itkNiftiImageIOTest4.cxx @@ -65,7 +65,7 @@ itkNiftiImageIOTest4(int argc, char * argv[]) imageRegion.SetSize(size); imageRegion.SetIndex(index); - Test4ImageType::Pointer test4Image = + const Test4ImageType::Pointer test4Image = itk::IOTestHelper::AllocateImageFromRegionAndSpacing(imageRegion, spacing); test4Image->FillBuffer(0); @@ -103,7 +103,7 @@ itkNiftiImageIOTest4(int argc, char * argv[]) } test4Image->SetDirection(dir); - std::string fname("directionsTest.nii.gz"); + const std::string fname("directionsTest.nii.gz"); try { itk::IOTestHelper::WriteImage(test4Image, fname); diff --git a/Modules/IO/NIFTI/test/itkNiftiImageIOTest5.cxx b/Modules/IO/NIFTI/test/itkNiftiImageIOTest5.cxx index 70650e50787..b46766efb4e 100644 --- a/Modules/IO/NIFTI/test/itkNiftiImageIOTest5.cxx +++ b/Modules/IO/NIFTI/test/itkNiftiImageIOTest5.cxx @@ -121,7 +121,7 @@ SlopeInterceptTest() if (!Equal(it.Value(), static_cast(i) / 256.0)) { // return EXIT_FAILURE; - double error = itk::Math::abs(it.Value() - (static_cast(i) / 256.0)); + const double error = itk::Math::abs(it.Value() - (static_cast(i) / 256.0)); if (error > maxerror) { maxerror = error; @@ -167,8 +167,8 @@ SlopeInterceptWriteTest() itout.Set(static_cast(i)); } using WriterType = itk::ImageFileWriter; - auto writer = WriterType::New(); - itk::NiftiImageIO::Pointer niftiImageIO(itk::NiftiImageIO::New()); + auto writer = WriterType::New(); + const itk::NiftiImageIO::Pointer niftiImageIO(itk::NiftiImageIO::New()); niftiImageIO->SetRescaleSlope(1.0 / 256.0); niftiImageIO->SetRescaleIntercept(-10.0); writer->SetImageIO(niftiImageIO); @@ -209,7 +209,7 @@ SlopeInterceptWriteTest() if (!Equal(it.Value(), static_cast(i) / 256.0 - 10.0)) { // return EXIT_FAILURE; - double error = itk::Math::abs(it.Value() - (static_cast(i) / 256.0 - 10.0)); + const double error = itk::Math::abs(it.Value() - (static_cast(i) / 256.0 - 10.0)); if (error > maxerror) { maxerror = error; diff --git a/Modules/IO/NIFTI/test/itkNiftiImageIOTest6.cxx b/Modules/IO/NIFTI/test/itkNiftiImageIOTest6.cxx index 5f52f81c6b8..59dc8edb1c0 100644 --- a/Modules/IO/NIFTI/test/itkNiftiImageIOTest6.cxx +++ b/Modules/IO/NIFTI/test/itkNiftiImageIOTest6.cxx @@ -33,11 +33,11 @@ itkNiftiImageIOTest6(int argc, char * argv[]) int success(EXIT_SUCCESS); using VectorImageType = itk::VectorImage; - VectorImageType::RegionType imageRegion; - VectorImageType::SizeType size; - VectorImageType::IndexType index; - VectorImageType::SpacingType spacing; - VectorImageType::VectorLengthType vecLength(4); + VectorImageType::RegionType imageRegion; + VectorImageType::SizeType size; + VectorImageType::IndexType index; + VectorImageType::SpacingType spacing; + const VectorImageType::VectorLengthType vecLength(4); for (unsigned int i = 0; i < 3; ++i) { @@ -47,7 +47,7 @@ itkNiftiImageIOTest6(int argc, char * argv[]) } imageRegion.SetSize(size); imageRegion.SetIndex(index); - VectorImageType::Pointer vecImage = + const VectorImageType::Pointer vecImage = itk::IOTestHelper::AllocateImageFromRegionAndSpacing(imageRegion, spacing, vecLength); itk::ImageRegionIterator it(vecImage, vecImage->GetLargestPossibleRegion()); diff --git a/Modules/IO/NIFTI/test/itkNiftiLargeImageRegionReadTest.cxx b/Modules/IO/NIFTI/test/itkNiftiLargeImageRegionReadTest.cxx index 731d36f2fc5..b61499477c2 100644 --- a/Modules/IO/NIFTI/test/itkNiftiLargeImageRegionReadTest.cxx +++ b/Modules/IO/NIFTI/test/itkNiftiLargeImageRegionReadTest.cxx @@ -48,8 +48,8 @@ itkNiftiLargeImageRegionReadTest(int argc, char * argv[]) using ImageType = itk::Image; // Create a large image - ImageType::SizeType size = { { 1034, 1034, 1020 } }; - ImageType::RegionType region; + const ImageType::SizeType size = { { 1034, 1034, 1020 } }; + ImageType::RegionType region; region.SetSize(size); { diff --git a/Modules/IO/NIFTI/test/itkNiftiReadAnalyzeTest.cxx b/Modules/IO/NIFTI/test/itkNiftiReadAnalyzeTest.cxx index 8310b3e354e..6dcc42c93fd 100644 --- a/Modules/IO/NIFTI/test/itkNiftiReadAnalyzeTest.cxx +++ b/Modules/IO/NIFTI/test/itkNiftiReadAnalyzeTest.cxx @@ -146,8 +146,8 @@ ReadImage(const std::string & fileName, { using ReaderType = itk::ImageFileReader; - auto reader = ReaderType::New(); - typename itk::NiftiImageIO::Pointer imageIO = itk::NiftiImageIO::New(); + auto reader = ReaderType::New(); + const typename itk::NiftiImageIO::Pointer imageIO = itk::NiftiImageIO::New(); { imageIO->SetLegacyAnalyze75Mode(analyze_mode); reader->SetImageIO(imageIO); diff --git a/Modules/IO/NIFTI/test/itkNiftiReadWriteDirectionTest.cxx b/Modules/IO/NIFTI/test/itkNiftiReadWriteDirectionTest.cxx index 081bb72407c..840f661e4fd 100644 --- a/Modules/IO/NIFTI/test/itkNiftiReadWriteDirectionTest.cxx +++ b/Modules/IO/NIFTI/test/itkNiftiReadWriteDirectionTest.cxx @@ -37,8 +37,8 @@ ReadImage(const std::string & fileName, bool SFORM_Permissive) { using ReaderType = itk::ImageFileReader; - auto reader = ReaderType::New(); - typename itk::NiftiImageIO::Pointer imageIO = itk::NiftiImageIO::New(); + auto reader = ReaderType::New(); + const typename itk::NiftiImageIO::Pointer imageIO = itk::NiftiImageIO::New(); { imageIO->SetSFORM_Permissive(SFORM_Permissive); reader->SetImageIO(imageIO); @@ -68,7 +68,8 @@ template bool CheckRotation(typename TImage::Pointer img) { - vnl_matrix_fixed rotation = img->GetDirection().GetVnlMatrix().extract(3, 3, 0, 0); + const vnl_matrix_fixed rotation = + img->GetDirection().GetVnlMatrix().extract(3, 3, 0, 0); const vnl_matrix_fixed candidate_identity = rotation * rotation.transpose(); return candidate_identity.is_identity(1.0e-4); } @@ -99,9 +100,9 @@ itkNiftiReadWriteDirectionTest(int argc, char * argv[]) } using TestImageType = itk::Image; - TestImageType::Pointer inputImage = itk::ReadImage(argv[1]); - TestImageType::Pointer inputImageNoQform = itk::ReadImage(argv[2]); - TestImageType::Pointer inputImageNoSform = itk::ReadImage(argv[3]); + const TestImageType::Pointer inputImage = itk::ReadImage(argv[1]); + const TestImageType::Pointer inputImageNoQform = itk::ReadImage(argv[2]); + const TestImageType::Pointer inputImageNoSform = itk::ReadImage(argv[3]); // Check if rotation matrix is orthogonal @@ -159,19 +160,19 @@ itkNiftiReadWriteDirectionTest(int argc, char * argv[]) } // Write image that originally had no sform direction representation into a file with both sform and qform - const std::string testOutputDir = argv[5]; - const std::string testFilename = testOutputDir + "/test_filled_sform.nii.gz"; - itk::ImageFileWriter::Pointer writer = itk::ImageFileWriter::New(); + const std::string testOutputDir = argv[5]; + const std::string testFilename = testOutputDir + "/test_filled_sform.nii.gz"; + const itk::ImageFileWriter::Pointer writer = itk::ImageFileWriter::New(); ITK_TRY_EXPECT_NO_EXCEPTION(itk::WriteImage(inputImageNoSform, testFilename)); // This time it should read from the newly written "sform" code in the image, which should // be the same as reading from qform of the original image - TestImageType::Pointer reReadImage = itk::ReadImage(testFilename); - const auto reReadImageDirection = reReadImage->GetDirection(); - const auto mdd = reReadImage->GetMetaDataDictionary(); - std::string sformCodeFromNifti; - const bool exposeSuccess = itk::ExposeMetaData(mdd, "sform_code_name", sformCodeFromNifti); + const TestImageType::Pointer reReadImage = itk::ReadImage(testFilename); + const auto reReadImageDirection = reReadImage->GetDirection(); + const auto mdd = reReadImage->GetMetaDataDictionary(); + std::string sformCodeFromNifti; + const bool exposeSuccess = itk::ExposeMetaData(mdd, "sform_code_name", sformCodeFromNifti); if (!exposeSuccess || sformCodeFromNifti != "NIFTI_XFORM_SCANNER_ANAT") { std::cerr << "Error: sform not set during writing" << std::endl; @@ -209,7 +210,7 @@ itkNiftiReadWriteDirectionTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(itk::ReadImage(argv[4])); // This should work - TestImageType::Pointer inputImageNonOrthoSform = ReadImage(argv[4], true); + const TestImageType::Pointer inputImageNonOrthoSform = ReadImage(argv[4], true); dictionary = inputImageNonOrthoSform->GetMetaDataDictionary(); if (!itk::ExposeMetaData(dictionary, "ITK_sform_corrected", temp) || temp != "YES") { @@ -240,10 +241,10 @@ itkNiftiReadWriteDirectionTest(int argc, char * argv[]) auto rRelative = inputImageNoQformDirection * nonOrthoDirectionInv; // Calculate the trace of the relative rotation matrix - double trace = rRelative[0][0] + rRelative[1][1] + rRelative[2][2]; + const double trace = rRelative[0][0] + rRelative[1][1] + rRelative[2][2]; // Calculate the angle of rotation between the two matrices - double angle = std::acos((trace - 1.0) / 2.0) * 180.0 / vnl_math::pi; + const double angle = std::acos((trace - 1.0) / 2.0) * 180.0 / vnl_math::pi; // The angle between the two matrices will depend on the amount of shear in the sform. Some test images // have relatively large shear to make sure they trigger the sform correction. In practice, permissive mode diff --git a/Modules/IO/NIFTI/test/itkNiftiWriteCoerceOrthogonalDirectionTest.cxx b/Modules/IO/NIFTI/test/itkNiftiWriteCoerceOrthogonalDirectionTest.cxx index f63d980cd42..c41479083f4 100644 --- a/Modules/IO/NIFTI/test/itkNiftiWriteCoerceOrthogonalDirectionTest.cxx +++ b/Modules/IO/NIFTI/test/itkNiftiWriteCoerceOrthogonalDirectionTest.cxx @@ -38,10 +38,10 @@ itkNiftiWriteCoerceOrthogonalDirectionTest(int argc, char * argv[]) const unsigned int dim = 2; using ImageType = itk::Image; - ImageType::IndexType startIndex = { { 0, 0 } }; - ImageType::SizeType imageSize = { { 2, 2 } }; - ImageType::RegionType region{ startIndex, imageSize }; - auto image1 = ImageType::New(); + const ImageType::IndexType startIndex = { { 0, 0 } }; + const ImageType::SizeType imageSize = { { 2, 2 } }; + const ImageType::RegionType region{ startIndex, imageSize }; + auto image1 = ImageType::New(); image1->SetRegions(region); image1->AllocateInitialized(); diff --git a/Modules/IO/NRRD/src/itkNrrdImageIO.cxx b/Modules/IO/NRRD/src/itkNrrdImageIO.cxx index 551051e7a80..528b107d267 100644 --- a/Modules/IO/NRRD/src/itkNrrdImageIO.cxx +++ b/Modules/IO/NRRD/src/itkNrrdImageIO.cxx @@ -209,9 +209,9 @@ NrrdImageIO::CanReadFile(const char * filename) // Check the extension first to avoid opening files that do not // look like nrrds. The file must have an appropriate extension to be // recognized. - std::string fname = filename; + const std::string fname = filename; - bool extensionFound = this->HasSupportedReadExtension(filename); + const bool extensionFound = this->HasSupportedReadExtension(filename); if (!extensionFound) { @@ -331,7 +331,7 @@ NrrdImageIO::ReadImageInformation() } // set type of pixel components; this is orthogonal to pixel type - IOComponentEnum cmpType = this->NrrdToITKComponentType(nrrd->type); + const IOComponentEnum cmpType = this->NrrdToITKComponentType(nrrd->type); if (IOComponentEnum::UNKNOWNCOMPONENTTYPE == cmpType) { itkExceptionMacro("Nrrd type " << airEnumStr(nrrdType, nrrd->type) @@ -341,10 +341,10 @@ NrrdImageIO::ReadImageInformation() // Set the number of image dimensions and bail if needed - unsigned int domainAxisIdx[NRRD_DIM_MAX]; - unsigned int domainAxisNum = nrrdDomainAxesGet(nrrd, domainAxisIdx); - unsigned int rangeAxisIdx[NRRD_DIM_MAX]; - unsigned int rangeAxisNum = nrrdRangeAxesGet(nrrd, rangeAxisIdx); + unsigned int domainAxisIdx[NRRD_DIM_MAX]; + const unsigned int domainAxisNum = nrrdDomainAxesGet(nrrd, domainAxisIdx); + unsigned int rangeAxisIdx[NRRD_DIM_MAX]; + const unsigned int rangeAxisNum = nrrdRangeAxesGet(nrrd, rangeAxisIdx); if (nrrd->spaceDim && nrrd->spaceDim != domainAxisNum) { itkExceptionMacro("ReadImageInformation: nrrd's #independent axes (" << domainAxisNum @@ -365,8 +365,8 @@ NrrdImageIO::ReadImageInformation() else if (1 == rangeAxisNum) { this->SetNumberOfDimensions(nrrd->dim - 1); - int kind = nrrd->axis[rangeAxisIdx[0]].kind; - size_t size = nrrd->axis[rangeAxisIdx[0]].size; + const int kind = nrrd->axis[rangeAxisIdx[0]].kind; + const size_t size = nrrd->axis[rangeAxisIdx[0]].size; // NOTE: it is the NRRD readers responsibility to make sure that // the size (#of components) associated with a specific kind is // matches the actual size of the axis. @@ -461,11 +461,11 @@ NrrdImageIO::ReadImageInformation() std::vector spaceDirStd(domainAxisNum); for (unsigned int axii = 0; axii < domainAxisNum; ++axii) { - unsigned int naxi = domainAxisIdx[axii]; + const unsigned int naxi = domainAxisIdx[axii]; this->SetDimensions(axii, static_cast(nrrd->axis[naxi].size)); - double spacing; - double spaceDir[NRRD_SPACE_DIM_MAX]; - int spacingStatus = nrrdSpacingCalculate(nrrd, naxi, &spacing, spaceDir); + double spacing; + double spaceDir[NRRD_SPACE_DIM_MAX]; + const int spacingStatus = nrrdSpacingCalculate(nrrd, naxi, &spacing, spaceDir); switch (spacingStatus) { @@ -557,8 +557,8 @@ NrrdImageIO::ReadImageInformation() } else { - double spaceOrigin[NRRD_DIM_MAX]; - int originStatus = nrrdOriginCalculate(nrrd, domainAxisIdx, domainAxisNum, nrrdCenterCell, spaceOrigin); + double spaceOrigin[NRRD_DIM_MAX]; + const int originStatus = nrrdOriginCalculate(nrrd, domainAxisIdx, domainAxisNum, nrrdCenterCell, spaceOrigin); for (unsigned int saxi = 0; saxi < domainAxisNum; ++saxi) { switch (originStatus) @@ -584,7 +584,7 @@ NrrdImageIO::ReadImageInformation() MetaDataDictionary & thisDic = this->GetMetaDataDictionary(); // Necessary to clear dict if ImageIO object is re-used thisDic.Clear(); - std::string classname(this->GetNameOfClass()); + const std::string classname(this->GetNameOfClass()); EncapsulateMetaData(thisDic, ITK_InputFilterName, classname); char key[AIR_STRLEN_SMALL]; @@ -607,8 +607,8 @@ NrrdImageIO::ReadImageInformation() // so we might was well go with consistent and idiomatic indexing. for (unsigned int axii = 0; axii < domainAxisNum; ++axii) { - unsigned int axi = domainAxisIdx[axii]; - NrrdAxisInfo * naxis = nrrd->axis + axi; + const unsigned int axi = domainAxisIdx[axii]; + NrrdAxisInfo * naxis = nrrd->axis + axi; if (AIR_EXISTS(naxis->thickness)) { snprintf(key, sizeof(key), "%s%s[%u]", KEY_PREFIX, airEnumStr(nrrdField, nrrdField_thicknesses), axii); @@ -777,8 +777,8 @@ NrrdImageIO::Read(void * buffer) FloatingPointExceptions::SetEnabled(saveFPEState); #endif - unsigned int rangeAxisIdx[NRRD_DIM_MAX]; - unsigned int rangeAxisNum = nrrdRangeAxesGet(nrrd, rangeAxisIdx); + unsigned int rangeAxisIdx[NRRD_DIM_MAX]; + const unsigned int rangeAxisNum = nrrdRangeAxesGet(nrrd, rangeAxisIdx); if (rangeAxisNum > 1) { @@ -857,7 +857,7 @@ NrrdImageIO::Read(void * buffer) bool NrrdImageIO::CanWriteFile(const char * name) { - std::string filename = name; + const std::string filename = name; if (filename.empty()) { @@ -899,8 +899,8 @@ NrrdImageIO::Write(const void * buffer) double spaceDir[NRRD_DIM_MAX][NRRD_SPACE_DIM_MAX]; double origin[NRRD_DIM_MAX]; - unsigned int baseDim; - unsigned int spaceDim = this->GetNumberOfDimensions(); + unsigned int baseDim; + const unsigned int spaceDim = this->GetNumberOfDimensions(); if (this->GetNumberOfComponents() > 1) { size[0] = this->GetNumberOfComponents(); @@ -943,7 +943,7 @@ NrrdImageIO::Write(const void * buffer) { baseDim = 0; } - unsigned int nrrdDim = baseDim + spaceDim; + const unsigned int nrrdDim = baseDim + spaceDim; std::vector spaceDirStd(spaceDim); unsigned int axi; for (axi = 0; axi < spaceDim; ++axi) @@ -951,7 +951,7 @@ NrrdImageIO::Write(const void * buffer) size[axi + baseDim] = this->GetDimensions(axi); kind[axi + baseDim] = nrrdKindDomain; origin[axi] = this->GetOrigin(axi); - double spacing = this->GetSpacing(axi); + const double spacing = this->GetSpacing(axi); spaceDirStd = this->GetDirection(axi); for (unsigned int saxi = 0; saxi < spaceDim; ++saxi) { @@ -1110,7 +1110,7 @@ NrrdImageIO::Write(const void * buffer) } else { - Superclass::IOFileEnum fileType = this->GetFileType(); + const Superclass::IOFileEnum fileType = this->GetFileType(); switch (fileType) { default: @@ -1125,7 +1125,7 @@ NrrdImageIO::Write(const void * buffer) } // set desired endianness of output - Superclass::IOByteOrderEnum byteOrder = this->GetByteOrder(); + const Superclass::IOByteOrderEnum byteOrder = this->GetByteOrder(); switch (byteOrder) { default: diff --git a/Modules/IO/NRRD/test/itkNrrdComplexImageReadTest.cxx b/Modules/IO/NRRD/test/itkNrrdComplexImageReadTest.cxx index aed13249eac..2727f986837 100644 --- a/Modules/IO/NRRD/test/itkNrrdComplexImageReadTest.cxx +++ b/Modules/IO/NRRD/test/itkNrrdComplexImageReadTest.cxx @@ -54,7 +54,7 @@ itkNrrdComplexImageReadTest(int argc, char * argv[]) return EXIT_FAILURE; } - myImage::Pointer image = reader->GetOutput(); + const myImage::Pointer image = reader->GetOutput(); // Pick off some pixels in the test image (the first, the last, and // a few in between) and make sure that the values are very close to @@ -107,7 +107,7 @@ itkNrrdComplexImageReadTest(int argc, char * argv[]) err += itk::Math::abs(sample.real() - -0.036674671); err += itk::Math::abs(sample.imag() - -0.0061681992); - double thresh = 0.00000038; + const double thresh = 0.00000038; if (err > thresh) { std::cout << "failure because err == " << err << "> " << thresh << std::endl; diff --git a/Modules/IO/NRRD/test/itkNrrdComplexImageReadWriteTest.cxx b/Modules/IO/NRRD/test/itkNrrdComplexImageReadWriteTest.cxx index 00502088556..443a46b6e67 100644 --- a/Modules/IO/NRRD/test/itkNrrdComplexImageReadWriteTest.cxx +++ b/Modules/IO/NRRD/test/itkNrrdComplexImageReadWriteTest.cxx @@ -55,7 +55,7 @@ itkNrrdComplexImageReadWriteTest(int argc, char * argv[]) return EXIT_FAILURE; } - myImage::Pointer image = reader->GetOutput(); + const myImage::Pointer image = reader->GetOutput(); image->Print(std::cout); // Generate test image diff --git a/Modules/IO/NRRD/test/itkNrrdCovariantVectorImageReadTest.cxx b/Modules/IO/NRRD/test/itkNrrdCovariantVectorImageReadTest.cxx index 313a65d298c..5cafdb8dbe0 100644 --- a/Modules/IO/NRRD/test/itkNrrdCovariantVectorImageReadTest.cxx +++ b/Modules/IO/NRRD/test/itkNrrdCovariantVectorImageReadTest.cxx @@ -54,9 +54,9 @@ itkNrrdCovariantVectorImageReadTest(int argc, char * argv[]) return EXIT_FAILURE; } - myImage::Pointer image = reader->GetOutput(); - myImage::IndexType coord; - PixelType sample; + const myImage::Pointer image = reader->GetOutput(); + myImage::IndexType coord; + PixelType sample; // The test image has been constructed so that the vector coefficients // coincide with sample coordinates diff --git a/Modules/IO/NRRD/test/itkNrrdCovariantVectorImageReadWriteTest.cxx b/Modules/IO/NRRD/test/itkNrrdCovariantVectorImageReadWriteTest.cxx index f4272339c35..d50ab72fc69 100644 --- a/Modules/IO/NRRD/test/itkNrrdCovariantVectorImageReadWriteTest.cxx +++ b/Modules/IO/NRRD/test/itkNrrdCovariantVectorImageReadWriteTest.cxx @@ -55,7 +55,7 @@ itkNrrdCovariantVectorImageReadWriteTest(int argc, char * argv[]) return EXIT_FAILURE; } - myImage::Pointer image = reader->GetOutput(); + const myImage::Pointer image = reader->GetOutput(); image->Print(std::cout); // Generate test image diff --git a/Modules/IO/NRRD/test/itkNrrdDiffusionTensor3DImageReadTensorDoubleWriteTensorDoubleTest.cxx b/Modules/IO/NRRD/test/itkNrrdDiffusionTensor3DImageReadTensorDoubleWriteTensorDoubleTest.cxx index b097518ee36..7f04db1da68 100644 --- a/Modules/IO/NRRD/test/itkNrrdDiffusionTensor3DImageReadTensorDoubleWriteTensorDoubleTest.cxx +++ b/Modules/IO/NRRD/test/itkNrrdDiffusionTensor3DImageReadTensorDoubleWriteTensorDoubleTest.cxx @@ -55,7 +55,7 @@ itkNrrdDiffusionTensor3DImageReadTensorDoubleWriteTensorDoubleTest(int argc, cha return EXIT_FAILURE; } - InImage::Pointer image = reader->GetOutput(); + const InImage::Pointer image = reader->GetOutput(); image->Print(std::cout); // Generate test image diff --git a/Modules/IO/NRRD/test/itkNrrdDiffusionTensor3DImageReadTest.cxx b/Modules/IO/NRRD/test/itkNrrdDiffusionTensor3DImageReadTest.cxx index e72762d443b..3a2bb1358e8 100644 --- a/Modules/IO/NRRD/test/itkNrrdDiffusionTensor3DImageReadTest.cxx +++ b/Modules/IO/NRRD/test/itkNrrdDiffusionTensor3DImageReadTest.cxx @@ -54,7 +54,7 @@ itkNrrdDiffusionTensor3DImageReadTest(int argc, char * argv[]) return EXIT_FAILURE; } - myImage::Pointer image = reader->GetOutput(); + const myImage::Pointer image = reader->GetOutput(); // Pick off some pixels in the test image (the first, the last, and // a few in between) and make sure that the values are very close to @@ -120,7 +120,7 @@ itkNrrdDiffusionTensor3DImageReadTest(int argc, char * argv[]) err += itk::Math::abs(sample(1, 2) - 0.43205333); err += itk::Math::abs(sample(2, 2) - 5.3755102); - double thresh = 0.00000041; + const double thresh = 0.00000041; if (err > thresh) { std::cout << "failure because err == " << err << "> " << thresh << std::endl; diff --git a/Modules/IO/NRRD/test/itkNrrdDiffusionTensor3DImageReadWriteTest.cxx b/Modules/IO/NRRD/test/itkNrrdDiffusionTensor3DImageReadWriteTest.cxx index 8aa203990c6..0996df173a8 100644 --- a/Modules/IO/NRRD/test/itkNrrdDiffusionTensor3DImageReadWriteTest.cxx +++ b/Modules/IO/NRRD/test/itkNrrdDiffusionTensor3DImageReadWriteTest.cxx @@ -55,7 +55,7 @@ itkNrrdDiffusionTensor3DImageReadWriteTest(int argc, char * argv[]) return EXIT_FAILURE; } - myImage::Pointer image = reader->GetOutput(); + const myImage::Pointer image = reader->GetOutput(); image->Print(std::cout); // Generate test image diff --git a/Modules/IO/NRRD/test/itkNrrdImageIOTest.h b/Modules/IO/NRRD/test/itkNrrdImageIOTest.h index e6771b2dffa..7062e0a3974 100644 --- a/Modules/IO/NRRD/test/itkNrrdImageIOTest.h +++ b/Modules/IO/NRRD/test/itkNrrdImageIOTest.h @@ -34,7 +34,7 @@ itkNrrdImageIOTestGenerateRandomImage(unsigned int size) { using ImageType = itk::Image; - typename itk::RandomImageSource::Pointer source = itk::RandomImageSource::New(); + const typename itk::RandomImageSource::Pointer source = itk::RandomImageSource::New(); typename ImageType::SizeType sz; typename ImageType::SpacingType spacing; @@ -61,10 +61,10 @@ itkNrrdImageIOTestReadWriteTest(std::string fn, unsigned int size, std::string i { using ImageType = itk::Image; - typename itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); - typename itk::ImageFileWriter::Pointer writer = itk::ImageFileWriter::New(); + const typename itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); + const typename itk::ImageFileWriter::Pointer writer = itk::ImageFileWriter::New(); - itk::NrrdImageIO::Pointer io = itk::NrrdImageIO::New(); + const itk::NrrdImageIO::Pointer io = itk::NrrdImageIO::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(io, NrrdImageIO, ImageIOBase); @@ -72,7 +72,7 @@ itkNrrdImageIOTestReadWriteTest(std::string fn, unsigned int size, std::string i ITK_TEST_EXPECT_TRUE(io->SupportsDimension(VImageDimension)); constexpr unsigned int NRRD_DIM_MAX = 16; // taken from NrrdIO.h which is not in the include path - unsigned long dim = NRRD_DIM_MAX + 1; + const unsigned long dim = NRRD_DIM_MAX + 1; ITK_TEST_EXPECT_TRUE(!io->SupportsDimension(dim)); // Binary files have no image information to read @@ -86,7 +86,7 @@ itkNrrdImageIOTestReadWriteTest(std::string fn, unsigned int size, std::string i if (inputFile != "null") { - typename itk::ImageFileReader::Pointer tmpReader = itk::ImageFileReader::New(); + const typename itk::ImageFileReader::Pointer tmpReader = itk::ImageFileReader::New(); tmpReader->SetImageIO(io); tmpReader->SetFileName(inputFile.c_str()); diff --git a/Modules/IO/NRRD/test/itkNrrdImageReadWriteTest.cxx b/Modules/IO/NRRD/test/itkNrrdImageReadWriteTest.cxx index 268b8a89c4c..469f1afe52b 100644 --- a/Modules/IO/NRRD/test/itkNrrdImageReadWriteTest.cxx +++ b/Modules/IO/NRRD/test/itkNrrdImageReadWriteTest.cxx @@ -51,7 +51,7 @@ itkNrrdImageReadWriteTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); - myImage::Pointer image = reader->GetOutput(); + const myImage::Pointer image = reader->GetOutput(); image->Print(std::cout); diff --git a/Modules/IO/NRRD/test/itkNrrdMetaDataTest.cxx b/Modules/IO/NRRD/test/itkNrrdMetaDataTest.cxx index 8e6e75c627a..2d748e0cf68 100644 --- a/Modules/IO/NRRD/test/itkNrrdMetaDataTest.cxx +++ b/Modules/IO/NRRD/test/itkNrrdMetaDataTest.cxx @@ -42,8 +42,8 @@ itkNrrdMetaDataTest(int argc, char * argv[]) // Image type using ImageType = itk::Image; // create dummy image - auto image1 = ImageType::New(); - ImageType::SizeType size = { { 2, 2, 2 } }; + auto image1 = ImageType::New(); + const ImageType::SizeType size = { { 2, 2, 2 } }; image1->SetRegions(size); image1->Allocate(); image1->FillBuffer(1); diff --git a/Modules/IO/NRRD/test/itkNrrdRGBAImageReadWriteTest.cxx b/Modules/IO/NRRD/test/itkNrrdRGBAImageReadWriteTest.cxx index 278e7a8c6d9..7bc6e724a5b 100644 --- a/Modules/IO/NRRD/test/itkNrrdRGBAImageReadWriteTest.cxx +++ b/Modules/IO/NRRD/test/itkNrrdRGBAImageReadWriteTest.cxx @@ -38,7 +38,7 @@ itkNrrdRGBAImageReadWriteTest(int argc, char * argv[]) using PixelType = itk::RGBAPixel; using myImage = itk::Image; - itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); reader->SetFileName(argv[1]); try @@ -52,7 +52,7 @@ itkNrrdRGBAImageReadWriteTest(int argc, char * argv[]) return EXIT_FAILURE; } - myImage::Pointer image = reader->GetOutput(); + const myImage::Pointer image = reader->GetOutput(); image->Print(std::cout); // Generate test image diff --git a/Modules/IO/NRRD/test/itkNrrdRGBImageReadWriteTest.cxx b/Modules/IO/NRRD/test/itkNrrdRGBImageReadWriteTest.cxx index 263b53dd68d..27716d83c9f 100644 --- a/Modules/IO/NRRD/test/itkNrrdRGBImageReadWriteTest.cxx +++ b/Modules/IO/NRRD/test/itkNrrdRGBImageReadWriteTest.cxx @@ -38,7 +38,7 @@ itkNrrdRGBImageReadWriteTest(int argc, char * argv[]) using PixelType = itk::RGBPixel; using myImage = itk::Image; - itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); reader->SetFileName(argv[1]); try @@ -52,7 +52,7 @@ itkNrrdRGBImageReadWriteTest(int argc, char * argv[]) return EXIT_FAILURE; } - myImage::Pointer image = reader->GetOutput(); + const myImage::Pointer image = reader->GetOutput(); image->Print(std::cout); // Generate test image diff --git a/Modules/IO/NRRD/test/itkNrrdVectorImageReadTest.cxx b/Modules/IO/NRRD/test/itkNrrdVectorImageReadTest.cxx index 1488e817fff..f5684b3512a 100644 --- a/Modules/IO/NRRD/test/itkNrrdVectorImageReadTest.cxx +++ b/Modules/IO/NRRD/test/itkNrrdVectorImageReadTest.cxx @@ -54,9 +54,9 @@ itkNrrdVectorImageReadTest(int argc, char * argv[]) return EXIT_FAILURE; } - myImage::Pointer image = reader->GetOutput(); - myImage::IndexType coord; - PixelType sample; + const myImage::Pointer image = reader->GetOutput(); + myImage::IndexType coord; + PixelType sample; // The test image has been constructed so that the vector coefficients // coincide with sample coordinates diff --git a/Modules/IO/NRRD/test/itkNrrdVectorImageReadWriteTest.cxx b/Modules/IO/NRRD/test/itkNrrdVectorImageReadWriteTest.cxx index 933044eb7c3..24a7b677726 100644 --- a/Modules/IO/NRRD/test/itkNrrdVectorImageReadWriteTest.cxx +++ b/Modules/IO/NRRD/test/itkNrrdVectorImageReadWriteTest.cxx @@ -55,7 +55,7 @@ itkNrrdVectorImageReadWriteTest(int argc, char * argv[]) return EXIT_FAILURE; } - myImage::Pointer image = reader->GetOutput(); + const myImage::Pointer image = reader->GetOutput(); image->Print(std::cout); // Generate test image diff --git a/Modules/IO/PNG/src/itkPNGImageIO.cxx b/Modules/IO/PNG/src/itkPNGImageIO.cxx index cce58147229..31d741217e1 100644 --- a/Modules/IO/PNG/src/itkPNGImageIO.cxx +++ b/Modules/IO/PNG/src/itkPNGImageIO.cxx @@ -64,7 +64,7 @@ bool PNGImageIO::CanReadFile(const char * file) { // First check the filename - std::string filename = file; + const std::string filename = file; if (filename.empty()) { @@ -73,18 +73,18 @@ PNGImageIO::CanReadFile(const char * file) } // Now check the file header - PNGFileWrapper pngfp(file, "rb"); + const PNGFileWrapper pngfp(file, "rb"); if (pngfp.m_FilePointer == nullptr) { return false; } unsigned char header[8]; - size_t temp = fread(header, 1, 8, pngfp.m_FilePointer); + const size_t temp = fread(header, 1, 8, pngfp.m_FilePointer); if (temp != 8) { return false; } - bool is_png = !png_sig_cmp(header, 0, 8); + const bool is_png = !png_sig_cmp(header, 0, 8); if (!is_png) { return false; @@ -122,15 +122,15 @@ PNGImageIO::Read(void * buffer) { itkDebugMacro("Read: file dimensions = " << this->GetNumberOfDimensions()); // use this class so return will call close - PNGFileWrapper pngfp(this->GetFileName(), "rb"); - FILE * fp = pngfp.m_FilePointer; + const PNGFileWrapper pngfp(this->GetFileName(), "rb"); + FILE * fp = pngfp.m_FilePointer; if (!fp) { itkExceptionMacro("PNGImageIO could not open file: " << this->GetFileName() << " for reading." << std::endl << "Reason: " << itksys::SystemTools::GetLastSystemError()); } unsigned char header[8]; - size_t temp = fread(header, 1, 8, fp); + const size_t temp = fread(header, 1, 8, fp); if (temp != 8) { itkExceptionMacro("PNGImageIO failed to read header for file: " << this->GetFileName() << std::endl @@ -138,7 +138,7 @@ PNGImageIO::Read(void * buffer) << " instead of 8"); } - bool is_png = !png_sig_cmp(header, 0, 8); + const bool is_png = !png_sig_cmp(header, 0, 8); if (!is_png) { itkExceptionMacro("File is not png type: " << this->GetFileName()); @@ -318,14 +318,14 @@ PNGImageIO::ReadImageInformation() m_Origin[1] = 0.0; // use this class so return will call close - PNGFileWrapper pngfp(m_FileName.c_str(), "rb"); - FILE * fp = pngfp.m_FilePointer; + const PNGFileWrapper pngfp(m_FileName.c_str(), "rb"); + FILE * fp = pngfp.m_FilePointer; if (!fp) { return; } unsigned char header[8]; - size_t temp = fread(header, 1, 8, fp); + const size_t temp = fread(header, 1, 8, fp); if (temp != 8) { itkExceptionMacro("PNGImageIO failed to read header for file: " << this->GetFileName() << std::endl @@ -333,7 +333,7 @@ PNGImageIO::ReadImageInformation() << " instead of 8"); } - bool is_png = !png_sig_cmp(header, 0, 8); + const bool is_png = !png_sig_cmp(header, 0, 8); if (!is_png) { return; @@ -489,7 +489,7 @@ PNGImageIO::ReadImageInformation() bool PNGImageIO::CanWriteFile(const char * name) { - std::string filename = name; + const std::string filename = name; if (filename.empty()) { @@ -513,8 +513,8 @@ void PNGImageIO::WriteSlice(const std::string & fileName, const void * const buffer) { // use this class so return will call close - PNGFileWrapper pngfp(fileName.c_str(), "wb"); - FILE * fp = pngfp.m_FilePointer; + const PNGFileWrapper pngfp(fileName.c_str(), "wb"); + FILE * fp = pngfp.m_FilePointer; if (!fp) { @@ -576,8 +576,8 @@ PNGImageIO::WriteSlice(const std::string & fileName, const void * const buffer) << "Reason: " << itksys::SystemTools::GetLastSystemError()); } - int colorType; - unsigned int numComp = this->GetNumberOfComponents(); + int colorType; + const unsigned int numComp = this->GetNumberOfComponents(); switch (numComp) { case 1: @@ -601,11 +601,11 @@ PNGImageIO::WriteSlice(const std::string & fileName, const void * const buffer) break; } - png_uint_32 width = this->GetDimensions(0); - double colSpacing = m_Spacing[0]; + const png_uint_32 width = this->GetDimensions(0); + const double colSpacing = m_Spacing[0]; - png_uint_32 height = (m_NumberOfDimensions > 1) ? this->GetDimensions(1) : 1; - double rowSpacing = (m_NumberOfDimensions > 1) ? m_Spacing[1] : 1; + const png_uint_32 height = (m_NumberOfDimensions > 1) ? this->GetDimensions(1) : 1; + const double rowSpacing = (m_NumberOfDimensions > 1) ? m_Spacing[1] : 1; png_set_IHDR(png_ptr, info_ptr, @@ -686,7 +686,7 @@ PNGImageIO::WriteSlice(const std::string & fileName, const void * const buffer) { const int rowInc = width * numComp * bitDepth / 8; - volatile const unsigned char * outPtr = ((const unsigned char *)buffer); + const volatile unsigned char * outPtr = ((const unsigned char *)buffer); for (unsigned int ui = 0; ui < height; ++ui) { row_pointers[ui] = const_cast(outPtr); diff --git a/Modules/IO/PNG/test/itkPNGImageIOTest.cxx b/Modules/IO/PNG/test/itkPNGImageIOTest.cxx index 39457415260..aab40d6b947 100644 --- a/Modules/IO/PNG/test/itkPNGImageIOTest.cxx +++ b/Modules/IO/PNG/test/itkPNGImageIOTest.cxx @@ -48,13 +48,13 @@ itkPNGImageIOTest(int argc, char * argv[]) // Read in the image - itk::PNGImageIO::Pointer io = itk::PNGImageIO::New(); + const itk::PNGImageIO::Pointer io = itk::PNGImageIO::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(io, PNGImageIO, ImageIOBase); // Exercise exception cases - size_t sizeOfActualIORegion = + const size_t sizeOfActualIORegion = io->GetIORegion().GetNumberOfPixels() * (io->GetComponentSize() * io->GetNumberOfComponents()); auto * loadBuffer = new char[sizeOfActualIORegion]; @@ -64,7 +64,7 @@ itkPNGImageIOTest(int argc, char * argv[]) auto useCompression = static_cast(std::stoi(argv[3])); ITK_TEST_SET_GET_BOOLEAN(io, UseCompression, useCompression); - int compressionLevel = std::stoi(argv[4]); + const int compressionLevel = std::stoi(argv[4]); io->SetCompressionLevel(compressionLevel); ITK_TEST_SET_GET_VALUE(compressionLevel, io->GetCompressionLevel()); @@ -103,7 +103,7 @@ itkPNGImageIOTest(int argc, char * argv[]) std::cout << "itk::PNGImageIO cannot read file " << io->GetFileName() << std::endl; return EXIT_FAILURE; } - itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); reader->SetFileName(argv[1]); reader->SetImageIO(io); ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); @@ -133,7 +133,7 @@ itkPNGImageIOTest(int argc, char * argv[]) } // Try writing - itk::ImageFileWriter::Pointer writer = itk::ImageFileWriter::New(); + const itk::ImageFileWriter::Pointer writer = itk::ImageFileWriter::New(); writer->SetInput(reader->GetOutput()); writer->SetFileName(argv[2]); writer->SetImageIO(io); @@ -145,7 +145,7 @@ itkPNGImageIOTest(int argc, char * argv[]) delete[] loadBuffer; // Exercise other methods - itk::ImageIOBase::SizeType pixelStride = io->GetPixelStride(); + const itk::ImageIOBase::SizeType pixelStride = io->GetPixelStride(); std::cout << "PixelStride: " << itk::NumericTraits::PrintType(pixelStride) << std::endl; // @@ -170,9 +170,9 @@ itkPNGImageIOTest(int argc, char * argv[]) auto volume = ImageType3D::New(); - auto size3D = ImageType3D::SizeType::Filled(10); - ImageType3D::IndexType start3D{}; - ImageType3D::RegionType region3D{ start3D, size3D }; + auto size3D = ImageType3D::SizeType::Filled(10); + const ImageType3D::IndexType start3D{}; + ImageType3D::RegionType region3D{ start3D, size3D }; volume->SetRegions(region3D); volume->Allocate(); @@ -212,9 +212,9 @@ itkPNGImageIOTest(int argc, char * argv[]) // auto image = ImageType2D::New(); - auto size2D = ImageType2D::SizeType::Filled(10); - ImageType2D::IndexType start2D{}; - ImageType2D::RegionType region2D{ start2D, size2D }; + auto size2D = ImageType2D::SizeType::Filled(10); + const ImageType2D::IndexType start2D{}; + ImageType2D::RegionType region2D{ start2D, size2D }; image->SetRegions(region2D); image->Allocate(); @@ -253,9 +253,9 @@ itkPNGImageIOTest(int argc, char * argv[]) // auto line = ImageType1D::New(); - auto size1D = ImageType1D::SizeType::Filled(10); - ImageType1D::IndexType start1D{}; - ImageType1D::RegionType region1D{ start1D, size1D }; + auto size1D = ImageType1D::SizeType::Filled(10); + const ImageType1D::IndexType start1D{}; + const ImageType1D::RegionType region1D{ start1D, size1D }; line->SetRegions(region1D); line->Allocate(); diff --git a/Modules/IO/PNG/test/itkPNGImageIOTest2.cxx b/Modules/IO/PNG/test/itkPNGImageIOTest2.cxx index 66b47e173cb..da6360ddcfa 100644 --- a/Modules/IO/PNG/test/itkPNGImageIOTest2.cxx +++ b/Modules/IO/PNG/test/itkPNGImageIOTest2.cxx @@ -70,12 +70,12 @@ itkPNGImageIOTest2(int argc, char * argv[]) // Read the input image - itk::PNGImageIO::Pointer io = itk::PNGImageIO::New(); + const itk::PNGImageIO::Pointer io = itk::PNGImageIO::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(io, PNGImageIO, ImageIOBase); // Exercise exception cases - size_t sizeOfActualIORegion = + const size_t sizeOfActualIORegion = io->GetIORegion().GetNumberOfPixels() * (io->GetComponentSize() * io->GetNumberOfComponents()); auto * loadBuffer = new char[sizeOfActualIORegion]; @@ -85,7 +85,7 @@ itkPNGImageIOTest2(int argc, char * argv[]) auto useCompression = static_cast(argv[3]); ITK_TEST_SET_GET_BOOLEAN(io, UseCompression, useCompression); - int compressionLevel = std::stoi(argv[4]); + const int compressionLevel = std::stoi(argv[4]); io->SetCompressionLevel(compressionLevel); ITK_TEST_SET_GET_VALUE(compressionLevel, io->GetCompressionLevel()); @@ -179,11 +179,11 @@ itkPNGImageIOTest2(int argc, char * argv[]) // Exercise other methods - itk::ImageIOBase::SizeType pixelStride = io->GetPixelStride(); + const itk::ImageIOBase::SizeType pixelStride = io->GetPixelStride(); std::cout << "PixelStride: " << itk::NumericTraits::PrintType(pixelStride) << std::endl; - ImageType::Pointer inputImage = reader->GetOutput(); + const ImageType::Pointer inputImage = reader->GetOutput(); // Write the grayscale output image auto writer = WriterType::New(); diff --git a/Modules/IO/PNG/test/itkPNGImageIOTest3.cxx b/Modules/IO/PNG/test/itkPNGImageIOTest3.cxx index f5f1d25f607..50bceabca08 100644 --- a/Modules/IO/PNG/test/itkPNGImageIOTest3.cxx +++ b/Modules/IO/PNG/test/itkPNGImageIOTest3.cxx @@ -40,8 +40,8 @@ itkPNGImageIOTest3(int argc, char * argv[]) using ReaderType = itk::ImageFileReader; // Read the input image - itk::PNGImageIO::Pointer io = itk::PNGImageIO::New(); - auto reader = ReaderType::New(); + const itk::PNGImageIO::Pointer io = itk::PNGImageIO::New(); + auto reader = ReaderType::New(); reader->SetFileName(argv[1]); reader->SetImageIO(io); diff --git a/Modules/IO/PNG/test/itkPNGImageIOTestPalette.cxx b/Modules/IO/PNG/test/itkPNGImageIOTestPalette.cxx index 98bdeec0973..cf4c3d62c12 100644 --- a/Modules/IO/PNG/test/itkPNGImageIOTestPalette.cxx +++ b/Modules/IO/PNG/test/itkPNGImageIOTestPalette.cxx @@ -64,7 +64,7 @@ itkPNGImageIOTestPalette(int argc, char * argv[]) ITK_TEST_SET_GET_BOOLEAN(io, ExpandRGBPalette, expandRGBPalette); // Exercise exception cases - size_t sizeOfActualIORegion = + const size_t sizeOfActualIORegion = io->GetIORegion().GetNumberOfPixels() * (io->GetComponentSize() * io->GetNumberOfComponents()); auto * loadBuffer = new char[sizeOfActualIORegion]; @@ -173,10 +173,10 @@ itkPNGImageIOTestPalette(int argc, char * argv[]) // case not possible here } - ScalarImageType::Pointer inputImage = reader->GetOutput(); + const ScalarImageType::Pointer inputImage = reader->GetOutput(); // test writing palette - bool writePalette = !expandRGBPalette && isPaletteImage; + const bool writePalette = !expandRGBPalette && isPaletteImage; std::cerr << "Trying to write the image as " << ((writePalette) ? "palette" : "expanded palette") << std::endl; ITK_TEST_SET_GET_BOOLEAN(io, WritePalette, writePalette); @@ -236,7 +236,7 @@ itkPNGImageIOTestPalette(int argc, char * argv[]) } // Exercise other methods - itk::ImageIOBase::SizeType pixelStride = io->GetPixelStride(); + const itk::ImageIOBase::SizeType pixelStride = io->GetPixelStride(); std::cout << "PixelStride: " << itk::NumericTraits::PrintType(pixelStride) << std::endl; // ToDo diff --git a/Modules/IO/PhilipsREC/src/itkPhilipsPAR.cxx b/Modules/IO/PhilipsREC/src/itkPhilipsPAR.cxx index 02bf5304a06..4addd37a7ee 100644 --- a/Modules/IO/PhilipsREC/src/itkPhilipsPAR.cxx +++ b/Modules/IO/PhilipsREC/src/itkPhilipsPAR.cxx @@ -499,7 +499,7 @@ PhilipsPAR::GetGeneralInfoString(std::string file, int lineNum) index = currentLine.find(":"); if (index != std::string::npos) { - std::string tempString = ":"; + const std::string tempString = ":"; outString = currentLine.substr(index + tempString.length()); } return outString; @@ -613,7 +613,7 @@ PhilipsPAR::ReadPAR(std::string parFile, struct par_parameter * pPar) inString >> pPar->repetition_time[repTime]; } inString.clear(); - struct image_info_defV3 tempInfo = GetImageInformationDefinitionV3(parFile, 89, this); + struct image_info_defV3 const tempInfo = GetImageInformationDefinitionV3(parFile, 89, this); if (tempInfo.problemreading) { std::ostringstream message; @@ -803,7 +803,7 @@ PhilipsPAR::ReadPAR(std::string parFile, struct par_parameter * pPar) // Slices are not sorted. else { - int slice = tempInfo.slice; + const int slice = tempInfo.slice; ++pPar->image_blocks; ++pPar->num_image_types; pPar->image_types[0] = tempInfo.image_type_mr; @@ -924,13 +924,13 @@ PhilipsPAR::ReadPAR(std::string parFile, struct par_parameter * pPar) // Only 1 slice, but how many repetitions of that slice? else { - int lineIncrement = 89; - int echoIndex = 0; - int cardiacIndex = 0; - int slice = tempInfo.slice; - int firstEchoNumber = echoNumber; - int firstCardiacPhase = cardiacPhase; - int firstDynamic = tempInfo.dynamic; + int lineIncrement = 89; + int echoIndex = 0; + int cardiacIndex = 0; + const int slice = tempInfo.slice; + const int firstEchoNumber = echoNumber; + const int firstCardiacPhase = cardiacPhase; + const int firstDynamic = tempInfo.dynamic; ++pPar->image_blocks; ++pPar->num_image_types; pPar->image_types[0] = tempInfo.image_type_mr; @@ -1318,7 +1318,7 @@ PhilipsPAR::ReadPAR(std::string parFile, struct par_parameter * pPar) // Slices are not sorted. else { - int slice = tempInfo.slice; + const int slice = tempInfo.slice; ++pPar->image_blocks; ++pPar->num_image_types; pPar->image_types[0] = tempInfo.image_type_mr; @@ -1455,13 +1455,13 @@ PhilipsPAR::ReadPAR(std::string parFile, struct par_parameter * pPar) // Only 1 slice, but how many repetitions of that slice? else { - int lineIncrement = 92; - int echoIndex = 0; - int cardiacIndex = 0; - int slice = tempInfo.slice; - int firstEchoNumber = echoNumber; - int firstCardiacPhase = cardiacPhase; - int firstDynamic = tempInfo.dynamic; + int lineIncrement = 92; + int echoIndex = 0; + int cardiacIndex = 0; + const int slice = tempInfo.slice; + const int firstEchoNumber = echoNumber; + const int firstCardiacPhase = cardiacPhase; + const int firstDynamic = tempInfo.dynamic; ++pPar->image_blocks; ++pPar->num_image_types; pPar->image_types[0] = tempInfo.image_type_mr; @@ -1938,14 +1938,14 @@ PhilipsPAR::GetRECRescaleValues(std::string parFile, rescaleValues->clear(); // Must match size of image_types rescaleValues->resize(PAR_DEFAULT_IMAGE_TYPES_SIZE); - PhilipsPAR::PARRescaleValues zero(0.0); + const PhilipsPAR::PARRescaleValues zero(0.0); for (unsigned int zeroIndex = 0; zeroIndex < rescaleValues->size(); ++zeroIndex) { (*rescaleValues)[zeroIndex] = zero; // Zero out everything } // Check version of PAR file. - int ResToolsVersion = this->GetPARVersion(parFile); + const int ResToolsVersion = this->GetPARVersion(parFile); if (ResToolsVersion == RESEARCH_IMAGE_EXPORT_TOOL_UNKNOWN) { return false; @@ -2051,7 +2051,7 @@ PhilipsPAR::GetDiffusionGradientOrientationAndBValues(std::string // Check version of PAR file. // Diffusion gradients are only stored in PAR version >= 4.1 - int ResToolsVersion = this->GetPARVersion(parFile); + const int ResToolsVersion = this->GetPARVersion(parFile); if (ResToolsVersion >= RESEARCH_IMAGE_EXPORT_TOOL_V4_1) { int gradientOrientationNumber = -1; @@ -2085,7 +2085,7 @@ PhilipsPAR::GetDiffusionGradientOrientationAndBValues(std::string struct image_info_defV4 tempInfo = GetImageInformationDefinitionV41(parFile, lineIncrement, this); while (!tempInfo.problemreading && tempInfo.slice && (gradientDirectionCount < tempPar.max_num_grad_orient)) { - int tempGradientOrientationNumber = tempInfo.gradient_orientation_number; + const int tempGradientOrientationNumber = tempInfo.gradient_orientation_number; if (gradientOrientationNumber != tempGradientOrientationNumber) { PhilipsPAR::PARDiffusionValues direction; @@ -2111,7 +2111,7 @@ PhilipsPAR::GetLabelTypesASL(std::string parFile, PhilipsPAR::PARLabelTypesASLCo // Check version of PAR file. // ASL labels are only stored in PAR version >= 4.2 - int ResToolsVersion = this->GetPARVersion(parFile); + const int ResToolsVersion = this->GetPARVersion(parFile); if (ResToolsVersion >= RESEARCH_IMAGE_EXPORT_TOOL_V4_2) { struct image_info_defV4 tempInfo; @@ -2139,7 +2139,7 @@ PhilipsPAR::GetLabelTypesASL(std::string parFile, PhilipsPAR::PARLabelTypesASLCo tempInfo = GetImageInformationDefinitionV42(parFile, lineIncrement, this); while (!tempInfo.problemreading && tempInfo.slice && (aslLabelCount < tempPar.num_label_types)) { - int tempASLLabelNumber = tempInfo.labelTypeASL; + const int tempASLLabelNumber = tempInfo.labelTypeASL; if (aslLabelNumber != tempASLLabelNumber) { (*labelTypes)[aslLabelCount] = tempASLLabelNumber; diff --git a/Modules/IO/PhilipsREC/src/itkPhilipsRECImageIO.cxx b/Modules/IO/PhilipsREC/src/itkPhilipsRECImageIO.cxx index 186d85b1621..54c15f548cf 100644 --- a/Modules/IO/PhilipsREC/src/itkPhilipsRECImageIO.cxx +++ b/Modules/IO/PhilipsREC/src/itkPhilipsRECImageIO.cxx @@ -212,9 +212,9 @@ PhilipsRECImageIOSetupSliceIndex(PhilipsRECImageIO::SliceIndexType * ind PhilipsPAR::PARSliceIndexImageTypeVector sliceImageTypesIndex, PhilipsPAR::PARSliceIndexScanSequenceVector sliceScanSequenceIndex) { - int index = 0; - int actualSlices = parParam.slice; - int remainingVolumes = parParam.image_blocks / parParam.num_slice_repetitions; + int index = 0; + const int actualSlices = parParam.slice; + const int remainingVolumes = parParam.image_blocks / parParam.num_slice_repetitions; if (indexMatrix->size() != (PhilipsRECImageIO::SliceIndexType::size_type)parParam.dim[2]) { @@ -407,7 +407,8 @@ PhilipsRECImageIO::PrintSelf(std::ostream & os, Indent indent) const PhilipsRECImageIO::IndexValueType PhilipsRECImageIO::GetSliceIndex(IndexValueType index) const { - IndexValueType maximumSliceNumber = Math::CastWithRangeCheck(this->m_SliceIndex->size()) - 1; + const IndexValueType maximumSliceNumber = + Math::CastWithRangeCheck(this->m_SliceIndex->size()) - 1; if ((index < 0) || (index > maximumSliceNumber)) { @@ -470,11 +471,11 @@ PhilipsRECImageIO::Read(void * buffer) numberOfSlices *= this->m_Dimensions[3]; } - SizeType imageSliceSizeInBytes = this->GetImageSizeInBytes() / numberOfSlices; + const SizeType imageSliceSizeInBytes = this->GetImageSizeInBytes() / numberOfSlices; for (IndexValueType slice = 0; slice < numberOfSlices; ++slice) { - IndexValueType realIndex = this->GetSliceIndex(static_cast(slice)); + const IndexValueType realIndex = this->GetSliceIndex(static_cast(slice)); if (realIndex < 0) { std::ostringstream message; @@ -498,10 +499,10 @@ PhilipsRECImageIO::Read(void * buffer) bool PhilipsRECImageIO::CanReadFile(const char * FileNameToRead) { - std::string filename(FileNameToRead); + const std::string filename(FileNameToRead); // we check that the correct extension is given by the user - std::string filenameext = GetExtension(filename); + const std::string filenameext = GetExtension(filename); if (filenameext != std::string(".PAR") && filenameext != std::string(".REC") && filenameext != std::string(".REC.gz") && filenameext != std::string(".par") && @@ -596,11 +597,11 @@ PhilipsRECImageIO::ReadImageInformation() // Setup the slice index matrix. this->m_SliceIndex->clear(); this->m_SliceIndex->resize(par.dim[2]); - PhilipsPAR::PARSliceIndexImageTypeVector sliceImageTypesIndexes = + const PhilipsPAR::PARSliceIndexImageTypeVector sliceImageTypesIndexes = philipsPAR->GetRECSliceIndexImageTypes(HeaderFileName); - PhilipsPAR::PARSliceIndexScanSequenceVector sliceScanSequencesIndexes = + const PhilipsPAR::PARSliceIndexScanSequenceVector sliceScanSequencesIndexes = philipsPAR->GetRECSliceIndexScanningSequence(HeaderFileName); - PhilipsPAR::PARImageTypeScanSequenceVector imageTypesScanSequencesIndexes = + const PhilipsPAR::PARImageTypeScanSequenceVector imageTypesScanSequencesIndexes = philipsPAR->GetImageTypesScanningSequence(HeaderFileName); PhilipsRECImageIOSetupSliceIndex( this->m_SliceIndex, 1, par, imageTypesScanSequencesIndexes, sliceImageTypesIndexes, sliceScanSequencesIndexes); @@ -671,7 +672,7 @@ PhilipsRECImageIO::ReadImageInformation() MetaDataDictionary & thisDic = this->GetMetaDataDictionary(); // Necessary to clear dict if ImageIO object is re-used thisDic.Clear(); - std::string classname(this->GetNameOfClass()); + const std::string classname(this->GetNameOfClass()); EncapsulateMetaData(thisDic, ITK_InputFilterName, classname); EncapsulateMetaData(thisDic, ITK_ImageFileBaseName, GetRootName(this->m_FileName)); @@ -771,7 +772,7 @@ PhilipsRECImageIO::ReadImageInformation() r3[0][1] = std::sin(par.angFH * Math::pi / 180.0); r3[1][1] = std::cos(par.angFH * Math::pi / 180.0); // Total rotation matrix. - AffineMatrix rtotal = r1 * r2 * r3; + const AffineMatrix rtotal = r1 * r2 * r3; #ifdef DEBUG_ORIENTATION std::cout << "Right-Left rotation = " << r1 << std::endl << "Anterior-Posterior rotation = " << r2 << std::endl @@ -780,7 +781,7 @@ PhilipsRECImageIO::ReadImageInformation() #endif // Find and set origin - AffineMatrix final = rtotal * spacing * direction; + const AffineMatrix final = rtotal * spacing * direction; #ifdef DEBUG_ORIENTATION std::cout << "Final transformation = " << final << std::endl; #endif diff --git a/Modules/IO/PhilipsREC/test/itkPhilipsRECImageIOPrintTest.cxx b/Modules/IO/PhilipsREC/test/itkPhilipsRECImageIOPrintTest.cxx index c9e70a3d377..952cfc6cbff 100644 --- a/Modules/IO/PhilipsREC/test/itkPhilipsRECImageIOPrintTest.cxx +++ b/Modules/IO/PhilipsREC/test/itkPhilipsRECImageIOPrintTest.cxx @@ -489,7 +489,7 @@ itkPhilipsRECImageIOPrintTest(int argc, char * argv[]) iter++) { std::cout << "Scanning Sequence " << iter << " ="; - PhilipsRECImageIOType::ImageTypeRescaleValuesContainerType::Pointer rescaleValueVector = + const PhilipsRECImageIOType::ImageTypeRescaleValuesContainerType::Pointer rescaleValueVector = ptrToRescaleValues->ElementAt(iter); for (PhilipsRECImageIOType::ImageTypeRescaleValuesContainerType::ElementIdentifier iter1 = 0; iter1 < rescaleValueVector->Size(); diff --git a/Modules/IO/RAW/include/itkRawImageIO.hxx b/Modules/IO/RAW/include/itkRawImageIO.hxx index 854ee49faa1..7562f7bb8ea 100644 --- a/Modules/IO/RAW/include/itkRawImageIO.hxx +++ b/Modules/IO/RAW/include/itkRawImageIO.hxx @@ -131,7 +131,7 @@ RawImageIO::Read(void * buffer) this->ComputeStrides(); // Offset into file - SizeValueType streamStart = this->GetHeaderSize(); + const SizeValueType streamStart = this->GetHeaderSize(); file.seekg((OffsetValueType)streamStart, std::ios::beg); if (file.fail()) { @@ -165,7 +165,7 @@ template bool RawImageIO::CanWriteFile(const char * fname) { - std::string filename(fname); + const std::string filename(fname); if (filename.empty()) { diff --git a/Modules/IO/RAW/test/itkRawImageIOTest.cxx b/Modules/IO/RAW/test/itkRawImageIOTest.cxx index d96a16392d5..daf0201e57f 100644 --- a/Modules/IO/RAW/test/itkRawImageIOTest.cxx +++ b/Modules/IO/RAW/test/itkRawImageIOTest.cxx @@ -71,7 +71,7 @@ itkRawImageIOTest(int argc, char * argv[]) ITK_TEST_EXPECT_TRUE(io->SupportsDimension(Dimension)); - unsigned long dim = 3; + const unsigned long dim = 3; ITK_TEST_EXPECT_TRUE(!io->SupportsDimension(dim)); // Binary files have no image information to read diff --git a/Modules/IO/RAW/test/itkRawImageIOTest2.cxx b/Modules/IO/RAW/test/itkRawImageIOTest2.cxx index befc5b2fca9..199fd54b096 100644 --- a/Modules/IO/RAW/test/itkRawImageIOTest2.cxx +++ b/Modules/IO/RAW/test/itkRawImageIOTest2.cxx @@ -51,9 +51,9 @@ itkRawImageIOTest2(int argc, char * argv[]) io->SetFileName(argv[1]); io->SetFileDimensionality(3); io->SetNumberOfDimensions(3); - unsigned int dim[3] = { 50, 50, 10 }; - double spacing[3] = { 1.0, 1.0, 1.0 }; - double origin[3] = { 0.0, 0.0, 0.0 }; + const unsigned int dim[3] = { 50, 50, 10 }; + const double spacing[3] = { 1.0, 1.0, 1.0 }; + const double origin[3] = { 0.0, 0.0, 0.0 }; for (unsigned int i = 0; i < 3; ++i) { io->SetDimensions(i, dim[i]); @@ -61,7 +61,7 @@ itkRawImageIOTest2(int argc, char * argv[]) io->SetOrigin(i, origin[i]); } io->SetHeaderSize(0); - unsigned short imageMask = 0x7fff; + const unsigned short imageMask = 0x7fff; io->SetImageMask(imageMask); ITK_TEST_SET_GET_VALUE(imageMask, io->GetImageMask()); diff --git a/Modules/IO/RAW/test/itkRawImageIOTest3.cxx b/Modules/IO/RAW/test/itkRawImageIOTest3.cxx index b70798c13ec..7fe7adf59db 100644 --- a/Modules/IO/RAW/test/itkRawImageIOTest3.cxx +++ b/Modules/IO/RAW/test/itkRawImageIOTest3.cxx @@ -52,8 +52,8 @@ itkRawImageIOTest3(int argc, char * argv[]) size[0] = 517; // prime numbers are good bug testers... size[1] = 293; - ImageType::RegionType region; - ImageType::IndexType index{}; + ImageType::RegionType region; + const ImageType::IndexType index{}; region.SetIndex(index); region.SetSize(size); diff --git a/Modules/IO/RAW/test/itkRawImageIOTest4.cxx b/Modules/IO/RAW/test/itkRawImageIOTest4.cxx index 02f9b73de38..d53942c8568 100644 --- a/Modules/IO/RAW/test/itkRawImageIOTest4.cxx +++ b/Modules/IO/RAW/test/itkRawImageIOTest4.cxx @@ -81,7 +81,7 @@ class RawImageIOReadFileTester { while (!it.IsAtEndOfLine()) { - PixelType readValue = it.Get(); + const PixelType readValue = it.Get(); std::cout << readValue << ' '; if (readValue != value) { @@ -121,8 +121,8 @@ itkRawImageIOTest4(int argc, char * argv[]) using ComponentType = itk::PixelTraits::ValueType; using ByteSwapperType = itk::ByteSwapper; - PixelType value{}; - unsigned int numberOfPixels = dims[0] * dims[1]; + PixelType value{}; + const unsigned int numberOfPixels = dims[0] * dims[1]; // Create the BigEndian binary file diff --git a/Modules/IO/RAW/test/itkRawImageIOTest5.cxx b/Modules/IO/RAW/test/itkRawImageIOTest5.cxx index ccd333ed1e2..641b59b6da8 100644 --- a/Modules/IO/RAW/test/itkRawImageIOTest5.cxx +++ b/Modules/IO/RAW/test/itkRawImageIOTest5.cxx @@ -40,9 +40,9 @@ class RawImageReaderAndWriter { m_Image = ImageType::New(); - typename ImageType::RegionType region; - typename ImageType::SizeType size; - typename ImageType::IndexType start{}; + typename ImageType::RegionType region; + typename ImageType::SizeType size; + const typename ImageType::IndexType start{}; size[0] = 16; // To fill the range of 8 bits image size[1] = 16; @@ -95,9 +95,9 @@ class RawImageReaderAndWriter auto rawImageIO = RawImageIOType::New(); reader->SetImageIO(rawImageIO); - unsigned int dim[2] = { 16, 16 }; - double spacing[2] = { 1.0, 1.0 }; - double origin[2] = { 0.0, 0.0 }; + const unsigned int dim[2] = { 16, 16 }; + const double spacing[2] = { 1.0, 1.0 }; + const double origin[2] = { 0.0, 0.0 }; for (unsigned int i = 0; i < 2; ++i) { @@ -112,7 +112,7 @@ class RawImageReaderAndWriter reader->Update(); - ImageType::ConstPointer image = reader->GetOutput(); + const ImageType::ConstPointer image = reader->GetOutput(); // @@ -173,7 +173,7 @@ itkRawImageIOTest5(int argc, char * argv[]) } - std::string directory = argv[1]; + const std::string directory = argv[1]; // diff --git a/Modules/IO/SpatialObjects/src/itkPolygonGroupSpatialObjectXMLFile.cxx b/Modules/IO/SpatialObjects/src/itkPolygonGroupSpatialObjectXMLFile.cxx index 431cab18b25..74082e9b27e 100644 --- a/Modules/IO/SpatialObjects/src/itkPolygonGroupSpatialObjectXMLFile.cxx +++ b/Modules/IO/SpatialObjects/src/itkPolygonGroupSpatialObjectXMLFile.cxx @@ -78,37 +78,37 @@ PolygonGroupSpatialObjectXMLFileReader::EndElement(const char * name) } else if (itksys::SystemTools::Strucmp(name, "X-SIZE") == 0) { - int size = std::stoi(m_CurCharacterData.c_str()); + const int size = std::stoi(m_CurCharacterData.c_str()); itk::EncapsulateMetaData(thisDic, ROI_X_SIZE, size); } else if (itksys::SystemTools::Strucmp(name, "Y-SIZE") == 0) { - int size = std::stoi(m_CurCharacterData.c_str()); + const int size = std::stoi(m_CurCharacterData.c_str()); itk::EncapsulateMetaData(thisDic, ROI_Y_SIZE, size); } else if (itksys::SystemTools::Strucmp(name, "Z-SIZE") == 0) { - int size = std::stoi(m_CurCharacterData.c_str()); + const int size = std::stoi(m_CurCharacterData.c_str()); itk::EncapsulateMetaData(thisDic, ROI_Z_SIZE, size); } else if (itksys::SystemTools::Strucmp(name, "X-RESOLUTION") == 0) { - float res = std::stod(m_CurCharacterData.c_str()); + const float res = std::stod(m_CurCharacterData.c_str()); itk::EncapsulateMetaData(thisDic, ROI_X_RESOLUTION, res); } else if (itksys::SystemTools::Strucmp(name, "Y-RESOLUTION") == 0) { - float res = std::stod(m_CurCharacterData.c_str()); + const float res = std::stod(m_CurCharacterData.c_str()); itk::EncapsulateMetaData(thisDic, ROI_Y_RESOLUTION, res); } else if (itksys::SystemTools::Strucmp(name, "Z-RESOLUTION") == 0) { - float res = std::stod(m_CurCharacterData.c_str()); + const float res = std::stod(m_CurCharacterData.c_str()); itk::EncapsulateMetaData(thisDic, ROI_Z_RESOLUTION, res); } else if (itksys::SystemTools::Strucmp(name, "NUM-SEGMENTS") == 0) { - int size = std::stoi(m_CurCharacterData.c_str()); + const int size = std::stoi(m_CurCharacterData.c_str()); itk::EncapsulateMetaData(thisDic, ROI_NUM_SEGMENTS, size); } else if (itksys::SystemTools::Strucmp(name, "POINT") == 0) @@ -195,12 +195,12 @@ PolygonGroupSpatialObjectXMLFileWriter::WriteFile() // sanity checks if (m_InputObject == nullptr) { - std::string errmsg("No PolygonGroup to Write"); + const std::string errmsg("No PolygonGroup to Write"); RAISE_EXCEPTION(errmsg); } if (m_Filename.empty()) { - std::string errmsg("No filename given"); + const std::string errmsg("No filename given"); RAISE_EXCEPTION(errmsg); } std::ofstream output(m_Filename.c_str()); diff --git a/Modules/IO/SpatialObjects/test/itkPolygonGroupSpatialObjectXMLFileTest.cxx b/Modules/IO/SpatialObjects/test/itkPolygonGroupSpatialObjectXMLFileTest.cxx index c2af405c404..babf4189101 100644 --- a/Modules/IO/SpatialObjects/test/itkPolygonGroupSpatialObjectXMLFileTest.cxx +++ b/Modules/IO/SpatialObjects/test/itkPolygonGroupSpatialObjectXMLFileTest.cxx @@ -35,7 +35,7 @@ buildPolygonGroup(PolygonGroup3DPointer & PolygonGroup) { for (float z = 0.0; z <= 10.0; z += 1.0) { - itk::PolygonSpatialObject<3>::Pointer strand = itk::PolygonSpatialObject<3>::New(); + const itk::PolygonSpatialObject<3>::Pointer strand = itk::PolygonSpatialObject<3>::New(); strand->SetThicknessInObjectSpace(1.0); // @@ -106,8 +106,8 @@ testPolygonGroupEquivalence(PolygonGroup3DPointer & p1, PolygonGroup3DPointer & delete children2; return EXIT_FAILURE; } - Polygon3DType::PointType curpoint1 = pointIt1->GetPositionInWorldSpace(); - Polygon3DType::PointType curpoint2 = pointIt2->GetPositionInWorldSpace(); + const Polygon3DType::PointType curpoint1 = pointIt1->GetPositionInWorldSpace(); + const Polygon3DType::PointType curpoint2 = pointIt2->GetPositionInWorldSpace(); if (curpoint1 != curpoint2) { // Just a silly test to make sure that the positions returned are valid @@ -163,7 +163,7 @@ itkPolygonGroupSpatialObjectXMLFileTest(int argc, char * argv[]) xmlfilename = xmlfilename + "/PolygonGroupSpatialObjectXMLFileTest.xml"; try { - itk::PolygonGroupSpatialObjectXMLFileWriter::Pointer pw = itk::PolygonGroupSpatialObjectXMLFileWriter::New(); + const itk::PolygonGroupSpatialObjectXMLFileWriter::Pointer pw = itk::PolygonGroupSpatialObjectXMLFileWriter::New(); // ITK_EXERCISE_BASIC_OBJECT_METHODS(pw, PolygonGroupSpatialObjectXMLFileWriter, XMLWriterBase); @@ -182,7 +182,7 @@ itkPolygonGroupSpatialObjectXMLFileTest(int argc, char * argv[]) try { - itk::PolygonGroupSpatialObjectXMLFileReader::Pointer p = itk::PolygonGroupSpatialObjectXMLFileReader::New(); + const itk::PolygonGroupSpatialObjectXMLFileReader::Pointer p = itk::PolygonGroupSpatialObjectXMLFileReader::New(); // ITK_EXERCISE_BASIC_OBJECT_METHODS(p, PolygonGroupSpatialObjectXMLFileReader, XMLReader); diff --git a/Modules/IO/SpatialObjects/test/itkReadVesselTubeSpatialObjectTest.cxx b/Modules/IO/SpatialObjects/test/itkReadVesselTubeSpatialObjectTest.cxx index cd99f98fca3..bb963a5e55b 100644 --- a/Modules/IO/SpatialObjects/test/itkReadVesselTubeSpatialObjectTest.cxx +++ b/Modules/IO/SpatialObjects/test/itkReadVesselTubeSpatialObjectTest.cxx @@ -46,8 +46,8 @@ itkReadVesselTubeSpatialObjectTest(int argc, char * argv[]) return EXIT_FAILURE; } - ReaderType::SpatialObjectPointer soScene = reader->GetOutput(); - const unsigned int numberOfChildren = soScene->GetNumberOfChildren(2); + const ReaderType::SpatialObjectPointer soScene = reader->GetOutput(); + const unsigned int numberOfChildren = soScene->GetNumberOfChildren(2); std::cout << "Number of children: " << numberOfChildren << std::endl; if (numberOfChildren != 2) { diff --git a/Modules/IO/SpatialObjects/test/itkReadWriteSpatialObjectTest.cxx b/Modules/IO/SpatialObjects/test/itkReadWriteSpatialObjectTest.cxx index 892f1b4e32a..915aad787ba 100644 --- a/Modules/IO/SpatialObjects/test/itkReadWriteSpatialObjectTest.cxx +++ b/Modules/IO/SpatialObjects/test/itkReadWriteSpatialObjectTest.cxx @@ -193,7 +193,7 @@ itkReadWriteSpatialObjectTest(int argc, char * argv[]) } /** Create a Tube composed of 3 tubes */ - TubePointer tube1 = TubeType::New(); + const TubePointer tube1 = TubeType::New(); tube1->GetProperty().SetName("Tube 1"); tube1->SetId(1); tube1->SetPoints(list); @@ -212,7 +212,7 @@ itkReadWriteSpatialObjectTest(int argc, char * argv[]) tube3->SetPoints(list3); tube3->Update(); - GroupPointer tubeN1 = GroupType::New(); + const GroupPointer tubeN1 = GroupType::New(); tubeN1->GetProperty().SetName("tube network 1"); tubeN1->SetId(0); tubeN1->AddChild(tube1); @@ -220,34 +220,34 @@ itkReadWriteSpatialObjectTest(int argc, char * argv[]) tubeN1->Update(); - GroupPointer tubeN2 = GroupType::New(); + const GroupPointer tubeN2 = GroupType::New(); tubeN2->SetId(5); tubeN2->GetProperty().SetName("tube network 2"); tubeN2->AddChild(tube3); tubeN2->Update(); - EllipsePointer ellipse = EllipseType::New(); + const EllipsePointer ellipse = EllipseType::New(); ellipse->SetRadiusInObjectSpace(9); ellipse->GetProperty().SetName("ellipse 1"); ellipse->Update(); - BlobPointer blob = BlobType::New(); + const BlobPointer blob = BlobType::New(); blob->SetPoints(list4); blob->GetProperty().SetName("Blob 1"); blob->Update(); - SurfacePointer surface = SurfaceType::New(); + const SurfacePointer surface = SurfaceType::New(); surface->SetPoints(list5); surface->GetProperty().SetName("Surface 1"); surface->Update(); - LinePointer line = LineType::New(); + const LinePointer line = LineType::New(); line->SetPoints(list6); line->GetProperty().SetName("Line 1"); line->Update(); - LandmarkPointer landmark = LandmarkType::New(); + const LandmarkPointer landmark = LandmarkType::New(); landmark->SetPoints(list7); landmark->GetProperty().SetName("Landmark 1"); landmark->Update(); @@ -257,12 +257,12 @@ itkReadWriteSpatialObjectTest(int argc, char * argv[]) using SizeType = itkImageType::SizeType; using RegionType = itkImageType::RegionType; - ImagePointer itkImage = itkImageType::New(); + const ImagePointer itkImage = itkImageType::New(); SizeType size; - unsigned int dim = 3; - double spacing[3]; + const unsigned int dim = 3; + double spacing[3]; for (unsigned int i = 0; i < dim; ++i) { @@ -272,7 +272,7 @@ itkReadWriteSpatialObjectTest(int argc, char * argv[]) RegionType region; region.SetSize(size); - itk::Index<3> zeroIndex{}; + const itk::Index<3> zeroIndex{}; region.SetIndex(zeroIndex); itkImage->SetRegions(region); itkImage->SetSpacing(spacing); @@ -296,7 +296,7 @@ itkReadWriteSpatialObjectTest(int argc, char * argv[]) using itkImageMaskType = ImageMaskType::ImageType; using ImageMaskPointer = itkImageMaskType::Pointer; - ImageMaskPointer itkImageMask = itkImageMaskType::New(); + const ImageMaskPointer itkImageMask = itkImageMaskType::New(); itkImageMask->SetRegions(region); itkImageMask->SetSpacing(spacing); @@ -428,7 +428,7 @@ itkReadWriteSpatialObjectTest(int argc, char * argv[]) reader->Update(); - ReaderType::SpatialObjectPointer myScene = reader->GetOutput(); + const ReaderType::SpatialObjectPointer myScene = reader->GetOutput(); if (!myScene) { @@ -854,7 +854,8 @@ itkReadWriteSpatialObjectTest(int argc, char * argv[]) if (!strcmp((*obj)->GetTypeName().c_str(), "ImageMaskSpatialObject")) { maskFound = true; - itkImageMaskType::ConstPointer constImage = dynamic_cast(obj->GetPointer())->GetImage(); + const itkImageMaskType::ConstPointer constImage = + dynamic_cast(obj->GetPointer())->GetImage(); itk::ImageRegionConstIteratorWithIndex it(constImage, constImage->GetLargestPossibleRegion()); for (unsigned char i = 0; !it.IsAtEnd(); i++, ++it) { diff --git a/Modules/IO/Stimulate/src/itkStimulateImageIO.cxx b/Modules/IO/Stimulate/src/itkStimulateImageIO.cxx index 9b432b2e3e1..3560f5bd28d 100644 --- a/Modules/IO/Stimulate/src/itkStimulateImageIO.cxx +++ b/Modules/IO/Stimulate/src/itkStimulateImageIO.cxx @@ -68,7 +68,7 @@ StimulateImageIO::CanReadFile(const char * filename) return false; } - bool extensionFound = this->HasSupportedReadExtension(filename, false); + const bool extensionFound = this->HasSupportedReadExtension(filename, false); if (!extensionFound) { @@ -252,8 +252,8 @@ StimulateImageIO::InternalReadImageInformation(std::ifstream & file) // to be centered: // save and reset old locale - float origin[4]; - std::locale currentLocale = std::locale::global(std::locale::classic()); + float origin[4]; + const std::locale currentLocale = std::locale::global(std::locale::classic()); sscanf(line, "%*s %f %f %f %f", origin, origin + 1, origin + 2, origin + 3); // reset locale std::locale::global(currentLocale); @@ -278,7 +278,7 @@ StimulateImageIO::InternalReadImageInformation(std::ifstream & file) // specified it is calculated according to: fov = interval * dim // save and reset old locale - std::locale currentLocale = std::locale::global(std::locale::classic()); + const std::locale currentLocale = std::locale::global(std::locale::classic()); sscanf(line, "%*s %f %f %f %f", fov, fov + 1, fov + 2, fov + 3); // reset locale std::locale::global(currentLocale); @@ -293,8 +293,8 @@ StimulateImageIO::InternalReadImageInformation(std::ifstream & file) // calculated according to: interval = fov / dim // save and reset old locale - std::locale currentLocale = std::locale::global(std::locale::classic()); - float spacing[4]; + const std::locale currentLocale = std::locale::global(std::locale::classic()); + float spacing[4]; sscanf(line, "%*s %f %f %f %f", spacing, spacing + 1, spacing + 2, spacing + 3); // reset locale std::locale::global(currentLocale); @@ -348,8 +348,8 @@ StimulateImageIO::InternalReadImageInformation(std::ifstream & file) // low_value and high_value. // save and reset old locale - std::locale currentLocale = std::locale::global(std::locale::classic()); - float range[2]; + const std::locale currentLocale = std::locale::global(std::locale::classic()); + float range[2]; sscanf(line, "%*s %f %f", range, range + 1); // reset locale std::locale::global(currentLocale); @@ -414,10 +414,10 @@ StimulateImageIO::InternalReadImageInformation(std::ifstream & file) // if the data filename has a directory specified, use it as is, // otherwise prepend the path of the .spr file. - std::string datafilenamePath = ::itksys::SystemTools::GetFilenamePath(datafilename); + const std::string datafilenamePath = ::itksys::SystemTools::GetFilenamePath(datafilename); if (datafilenamePath.empty()) { - std::string fileNamePath = ::itksys::SystemTools::GetFilenamePath(m_FileName.c_str()); + const std::string fileNamePath = ::itksys::SystemTools::GetFilenamePath(m_FileName.c_str()); m_DataFileName = fileNamePath + "/" + datafilename; } else @@ -465,7 +465,7 @@ StimulateImageIO::ReadImageInformation() bool StimulateImageIO::CanWriteFile(const char * name) { - std::string filename = name; + const std::string filename = name; if (filename.empty()) { @@ -474,7 +474,7 @@ StimulateImageIO::CanWriteFile(const char * name) } - bool extensionFound = this->HasSupportedWriteExtension(name); + const bool extensionFound = this->HasSupportedWriteExtension(name); if (!extensionFound) { @@ -492,7 +492,7 @@ StimulateImageIO::Write(const void * buffer) this->OpenFileForWriting(file, m_FileName); // Check the image region for proper dimensions, etc. - unsigned int numDims = this->GetNumberOfDimensions(); + const unsigned int numDims = this->GetNumberOfDimensions(); if (numDims < 2 || numDims > 4) { itkExceptionMacro("Stimulate Writer can only write 2,3 or 4-dimensional images"); diff --git a/Modules/IO/Stimulate/test/itkStimulateImageIOTest.cxx b/Modules/IO/Stimulate/test/itkStimulateImageIOTest.cxx index e1283b3fd63..9461c33484d 100644 --- a/Modules/IO/Stimulate/test/itkStimulateImageIOTest.cxx +++ b/Modules/IO/Stimulate/test/itkStimulateImageIOTest.cxx @@ -55,7 +55,7 @@ itkStimulateImageIOTest(int argc, char * argv[]) // Create a mapper (in this case a writer). A mapper // is templated on the input type. // - itk::StimulateImageIO::Pointer sprIO = itk::StimulateImageIO::New(); + const itk::StimulateImageIO::Pointer sprIO = itk::StimulateImageIO::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(sprIO, StimulateImageIO, ImageIOBase); diff --git a/Modules/IO/Stimulate/test/itkStimulateImageIOTest2.cxx b/Modules/IO/Stimulate/test/itkStimulateImageIOTest2.cxx index 299e0381b9b..e8a1d406b98 100644 --- a/Modules/IO/Stimulate/test/itkStimulateImageIOTest2.cxx +++ b/Modules/IO/Stimulate/test/itkStimulateImageIOTest2.cxx @@ -43,7 +43,7 @@ itkStimulateImageIOTest2(int argc, char * argv[]) itk::StimulateImageIO::Pointer io; io = itk::StimulateImageIO::New(); - itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); std::cout << "Filename: " << argv[1] << std::endl; reader->SetFileName(argv[1]); @@ -52,10 +52,10 @@ itkStimulateImageIOTest2(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); - myImage::Pointer image = reader->GetOutput(); + const myImage::Pointer image = reader->GetOutput(); image->Print(std::cout); - myImage::RegionType region = image->GetLargestPossibleRegion(); + const myImage::RegionType region = image->GetLargestPossibleRegion(); std::cout << "region " << region; // This is where we call all of the Get Functions to increase coverage. diff --git a/Modules/IO/TIFF/src/itkTIFFImageIO.cxx b/Modules/IO/TIFF/src/itkTIFFImageIO.cxx index 482ef656bcc..74e1b40ecc7 100644 --- a/Modules/IO/TIFF/src/itkTIFFImageIO.cxx +++ b/Modules/IO/TIFF/src/itkTIFFImageIO.cxx @@ -31,7 +31,7 @@ bool TIFFImageIO::CanReadFile(const char * file) { // First check the filename - std::string filename = file; + const std::string filename = file; if (filename.empty()) { @@ -40,7 +40,7 @@ TIFFImageIO::CanReadFile(const char * file) } // Now check if this is a valid TIFF image - int res = m_InternalImage->Open(file, true); + const int res = m_InternalImage->Open(file, true); if (res) { return true; @@ -461,7 +461,7 @@ TIFFImageIO::ReadImageInformation() this->SetPixelType(IOPixelEnum::RGBA); } - bool isPalette = + const bool isPalette = (this->GetFormat() == TIFFImageIO::PALETTE_GRAYSCALE || this->GetFormat() == TIFFImageIO::PALETTE_RGB) && m_TotalColors > 0; bool isPaletteShortType = false; @@ -540,7 +540,7 @@ TIFFImageIO::ReadImageInformation() bool TIFFImageIO::CanWriteFile(const char * name) { - std::string filename = name; + const std::string filename = name; if (filename.empty()) { @@ -581,9 +581,9 @@ TIFFImageIO::InternalWrite(const void * buffer) pages = static_cast(m_Dimensions[2]); } - auto scomponents = static_cast(this->GetNumberOfComponents()); - double resolution_x{ m_Spacing[0] != 0.0 ? 25.4 / m_Spacing[0] : 0.0 }; - double resolution_y{ m_Spacing[1] != 0.0 ? 25.4 / m_Spacing[1] : 0.0 }; + auto scomponents = static_cast(this->GetNumberOfComponents()); + const double resolution_x{ m_Spacing[0] != 0.0 ? 25.4 / m_Spacing[0] : 0.0 }; + const double resolution_y{ m_Spacing[1] != 0.0 ? 25.4 / m_Spacing[1] : 0.0 }; // rowsperstrip is set to a default value but modified based on the tif scanlinesize before // passing it into the TIFFSetField (see below). auto rowsperstrip = uint32_t{ 0 }; @@ -677,8 +677,8 @@ TIFFImageIO::InternalWrite(const void * buffer) { // if number of scalar components is greater than 3, that means we assume // there is alpha. - uint16_t extra_samples = scomponents - 3; - const auto sample_info = make_unique_for_overwrite(scomponents - 3); + const uint16_t extra_samples = scomponents - 3; + const auto sample_info = make_unique_for_overwrite(scomponents - 3); sample_info[0] = EXTRASAMPLE_ASSOCALPHA; for (uint16_t cc = 1; cc < scomponents - 3; ++cc) { @@ -768,7 +768,7 @@ TIFFImageIO::InternalWrite(const void * buffer) // Rather than change that value in the third party libtiff library, we instead compute the // rowsperstrip here to lead to this same value. #ifdef TIFF_INT64_T // detect if libtiff4 - uint64_t scanlinesize = TIFFScanlineSize64(tif); + uint64_t const scanlinesize = TIFFScanlineSize64(tif); #else tsize_t scanlinesize = TIFFScanlineSize(tif); #endif @@ -901,7 +901,7 @@ TIFFImageIO::CanFindTIFFTag(unsigned int t) itkExceptionMacro("Need to call CanReadFile before"); } - ttag_t tag = t; // 32bits integer + const ttag_t tag = t; // 32bits integer const TIFFField * fld = TIFFFieldWithTag(m_InternalImage->m_Image, tag); @@ -920,8 +920,8 @@ TIFFImageIO::ReadRawByteFromTag(unsigned int t, unsigned int & value_count) { itkExceptionMacro("Need to call CanReadFile before"); } - ttag_t tag = t; - void * raw_data = nullptr; + const ttag_t tag = t; + void * raw_data = nullptr; const TIFFField * fld = TIFFFieldWithTag(m_InternalImage->m_Image, tag); @@ -1000,7 +1000,7 @@ TIFFImageIO::AllocateTiffPalette(uint16_t bps) m_ColorBlue = nullptr; // bpp is 16 at maximum for palette image - tmsize_t array_size = tmsize_t{ 1 } << bps * sizeof(uint16_t); + const tmsize_t array_size = tmsize_t{ 1 } << bps * sizeof(uint16_t); m_ColorRed = static_cast(_TIFFmalloc(array_size)); if (!m_ColorRed) { @@ -1023,7 +1023,7 @@ TIFFImageIO::AllocateTiffPalette(uint16_t bps) itkExceptionMacro("Can't allocate space for Blue channel of component tables."); } // TIFF palette length is fixed for a given bpp - uint64_t TIFFPaletteLength = uint64_t{ 1 } << bps; + const uint64_t TIFFPaletteLength = uint64_t{ 1 } << bps; for (size_t i = 0; i < TIFFPaletteLength; ++i) { if (i < m_ColorPalette.size()) @@ -1072,7 +1072,7 @@ TIFFImageIO::ReadTIFFTags() } raw_data = nullptr; - uint32_t tag = TIFFGetTagListEntry(m_InternalImage->m_Image, i); + const uint32_t tag = TIFFGetTagListEntry(m_InternalImage->m_Image, i); const TIFFField * field = TIFFFieldWithTag(m_InternalImage->m_Image, tag); diff --git a/Modules/IO/TIFF/src/itkTIFFReaderInternal.cxx b/Modules/IO/TIFF/src/itkTIFFReaderInternal.cxx index e8da02800a3..2f14253080b 100644 --- a/Modules/IO/TIFF/src/itkTIFFReaderInternal.cxx +++ b/Modules/IO/TIFF/src/itkTIFFReaderInternal.cxx @@ -106,7 +106,7 @@ TIFFReaderInternal::Open(const char * filename, bool silent) // Macro added in libtiff 4.5.0 #if defined(TIFFLIB_AT_LEAST) - std::unique_ptr options(TIFFOpenOptionsAlloc()); + std::unique_ptr const options(TIFFOpenOptionsAlloc()); TIFFOpenOptionsSetErrorHandlerExtR(options.get(), itkTIFFErrorHandlerExtR, this); TIFFOpenOptionsSetWarningHandlerExtR(options.get(), itkTIFFWarningHandlerExtR, this); if (silent) diff --git a/Modules/IO/TIFF/test/itkLargeTIFFImageWriteReadTest.cxx b/Modules/IO/TIFF/test/itkLargeTIFFImageWriteReadTest.cxx index 09e73f678ba..02d2990baa4 100644 --- a/Modules/IO/TIFF/test/itkLargeTIFFImageWriteReadTest.cxx +++ b/Modules/IO/TIFF/test/itkLargeTIFFImageWriteReadTest.cxx @@ -42,8 +42,8 @@ itkLargeTIFFImageWriteReadTestHelper(std::string filename, typename TImage::Size using SizeValueType = itk::SizeValueType; - typename ImageType::IndexType index{}; - typename ImageType::RegionType region{ index, size }; + const typename ImageType::IndexType index{}; + const typename ImageType::RegionType region{ index, size }; { // Write block auto image = ImageType::New(); @@ -104,7 +104,7 @@ itkLargeTIFFImageWriteReadTestHelper(std::string filename, typename TImage::Size auto reader = ReaderType::New(); reader->SetFileName(filename); - itk::TIFFImageIO::Pointer io = itk::TIFFImageIO::New(); + const itk::TIFFImageIO::Pointer io = itk::TIFFImageIO::New(); reader->SetImageIO(io); itk::TimeProbesCollectorBase chronometer; @@ -112,7 +112,7 @@ itkLargeTIFFImageWriteReadTestHelper(std::string filename, typename TImage::Size ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); chronometer.Stop("Read"); - typename ImageType::ConstPointer readImage = reader->GetOutput(); + const typename ImageType::ConstPointer readImage = reader->GetOutput(); ConstIteratorType ritr(readImage, region); diff --git a/Modules/IO/TIFF/test/itkTIFFImageIOCompressionTest.cxx b/Modules/IO/TIFF/test/itkTIFFImageIOCompressionTest.cxx index 45405d2be04..77bf356a66c 100644 --- a/Modules/IO/TIFF/test/itkTIFFImageIOCompressionTest.cxx +++ b/Modules/IO/TIFF/test/itkTIFFImageIOCompressionTest.cxx @@ -41,7 +41,7 @@ itkTIFFImageIOCompressionTestHelper(int, char * argv[], int JPEGQuality) auto writer = WriterType::New(); - itk::TIFFImageIO::Pointer imageIO = itk::TIFFImageIO::New(); + const itk::TIFFImageIO::Pointer imageIO = itk::TIFFImageIO::New(); ITK_TRY_EXPECT_NO_EXCEPTION(imageIO->SetCompressor("")); ITK_TEST_EXPECT_EQUAL(imageIO->GetCompressor(), ""); @@ -66,13 +66,13 @@ itkTIFFImageIOCompressionTestHelper(int, char * argv[], int JPEGQuality) imageIO->SetCompressionLevel(110); ITK_TEST_EXPECT_EQUAL(imageIO->GetCompressionLevel(), 100); - itk::TIFFImageIO::Pointer io = itk::TIFFImageIO::New(); + const itk::TIFFImageIO::Pointer io = itk::TIFFImageIO::New(); reader->SetFileName(argv[1]); reader->SetImageIO(io); ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); - std::string compression = argv[3]; + const std::string compression = argv[3]; // Write out a compressed version writer->SetInput(reader->GetOutput()); @@ -150,11 +150,11 @@ itkTIFFImageIOCompressionTest(int argc, char * argv[]) JPEGQuality = std::stoi(argv[4]); } - std::string inputFilename = argv[1]; + const std::string inputFilename = argv[1]; using ScalarPixelType = itk::IOComponentEnum; - itk::TIFFImageIO::Pointer imageIO = itk::TIFFImageIO::New(); + const itk::TIFFImageIO::Pointer imageIO = itk::TIFFImageIO::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(imageIO, TIFFImageIO, ImageIOBase); diff --git a/Modules/IO/TIFF/test/itkTIFFImageIOInfoTest.cxx b/Modules/IO/TIFF/test/itkTIFFImageIOInfoTest.cxx index 06789a1372f..8b470477b32 100644 --- a/Modules/IO/TIFF/test/itkTIFFImageIOInfoTest.cxx +++ b/Modules/IO/TIFF/test/itkTIFFImageIOInfoTest.cxx @@ -72,10 +72,10 @@ itkTIFFImageIOInfoTest(int argc, char * argv[]) std::cout << "MetaDataDictionary" << std::endl; while (itr != end) { - itk::MetaDataObjectBase::Pointer entry = itr->second; - const std::string tagkey = itr->first; + const itk::MetaDataObjectBase::Pointer entry = itr->second; + const std::string tagkey = itr->first; - MetaDataStringType::Pointer entryvalue = dynamic_cast(entry.GetPointer()); + const MetaDataStringType::Pointer entryvalue = dynamic_cast(entry.GetPointer()); if (entryvalue) { diff --git a/Modules/IO/TIFF/test/itkTIFFImageIOTest.cxx b/Modules/IO/TIFF/test/itkTIFFImageIOTest.cxx index d9cd1d9cedb..9d88ff00625 100644 --- a/Modules/IO/TIFF/test/itkTIFFImageIOTest.cxx +++ b/Modules/IO/TIFF/test/itkTIFFImageIOTest.cxx @@ -33,7 +33,7 @@ TestMultipleReads(const std::string & fname, TImage *) auto reader = ReaderType::New(); - itk::TIFFImageIO::Pointer io = itk::TIFFImageIO::New(); + const itk::TIFFImageIO::Pointer io = itk::TIFFImageIO::New(); reader->SetFileName(fname.c_str()); reader->SetImageIO(io); @@ -69,7 +69,7 @@ itkTIFFImageIOTestHelper(int, char * argv[]) auto reader = ReaderType::New(); auto writer = WriterType::New(); - itk::TIFFImageIO::Pointer io = itk::TIFFImageIO::New(); + const itk::TIFFImageIO::Pointer io = itk::TIFFImageIO::New(); reader->SetFileName(argv[1]); reader->SetImageIO(io); @@ -79,11 +79,11 @@ itkTIFFImageIOTestHelper(int, char * argv[]) TestMultipleReads(argv[1], nullptr); - typename ImageType::Pointer image = reader->GetOutput(); + const typename ImageType::Pointer image = reader->GetOutput(); image->Print(std::cout); - typename ImageType::RegionType region = image->GetLargestPossibleRegion(); + const typename ImageType::RegionType region = image->GetLargestPossibleRegion(); std::cout << "region " << region << std::endl; // Generate test image @@ -161,7 +161,7 @@ itkTIFFImageIOTest(int argc, char * argv[]) } else if (dimension == 4 && pixelType == 3) { - itk::Image::Pointer dummy; + const itk::Image::Pointer dummy; return itkTIFFImageIOTestHelper>(argc, argv); } else if (dimension == 4 && pixelType == 4) diff --git a/Modules/IO/TIFF/test/itkTIFFImageIOTestPalette.cxx b/Modules/IO/TIFF/test/itkTIFFImageIOTestPalette.cxx index 8413fa3324f..a59c87b554d 100644 --- a/Modules/IO/TIFF/test/itkTIFFImageIOTestPalette.cxx +++ b/Modules/IO/TIFF/test/itkTIFFImageIOTestPalette.cxx @@ -173,10 +173,10 @@ itkTIFFImageIOTestPalette(int argc, char * argv[]) // case not possible here } - ScalarImageType::Pointer inputImage = reader->GetOutput(); + const ScalarImageType::Pointer inputImage = reader->GetOutput(); // test writing palette - bool writePalette = !expandRGBPalette && isPaletteImage; + const bool writePalette = !expandRGBPalette && isPaletteImage; std::cerr << "Trying to write the image as " << ((writePalette) ? "palette" : "expanded palette") << std::endl; ITK_TEST_SET_GET_BOOLEAN(io, WritePalette, writePalette); @@ -237,7 +237,7 @@ itkTIFFImageIOTestPalette(int argc, char * argv[]) } // Exercise other methods - itk::ImageIOBase::SizeType pixelStride = io->GetPixelStride(); + const itk::ImageIOBase::SizeType pixelStride = io->GetPixelStride(); std::cout << "PixelStride: " << itk::NumericTraits::PrintType(pixelStride) << std::endl; // ToDo diff --git a/Modules/IO/TransformBase/src/itkCompositeTransformIOHelper.cxx b/Modules/IO/TransformBase/src/itkCompositeTransformIOHelper.cxx index 891a10ce5f2..333685257ac 100644 --- a/Modules/IO/TransformBase/src/itkCompositeTransformIOHelper.cxx +++ b/Modules/IO/TransformBase/src/itkCompositeTransformIOHelper.cxx @@ -166,8 +166,8 @@ CompositeTransformIOHelperTemplate::BuildTransformList(con const typename CompositeType::TransformQueueType & transforms = composite->GetTransformQueue(); for (auto it = transforms.begin(); it != transforms.end(); ++it) { - const auto * curTransform = static_cast(it->GetPointer()); - ConstTransformPointer curPtr = curTransform; + const auto * curTransform = static_cast(it->GetPointer()); + const ConstTransformPointer curPtr = curTransform; this->m_TransformList.push_back(curPtr); } return 1; diff --git a/Modules/IO/TransformBase/src/itkTransformFileReader.cxx b/Modules/IO/TransformBase/src/itkTransformFileReader.cxx index b1f6c32d34f..ab8a0e82cab 100644 --- a/Modules/IO/TransformBase/src/itkTransformFileReader.cxx +++ b/Modules/IO/TransformBase/src/itkTransformFileReader.cxx @@ -105,7 +105,8 @@ TransformFileReaderTemplate::Update() msg << " File does not exists!"; } - std::list allobjects = ObjectFactoryBase::CreateAllInstance("itkTransformIOBaseTemplate"); + const std::list allobjects = + ObjectFactoryBase::CreateAllInstance("itkTransformIOBaseTemplate"); if (!allobjects.empty()) { @@ -150,8 +151,8 @@ TransformFileReaderTemplate::Update() // need to be initialized using the transform parameters. // kernelTransform->ComputeWMatrix() has to be called after the transform is read but // before the transform is used. - std::string transformTypeName = ioTransformList.front()->GetNameOfClass(); - const size_t len = strlen("KernelTransform"); // Computed at compile time in most cases + const std::string transformTypeName = ioTransformList.front()->GetNameOfClass(); + const size_t len = strlen("KernelTransform"); // Computed at compile time in most cases if (transformTypeName.size() >= len && !transformTypeName.compare(transformTypeName.size() - len, len, "KernelTransform")) { @@ -171,8 +172,8 @@ TransformFileReaderTemplate::Update() const std::string firstTransformName = ioTransformList.front()->GetNameOfClass(); if (firstTransformName.find("CompositeTransform") != std::string::npos) { - typename TransformListType::const_iterator tit = ioTransformList.begin(); - typename TransformType::Pointer composite = tit->GetPointer(); + const typename TransformListType::const_iterator tit = ioTransformList.begin(); + const typename TransformType::Pointer composite = tit->GetPointer(); // CompositeTransformIOHelperTemplate knows how to assign to the composite // transform's internal list diff --git a/Modules/IO/TransformBase/src/itkTransformFileWriterSpecializations.cxx b/Modules/IO/TransformBase/src/itkTransformFileWriterSpecializations.cxx index 8817908c9b2..d740e6dd841 100644 --- a/Modules/IO/TransformBase/src/itkTransformFileWriterSpecializations.cxx +++ b/Modules/IO/TransformBase/src/itkTransformFileWriterSpecializations.cxx @@ -85,7 +85,7 @@ template const typename TransformFileWriterTemplate::TransformType * TransformFileWriterTemplate::GetInput() { - ConstTransformPointer res = m_TransformList.front(); + const ConstTransformPointer res = m_TransformList.front(); return res.GetPointer(); } @@ -130,7 +130,8 @@ TransformFileWriterTemplate::Update() std::ostringstream msg; msg << "Could not create Transform IO object for writing file " << this->GetFileName() << std::endl; - std::list allobjects = ObjectFactoryBase::CreateAllInstance("itkTransformIOBaseTemplate"); + const std::list allobjects = + ObjectFactoryBase::CreateAllInstance("itkTransformIOBaseTemplate"); if (!allobjects.empty()) { @@ -196,8 +197,8 @@ struct TransformIOHelper TransformIOBaseTemplate::CorrectTransformPrecisionType(transformName); // Instantiate the transform - LightObject::Pointer i = ObjectFactoryBase::CreateInstance(transformName.c_str()); - OutputTransformPointer convertedTransform = dynamic_cast(i.GetPointer()); + const LightObject::Pointer i = ObjectFactoryBase::CreateInstance(transformName.c_str()); + OutputTransformPointer convertedTransform = dynamic_cast(i.GetPointer()); if (convertedTransform.IsNull()) { itkGenericExceptionMacro("Could not create an instance of " << transformName); @@ -293,7 +294,7 @@ AddToTransformList(typename TInputTransformType::ConstPointer & tran The first transform of the output transform list should be a composite transform we push back just an empty composite transform as it will be skipped by the outputHelper. */ - OutputTransformPointer outputComposite = IOhelper::CreateNewTypeTransform(transformName); + const OutputTransformPointer outputComposite = IOhelper::CreateNewTypeTransform(transformName); compositeTransformList.push_back(outputComposite); // Now we iterate through input list and convert each sub transform to a new transform with requested precision @@ -306,7 +307,7 @@ AddToTransformList(typename TInputTransformType::ConstPointer & tran // get the input sub transform const InputTransformType * const inSub = it->GetPointer(); // convert each sub transform and push them to the output transform list - std::string inSubName = inSub->GetTransformTypeAsString(); + const std::string inSubName = inSub->GetTransformTypeAsString(); OutputTransformPointer convertedSub = IOhelper::CreateNewTypeTransform(inSubName); IOhelper::SetAllParameters(inSub, convertedSub); // push back the converted sub transform to the composite transform list diff --git a/Modules/IO/TransformBase/src/itkTransformIOBase.cxx b/Modules/IO/TransformBase/src/itkTransformIOBase.cxx index 5c8b8824c01..fe79eb9b2d4 100644 --- a/Modules/IO/TransformBase/src/itkTransformIOBase.cxx +++ b/Modules/IO/TransformBase/src/itkTransformIOBase.cxx @@ -44,7 +44,7 @@ TransformIOBaseTemplate::CreateTransform(TransformPointer // Instantiate the transform itkDebugMacro("About to call ObjectFactory"); - LightObject::Pointer i = ObjectFactoryBase::CreateInstance(ClassName.c_str()); + const LightObject::Pointer i = ObjectFactoryBase::CreateInstance(ClassName.c_str()); itkDebugMacro("After call ObjectFactory"); ptr = dynamic_cast(i.GetPointer()); if (ptr.IsNull()) @@ -54,7 +54,7 @@ TransformIOBaseTemplate::CreateTransform(TransformPointer << "The usual cause of this error is not registering the " << "transform with TransformFactory" << std::endl; msg << "Currently registered Transforms: " << std::endl; - std::list names = theFactory->GetClassOverrideWithNames(); + const std::list names = theFactory->GetClassOverrideWithNames(); for (auto & name : names) { msg << "\t\"" << name << '"' << std::endl; diff --git a/Modules/IO/TransformFactory/include/itkTransformFactoryBase.h b/Modules/IO/TransformFactory/include/itkTransformFactoryBase.h index 729426ba476..cd61f59decb 100644 --- a/Modules/IO/TransformFactory/include/itkTransformFactoryBase.h +++ b/Modules/IO/TransformFactory/include/itkTransformFactoryBase.h @@ -94,7 +94,7 @@ class TransformFactoryBase : public ObjectFactoryBase // Ensure there is only one transform registered by a name, this // may happen on windows where this library is static, and the // global init flag may not be unique. - LightObject::Pointer test = this->CreateInstance(classOverride); + const LightObject::Pointer test = this->CreateInstance(classOverride); if (test.IsNotNull()) { itkDebugMacro("Refusing to register transform \"" << classOverride << "\" again!"); diff --git a/Modules/IO/TransformFactory/src/itkTransformFactoryBase.cxx b/Modules/IO/TransformFactory/src/itkTransformFactoryBase.cxx index 955c3e80694..a598da597f9 100644 --- a/Modules/IO/TransformFactory/src/itkTransformFactoryBase.cxx +++ b/Modules/IO/TransformFactory/src/itkTransformFactoryBase.cxx @@ -98,7 +98,7 @@ TransformFactoryBase::GetFactory() if (m_Factory == nullptr) { // Make and register the factory - Pointer p = New(); + const Pointer p = New(); m_Factory = p.GetPointer(); ObjectFactoryBase::RegisterFactory(p); p->RegisterDefaultTransforms(); diff --git a/Modules/IO/TransformFactory/test/itkTransformFactoryBaseTest.cxx b/Modules/IO/TransformFactory/test/itkTransformFactoryBaseTest.cxx index 2ed64821be9..41d1b0209ab 100644 --- a/Modules/IO/TransformFactory/test/itkTransformFactoryBaseTest.cxx +++ b/Modules/IO/TransformFactory/test/itkTransformFactoryBaseTest.cxx @@ -258,10 +258,10 @@ itkTransformFactoryBaseTest(int, char *[]) } // test other methods - itk::TransformFactoryBase::Pointer base = itk::TransformFactoryBase::New(); - const char * itkVersion = base->GetITKSourceVersion(); - const char * description = base->GetDescription(); - const char * type = base->GetNameOfClass(); + const itk::TransformFactoryBase::Pointer base = itk::TransformFactoryBase::New(); + const char * itkVersion = base->GetITKSourceVersion(); + const char * description = base->GetDescription(); + const char * type = base->GetNameOfClass(); if (strcmp(itkVersion, ITK_SOURCE_VERSION) != 0) { std::cout << "[FAILED] Did not report version correctly" << std::endl; diff --git a/Modules/IO/TransformHDF5/src/itkHDF5TransformIO.cxx b/Modules/IO/TransformHDF5/src/itkHDF5TransformIO.cxx index c1defe3619f..dc5c2769993 100644 --- a/Modules/IO/TransformHDF5/src/itkHDF5TransformIO.cxx +++ b/Modules/IO/TransformHDF5/src/itkHDF5TransformIO.cxx @@ -45,14 +45,14 @@ HDF5TransformIOTemplate::CanReadFile(const char * fileName bool rval = true; try { - htri_t ishdf5 = H5Fis_hdf5(fileName); + const htri_t ishdf5 = H5Fis_hdf5(fileName); if (ishdf5 <= 0) { return false; } - H5::H5File h5file(fileName, H5F_ACC_RDONLY); + const H5::H5File h5file(fileName, H5F_ACC_RDONLY); #if (H5_VERS_MAJOR == 1) && (H5_VERS_MINOR < 10) // check the file has the "TransformGroup" @@ -83,7 +83,7 @@ HDF5TransformIOTemplate::CanWriteFile(const char * fileNam const char * extensions[] = { ".hdf", ".h4", ".hdf4", ".h5", ".hdf5", ".he4", ".he5", ".hd5", nullptr, }; - std::string ext(itksys::SystemTools::GetFilenameLastExtension(fileName)); + const std::string ext(itksys::SystemTools::GetFilenameLastExtension(fileName)); for (unsigned int i = 0; extensions[i] != nullptr; ++i) { if (ext == extensions[i]) @@ -117,8 +117,8 @@ void HDF5TransformIOTemplate::WriteParameters(const std::string & name, const ParametersType & parameters) { - const hsize_t dim(parameters.Size()); - H5::DataSpace paramSpace(1, &dim); + const hsize_t dim(parameters.Size()); + const H5::DataSpace paramSpace(1, &dim); H5::DataSet paramSet; @@ -130,7 +130,7 @@ HDF5TransformIOTemplate::WriteParameters(const std::string // set up properties for chunked, compressed writes. // in this case, set the chunk size to be the N-1 dimension // region - H5::DSetCreatPropList plist; + const H5::DSetCreatPropList plist; plist.setDeflate(5); // Set intermediate compression level constexpr hsize_t oneMegabyte = 1024 * 1024; const hsize_t chunksize = (dim > oneMegabyte) ? oneMegabyte : dim; // Use chunks of 1 MB if large, else use dim @@ -151,9 +151,9 @@ void HDF5TransformIOTemplate::WriteFixedParameters(const std::string & name, const FixedParametersType & fixedParameters) { - const hsize_t dim(fixedParameters.Size()); - H5::DataSpace paramSpace(1, &dim); - H5::DataSet paramSet = this->m_H5File->createDataSet(name, H5::PredType::NATIVE_DOUBLE, paramSpace); + const hsize_t dim(fixedParameters.Size()); + const H5::DataSpace paramSpace(1, &dim); + H5::DataSet paramSet = this->m_H5File->createDataSet(name, H5::PredType::NATIVE_DOUBLE, paramSpace); paramSet.write(fixedParameters.data_block(), H5::PredType::NATIVE_DOUBLE); paramSet.close(); } @@ -179,7 +179,7 @@ HDF5TransformIOTemplate::ReadParameters(const std::string Space.getSimpleExtentDims(&dim, nullptr); ParametersType ParameterArray; ParameterArray.SetSize(dim); - H5::FloatType ParamType = paramSet.getFloatType(); + const H5::FloatType ParamType = paramSet.getFloatType(); if (ParamType.getSize() == sizeof(double)) { @@ -210,8 +210,8 @@ HDF5TransformIOTemplate::ReadFixedParameters(const std::st -> FixedParametersType { - H5::DataSet paramSet = this->m_H5File->openDataSet(DataSetName); - H5T_class_t Type = paramSet.getTypeClass(); + H5::DataSet paramSet = this->m_H5File->openDataSet(DataSetName); + const H5T_class_t Type = paramSet.getTypeClass(); if (Type != H5T_FLOAT) { itkExceptionMacro("Wrong data type for " << DataSetName << "in HDF5 File"); @@ -255,10 +255,10 @@ template void HDF5TransformIOTemplate::WriteString(const std::string & path, const std::string & value) { - hsize_t numStrings(1); - H5::DataSpace strSpace(1, &numStrings); - H5::StrType strType(H5::PredType::C_S1, H5T_VARIABLE); - H5::DataSet strSet = this->m_H5File->createDataSet(path, strType, strSpace); + const hsize_t numStrings(1); + const H5::DataSpace strSpace(1, &numStrings); + const H5::StrType strType(H5::PredType::C_S1, H5T_VARIABLE); + H5::DataSet strSet = this->m_H5File->createDataSet(path, strType, strSpace); strSet.write(value, strType); strSet.close(); } @@ -296,7 +296,7 @@ HDF5TransformIOTemplate::Read() for (unsigned int i = 0; i < transformGroup.getNumObjs(); ++i) { - std::string transformName(GetTransformName(i)); + const std::string transformName(GetTransformName(i)); // open /TransformGroup/N H5::Group currentTransformGroup = this->m_H5File->openGroup(transformName); @@ -304,10 +304,10 @@ HDF5TransformIOTemplate::Read() // read transform type std::string transformType; { - hsize_t numStrings(1); - H5::DataSpace strSpace(1, &numStrings); - H5::StrType typeType(H5::PredType::C_S1, H5T_VARIABLE); - std::string typeName(transformName); + const hsize_t numStrings(1); + const H5::DataSpace strSpace(1, &numStrings); + const H5::StrType typeType(H5::PredType::C_S1, H5T_VARIABLE); + std::string typeName(transformName); typeName += transformTypeName; H5::DataSet typeSet = this->m_H5File->openDataSet(typeName); typeSet.read(transformType, typeType, strSpace); @@ -335,7 +335,7 @@ HDF5TransformIOTemplate::Read() #endif fixedParamsName = transformName + transformFixedNameMisspelled; } - FixedParametersType fixedparams(this->ReadFixedParameters(fixedParamsName)); + const FixedParametersType fixedparams(this->ReadFixedParameters(fixedParamsName)); transform->SetFixedParameters(fixedparams); std::string paramsName(transformName + transformParamsName); @@ -349,7 +349,7 @@ HDF5TransformIOTemplate::Read() #endif paramsName = transformName + transformParamsNameMisspelled; } - ParametersType params = this->ReadParameters(paramsName); + const ParametersType params = this->ReadParameters(paramsName); transform->SetParametersByValue(params); } currentTransformGroup.close(); @@ -369,7 +369,7 @@ void HDF5TransformIOTemplate::WriteOneTransform(const int transformIndex, const TransformType * curTransform) { - std::string transformName(GetTransformName(transformIndex)); + const std::string transformName(GetTransformName(transformIndex)); this->m_H5File->createGroup(transformName); const std::string transformType = curTransform->GetTransformTypeAsString(); // @@ -392,12 +392,12 @@ HDF5TransformIOTemplate::WriteOneTransform(const int { // // write out Fixed Parameters - FixedParametersType FixedtmpArray = curTransform->GetFixedParameters(); - const std::string fixedParamsName(transformName + transformFixedName); + const FixedParametersType FixedtmpArray = curTransform->GetFixedParameters(); + const std::string fixedParamsName(transformName + transformFixedName); this->WriteFixedParameters(fixedParamsName, FixedtmpArray); // parameters - ParametersType tmpArray = curTransform->GetParameters(); - const std::string paramsName(transformName + transformParamsName); + const ParametersType tmpArray = curTransform->GetParameters(); + const std::string paramsName(transformName + transformParamsName); this->WriteParameters(paramsName, tmpArray); } } @@ -410,7 +410,7 @@ HDF5TransformIOTemplate::Write() sysInfo.RunOSCheck(); try { - H5::FileAccPropList fapl; + const H5::FileAccPropList fapl; #if (H5_VERS_MAJOR > 1) || (H5_VERS_MAJOR == 1) && (H5_VERS_MINOR > 10) || \ (H5_VERS_MAJOR == 1) && (H5_VERS_MINOR == 10) && (H5_VERS_RELEASE >= 2) // File format which is backwards compatible with HDF5 version 1.8 @@ -436,7 +436,7 @@ HDF5TransformIOTemplate::Write() { itkExceptionMacro(<< "No transforms to write"); } - std::string compositeTransformType = transformList.front()->GetTransformTypeAsString(); + const std::string compositeTransformType = transformList.front()->GetTransformTypeAsString(); CompositeTransformIOHelperTemplate helper; // @@ -448,7 +448,7 @@ HDF5TransformIOTemplate::Write() transformList = helper.GetTransformList(transformList.front().GetPointer()); } - typename ConstTransformListType::const_iterator end = transformList.end(); + const typename ConstTransformListType::const_iterator end = transformList.end(); int count = 0; diff --git a/Modules/IO/TransformHDF5/test/itkIOTransformHDF5Test.cxx b/Modules/IO/TransformHDF5/test/itkIOTransformHDF5Test.cxx index a30d2aa193c..78fdaa563cd 100644 --- a/Modules/IO/TransformHDF5/test/itkIOTransformHDF5Test.cxx +++ b/Modules/IO/TransformHDF5/test/itkIOTransformHDF5Test.cxx @@ -49,10 +49,10 @@ ReadWriteTest(const std::string fileName, const bool isRealDisplacementField, co using FieldType = typename DisplacementTransformType::DisplacementFieldType; auto knownField = FieldType::New(); // This is based on itk::Image { - constexpr int dimLength = 20; - auto size = FieldType::SizeType::Filled(dimLength); - typename FieldType::IndexType start{}; - typename FieldType::RegionType region{ start, size }; + constexpr int dimLength = 20; + auto size = FieldType::SizeType::Filled(dimLength); + const typename FieldType::IndexType start{}; + const typename FieldType::RegionType region{ start, size }; knownField->SetRegions(region); auto spacing = itk::MakeFilled(requiredSpacing); @@ -130,7 +130,7 @@ ReadWriteTest(const std::string fileName, const bool isRealDisplacementField, co // Read first transform const typename itk::TransformFileReaderTemplate::TransformListType * list = reader->GetTransformList(); - typename DisplacementTransformType::ConstPointer readDisplacementTransform = + const typename DisplacementTransformType::ConstPointer readDisplacementTransform = static_cast((*(list->begin())).GetPointer()); if (readDisplacementTransform.IsNull()) { @@ -139,7 +139,7 @@ ReadWriteTest(const std::string fileName, const bool isRealDisplacementField, co std::cerr << typeid(DisplacementTransformType).name() << std::endl; return EXIT_FAILURE; } - typename DisplacementTransformType::DisplacementFieldType::ConstPointer readDisplacement = + const typename DisplacementTransformType::DisplacementFieldType::ConstPointer readDisplacement = readDisplacementTransform->GetDisplacementField(); if (readDisplacement.IsNull()) { @@ -200,10 +200,10 @@ oneTest(const std::string goodname, const std::string badname, const bool useCom } affine->SetFixedParameters(p); } - typename itk::TransformFileWriterTemplate::Pointer writer = + const typename itk::TransformFileWriterTemplate::Pointer writer = itk::TransformFileWriterTemplate::New(); writer->SetUseCompression(useCompression); - typename itk::TransformFileReaderTemplate::Pointer reader = + const typename itk::TransformFileReaderTemplate::Pointer reader = itk::TransformFileReaderTemplate::New(); writer->AddTransform(affine); @@ -271,10 +271,10 @@ oneTest(const std::string goodname, const std::string badname, const bool useCom } Bogus->SetFixedParameters(p); } - typename itk::TransformFileWriterTemplate::Pointer badwriter = + const typename itk::TransformFileWriterTemplate::Pointer badwriter = itk::TransformFileWriterTemplate::New(); badwriter->SetUseCompression(useCompression); - typename itk::TransformFileReaderTemplate::Pointer badreader = + const typename itk::TransformFileReaderTemplate::Pointer badreader = itk::TransformFileReaderTemplate::New(); badwriter->AddTransform(Bogus); badwriter->SetFileName(badname); diff --git a/Modules/IO/TransformHDF5/test/itkThinPlateTransformWriteReadTest.cxx b/Modules/IO/TransformHDF5/test/itkThinPlateTransformWriteReadTest.cxx index ee51e8a9b8f..c040b87d2a8 100644 --- a/Modules/IO/TransformHDF5/test/itkThinPlateTransformWriteReadTest.cxx +++ b/Modules/IO/TransformHDF5/test/itkThinPlateTransformWriteReadTest.cxx @@ -173,11 +173,11 @@ itkThinPlateTransformWriteReadTest(int argc, char * argv[]) itk::ObjectFactoryBase::RegisterFactory(itk::HDF5TransformIOFactory::New()); // Run tests - int resultEBS = ReadWriteTest("ElasticBodySplineKernelTransform_double_2.h5"); - int resultEBRS = ReadWriteTest("ElasticBodyReciprocalSplineKernelTransform_double_2.h5"); - int resultTPS = ReadWriteTest("ThinPlateSplineKernelTransform_double_2.h5"); - int resultTPR2 = ReadWriteTest("ThinPlateR2LogRSplineKernelTransform_double_2.h5"); - int resultVS = ReadWriteTest("VolumeSplineKernelTransform_double_2.h5"); + const int resultEBS = ReadWriteTest("ElasticBodySplineKernelTransform_double_2.h5"); + const int resultEBRS = ReadWriteTest("ElasticBodyReciprocalSplineKernelTransform_double_2.h5"); + const int resultTPS = ReadWriteTest("ThinPlateSplineKernelTransform_double_2.h5"); + const int resultTPR2 = ReadWriteTest("ThinPlateR2LogRSplineKernelTransform_double_2.h5"); + const int resultVS = ReadWriteTest("VolumeSplineKernelTransform_double_2.h5"); // Check results if (resultEBS != EXIT_SUCCESS || resultEBRS != EXIT_SUCCESS || resultTPS != EXIT_SUCCESS || diff --git a/Modules/IO/TransformInsightLegacy/src/itkTxtTransformIO.cxx b/Modules/IO/TransformInsightLegacy/src/itkTxtTransformIO.cxx index bfa1151ba72..acc370ba572 100644 --- a/Modules/IO/TransformInsightLegacy/src/itkTxtTransformIO.cxx +++ b/Modules/IO/TransformInsightLegacy/src/itkTxtTransformIO.cxx @@ -89,11 +89,11 @@ TxtTransformIOTemplate::ReadComponentFile(std::string Valu * into a CompositeTransform. * The component filenames are listed w/out paths, and are expected * to be in the same path as the master file. */ - std::string filePath = itksys::SystemTools::GetFilenamePath(this->GetFileName()) + "/"; + const std::string filePath = itksys::SystemTools::GetFilenamePath(this->GetFileName()) + "/"; /* Use TransformFileReader to read each component file. */ - auto reader = TransformFileReaderTemplate::New(); - std::string componentFullPath = filePath + Value; + auto reader = TransformFileReaderTemplate::New(); + const std::string componentFullPath = filePath + Value; reader->SetFileName(componentFullPath); try { @@ -103,7 +103,7 @@ TxtTransformIOTemplate::ReadComponentFile(std::string Valu { itkExceptionMacro("Error reading component file: " << Value << std::endl << ex); } - TransformPointer transform = reader->GetTransformList()->front().GetPointer(); + const TransformPointer transform = reader->GetTransformList()->front().GetPointer(); this->GetReadTransformList().push_back(transform); } @@ -158,8 +158,8 @@ TxtTransformIOTemplate::Read() // Throw an error itkExceptionMacro("Tags must be delimited by :"); } - std::string Name = trim(line.substr(0, end)); - std::string Value = trim(line.substr(end + 1, line.length())); + const std::string Name = trim(line.substr(0, end)); + std::string Value = trim(line.substr(end + 1, line.length())); // Push back itkDebugMacro("Name: \"" << Name << '"'); itkDebugMacro("Value: \"" << Value << '"'); @@ -274,7 +274,7 @@ TxtTransformIOTemplate::Write() } int count = 0; - typename ConstTransformListType::const_iterator end = transformList.end(); + const typename ConstTransformListType::const_iterator end = transformList.end(); for (typename ConstTransformListType::const_iterator it = transformList.begin(); it != end; ++it, ++count) { @@ -294,13 +294,13 @@ TxtTransformIOTemplate::Write() else { { - vnl_vector TempArray = (*it)->GetParameters(); + const vnl_vector TempArray = (*it)->GetParameters(); out << "Parameters: "; // << TempArray << std::endl; itk_impl_details::print_vector(out, TempArray); out << std::endl; } { - vnl_vector FixedTempArray = (*it)->GetFixedParameters(); + const vnl_vector FixedTempArray = (*it)->GetFixedParameters(); out << "FixedParameters: "; // << FixedTempArray << std::endl; itk_impl_details::print_vector(out, FixedTempArray); out << std::endl; diff --git a/Modules/IO/TransformInsightLegacy/test/itkIOEuler3DTransformTxtTest.cxx b/Modules/IO/TransformInsightLegacy/test/itkIOEuler3DTransformTxtTest.cxx index 13a467bebc1..f769ef1487f 100644 --- a/Modules/IO/TransformInsightLegacy/test/itkIOEuler3DTransformTxtTest.cxx +++ b/Modules/IO/TransformInsightLegacy/test/itkIOEuler3DTransformTxtTest.cxx @@ -45,7 +45,7 @@ itkIOEuler3DTransformTxtTest(int argc, char * argv[]) // read old style format in reader->SetFileName(argv[1]); reader->Update(); - TransformType::Pointer oldStyleInput = + const TransformType::Pointer oldStyleInput = static_cast((reader->GetTransformList()->begin())->GetPointer()); // modify the interpretation of the Euler angles @@ -59,7 +59,7 @@ itkIOEuler3DTransformTxtTest(int argc, char * argv[]) // read new style format back in reader->SetFileName(argv[2]); reader->Update(); - TransformType::Pointer newStyleInput = + const TransformType::Pointer newStyleInput = static_cast((reader->GetTransformList()->begin())->GetPointer()); const TransformType::MatrixType & oldStyleMat = oldStyleInput->GetMatrix(); diff --git a/Modules/IO/TransformInsightLegacy/test/itkIOTransformTxtTest.cxx b/Modules/IO/TransformInsightLegacy/test/itkIOTransformTxtTest.cxx index f84be1f0f0d..4c850786f42 100644 --- a/Modules/IO/TransformInsightLegacy/test/itkIOTransformTxtTest.cxx +++ b/Modules/IO/TransformInsightLegacy/test/itkIOTransformTxtTest.cxx @@ -245,7 +245,7 @@ templatelessTest(const std::string & outputDirectory) using TransformType = itk::Rigid2DTransform; auto transform = TransformType::New(); - itk::TransformFileWriter::Pointer writer = itk::TransformFileWriter::New(); + const itk::TransformFileWriter::Pointer writer = itk::TransformFileWriter::New(); writer->SetInput(transform); writer->SetFileName(outputFile); ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update()); diff --git a/Modules/IO/TransformMatlab/src/itkMatlabTransformIO.cxx b/Modules/IO/TransformMatlab/src/itkMatlabTransformIO.cxx index 2dc663c5f2f..1d15346d5b2 100644 --- a/Modules/IO/TransformMatlab/src/itkMatlabTransformIO.cxx +++ b/Modules/IO/TransformMatlab/src/itkMatlabTransformIO.cxx @@ -131,7 +131,7 @@ MatlabTransformIOTemplate::Write() this->OpenStream(out, true); while (it != this->GetWriteTransformList().end()) { - std::string xfrmType((*it)->GetTransformTypeAsString()); + const std::string xfrmType((*it)->GetTransformTypeAsString()); TempArray = (*it)->GetParameters(); vnl_matlab_write(out, TempArray.begin(), TempArray.size(), xfrmType.c_str()); TempArray = (*it)->GetFixedParameters(); diff --git a/Modules/IO/TransformMatlab/test/itkIOTransformMatlabTest.cxx b/Modules/IO/TransformMatlab/test/itkIOTransformMatlabTest.cxx index 90d7e7dcfe5..f1da433d5ce 100644 --- a/Modules/IO/TransformMatlab/test/itkIOTransformMatlabTest.cxx +++ b/Modules/IO/TransformMatlab/test/itkIOTransformMatlabTest.cxx @@ -259,13 +259,13 @@ itkIOTransformMatlabTest(int argc, char * argv[]) itksys::SystemTools::ChangeDirectory(argv[1]); } - int result1 = oneTest("Transforms_float.mat", "TransformsBad_float.mat"); - int result2 = secondTest(); + const int result1 = oneTest("Transforms_float.mat", "TransformsBad_float.mat"); + const int result2 = secondTest(); - int result3 = oneTest("Transforms_double.mat", "TransformsBad_double.mat"); - int result4 = secondTest(); + const int result3 = oneTest("Transforms_double.mat", "TransformsBad_double.mat"); + const int result4 = secondTest(); - int result5 = thirdTest(); + const int result5 = thirdTest(); return ((!(result1 == EXIT_SUCCESS && result2 == EXIT_SUCCESS)) && (!(result3 == EXIT_SUCCESS && result4 == EXIT_SUCCESS)) && (!(result5 == EXIT_SUCCESS))); diff --git a/Modules/IO/VTK/src/itkVTKImageIO.cxx b/Modules/IO/VTK/src/itkVTKImageIO.cxx index d8be6385316..f714fb41ad1 100644 --- a/Modules/IO/VTK/src/itkVTKImageIO.cxx +++ b/Modules/IO/VTK/src/itkVTKImageIO.cxx @@ -128,7 +128,7 @@ VTKImageIO::CanStreamWrite() void VTKImageIO::SetPixelTypeFromString(const std::string & pixelType) { - IOComponentEnum compType = GetComponentTypeFromString(pixelType); + const IOComponentEnum compType = GetComponentTypeFromString(pixelType); if (compType == IOComponentEnum::UNKNOWNCOMPONENTTYPE) { if (pixelType.find("vtktypeuint64") < pixelType.length()) @@ -239,7 +239,7 @@ VTKImageIO::InternalReadImageInformation(std::ifstream & file) { double spacing[3]; // save and reset old locale - std::locale currentLocale = std::locale::global(std::locale::classic()); + const std::locale currentLocale = std::locale::global(std::locale::classic()); sscanf(text.c_str(), "%*s %lf %lf %lf", spacing, spacing + 1, spacing + 2); // reset locale std::locale::global(currentLocale); @@ -253,7 +253,7 @@ VTKImageIO::InternalReadImageInformation(std::ifstream & file) { double origin[3]; // save and reset old locale - std::locale currentLocale = std::locale::global(std::locale::classic()); + const std::locale currentLocale = std::locale::global(std::locale::classic()); sscanf(text.c_str(), "%*s %lf %lf %lf", origin, origin + 1, origin + 2); // reset locale std::locale::global(currentLocale); @@ -331,7 +331,7 @@ VTKImageIO::InternalReadImageInformation(std::ifstream & file) this->SetNumberOfComponents(numComp); // maybe "LOOKUP_TABLE default" - std::streampos pos = file.tellg(); + const std::streampos pos = file.tellg(); this->GetNextLine(file, text); if (!(text.find("lookup_table") < text.length())) @@ -387,7 +387,7 @@ VTKImageIO::ReadHeaderSize(std::ifstream & file) readAttribute = true; // maybe "LOOKUP_TABLE default" - std::streampos pos = file.tellg(); + const std::streampos pos = file.tellg(); this->GetNextLine(file, text); if (!(text.find("lookup_table") < text.length())) @@ -498,7 +498,7 @@ VTKImageIO::ReadSymmetricTensorBufferAsBinary(std::istream & is, void * buffer, { std::streamsize bytesRemaining = num; const SizeType componentSize = this->GetComponentSize(); - SizeType pixelSize = componentSize * 6; + const SizeType pixelSize = componentSize * 6; if (this->GetNumberOfComponents() != 6) { @@ -576,7 +576,7 @@ VTKImageIO::Read(void * buffer) } // seek pass the header - std::streampos dataPos = static_cast(this->GetHeaderSize()); + const std::streampos dataPos = static_cast(this->GetHeaderSize()); file.seekg(dataPos, std::ios::beg); // We are positioned at the data. The data is read depending on whether @@ -640,7 +640,7 @@ VTKImageIO::WriteImageInformation(const void * itkNotUsed(buffer)) this->OpenFileForWriting(file, m_FileName, true); // Check the image region for proper dimensions, etc. - unsigned int numDims = this->GetNumberOfDimensions(); + const unsigned int numDims = this->GetNumberOfDimensions(); if (numDims < 1 || numDims > 3) { itkExceptionMacro("VTK Writer can only write 1, 2 or 3-dimensional images"); @@ -724,8 +724,8 @@ WriteTensorBuffer(std::ostream & os, ImageIOBase::SizeType i = 0; if (components == 3) { - PrintType zero(TComponent{}); - PrintType e12; + const PrintType zero(TComponent{}); + PrintType e12; while (i < num) { // row 1 @@ -943,7 +943,7 @@ VTKImageIO::Write(const void * buffer) // write one byte at the end of the file to allocate (this is a // nifty trick which should not write the entire size of the file // just allocate it, if the system supports sparse files) - std::streampos seekPos = this->GetImageSizeInBytes() + this->GetHeaderSize() - 1; + const std::streampos seekPos = this->GetImageSizeInBytes() + this->GetHeaderSize() - 1; file.seekp(seekPos, std::ios::cur); file.write("\0", 1); file.seekp(0); @@ -995,7 +995,7 @@ VTKImageIO::Write(const void * buffer) itkAssertOrThrowMacro(this->GetHeaderSize() != 0, "Header size is unknown when it shouldn't be!"); // seek pass the header - std::streampos dataPos = static_cast(this->GetHeaderSize()); + const std::streampos dataPos = static_cast(this->GetHeaderSize()); file.seekp(dataPos, std::ios::beg); if (file.fail()) diff --git a/Modules/IO/VTK/test/itkVTKImageIO2Test.cxx b/Modules/IO/VTK/test/itkVTKImageIO2Test.cxx index eb5b4caa1fd..90494b2f56f 100644 --- a/Modules/IO/VTK/test/itkVTKImageIO2Test.cxx +++ b/Modules/IO/VTK/test/itkVTKImageIO2Test.cxx @@ -130,7 +130,7 @@ class VTKImageIOTester writer->SetInput(image); - std::string m_OutputFileName = VTKImageIOTester::SetupFileName(filePrefix, "vtk", outputPath); + const std::string m_OutputFileName = VTKImageIOTester::SetupFileName(filePrefix, "vtk", outputPath); writer->SetFileName(m_OutputFileName); writer->Update(); @@ -177,7 +177,7 @@ class VTKImageIOTester vtkIO->SetFileTypeToBinary(); } - std::string m_OutputFileName = VTKImageIOTester::SetupFileName(filePrefix, "vtk", outputPath); + const std::string m_OutputFileName = VTKImageIOTester::SetupFileName(filePrefix, "vtk", outputPath); reader->SetFileName(m_OutputFileName); // Check that the correct content was written to the header. @@ -192,7 +192,7 @@ class VTKImageIOTester } // read the image - typename ImageType::Pointer image = reader->GetOutput(); + const typename ImageType::Pointer image = reader->GetOutput(); reader->Update(); // test the CanReadFile function after the fact (should always @@ -203,9 +203,9 @@ class VTKImageIOTester } // check the size - typename ImageType::RegionType region = image->GetLargestPossibleRegion(); - typename ImageType::SizeType size = region.GetSize(); - bool sizeGood = true; + const typename ImageType::RegionType region = image->GetLargestPossibleRegion(); + typename ImageType::SizeType size = region.GetSize(); + bool sizeGood = true; for (unsigned int i = 0; i < ImageType::GetImageDimension(); ++i) { if (size[i] != 10) @@ -283,7 +283,7 @@ class VTKImageIOTester using IOType = itk::VTKImageIO; auto vtkIO = IOType::New(); - std::string fileName = VTKImageIOTester::SetupFileName(filePrefix, fileExtension, outputPath); + const std::string fileName = VTKImageIOTester::SetupFileName(filePrefix, fileExtension, outputPath); return vtkIO->CanReadFile(fileName.c_str()); } @@ -294,7 +294,7 @@ class VTKImageIOTester using IOType = itk::VTKImageIO; auto vtkIO = IOType::New(); - std::string fileName = VTKImageIOTester::SetupFileName(filePrefix, fileExtension, outputPath); + const std::string fileName = VTKImageIOTester::SetupFileName(filePrefix, fileExtension, outputPath); return vtkIO->CanWriteFile(fileName.c_str()); } @@ -357,8 +357,8 @@ itkVTKImageIO2Test(int argc, char * argv[]) return EXIT_FAILURE; } - std::string filePrefix = argv[0]; - std::string outputPath = argv[1]; + const std::string filePrefix = argv[0]; + std::string outputPath = argv[1]; // // test all usable pixel types diff --git a/Modules/IO/VTK/test/itkVTKImageIO2Test2.cxx b/Modules/IO/VTK/test/itkVTKImageIO2Test2.cxx index 699d632a4e6..fa22d81f532 100644 --- a/Modules/IO/VTK/test/itkVTKImageIO2Test2.cxx +++ b/Modules/IO/VTK/test/itkVTKImageIO2Test2.cxx @@ -40,7 +40,7 @@ itkVTKImageIO2Test2(int argc, char * argv[]) return EXIT_FAILURE; } - std::string outputFileName = argv[1]; + const std::string outputFileName = argv[1]; using PixelType = itk::SymmetricSecondRankTensor; using ImageType = itk::Image; diff --git a/Modules/IO/VTK/test/itkVTKImageIOStreamTest.cxx b/Modules/IO/VTK/test/itkVTKImageIOStreamTest.cxx index 6ad17651aba..104c8eb2f0e 100644 --- a/Modules/IO/VTK/test/itkVTKImageIOStreamTest.cxx +++ b/Modules/IO/VTK/test/itkVTKImageIOStreamTest.cxx @@ -137,8 +137,8 @@ TestStreamWrite(char * file1, unsigned int numberOfStreams = 0) constValueImageSource->SetValue(static_cast(23)); constValueImageSource->SetSize(size); - typename ImageType::SpacingValueType spacing[3] = { 5.0f, 10.0f, 15.0f }; - typename ImageType::PointValueType origin[3] = { -5.0f, -10.0f, -15.0f }; + typename ImageType::SpacingValueType spacing[3] = { 5.0f, 10.0f, 15.0f }; + const typename ImageType::PointValueType origin[3] = { -5.0f, -10.0f, -15.0f }; constValueImageSource->SetSpacing(spacing); constValueImageSource->SetOrigin(origin); @@ -171,9 +171,9 @@ TestStreamWrite(char * file1, unsigned int numberOfStreams = 0) consValueImage->SetRequestedRegion(consValueImage->GetLargestPossibleRegion()); consValueImage->Update(); reader->Update(); - bool imagesEqual = ImagesEqual(consValueImage, reader->GetOutput()); + const bool imagesEqual = ImagesEqual(consValueImage, reader->GetOutput()); - std::string componentType = itk::ImageIOBase::GetComponentTypeAsString(vtkIO->GetComponentType()); + const std::string componentType = itk::ImageIOBase::GetComponentTypeAsString(vtkIO->GetComponentType()); if (!imagesEqual) { @@ -209,8 +209,8 @@ TestStreamRead(char * file1, unsigned int numberOfStreams = 0) constValueImageSource->SetValue(static_cast(23)); constValueImageSource->SetSize(size); - typename ImageType::SpacingValueType spacing[3] = { 5.0f, 10.0f, 15.0f }; - typename ImageType::PointValueType origin[3] = { -5.0f, -10.0f, -15.0f }; + typename ImageType::SpacingValueType spacing[3] = { 5.0f, 10.0f, 15.0f }; + const typename ImageType::PointValueType origin[3] = { -5.0f, -10.0f, -15.0f }; constValueImageSource->SetSpacing(spacing); constValueImageSource->SetOrigin(origin); @@ -243,8 +243,8 @@ TestStreamRead(char * file1, unsigned int numberOfStreams = 0) // Simulate streaming and compares regions numberOfStreams = std::clamp(numberOfStreams, 1u, static_cast(size[TDimension - 1])); - typename ImageType::SizeValueType width = (size[TDimension - 1] + numberOfStreams - 1) / numberOfStreams; - typename ImageType::RegionType totalRegion = consValueImage->GetLargestPossibleRegion(); + const typename ImageType::SizeValueType width = (size[TDimension - 1] + numberOfStreams - 1) / numberOfStreams; + const typename ImageType::RegionType totalRegion = consValueImage->GetLargestPossibleRegion(); ImageType * readImage = reader->GetOutput(); consValueImage->SetRequestedRegion(totalRegion); @@ -268,7 +268,7 @@ TestStreamRead(char * file1, unsigned int numberOfStreams = 0) } } - std::string componentType = itk::ImageIOBase::GetComponentTypeAsString(vtkIO->GetComponentType()); + const std::string componentType = itk::ImageIOBase::GetComponentTypeAsString(vtkIO->GetComponentType()); if (!imagesEqual) { @@ -293,8 +293,8 @@ itkVTKImageIOStreamTest(int argc, char * argv[]) return EXIT_FAILURE; } - unsigned int numberOfStreams = 2; - int status = 0; + const unsigned int numberOfStreams = 2; + int status = 0; #define ReadWriteTestMACRO(scalarType) \ status += TestStreamWrite(argv[1], 0); \ diff --git a/Modules/IO/VTK/test/itkVTKImageIOTest3.cxx b/Modules/IO/VTK/test/itkVTKImageIOTest3.cxx index 0f15e078e10..5115e0a34ac 100644 --- a/Modules/IO/VTK/test/itkVTKImageIOTest3.cxx +++ b/Modules/IO/VTK/test/itkVTKImageIOTest3.cxx @@ -36,7 +36,7 @@ itkVTKImageIOTest3(int argc, char * argv[]) } - itk::VTKImageIO::Pointer vtkImageIO = itk::VTKImageIO::New(); + const itk::VTKImageIO::Pointer vtkImageIO = itk::VTKImageIO::New(); // Ensure that the ImageIO does not claim to read a .vtk file with PolyData ITK_TEST_EXPECT_EQUAL(vtkImageIO->CanReadFile(argv[1]), false); diff --git a/Modules/IO/XML/include/itkDOMReader.hxx b/Modules/IO/XML/include/itkDOMReader.hxx index d0a76c22e3a..b387538d423 100644 --- a/Modules/IO/XML/include/itkDOMReader.hxx +++ b/Modules/IO/XML/include/itkDOMReader.hxx @@ -92,8 +92,8 @@ DOMReader::Update(const DOMNodeType * inputdom, const void * userdata) this->GetLogger()->SetName(this->GetNameOfClass()); // variable/info needed for logging - FancyString info; - FancyString tagname = inputdom->GetName(); + FancyString info; + const FancyString tagname = inputdom->GetName(); // log start of reading info << ClearContent << "Reading \"" << tagname << "\" ...\n"; @@ -122,11 +122,11 @@ DOMReader::Update() // create the intermediate DOM object if it is not set if (this->m_IntermediateDOM.IsNull()) { - DOMNodePointer node = DOMNodeType::New(); + const DOMNodePointer node = DOMNodeType::New(); this->SetIntermediateDOM(node); } - FancyString fn(this->m_FileName); + const FancyString fn(this->m_FileName); // remove previous data from the DOM object this->m_IntermediateDOM->RemoveAllAttributesAndChildren(); @@ -138,8 +138,8 @@ DOMReader::Update() reader->Update(); // save the current working directory (WD), and change the WD to where the XML file is located - FancyString sOldWorkingDir = itksys::SystemTools::GetCurrentWorkingDirectory(); - FancyString sNewWorkingDir = itksys::SystemTools::GetFilenamePath(fn); + const FancyString sOldWorkingDir = itksys::SystemTools::GetCurrentWorkingDirectory(); + const FancyString sNewWorkingDir = itksys::SystemTools::GetFilenamePath(fn); itksys::SystemTools::ChangeDirectory(sNewWorkingDir); this->Update(this->m_IntermediateDOM); diff --git a/Modules/IO/XML/include/itkDOMWriter.hxx b/Modules/IO/XML/include/itkDOMWriter.hxx index d8763e67ba7..10f56ab369d 100644 --- a/Modules/IO/XML/include/itkDOMWriter.hxx +++ b/Modules/IO/XML/include/itkDOMWriter.hxx @@ -90,8 +90,8 @@ DOMWriter::Update(DOMNodeType * outputdom, const void * userdata) this->GetLogger()->SetName(this->GetNameOfClass()); // variable/info needed for logging - FancyString info; - FancyString objname = this->GetInput()->GetNameOfClass(); + FancyString info; + const FancyString objname = this->GetInput()->GetNameOfClass(); // log start of writing info << ClearContent << "Writing \"" << objname << "\" ...\n"; @@ -118,15 +118,15 @@ DOMWriter::Update() this->SetIntermediateDOM(temp); } - FancyString fn(this->m_FileName); + const FancyString fn(this->m_FileName); // create the output file if necessary // this is to make sure that the output directory is created if it does exist FileTools::CreateFile(fn); // save the current working directory (WD), and change the WD to where the XML file is located - FancyString sOldWorkingDir = itksys::SystemTools::GetCurrentWorkingDirectory(); - FancyString sNewWorkingDir = itksys::SystemTools::GetFilenamePath(fn); + const FancyString sOldWorkingDir = itksys::SystemTools::GetCurrentWorkingDirectory(); + const FancyString sNewWorkingDir = itksys::SystemTools::GetFilenamePath(fn); itksys::SystemTools::ChangeDirectory(sNewWorkingDir); this->Update(this->m_IntermediateDOM); diff --git a/Modules/IO/XML/include/itkFileTools.h b/Modules/IO/XML/include/itkFileTools.h index 4978ccda80c..84680c9c117 100644 --- a/Modules/IO/XML/include/itkFileTools.h +++ b/Modules/IO/XML/include/itkFileTools.h @@ -95,7 +95,7 @@ FileTools::CreateFile(const std::string & fn) } // make sure the directory exists - std::string dir = itksys::SystemTools::GetFilenamePath(fn.c_str()); + const std::string dir = itksys::SystemTools::GetFilenamePath(fn.c_str()); FileTools::CreateDirectory(dir); // create the file diff --git a/Modules/IO/XML/src/itkDOMNode.cxx b/Modules/IO/XML/src/itkDOMNode.cxx index d6e7ae6a975..0ff1310c712 100644 --- a/Modules/IO/XML/src/itkDOMNode.cxx +++ b/Modules/IO/XML/src/itkDOMNode.cxx @@ -478,7 +478,7 @@ DOMNode::Find(const std::string & path) std::string rpath; { - size_t pos = path.find_first_of('/'); + const size_t pos = path.find_first_of('/'); if (pos == std::string::npos) { s = path; @@ -573,10 +573,10 @@ DOMNode::Find(const std::string & path) // [:n] else { - size_t pos = s.find_first_of(':'); + const size_t pos = s.find_first_of(':'); if (pos != std::string::npos) { - std::string s2 = s.substr(pos + 1); + const std::string s2 = s.substr(pos + 1); s = s.substr(0, pos); std::istringstream iss(s2); IdentifierType i = 0; diff --git a/Modules/IO/XML/src/itkDOMNodeXMLReader.cxx b/Modules/IO/XML/src/itkDOMNodeXMLReader.cxx index 4a423393798..59a5049aed1 100644 --- a/Modules/IO/XML/src/itkDOMNodeXMLReader.cxx +++ b/Modules/IO/XML/src/itkDOMNodeXMLReader.cxx @@ -90,11 +90,11 @@ DOMNodeXMLReader::Update(std::istream & is) XML_SetCharacterDataHandler(parser, &itkXMLParserCharacterDataHandler); XML_SetUserData(parser, this); - bool ok = XML_Parse(parser, s.data(), static_cast(s.size()), false); + const bool ok = XML_Parse(parser, s.data(), static_cast(s.size()), false); if (!ok) { - ExceptionObject e(__FILE__, __LINE__); - std::string message(XML_ErrorString(XML_GetErrorCode(parser))); + ExceptionObject e(__FILE__, __LINE__); + const std::string message(XML_ErrorString(XML_GetErrorCode(parser))); e.SetDescription(message.c_str()); throw e; } @@ -128,7 +128,7 @@ DOMNodeXMLReader::StartElement(const char * name, const char ** atts) OutputType * node = nullptr; if (this->m_Context) { - OutputPointer node1 = OutputType::New(); + const OutputPointer node1 = OutputType::New(); node = (OutputType *)node1; this->m_Context->AddChildAtEnd(node); } @@ -142,8 +142,8 @@ DOMNodeXMLReader::StartElement(const char * name, const char ** atts) size_t i = 0; while (atts[i]) { - std::string key(atts[i++]); - std::string value(atts[i++]); + const std::string key(atts[i++]); + const std::string value(atts[i++]); if (StringTools::MatchWith(key, "id")) { node->SetID(value); diff --git a/Modules/IO/XML/src/itkDOMNodeXMLWriter.cxx b/Modules/IO/XML/src/itkDOMNodeXMLWriter.cxx index 2c1d26e9283..e6d5f8170c9 100644 --- a/Modules/IO/XML/src/itkDOMNodeXMLWriter.cxx +++ b/Modules/IO/XML/src/itkDOMNodeXMLWriter.cxx @@ -52,7 +52,7 @@ DOMNodeXMLWriter::Update(std::ostream & os, std::string indent) os << indent << '<' << input->GetName(); // write the "id" attribute if it is present - std::string id = input->GetID(); + const std::string id = input->GetID(); if (!id.empty()) { os << " id=\"" << id << '"'; diff --git a/Modules/IO/XML/src/itkStringTools.cxx b/Modules/IO/XML/src/itkStringTools.cxx index b8c501c5c2a..5bc406272a8 100644 --- a/Modules/IO/XML/src/itkStringTools.cxx +++ b/Modules/IO/XML/src/itkStringTools.cxx @@ -106,7 +106,7 @@ StringTools::ToLowerCase(std::string & str) void StringTools::Split(const std::string & s, std::string & lpart, std::string & rpart, const std::string & delims) { - std::string::size_type pos = s.find_first_of(delims); + const std::string::size_type pos = s.find_first_of(delims); if (pos != std::string::npos) { lpart = s.substr(0, pos); @@ -129,7 +129,7 @@ StringTools::Split(const std::string & s, std::vector & result, con std::string str = s; while (!str.empty()) { - std::string::size_type pos = str.find_first_of(delims); + const std::string::size_type pos = str.find_first_of(delims); if (pos != std::string::npos) { std::string front = str.substr(0, pos); @@ -227,7 +227,7 @@ StringTools::StartWith(const std::string & s1, const std::string & s2, bool igno bool StringTools::EndWith(const std::string & s1, const std::string & s2, bool ignoreCase) { - std::string::size_type pos = s1.size() - s2.size(); + const std::string::size_type pos = s1.size() - s2.size(); // if case is not important if (ignoreCase) diff --git a/Modules/IO/XML/src/itkXMLFile.cxx b/Modules/IO/XML/src/itkXMLFile.cxx index 23f94640ea8..02a1389c8d1 100644 --- a/Modules/IO/XML/src/itkXMLFile.cxx +++ b/Modules/IO/XML/src/itkXMLFile.cxx @@ -85,7 +85,7 @@ XMLReaderBase::parse() } // Default stream parser just reads a block at a time. - std::streamsize filesize = itksys::SystemTools::FileLength(m_Filename.c_str()); + const std::streamsize filesize = itksys::SystemTools::FileLength(m_Filename.c_str()); const auto buffer = make_unique_for_overwrite(filesize); diff --git a/Modules/IO/XML/test/itkDOMTest1.cxx b/Modules/IO/XML/test/itkDOMTest1.cxx index f45abd18793..288a8c681c6 100644 --- a/Modules/IO/XML/test/itkDOMTest1.cxx +++ b/Modules/IO/XML/test/itkDOMTest1.cxx @@ -30,7 +30,7 @@ itkDOMTest1(int, char *[]) try { // create a DOM object - itk::DOMNode::Pointer dom = itk::DOMNode::New(); + const itk::DOMNode::Pointer dom = itk::DOMNode::New(); dom->SetName("SimpleTestObject"); // add some attributes @@ -39,18 +39,18 @@ itkDOMTest1(int, char *[]) // add some children // 1st child - itk::DOMNode::Pointer child1 = itk::DOMNode::New(); + const itk::DOMNode::Pointer child1 = itk::DOMNode::New(); child1->SetName("city"); child1->SetAttribute("name", "New York"); dom->AddChild(child1); // 2nd child - itk::DOMNode::Pointer child2 = itk::DOMNode::New(); + const itk::DOMNode::Pointer child2 = itk::DOMNode::New(); child2->SetName("city"); child2->SetAttribute("id", "dc"); child2->SetAttribute("name", "District of Columbia"); dom->AddChild(child2); // 3rd child - itk::DOMNode::Pointer child3 = itk::DOMNode::New(); + const itk::DOMNode::Pointer child3 = itk::DOMNode::New(); child3->SetName("country"); child3->SetAttribute("id", "usa"); child3->AddTextChild("United States of America"); diff --git a/Modules/IO/XML/test/itkDOMTest2.cxx b/Modules/IO/XML/test/itkDOMTest2.cxx index 7195d2f3fee..33fd19749d8 100644 --- a/Modules/IO/XML/test/itkDOMTest2.cxx +++ b/Modules/IO/XML/test/itkDOMTest2.cxx @@ -43,20 +43,20 @@ itkDOMTest2(int argc, char * argv[]) try { // read a DOM object from an XML file - itk::DOMNodeXMLReader::Pointer reader = itk::DOMNodeXMLReader::New(); + const itk::DOMNodeXMLReader::Pointer reader = itk::DOMNodeXMLReader::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(reader, DOMNodeXMLReader, Object); - std::string inputFileName = argv[1]; + const std::string inputFileName = argv[1]; reader->SetFileName(inputFileName); ITK_TEST_SET_GET_VALUE(inputFileName, reader->GetFileName()); reader->Update(); - itk::DOMNode::Pointer dom = reader->GetOutput(); + const itk::DOMNode::Pointer dom = reader->GetOutput(); // write a DOM object to an XML file - itk::DOMNodeXMLWriter::Pointer writer = itk::DOMNodeXMLWriter::New(); + const itk::DOMNodeXMLWriter::Pointer writer = itk::DOMNodeXMLWriter::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(writer, DOMNodeXMLWriter, Object); @@ -64,23 +64,23 @@ itkDOMTest2(int argc, char * argv[]) writer->SetInput(dom); ITK_TEST_SET_GET_VALUE(dom, writer->GetInput()); - std::string outputFileName = argv[2]; + const std::string outputFileName = argv[2]; writer->SetFileName(outputFileName); ITK_TEST_SET_GET_VALUE(outputFileName, writer->GetFileName()); writer->Update(); // write a DOM object to an XML stream - itk::DOMNode::Pointer dom1 = dom; - std::ostringstream oss; + const itk::DOMNode::Pointer dom1 = dom; + std::ostringstream oss; oss << *dom1; - std::string s = oss.str(); + const std::string s = oss.str(); std::cout << "Write DOM object to an output string stream: " << std::endl; std::cout << s << std::endl; // read a DOM object from an XML stream - itk::DOMNode::Pointer dom2 = itk::DOMNode::New(); - std::istringstream iss(s); + const itk::DOMNode::Pointer dom2 = itk::DOMNode::New(); + std::istringstream iss(s); iss >> *dom2; std::cout << "Read DOM object from an input string stream: " << std::endl; std::cout << *dom2 << std::endl; diff --git a/Modules/IO/XML/test/itkDOMTest3.cxx b/Modules/IO/XML/test/itkDOMTest3.cxx index 65b5d87c022..f2bd3620572 100644 --- a/Modules/IO/XML/test/itkDOMTest3.cxx +++ b/Modules/IO/XML/test/itkDOMTest3.cxx @@ -43,10 +43,10 @@ itkDOMTest3(int argc, char * argv[]) try { // read the DOM object from the input XML file - itk::DOMNodeXMLReader::Pointer reader = itk::DOMNodeXMLReader::New(); + const itk::DOMNodeXMLReader::Pointer reader = itk::DOMNodeXMLReader::New(); reader->SetFileName(argv[1]); reader->Update(); - itk::DOMNode::Pointer dom = reader->GetOutput(); + const itk::DOMNode::Pointer dom = reader->GetOutput(); itk::DOMNode * node = dom->GetChild(0); if (!node) diff --git a/Modules/IO/XML/test/itkDOMTest4.cxx b/Modules/IO/XML/test/itkDOMTest4.cxx index 193c2ddd123..3e459865f95 100644 --- a/Modules/IO/XML/test/itkDOMTest4.cxx +++ b/Modules/IO/XML/test/itkDOMTest4.cxx @@ -41,10 +41,10 @@ itkDOMTest4(int argc, char * argv[]) try { // read the DOM object from the input XML file - itk::DOMNodeXMLReader::Pointer reader = itk::DOMNodeXMLReader::New(); + const itk::DOMNodeXMLReader::Pointer reader = itk::DOMNodeXMLReader::New(); reader->SetFileName(argv[1]); reader->Update(); - itk::DOMNode::Pointer dom = reader->GetOutput(); + const itk::DOMNode::Pointer dom = reader->GetOutput(); std::string sQueryString = argv[2]; // itk_add_test has problem to supply an empty string, so we use a special string diff --git a/Modules/IO/XML/test/itkDOMTest5.cxx b/Modules/IO/XML/test/itkDOMTest5.cxx index c5d2aec6c05..8f5ada29dfa 100644 --- a/Modules/IO/XML/test/itkDOMTest5.cxx +++ b/Modules/IO/XML/test/itkDOMTest5.cxx @@ -43,7 +43,7 @@ itkDOMTest5(int argc, char * argv[]) std::cout << std::endl; // create the test object - itk::DOMTestObject::Pointer testobj1 = itk::DOMTestObject::New(); + const itk::DOMTestObject::Pointer testobj1 = itk::DOMTestObject::New(); // settings for foo testobj1->SetFooValue("Hello!"); testobj1->SetFooFileName("itkDOMTest5-output/foo.txt"); @@ -53,7 +53,7 @@ itkDOMTest5(int argc, char * argv[]) std::cout << std::endl; // write the test object to an XML file - itk::DOMTestObjectDOMWriter::Pointer writer = itk::DOMTestObjectDOMWriter::New(); + const itk::DOMTestObjectDOMWriter::Pointer writer = itk::DOMTestObjectDOMWriter::New(); writer->SetInput(testobj1); const auto filename = std::string(argv[1]); @@ -65,7 +65,7 @@ itkDOMTest5(int argc, char * argv[]) itk::DOMTestObject::Pointer testobj2; // read the object back to memory from the disk - itk::DOMTestObjectDOMReader::Pointer reader = itk::DOMTestObjectDOMReader::New(); + const itk::DOMTestObjectDOMReader::Pointer reader = itk::DOMTestObjectDOMReader::New(); reader->SetFileName(filename); ITK_TEST_SET_GET_VALUE(filename, std::string(reader->GetFileName())); diff --git a/Modules/IO/XML/test/itkDOMTest6.cxx b/Modules/IO/XML/test/itkDOMTest6.cxx index ac6f1546874..3f7009409ca 100644 --- a/Modules/IO/XML/test/itkDOMTest6.cxx +++ b/Modules/IO/XML/test/itkDOMTest6.cxx @@ -81,7 +81,7 @@ testStringToolsWithBasicType() std::string s; // write out - DataType dataIn = '*'; + const DataType dataIn = '*'; itk::StringTools::FromData(s, dataIn); // read back @@ -104,7 +104,7 @@ testStringToolsWithBasicType() std::string s; // write out - DataType dataIn = -1024; + const DataType dataIn = -1024; itk::StringTools::FromData(s, dataIn); // read back @@ -127,7 +127,7 @@ testStringToolsWithBasicType() std::string s; // write out - DataType dataIn = -0.1; + const DataType dataIn = -0.1; itk::StringTools::FromData(s, dataIn); // read back diff --git a/Modules/IO/XML/test/itkDOMTestObjectDOMWriter.h b/Modules/IO/XML/test/itkDOMTestObjectDOMWriter.h index f3222b58e69..0f460e39b54 100644 --- a/Modules/IO/XML/test/itkDOMTestObjectDOMWriter.h +++ b/Modules/IO/XML/test/itkDOMTestObjectDOMWriter.h @@ -66,7 +66,7 @@ DOMTestObjectDOMWriter::GenerateData(DOMNodeType * outputdom, const void *) cons // write child foo fn = input->GetFooFileName(); - DOMNodePointer foo = DOMNodeType::New(); + const DOMNodePointer foo = DOMNodeType::New(); foo->SetName("foo"); foo->SetAttribute("fname", fn); outputdom->AddChild(foo); diff --git a/Modules/IO/XML/test/itkFancyStringTest.cxx b/Modules/IO/XML/test/itkFancyStringTest.cxx index f3555c7d959..025c26b5a2e 100644 --- a/Modules/IO/XML/test/itkFancyStringTest.cxx +++ b/Modules/IO/XML/test/itkFancyStringTest.cxx @@ -77,7 +77,7 @@ testFancyStringWithBasicType() itk::FancyString s; // write out - DataType dataIn = '*'; + const DataType dataIn = '*'; s << dataIn; // read back @@ -100,7 +100,7 @@ testFancyStringWithBasicType() itk::FancyString s; // write out - DataType dataIn = -1024; + const DataType dataIn = -1024; s << dataIn; // read back @@ -123,7 +123,7 @@ testFancyStringWithBasicType() itk::FancyString s; // write out - DataType dataIn = -0.1; + const DataType dataIn = -0.1; s << dataIn; // read back @@ -466,12 +466,12 @@ testFancyStringUnequalOperator() } { - itk::FancyString s1{ "Hello World!" }; - itk::FancyString s2{ "Hello World" }; + itk::FancyString s1{ "Hello World!" }; + const itk::FancyString s2{ "Hello World" }; ITK_TEST_EXPECT_TRUE(s1 != s2); - itk::FancyString s3{ "Hello world!" }; + const itk::FancyString s3{ "Hello world!" }; ITK_TEST_EXPECT_TRUE(s1 != s3); } @@ -499,8 +499,8 @@ testFancyStringEqualOperator() } { - itk::FancyString s1{ "Hello World!" }; - itk::FancyString s2{ "Hello World!" }; + itk::FancyString s1{ "Hello World!" }; + const itk::FancyString s2{ "Hello World!" }; ITK_TEST_EXPECT_TRUE(s1 == s2); } diff --git a/Modules/Nonunit/IntegratedTest/test/itkAlgorithmsPrintTest.cxx b/Modules/Nonunit/IntegratedTest/test/itkAlgorithmsPrintTest.cxx index 0920b6fa8ee..3400dfc0fd1 100644 --- a/Modules/Nonunit/IntegratedTest/test/itkAlgorithmsPrintTest.cxx +++ b/Modules/Nonunit/IntegratedTest/test/itkAlgorithmsPrintTest.cxx @@ -37,51 +37,51 @@ main(int, char *[]) using VectorType = itk::Vector; using VectorImageType = itk::Image; - itk::AntiAliasBinaryImageFilter::Pointer AntiAliasBinaryImageFilterObj = + const itk::AntiAliasBinaryImageFilter::Pointer AntiAliasBinaryImageFilterObj = itk::AntiAliasBinaryImageFilter::New(); std::cout << "-------------AntiAliasBinaryImageFilter " << AntiAliasBinaryImageFilterObj; - itk::BinaryMask3DMeshSource::Pointer BinaryMask3DMeshSourceObj = + const itk::BinaryMask3DMeshSource::Pointer BinaryMask3DMeshSourceObj = itk::BinaryMask3DMeshSource::New(); std::cout << "-------------BinaryMask3DMeshSource " << BinaryMask3DMeshSourceObj; - itk::BinaryMinMaxCurvatureFlowFunction::Pointer BinaryMinMaxCurvatureFlowFunctionObj = + const itk::BinaryMinMaxCurvatureFlowFunction::Pointer BinaryMinMaxCurvatureFlowFunctionObj = itk::BinaryMinMaxCurvatureFlowFunction::New(); std::cout << "-------------BinaryMinMaxCurvatureFlowFunction " << BinaryMinMaxCurvatureFlowFunctionObj; - itk::BinaryMinMaxCurvatureFlowImageFilter::Pointer BinaryMinMaxCurvatureFlowImageFilterObj = - itk::BinaryMinMaxCurvatureFlowImageFilter::New(); + const itk::BinaryMinMaxCurvatureFlowImageFilter::Pointer + BinaryMinMaxCurvatureFlowImageFilterObj = itk::BinaryMinMaxCurvatureFlowImageFilter::New(); std::cout << "-------------BinaryMinMaxCurvatureFlowImageFilter " << BinaryMinMaxCurvatureFlowImageFilterObj; - itk::CannySegmentationLevelSetFunction::Pointer CannySegmentationLevelSetFunctionObj = + const itk::CannySegmentationLevelSetFunction::Pointer CannySegmentationLevelSetFunctionObj = itk::CannySegmentationLevelSetFunction::New(); std::cout << "-------------CannySegmentationLevelSetFunction " << CannySegmentationLevelSetFunctionObj; - itk::CannySegmentationLevelSetImageFilter::Pointer CannySegmentationLevelSetImageFilterObj = - itk::CannySegmentationLevelSetImageFilter::New(); + const itk::CannySegmentationLevelSetImageFilter::Pointer + CannySegmentationLevelSetImageFilterObj = itk::CannySegmentationLevelSetImageFilter::New(); std::cout << "-------------CannySegmentationLevelSetImageFilter " << CannySegmentationLevelSetImageFilterObj; - itk::ConnectedRegionsMeshFilter::Pointer ConnectedRegionsMeshFilterObj = + const itk::ConnectedRegionsMeshFilter::Pointer ConnectedRegionsMeshFilterObj = itk::ConnectedRegionsMeshFilter::New(); std::cout << "-------------ConnectedRegionsMeshFilter " << ConnectedRegionsMeshFilterObj; - itk::CurvatureFlowFunction::Pointer CurvatureFlowFunctionObj = + const itk::CurvatureFlowFunction::Pointer CurvatureFlowFunctionObj = itk::CurvatureFlowFunction::New(); std::cout << "-------------CurvatureFlowFunction " << CurvatureFlowFunctionObj; - itk::CurvatureFlowImageFilter::Pointer CurvatureFlowImageFilterObj = + const itk::CurvatureFlowImageFilter::Pointer CurvatureFlowImageFilterObj = itk::CurvatureFlowImageFilter::New(); std::cout << "-------------CurvatureFlowImageFilter " << CurvatureFlowImageFilterObj; - itk::DemonsRegistrationFilter::Pointer DemonsRegistrationFilterObj = + const itk::DemonsRegistrationFilter::Pointer DemonsRegistrationFilterObj = itk::DemonsRegistrationFilter::New(); std::cout << "-------------DemonsRegistrationFilter " << DemonsRegistrationFilterObj; - itk::DemonsRegistrationFunction::Pointer DemonsRegistrationFunctionObj = + const itk::DemonsRegistrationFunction::Pointer DemonsRegistrationFunctionObj = itk::DemonsRegistrationFunction::New(); std::cout << "-------------DemonsRegistrationFunction " << DemonsRegistrationFunctionObj; - itk::ExtensionVelocitiesImageFilter::Pointer ExtensionVelocitiesImageFilterObj = + const itk::ExtensionVelocitiesImageFilter::Pointer ExtensionVelocitiesImageFilterObj = itk::ExtensionVelocitiesImageFilter::New(); std::cout << "-------------ExtensionVelocitiesImageFilter " << ExtensionVelocitiesImageFilterObj; @@ -89,11 +89,11 @@ main(int, char *[]) // itk::fem::FEMRegistrationFilter::New(); // std:: cout << "-------------FEMRegistrationFilter " << FEMRegistrationFilterObj; - itk::FastMarchingExtensionImageFilter::Pointer FastMarchingExtensionImageFilterObj = + const itk::FastMarchingExtensionImageFilter::Pointer FastMarchingExtensionImageFilterObj = itk::FastMarchingExtensionImageFilter::New(); std::cout << "-------------FastMarchingExtensionImageFilter " << FastMarchingExtensionImageFilterObj; - itk::FastMarchingImageFilter::Pointer FastMarchingImageFilterObj = + const itk::FastMarchingImageFilter::Pointer FastMarchingImageFilterObj = itk::FastMarchingImageFilter::New(); std::cout << "-------------FastMarchingImageFilter " << FastMarchingImageFilterObj; diff --git a/Modules/Nonunit/IntegratedTest/test/itkAlgorithmsPrintTest2.cxx b/Modules/Nonunit/IntegratedTest/test/itkAlgorithmsPrintTest2.cxx index 38c6bcbef2a..4e2cb22dfa9 100644 --- a/Modules/Nonunit/IntegratedTest/test/itkAlgorithmsPrintTest2.cxx +++ b/Modules/Nonunit/IntegratedTest/test/itkAlgorithmsPrintTest2.cxx @@ -46,7 +46,7 @@ main(int, char *[]) // Used for NormalizedCorrelationPointSetToImageMetric using PointSetType = itk::PointSet; - itk::MattesMutualInformationImageToImageMetric::Pointer + const itk::MattesMutualInformationImageToImageMetric::Pointer MattesMutualInformationImageToImageMetricObj = itk::MattesMutualInformationImageToImageMetric::New(); std::cout << "-------------MattesMutualInformationImageToImageMetric " @@ -55,67 +55,68 @@ main(int, char *[]) /*itk::MeanSquaresPointSetToImageMetric::Pointer MeanSquaresPointSetToImageMetricObj = itk::MeanSquaresPointSetToImageMetric::New(); std:: cout << "-------------MeanSquaresPointSetToImageMetric " << MeanSquaresPointSetToImageMetricObj;*/ - itk::MeanSquaresImageToImageMetric::Pointer MeanSquaresImageToImageMetricObj = + const itk::MeanSquaresImageToImageMetric::Pointer MeanSquaresImageToImageMetricObj = itk::MeanSquaresImageToImageMetric::New(); std::cout << "-------------MeanSquaresImageToImageMetric " << MeanSquaresImageToImageMetricObj; - itk::MinMaxCurvatureFlowFunction::Pointer MinMaxCurvatureFlowFunctionObj = + const itk::MinMaxCurvatureFlowFunction::Pointer MinMaxCurvatureFlowFunctionObj = itk::MinMaxCurvatureFlowFunction::New(); std::cout << "-------------MinMaxCurvatureFlowFunction " << MinMaxCurvatureFlowFunctionObj; - itk::MinMaxCurvatureFlowImageFilter::Pointer MinMaxCurvatureFlowImageFilterObj = + const itk::MinMaxCurvatureFlowImageFilter::Pointer MinMaxCurvatureFlowImageFilterObj = itk::MinMaxCurvatureFlowImageFilter::New(); std::cout << "-------------MinMaxCurvatureFlowImageFilter " << MinMaxCurvatureFlowImageFilterObj; - itk::MultiResolutionImageRegistrationMethod::Pointer MultiResolutionImageRegistrationMethodObj = - itk::MultiResolutionImageRegistrationMethod::New(); + const itk::MultiResolutionImageRegistrationMethod::Pointer + MultiResolutionImageRegistrationMethodObj = + itk::MultiResolutionImageRegistrationMethod::New(); std::cout << "-------------MultiResolutionImageRegistrationMethod " << MultiResolutionImageRegistrationMethodObj; - itk::MultiResolutionPDEDeformableRegistration::Pointer + const itk::MultiResolutionPDEDeformableRegistration::Pointer MultiResolutionPDEDeformableRegistrationObj = itk::MultiResolutionPDEDeformableRegistration::New(); std::cout << "-------------MultiResolutionPDEDeformableRegistration " << MultiResolutionPDEDeformableRegistrationObj; - itk::MultiResolutionPyramidImageFilter::Pointer MultiResolutionPyramidImageFilterObj = + const itk::MultiResolutionPyramidImageFilter::Pointer MultiResolutionPyramidImageFilterObj = itk::MultiResolutionPyramidImageFilter::New(); std::cout << "-------------MultiResolutionPyramidImageFilter " << MultiResolutionPyramidImageFilterObj; - itk::MutualInformationImageToImageMetric::Pointer MutualInformationImageToImageMetricObj = + const itk::MutualInformationImageToImageMetric::Pointer MutualInformationImageToImageMetricObj = itk::MutualInformationImageToImageMetric::New(); std::cout << "-------------MutualInformationImageToImageMetric " << MutualInformationImageToImageMetricObj; - itk::NormalizedCorrelationImageToImageMetric::Pointer + const itk::NormalizedCorrelationImageToImageMetric::Pointer NormalizedCorrelationImageToImageMetricObj = itk::NormalizedCorrelationImageToImageMetric::New(); std::cout << "-------------NormalizedCorrelationImageToImageMetric " << NormalizedCorrelationImageToImageMetricObj; - itk::NormalizedCorrelationPointSetToImageMetric::Pointer + const itk::NormalizedCorrelationPointSetToImageMetric::Pointer NormalizedCorrelationPointSetToImageMetricObj = itk::NormalizedCorrelationPointSetToImageMetric::New(); std::cout << "-------------NormalizedCorrelationPointSetToImageMetric " << NormalizedCorrelationPointSetToImageMetricObj; using HistogramType = itk::Statistics::Histogram; - itk::OtsuThresholdCalculator::Pointer OtsuThresholdCalculatorObj = + const itk::OtsuThresholdCalculator::Pointer OtsuThresholdCalculatorObj = itk::OtsuThresholdCalculator::New(); std::cout << "-------------OtsuThresholdCalculator " << OtsuThresholdCalculatorObj; - itk::PDEDeformableRegistrationFilter::Pointer + const itk::PDEDeformableRegistrationFilter::Pointer PDEDeformableRegistrationFilterObj = itk::PDEDeformableRegistrationFilter::New(); std::cout << "-------------PDEDeformableRegistrationFilter " << PDEDeformableRegistrationFilterObj; // NOTE: RGBGibbsPriorFilter only works in 3D - itk::RGBGibbsPriorFilter::Pointer RGBGibbsPriorFilterObj = + const itk::RGBGibbsPriorFilter::Pointer RGBGibbsPriorFilterObj = itk::RGBGibbsPriorFilter::New(); std::cout << "-------------RGBGibbsPriorFilter " << RGBGibbsPriorFilterObj; - itk::RecursiveMultiResolutionPyramidImageFilter::Pointer + const itk::RecursiveMultiResolutionPyramidImageFilter::Pointer RecursiveMultiResolutionPyramidImageFilterObj = itk::RecursiveMultiResolutionPyramidImageFilter::New(); std::cout << "-------------RecursiveMultiResolutionPyramidImageFilter " << RecursiveMultiResolutionPyramidImageFilterObj; - itk::ReinitializeLevelSetImageFilter::Pointer ReinitializeLevelSetImageFilterObj = + const itk::ReinitializeLevelSetImageFilter::Pointer ReinitializeLevelSetImageFilterObj = itk::ReinitializeLevelSetImageFilter::New(); std::cout << "-------------ReinitializeLevelSetImageFilter " << ReinitializeLevelSetImageFilterObj; diff --git a/Modules/Nonunit/IntegratedTest/test/itkAlgorithmsPrintTest3.cxx b/Modules/Nonunit/IntegratedTest/test/itkAlgorithmsPrintTest3.cxx index 45f40b6c21f..45c90c2c0a8 100644 --- a/Modules/Nonunit/IntegratedTest/test/itkAlgorithmsPrintTest3.cxx +++ b/Modules/Nonunit/IntegratedTest/test/itkAlgorithmsPrintTest3.cxx @@ -40,84 +40,89 @@ main(int, char *[]) using RGBVectorType = itk::Vector; using RGBVectorImageType = itk::Image; - itk::ShapeDetectionLevelSetFunction::Pointer ShapeDetectionLevelSetFunctionObj = + const itk::ShapeDetectionLevelSetFunction::Pointer ShapeDetectionLevelSetFunctionObj = itk::ShapeDetectionLevelSetFunction::New(); std::cout << "-------------ShapeDetectionLevelSetFunction " << ShapeDetectionLevelSetFunctionObj; - itk::ShapeDetectionLevelSetImageFilter::Pointer ShapeDetectionLevelSetImageFilterObj = - itk::ShapeDetectionLevelSetImageFilter::New(); + const itk::ShapeDetectionLevelSetImageFilter::Pointer + ShapeDetectionLevelSetImageFilterObj = itk::ShapeDetectionLevelSetImageFilter::New(); std::cout << "-------------ShapeDetectionLevelSetImageFilter " << ShapeDetectionLevelSetImageFilterObj; - itk::SphereMeshSource::Pointer SphereMeshSourceObj = itk::SphereMeshSource::New(); + const itk::SphereMeshSource::Pointer SphereMeshSourceObj = itk::SphereMeshSource::New(); std::cout << "-------------SphereMeshSource " << SphereMeshSourceObj; - itk::ThresholdSegmentationLevelSetFunction::Pointer ThresholdSegmentationLevelSetFunctionObj = - itk::ThresholdSegmentationLevelSetFunction::New(); + const itk::ThresholdSegmentationLevelSetFunction::Pointer + ThresholdSegmentationLevelSetFunctionObj = itk::ThresholdSegmentationLevelSetFunction::New(); std::cout << "-------------ThresholdSegmentationLevelSetFunction " << ThresholdSegmentationLevelSetFunctionObj; - itk::ThresholdSegmentationLevelSetImageFilter::Pointer + const itk::ThresholdSegmentationLevelSetImageFilter::Pointer ThresholdSegmentationLevelSetImageFilterObj = itk::ThresholdSegmentationLevelSetImageFilter::New(); std::cout << "-------------ThresholdSegmentationLevelSetImageFilter " << ThresholdSegmentationLevelSetImageFilterObj; - itk::VoronoiDiagram2D::Pointer VoronoiDiagram2DObj = itk::VoronoiDiagram2D::New(); + const itk::VoronoiDiagram2D::Pointer VoronoiDiagram2DObj = itk::VoronoiDiagram2D::New(); std::cout << "-------------VoronoiDiagram2D " << VoronoiDiagram2DObj; - itk::VoronoiDiagram2DGenerator::Pointer VoronoiDiagram2DGeneratorObj = + const itk::VoronoiDiagram2DGenerator::Pointer VoronoiDiagram2DGeneratorObj = itk::VoronoiDiagram2DGenerator::New(); std::cout << "-------------VoronoiDiagram2DGenerator " << VoronoiDiagram2DGeneratorObj; - itk::VoronoiPartitioningImageFilter::Pointer VoronoiPartitioningImageFilterObj = + const itk::VoronoiPartitioningImageFilter::Pointer VoronoiPartitioningImageFilterObj = itk::VoronoiPartitioningImageFilter::New(); std::cout << "-------------VoronoiPartitioningImageFilter " << VoronoiPartitioningImageFilterObj; - itk::VoronoiSegmentationImageFilter::Pointer VoronoiSegmentationImageFilterObj = + const itk::VoronoiSegmentationImageFilter::Pointer VoronoiSegmentationImageFilterObj = itk::VoronoiSegmentationImageFilter::New(); std::cout << "-------------VoronoiSegmentationImageFilter " << VoronoiSegmentationImageFilterObj; - itk::VoronoiSegmentationImageFilterBase::Pointer VoronoiSegmentationImageFilterBaseObj = + const itk::VoronoiSegmentationImageFilterBase::Pointer VoronoiSegmentationImageFilterBaseObj = itk::VoronoiSegmentationImageFilterBase::New(); std::cout << "-------------VoronoiSegmentationImageFilterBase " << VoronoiSegmentationImageFilterBaseObj; - itk::VoronoiSegmentationRGBImageFilter::Pointer VoronoiSegmentationRGBImageFilterObj = - itk::VoronoiSegmentationRGBImageFilter::New(); + const itk::VoronoiSegmentationRGBImageFilter::Pointer + VoronoiSegmentationRGBImageFilterObj = itk::VoronoiSegmentationRGBImageFilter::New(); std::cout << "-------------VoronoiSegmentationRGBImageFilter " << VoronoiSegmentationRGBImageFilterObj; - itk::watershed::Boundary::Pointer WatershedBoundaryObj = itk::watershed::Boundary::New(); + const itk::watershed::Boundary::Pointer WatershedBoundaryObj = itk::watershed::Boundary::New(); std::cout << "-------------WatershedBoundary " << WatershedBoundaryObj; - itk::watershed::BoundaryResolver::Pointer WatershedBoundaryResolverObj = + const itk::watershed::BoundaryResolver::Pointer WatershedBoundaryResolverObj = itk::watershed::BoundaryResolver::New(); std::cout << "-------------WatershedBoundaryResolver " << WatershedBoundaryResolverObj; - itk::watershed::EquivalenceRelabeler::Pointer WatershedEquivalenceRelabelerObj = + const itk::watershed::EquivalenceRelabeler::Pointer WatershedEquivalenceRelabelerObj = itk::watershed::EquivalenceRelabeler::New(); std::cout << "-------------WatershedEquivalenceRelabeler " << WatershedEquivalenceRelabelerObj; - itk::WatershedImageFilter::Pointer WatershedImageFilterObj = itk::WatershedImageFilter::New(); + const itk::WatershedImageFilter::Pointer WatershedImageFilterObj = + itk::WatershedImageFilter::New(); std::cout << "-------------WatershedImageFilter " << WatershedImageFilterObj; - itk::WatershedMiniPipelineProgressCommand::Pointer WatershedMiniPipelineProgressCommandObj = + const itk::WatershedMiniPipelineProgressCommand::Pointer WatershedMiniPipelineProgressCommandObj = itk::WatershedMiniPipelineProgressCommand::New(); std::cout << "-------------WatershedMiniPipelineProgressCommand " << WatershedMiniPipelineProgressCommandObj; - itk::watershed::Relabeler::Pointer WatershedRelabelerObj = itk::watershed::Relabeler::New(); + const itk::watershed::Relabeler::Pointer WatershedRelabelerObj = + itk::watershed::Relabeler::New(); std::cout << "-------------WatershedRelabeler " << WatershedRelabelerObj; - itk::watershed::SegmentTable::Pointer WatershedSegmentTableObj = itk::watershed::SegmentTable::New(); + const itk::watershed::SegmentTable::Pointer WatershedSegmentTableObj = + itk::watershed::SegmentTable::New(); std::cout << "-------------WatershedSegmentTable " << WatershedSegmentTableObj; - itk::watershed::SegmentTree::Pointer WatershedSegmentTreeObj = itk::watershed::SegmentTree::New(); + const itk::watershed::SegmentTree::Pointer WatershedSegmentTreeObj = + itk::watershed::SegmentTree::New(); std::cout << "-------------WatershedSegmentTree " << WatershedSegmentTreeObj; - itk::watershed::SegmentTreeGenerator::Pointer WatershedSegmentTreeGeneratorObj = + const itk::watershed::SegmentTreeGenerator::Pointer WatershedSegmentTreeGeneratorObj = itk::watershed::SegmentTreeGenerator::New(); std::cout << "-------------WatershedSegmentTreeGenerator " << WatershedSegmentTreeGeneratorObj; - itk::watershed::Segmenter::Pointer WatershedSegmenterObj = itk::watershed::Segmenter::New(); + const itk::watershed::Segmenter::Pointer WatershedSegmenterObj = + itk::watershed::Segmenter::New(); std::cout << "-------------WatershedSegmenter " << WatershedSegmenterObj; - itk::MRASlabIdentifier::Pointer MRASlabIdentifierObj = itk::MRASlabIdentifier::New(); + const itk::MRASlabIdentifier::Pointer MRASlabIdentifierObj = itk::MRASlabIdentifier::New(); std::cout << "-------------MRASlabIdentifier " << MRASlabIdentifierObj; return EXIT_SUCCESS; } diff --git a/Modules/Nonunit/IntegratedTest/test/itkAlgorithmsPrintTest4.cxx b/Modules/Nonunit/IntegratedTest/test/itkAlgorithmsPrintTest4.cxx index 8e997066ed4..8c253422a5a 100644 --- a/Modules/Nonunit/IntegratedTest/test/itkAlgorithmsPrintTest4.cxx +++ b/Modules/Nonunit/IntegratedTest/test/itkAlgorithmsPrintTest4.cxx @@ -59,67 +59,68 @@ main(int, char *[]) // Used for ImageToSpatialObjectRegistrationMethod using GroupType = itk::GroupSpatialObject<2>; - itk::GeodesicActiveContourLevelSetFunction::Pointer GeodesicActiveContourLevelSetFunctionObj = + const itk::GeodesicActiveContourLevelSetFunction::Pointer GeodesicActiveContourLevelSetFunctionObj = itk::GeodesicActiveContourLevelSetFunction::New(); std::cout << "-------------GeodesicActiveContourLevelSetFunction " << GeodesicActiveContourLevelSetFunctionObj; - itk::GeodesicActiveContourLevelSetImageFilter::Pointer + const itk::GeodesicActiveContourLevelSetImageFilter::Pointer GeodesicActiveContourLevelSetImageFilterObj = itk::GeodesicActiveContourLevelSetImageFilter::New(); std::cout << "-------------GeodesicActiveContourLevelSetImageFilter " << GeodesicActiveContourLevelSetImageFilterObj; - itk::GradientVectorFlowImageFilter::Pointer GradientVectorFlowImageFilterObj = - itk::GradientVectorFlowImageFilter::New(); + const itk::GradientVectorFlowImageFilter::Pointer + GradientVectorFlowImageFilterObj = itk::GradientVectorFlowImageFilter::New(); std::cout << "-------------GradientVectorFlowImageFilter " << GradientVectorFlowImageFilterObj; - itk::HistogramMatchingImageFilter::Pointer HistogramMatchingImageFilterObj = + const itk::HistogramMatchingImageFilter::Pointer HistogramMatchingImageFilterObj = itk::HistogramMatchingImageFilter::New(); std::cout << "-------------HistogramMatchingImageFilter " << HistogramMatchingImageFilterObj; - itk::ImageClassifierBase::Pointer ImageClassifierBaseObj = + const itk::ImageClassifierBase::Pointer ImageClassifierBaseObj = itk::ImageClassifierBase::New(); std::cout << "-------------ImageClassifierBase " << ImageClassifierBaseObj; - itk::ImageGaussianModelEstimator::Pointer + const itk::ImageGaussianModelEstimator::Pointer ImageGaussianModelEstimatorObj = itk::ImageGaussianModelEstimator::New(); std::cout << "-------------ImageGaussianModelEstimator " << ImageGaussianModelEstimatorObj; - itk::ImageKmeansModelEstimator::Pointer ImageKmeansModelEstimatorObj = + const itk::ImageKmeansModelEstimator::Pointer ImageKmeansModelEstimatorObj = itk::ImageKmeansModelEstimator::New(); std::cout << "-------------ImageKmeansModelEstimator " << ImageKmeansModelEstimatorObj; - itk::ImageRegistrationMethod::Pointer ImageRegistrationMethodObj = + const itk::ImageRegistrationMethod::Pointer ImageRegistrationMethodObj = itk::ImageRegistrationMethod::New(); std::cout << "-------------ImageRegistrationMethod " << ImageRegistrationMethodObj; - itk::ImageToSpatialObjectRegistrationMethod::Pointer ImageToSpatialObjectRegistrationMethodObj = - itk::ImageToSpatialObjectRegistrationMethod::New(); + const itk::ImageToSpatialObjectRegistrationMethod::Pointer + ImageToSpatialObjectRegistrationMethodObj = + itk::ImageToSpatialObjectRegistrationMethod::New(); std::cout << "-------------ImageToSpatialObjectRegistrationMethod " << ImageToSpatialObjectRegistrationMethodObj; - itk::KLMRegionGrowImageFilter::Pointer KLMRegionGrowImageFilterObj = + const itk::KLMRegionGrowImageFilter::Pointer KLMRegionGrowImageFilterObj = itk::KLMRegionGrowImageFilter::New(); std::cout << "-------------KLMRegionGrowImageFilter " << KLMRegionGrowImageFilterObj; - itk::LaplacianSegmentationLevelSetFunction::Pointer LaplacianSegmentationLevelSetFunctionObj = - itk::LaplacianSegmentationLevelSetFunction::New(); + const itk::LaplacianSegmentationLevelSetFunction::Pointer + LaplacianSegmentationLevelSetFunctionObj = itk::LaplacianSegmentationLevelSetFunction::New(); std::cout << "-------------LaplacianSegmentationLevelSetFunction " << LaplacianSegmentationLevelSetFunctionObj; - itk::LaplacianSegmentationLevelSetImageFilter::Pointer + const itk::LaplacianSegmentationLevelSetImageFilter::Pointer LaplacianSegmentationLevelSetImageFilterObj = itk::LaplacianSegmentationLevelSetImageFilter::New(); std::cout << "-------------LaplacianSegmentationLevelSetImageFilter " << LaplacianSegmentationLevelSetImageFilterObj; - itk::LevelSetNeighborhoodExtractor::Pointer LevelSetNeighborhoodExtractorObj = + const itk::LevelSetNeighborhoodExtractor::Pointer LevelSetNeighborhoodExtractorObj = itk::LevelSetNeighborhoodExtractor::New(); std::cout << "-------------LevelSetNeighborhoodExtractor " << LevelSetNeighborhoodExtractorObj; - itk::LevelSetVelocityNeighborhoodExtractor::Pointer LevelSetVelocityNeighborhoodExtractorObj = - itk::LevelSetVelocityNeighborhoodExtractor::New(); + const itk::LevelSetVelocityNeighborhoodExtractor::Pointer + LevelSetVelocityNeighborhoodExtractorObj = itk::LevelSetVelocityNeighborhoodExtractor::New(); std::cout << "-------------LevelSetVelocityNeighborhoodExtractor " << LevelSetVelocityNeighborhoodExtractorObj; - itk::MeanReciprocalSquareDifferencePointSetToImageMetric::Pointer + const itk::MeanReciprocalSquareDifferencePointSetToImageMetric::Pointer MeanReciprocalSquareDifferencePointSetToImageMetricObj = itk::MeanReciprocalSquareDifferencePointSetToImageMetric::New(); std::cout << "-------------MeanReciprocalSquareDifferencePointSetToImageMetric " diff --git a/Modules/Nonunit/IntegratedTest/test/itkBasicFiltersPrintTest.cxx b/Modules/Nonunit/IntegratedTest/test/itkBasicFiltersPrintTest.cxx index ecbb4c73b07..e1a5dad8ce2 100644 --- a/Modules/Nonunit/IntegratedTest/test/itkBasicFiltersPrintTest.cxx +++ b/Modules/Nonunit/IntegratedTest/test/itkBasicFiltersPrintTest.cxx @@ -93,246 +93,249 @@ itkBasicFiltersPrintTest(int, char *[]) using KernelType = itk::BinaryBallStructuringElement; - itk::AcosImageFilter::Pointer AcosImageFilterObj = + const itk::AcosImageFilter::Pointer AcosImageFilterObj = itk::AcosImageFilter::New(); std::cout << "-------------AcosImageFilter" << AcosImageFilterObj; - itk::AdaptiveHistogramEqualizationImageFilter::Pointer AdaptiveHistogramEqualizationImageFilterObj = + const itk::AdaptiveHistogramEqualizationImageFilter::Pointer AdaptiveHistogramEqualizationImageFilterObj = itk::AdaptiveHistogramEqualizationImageFilter::New(); std::cout << "-------------AdaptiveHistogramEqualizationImageFilter" << AdaptiveHistogramEqualizationImageFilterObj; - itk::AddImageFilter::Pointer AddImageFilterObj = + const itk::AddImageFilter::Pointer AddImageFilterObj = itk::AddImageFilter::New(); std::cout << "-------------AddImageFilter" << AddImageFilterObj; - itk::AsinImageFilter::Pointer AsinImageFilterObj = + const itk::AsinImageFilter::Pointer AsinImageFilterObj = itk::AsinImageFilter::New(); std::cout << "-------------AsinImageFilter" << AsinImageFilterObj; - itk::Atan2ImageFilter::Pointer Atan2ImageFilterObj = + const itk::Atan2ImageFilter::Pointer Atan2ImageFilterObj = itk::Atan2ImageFilter::New(); std::cout << "-------------Atan2ImageFilter" << Atan2ImageFilterObj; - itk::AtanImageFilter::Pointer AtanImageFilterObj = + const itk::AtanImageFilter::Pointer AtanImageFilterObj = itk::AtanImageFilter::New(); std::cout << "-------------AtanImageFilter" << AtanImageFilterObj; - itk::BSplineDecompositionImageFilter::Pointer BSplineDecompositionImageFilterObj = + const itk::BSplineDecompositionImageFilter::Pointer BSplineDecompositionImageFilterObj = itk::BSplineDecompositionImageFilter::New(); std::cout << "-------------BSplineDecompositionImageFilter" << BSplineDecompositionImageFilterObj; - itk::BSplineDownsampleImageFilter::Pointer BSplineDownsampleImageFilterObj = + const itk::BSplineDownsampleImageFilter::Pointer BSplineDownsampleImageFilterObj = itk::BSplineDownsampleImageFilter::New(); std::cout << "-------------BSplineDownsampleImageFilter" << BSplineDownsampleImageFilterObj; - itk::BSplineInterpolateImageFunction::Pointer BSplineInterpolateImageFunctionObj = + const itk::BSplineInterpolateImageFunction::Pointer BSplineInterpolateImageFunctionObj = itk::BSplineInterpolateImageFunction::New(); std::cout << "-------------BSplineInterpolateImageFunction" << BSplineInterpolateImageFunctionObj; - itk::BSplineResampleImageFunction::Pointer BSplineResampleImageFunctionObj = + const itk::BSplineResampleImageFunction::Pointer BSplineResampleImageFunctionObj = itk::BSplineResampleImageFunction::New(); std::cout << "-------------BSplineResampleImageFunction" << BSplineResampleImageFunctionObj; - itk::BSplineUpsampleImageFilter::Pointer BSplineUpsampleImageFilterObj = + const itk::BSplineUpsampleImageFilter::Pointer BSplineUpsampleImageFilterObj = itk::BSplineUpsampleImageFilter::New(); std::cout << "-------------BSplineUpsampleImageFilter" << BSplineUpsampleImageFilterObj; - itk::BilateralImageFilter::Pointer BilateralImageFilterObj = + const itk::BilateralImageFilter::Pointer BilateralImageFilterObj = itk::BilateralImageFilter::New(); std::cout << "-------------BilateralImageFilter" << BilateralImageFilterObj; - itk::BinaryDilateImageFilter::Pointer BinaryDilateImageFilterObj = + const itk::BinaryDilateImageFilter::Pointer BinaryDilateImageFilterObj = itk::BinaryDilateImageFilter::New(); std::cout << "-------------BinaryDilateImageFilter" << BinaryDilateImageFilterObj; - itk::BinaryErodeImageFilter::Pointer BinaryErodeImageFilterObj = + const itk::BinaryErodeImageFilter::Pointer BinaryErodeImageFilterObj = itk::BinaryErodeImageFilter::New(); std::cout << "-------------BinaryErodeImageFilter" << BinaryErodeImageFilterObj; - itk::BinaryMagnitudeImageFilter::Pointer BinaryMagnitudeImageFilterObj = + const itk::BinaryMagnitudeImageFilter::Pointer BinaryMagnitudeImageFilterObj = itk::BinaryMagnitudeImageFilter::New(); std::cout << "-------------BinaryMagnitudeImageFilter" << BinaryMagnitudeImageFilterObj; - itk::BinaryMedianImageFilter::Pointer BinaryMedianImageFilterObj = + const itk::BinaryMedianImageFilter::Pointer BinaryMedianImageFilterObj = itk::BinaryMedianImageFilter::New(); std::cout << "-------------BinaryMedianImageFilter" << BinaryMedianImageFilterObj; - itk::BinaryThresholdImageFilter::Pointer BinaryThresholdImageFilterObj = + const itk::BinaryThresholdImageFilter::Pointer BinaryThresholdImageFilterObj = itk::BinaryThresholdImageFilter::New(); std::cout << "-------------BinaryThresholdImageFilter" << BinaryThresholdImageFilterObj; - itk::BinomialBlurImageFilter::Pointer BinomialBlurImageFilterObj = + const itk::BinomialBlurImageFilter::Pointer BinomialBlurImageFilterObj = itk::BinomialBlurImageFilter::New(); std::cout << "-------------BinomialBlurImageFilter" << BinomialBlurImageFilterObj; - itk::CannyEdgeDetectionImageFilter::Pointer CannyEdgeDetectionImageFilterObj = + const itk::CannyEdgeDetectionImageFilter::Pointer CannyEdgeDetectionImageFilterObj = itk::CannyEdgeDetectionImageFilter::New(); std::cout << "-------------CannyEdgeDetectionImageFilter" << CannyEdgeDetectionImageFilterObj; - itk::CastImageFilter::Pointer CastImageFilterObj = + const itk::CastImageFilter::Pointer CastImageFilterObj = itk::CastImageFilter::New(); std::cout << "-------------CastImageFilter" << CastImageFilterObj; - itk::ChangeInformationImageFilter::Pointer ChangeInformationImageFilterObj = + const itk::ChangeInformationImageFilter::Pointer ChangeInformationImageFilterObj = itk::ChangeInformationImageFilter::New(); std::cout << "-------------ChangeInformationImageFilter" << ChangeInformationImageFilterObj; - itk::ComposeImageFilter::Pointer ComposeImageFilterObj = itk::ComposeImageFilter::New(); + const itk::ComposeImageFilter::Pointer ComposeImageFilterObj = itk::ComposeImageFilter::New(); std::cout << "-------------ComposeImageFilter" << ComposeImageFilterObj; - itk::ConfidenceConnectedImageFilter::Pointer ConfidenceConnectedImageFilterObj = + const itk::ConfidenceConnectedImageFilter::Pointer ConfidenceConnectedImageFilterObj = itk::ConfidenceConnectedImageFilter::New(); std::cout << "-------------ConfidenceConnectedImageFilter" << ConfidenceConnectedImageFilterObj; - itk::ConnectedThresholdImageFilter::Pointer ConnectedThresholdImageFilterObj = + const itk::ConnectedThresholdImageFilter::Pointer ConnectedThresholdImageFilterObj = itk::ConnectedThresholdImageFilter::New(); std::cout << "-------------ConnectedThresholdImageFilter" << ConnectedThresholdImageFilterObj; - itk::ConstantPadImageFilter::Pointer ConstantPadImageFilterObj = + const itk::ConstantPadImageFilter::Pointer ConstantPadImageFilterObj = itk::ConstantPadImageFilter::New(); std::cout << "-------------ConstantPadImageFilter" << ConstantPadImageFilterObj; - itk::CosImageFilter::Pointer CosImageFilterObj = + const itk::CosImageFilter::Pointer CosImageFilterObj = itk::CosImageFilter::New(); std::cout << "-------------CosImageFilter" << CosImageFilterObj; - itk::CropImageFilter::Pointer CropImageFilterObj = + const itk::CropImageFilter::Pointer CropImageFilterObj = itk::CropImageFilter::New(); std::cout << "-------------CropImageFilter" << CropImageFilterObj; - itk::CurvatureAnisotropicDiffusionImageFilter::Pointer + const itk::CurvatureAnisotropicDiffusionImageFilter::Pointer CurvatureAnisotropicDiffusionImageFilterObj = itk::CurvatureAnisotropicDiffusionImageFilter::New(); std::cout << "-------------CurvatureAnisotropicDiffusionImageFilter" << CurvatureAnisotropicDiffusionImageFilterObj; - itk::CurvatureNDAnisotropicDiffusionFunction::Pointer CurvatureNDAnisotropicDiffusionFunctionObj = + const itk::CurvatureNDAnisotropicDiffusionFunction::Pointer CurvatureNDAnisotropicDiffusionFunctionObj = itk::CurvatureNDAnisotropicDiffusionFunction::New(); std::cout << "-------------CurvatureNDAnisotropicDiffusionFunction" << CurvatureNDAnisotropicDiffusionFunctionObj; - itk::DanielssonDistanceMapImageFilter::Pointer DanielssonDistanceMapImageFilterObj = + const itk::DanielssonDistanceMapImageFilter::Pointer DanielssonDistanceMapImageFilterObj = itk::DanielssonDistanceMapImageFilter::New(); std::cout << "-------------DanielssonDistanceMapImageFilter" << DanielssonDistanceMapImageFilterObj; - itk::SignedDanielssonDistanceMapImageFilter::Pointer + const itk::SignedDanielssonDistanceMapImageFilter::Pointer SignedDanielssonDistanceMapImageFilterObj = itk::SignedDanielssonDistanceMapImageFilter::New(); std::cout << "-------------SignedDanielssonDistanceMapImageFilter" << SignedDanielssonDistanceMapImageFilterObj; - itk::DerivativeImageFilter::Pointer DerivativeImageFilterObj = + const itk::DerivativeImageFilter::Pointer DerivativeImageFilterObj = itk::DerivativeImageFilter::New(); std::cout << "-------------DerivativeImageFilter" << DerivativeImageFilterObj; - itk::DifferenceOfGaussiansGradientImageFilter::Pointer DifferenceOfGaussiansGradientImageFilterObj = - itk::DifferenceOfGaussiansGradientImageFilter::New(); + const itk::DifferenceOfGaussiansGradientImageFilter::Pointer + DifferenceOfGaussiansGradientImageFilterObj = + itk::DifferenceOfGaussiansGradientImageFilter::New(); std::cout << "-------------DifferenceOfGaussiansGradientImageFilter" << DifferenceOfGaussiansGradientImageFilterObj; - itk::DiffusionTensor3DReconstructionImageFilter::Pointer + const itk::DiffusionTensor3DReconstructionImageFilter::Pointer DiffusionTensor3DReconstructionImageFilterObj = itk::DiffusionTensor3DReconstructionImageFilter::New(); std::cout << "-------------DiffusionTensor3DReconstructionImageFilter" << DiffusionTensor3DReconstructionImageFilterObj; - itk::DilateObjectMorphologyImageFilter::Pointer + const itk::DilateObjectMorphologyImageFilter::Pointer DilateObjectMorphologyImageFilterObj = itk::DilateObjectMorphologyImageFilter::New(); std::cout << "-------------DilateObjectMorphologyImageFilter" << DilateObjectMorphologyImageFilterObj; - itk::DirectedHausdorffDistanceImageFilter::Pointer DirectedHausdorffDistanceImageFilterObj = - itk::DirectedHausdorffDistanceImageFilter::New(); + const itk::DirectedHausdorffDistanceImageFilter::Pointer + DirectedHausdorffDistanceImageFilterObj = itk::DirectedHausdorffDistanceImageFilter::New(); std::cout << "-------------DirectedHausdorffDistanceImageFilter" << DirectedHausdorffDistanceImageFilterObj; - itk::DiscreteGaussianImageFilter::Pointer DiscreteGaussianImageFilterObj = + const itk::DiscreteGaussianImageFilter::Pointer DiscreteGaussianImageFilterObj = itk::DiscreteGaussianImageFilter::New(); std::cout << "-------------DiscreteGaussianImageFilter" << DiscreteGaussianImageFilterObj; - itk::DivideImageFilter::Pointer DivideImageFilterObj = + const itk::DivideImageFilter::Pointer DivideImageFilterObj = itk::DivideImageFilter::New(); std::cout << "-------------DivideImageFilter" << DivideImageFilterObj; - itk::EdgePotentialImageFilter::Pointer EdgePotentialImageFilterObj = + const itk::EdgePotentialImageFilter::Pointer EdgePotentialImageFilterObj = itk::EdgePotentialImageFilter::New(); std::cout << "-------------EdgePotentialImageFilter" << EdgePotentialImageFilterObj; - itk::EigenAnalysis2DImageFilter::Pointer EigenAnalysis2DImageFilterObj = + const itk::EigenAnalysis2DImageFilter::Pointer EigenAnalysis2DImageFilterObj = itk::EigenAnalysis2DImageFilter::New(); std::cout << "-------------EigenAnalysis2DImageFilter" << EigenAnalysis2DImageFilterObj; - itk::ErodeObjectMorphologyImageFilter::Pointer + const itk::ErodeObjectMorphologyImageFilter::Pointer ErodeObjectMorphologyImageFilterObj = itk::ErodeObjectMorphologyImageFilter::New(); std::cout << "-------------ErodeObjectMorphologyImageFilter" << ErodeObjectMorphologyImageFilterObj; - itk::ExpImageFilter::Pointer ExpImageFilterObj = + const itk::ExpImageFilter::Pointer ExpImageFilterObj = itk::ExpImageFilter::New(); std::cout << "-------------ExpImageFilter" << ExpImageFilterObj; - itk::ExpNegativeImageFilter::Pointer ExpNegativeImageFilterObj = + const itk::ExpNegativeImageFilter::Pointer ExpNegativeImageFilterObj = itk::ExpNegativeImageFilter::New(); std::cout << "-------------ExpNegativeImageFilter" << ExpNegativeImageFilterObj; - itk::ExpandImageFilter::Pointer ExpandImageFilterObj = + const itk::ExpandImageFilter::Pointer ExpandImageFilterObj = itk::ExpandImageFilter::New(); std::cout << "-------------ExpandImageFilter" << ExpandImageFilterObj; - itk::ExtractImageFilter::Pointer ExtractImageFilterObj = + const itk::ExtractImageFilter::Pointer ExtractImageFilterObj = itk::ExtractImageFilter::New(); std::cout << "-------------ExtractImageFilter" << ExtractImageFilterObj; - itk::FlipImageFilter::Pointer FlipImageFilterObj = itk::FlipImageFilter::New(); + const itk::FlipImageFilter::Pointer FlipImageFilterObj = itk::FlipImageFilter::New(); std::cout << "-------------FlipImageFilter" << FlipImageFilterObj; - itk::GaussianImageSource::Pointer GaussianImageSourceObj = itk::GaussianImageSource::New(); + const itk::GaussianImageSource::Pointer GaussianImageSourceObj = + itk::GaussianImageSource::New(); std::cout << "-------------GaussianImageSource" << GaussianImageSourceObj; - itk::GradientAnisotropicDiffusionImageFilter::Pointer + const itk::GradientAnisotropicDiffusionImageFilter::Pointer GradientAnisotropicDiffusionImageFilterObj = itk::GradientAnisotropicDiffusionImageFilter::New(); std::cout << "-------------GradientAnisotropicDiffusionImageFilter" << GradientAnisotropicDiffusionImageFilterObj; - itk::GradientImageFilter::Pointer GradientImageFilterObj = itk::GradientImageFilter::New(); + const itk::GradientImageFilter::Pointer GradientImageFilterObj = + itk::GradientImageFilter::New(); std::cout << "-------------GradientImageFilter" << GradientImageFilterObj; - itk::GradientMagnitudeImageFilter::Pointer GradientMagnitudeImageFilterObj = + const itk::GradientMagnitudeImageFilter::Pointer GradientMagnitudeImageFilterObj = itk::GradientMagnitudeImageFilter::New(); std::cout << "-------------GradientMagnitudeImageFilter" << GradientMagnitudeImageFilterObj; - itk::GradientMagnitudeRecursiveGaussianImageFilter::Pointer + const itk::GradientMagnitudeRecursiveGaussianImageFilter::Pointer GradientMagnitudeRecursiveGaussianImageFilterObj = itk::GradientMagnitudeRecursiveGaussianImageFilter::New(); std::cout << "-------------GradientMagnitudeRecursiveGaussianImageFilter" << GradientMagnitudeRecursiveGaussianImageFilterObj; - itk::GradientNDAnisotropicDiffusionFunction::Pointer GradientNDAnisotropicDiffusionFunctionObj = + const itk::GradientNDAnisotropicDiffusionFunction::Pointer GradientNDAnisotropicDiffusionFunctionObj = itk::GradientNDAnisotropicDiffusionFunction::New(); std::cout << "-------------GradientNDAnisotropicDiffusionFunction" << GradientNDAnisotropicDiffusionFunctionObj; - itk::GradientRecursiveGaussianImageFilter::Pointer GradientRecursiveGaussianImageFilterObj = + const itk::GradientRecursiveGaussianImageFilter::Pointer GradientRecursiveGaussianImageFilterObj = itk::GradientRecursiveGaussianImageFilter::New(); std::cout << "-------------GradientRecursiveGaussianImageFilter" << GradientRecursiveGaussianImageFilterObj; - itk::GrayscaleDilateImageFilter::Pointer GrayscaleDilateImageFilterObj = + const itk::GrayscaleDilateImageFilter::Pointer GrayscaleDilateImageFilterObj = itk::GrayscaleDilateImageFilter::New(); std::cout << "-------------GrayscaleDilateImageFilter" << GrayscaleDilateImageFilterObj; - itk::GrayscaleErodeImageFilter::Pointer GrayscaleErodeImageFilterObj = + const itk::GrayscaleErodeImageFilter::Pointer GrayscaleErodeImageFilterObj = itk::GrayscaleErodeImageFilter::New(); std::cout << "-------------GrayscaleErodeImageFilter" << GrayscaleErodeImageFilterObj; - itk::GrayscaleFunctionDilateImageFilter::Pointer + const itk::GrayscaleFunctionDilateImageFilter::Pointer GrayscaleFunctionDilateImageFilterObj = itk::GrayscaleFunctionDilateImageFilter::New(); std::cout << "-------------GrayscaleFunctionDilateImageFilter" << GrayscaleFunctionDilateImageFilterObj; - itk::GrayscaleFunctionErodeImageFilter::Pointer + const itk::GrayscaleFunctionErodeImageFilter::Pointer GrayscaleFunctionErodeImageFilterObj = itk::GrayscaleFunctionErodeImageFilter::New(); std::cout << "-------------GrayscaleFunctionErodeImageFilter" << GrayscaleFunctionErodeImageFilterObj; - itk::HardConnectedComponentImageFilter::Pointer HardConnectedComponentImageFilterObj = + const itk::HardConnectedComponentImageFilter::Pointer HardConnectedComponentImageFilterObj = itk::HardConnectedComponentImageFilter::New(); std::cout << "-------------HardConnectedComponentImageFilter" << HardConnectedComponentImageFilterObj; - itk::HausdorffDistanceImageFilter::Pointer HausdorffDistanceImageFilterObj = + const itk::HausdorffDistanceImageFilter::Pointer HausdorffDistanceImageFilterObj = itk::HausdorffDistanceImageFilter::New(); std::cout << "-------------HausdorffDistanceImageFilter" << HausdorffDistanceImageFilterObj; diff --git a/Modules/Nonunit/IntegratedTest/test/itkCommonPrintTest.cxx b/Modules/Nonunit/IntegratedTest/test/itkCommonPrintTest.cxx index 22d8affadb4..64cf287a780 100644 --- a/Modules/Nonunit/IntegratedTest/test/itkCommonPrintTest.cxx +++ b/Modules/Nonunit/IntegratedTest/test/itkCommonPrintTest.cxx @@ -122,342 +122,349 @@ itkCommonPrintTest(int, char *[]) // Used for ImageAdaptor using RedAccessorType = itk::RedPixelAccessor; - itk::AcosImageAdaptor::Pointer AcosImageAdaptorObj = + const itk::AcosImageAdaptor::Pointer AcosImageAdaptorObj = itk::AcosImageAdaptor::New(); std::cout << "------------AcosImageAdaptor" << AcosImageAdaptorObj; - itk::AddImageAdaptor::Pointer AddImageAdaptorObj = itk::AddImageAdaptor::New(); + const itk::AddImageAdaptor::Pointer AddImageAdaptorObj = itk::AddImageAdaptor::New(); std::cout << "------------AddImageAdaptor" << AddImageAdaptorObj; - itk::AffineTransform::Pointer AffineTransformObj = itk::AffineTransform::New(); + const itk::AffineTransform::Pointer AffineTransformObj = itk::AffineTransform::New(); std::cout << "------------AffineTransform" << AffineTransformObj; - itk::AsinImageAdaptor::Pointer AsinImageAdaptorObj = + const itk::AsinImageAdaptor::Pointer AsinImageAdaptorObj = itk::AsinImageAdaptor::New(); std::cout << "------------AsinImageAdaptor" << AsinImageAdaptorObj; - itk::AtanImageAdaptor::Pointer AtanImageAdaptorObj = + const itk::AtanImageAdaptor::Pointer AtanImageAdaptorObj = itk::AtanImageAdaptor::New(); std::cout << "------------AtanImageAdaptor" << AtanImageAdaptorObj; - itk::AzimuthElevationToCartesianTransform::Pointer AzimuthElevationToCartesianTransformObj = + const itk::AzimuthElevationToCartesianTransform::Pointer AzimuthElevationToCartesianTransformObj = itk::AzimuthElevationToCartesianTransform::New(); std::cout << "------------AzimuthElevationToCartesianTransform" << AzimuthElevationToCartesianTransformObj; - itk::BSplineTransform::Pointer BSplineTransformObj = itk::BSplineTransform::New(); + const itk::BSplineTransform::Pointer BSplineTransformObj = itk::BSplineTransform::New(); std::cout << "------------BSplineTransform" << BSplineTransformObj; - itk::BSplineDerivativeKernelFunction<3>::Pointer BSplineDerivativeKernelFunctionObj = + const itk::BSplineDerivativeKernelFunction<3>::Pointer BSplineDerivativeKernelFunctionObj = itk::BSplineDerivativeKernelFunction<3>::New(); std::cout << "------------BSplineDerivativeKernelFunction" << BSplineDerivativeKernelFunctionObj; - itk::BSplineInterpolationWeightFunction::Pointer BSplineInterpolationWeightFunctionObj = + const itk::BSplineInterpolationWeightFunction::Pointer BSplineInterpolationWeightFunctionObj = itk::BSplineInterpolationWeightFunction::New(); std::cout << "------------BSplineInterpolationWeightFunction" << BSplineInterpolationWeightFunctionObj; - itk::BSplineKernelFunction<3>::Pointer BSplineKernelFunctionObj = itk::BSplineKernelFunction<3>::New(); + const itk::BSplineKernelFunction<3>::Pointer BSplineKernelFunctionObj = itk::BSplineKernelFunction<3>::New(); std::cout << "------------BSplineKernelFunction" << BSplineKernelFunctionObj; - itk::BinaryThresholdImageFunction::Pointer BinaryThresholdImageFunctionObj = + const itk::BinaryThresholdImageFunction::Pointer BinaryThresholdImageFunctionObj = itk::BinaryThresholdImageFunction::New(); std::cout << "------------BinaryThresholdImageFunction" << BinaryThresholdImageFunctionObj; - itk::BoundingBox::Pointer BoundingBoxObj = itk::BoundingBox::New(); + const itk::BoundingBox::Pointer BoundingBoxObj = itk::BoundingBox::New(); std::cout << "------------BoundingBox" << BoundingBoxObj; - itk::CenteredAffineTransform::Pointer CenteredAffineTransformObj = + const itk::CenteredAffineTransform::Pointer CenteredAffineTransformObj = itk::CenteredAffineTransform::New(); std::cout << "------------CenteredAffineTransform" << CenteredAffineTransformObj; - itk::CenteredRigid2DTransform::Pointer CenteredRigid2DTransformObj = + const itk::CenteredRigid2DTransform::Pointer CenteredRigid2DTransformObj = itk::CenteredRigid2DTransform::New(); std::cout << "------------CenteredRigid2DTransform" << CenteredRigid2DTransformObj; - itk::CenteredTransformInitializer::Pointer CenteredTransformInitializerObj = - itk::CenteredTransformInitializer::New(); + const itk::CenteredTransformInitializer::Pointer + CenteredTransformInitializerObj = itk::CenteredTransformInitializer::New(); std::cout << "------------CenteredTransformInitializer" << CenteredTransformInitializerObj; - itk::CentralDifferenceImageFunction::Pointer CentralDifferenceImageFunctionObj = + const itk::CentralDifferenceImageFunction::Pointer CentralDifferenceImageFunctionObj = itk::CentralDifferenceImageFunction::New(); std::cout << "------------CentralDifferenceImageFunction" << CentralDifferenceImageFunctionObj; - itk::ColorTable::Pointer ColorTableObj = itk::ColorTable::New(); + const itk::ColorTable::Pointer ColorTableObj = itk::ColorTable::New(); std::cout << "------------ColorTable" << ColorTableObj; - itk::ConicShellInteriorExteriorSpatialFunction<3>::Pointer ConicShellInteriorExteriorSpatialFunctionObj = + const itk::ConicShellInteriorExteriorSpatialFunction<3>::Pointer ConicShellInteriorExteriorSpatialFunctionObj = itk::ConicShellInteriorExteriorSpatialFunction<3>::New(); std::cout << "------------ConicShellInteriorExteriorSpatialFunction" << ConicShellInteriorExteriorSpatialFunctionObj; - itk::CosImageAdaptor::Pointer CosImageAdaptorObj = + const itk::CosImageAdaptor::Pointer CosImageAdaptorObj = itk::CosImageAdaptor::New(); std::cout << "------------CosImageAdaptor" << CosImageAdaptorObj; - itk::ElasticBodyReciprocalSplineKernelTransform::Pointer ElasticBodyReciprocalSplineKernelTransformObj = - itk::ElasticBodyReciprocalSplineKernelTransform::New(); + const itk::ElasticBodyReciprocalSplineKernelTransform::Pointer + ElasticBodyReciprocalSplineKernelTransformObj = itk::ElasticBodyReciprocalSplineKernelTransform::New(); std::cout << "------------ElasticBodyReciprocalSplineKernelTransform" << ElasticBodyReciprocalSplineKernelTransformObj; - itk::ElasticBodySplineKernelTransform::Pointer ElasticBodySplineKernelTransformObj = + const itk::ElasticBodySplineKernelTransform::Pointer ElasticBodySplineKernelTransformObj = itk::ElasticBodySplineKernelTransform::New(); std::cout << "------------ElasticBodySplineKernelTransform" << ElasticBodySplineKernelTransformObj; - itk::EllipsoidInteriorExteriorSpatialFunction<2, PointType>::Pointer EllipsoidInteriorExteriorSpatialFunctionObj = - itk::EllipsoidInteriorExteriorSpatialFunction<2, PointType>::New(); + const itk::EllipsoidInteriorExteriorSpatialFunction<2, PointType>::Pointer + EllipsoidInteriorExteriorSpatialFunctionObj = itk::EllipsoidInteriorExteriorSpatialFunction<2, PointType>::New(); std::cout << "------------EllipsoidInteriorExteriorSpatialFunction" << EllipsoidInteriorExteriorSpatialFunctionObj; - itk::EquivalencyTable::Pointer EquivalencyTableObj = itk::EquivalencyTable::New(); + const itk::EquivalencyTable::Pointer EquivalencyTableObj = itk::EquivalencyTable::New(); std::cout << "-------------EquivalencyTable " << EquivalencyTableObj; - itk::Euler2DTransform::Pointer Euler2DTransformObj = itk::Euler2DTransform::New(); + const itk::Euler2DTransform::Pointer Euler2DTransformObj = itk::Euler2DTransform::New(); std::cout << "------------Euler2DTransform" << Euler2DTransformObj; - itk::Euler3DTransform::Pointer Euler3DTransformObj = itk::Euler3DTransform::New(); + const itk::Euler3DTransform::Pointer Euler3DTransformObj = itk::Euler3DTransform::New(); std::cout << "------------Euler3DTransform" << Euler3DTransformObj; - itk::ExpImageAdaptor::Pointer ExpImageAdaptorObj = + const itk::ExpImageAdaptor::Pointer ExpImageAdaptorObj = itk::ExpImageAdaptor::New(); std::cout << "------------ExpImageAdaptor" << ExpImageAdaptorObj; - itk::ExpNegativeImageAdaptor::Pointer ExpNegativeImageAdaptorObj = + const itk::ExpNegativeImageAdaptor::Pointer ExpNegativeImageAdaptorObj = itk::ExpNegativeImageAdaptor::New(); std::cout << "------------ExpNegativeImageAdaptor" << ExpNegativeImageAdaptorObj; - itk::FileOutputWindow::Pointer FileOutputWindowObj = itk::FileOutputWindow::New(); + const itk::FileOutputWindow::Pointer FileOutputWindowObj = itk::FileOutputWindow::New(); std::cout << "------------FileOutputWindow" << FileOutputWindowObj; - itk::FiniteCylinderSpatialFunction<3, Point3DType>::Pointer FiniteCylinderSpatialFunctionObj = + const itk::FiniteCylinderSpatialFunction<3, Point3DType>::Pointer FiniteCylinderSpatialFunctionObj = itk::FiniteCylinderSpatialFunction<3, Point3DType>::New(); std::cout << "------------FiniteCylinderSpatialFunction" << FiniteCylinderSpatialFunctionObj; - itk::FrustumSpatialFunction<3, Point3DType>::Pointer FrustumSpatialFunctionObj = + const itk::FrustumSpatialFunction<3, Point3DType>::Pointer FrustumSpatialFunctionObj = itk::FrustumSpatialFunction<3, Point3DType>::New(); std::cout << "------------FrustumSpatialFunction" << FrustumSpatialFunctionObj; - itk::GaussianKernelFunction::Pointer GaussianKernelFunctionObj = itk::GaussianKernelFunction::New(); + const itk::GaussianKernelFunction::Pointer GaussianKernelFunctionObj = + itk::GaussianKernelFunction::New(); std::cout << "------------GaussianKernelFunction" << GaussianKernelFunctionObj; - itk::GaussianSpatialFunction::Pointer GaussianSpatialFunctionObj = + const itk::GaussianSpatialFunction::Pointer GaussianSpatialFunctionObj = itk::GaussianSpatialFunction::New(); std::cout << "------------GaussianSpatialFunction" << GaussianSpatialFunctionObj; - itk::IdentityTransform::Pointer IdentityTransformObj = itk::IdentityTransform::New(); + const itk::IdentityTransform::Pointer IdentityTransformObj = itk::IdentityTransform::New(); std::cout << "------------IdentityTransform" << IdentityTransformObj; - itk::Image::Pointer ImageObj = itk::Image::New(); + const itk::Image::Pointer ImageObj = itk::Image::New(); std::cout << "------------Image" << ImageObj; - itk::ImageAdaptor::Pointer ImageAdaptorObj = + const itk::ImageAdaptor::Pointer ImageAdaptorObj = itk::ImageAdaptor::New(); std::cout << "------------ImageAdaptor" << ImageAdaptorObj; - itk::ImageBase<3>::Pointer ImageBaseObj = itk::ImageBase<3>::New(); + const itk::ImageBase<3>::Pointer ImageBaseObj = itk::ImageBase<3>::New(); std::cout << "------------ImageBase" << ImageBaseObj; - itk::ImageRegionSplitterMultidimensional::Pointer ImageRegionSplitterMultidimensionalObj = + const itk::ImageRegionSplitterMultidimensional::Pointer ImageRegionSplitterMultidimensionalObj = itk::ImageRegionSplitterMultidimensional::New(); std::cout << "------------ImageRegionSplitterMultidimensional" << ImageRegionSplitterMultidimensionalObj; - itk::ImportImageContainer::Pointer ImportImageContainerObj = + const itk::ImportImageContainer::Pointer ImportImageContainerObj = itk::ImportImageContainer::New(); std::cout << "------------ImportImageContainer" << ImportImageContainerObj; - itk::KLMSegmentationBorder::Pointer KLMSegmentationBorderObj = itk::KLMSegmentationBorder::New(); + const itk::KLMSegmentationBorder::Pointer KLMSegmentationBorderObj = itk::KLMSegmentationBorder::New(); std::cout << "------------KLMSegmentationBorder" << KLMSegmentationBorderObj; - itk::KLMSegmentationRegion::Pointer KLMSegmentationRegionObj = itk::KLMSegmentationRegion::New(); + const itk::KLMSegmentationRegion::Pointer KLMSegmentationRegionObj = itk::KLMSegmentationRegion::New(); std::cout << "------------KLMSegmentationRegion" << KLMSegmentationRegionObj; - itk::KernelTransform::Pointer KernelTransformObj = itk::KernelTransform::New(); + const itk::KernelTransform::Pointer KernelTransformObj = itk::KernelTransform::New(); std::cout << "------------KernelTransform" << KernelTransformObj; - itk::LevelSetFunction::Pointer LevelSetFunctionObj = itk::LevelSetFunction::New(); + const itk::LevelSetFunction::Pointer LevelSetFunctionObj = itk::LevelSetFunction::New(); std::cout << "------------LevelSetFunction" << LevelSetFunctionObj; - itk::LightProcessObject::Pointer LightProcessObjectObj = itk::LightProcessObject::New(); + const itk::LightProcessObject::Pointer LightProcessObjectObj = itk::LightProcessObject::New(); std::cout << "------------LightProcessObject" << LightProcessObjectObj; - itk::LinearInterpolateImageFunction::Pointer LinearInterpolateImageFunctionObj = + const itk::LinearInterpolateImageFunction::Pointer LinearInterpolateImageFunctionObj = itk::LinearInterpolateImageFunction::New(); std::cout << "------------LinearInterpolateImageFunction" << LinearInterpolateImageFunctionObj; - itk::Log10ImageAdaptor::Pointer Log10ImageAdaptorObj = + const itk::Log10ImageAdaptor::Pointer Log10ImageAdaptorObj = itk::Log10ImageAdaptor::New(); std::cout << "------------Log10ImageAdaptor" << Log10ImageAdaptorObj; - itk::LogImageAdaptor::Pointer LogImageAdaptorObj = + const itk::LogImageAdaptor::Pointer LogImageAdaptorObj = itk::LogImageAdaptor::New(); std::cout << "------------LogImageAdaptor" << LogImageAdaptorObj; - itk::MapContainer::Pointer MapContainerObj = + const itk::MapContainer::Pointer MapContainerObj = itk::MapContainer::New(); std::cout << "------------MapContainer" << MapContainerObj; - itk::MatrixResizeableDataObject::Pointer MatrixResizeableDataObjectObj = + const itk::MatrixResizeableDataObject::Pointer MatrixResizeableDataObjectObj = itk::MatrixResizeableDataObject::New(); std::cout << "------------MatrixResizeableDataObject" << MatrixResizeableDataObjectObj; - itk::Statistics::MaximumDecisionRule::Pointer MaximumDecisionRuleObj = itk::Statistics::MaximumDecisionRule::New(); + const itk::Statistics::MaximumDecisionRule::Pointer MaximumDecisionRuleObj = + itk::Statistics::MaximumDecisionRule::New(); std::cout << "------------MaximumDecisionRule" << MaximumDecisionRuleObj; - itk::Statistics::MaximumRatioDecisionRule::Pointer MaximumRatioDecisionRuleObj = + const itk::Statistics::MaximumRatioDecisionRule::Pointer MaximumRatioDecisionRuleObj = itk::Statistics::MaximumRatioDecisionRule::New(); std::cout << "------------MaximumRatioDecisionRule" << MaximumRatioDecisionRuleObj; - itk::MeanImageFunction::Pointer MeanImageFunctionObj = + const itk::MeanImageFunction::Pointer MeanImageFunctionObj = itk::MeanImageFunction::New(); std::cout << "------------MeanImageFunction" << MeanImageFunctionObj; - itk::MedianImageFunction::Pointer MedianImageFunctionObj = + const itk::MedianImageFunction::Pointer MedianImageFunctionObj = itk::MedianImageFunction::New(); std::cout << "------------MedianImageFunction" << MedianImageFunctionObj; - itk::Mesh::Pointer MeshObj = itk::Mesh::New(); + const itk::Mesh::Pointer MeshObj = itk::Mesh::New(); std::cout << "------------Mesh" << MeshObj; - itk::MeshSource::Pointer MeshSourceObj = itk::MeshSource::New(); + const itk::MeshSource::Pointer MeshSourceObj = itk::MeshSource::New(); std::cout << "------------MeshSource" << MeshSourceObj; - itk::MeshToMeshFilter::Pointer MeshToMeshFilterObj = + const itk::MeshToMeshFilter::Pointer MeshToMeshFilterObj = itk::MeshToMeshFilter::New(); std::cout << "------------MeshToMeshFilter" << MeshToMeshFilterObj; - itk::Statistics::MinimumDecisionRule::Pointer MinimumDecisionRuleObj = itk::Statistics::MinimumDecisionRule::New(); + const itk::Statistics::MinimumDecisionRule::Pointer MinimumDecisionRuleObj = + itk::Statistics::MinimumDecisionRule::New(); std::cout << "------------MinimumDecisionRule" << MinimumDecisionRuleObj; - itk::MultiThreaderBase::Pointer MultiThreaderObj = itk::MultiThreaderBase::New(); + const itk::MultiThreaderBase::Pointer MultiThreaderObj = itk::MultiThreaderBase::New(); std::cout << "------------MultiThreaderBase" << MultiThreaderObj; - itk::NearestNeighborInterpolateImageFunction::Pointer NearestNeighborInterpolateImageFunctionObj = - itk::NearestNeighborInterpolateImageFunction::New(); + const itk::NearestNeighborInterpolateImageFunction::Pointer + NearestNeighborInterpolateImageFunctionObj = itk::NearestNeighborInterpolateImageFunction::New(); std::cout << "------------NearestNeighborInterpolateImageFunction" << NearestNeighborInterpolateImageFunctionObj; - itk::NeighborhoodBinaryThresholdImageFunction::Pointer NeighborhoodBinaryThresholdImageFunctionObj = - itk::NeighborhoodBinaryThresholdImageFunction::New(); + const itk::NeighborhoodBinaryThresholdImageFunction::Pointer + NeighborhoodBinaryThresholdImageFunctionObj = + itk::NeighborhoodBinaryThresholdImageFunction::New(); std::cout << "------------NeighborhoodBinaryThresholdImageFunction" << NeighborhoodBinaryThresholdImageFunctionObj; - itk::NthElementImageAdaptor::Pointer NthElementImageAdaptorObj = + const itk::NthElementImageAdaptor::Pointer NthElementImageAdaptorObj = itk::NthElementImageAdaptor::New(); std::cout << "------------NthElementImageAdaptor" << NthElementImageAdaptorObj; - itk::ObjectStore::Pointer ObjectStoreObj = itk::ObjectStore::New(); + const itk::ObjectStore::Pointer ObjectStoreObj = itk::ObjectStore::New(); std::cout << "------------ObjectStore" << ObjectStoreObj; - itk::OneWayEquivalencyTable::Pointer OneWayEquivalencyTableObj = itk::OneWayEquivalencyTable::New(); + const itk::OneWayEquivalencyTable::Pointer OneWayEquivalencyTableObj = itk::OneWayEquivalencyTable::New(); std::cout << "-------------OneWayEquivalencyTable " << OneWayEquivalencyTableObj; - itk::PointSet::Pointer PointSetObj = itk::PointSet::New(); + const itk::PointSet::Pointer PointSetObj = itk::PointSet::New(); std::cout << "------------PointSet" << PointSetObj; - itk::ProgressAccumulator::Pointer ProgressAccumulatorObj = itk::ProgressAccumulator::New(); + const itk::ProgressAccumulator::Pointer ProgressAccumulatorObj = itk::ProgressAccumulator::New(); std::cout << "------------ProgressAccumulator" << ProgressAccumulatorObj; - itk::QuaternionRigidTransform::Pointer QuaternionRigidTransformObj = + const itk::QuaternionRigidTransform::Pointer QuaternionRigidTransformObj = itk::QuaternionRigidTransform::New(); std::cout << "------------QuaternionRigidTransform" << QuaternionRigidTransformObj; - itk::RGBToVectorImageAdaptor::Pointer RGBToVectorImageAdaptorObj = + const itk::RGBToVectorImageAdaptor::Pointer RGBToVectorImageAdaptorObj = itk::RGBToVectorImageAdaptor::New(); std::cout << "------------RGBToVectorImageAdaptor" << RGBToVectorImageAdaptorObj; - itk::Rigid2DTransform::Pointer Rigid2DTransformObj = itk::Rigid2DTransform::New(); + const itk::Rigid2DTransform::Pointer Rigid2DTransformObj = itk::Rigid2DTransform::New(); std::cout << "------------Rigid2DTransform" << Rigid2DTransformObj; - itk::Rigid3DPerspectiveTransform::Pointer Rigid3DPerspectiveTransformObj = + const itk::Rigid3DPerspectiveTransform::Pointer Rigid3DPerspectiveTransformObj = itk::Rigid3DPerspectiveTransform::New(); std::cout << "------------Rigid3DPerspectiveTransform" << Rigid3DPerspectiveTransformObj; - itk::ScaleTransform::Pointer ScaleTransformObj = itk::ScaleTransform::New(); + const itk::ScaleTransform::Pointer ScaleTransformObj = itk::ScaleTransform::New(); std::cout << "------------ScaleTransform" << ScaleTransformObj; - itk::SegmentationBorder::Pointer SegmentationBorderObj = itk::SegmentationBorder::New(); + const itk::SegmentationBorder::Pointer SegmentationBorderObj = itk::SegmentationBorder::New(); std::cout << "------------SegmentationBorder" << SegmentationBorderObj; - itk::SegmentationRegion::Pointer SegmentationRegionObj = itk::SegmentationRegion::New(); + const itk::SegmentationRegion::Pointer SegmentationRegionObj = itk::SegmentationRegion::New(); std::cout << "------------SegmentationRegion" << SegmentationRegionObj; - itk::Similarity2DTransform::Pointer Similarity2DTransformObj = itk::Similarity2DTransform::New(); + const itk::Similarity2DTransform::Pointer Similarity2DTransformObj = + itk::Similarity2DTransform::New(); std::cout << "------------Similarity2DTransform" << Similarity2DTransformObj; - itk::SinImageAdaptor::Pointer SinImageAdaptorObj = + const itk::SinImageAdaptor::Pointer SinImageAdaptorObj = itk::SinImageAdaptor::New(); std::cout << "------------SinImageAdaptor" << SinImageAdaptorObj; - itk::SphereSpatialFunction<2, PointType>::Pointer SphereSpatialFunctionObj = + const itk::SphereSpatialFunction<2, PointType>::Pointer SphereSpatialFunctionObj = itk::SphereSpatialFunction<2, PointType>::New(); std::cout << "------------SphereSpatialFunction" << SphereSpatialFunctionObj; - itk::SqrtImageAdaptor::Pointer SqrtImageAdaptorObj = + const itk::SqrtImageAdaptor::Pointer SqrtImageAdaptorObj = itk::SqrtImageAdaptor::New(); std::cout << "------------SqrtImageAdaptor" << SqrtImageAdaptorObj; - itk::SymmetricEllipsoidInteriorExteriorSpatialFunction<>::Pointer + const itk::SymmetricEllipsoidInteriorExteriorSpatialFunction<>::Pointer SymmetricEllipsoidInteriorExteriorSpatialFunctionObj = itk::SymmetricEllipsoidInteriorExteriorSpatialFunction<>::New(); std::cout << "------------SymmetricEllipsoidInteriorExteriorSpatialFunction" << SymmetricEllipsoidInteriorExteriorSpatialFunctionObj; - itk::TanImageAdaptor::Pointer TanImageAdaptorObj = + const itk::TanImageAdaptor::Pointer TanImageAdaptorObj = itk::TanImageAdaptor::New(); std::cout << "------------TanImageAdaptor" << TanImageAdaptorObj; - itk::TextOutput::Pointer TextOutputObj = itk::TextOutput::New(); + const itk::TextOutput::Pointer TextOutputObj = itk::TextOutput::New(); std::cout << "------------TextOutput" << TextOutputObj; - itk::ThinPlateR2LogRSplineKernelTransform::Pointer ThinPlateR2LogRSplineKernelTransformObj = + const itk::ThinPlateR2LogRSplineKernelTransform::Pointer ThinPlateR2LogRSplineKernelTransformObj = itk::ThinPlateR2LogRSplineKernelTransform::New(); std::cout << "------------ThinPlateR2LogRSplineKernelTransform" << ThinPlateR2LogRSplineKernelTransformObj; - itk::ThinPlateSplineKernelTransform::Pointer ThinPlateSplineKernelTransformObj = + const itk::ThinPlateSplineKernelTransform::Pointer ThinPlateSplineKernelTransformObj = itk::ThinPlateSplineKernelTransform::New(); std::cout << "------------ThinPlateSplineKernelTransform" << ThinPlateSplineKernelTransformObj; - itk::TorusInteriorExteriorSpatialFunction<>::Pointer TorusInteriorExteriorSpatialFunctionObj = + const itk::TorusInteriorExteriorSpatialFunction<>::Pointer TorusInteriorExteriorSpatialFunctionObj = itk::TorusInteriorExteriorSpatialFunction<>::New(); std::cout << "------------TorusInteriorExteriorSpatialFunction" << TorusInteriorExteriorSpatialFunctionObj; - itk::TranslationTransform::Pointer TranslationTransformObj = itk::TranslationTransform::New(); + const itk::TranslationTransform::Pointer TranslationTransformObj = + itk::TranslationTransform::New(); std::cout << "------------TranslationTransform" << TranslationTransformObj; - itk::ValarrayImageContainer::Pointer ValarrayImageContainerObj = + const itk::ValarrayImageContainer::Pointer ValarrayImageContainerObj = itk::ValarrayImageContainer::New(); std::cout << "------------ValarrayImageContainer" << ValarrayImageContainerObj; - itk::VarianceImageFunction::Pointer VarianceImageFunctionObj = + const itk::VarianceImageFunction::Pointer VarianceImageFunctionObj = itk::VarianceImageFunction::New(); std::cout << "------------VarianceImageFunction" << VarianceImageFunctionObj; - itk::VectorContainer::Pointer VectorContainerObj = itk::VectorContainer::New(); + const itk::VectorContainer::Pointer VectorContainerObj = itk::VectorContainer::New(); std::cout << "------------VectorContainer" << VectorContainerObj; - itk::VectorImage::Pointer VectorImageObj = itk::VectorImage::New(); + const itk::VectorImage::Pointer VectorImageObj = itk::VectorImage::New(); std::cout << "------------VectorImage" << VectorImageObj; - itk::VectorLinearInterpolateImageFunction::Pointer VectorLinearInterpolateImageFunctionObj = - itk::VectorLinearInterpolateImageFunction::New(); + const itk::VectorLinearInterpolateImageFunction::Pointer + VectorLinearInterpolateImageFunctionObj = itk::VectorLinearInterpolateImageFunction::New(); std::cout << "------------VectorLinearInterpolateImageFunction" << VectorLinearInterpolateImageFunctionObj; - itk::VectorToRGBImageAdaptor::Pointer VectorToRGBImageAdaptorObj = + const itk::VectorToRGBImageAdaptor::Pointer VectorToRGBImageAdaptorObj = itk::VectorToRGBImageAdaptor::New(); std::cout << "------------VectorToRGBImageAdaptor" << VectorToRGBImageAdaptorObj; - itk::Version::Pointer VersionObj = itk::Version::New(); + const itk::Version::Pointer VersionObj = itk::Version::New(); std::cout << "------------Version" << VersionObj; - itk::ScaleSkewVersor3DTransform::Pointer ScaleSkewVersor3DTransformObj = + const itk::ScaleSkewVersor3DTransform::Pointer ScaleSkewVersor3DTransformObj = itk::ScaleSkewVersor3DTransform::New(); std::cout << "------------ScaleSkewVersor3DTransform" << ScaleSkewVersor3DTransformObj; - itk::VersorRigid3DTransform::Pointer VersorRigid3DTransformObj = itk::VersorRigid3DTransform::New(); + const itk::VersorRigid3DTransform::Pointer VersorRigid3DTransformObj = + itk::VersorRigid3DTransform::New(); std::cout << "------------VersorRigid3DTransform" << VersorRigid3DTransformObj; - itk::VersorTransform::Pointer VersorTransformObj = itk::VersorTransform::New(); + const itk::VersorTransform::Pointer VersorTransformObj = itk::VersorTransform::New(); std::cout << "------------VersorTransform" << VersorTransformObj; - itk::VolumeSplineKernelTransform::Pointer VolumeSplineKernelTransformObj = + const itk::VolumeSplineKernelTransform::Pointer VolumeSplineKernelTransformObj = itk::VolumeSplineKernelTransform::New(); std::cout << "------------VolumeSplineKernelTransform" << VolumeSplineKernelTransformObj; - itk::XMLFileOutputWindow::Pointer XMLFileOutputWindowObj = itk::XMLFileOutputWindow::New(); + const itk::XMLFileOutputWindow::Pointer XMLFileOutputWindowObj = itk::XMLFileOutputWindow::New(); std::cout << "------------XMLFileOutputWindow" << XMLFileOutputWindowObj; diff --git a/Modules/Nonunit/IntegratedTest/test/itkFilterImageAddTest.cxx b/Modules/Nonunit/IntegratedTest/test/itkFilterImageAddTest.cxx index 5e2a023b7af..93b7b52840e 100644 --- a/Modules/Nonunit/IntegratedTest/test/itkFilterImageAddTest.cxx +++ b/Modules/Nonunit/IntegratedTest/test/itkFilterImageAddTest.cxx @@ -54,7 +54,7 @@ itkFilterImageAddTest(int, char *[]) start[1] = 0; start[2] = 0; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; // Initialize Image A inputImageA->SetRegions(region); @@ -107,7 +107,7 @@ itkFilterImageAddTest(int, char *[]) filter->SetInput2(inputImageB); // Get the Smart Pointer to the Filter Output - myImageType3::Pointer outputImage = filter->GetOutput(); + const myImageType3::Pointer outputImage = filter->GetOutput(); // Execute the filter diff --git a/Modules/Nonunit/IntegratedTest/test/itkIOPrintTest.cxx b/Modules/Nonunit/IntegratedTest/test/itkIOPrintTest.cxx index 2c1e8088f39..1a3cadc8b68 100644 --- a/Modules/Nonunit/IntegratedTest/test/itkIOPrintTest.cxx +++ b/Modules/Nonunit/IntegratedTest/test/itkIOPrintTest.cxx @@ -35,7 +35,7 @@ int itkIOPrintTest(int, char *[]) { using ImageType = itk::Image; - itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); itk::PNGImageIO::Pointer PNGio; PNGio = itk::PNGImageIO::New(); diff --git a/Modules/Nonunit/IntegratedTest/test/itkNumericsPrintTest.cxx b/Modules/Nonunit/IntegratedTest/test/itkNumericsPrintTest.cxx index 8e6ebc0952d..c21f5159a67 100644 --- a/Modules/Nonunit/IntegratedTest/test/itkNumericsPrintTest.cxx +++ b/Modules/Nonunit/IntegratedTest/test/itkNumericsPrintTest.cxx @@ -30,57 +30,59 @@ int itkNumericsPrintTest(int, char *[]) { - itk::AmoebaOptimizer::Pointer AmoebaOptimizerObj = itk::AmoebaOptimizer::New(); + const itk::AmoebaOptimizer::Pointer AmoebaOptimizerObj = itk::AmoebaOptimizer::New(); std::cout << "----------AmoebaOptimizer " << AmoebaOptimizerObj; auto * CacheableScalarFunctionObj = new itk::CacheableScalarFunction; std::cout << "----------CacheableScalarFunction " << CacheableScalarFunctionObj; delete CacheableScalarFunctionObj; - itk::ConjugateGradientOptimizer::Pointer ConjugateGradientOptimizerObj = itk::ConjugateGradientOptimizer::New(); + const itk::ConjugateGradientOptimizer::Pointer ConjugateGradientOptimizerObj = itk::ConjugateGradientOptimizer::New(); std::cout << "----------ConjugateGradientOptimizer " << ConjugateGradientOptimizerObj; - itk::CumulativeGaussianOptimizer::Pointer CumulativeGaussianOptimizerObj = itk::CumulativeGaussianOptimizer::New(); + const itk::CumulativeGaussianOptimizer::Pointer CumulativeGaussianOptimizerObj = + itk::CumulativeGaussianOptimizer::New(); std::cout << "----------CumulativeGaussianOptimizer " << CumulativeGaussianOptimizerObj; - itk::CumulativeGaussianCostFunction::Pointer CumulativeGaussianCostFunctionObj = + const itk::CumulativeGaussianCostFunction::Pointer CumulativeGaussianCostFunctionObj = itk::CumulativeGaussianCostFunction::New(); std::cout << "----------CumulativeGaussianCostFunction " << CumulativeGaussianCostFunctionObj; - itk::GradientDescentOptimizer::Pointer GradientDescentOptimizerObj = itk::GradientDescentOptimizer::New(); + const itk::GradientDescentOptimizer::Pointer GradientDescentOptimizerObj = itk::GradientDescentOptimizer::New(); std::cout << "----------GradientDescentOptimizer " << GradientDescentOptimizerObj; - itk::LBFGSOptimizer::Pointer LBFGSOptimizerObj = itk::LBFGSOptimizer::New(); + const itk::LBFGSOptimizer::Pointer LBFGSOptimizerObj = itk::LBFGSOptimizer::New(); std::cout << "----------LBFGSOptimizer " << LBFGSOptimizerObj; - itk::LevenbergMarquardtOptimizer::Pointer LevenbergMarquardtOptimizerObj = itk::LevenbergMarquardtOptimizer::New(); + const itk::LevenbergMarquardtOptimizer::Pointer LevenbergMarquardtOptimizerObj = + itk::LevenbergMarquardtOptimizer::New(); std::cout << "----------LevenbergMarquardtOptimizer " << LevenbergMarquardtOptimizerObj; using PolynomialType = itk::MultivariateLegendrePolynomial; - constexpr unsigned int dimension = 3; - constexpr unsigned int degree = 3; - PolynomialType::DomainSizeType domainSize(dimension); + constexpr unsigned int dimension = 3; + constexpr unsigned int degree = 3; + const PolynomialType::DomainSizeType domainSize(dimension); auto * MultivariateLegendrePolynomialObj = new itk::MultivariateLegendrePolynomial(dimension, degree, domainSize); std::cout << "----------MultivariateLegendrePolynomial " << *MultivariateLegendrePolynomialObj; delete MultivariateLegendrePolynomialObj; - itk::OnePlusOneEvolutionaryOptimizer::Pointer OnePlusOneEvolutionaryOptimizerObj = + const itk::OnePlusOneEvolutionaryOptimizer::Pointer OnePlusOneEvolutionaryOptimizerObj = itk::OnePlusOneEvolutionaryOptimizer::New(); std::cout << "----------OnePlusOneEvolutionaryOptimizer " << OnePlusOneEvolutionaryOptimizerObj; - itk::Optimizer::Pointer OptimizerObj = itk::Optimizer::New(); + const itk::Optimizer::Pointer OptimizerObj = itk::Optimizer::New(); std::cout << "----------Optimizer " << OptimizerObj; - itk::QuaternionRigidTransformGradientDescentOptimizer::Pointer QuaternionRigidTransformGradientDescentOptimizerObj = - itk::QuaternionRigidTransformGradientDescentOptimizer::New(); + const itk::QuaternionRigidTransformGradientDescentOptimizer::Pointer + QuaternionRigidTransformGradientDescentOptimizerObj = itk::QuaternionRigidTransformGradientDescentOptimizer::New(); std::cout << "----------QuaternionRigidTransformGradientDescentOptimizer " << QuaternionRigidTransformGradientDescentOptimizerObj; - itk::RegularStepGradientDescentBaseOptimizer::Pointer RegularStepGradientDescentBaseOptimizerObj = + const itk::RegularStepGradientDescentBaseOptimizer::Pointer RegularStepGradientDescentBaseOptimizerObj = itk::RegularStepGradientDescentBaseOptimizer::New(); std::cout << "----------RegularStepGradientDescentBaseOptimizer " << RegularStepGradientDescentBaseOptimizerObj; - itk::RegularStepGradientDescentOptimizer::Pointer RegularStepGradientDescentOptimizerObj = + const itk::RegularStepGradientDescentOptimizer::Pointer RegularStepGradientDescentOptimizerObj = itk::RegularStepGradientDescentOptimizer::New(); std::cout << "----------RegularStepGradientDescentOptimizer " << RegularStepGradientDescentOptimizerObj; @@ -88,7 +90,7 @@ itkNumericsPrintTest(int, char *[]) std::cout << "----------SingleValuedVnlCostFunctionAdaptor " << SingleValuedVnlCostFunctionAdaptorObj; delete SingleValuedVnlCostFunctionAdaptorObj; - itk::VersorTransformOptimizer::Pointer VersorTransformOptimizerObj = itk::VersorTransformOptimizer::New(); + const itk::VersorTransformOptimizer::Pointer VersorTransformOptimizerObj = itk::VersorTransformOptimizer::New(); std::cout << "----------VersorTransformOptimizer " << VersorTransformOptimizerObj; return 0; diff --git a/Modules/Nonunit/IntegratedTest/test/itkReleaseDataFilterTest.cxx b/Modules/Nonunit/IntegratedTest/test/itkReleaseDataFilterTest.cxx index 5fcc6f8ec4e..3237f45864e 100644 --- a/Modules/Nonunit/IntegratedTest/test/itkReleaseDataFilterTest.cxx +++ b/Modules/Nonunit/IntegratedTest/test/itkReleaseDataFilterTest.cxx @@ -99,7 +99,7 @@ itkReleaseDataFilterTest(int, char *[]) streamer->SetNumberOfStreamDivisions(4); - ImageType::SizeType zeroSize{}; + const ImageType::SizeType zeroSize{}; std::cout << "---- Updating \"a\" Pipeline ---" << std::endl; diff --git a/Modules/Nonunit/IntegratedTest/test/itkShrinkImagePreserveObjectPhysicalLocations.cxx b/Modules/Nonunit/IntegratedTest/test/itkShrinkImagePreserveObjectPhysicalLocations.cxx index 74067be06a6..41ddbd106e3 100644 --- a/Modules/Nonunit/IntegratedTest/test/itkShrinkImagePreserveObjectPhysicalLocations.cxx +++ b/Modules/Nonunit/IntegratedTest/test/itkShrinkImagePreserveObjectPhysicalLocations.cxx @@ -116,8 +116,8 @@ ComputeCG(TImageType::Pointer img) { const double value = it.Value(); sumMass += value; - TImageType::IndexType indexPosition = it.GetIndex(); - TImageType::PointType physicalPosition; + const TImageType::IndexType indexPosition = it.GetIndex(); + TImageType::PointType physicalPosition; img->TransformIndexToPhysicalPoint(indexPosition, physicalPosition); for (unsigned int i = 0; i < TImageType::ImageDimension; ++i) @@ -176,18 +176,18 @@ itkShrinkImagePreserveObjectPhysicalLocations(int, char *[]) } } - PyramidFilterType::Pointer MyPyramid = MakeTwoLevelPyramid(image); - TImageType::Pointer ReallySmallImage = MyPyramid->GetOutput(0); - TImageType::Pointer SmallImage = MyPyramid->GetOutput(1); + const PyramidFilterType::Pointer MyPyramid = MakeTwoLevelPyramid(image); + const TImageType::Pointer ReallySmallImage = MyPyramid->GetOutput(0); + const TImageType::Pointer SmallImage = MyPyramid->GetOutput(1); - itk::ShrinkImageFilter::Pointer Shrinkfilter = + const itk::ShrinkImageFilter::Pointer Shrinkfilter = itk::ShrinkImageFilter::New(); Shrinkfilter->SetInput(image); Shrinkfilter->SetShrinkFactors(4); Shrinkfilter->Update(); - TImageType::Pointer ShrinkSmallImage = Shrinkfilter->GetOutput(); + const TImageType::Pointer ShrinkSmallImage = Shrinkfilter->GetOutput(); - itk::DiscreteGaussianImageFilter::Pointer smoother = + const itk::DiscreteGaussianImageFilter::Pointer smoother = itk::DiscreteGaussianImageFilter::New(); smoother->SetInput(image); smoother->SetUseImageSpacing(true); @@ -201,14 +201,14 @@ itkShrinkImagePreserveObjectPhysicalLocations(int, char *[]) smoother->SetVariance(variance); smoother->Update(); - TImageType::Pointer GaussianImage = smoother->GetOutput(); + const TImageType::Pointer GaussianImage = smoother->GetOutput(); - itk::ShrinkImageFilter::Pointer smootherShrinkfilter = + const itk::ShrinkImageFilter::Pointer smootherShrinkfilter = itk::ShrinkImageFilter::New(); smootherShrinkfilter->SetInput(GaussianImage); smootherShrinkfilter->SetShrinkFactors(4); smootherShrinkfilter->Update(); - TImageType::Pointer GaussianShrinkSmallImage = smootherShrinkfilter->GetOutput(); + const TImageType::Pointer GaussianShrinkSmallImage = smootherShrinkfilter->GetOutput(); // #define WriteDebugImaging #ifdef WriteDebugImaging diff --git a/Modules/Nonunit/IntegratedTest/test/itkSpatialObjectPrintTest.cxx b/Modules/Nonunit/IntegratedTest/test/itkSpatialObjectPrintTest.cxx index 14c23ccffcd..4ec29f92ffc 100644 --- a/Modules/Nonunit/IntegratedTest/test/itkSpatialObjectPrintTest.cxx +++ b/Modules/Nonunit/IntegratedTest/test/itkSpatialObjectPrintTest.cxx @@ -37,54 +37,54 @@ int itkSpatialObjectPrintTest(int, char *[]) { - itk::ArrowSpatialObject<3>::Pointer ArrowSpatialObjectObj = itk::ArrowSpatialObject<3>::New(); + const itk::ArrowSpatialObject<3>::Pointer ArrowSpatialObjectObj = itk::ArrowSpatialObject<3>::New(); std::cout << "----------ArrowSpatialObject " << ArrowSpatialObjectObj; - itk::BlobSpatialObject<3>::Pointer BlobSpatialObjectObj = itk::BlobSpatialObject<3>::New(); + const itk::BlobSpatialObject<3>::Pointer BlobSpatialObjectObj = itk::BlobSpatialObject<3>::New(); std::cout << "----------BlobSpatialObject " << BlobSpatialObjectObj; - itk::BoxSpatialObject<3>::Pointer BoxSpatialObjectObj = itk::BoxSpatialObject<3>::New(); + const itk::BoxSpatialObject<3>::Pointer BoxSpatialObjectObj = itk::BoxSpatialObject<3>::New(); std::cout << "----------BoxSpatialObject " << BoxSpatialObjectObj; - itk::ContourSpatialObject<3>::Pointer ContourSpatialObjectObj = itk::ContourSpatialObject<3>::New(); + const itk::ContourSpatialObject<3>::Pointer ContourSpatialObjectObj = itk::ContourSpatialObject<3>::New(); std::cout << "----------ContourSpatialObject " << ContourSpatialObjectObj; - itk::DTITubeSpatialObject<3>::Pointer DTITubeSpatialObjectObj = itk::DTITubeSpatialObject<3>::New(); + const itk::DTITubeSpatialObject<3>::Pointer DTITubeSpatialObjectObj = itk::DTITubeSpatialObject<3>::New(); std::cout << "----------DTITubeSpatialObject " << DTITubeSpatialObjectObj; - itk::EllipseSpatialObject<3>::Pointer EllipseSpatialObjectObj = itk::EllipseSpatialObject<3>::New(); + const itk::EllipseSpatialObject<3>::Pointer EllipseSpatialObjectObj = itk::EllipseSpatialObject<3>::New(); std::cout << "----------EllipseSpatialObject " << EllipseSpatialObjectObj; - itk::GaussianSpatialObject<3>::Pointer GaussianSpatialObjectObj = itk::GaussianSpatialObject<3>::New(); + const itk::GaussianSpatialObject<3>::Pointer GaussianSpatialObjectObj = itk::GaussianSpatialObject<3>::New(); std::cout << "----------GaussianSpatialObject " << GaussianSpatialObjectObj; - itk::GroupSpatialObject<3>::Pointer GroupSpatialObjectObj = itk::GroupSpatialObject<3>::New(); + const itk::GroupSpatialObject<3>::Pointer GroupSpatialObjectObj = itk::GroupSpatialObject<3>::New(); std::cout << "----------GroupSpatialObject " << GroupSpatialObjectObj; - itk::ImageMaskSpatialObject<3>::Pointer ImageMaskSpatialObjectObj = itk::ImageMaskSpatialObject<3>::New(); + const itk::ImageMaskSpatialObject<3>::Pointer ImageMaskSpatialObjectObj = itk::ImageMaskSpatialObject<3>::New(); std::cout << "----------ImageMaskSpatialObject " << ImageMaskSpatialObjectObj; using Pixel = unsigned short; - itk::ImageSpatialObject<3, Pixel>::Pointer ImageSpatialObjectObj = itk::ImageSpatialObject<3, Pixel>::New(); + const itk::ImageSpatialObject<3, Pixel>::Pointer ImageSpatialObjectObj = itk::ImageSpatialObject<3, Pixel>::New(); std::cout << "----------ImageSpatialObject " << ImageSpatialObjectObj; - itk::LandmarkSpatialObject<3>::Pointer LandmarkSpatialObjectObj = itk::LandmarkSpatialObject<3>::New(); + const itk::LandmarkSpatialObject<3>::Pointer LandmarkSpatialObjectObj = itk::LandmarkSpatialObject<3>::New(); std::cout << "----------LandmarkSpatialObject " << LandmarkSpatialObjectObj; - itk::LineSpatialObject<3>::Pointer LineSpatialObjectObj = itk::LineSpatialObject<3>::New(); + const itk::LineSpatialObject<3>::Pointer LineSpatialObjectObj = itk::LineSpatialObject<3>::New(); std::cout << "----------LineSpatialObject " << LineSpatialObjectObj; auto * LineSpatialObjectPointObj = new itk::LineSpatialObjectPoint<3>; std::cout << "----------LineSpatialObjectPoint " << LineSpatialObjectPointObj; delete LineSpatialObjectPointObj; - itk::MeshSpatialObject<>::Pointer MeshSpatialObjectObj = itk::MeshSpatialObject<>::New(); + const itk::MeshSpatialObject<>::Pointer MeshSpatialObjectObj = itk::MeshSpatialObject<>::New(); std::cout << "----------MeshSpatialObject " << MeshSpatialObjectObj; - itk::PolygonSpatialObject<3>::Pointer PolygonSpatialObjectObj = itk::PolygonSpatialObject<3>::New(); + const itk::PolygonSpatialObject<3>::Pointer PolygonSpatialObjectObj = itk::PolygonSpatialObject<3>::New(); std::cout << "----------PolygonSpatialObject " << PolygonSpatialObjectObj; - itk::SpatialObject<3>::Pointer SpatialObjectObj = itk::SpatialObject<3>::New(); + const itk::SpatialObject<3>::Pointer SpatialObjectObj = itk::SpatialObject<3>::New(); std::cout << "----------SpatialObject " << SpatialObjectObj; auto * SpatialObjectPointObj = new itk::SpatialObjectPoint<3>; @@ -92,21 +92,21 @@ itkSpatialObjectPrintTest(int, char *[]) SpatialObjectPointObj->Print(std::cout); delete SpatialObjectPointObj; - itk::SpatialObjectProperty SpatialObjectPropertyObj; + const itk::SpatialObjectProperty SpatialObjectPropertyObj; std::cout << "----------SpatialObjectProperty "; SpatialObjectPropertyObj.Print(std::cout); - itk::SurfaceSpatialObject<3>::Pointer SurfaceSpatialObjectObj = itk::SurfaceSpatialObject<3>::New(); + const itk::SurfaceSpatialObject<3>::Pointer SurfaceSpatialObjectObj = itk::SurfaceSpatialObject<3>::New(); std::cout << "----------SurfaceSpatialObject " << SurfaceSpatialObjectObj; - itk::SurfaceSpatialObjectPoint<3> SurfaceSpatialObjectPointObj; + const itk::SurfaceSpatialObjectPoint<3> SurfaceSpatialObjectPointObj; std::cout << "----------SurfaceSpatialObjectPoint "; SurfaceSpatialObjectPointObj.Print(std::cout); - itk::TubeSpatialObject<3>::Pointer TubeSpatialObjectObj = itk::TubeSpatialObject<3>::New(); + const itk::TubeSpatialObject<3>::Pointer TubeSpatialObjectObj = itk::TubeSpatialObject<3>::New(); std::cout << "----------TubeSpatialObject " << TubeSpatialObjectObj; - itk::TubeSpatialObjectPoint<3> TubeSpatialObjectPointObj; + const itk::TubeSpatialObjectPoint<3> TubeSpatialObjectPointObj; std::cout << "----------TubeSpatialObjectPoint "; TubeSpatialObjectPointObj.Print(std::cout); diff --git a/Modules/Nonunit/IntegratedTest/test/itkStatisticsPrintTest.cxx b/Modules/Nonunit/IntegratedTest/test/itkStatisticsPrintTest.cxx index b777260ab57..45d425d901e 100644 --- a/Modules/Nonunit/IntegratedTest/test/itkStatisticsPrintTest.cxx +++ b/Modules/Nonunit/IntegratedTest/test/itkStatisticsPrintTest.cxx @@ -137,7 +137,7 @@ itkStatisticsPrintTest(int, char *[]) std::cout << "----------ImageToListSampleAdaptor "; std::cout << ImageToListSampleAdaptorObj; - JointDomainImageToListSampleAdaptorType::Pointer JointDomainImageToListSampleAdaptorObj = + const JointDomainImageToListSampleAdaptorType::Pointer JointDomainImageToListSampleAdaptorObj = JointDomainImageToListSampleAdaptorType::New(); std::cout << "----------JointDomainImageToListSampleAdaptor "; std::cout << JointDomainImageToListSampleAdaptorObj; @@ -146,29 +146,29 @@ itkStatisticsPrintTest(int, char *[]) std::cout << "----------PointSetToListSampleAdaptor "; std::cout << PointSetToListSampleAdaptorObj; - ScalarImageToCooccurrenceMatrixFilterType::Pointer ScalarImageToCooccurrenceMatrixFilterObj = + const ScalarImageToCooccurrenceMatrixFilterType::Pointer ScalarImageToCooccurrenceMatrixFilterObj = ScalarImageToCooccurrenceMatrixFilterType::New(); std::cout << "----------ScalarImageToCooccurrenceMatrixFilter "; std::cout << ScalarImageToCooccurrenceMatrixFilterObj; - ScalarImageToCooccurrenceListSampleFilterType::Pointer ScalarImageToCooccurrenceListSampleFilterObj = + const ScalarImageToCooccurrenceListSampleFilterType::Pointer ScalarImageToCooccurrenceListSampleFilterObj = ScalarImageToCooccurrenceListSampleFilterType::New(); std::cout << "----------ScalarImageToCooccurrenceListSampleFilter "; std::cout << ScalarImageToCooccurrenceListSampleFilterObj; - ScalarImageToTextureFeaturesFilterType::Pointer ScalarImageToTextureFeaturesFilterObj = + const ScalarImageToTextureFeaturesFilterType::Pointer ScalarImageToTextureFeaturesFilterObj = ScalarImageToTextureFeaturesFilterType::New(); std::cout << "----------ScalarImageToTextureFeaturesFilter "; std::cout << ScalarImageToTextureFeaturesFilterObj; - HistogramToTextureFeaturesFilterType::Pointer HistogramToTextureFeaturesFilterObj = + const HistogramToTextureFeaturesFilterType::Pointer HistogramToTextureFeaturesFilterObj = HistogramToTextureFeaturesFilterType::New(); std::cout << "----------HistogramToTextureFeaturesFilter " << HistogramToTextureFeaturesFilterObj; auto MembershipSampleObj = MembershipSampleType::New(); std::cout << "----------MembershipSample " << MembershipSampleObj; - DistanceToCentroidMembershipFunctionType::Pointer DistanceToCentroidMembershipFunctionObj = + const DistanceToCentroidMembershipFunctionType::Pointer DistanceToCentroidMembershipFunctionObj = DistanceToCentroidMembershipFunctionType::New(); std::cout << "----------DistanceToCentroidMembershipFunction " << DistanceToCentroidMembershipFunctionObj; @@ -181,7 +181,7 @@ itkStatisticsPrintTest(int, char *[]) auto covarianceFilterObj = CovarianceSampleFilterType::New(); std::cout << "----------Covariance filter " << covarianceFilterObj; - WeightedCovarianceSampleFilterType::Pointer weighedCovarianceSampleFilterObj = + const WeightedCovarianceSampleFilterType::Pointer weighedCovarianceSampleFilterObj = WeightedCovarianceSampleFilterType::New(); std::cout << "----------WeightedCovariance filter " << weighedCovarianceSampleFilterObj; diff --git a/Modules/Numerics/Eigen/include/itkEigenAnalysis2DImageFilter.hxx b/Modules/Numerics/Eigen/include/itkEigenAnalysis2DImageFilter.hxx index 6fad1637845..a13bac88d5c 100644 --- a/Modules/Numerics/Eigen/include/itkEigenAnalysis2DImageFilter.hxx +++ b/Modules/Numerics/Eigen/include/itkEigenAnalysis2DImageFilter.hxx @@ -118,15 +118,15 @@ template ::GenerateData() { - typename TInputImage::ConstPointer inputPtr1(dynamic_cast((ProcessObject::GetInput(0)))); + const typename TInputImage::ConstPointer inputPtr1(dynamic_cast((ProcessObject::GetInput(0)))); - typename TInputImage::ConstPointer inputPtr2(dynamic_cast((ProcessObject::GetInput(1)))); + const typename TInputImage::ConstPointer inputPtr2(dynamic_cast((ProcessObject::GetInput(1)))); - typename TInputImage::ConstPointer inputPtr3(dynamic_cast((ProcessObject::GetInput(2)))); + const typename TInputImage::ConstPointer inputPtr3(dynamic_cast((ProcessObject::GetInput(2)))); - EigenValueImagePointer outputPtr1 = this->GetMaxEigenValue(); - EigenValueImagePointer outputPtr2 = this->GetMinEigenValue(); - EigenVectorImagePointer outputPtr3 = this->GetMaxEigenVector(); + const EigenValueImagePointer outputPtr1 = this->GetMaxEigenValue(); + const EigenValueImagePointer outputPtr2 = this->GetMinEigenValue(); + const EigenVectorImagePointer outputPtr3 = this->GetMaxEigenVector(); outputPtr1->SetBufferedRegion(inputPtr1->GetBufferedRegion()); outputPtr2->SetBufferedRegion(inputPtr1->GetBufferedRegion()); @@ -136,7 +136,7 @@ EigenAnalysis2DImageFilter::Ge outputPtr2->Allocate(); outputPtr3->Allocate(); - EigenValueImageRegionType region = outputPtr1->GetRequestedRegion(); + const EigenValueImageRegionType region = outputPtr1->GetRequestedRegion(); ImageRegionConstIteratorWithIndex inputIt1(inputPtr1, region); ImageRegionConstIteratorWithIndex inputIt2(inputPtr2, region); @@ -146,7 +146,7 @@ EigenAnalysis2DImageFilter::Ge ImageRegionIteratorWithIndex outputIt2(outputPtr2, region); ImageRegionIteratorWithIndex outputIt3(outputPtr3, region); - EigenVectorType nullVector{}; + const EigenVectorType nullVector{}; // support progress methods/callbacks ProgressReporter progress(this, 0, region.GetNumberOfPixels()); diff --git a/Modules/Numerics/Eigen/test/itkEigenAnalysis2DImageFilterTest.cxx b/Modules/Numerics/Eigen/test/itkEigenAnalysis2DImageFilterTest.cxx index 004a08f9a8a..b77412fcb31 100644 --- a/Modules/Numerics/Eigen/test/itkEigenAnalysis2DImageFilterTest.cxx +++ b/Modules/Numerics/Eigen/test/itkEigenAnalysis2DImageFilterTest.cxx @@ -54,14 +54,14 @@ class EigenAnalysis2DImageFilterTester InitializeImage(myImageType * image, double value) { - typename myImageType::Pointer inputImage(image); + const typename myImageType::Pointer inputImage(image); // Define their size, and start index auto size = mySizeType::Filled(2); - myIndexType start{}; + const myIndexType start{}; - myRegionType region{ start, size }; + const myRegionType region{ start, size }; inputImage->SetRegions(region); inputImage->Allocate(); @@ -81,7 +81,7 @@ class EigenAnalysis2DImageFilterTester PrintImage(myImageType * image, const char * text) { - typename myImageType::Pointer imagePtr(image); + const typename myImageType::Pointer imagePtr(image); // Create an iterator for going through the image myIteratorType it(imagePtr, imagePtr->GetRequestedRegion()); @@ -103,7 +103,7 @@ class EigenAnalysis2DImageFilterTester PrintImage(myVectorImageType * image, const char * text) { - typename myVectorImageType::Pointer imagePtr(image); + const typename myVectorImageType::Pointer imagePtr(image); // Create an iterator for going through the image myVectorIteratorType it(imagePtr, imagePtr->GetRequestedRegion()); @@ -135,8 +135,8 @@ class EigenAnalysis2DImageFilterTester // Create a Filter - auto filter = myFilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + auto filter = myFilterType::New(); + const itk::SimpleFilterWatcher watcher(filter); // Connect the input images filter->SetInput1(inputImageXX); @@ -148,10 +148,10 @@ class EigenAnalysis2DImageFilterTester filter->Update(); // Get - typename myImageType::Pointer maxEigenValue = filter->GetMaxEigenValue(); - typename myImageType::Pointer minEigenValue = filter->GetMinEigenValue(); + const typename myImageType::Pointer maxEigenValue = filter->GetMaxEigenValue(); + const typename myImageType::Pointer minEigenValue = filter->GetMinEigenValue(); - typename myVectorImageType::Pointer maxEigenVector = filter->GetMaxEigenVector(); + const typename myVectorImageType::Pointer maxEigenVector = filter->GetMaxEigenVector(); PrintImage(maxEigenValue, "Max Eigen Value"); PrintImage(minEigenValue, "Min Eigen Value"); diff --git a/Modules/Numerics/NarrowBand/include/itkNarrowBand.hxx b/Modules/Numerics/NarrowBand/include/itkNarrowBand.hxx index 254022dfc2b..73df0e6ea50 100644 --- a/Modules/Numerics/NarrowBand/include/itkNarrowBand.hxx +++ b/Modules/Numerics/NarrowBand/include/itkNarrowBand.hxx @@ -36,8 +36,8 @@ template std::vector::RegionType> NarrowBand::SplitBand(const SizeType & n) { - SizeType t_n = n; - SizeType t_size = m_NodeContainer.size(); + SizeType t_n = n; + const SizeType t_size = m_NodeContainer.size(); std::vector regionList; if (t_n > t_size) diff --git a/Modules/Numerics/NarrowBand/include/itkNarrowBandImageFilterBase.hxx b/Modules/Numerics/NarrowBand/include/itkNarrowBandImageFilterBase.hxx index d8fac12f7bf..e7b449c2fa2 100644 --- a/Modules/Numerics/NarrowBand/include/itkNarrowBandImageFilterBase.hxx +++ b/Modules/Numerics/NarrowBand/include/itkNarrowBandImageFilterBase.hxx @@ -53,7 +53,7 @@ NarrowBandImageFilterBase::GenerateData() if (!this->m_IsInitialized) { // Allocate the output image - typename TOutputImage::Pointer output = this->GetOutput(); + const typename TOutputImage::Pointer output = this->GetOutput(); output->SetBufferedRegion(output->GetRequestedRegion()); output->Allocate(); @@ -225,10 +225,10 @@ NarrowBandImageFilterBase::ThreadedApplyUpdate(const // const int INNER_MASK = 2; constexpr signed char INNER_MASK = 2; - typename NarrowBandType::ConstIterator it; - typename OutputImageType::Pointer image = this->GetOutput(); - typename OutputImageType::PixelType oldvalue; - typename OutputImageType::PixelType newvalue; + typename NarrowBandType::ConstIterator it; + const typename OutputImageType::Pointer image = this->GetOutput(); + typename OutputImageType::PixelType oldvalue; + typename OutputImageType::PixelType newvalue; for (it = regionToProcess.first; it != regionToProcess.last; ++it) { oldvalue = image->GetPixel(it->m_Index); @@ -249,9 +249,9 @@ NarrowBandImageFilterBase::ThreadedCalculateChange(co using NeighborhoodIteratorType = typename FiniteDifferenceFunctionType::NeighborhoodType; - typename OutputImageType::Pointer output = this->GetOutput(); - TimeStepType timeStep; - void * globalData; + const typename OutputImageType::Pointer output = this->GetOutput(); + TimeStepType timeStep; + void * globalData; // Get the FiniteDifferenceFunction to use in calculations. const typename FiniteDifferenceFunctionType::Pointer df = this->GetDifferenceFunction(); diff --git a/Modules/Numerics/NarrowBand/test/itkNarrowBandImageFilterBaseTest.cxx b/Modules/Numerics/NarrowBand/test/itkNarrowBandImageFilterBaseTest.cxx index 99334f0f74b..b46fa143b41 100644 --- a/Modules/Numerics/NarrowBand/test/itkNarrowBandImageFilterBaseTest.cxx +++ b/Modules/Numerics/NarrowBand/test/itkNarrowBandImageFilterBaseTest.cxx @@ -95,8 +95,8 @@ template double SimpleSignedDistance(const TPoint & p) { - auto center = itk::MakeFilled(32); - double radius = 19.5; + auto center = itk::MakeFilled(32); + const double radius = 19.5; double accum = 0.0; for (unsigned int j = 0; j < TPoint::PointDimension; ++j) @@ -125,9 +125,9 @@ itkNarrowBandImageFilterBaseTest(int argc, char * argv[]) using WriterImageType = itk::Image; using PointType = itk::Point; - ImageType::SizeType size = { { 64, 64 } }; - ImageType::IndexType index = { { 0, 0 } }; - ImageType::RegionType region{ index, size }; + const ImageType::SizeType size = { { 64, 64 } }; + const ImageType::IndexType index = { { 0, 0 } }; + const ImageType::RegionType region{ index, size }; auto inputImage = ImageType::New(); inputImage->SetRegions(region); diff --git a/Modules/Numerics/NarrowBand/test/itkNarrowBandTest.cxx b/Modules/Numerics/NarrowBand/test/itkNarrowBandTest.cxx index d2169a03218..a1c1860ee4b 100644 --- a/Modules/Numerics/NarrowBand/test/itkNarrowBandTest.cxx +++ b/Modules/Numerics/NarrowBand/test/itkNarrowBandTest.cxx @@ -52,8 +52,8 @@ itkNarrowBandTest(int, char *[]) // Iterate over the band using itType = BandType::ConstIterator; - itType it = band->Begin(); - itType itend = band->End(); + itType it = band->Begin(); + const itType itend = band->End(); // BandNodeType *tmp; for (unsigned int i = 0; it != itend; ++it) @@ -66,8 +66,8 @@ itkNarrowBandTest(int, char *[]) std::vector regions = band->SplitBand(10); // RegionType region; using regionitType = std::vector::const_iterator; - regionitType regionsit = regions.begin(); - regionitType regionsitend = regions.end(); + regionitType regionsit = regions.begin(); + const regionitType regionsitend = regions.end(); std::cout << "Number of regions: " << regions.size() << std::endl; for (unsigned int i = 0; regionsit != regionsitend; ++regionsit) { diff --git a/Modules/Numerics/Optimizers/src/itkConjugateGradientOptimizer.cxx b/Modules/Numerics/Optimizers/src/itkConjugateGradientOptimizer.cxx index 1fa4163c821..13c2c16b61f 100644 --- a/Modules/Numerics/Optimizers/src/itkConjugateGradientOptimizer.cxx +++ b/Modules/Numerics/Optimizers/src/itkConjugateGradientOptimizer.cxx @@ -91,7 +91,7 @@ ConjugateGradientOptimizer::StartOptimization() this->GetNonConstCostFunctionAdaptor()->NegateCostFunctionOn(); } - ParametersType initialPosition = this->GetInitialPosition(); + const ParametersType initialPosition = this->GetInitialPosition(); ParametersType parameters(initialPosition); diff --git a/Modules/Numerics/Optimizers/src/itkCumulativeGaussianCostFunction.cxx b/Modules/Numerics/Optimizers/src/itkCumulativeGaussianCostFunction.cxx index 8f725240ffe..4d6366e0959 100644 --- a/Modules/Numerics/Optimizers/src/itkCumulativeGaussianCostFunction.cxx +++ b/Modules/Numerics/Optimizers/src/itkCumulativeGaussianCostFunction.cxx @@ -41,7 +41,7 @@ double CumulativeGaussianCostFunction::CalculateFitError(MeasureType * setTestArray) { // Use root mean square error as a measure of fit quality. - unsigned int numberOfElements = m_OriginalDataArray.GetNumberOfElements(); + const unsigned int numberOfElements = m_OriginalDataArray.GetNumberOfElements(); if (numberOfElements != setTestArray->GetNumberOfElements()) { @@ -78,7 +78,7 @@ CumulativeGaussianCostFunction::EvaluateCumulativeGaussian(double argument) cons else { // Tabulated error function evaluated for 0 to 299. - double y[300] = { + const double y[300] = { 0, .011283416, .022564575, .033841222, .045111106, .056371978, .067621594, .07885772, .090078126, .101280594, .112462916, .123622896, .134758352, .145867115, .156947033, .167995971, .179011813, .189992461, .200935839, .211839892, .222702589, .233521923, .244295911, .255022599, .265700058, .276326389, .286899723, @@ -124,15 +124,15 @@ CumulativeGaussianCostFunction::EvaluateCumulativeGaussian(double argument) cons } else { - double slope = + const double slope = (y[temp + 1] - y[temp]) / ((static_cast(temp) + 1) / 100 - (static_cast(temp) / 100)); erfValue = slope * (argument - (static_cast(temp) + 1) / 100) + y[temp + 1]; } } else { - int temp = -static_cast(argument * 100); - double slope = + const int temp = -static_cast(argument * 100); + const double slope = (-y[temp + 1] + y[temp]) / (-(static_cast(temp) + 1) / 100 + (static_cast(temp) / 100)); erfValue = (slope * (argument + (static_cast(temp) + 1) / 100) - y[temp + 1]); } diff --git a/Modules/Numerics/Optimizers/src/itkCumulativeGaussianOptimizer.cxx b/Modules/Numerics/Optimizers/src/itkCumulativeGaussianOptimizer.cxx index e9b2cd10ad1..c0896844221 100644 --- a/Modules/Numerics/Optimizers/src/itkCumulativeGaussianOptimizer.cxx +++ b/Modules/Numerics/Optimizers/src/itkCumulativeGaussianOptimizer.cxx @@ -49,9 +49,9 @@ CumulativeGaussianOptimizer::ExtendGaussian(MeasureType * originalArray, // Use the parameters from originalArray to construct a Gaussian in // extendedArray // shifting the mean to the right by startingPointForInsertion. - double mean = startingPointForInsertion + m_ComputedMean; - double sd = m_ComputedStandardDeviation; - double amplitude = m_ComputedAmplitude; + const double mean = startingPointForInsertion + m_ComputedMean; + const double sd = m_ComputedStandardDeviation; + const double amplitude = m_ComputedAmplitude; m_OffsetForMean = startingPointForInsertion; @@ -73,8 +73,8 @@ CumulativeGaussianOptimizer::FindAverageSumOfSquaredDifferences(MeasureType * ar // Given two arrays array1 and array2 of equal length, calculate the average // sum of squared // differences between them. - int size = array1->GetNumberOfElements(); - double sum = 0; + const int size = array1->GetNumberOfElements(); + double sum = 0; for (int i = 0; i < size; ++i) { @@ -103,9 +103,9 @@ CumulativeGaussianOptimizer::FindParametersOfGaussian(MeasureType * sampledGauss PrintComputedParameters(); } - int sampledGaussianArraySize = sampledGaussianArray->GetNumberOfElements(); - int extendedArraySize = 3 * sampledGaussianArraySize; - auto * extendedArray = new MeasureType(); + const int sampledGaussianArraySize = sampledGaussianArray->GetNumberOfElements(); + const int extendedArraySize = 3 * sampledGaussianArraySize; + auto * extendedArray = new MeasureType(); extendedArray->SetSize(extendedArraySize); auto * extendedArrayCopy = new MeasureType(); extendedArrayCopy->SetSize(extendedArraySize); @@ -115,7 +115,7 @@ CumulativeGaussianOptimizer::FindParametersOfGaussian(MeasureType * sampledGauss extendedArray = ExtendGaussian(sampledGaussianArray, extendedArray, sampledGaussianArraySize); MeasureGaussianParameters(extendedArray); - bool smallChangeBetweenIterations = false; + const bool smallChangeBetweenIterations = false; while (averageSumOfSquaredDifferences >= m_DifferenceTolerance) { for (int j = 0; j < extendedArraySize; ++j) @@ -130,7 +130,7 @@ CumulativeGaussianOptimizer::FindParametersOfGaussian(MeasureType * sampledGauss { PrintComputedParameters(); } - double temp = averageSumOfSquaredDifferences; + const double temp = averageSumOfSquaredDifferences; averageSumOfSquaredDifferences = FindAverageSumOfSquaredDifferences(extendedArray, extendedArrayCopy); // Stop if there is a very very very small change between iterations. @@ -222,9 +222,9 @@ CumulativeGaussianOptimizer::RecalculateExtendedArrayFromGaussianParameters(Meas // From the Gaussian parameters stored with the extendedArray, // recalculate the extended portion of the extendedArray, // leaving the inserted original array unchanged. - double mean = m_ComputedMean; - double sd = m_ComputedStandardDeviation; - double amplitude = m_ComputedAmplitude; + const double mean = m_ComputedMean; + const double sd = m_ComputedStandardDeviation; + const double amplitude = m_ComputedAmplitude; for (int i = 0; i < static_cast(extendedArray->GetNumberOfElements()); ++i) { @@ -252,8 +252,8 @@ CumulativeGaussianOptimizer::StartOptimization() m_StopConditionDescription << this->GetNameOfClass() << ": Running"; // Declare arrays. - int cumGaussianArraySize = m_CumulativeGaussianArray->GetNumberOfElements(); - int sampledGaussianArraySize = cumGaussianArraySize; + const int cumGaussianArraySize = m_CumulativeGaussianArray->GetNumberOfElements(); + const int sampledGaussianArraySize = cumGaussianArraySize; // int cumGaussianArrayCopySize = cumGaussianArraySize; auto * sampledGaussianArray = new MeasureType(); @@ -298,7 +298,7 @@ CumulativeGaussianOptimizer::StartOptimization() m_ComputedMean += 0.5; // Find the best vertical shift that minimizes the least square error. - double c = VerticalBestShift(cumGaussianArrayCopy, sampledGaussianArray); + const double c = VerticalBestShift(cumGaussianArrayCopy, sampledGaussianArray); // Add constant c to array. for (int i = 0; i < static_cast(sampledGaussianArray->GetNumberOfElements()); ++i) @@ -307,10 +307,10 @@ CumulativeGaussianOptimizer::StartOptimization() } // Calculate the mean, standard deviation, lower and upper asymptotes of the // sampled Cumulative Gaussian. - auto floorOfMean = static_cast(m_ComputedMean); - double yFloorOfMean = sampledGaussianArray->get(floorOfMean); - double yCeilingOfMean = sampledGaussianArray->get(floorOfMean + 1); - double y = (m_ComputedMean - floorOfMean) * (yCeilingOfMean - yFloorOfMean) + yFloorOfMean; + auto floorOfMean = static_cast(m_ComputedMean); + const double yFloorOfMean = sampledGaussianArray->get(floorOfMean); + const double yCeilingOfMean = sampledGaussianArray->get(floorOfMean + 1); + const double y = (m_ComputedMean - floorOfMean) * (yCeilingOfMean - yFloorOfMean) + yFloorOfMean; m_UpperAsymptote = y + m_ComputedTransitionHeight / 2; m_LowerAsymptote = y - m_ComputedTransitionHeight / 2; @@ -357,8 +357,8 @@ CumulativeGaussianOptimizer::VerticalBestShift(MeasureType * originalArray, Meas // => nC = sum(Ai) - sum(Bi) // => C = (sum(Ai) - sum(Bi)) / n - double c = 0; - int size = originalArray->GetNumberOfElements(); + double c = 0; + const int size = originalArray->GetNumberOfElements(); for (int i = 0; i < size; ++i) { diff --git a/Modules/Numerics/Optimizers/src/itkExhaustiveOptimizer.cxx b/Modules/Numerics/Optimizers/src/itkExhaustiveOptimizer.cxx index af00200de77..df973f43f0e 100644 --- a/Modules/Numerics/Optimizers/src/itkExhaustiveOptimizer.cxx +++ b/Modules/Numerics/Optimizers/src/itkExhaustiveOptimizer.cxx @@ -36,11 +36,11 @@ ExhaustiveOptimizer::StartWalking() m_StopConditionDescription.str(""); m_StopConditionDescription << this->GetNameOfClass() << ": Running"; - ParametersType initialPos = this->GetInitialPosition(); + const ParametersType initialPos = this->GetInitialPosition(); m_MinimumMetricValuePosition = initialPos; m_MaximumMetricValuePosition = initialPos; - MeasureType initialValue = this->GetValue(this->GetInitialPosition()); + const MeasureType initialValue = this->GetValue(this->GetInitialPosition()); m_MaximumMetricValue = initialValue; m_MinimumMetricValue = initialValue; @@ -86,7 +86,7 @@ ExhaustiveOptimizer::ResumeWalking() while (!m_Stop) { - ParametersType currentPosition = this->GetCurrentPosition(); + const ParametersType currentPosition = this->GetCurrentPosition(); if (m_Stop) { diff --git a/Modules/Numerics/Optimizers/src/itkInitializationBiasedParticleSwarmOptimizer.cxx b/Modules/Numerics/Optimizers/src/itkInitializationBiasedParticleSwarmOptimizer.cxx index d1b203a6b7b..ae0dec9de4d 100644 --- a/Modules/Numerics/Optimizers/src/itkInitializationBiasedParticleSwarmOptimizer.cxx +++ b/Modules/Numerics/Optimizers/src/itkInitializationBiasedParticleSwarmOptimizer.cxx @@ -44,22 +44,22 @@ InitializationBiasedParticleSwarmOptimizer::PrintSelf(std::ostream & os, Indent void InitializationBiasedParticleSwarmOptimizer::UpdateSwarm() { - itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer randomGenerator = + const itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer randomGenerator = Statistics::MersenneTwisterRandomVariateGenerator::GetInstance(); ParametersType initialPosition = GetInitialPosition(); - unsigned int n = static_cast((GetCostFunction())->GetNumberOfParameters()); + const unsigned int n = static_cast((GetCostFunction())->GetNumberOfParameters()); // linear decrease in the weight of the initial parameter values - double initializationCoefficient = + const double initializationCoefficient = this->m_InitializationCoefficient * (1.0 - static_cast(m_IterationIndex) / static_cast(m_MaximalNumberOfIterations)); for (unsigned int j = 0; j < m_NumberOfParticles; ++j) { - ParticleData & p = m_Particles[j]; - ParametersType::ValueType phi1 = randomGenerator->GetVariateWithClosedRange() * this->m_PersonalCoefficient; - ParametersType::ValueType phi2 = randomGenerator->GetVariateWithClosedRange() * this->m_GlobalCoefficient; - ParametersType::ValueType phi3 = randomGenerator->GetVariateWithClosedRange() * initializationCoefficient; + ParticleData & p = m_Particles[j]; + const ParametersType::ValueType phi1 = randomGenerator->GetVariateWithClosedRange() * this->m_PersonalCoefficient; + const ParametersType::ValueType phi2 = randomGenerator->GetVariateWithClosedRange() * this->m_GlobalCoefficient; + const ParametersType::ValueType phi3 = randomGenerator->GetVariateWithClosedRange() * initializationCoefficient; for (unsigned int k = 0; k < n; ++k) { // update velocity p.m_CurrentVelocity[k] = m_InertiaCoefficient * p.m_CurrentVelocity[k] + diff --git a/Modules/Numerics/Optimizers/src/itkLBFGSBOptimizer.cxx b/Modules/Numerics/Optimizers/src/itkLBFGSBOptimizer.cxx index ecca60cf81f..1c82e2f2f21 100644 --- a/Modules/Numerics/Optimizers/src/itkLBFGSBOptimizer.cxx +++ b/Modules/Numerics/Optimizers/src/itkLBFGSBOptimizer.cxx @@ -289,7 +289,7 @@ LBFGSBOptimizer::StartOptimization() { // Check if all the bounds parameters are the same size as the initial // parameters. - unsigned int numberOfParameters = m_CostFunction->GetNumberOfParameters(); + const unsigned int numberOfParameters = m_CostFunction->GetNumberOfParameters(); if (this->GetInitialPosition().Size() < numberOfParameters) { diff --git a/Modules/Numerics/Optimizers/src/itkLevenbergMarquardtOptimizer.cxx b/Modules/Numerics/Optimizers/src/itkLevenbergMarquardtOptimizer.cxx index 5abdbc6d2a8..efe641cb38f 100644 --- a/Modules/Numerics/Optimizers/src/itkLevenbergMarquardtOptimizer.cxx +++ b/Modules/Numerics/Optimizers/src/itkLevenbergMarquardtOptimizer.cxx @@ -101,8 +101,8 @@ LevenbergMarquardtOptimizer::StartOptimization() { this->InvokeEvent(StartEvent()); - ParametersType initialPosition = GetInitialPosition(); - ParametersType parameters(initialPosition); + const ParametersType initialPosition = GetInitialPosition(); + ParametersType parameters(initialPosition); // If the user provides the scales then we set otherwise we don't // for computation speed. diff --git a/Modules/Numerics/Optimizers/src/itkOnePlusOneEvolutionaryOptimizer.cxx b/Modules/Numerics/Optimizers/src/itkOnePlusOneEvolutionaryOptimizer.cxx index f34f07bbd14..b68f3a23235 100644 --- a/Modules/Numerics/Optimizers/src/itkOnePlusOneEvolutionaryOptimizer.cxx +++ b/Modules/Numerics/Optimizers/src/itkOnePlusOneEvolutionaryOptimizer.cxx @@ -88,7 +88,7 @@ OnePlusOneEvolutionaryOptimizer::StartOptimization() this->InvokeEvent(StartEvent()); m_Stop = false; - unsigned int spaceDimension = m_CostFunction->GetNumberOfParameters(); + const unsigned int spaceDimension = m_CostFunction->GetNumberOfParameters(); vnl_matrix A(spaceDimension, spaceDimension); vnl_vector parent(this->GetInitialPosition()); vnl_vector f_norm(spaceDimension); @@ -265,7 +265,7 @@ OnePlusOneEvolutionaryOptimizer::StartOptimization() // f_norm, f_norm) // A = A + (adjust - 1.0) * A; - double alpha = ((adjust - 1.0) / dot_product(f_norm, f_norm)); + const double alpha = ((adjust - 1.0) / dot_product(f_norm, f_norm)); for (unsigned int c = 0; c < spaceDimension; ++c) { for (unsigned int r = 0; r < spaceDimension; ++r) diff --git a/Modules/Numerics/Optimizers/src/itkParticleSwarmOptimizer.cxx b/Modules/Numerics/Optimizers/src/itkParticleSwarmOptimizer.cxx index 6f3bed5c9f1..29a8caf5e6d 100644 --- a/Modules/Numerics/Optimizers/src/itkParticleSwarmOptimizer.cxx +++ b/Modules/Numerics/Optimizers/src/itkParticleSwarmOptimizer.cxx @@ -46,16 +46,16 @@ ParticleSwarmOptimizer::PrintSelf(std::ostream & os, Indent indent) const void ParticleSwarmOptimizer::UpdateSwarm() { - itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer randomGenerator = + const itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer randomGenerator = Statistics::MersenneTwisterRandomVariateGenerator::GetInstance(); - unsigned int n = static_cast((GetCostFunction())->GetNumberOfParameters()); + const unsigned int n = static_cast((GetCostFunction())->GetNumberOfParameters()); for (unsigned int j = 0; j < m_NumberOfParticles; ++j) { - ParticleData & p = m_Particles[j]; - ParametersType::ValueType phi1 = randomGenerator->GetVariateWithClosedRange() * this->m_PersonalCoefficient; - ParametersType::ValueType phi2 = randomGenerator->GetVariateWithClosedRange() * this->m_GlobalCoefficient; + ParticleData & p = m_Particles[j]; + const ParametersType::ValueType phi1 = randomGenerator->GetVariateWithClosedRange() * this->m_PersonalCoefficient; + const ParametersType::ValueType phi2 = randomGenerator->GetVariateWithClosedRange() * this->m_GlobalCoefficient; for (unsigned int k = 0; k < n; ++k) { // update velocity p.m_CurrentVelocity[k] = m_InertiaCoefficient * p.m_CurrentVelocity[k] + diff --git a/Modules/Numerics/Optimizers/src/itkParticleSwarmOptimizerBase.cxx b/Modules/Numerics/Optimizers/src/itkParticleSwarmOptimizerBase.cxx index 1de17fe31e7..961c420ce07 100644 --- a/Modules/Numerics/Optimizers/src/itkParticleSwarmOptimizerBase.cxx +++ b/Modules/Numerics/Optimizers/src/itkParticleSwarmOptimizerBase.cxx @@ -152,7 +152,7 @@ ParticleSwarmOptimizerBase::PrintSelf(std::ostream & os, Indent indent) const os << indent << "Maximal number of iterations: " << this->m_MaximalNumberOfIterations << '\n'; os << indent << "Number of generations with minimal improvement: "; os << this->m_NumberOfGenerationsWithMinimalImprovement << '\n'; - ParameterBoundsType::const_iterator end = this->m_ParameterBounds.end(); + const ParameterBoundsType::const_iterator end = this->m_ParameterBounds.end(); os << indent << "Parameter bounds: ["; for (ParameterBoundsType::const_iterator it = this->m_ParameterBounds.begin(); it != end; ++it) { @@ -179,7 +179,7 @@ ParticleSwarmOptimizerBase::PrintSelf(std::ostream & os, Indent indent) const void ParticleSwarmOptimizerBase::PrintSwarm(std::ostream & os, Indent indent) const { - std::vector::const_iterator end = this->m_Particles.end(); + const std::vector::const_iterator end = this->m_Particles.end(); os << indent << "[\n"; for (std::vector::const_iterator it = this->m_Particles.begin(); it != end; ++it) { @@ -199,7 +199,7 @@ ParticleSwarmOptimizerBase::PrintSwarm(std::ostream & os, Indent indent) const void ParticleSwarmOptimizerBase::PrintParamtersType(const ParametersType & x, std::ostream & os) const { - unsigned int sz = x.size(); + const unsigned int sz = x.size(); for (unsigned int i = 0; i < sz; ++i) { os << x[i] << ' '; @@ -210,9 +210,9 @@ ParticleSwarmOptimizerBase::PrintParamtersType(const ParametersType & x, std::os void ParticleSwarmOptimizerBase::StartOptimization() { - bool converged = false; - unsigned int bestValueMemorySize = this->m_NumberOfGenerationsWithMinimalImprovement + 1; - auto percentileIndex = + bool converged = false; + const unsigned int bestValueMemorySize = this->m_NumberOfGenerationsWithMinimalImprovement + 1; + auto percentileIndex = static_cast(this->m_PercentageParticlesConverged * (this->m_NumberOfParticles - 1) + 0.5); ValidateSettings(); @@ -222,7 +222,7 @@ ParticleSwarmOptimizerBase::StartOptimization() InvokeEvent(StartEvent()); // run the simulation - unsigned int n = static_cast((GetCostFunction())->GetNumberOfParameters()); + const unsigned int n = static_cast((GetCostFunction())->GetNumberOfParameters()); for (this->m_IterationIndex = 1; m_IterationIndex < m_MaximalNumberOfIterations && !converged; ++m_IterationIndex) { @@ -241,7 +241,7 @@ ParticleSwarmOptimizerBase::StartOptimization() SetCurrentPosition(this->m_ParametersBestValue); // update the best value memory - unsigned int index = this->m_IterationIndex % bestValueMemorySize; + const unsigned int index = this->m_IterationIndex % bestValueMemorySize; this->m_FunctionBestValueMemory[index] = m_FunctionBestValue; // check for convergence. the m_FunctionBestValueMemory is a ring // buffer with m_NumberOfGenerationsWithMinimalImprovement+1 @@ -298,7 +298,7 @@ ParticleSwarmOptimizerBase::ValidateSettings() } // if we got here it is safe to get the number of parameters the cost // function expects - unsigned int n = static_cast((GetCostFunction())->GetNumberOfParameters()); + const unsigned int n = static_cast((GetCostFunction())->GetNumberOfParameters()); // check that the number of parameters match ParametersType initialPosition = GetInitialPosition(); @@ -342,7 +342,7 @@ ParticleSwarmOptimizerBase::ValidateSettings() { itkExceptionMacro("cost function and particle data dimensions mismatch"); } - std::vector::iterator end = this->m_Particles.end(); + const std::vector::iterator end = this->m_Particles.end(); for (std::vector::iterator it = this->m_Particles.begin(); it != end; ++it) { ParticleData & p = (*it); @@ -375,7 +375,7 @@ ParticleSwarmOptimizerBase::ValidateSettings() void ParticleSwarmOptimizerBase::Initialize() { - itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer randomGenerator = + const itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer randomGenerator = Statistics::MersenneTwisterRandomVariateGenerator::GetInstance(); if (m_UseSeed) { @@ -415,10 +415,10 @@ ParticleSwarmOptimizerBase::Initialize() void ParticleSwarmOptimizerBase::RandomInitialization() { - unsigned int n = GetInitialPosition().Size(); - ParameterBoundsType parameterBounds(this->m_ParameterBounds); - ParametersType mean = GetInitialPosition(); - itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer randomGenerator = + const unsigned int n = GetInitialPosition().Size(); + ParameterBoundsType parameterBounds(this->m_ParameterBounds); + ParametersType mean = GetInitialPosition(); + const itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer randomGenerator = Statistics::MersenneTwisterRandomVariateGenerator::GetInstance(); // create swarm diff --git a/Modules/Numerics/Optimizers/src/itkPowellOptimizer.cxx b/Modules/Numerics/Optimizers/src/itkPowellOptimizer.cxx index 1adea2bb98a..b4db8c1d7c6 100644 --- a/Modules/Numerics/Optimizers/src/itkPowellOptimizer.cxx +++ b/Modules/Numerics/Optimizers/src/itkPowellOptimizer.cxx @@ -120,7 +120,7 @@ PowellOptimizer::SetCurrentLinePoint(double x, double fx) void PowellOptimizer::Swap(double * a, double * b) const { - double tf = *a; + const double tf = *a; *a = *b; *b = tf; } @@ -265,7 +265,7 @@ PowellOptimizer::BracketedLineOptimize(double ax, for (m_CurrentLineIteration = 0; m_CurrentLineIteration < m_MaximumLineIteration; ++m_CurrentLineIteration) { - double middle_range = (a + b) / 2; + const double middle_range = (a + b) / 2; double new_step; /* Step at this iteration */ @@ -292,7 +292,7 @@ PowellOptimizer::BracketedLineOptimize(double ax, /* Decide if the interpolation can be tried */ if (itk::Math::abs(x - w) >= tolerance1) /* If x and w are distinct */ { - double t = (x - w) * (functionValueOfX - functionValueOfV); + const double t = (x - w) * (functionValueOfX - functionValueOfV); double q; /* ted as p/q; division operation*/ q = (x - v) * (functionValueOfX - functionValueOfW); @@ -338,9 +338,9 @@ PowellOptimizer::BracketedLineOptimize(double ax, /* Obtain the next approximation to min */ /* and reduce the enveloping range */ - double t = x + new_step; /* Tentative point for the min */ + const double t = x + new_step; /* Tentative point for the min */ - double functionValueOft = this->GetLineValue(t, tempCoord); + const double functionValueOft = this->GetLineValue(t, tempCoord); if (functionValueOft <= functionValueOfX) { @@ -436,7 +436,7 @@ PowellOptimizer::StartOptimization() for (m_CurrentIteration = 0; m_CurrentIteration <= m_MaximumIteration; ++m_CurrentIteration) { - double fp = fx; + const double fp = fx; unsigned int ibig = 0; double del = 0.0; @@ -446,7 +446,7 @@ PowellOptimizer::StartOptimization() { xit[j] = xi[j][i]; } - double fptt = fx; + const double fptt = fx; this->SetLine(p, xit); @@ -485,10 +485,10 @@ PowellOptimizer::StartOptimization() } this->SetLine(ptt, xit); - double fptt = this->GetLineValue(0, tempCoord); + const double fptt = this->GetLineValue(0, tempCoord); if (fptt < fp) { - double t = 2.0 * (fp - 2.0 * fx + fptt) * itk::Math::sqr(fp - fx - del) - del * itk::Math::sqr(fp - fptt); + const double t = 2.0 * (fp - 2.0 * fx + fptt) * itk::Math::sqr(fp - fx - del) - del * itk::Math::sqr(fp - fptt); if (t < 0.0) { this->SetLine(p, xit); diff --git a/Modules/Numerics/Optimizers/src/itkVersorTransformOptimizer.cxx b/Modules/Numerics/Optimizers/src/itkVersorTransformOptimizer.cxx index ca4a5c63983..d3933724bb5 100644 --- a/Modules/Numerics/Optimizers/src/itkVersorTransformOptimizer.cxx +++ b/Modules/Numerics/Optimizers/src/itkVersorTransformOptimizer.cxx @@ -65,7 +65,7 @@ VersorTransformOptimizer::StepAlongGradient(double factor, const DerivativeType // Composing the currentRotation with the gradientRotation // produces the new Rotation versor // - VersorType newRotation = currentRotation * gradientRotation; + const VersorType newRotation = currentRotation * gradientRotation; ParametersType newParameters(NumberOfParameters); diff --git a/Modules/Numerics/Optimizers/test/itkAmoebaOptimizerTest.cxx b/Modules/Numerics/Optimizers/test/itkAmoebaOptimizerTest.cxx index dce056cff43..b411a82b5e2 100644 --- a/Modules/Numerics/Optimizers/test/itkAmoebaOptimizerTest.cxx +++ b/Modules/Numerics/Optimizers/test/itkAmoebaOptimizerTest.cxx @@ -90,8 +90,8 @@ class amoebaTestF1 : public itk::SingleValuedCostFunction { v[i] = parameters[i]; } - VectorType Av = m_A * v; - double val = (inner_product(Av, v)) / 2.0; + const VectorType Av = m_A * v; + double val = (inner_product(Av, v)) / 2.0; val -= inner_product(m_B, v); if (m_Negate) { @@ -250,8 +250,8 @@ AmoebaTest2(); int itkAmoebaOptimizerTest(int, char *[]) { - int result1 = AmoebaTest1(); - int result2 = AmoebaTest2(); + const int result1 = AmoebaTest1(); + const int result2 = AmoebaTest2(); std::cout << "All Tests Completed." << std::endl; @@ -281,7 +281,7 @@ AmoebaTest1() ITK_TEST_EXPECT_TRUE(itkOptimizer->CanUseScales()); // set optimizer parameters - typename OptimizerType::NumberOfIterationsType numberOfIterations = 10; + const typename OptimizerType::NumberOfIterationsType numberOfIterations = 10; itkOptimizer->SetMaximumNumberOfIterations(numberOfIterations); ITK_TEST_SET_GET_VALUE(numberOfIterations, itkOptimizer->GetMaximumNumberOfIterations()); @@ -362,8 +362,8 @@ AmoebaTest1() OptimizerType::ParametersType finalPosition; finalPosition = itkOptimizer->GetCurrentPosition(); - double trueParameters[2] = { 2, -2 }; - bool pass = true; + const double trueParameters[2] = { 2, -2 }; + bool pass = true; std::cout << "Right answer = " << trueParameters[0] << " , " << trueParameters[1] << std::endl; std::cout << "Final position = " << finalPosition << std::endl; @@ -484,13 +484,13 @@ AmoebaTest2() auto itkOptimizer = OptimizerType::New(); // set optimizer parameters - unsigned int maxIterations = 100; + const unsigned int maxIterations = 100; itkOptimizer->SetMaximumNumberOfIterations(maxIterations); - double xTolerance = 0.01; + const double xTolerance = 0.01; itkOptimizer->SetParametersConvergenceTolerance(xTolerance); - double fTolerance = 0.001; + const double fTolerance = 0.001; itkOptimizer->SetFunctionConvergenceTolerance(fTolerance); // the initial simplex is constructed as: diff --git a/Modules/Numerics/Optimizers/test/itkConjugateGradientOptimizerTest.cxx b/Modules/Numerics/Optimizers/test/itkConjugateGradientOptimizerTest.cxx index bdf3a37b6ca..a0e91ee2aff 100644 --- a/Modules/Numerics/Optimizers/test/itkConjugateGradientOptimizerTest.cxx +++ b/Modules/Numerics/Optimizers/test/itkConjugateGradientOptimizerTest.cxx @@ -68,14 +68,14 @@ class conjugateCostFunction : public itk::SingleValuedCostFunction GetValue(const ParametersType & position) const override { - double x = position[0]; - double y = position[1]; + const double x = position[0]; + const double y = position[1]; std::cout << "GetValue ( "; std::cout << x << " , " << y; std::cout << ") = "; - double val = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; + const double val = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; std::cout << val << std::endl; @@ -86,8 +86,8 @@ class conjugateCostFunction : public itk::SingleValuedCostFunction GetDerivative(const ParametersType & position, DerivativeType & derivative) const override { - double x = position[0]; - double y = position[1]; + const double x = position[0]; + const double y = position[1]; std::cout << "GetDerivative ( "; std::cout << x << " , " << y; @@ -241,8 +241,8 @@ itkConjugateGradientOptimizerTest(int, char *[]) std::cout << finalPosition[0] << ','; std::cout << finalPosition[1] << ')' << std::endl; - bool pass = true; - double trueParameters[2] = { 2, -2 }; + bool pass = true; + const double trueParameters[2] = { 2, -2 }; for (unsigned int j = 0; j < 2; ++j) { if (itk::Math::abs(finalPosition[j] - trueParameters[j]) > 0.01) @@ -259,7 +259,7 @@ itkConjugateGradientOptimizerTest(int, char *[]) // Get the final value of the optimizer std::cout << "Testing GetValue() : "; - OptimizerType::MeasureType finalValue = itkOptimizer->GetValue(); + const OptimizerType::MeasureType finalValue = itkOptimizer->GetValue(); if (itk::Math::abs(finalValue + 10.0) > 0.01) { std::cout << "[FAILURE]" << std::endl; diff --git a/Modules/Numerics/Optimizers/test/itkCumulativeGaussianOptimizerTest.cxx b/Modules/Numerics/Optimizers/test/itkCumulativeGaussianOptimizerTest.cxx index 58402f41af1..59d48242c91 100644 --- a/Modules/Numerics/Optimizers/test/itkCumulativeGaussianOptimizerTest.cxx +++ b/Modules/Numerics/Optimizers/test/itkCumulativeGaussianOptimizerTest.cxx @@ -34,13 +34,13 @@ int itkCumulativeGaussianOptimizerTest(int, char *[]) { - double mean = 3; // Mean of the Cumulative Gaussian. - // Ranges from 0 to N-1, where N is numberOfSamples. - double standardDeviation = 2; // Standard deviation of the Cumulative Gaussian. - double lowerAsymptote = -10; // Lower asymptotic value of the Cumulative Gaussian. - int numberOfSamples = 9; // Number of data samples. - double upperAsymptote = 10; // Upper asymptotic value of the Cumulative Gaussian. - double differenceTolerance = 1e-20; // Tolerance allowed for the difference between Gaussian iterations. + const double mean = 3; // Mean of the Cumulative Gaussian. + // Ranges from 0 to N-1, where N is numberOfSamples. + const double standardDeviation = 2; // Standard deviation of the Cumulative Gaussian. + const double lowerAsymptote = -10; // Lower asymptotic value of the Cumulative Gaussian. + const int numberOfSamples = 9; // Number of data samples. + const double upperAsymptote = 10; // Upper asymptotic value of the Cumulative Gaussian. + const double differenceTolerance = 1e-20; // Tolerance allowed for the difference between Gaussian iterations. // Typedef and initialization for the Cumulative Gaussian Optimizer. using CumulativeGaussianOptimizerType = itk::CumulativeGaussianOptimizer; @@ -86,7 +86,7 @@ itkCumulativeGaussianOptimizerTest(int, char *[]) ITK_TEST_SET_GET_VALUE(differenceTolerance, optimizer->GetDifferenceTolerance()); // Print results after each iteration. - bool verbose = true; + const bool verbose = true; ITK_TEST_SET_GET_BOOLEAN(optimizer, Verbose, verbose); // Set the data array. diff --git a/Modules/Numerics/Optimizers/test/itkExhaustiveOptimizerTest.cxx b/Modules/Numerics/Optimizers/test/itkExhaustiveOptimizerTest.cxx index 1c88d21a2da..91d51a46a19 100644 --- a/Modules/Numerics/Optimizers/test/itkExhaustiveOptimizerTest.cxx +++ b/Modules/Numerics/Optimizers/test/itkExhaustiveOptimizerTest.cxx @@ -65,14 +65,14 @@ class RSGCostFunction : public itk::SingleValuedCostFunction GetValue(const ParametersType & parameters) const override { - double x = parameters[0]; - double y = parameters[1]; + const double x = parameters[0]; + const double y = parameters[1]; std::cout << "GetValue( "; std::cout << x << ' '; std::cout << y << ") = "; - MeasureType measure = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; + const MeasureType measure = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; std::cout << measure << std::endl; @@ -83,8 +83,8 @@ class RSGCostFunction : public itk::SingleValuedCostFunction GetDerivative(const ParametersType & parameters, DerivativeType & derivative) const override { - double x = parameters[0]; - double y = parameters[1]; + const double x = parameters[0]; + const double y = parameters[1]; std::cout << "GetDerivative( "; std::cout << x << ' '; @@ -217,12 +217,12 @@ itkExhaustiveOptimizerTest(int, char *[]) } - bool minimumValuePass = itk::Math::abs(itkOptimizer->GetMinimumMetricValue() - -10) < 1E-3; + const bool minimumValuePass = itk::Math::abs(itkOptimizer->GetMinimumMetricValue() - -10) < 1E-3; std::cout << "MinimumMetricValue = " << itkOptimizer->GetMinimumMetricValue() << std::endl; std::cout << "Minimum Position = " << itkOptimizer->GetMinimumMetricValuePosition() << std::endl; - bool maximumValuePass = itk::Math::abs(itkOptimizer->GetMaximumMetricValue() - 926) < 1E-3; + const bool maximumValuePass = itk::Math::abs(itkOptimizer->GetMaximumMetricValue() - 926) < 1E-3; std::cout << "MaximumMetricValue = " << itkOptimizer->GetMaximumMetricValue() << std::endl; std::cout << "Maximum Position = " << itkOptimizer->GetMaximumMetricValuePosition() << std::endl; @@ -234,7 +234,7 @@ itkExhaustiveOptimizerTest(int, char *[]) bool visitedIndicesPass = true; std::vector visitedIndices = idxObserver->m_VisitedIndices; - size_t requiredNumberOfSteps = (2 * steps[0] + 1) * (2 * steps[1] + 1); + const size_t requiredNumberOfSteps = (2 * steps[0] + 1) * (2 * steps[1] + 1); if (visitedIndices.size() != requiredNumberOfSteps) { visitedIndicesPass = false; @@ -255,8 +255,8 @@ itkExhaustiveOptimizerTest(int, char *[]) // // check results to see if it is within range // - bool trueParamsPass = true; - double trueParameters[2] = { 2, -2 }; + bool trueParamsPass = true; + const double trueParameters[2] = { 2, -2 }; for (unsigned int j = 0; j < 2; ++j) { if (itk::Math::abs(finalPosition[j] - trueParameters[j]) > 0.01) diff --git a/Modules/Numerics/Optimizers/test/itkFRPROptimizerTest.cxx b/Modules/Numerics/Optimizers/test/itkFRPROptimizerTest.cxx index dd57c38cea6..f4a70c30e88 100644 --- a/Modules/Numerics/Optimizers/test/itkFRPROptimizerTest.cxx +++ b/Modules/Numerics/Optimizers/test/itkFRPROptimizerTest.cxx @@ -62,14 +62,14 @@ class FRPRGradientCostFunction : public itk::SingleValuedCostFunction GetValue(const ParametersType & parameters) const override { - double x = parameters[0]; - double y = parameters[1]; + const double x = parameters[0]; + const double y = parameters[1]; std::cout << "GetValue( "; std::cout << x << ' '; std::cout << y << ") = "; - MeasureType measure = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; + const MeasureType measure = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; std::cout << measure << std::endl; @@ -80,8 +80,8 @@ class FRPRGradientCostFunction : public itk::SingleValuedCostFunction GetDerivative(const ParametersType & parameters, DerivativeType & derivative) const override { - double x = parameters[0]; - double y = parameters[1]; + const double x = parameters[0]; + const double y = parameters[1]; std::cout << "GetDerivative( "; std::cout << x << ' '; @@ -140,7 +140,7 @@ itkFRPROptimizerTest(int, char *[]) itkOptimizer->SetMaximize(false); itkOptimizer->SetMaximumIteration(50); - bool useUnitLengthGradient = false; + const bool useUnitLengthGradient = false; ITK_TEST_SET_GET_BOOLEAN(itkOptimizer, UseUnitLengthGradient, useUnitLengthGradient); { @@ -171,8 +171,8 @@ itkFRPROptimizerTest(int, char *[]) // // check results to see if it is within range // - bool pass = true; - double trueParameters[2] = { 2, -2 }; + bool pass = true; + const double trueParameters[2] = { 2, -2 }; for (unsigned int j = 0; j < 2; ++j) { if (itk::Math::abs(finalPosition[j] - trueParameters[j]) > 0.01) @@ -226,8 +226,8 @@ itkFRPROptimizerTest(int, char *[]) // // check results to see if it is within range // - bool pass = true; - double trueParameters[2] = { 2, -2 }; + bool pass = true; + const double trueParameters[2] = { 2, -2 }; for (unsigned int j = 0; j < 2; ++j) { if (itk::Math::abs(finalPosition[j] - trueParameters[j]) > 0.01) diff --git a/Modules/Numerics/Optimizers/test/itkGradientDescentOptimizerTest.cxx b/Modules/Numerics/Optimizers/test/itkGradientDescentOptimizerTest.cxx index 2b67385207a..7815225f141 100644 --- a/Modules/Numerics/Optimizers/test/itkGradientDescentOptimizerTest.cxx +++ b/Modules/Numerics/Optimizers/test/itkGradientDescentOptimizerTest.cxx @@ -64,14 +64,14 @@ class gradientCostFunction : public itk::SingleValuedCostFunction GetValue(const ParametersType & parameters) const override { - double x = parameters[0]; - double y = parameters[1]; + const double x = parameters[0]; + const double y = parameters[1]; std::cout << "GetValue( "; std::cout << x << ' '; std::cout << y << ") = "; - MeasureType measure = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; + const MeasureType measure = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; std::cout << measure << std::endl; @@ -82,8 +82,8 @@ class gradientCostFunction : public itk::SingleValuedCostFunction GetDerivative(const ParametersType & parameters, DerivativeType & derivative) const override { - double x = parameters[0]; - double y = parameters[1]; + const double x = parameters[0]; + const double y = parameters[1]; std::cout << "GetDerivative( "; std::cout << x << ' '; @@ -141,17 +141,17 @@ itkGradientDescentOptimizerTest(int, char *[]) initialPosition[1] = -100; - bool maximize = false; + const bool maximize = false; ITK_TEST_SET_GET_BOOLEAN(itkOptimizer, Maximize, maximize); - bool minimize = !maximize; + const bool minimize = !maximize; ITK_TEST_SET_GET_BOOLEAN(itkOptimizer, Minimize, minimize); - double learningRate = 0.1; + const double learningRate = 0.1; itkOptimizer->SetLearningRate(learningRate); ITK_TEST_SET_GET_VALUE(learningRate, itkOptimizer->GetLearningRate()); - itk::SizeValueType numberOfIterations = 50; + const itk::SizeValueType numberOfIterations = 50; itkOptimizer->SetNumberOfIterations(numberOfIterations); ITK_TEST_SET_GET_VALUE(numberOfIterations, itkOptimizer->GetNumberOfIterations()); @@ -179,8 +179,8 @@ itkGradientDescentOptimizerTest(int, char *[]) // // check results to see if it is within range // - bool pass = true; - double trueParameters[2] = { 2, -2 }; + bool pass = true; + const double trueParameters[2] = { 2, -2 }; for (unsigned int j = 0; j < 2; ++j) { if (itk::Math::abs(finalPosition[j] - trueParameters[j]) > 0.01) diff --git a/Modules/Numerics/Optimizers/test/itkInitializationBiasedParticleSwarmOptimizerTest.cxx b/Modules/Numerics/Optimizers/test/itkInitializationBiasedParticleSwarmOptimizerTest.cxx index d2df9e0650d..017cafd402b 100644 --- a/Modules/Numerics/Optimizers/test/itkInitializationBiasedParticleSwarmOptimizerTest.cxx +++ b/Modules/Numerics/Optimizers/test/itkInitializationBiasedParticleSwarmOptimizerTest.cxx @@ -113,7 +113,7 @@ itkInitializationBiasedParticleSwarmOptimizerTest(int argc, char * argv[]) } std::cout << "All Tests Completed." << std::endl; - double threshold = 0.8; + const double threshold = 0.8; if (static_cast(success1) / static_cast(allIterations) <= threshold || static_cast(success2) / static_cast(allIterations) <= threshold || static_cast(success3) / static_cast(allIterations) <= threshold) @@ -138,7 +138,7 @@ IBPSOTest1(typename OptimizerType::CoefficientType inertiaCoefficient, constexpr double knownParameters = 2.0; // the function we want to optimize - itk::ParticleSwarmTestF1::Pointer costFunction = itk::ParticleSwarmTestF1::New(); + const itk::ParticleSwarmTestF1::Pointer costFunction = itk::ParticleSwarmTestF1::New(); auto itkOptimizer = OptimizerType::New(); @@ -178,7 +178,7 @@ IBPSOTest1(typename OptimizerType::CoefficientType inertiaCoefficient, itkOptimizer->SetCostFunction(costFunction); // observe the iterations - itk::CommandIterationUpdateParticleSwarm::Pointer observer = itk::CommandIterationUpdateParticleSwarm::New(); + const itk::CommandIterationUpdateParticleSwarm::Pointer observer = itk::CommandIterationUpdateParticleSwarm::New(); if (initalizationBasedTestVerboseFlag) { itkOptimizer->AddObserver(itk::IterationEvent(), observer); @@ -264,7 +264,7 @@ IBPSOTest2(typename OptimizerType::CoefficientType inertiaCoefficient, knownParameters[1] = -2.0; // the function we want to optimize - itk::ParticleSwarmTestF2::Pointer costFunction = itk::ParticleSwarmTestF2::New(); + const itk::ParticleSwarmTestF2::Pointer costFunction = itk::ParticleSwarmTestF2::New(); auto itkOptimizer = OptimizerType::New(); @@ -305,7 +305,7 @@ IBPSOTest2(typename OptimizerType::CoefficientType inertiaCoefficient, itkOptimizer->SetCostFunction(costFunction); // observe the iterations - itk::CommandIterationUpdateParticleSwarm::Pointer observer = itk::CommandIterationUpdateParticleSwarm::New(); + const itk::CommandIterationUpdateParticleSwarm::Pointer observer = itk::CommandIterationUpdateParticleSwarm::New(); if (initalizationBasedTestVerboseFlag) { itkOptimizer->AddObserver(itk::IterationEvent(), observer); @@ -363,7 +363,7 @@ IBPSOTest3(typename OptimizerType::CoefficientType inertiaCoefficient, knownParameters[1] = 1.0; // the function we want to optimize - itk::ParticleSwarmTestF3::Pointer costFunction = itk::ParticleSwarmTestF3::New(); + const itk::ParticleSwarmTestF3::Pointer costFunction = itk::ParticleSwarmTestF3::New(); auto itkOptimizer = OptimizerType::New(); @@ -404,7 +404,7 @@ IBPSOTest3(typename OptimizerType::CoefficientType inertiaCoefficient, itkOptimizer->SetCostFunction(costFunction); // observe the iterations - itk::CommandIterationUpdateParticleSwarm::Pointer observer = itk::CommandIterationUpdateParticleSwarm::New(); + const itk::CommandIterationUpdateParticleSwarm::Pointer observer = itk::CommandIterationUpdateParticleSwarm::New(); if (initalizationBasedTestVerboseFlag) { itkOptimizer->AddObserver(itk::IterationEvent(), observer); diff --git a/Modules/Numerics/Optimizers/test/itkLBFGSBOptimizerTest.cxx b/Modules/Numerics/Optimizers/test/itkLBFGSBOptimizerTest.cxx index 74291172251..998aadddd41 100644 --- a/Modules/Numerics/Optimizers/test/itkLBFGSBOptimizerTest.cxx +++ b/Modules/Numerics/Optimizers/test/itkLBFGSBOptimizerTest.cxx @@ -70,14 +70,14 @@ class LBFGSBCostFunction : public itk::SingleValuedCostFunction GetValue(const ParametersType & position) const override { - double x = position[0]; - double y = position[1]; + const double x = position[0]; + const double y = position[1]; std::cout << "GetValue ( "; std::cout << x << " , " << y; std::cout << ") = "; - double val = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; + const double val = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; std::cout << val << std::endl; @@ -88,8 +88,8 @@ class LBFGSBCostFunction : public itk::SingleValuedCostFunction GetDerivative(const ParametersType & position, DerivativeType & derivative) const override { - double x = position[0]; - double y = position[1]; + const double x = position[0]; + const double y = position[1]; std::cout << "GetDerivative ( "; std::cout << x << " , " << y; @@ -193,7 +193,7 @@ itkLBFGSBOptimizerTest(int, char *[]) itkOptimizer->SetCostFunction(costFunction); - bool trace = false; + const bool trace = false; ITK_TEST_SET_GET_BOOLEAN(itkOptimizer, Trace, trace); const double F_Convergence_Factor = 1e+7; // Function value tolerance @@ -212,7 +212,7 @@ itkLBFGSBOptimizerTest(int, char *[]) itkOptimizer->SetMaximumNumberOfEvaluations(Max_Iterations); ITK_TEST_SET_GET_VALUE(Max_Iterations, itkOptimizer->GetMaximumNumberOfEvaluations()); - unsigned int maximumNumberOfCorrections = 5; + const unsigned int maximumNumberOfCorrections = 5; itkOptimizer->SetMaximumNumberOfCorrections(maximumNumberOfCorrections); ITK_TEST_SET_GET_VALUE(maximumNumberOfCorrections, itkOptimizer->GetMaximumNumberOfCorrections()); @@ -299,7 +299,7 @@ itkLBFGSBOptimizerTest(int, char *[]) bool pass = true; std::string errorIn; - double trueParameters[2] = { 4.0 / 3.0, -1.0 }; + const double trueParameters[2] = { 4.0 / 3.0, -1.0 }; for (unsigned int j = 0; j < 2; ++j) { if (itk::Math::abs(finalPosition[j] - trueParameters[j]) > 0.01) diff --git a/Modules/Numerics/Optimizers/test/itkLBFGSOptimizerTest.cxx b/Modules/Numerics/Optimizers/test/itkLBFGSOptimizerTest.cxx index 37dea8803ec..d8a2793fa7d 100644 --- a/Modules/Numerics/Optimizers/test/itkLBFGSOptimizerTest.cxx +++ b/Modules/Numerics/Optimizers/test/itkLBFGSOptimizerTest.cxx @@ -67,14 +67,14 @@ class LBFGSCostFunction : public itk::SingleValuedCostFunction double GetValue(const ParametersType & position) const override { - double x = position[0]; - double y = position[1]; + const double x = position[0]; + const double y = position[1]; std::cout << "GetValue ( "; std::cout << x << " , " << y; std::cout << ") = "; - double val = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; + const double val = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; std::cout << val << std::endl; @@ -84,8 +84,8 @@ class LBFGSCostFunction : public itk::SingleValuedCostFunction void GetDerivative(const ParametersType & position, DerivativeType & derivative) const override { - double x = position[0]; - double y = position[1]; + const double x = position[0]; + const double y = position[1]; std::cout << "GetDerivative ( "; std::cout << x << " , " << y; @@ -128,7 +128,7 @@ itkLBFGSOptimizerTest(int, char *[]) auto costFunction = LBFGSCostFunction::New(); // Set some optimizer parameters - bool trace = false; + const bool trace = false; ITK_TEST_SET_GET_BOOLEAN(itkOptimizer, Trace, trace); unsigned int maximumNumberOfFunctionEvaluations = 1000; @@ -219,8 +219,8 @@ itkLBFGSOptimizerTest(int, char *[]) // // check results to see if it is within range // - bool pass = true; - double trueParameters[2] = { 2, -2 }; + bool pass = true; + const double trueParameters[2] = { 2, -2 }; for (unsigned int j = 0; j < 2; ++j) { if (itk::Math::abs(finalPosition[j] - trueParameters[j]) > 0.01) @@ -237,7 +237,7 @@ itkLBFGSOptimizerTest(int, char *[]) // Get the final value of the optimizer std::cout << "Testing GetValue() : "; - OptimizerType::MeasureType finalValue = itkOptimizer->GetValue(); + const OptimizerType::MeasureType finalValue = itkOptimizer->GetValue(); if (itk::Math::abs(finalValue + 10.0) > 0.01) { std::cout << "[FAILURE]" << std::endl; diff --git a/Modules/Numerics/Optimizers/test/itkLevenbergMarquardtOptimizerTest.cxx b/Modules/Numerics/Optimizers/test/itkLevenbergMarquardtOptimizerTest.cxx index 195ff4ad30e..ed0580c89af 100644 --- a/Modules/Numerics/Optimizers/test/itkLevenbergMarquardtOptimizerTest.cxx +++ b/Modules/Numerics/Optimizers/test/itkLevenbergMarquardtOptimizerTest.cxx @@ -101,9 +101,9 @@ class LMCostFunction : public itk::MultipleValuedCostFunction { std::cout << "GetValue( "; - double a = parameters[0]; - double b = parameters[1]; - double c = parameters[2]; + const double a = parameters[0]; + const double b = parameters[1]; + const double c = parameters[2]; std::cout << a << " , "; std::cout << b << " , "; @@ -132,9 +132,9 @@ class LMCostFunction : public itk::MultipleValuedCostFunction { std::cout << "GetDerivative( "; - double a = parameters[0]; - double b = parameters[1]; - double c = parameters[2]; + const double a = parameters[0]; + const double b = parameters[1]; + const double c = parameters[2]; std::cout << a << " , "; std::cout << b << " , "; @@ -372,8 +372,8 @@ itkRunLevenbergMarquardOptimization(bool useGradient, // // check results to see if it is within range // - bool pass = true; - double trueParameters[3] = { ra, rb, rc }; + bool pass = true; + const double trueParameters[3] = { ra, rb, rc }; for (unsigned int j = 0; j < LMCostFunction::SpaceDimension; ++j) { if (itk::Math::abs(finalPosition[j] - trueParameters[j]) > 0.01) diff --git a/Modules/Numerics/Optimizers/test/itkOnePlusOneEvolutionaryOptimizerTest.cxx b/Modules/Numerics/Optimizers/test/itkOnePlusOneEvolutionaryOptimizerTest.cxx index 4b1a678203d..0b61df8f84b 100644 --- a/Modules/Numerics/Optimizers/test/itkOnePlusOneEvolutionaryOptimizerTest.cxx +++ b/Modules/Numerics/Optimizers/test/itkOnePlusOneEvolutionaryOptimizerTest.cxx @@ -66,14 +66,14 @@ class OnePlusOneCostFunction : public itk::SingleValuedCostFunction MeasureType GetValue(const ParametersType & parameters) const override { - double x = parameters[0]; - double y = parameters[1]; + const double x = parameters[0]; + const double y = parameters[1]; std::cout << "GetValue( "; std::cout << x << ' '; std::cout << y << ") = "; - MeasureType measure = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; + const MeasureType measure = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; std::cout << measure << std::endl; @@ -124,7 +124,7 @@ class OnePlusOneCommandIterationUpdate : public itk::Command { return; } - double currentValue = optimizer->GetValue(); + const double currentValue = optimizer->GetValue(); // Only print out when the Metric value changes if (itk::Math::abs(m_LastMetricValue - currentValue) > 1e-7) { @@ -155,11 +155,11 @@ itkOnePlusOneEvolutionaryOptimizerTest(int, char *[]) ITK_TEST_EXPECT_TRUE(!itkOptimizer->GetInitialized()); - itk::OnePlusOneCommandIterationUpdate::Pointer observer = itk::OnePlusOneCommandIterationUpdate::New(); + const itk::OnePlusOneCommandIterationUpdate::Pointer observer = itk::OnePlusOneCommandIterationUpdate::New(); itkOptimizer->AddObserver(itk::IterationEvent(), observer); // Declaration of the CostFunction - itk::OnePlusOneCostFunction::Pointer costFunction = itk::OnePlusOneCostFunction::New(); + const itk::OnePlusOneCostFunction::Pointer costFunction = itk::OnePlusOneCostFunction::New(); itkOptimizer->SetCostFunction(costFunction); @@ -180,7 +180,7 @@ itkOnePlusOneEvolutionaryOptimizerTest(int, char *[]) ITK_TEST_SET_GET_VALUE(!maximize, itkOptimizer->GetMinimize()); ITK_TEST_SET_GET_BOOLEAN(itkOptimizer, Maximize, maximize); - unsigned int maximumIteration = 8000; + const unsigned int maximumIteration = 8000; itkOptimizer->SetMaximumIteration(8000); ITK_TEST_SET_GET_VALUE(maximumIteration, itkOptimizer->GetMaximumIteration()); @@ -233,8 +233,8 @@ itkOnePlusOneEvolutionaryOptimizerTest(int, char *[]) // // check results to see if it is within range // - bool pass = true; - double trueParameters[2] = { 2, -2 }; + bool pass = true; + const double trueParameters[2] = { 2, -2 }; for (unsigned int j = 0; j < 2; ++j) { if (itk::Math::abs(finalPosition[j] - trueParameters[j]) > 0.01) diff --git a/Modules/Numerics/Optimizers/test/itkOptimizersHierarchyTest.cxx b/Modules/Numerics/Optimizers/test/itkOptimizersHierarchyTest.cxx index 220755e7199..b81bf62a9a0 100644 --- a/Modules/Numerics/Optimizers/test/itkOptimizersHierarchyTest.cxx +++ b/Modules/Numerics/Optimizers/test/itkOptimizersHierarchyTest.cxx @@ -45,11 +45,11 @@ itkOptimizersHierarchyTest(int, char *[]) using OptimizerType = itk::Optimizer; auto genericOptimizer = OptimizerType::New(); - unsigned int spaceDimension = 10; + const unsigned int spaceDimension = 10; - OptimizerType::ParametersType initialPosition(spaceDimension); - OptimizerType::ParametersType currentPosition(spaceDimension); - OptimizerType::ScalesType parameterScale(spaceDimension); + OptimizerType::ParametersType initialPosition(spaceDimension); + const OptimizerType::ParametersType currentPosition(spaceDimension); + OptimizerType::ScalesType parameterScale(spaceDimension); parameterScale.Fill(1.5); initialPosition.Fill(2.0); @@ -148,8 +148,8 @@ itkOptimizersHierarchyTest(int, char *[]) // Not used; empty method body; called for coverage purposes - CumulativeGaussianCostFunctionType::ParametersType parameters{}; - CumulativeGaussianCostFunctionType::DerivativeType derivative; + const CumulativeGaussianCostFunctionType::ParametersType parameters{}; + CumulativeGaussianCostFunctionType::DerivativeType derivative; cumGaussCostFunc->GetDerivative(parameters, derivative); diff --git a/Modules/Numerics/Optimizers/test/itkParticleSwarmOptimizerTest.cxx b/Modules/Numerics/Optimizers/test/itkParticleSwarmOptimizerTest.cxx index 18ae7c5e673..c477d08bf33 100644 --- a/Modules/Numerics/Optimizers/test/itkParticleSwarmOptimizerTest.cxx +++ b/Modules/Numerics/Optimizers/test/itkParticleSwarmOptimizerTest.cxx @@ -66,11 +66,11 @@ itkParticleSwarmOptimizerTest(int argc, char * argv[]) verboseFlag = std::stoi(argv[1]) ? true : false; } - unsigned int allIterations = 10; - double threshold = 0.8; - unsigned int success1{}; - unsigned int success2{}; - unsigned int success3{}; + const unsigned int allIterations = 10; + const double threshold = 0.8; + unsigned int success1{}; + unsigned int success2{}; + unsigned int success3{}; std::cout << "Particle Swarm Optimizer Test \n \n"; @@ -110,10 +110,10 @@ PSOTest1() std::cout << "Particle Swarm Optimizer Test 1 [f(x) = if(x<0) x^2+4x; else 2x^2-8x]\n"; std::cout << "-------------------------------\n"; - double knownParameters = 2.0; + const double knownParameters = 2.0; // the function we want to optimize - itk::ParticleSwarmTestF1::Pointer costFunction = itk::ParticleSwarmTestF1::New(); + const itk::ParticleSwarmTestF1::Pointer costFunction = itk::ParticleSwarmTestF1::New(); auto itkOptimizer = OptimizerType::New(); itkOptimizer->UseSeedOn(); @@ -122,10 +122,10 @@ PSOTest1() // set optimizer parameters OptimizerType::ParameterBoundsType bounds; bounds.push_back(std::make_pair(-10, 10)); - unsigned int numberOfParticles = 10; - unsigned int maxIterations = 100; - double xTolerance = 0.1; - double fTolerance = 0.001; + const unsigned int numberOfParticles = 10; + const unsigned int maxIterations = 100; + const double xTolerance = 0.1; + const double fTolerance = 0.001; OptimizerType::ParametersType initialParameters(1); @@ -137,7 +137,7 @@ PSOTest1() itkOptimizer->SetCostFunction(costFunction); // observe the iterations - itk::CommandIterationUpdateParticleSwarm::Pointer observer = itk::CommandIterationUpdateParticleSwarm::New(); + const itk::CommandIterationUpdateParticleSwarm::Pointer observer = itk::CommandIterationUpdateParticleSwarm::New(); if (verboseFlag) { itkOptimizer->AddObserver(itk::IterationEvent(), observer); @@ -212,7 +212,7 @@ PSOTest2() knownParameters[1] = -2.0; // the function we want to optimize - itk::ParticleSwarmTestF2::Pointer costFunction = itk::ParticleSwarmTestF2::New(); + const itk::ParticleSwarmTestF2::Pointer costFunction = itk::ParticleSwarmTestF2::New(); auto itkOptimizer = OptimizerType::New(); itkOptimizer->UseSeedOn(); @@ -222,10 +222,10 @@ PSOTest2() OptimizerType::ParameterBoundsType bounds; bounds.push_back(std::make_pair(-10, 10)); bounds.push_back(std::make_pair(-10, 10)); - unsigned int numberOfParticles = 10; - unsigned int maxIterations = 100; - double xTolerance = 0.1; - double fTolerance = 0.001; + const unsigned int numberOfParticles = 10; + const unsigned int maxIterations = 100; + const double xTolerance = 0.1; + const double fTolerance = 0.001; OptimizerType::ParametersType initialParameters(2); itkOptimizer->SetParameterBounds(bounds); @@ -236,7 +236,7 @@ PSOTest2() itkOptimizer->SetCostFunction(costFunction); // observe the iterations - itk::CommandIterationUpdateParticleSwarm::Pointer observer = itk::CommandIterationUpdateParticleSwarm::New(); + const itk::CommandIterationUpdateParticleSwarm::Pointer observer = itk::CommandIterationUpdateParticleSwarm::New(); if (verboseFlag) { itkOptimizer->AddObserver(itk::IterationEvent(), observer); @@ -291,7 +291,7 @@ PSOTest3() knownParameters[1] = 1.0; // the function we want to optimize - itk::ParticleSwarmTestF3::Pointer costFunction = itk::ParticleSwarmTestF3::New(); + const itk::ParticleSwarmTestF3::Pointer costFunction = itk::ParticleSwarmTestF3::New(); auto itkOptimizer = OptimizerType::New(); itkOptimizer->UseSeedOn(); @@ -301,10 +301,10 @@ PSOTest3() OptimizerType::ParameterBoundsType bounds; bounds.push_back(std::make_pair(-100, 100)); bounds.push_back(std::make_pair(-100, 100)); - unsigned int numberOfParticles = 100; - unsigned int maxIterations = 200; - double xTolerance = 0.1; - double fTolerance = 0.01; + const unsigned int numberOfParticles = 100; + const unsigned int maxIterations = 200; + const double xTolerance = 0.1; + const double fTolerance = 0.01; OptimizerType::ParametersType initialParameters(2); // Exercise Get/Set methods @@ -325,7 +325,7 @@ PSOTest3() return EXIT_FAILURE; } - unsigned int numberOfGenerationsWithMinimalImprovement = 1; + const unsigned int numberOfGenerationsWithMinimalImprovement = 1; itkOptimizer->SetNumberOfGenerationsWithMinimalImprovement(numberOfGenerationsWithMinimalImprovement); if (itkOptimizer->GetNumberOfGenerationsWithMinimalImprovement() != numberOfGenerationsWithMinimalImprovement) { @@ -343,7 +343,7 @@ PSOTest3() } itkOptimizer->SetCostFunction(costFunction); - double percentageParticlesConverged = 0.6; + const double percentageParticlesConverged = 0.6; itkOptimizer->SetPercentageParticlesConverged(percentageParticlesConverged); if (itk::Math::abs(itkOptimizer->GetPercentageParticlesConverged() - percentageParticlesConverged) > tolerance) { @@ -351,7 +351,7 @@ PSOTest3() return EXIT_FAILURE; } - double inertiaCoefficient = 0.7298; + const double inertiaCoefficient = 0.7298; itkOptimizer->SetInertiaCoefficient(inertiaCoefficient); if (itk::Math::abs(itkOptimizer->GetInertiaCoefficient() - inertiaCoefficient)) { @@ -359,7 +359,7 @@ PSOTest3() return EXIT_FAILURE; } - double personalCoefficient = 1.496; + const double personalCoefficient = 1.496; itkOptimizer->SetPersonalCoefficient(personalCoefficient); if (itk::Math::abs(itkOptimizer->GetPersonalCoefficient() - personalCoefficient)) { @@ -367,7 +367,7 @@ PSOTest3() return EXIT_FAILURE; } - double gobalCoefficient = 1.496; + const double gobalCoefficient = 1.496; itkOptimizer->SetGlobalCoefficient(gobalCoefficient); if (itk::Math::abs(itkOptimizer->GetGlobalCoefficient() - gobalCoefficient)) { @@ -379,7 +379,7 @@ PSOTest3() itkOptimizer->Print(std::cout); // observe the iterations - itk::CommandIterationUpdateParticleSwarm::Pointer observer = itk::CommandIterationUpdateParticleSwarm::New(); + const itk::CommandIterationUpdateParticleSwarm::Pointer observer = itk::CommandIterationUpdateParticleSwarm::New(); if (verboseFlag) { diff --git a/Modules/Numerics/Optimizers/test/itkParticleSwarmOptimizerTestFunctions.h b/Modules/Numerics/Optimizers/test/itkParticleSwarmOptimizerTestFunctions.h index 5beeb2c1b1e..8b584f302e5 100644 --- a/Modules/Numerics/Optimizers/test/itkParticleSwarmOptimizerTestFunctions.h +++ b/Modules/Numerics/Optimizers/test/itkParticleSwarmOptimizerTestFunctions.h @@ -219,7 +219,7 @@ class CommandIterationUpdateParticleSwarm : public Command std::cout << "f(x): " << optimizer->GetValue() << std::endl; if (m_PrintOptimizer) { - ParticleSwarmOptimizerBase::Pointer optimizerPtr = const_cast(optimizer); + const ParticleSwarmOptimizerBase::Pointer optimizerPtr = const_cast(optimizer); std::cout << optimizerPtr; } } diff --git a/Modules/Numerics/Optimizers/test/itkPowellOptimizerTest.cxx b/Modules/Numerics/Optimizers/test/itkPowellOptimizerTest.cxx index 5f12a4471bf..a76d8f7d9ad 100644 --- a/Modules/Numerics/Optimizers/test/itkPowellOptimizerTest.cxx +++ b/Modules/Numerics/Optimizers/test/itkPowellOptimizerTest.cxx @@ -68,14 +68,14 @@ class PowellBoundedCostFunction : public itk::SingleValuedCostFunction { ++POWELL_CALLS_TO_GET_VALUE; - double x = parameters[0]; - double y = parameters[1]; + const double x = parameters[0]; + const double y = parameters[1]; std::cout << " GetValue( "; std::cout << x << ' '; std::cout << y << ") = "; - MeasureType measure = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; + const MeasureType measure = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; std::cout << measure << std::endl; @@ -183,8 +183,8 @@ itkPowellOptimizerTest(int argc, char * argv[]) // // check results to see if it is within range // - bool pass = true; - double trueParameters[2] = { 2, -2 }; + bool pass = true; + const double trueParameters[2] = { 2, -2 }; for (unsigned int j = 0; j < 2; ++j) { if (itk::Math::abs(finalPosition[j] - trueParameters[j]) > 0.01) diff --git a/Modules/Numerics/Optimizers/test/itkRegularStepGradientDescentOptimizerTest.cxx b/Modules/Numerics/Optimizers/test/itkRegularStepGradientDescentOptimizerTest.cxx index 68db3148c32..81022df36d7 100644 --- a/Modules/Numerics/Optimizers/test/itkRegularStepGradientDescentOptimizerTest.cxx +++ b/Modules/Numerics/Optimizers/test/itkRegularStepGradientDescentOptimizerTest.cxx @@ -63,14 +63,14 @@ class RSGCostFunction : public itk::SingleValuedCostFunction GetValue(const ParametersType & parameters) const override { - double x = parameters[0]; - double y = parameters[1]; + const double x = parameters[0]; + const double y = parameters[1]; std::cout << "GetValue( "; std::cout << x << ' '; std::cout << y << ") = "; - MeasureType measure = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; + const MeasureType measure = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; std::cout << measure << std::endl; return measure; @@ -80,8 +80,8 @@ class RSGCostFunction : public itk::SingleValuedCostFunction GetDerivative(const ParametersType & parameters, DerivativeType & derivative) const override { - double x = parameters[0]; - double y = parameters[1]; + const double x = parameters[0]; + const double y = parameters[1]; std::cout << "GetDerivative( "; std::cout << x << ' '; @@ -157,7 +157,7 @@ itkRegularStepGradientDescentOptimizerTest(int, char *[]) itkOptimizer->SetMinimumStepLength(minimumStepLength); ITK_TEST_SET_GET_VALUE(minimumStepLength, itkOptimizer->GetMinimumStepLength()); - itk::SizeValueType numberOfIterations = static_cast(900); + const itk::SizeValueType numberOfIterations = static_cast(900); itkOptimizer->SetNumberOfIterations(numberOfIterations); ITK_TEST_SET_GET_VALUE(numberOfIterations, itkOptimizer->GetNumberOfIterations()); @@ -173,8 +173,8 @@ itkRegularStepGradientDescentOptimizerTest(int, char *[]) std::cout << finalPosition[1] << ')' << std::endl; // Check results to see if it is within range - bool pass = true; - double trueParameters[2] = { 2, -2 }; + bool pass = true; + const double trueParameters[2] = { 2, -2 }; for (unsigned int j = 0; j < 2; ++j) { if (itk::Math::abs(finalPosition[j] - trueParameters[j]) > 0.01) diff --git a/Modules/Numerics/Optimizers/test/itkSPSAOptimizerTest.cxx b/Modules/Numerics/Optimizers/test/itkSPSAOptimizerTest.cxx index 11b164806f9..1215ad651d8 100644 --- a/Modules/Numerics/Optimizers/test/itkSPSAOptimizerTest.cxx +++ b/Modules/Numerics/Optimizers/test/itkSPSAOptimizerTest.cxx @@ -62,14 +62,14 @@ class SPSACostFunction : public itk::SingleValuedCostFunction GetValue(const ParametersType & parameters) const override { - double x = parameters[0]; - double y = parameters[1]; + const double x = parameters[0]; + const double y = parameters[1]; std::cout << "GetValue( "; std::cout << x << ' '; std::cout << y << ") = "; - MeasureType measure = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; + const MeasureType measure = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; std::cout << measure << std::endl; return measure; @@ -79,8 +79,8 @@ class SPSACostFunction : public itk::SingleValuedCostFunction GetDerivative(const ParametersType & parameters, DerivativeType & derivative) const override { - double x = parameters[0]; - double y = parameters[1]; + const double x = parameters[0]; + const double y = parameters[1]; std::cout << "GetDerivative( "; std::cout << x << ' '; @@ -128,48 +128,48 @@ itkSPSAOptimizerTest(int, char *[]) parametersScale[1] = 2.0; itkOptimizer->SetScales(parametersScale); - bool maximize = false; + const bool maximize = false; ITK_TEST_SET_GET_BOOLEAN(itkOptimizer, Maximize, maximize); - bool minimize = !maximize; + const bool minimize = !maximize; ITK_TEST_SET_GET_BOOLEAN(itkOptimizer, Minimize, minimize); - double a = 10.0; + const double a = 10.0; itkOptimizer->SetA(a); ITK_TEST_SET_GET_VALUE(a, itkOptimizer->GetA()); - double alpha = 0.602; + const double alpha = 0.602; itkOptimizer->SetAlpha(alpha); ITK_TEST_SET_GET_VALUE(alpha, itkOptimizer->GetAlpha()); - double c = 0.0001; + const double c = 0.0001; itkOptimizer->Setc(c); ITK_TEST_SET_GET_VALUE(c, itkOptimizer->Getc()); itkOptimizer->SetSc(c); ITK_TEST_SET_GET_VALUE(c, itkOptimizer->GetSc()); - double gamma = 0.101; + const double gamma = 0.101; itkOptimizer->SetGamma(gamma); ITK_TEST_SET_GET_VALUE(gamma, itkOptimizer->GetGamma()); - double tolerance = 1e-5; + const double tolerance = 1e-5; itkOptimizer->SetTolerance(tolerance); ITK_TEST_SET_GET_VALUE(tolerance, itkOptimizer->GetTolerance()); - double stateOfConvergenceDecayRate = 0.5; + const double stateOfConvergenceDecayRate = 0.5; itkOptimizer->SetStateOfConvergenceDecayRate(stateOfConvergenceDecayRate); ITK_TEST_SET_GET_VALUE(stateOfConvergenceDecayRate, itkOptimizer->GetStateOfConvergenceDecayRate()); - itk::SizeValueType minimumNumberOfIterations = 10; + const itk::SizeValueType minimumNumberOfIterations = 10; itkOptimizer->SetMinimumNumberOfIterations(10); ITK_TEST_SET_GET_VALUE(minimumNumberOfIterations, itkOptimizer->GetMinimumNumberOfIterations()); - itk::SizeValueType maximumNumberOfIterations = 100; + const itk::SizeValueType maximumNumberOfIterations = 100; itkOptimizer->SetMaximumNumberOfIterations(maximumNumberOfIterations); ITK_TEST_SET_GET_VALUE(maximumNumberOfIterations, itkOptimizer->GetMaximumNumberOfIterations()); - itk::SizeValueType numberOfPerturbations = 1; + const itk::SizeValueType numberOfPerturbations = 1; itkOptimizer->SetNumberOfPerturbations(numberOfPerturbations); ITK_TEST_SET_GET_VALUE(numberOfPerturbations, itkOptimizer->GetNumberOfPerturbations()); @@ -225,8 +225,8 @@ itkSPSAOptimizerTest(int, char *[]) // // check results to see if it is within range // - bool pass = true; - double trueParameters[2] = { 2, -2 }; + bool pass = true; + const double trueParameters[2] = { 2, -2 }; for (unsigned int j = 0; j < 2; ++j) { if (itk::Math::abs(finalPosition[j] - trueParameters[j]) > 0.01) diff --git a/Modules/Numerics/Optimizers/test/itkVersorRigid3DTransformOptimizerTest.cxx b/Modules/Numerics/Optimizers/test/itkVersorRigid3DTransformOptimizerTest.cxx index f558d32f3bd..c073dc1d9da 100644 --- a/Modules/Numerics/Optimizers/test/itkVersorRigid3DTransformOptimizerTest.cxx +++ b/Modules/Numerics/Optimizers/test/itkVersorRigid3DTransformOptimizerTest.cxx @@ -122,10 +122,10 @@ class versorRigid3DCostFunction : public itk::SingleValuedCostFunction m_Transform->SetParameters(p); - PointType P2 = m_Transform->TransformPoint(m_P1); - PointType Q2 = m_Transform->TransformPoint(m_Q1); + const PointType P2 = m_Transform->TransformPoint(m_P1); + const PointType Q2 = m_Transform->TransformPoint(m_Q1); - MeasureType measure = P2.SquaredEuclideanDistanceTo(m_P) + Q2.SquaredEuclideanDistanceTo(m_Q); + const MeasureType measure = P2.SquaredEuclideanDistanceTo(m_P) + Q2.SquaredEuclideanDistanceTo(m_Q); return measure; } @@ -155,9 +155,9 @@ class versorRigid3DCostFunction : public itk::SingleValuedCostFunction versorY.SetRotationAroundY(deltaAngle); versorZ.SetRotationAroundZ(deltaAngle); - VersorType plusdDeltaX = currentVersor * versorX; - VersorType plusdDeltaY = currentVersor * versorY; - VersorType plusdDeltaZ = currentVersor * versorZ; + const VersorType plusdDeltaX = currentVersor * versorX; + const VersorType plusdDeltaY = currentVersor * versorY; + const VersorType plusdDeltaZ = currentVersor * versorZ; ParametersType parametersPlustDeltaVX = parameters; ParametersType parametersPlustDeltaVY = parameters; @@ -250,7 +250,7 @@ itkVersorRigid3DTransformOptimizerTest(int, char *[]) axis[1] = 0.0f; axis[2] = 0.0f; - VersorType::ValueType angle = 0.0f; + const VersorType::ValueType angle = 0.0f; VersorType initialRotation; initialRotation.Set(axis, angle); @@ -349,7 +349,7 @@ itkVersorRigid3DTransformOptimizerTest(int, char *[]) std::cout << "Final parameters = " << finalPosition << std::endl; std::cout << "True Parameters = " << trueParameters << std::endl; - VersorType ratio = finalRotation * trueRotation.GetReciprocal(); + const VersorType ratio = finalRotation * trueRotation.GetReciprocal(); const VersorType::ValueType cosHalfAngle = ratio.GetW(); const VersorType::ValueType cosHalfAngleSquare = cosHalfAngle * cosHalfAngle; if (cosHalfAngleSquare < 0.95) diff --git a/Modules/Numerics/Optimizers/test/itkVersorTransformOptimizerTest.cxx b/Modules/Numerics/Optimizers/test/itkVersorTransformOptimizerTest.cxx index bc2609f2ae9..24223d68b90 100644 --- a/Modules/Numerics/Optimizers/test/itkVersorTransformOptimizerTest.cxx +++ b/Modules/Numerics/Optimizers/test/itkVersorTransformOptimizerTest.cxx @@ -102,7 +102,7 @@ class versorCostFunction : public itk::SingleValuedCostFunction const VectorType C = m_Transform->TransformVector(B); - MeasureType measure = A * C; + const MeasureType measure = A * C; std::cout << measure << std::endl; @@ -135,9 +135,9 @@ class versorCostFunction : public itk::SingleValuedCostFunction versorY.SetRotationAroundY(deltaAngle); versorZ.SetRotationAroundZ(deltaAngle); - VersorType plusdDeltaX = currentVersor * versorX; - VersorType plusdDeltaY = currentVersor * versorY; - VersorType plusdDeltaZ = currentVersor * versorZ; + const VersorType plusdDeltaX = currentVersor * versorX; + const VersorType plusdDeltaY = currentVersor * versorY; + const VersorType plusdDeltaZ = currentVersor * versorZ; ParametersType parametersPlustDeltaX(SpaceDimension); ParametersType parametersPlustDeltaY(SpaceDimension); @@ -207,7 +207,7 @@ itkVersorTransformOptimizerTest(int, char *[]) axis[1] = 0.0f; axis[2] = 0.0f; - VersorType::ValueType angle = 0.0f; + const VersorType::ValueType angle = 0.0f; VersorType initialRotation; initialRotation.Set(axis, angle); @@ -281,7 +281,7 @@ itkVersorTransformOptimizerTest(int, char *[]) std::cout << "True Parameters = " << trueParameters << std::endl; - VersorType ratio = finalRotation * trueRotation.GetReciprocal(); + const VersorType ratio = finalRotation * trueRotation.GetReciprocal(); const VersorType::ValueType cosHalfAngle = ratio.GetW(); const VersorType::ValueType cosHalfAngleSquare = cosHalfAngle * cosHalfAngle; if (cosHalfAngleSquare < 0.95) diff --git a/Modules/Numerics/Optimizersv4/include/itkExhaustiveOptimizerv4.hxx b/Modules/Numerics/Optimizersv4/include/itkExhaustiveOptimizerv4.hxx index 5682e9e2462..0bdfdbb302c 100644 --- a/Modules/Numerics/Optimizersv4/include/itkExhaustiveOptimizerv4.hxx +++ b/Modules/Numerics/Optimizersv4/include/itkExhaustiveOptimizerv4.hxx @@ -54,7 +54,7 @@ ExhaustiveOptimizerv4::StartWalking() this->SetInitialPosition(initialPos); // store the initial position - MeasureType initialValue = this->m_Metric->GetValue(); + const MeasureType initialValue = this->m_Metric->GetValue(); m_MaximumMetricValue = initialValue; m_MinimumMetricValue = initialValue; @@ -101,7 +101,7 @@ ExhaustiveOptimizerv4::ResumeWalking() while (!m_Stop) { - ParametersType currentPosition = this->GetCurrentPosition(); + const ParametersType currentPosition = this->GetCurrentPosition(); if (m_Stop) { diff --git a/Modules/Numerics/Optimizersv4/include/itkGradientDescentLineSearchOptimizerv4.hxx b/Modules/Numerics/Optimizersv4/include/itkGradientDescentLineSearchOptimizerv4.hxx index de7b15c4668..3e5ce0cacd0 100644 --- a/Modules/Numerics/Optimizersv4/include/itkGradientDescentLineSearchOptimizerv4.hxx +++ b/Modules/Numerics/Optimizersv4/include/itkGradientDescentLineSearchOptimizerv4.hxx @@ -140,7 +140,7 @@ GradientDescentLineSearchOptimizerv4Template::Gol // scope before we call recursively below. With dense transforms // we would otherwise eat up a lot of memory unnecessarily. TInternalComputationValueType baseLearningRate = this->m_LearningRate; - DerivativeType baseGradient(this->m_Gradient); + const DerivativeType baseGradient(this->m_Gradient); ParametersType baseParameters(this->GetCurrentPosition()); this->m_LearningRate = x; diff --git a/Modules/Numerics/Optimizersv4/include/itkGradientDescentOptimizerBasev4.hxx b/Modules/Numerics/Optimizersv4/include/itkGradientDescentOptimizerBasev4.hxx index f635b450580..22ea5802783 100644 --- a/Modules/Numerics/Optimizersv4/include/itkGradientDescentOptimizerBasev4.hxx +++ b/Modules/Numerics/Optimizersv4/include/itkGradientDescentOptimizerBasev4.hxx @@ -29,13 +29,13 @@ GradientDescentOptimizerBasev4Template::GradientD { /** Threader for apply scales to gradient */ - typename GradientDescentOptimizerBasev4ModifyGradientByScalesThreaderTemplate::Pointer - modifyGradientByScalesThreader = - GradientDescentOptimizerBasev4ModifyGradientByScalesThreaderTemplate::New(); + const typename GradientDescentOptimizerBasev4ModifyGradientByScalesThreaderTemplate< + TInternalComputationValueType>::Pointer modifyGradientByScalesThreader = + GradientDescentOptimizerBasev4ModifyGradientByScalesThreaderTemplate::New(); this->m_ModifyGradientByScalesThreader = modifyGradientByScalesThreader; /** Threader for apply the learning rate to gradient */ - typename GradientDescentOptimizerBasev4ModifyGradientByLearningRateThreaderTemplate< + const typename GradientDescentOptimizerBasev4ModifyGradientByLearningRateThreaderTemplate< TInternalComputationValueType>::Pointer modifyGradientByLearningRateThreader = GradientDescentOptimizerBasev4ModifyGradientByLearningRateThreaderTemplate::New(); this->m_ModifyGradientByLearningRateThreader = modifyGradientByLearningRateThreader; diff --git a/Modules/Numerics/Optimizersv4/include/itkGradientDescentOptimizerv4.hxx b/Modules/Numerics/Optimizersv4/include/itkGradientDescentOptimizerv4.hxx index 4f023201cfb..29fc20975bf 100644 --- a/Modules/Numerics/Optimizersv4/include/itkGradientDescentOptimizerv4.hxx +++ b/Modules/Numerics/Optimizersv4/include/itkGradientDescentOptimizerv4.hxx @@ -221,7 +221,7 @@ GradientDescentOptimizerv4Template::ModifyGradien // Take the modulo of the index to handle gradients from transforms // with local support. The gradient array stores the gradient of local // parameters at each local index with linear packing. - IndexValueType index = j % scales.Size(); + const IndexValueType index = j % scales.Size(); this->m_Gradient[j] = this->m_Gradient[j] * factor[index]; } } diff --git a/Modules/Numerics/Optimizersv4/include/itkLBFGS2Optimizerv4.h b/Modules/Numerics/Optimizersv4/include/itkLBFGS2Optimizerv4.h index 5750626287d..a750548d730 100644 --- a/Modules/Numerics/Optimizersv4/include/itkLBFGS2Optimizerv4.h +++ b/Modules/Numerics/Optimizersv4/include/itkLBFGS2Optimizerv4.h @@ -533,7 +533,7 @@ class ITK_TEMPLATE_EXPORT LBFGS2Optimizerv4Template GetConvergenceValue() const override { itkWarningMacro("Not supported. Please use LBFGS specific convergence methods."); - static PrecisionType value{}; + static const PrecisionType value{}; return value; } diff --git a/Modules/Numerics/Optimizersv4/include/itkLBFGS2Optimizerv4.hxx b/Modules/Numerics/Optimizersv4/include/itkLBFGS2Optimizerv4.hxx index f6cba844574..a0981e45156 100644 --- a/Modules/Numerics/Optimizersv4/include/itkLBFGS2Optimizerv4.hxx +++ b/Modules/Numerics/Optimizersv4/include/itkLBFGS2Optimizerv4.hxx @@ -87,7 +87,7 @@ LBFGS2Optimizerv4Template::ResumeOptimization() // Copy parameters const ParametersType & parameters = this->m_Metric->GetParameters(); - int N = parameters.GetSize(); + const int N = parameters.GetSize(); if (N == 0) { itkExceptionMacro("Optimizer parameters are not initialized."); @@ -414,7 +414,7 @@ auto LBFGS2Optimizerv4Template::GetLineSearch() const -> LineSearchMethodEnum { LineSearchMethodEnum linesearch = LineSearchMethodEnum::LINESEARCH_DEFAULT; - int lbfgsLineSearch = m_Parameters.linesearch; + const int lbfgsLineSearch = m_Parameters.linesearch; if (lbfgsLineSearch == LBFGS_LINESEARCH_BACKTRACKING) { linesearch = LineSearchMethodEnum::LINESEARCH_BACKTRACKING; diff --git a/Modules/Numerics/Optimizersv4/include/itkMultiStartOptimizerv4.hxx b/Modules/Numerics/Optimizersv4/include/itkMultiStartOptimizerv4.hxx index e7282906abc..2de74235d4c 100644 --- a/Modules/Numerics/Optimizersv4/include/itkMultiStartOptimizerv4.hxx +++ b/Modules/Numerics/Optimizersv4/include/itkMultiStartOptimizerv4.hxx @@ -102,7 +102,7 @@ template void MultiStartOptimizerv4Template::InstantiateLocalOptimizer() { - LocalOptimizerPointer optimizer = LocalOptimizerType::New(); + const LocalOptimizerPointer optimizer = LocalOptimizerType::New(); optimizer->SetLearningRate(static_cast(1.e-1)); optimizer->SetNumberOfIterations(25); this->m_LocalOptimizer = optimizer; diff --git a/Modules/Numerics/Optimizersv4/include/itkObjectToObjectMetric.hxx b/Modules/Numerics/Optimizersv4/include/itkObjectToObjectMetric.hxx index 64b007c8adf..1d61652fe23 100644 --- a/Modules/Numerics/Optimizersv4/include/itkObjectToObjectMetric.hxx +++ b/Modules/Numerics/Optimizersv4/include/itkObjectToObjectMetric.hxx @@ -348,7 +348,7 @@ ObjectToObjectMetricm_VirtualImage->ComputeOffset(index) * numberOfLocalParameters; + const OffsetValueType offset = this->m_VirtualImage->ComputeOffset(index) * numberOfLocalParameters; return offset; } else @@ -485,9 +485,9 @@ ObjectToObjectMetricGetDisplacementField(); - typename FieldType::RegionType fieldRegion = field->GetBufferedRegion(); - VirtualRegionType virtualRegion = this->GetVirtualRegion(); + const typename FieldType::ConstPointer field = displacementTransform->GetDisplacementField(); + const typename FieldType::RegionType fieldRegion = field->GetBufferedRegion(); + const VirtualRegionType virtualRegion = this->GetVirtualRegion(); if (virtualRegion.GetSize() != fieldRegion.GetSize() || virtualRegion.GetIndex() != fieldRegion.GetIndex()) { itkExceptionMacro( diff --git a/Modules/Numerics/Optimizersv4/include/itkOnePlusOneEvolutionaryOptimizerv4.hxx b/Modules/Numerics/Optimizersv4/include/itkOnePlusOneEvolutionaryOptimizerv4.hxx index f5a909de2f1..6960a3e49f3 100644 --- a/Modules/Numerics/Optimizersv4/include/itkOnePlusOneEvolutionaryOptimizerv4.hxx +++ b/Modules/Numerics/Optimizersv4/include/itkOnePlusOneEvolutionaryOptimizerv4.hxx @@ -94,7 +94,7 @@ OnePlusOneEvolutionaryOptimizerv4::StartOptimizat this->InvokeEvent(StartEvent()); m_Stop = false; - unsigned int spaceDimension = this->m_Metric->GetNumberOfParameters(); + const unsigned int spaceDimension = this->m_Metric->GetNumberOfParameters(); vnl_matrix A(spaceDimension, spaceDimension); vnl_vector parent(this->m_Metric->GetParameters()); vnl_vector f_norm(spaceDimension); @@ -253,7 +253,7 @@ OnePlusOneEvolutionaryOptimizerv4::StartOptimizat // f_norm, f_norm) // A = A + (adjust - 1.0) * A; - double alpha = ((adjust - 1.0) / dot_product(f_norm, f_norm)); + const double alpha = ((adjust - 1.0) / dot_product(f_norm, f_norm)); for (unsigned int c = 0; c < spaceDimension; ++c) { for (unsigned int r = 0; r < spaceDimension; ++r) diff --git a/Modules/Numerics/Optimizersv4/include/itkPowellOptimizerv4.hxx b/Modules/Numerics/Optimizersv4/include/itkPowellOptimizerv4.hxx index 3db5ea7b005..94646993a04 100644 --- a/Modules/Numerics/Optimizersv4/include/itkPowellOptimizerv4.hxx +++ b/Modules/Numerics/Optimizersv4/include/itkPowellOptimizerv4.hxx @@ -105,7 +105,7 @@ template void PowellOptimizerv4::Swap(double * a, double * b) const { - double tf = *a; + const double tf = *a; *a = *b; *b = tf; } @@ -260,7 +260,7 @@ PowellOptimizerv4::BracketedLineOptimize(double for (m_CurrentLineIteration = 0; m_CurrentLineIteration < m_MaximumLineIteration; ++m_CurrentLineIteration) { - double middle_range = (a + b) / 2; + const double middle_range = (a + b) / 2; double new_step; /* Step at this iteration */ @@ -287,7 +287,7 @@ PowellOptimizerv4::BracketedLineOptimize(double /* Decide if the interpolation can be tried */ if (itk::Math::abs(x - w) >= tolerance1) /* If x and w are distinct */ { - double t = (x - w) * (functionValueOfX - functionValueOfV); + const double t = (x - w) * (functionValueOfX - functionValueOfV); double q; /* ted as p/q; division operation*/ q = (x - v) * (functionValueOfX - functionValueOfW); @@ -333,9 +333,9 @@ PowellOptimizerv4::BracketedLineOptimize(double /* Obtain the next approximation to min */ /* and reduce the enveloping range */ - double t = x + new_step; /* Tentative point for the min */ + const double t = x + new_step; /* Tentative point for the min */ - double functionValueOft = this->GetLineValue(t, tempCoord); + const double functionValueOft = this->GetLineValue(t, tempCoord); if (functionValueOft <= functionValueOfX) { @@ -430,7 +430,7 @@ PowellOptimizerv4::StartOptimization(bool /* doOn for (this->m_CurrentIteration = 0; this->m_CurrentIteration <= m_MaximumIteration; this->m_CurrentIteration++) { - double fp = fx; + const double fp = fx; unsigned int ibig = 0; double del = 0.0; @@ -440,7 +440,7 @@ PowellOptimizerv4::StartOptimization(bool /* doOn { xit[j] = xi[j][i]; } - double fptt = fx; + const double fptt = fx; this->SetLine(p, xit); @@ -488,10 +488,10 @@ PowellOptimizerv4::StartOptimization(bool /* doOn } this->SetLine(ptt, xit); - double fptt = this->GetLineValue(0, tempCoord); + const double fptt = this->GetLineValue(0, tempCoord); if (fptt < fp) { - double t = 2.0 * (fp - 2.0 * fx + fptt) * itk::Math::sqr(fp - fx - del) - del * itk::Math::sqr(fp - fptt); + const double t = 2.0 * (fp - 2.0 * fx + fptt) * itk::Math::sqr(fp - fx - del) - del * itk::Math::sqr(fp - fptt); if (t < 0.0) { this->SetLine(p, xit); diff --git a/Modules/Numerics/Optimizersv4/include/itkQuasiNewtonOptimizerv4.hxx b/Modules/Numerics/Optimizersv4/include/itkQuasiNewtonOptimizerv4.hxx index 9e067f470d8..f914f24b39b 100644 --- a/Modules/Numerics/Optimizersv4/include/itkQuasiNewtonOptimizerv4.hxx +++ b/Modules/Numerics/Optimizersv4/include/itkQuasiNewtonOptimizerv4.hxx @@ -41,7 +41,7 @@ QuasiNewtonOptimizerv4Template::QuasiNewtonOptimi /** Threader for Quasi-Newton method */ using OptimizerType = QuasiNewtonOptimizerv4EstimateNewtonStepThreaderTemplate; using OptimizerPointer = typename OptimizerType::Pointer; - OptimizerPointer estimateNewtonStepThreader = OptimizerType::New(); + const OptimizerPointer estimateNewtonStepThreader = OptimizerType::New(); this->m_EstimateNewtonStepThreader = estimateNewtonStepThreader; } @@ -266,7 +266,7 @@ QuasiNewtonOptimizerv4Template::ResetNewtonStep(I m_HessianArray[loc][i][i] = NumericTraits::OneValue(); // identity matrix } - IndexValueType offset = loc * numLocalPara; + const IndexValueType offset = loc * numLocalPara; for (SizeValueType p = 0; p < numLocalPara; ++p) { // Set to zero for invalid Newton steps. @@ -307,8 +307,8 @@ QuasiNewtonOptimizerv4Template::EstimateNewtonSte { const SizeValueType numLocalPara = this->m_Metric->GetNumberOfLocalParameters(); - IndexValueType low = subrange[0] / numLocalPara; - IndexValueType high = subrange[1] / numLocalPara; + const IndexValueType low = subrange[0] / numLocalPara; + IndexValueType high = subrange[1] / numLocalPara; // let us denote the i-th thread's sub range by subrange_i // we assume subrange_i[1] + 1 = subrange_(i+1)[0] . @@ -349,8 +349,8 @@ QuasiNewtonOptimizerv4Template::ComputeHessianAnd return false; } - const SizeValueType numLocalPara = this->m_Metric->GetNumberOfLocalParameters(); - IndexValueType offset = loc * numLocalPara; + const SizeValueType numLocalPara = this->m_Metric->GetNumberOfLocalParameters(); + const IndexValueType offset = loc * numLocalPara; ParametersType dx(numLocalPara); // delta of position x: x_k+1 - x_k DerivativeType dg(numLocalPara); // delta of gradient: g_k+1 - g_k @@ -374,9 +374,9 @@ QuasiNewtonOptimizerv4Template::ComputeHessianAnd return false; } - vnl_matrix plus = outer_product(dg, dg) / dot_dg_dx; - vnl_matrix minus = outer_product(edg, edg) / dot_edg_dx; - vnl_matrix newHessian = this->m_HessianArray[loc] + plus - minus; + const vnl_matrix plus = outer_product(dg, dg) / dot_dg_dx; + const vnl_matrix minus = outer_product(edg, edg) / dot_edg_dx; + vnl_matrix newHessian = this->m_HessianArray[loc] + plus - minus; this->m_HessianArray[loc] = newHessian; diff --git a/Modules/Numerics/Optimizersv4/include/itkRegistrationParameterScalesEstimator.hxx b/Modules/Numerics/Optimizersv4/include/itkRegistrationParameterScalesEstimator.hxx index 76f43f30b87..c449eca3329 100644 --- a/Modules/Numerics/Optimizersv4/include/itkRegistrationParameterScalesEstimator.hxx +++ b/Modules/Numerics/Optimizersv4/include/itkRegistrationParameterScalesEstimator.hxx @@ -160,7 +160,7 @@ RegistrationParameterScalesEstimator::IsBSplineTransform() if (this->m_TransformForward) { using CompositeTransformType = CompositeTransform; - typename CompositeTransformType::Pointer compositeTransform = + const typename CompositeTransformType::Pointer compositeTransform = dynamic_cast(const_cast(this->m_Metric->GetMovingTransform())); if (compositeTransform) @@ -181,7 +181,7 @@ RegistrationParameterScalesEstimator::IsBSplineTransform() else // !this->m_TransformForward { using CompositeTransformType = CompositeTransform; - typename CompositeTransformType::Pointer compositeTransform = + const typename CompositeTransformType::Pointer compositeTransform = dynamic_cast(const_cast(this->m_Metric->GetFixedTransform())); if (compositeTransform) @@ -240,14 +240,14 @@ RegistrationParameterScalesEstimator::UpdateTransformParameters(const P // Apply the delta parameters to the transform if (this->m_TransformForward) { - typename MovingTransformType::Pointer movingTransform = + const typename MovingTransformType::Pointer movingTransform = const_cast(this->m_Metric->GetMovingTransform()); auto & step = const_cast(deltaParameters); movingTransform->UpdateTransformParameters(step); } else { - typename FixedTransformType::Pointer fixedTransform = + const typename FixedTransformType::Pointer fixedTransform = const_cast(this->m_Metric->GetFixedTransform()); auto & step = const_cast(deltaParameters); fixedTransform->UpdateTransformParameters(step); @@ -441,8 +441,8 @@ template auto RegistrationParameterScalesEstimator::GetVirtualDomainCentralIndex() -> VirtualIndexType { - VirtualRegionType region = this->m_Metric->GetVirtualRegion(); - const SizeValueType dim = this->GetDimension(); + const VirtualRegionType region = this->m_Metric->GetVirtualRegion(); + const SizeValueType dim = this->GetDimension(); VirtualIndexType lowerIndex = region.GetIndex(); VirtualIndexType upperIndex = region.GetUpperIndex(); @@ -462,8 +462,8 @@ RegistrationParameterScalesEstimator::GetVirtualDomainCentralRegion() - { VirtualIndexType centralIndex = this->GetVirtualDomainCentralIndex(); - VirtualRegionType region = this->m_Metric->GetVirtualRegion(); - const SizeValueType dim = this->GetDimension(); + const VirtualRegionType region = this->m_Metric->GetVirtualRegion(); + const SizeValueType dim = this->GetDimension(); VirtualIndexType lowerIndex = region.GetIndex(); VirtualIndexType upperIndex = region.GetUpperIndex(); @@ -491,7 +491,7 @@ template void RegistrationParameterScalesEstimator::SampleVirtualDomainWithCentralRegion() { - VirtualRegionType centralRegion = this->GetVirtualDomainCentralRegion(); + const VirtualRegionType centralRegion = this->GetVirtualDomainCentralRegion(); SampleVirtualDomainWithRegion(centralRegion); } @@ -499,8 +499,8 @@ template void RegistrationParameterScalesEstimator::SampleVirtualDomainWithRegion(VirtualRegionType region) { - VirtualImageConstPointer image = this->m_Metric->GetVirtualImage(); - const SizeValueType total = region.GetNumberOfPixels(); + const VirtualImageConstPointer image = this->m_Metric->GetVirtualImage(); + const SizeValueType total = region.GetNumberOfPixels(); this->m_SamplePoints.resize(total); /* Set up an iterator within the user specified virtual image region. */ @@ -525,10 +525,10 @@ template void RegistrationParameterScalesEstimator::SampleVirtualDomainWithCorners() { - VirtualImageConstPointer image = this->m_Metric->GetVirtualImage(); + const VirtualImageConstPointer image = this->m_Metric->GetVirtualImage(); - VirtualRegionType region = this->m_Metric->GetVirtualRegion(); - VirtualIndexType firstCorner = region.GetIndex(); + const VirtualRegionType region = this->m_Metric->GetVirtualRegion(); + VirtualIndexType firstCorner = region.GetIndex(); VirtualSizeType size = region.GetSize(); const unsigned int cornerNumber = 1 << VirtualDimension; // 2^Dimension @@ -553,7 +553,7 @@ template void RegistrationParameterScalesEstimator::SampleVirtualDomainRandomly() { - VirtualImageConstPointer image = this->m_Metric->GetVirtualImage(); + const VirtualImageConstPointer image = this->m_Metric->GetVirtualImage(); if (m_NumberOfRandomSamples == 0) { @@ -564,7 +564,7 @@ RegistrationParameterScalesEstimator::SampleVirtualDomainRandomly() } else { - FloatType ratio = 1 + std::log((FloatType)total / SizeOfSmallDomain); + const FloatType ratio = 1 + std::log((FloatType)total / SizeOfSmallDomain); // ratio >= 1 since total/SizeOfSmallDomain > 1 this->m_NumberOfRandomSamples = static_cast(SizeOfSmallDomain * ratio); @@ -622,7 +622,7 @@ template void RegistrationParameterScalesEstimator::SampleVirtualDomainFully() { - VirtualRegionType region = this->m_Metric->GetVirtualRegion(); + const VirtualRegionType region = this->m_Metric->GetVirtualRegion(); this->SampleVirtualDomainWithRegion(region); } diff --git a/Modules/Numerics/Optimizersv4/include/itkRegistrationParameterScalesFromIndexShift.hxx b/Modules/Numerics/Optimizersv4/include/itkRegistrationParameterScalesFromIndexShift.hxx index 1713f586a7f..6fc6937c1fb 100644 --- a/Modules/Numerics/Optimizersv4/include/itkRegistrationParameterScalesFromIndexShift.hxx +++ b/Modules/Numerics/Optimizersv4/include/itkRegistrationParameterScalesFromIndexShift.hxx @@ -94,14 +94,14 @@ RegistrationParameterScalesFromIndexShift::TransformPointToContinuousIn if (this->GetTransformForward()) { - MovingPointType mappedPoint = this->m_Metric->GetMovingTransform()->TransformPoint(point); + const MovingPointType mappedPoint = this->m_Metric->GetMovingTransform()->TransformPoint(point); mappedIndex = this->m_Metric->GetMovingImage()->template TransformPhysicalPointToContinuousIndex( mappedPoint); } else { - FixedPointType mappedPoint = this->m_Metric->GetFixedTransform()->TransformPoint(point); + const FixedPointType mappedPoint = this->m_Metric->GetFixedTransform()->TransformPoint(point); mappedIndex = this->m_Metric->GetFixedImage()->template TransformPhysicalPointToContinuousIndex( mappedPoint); diff --git a/Modules/Numerics/Optimizersv4/include/itkRegistrationParameterScalesFromJacobian.hxx b/Modules/Numerics/Optimizersv4/include/itkRegistrationParameterScalesFromJacobian.hxx index 8197e3ba118..fd9164fdd3a 100644 --- a/Modules/Numerics/Optimizersv4/include/itkRegistrationParameterScalesFromJacobian.hxx +++ b/Modules/Numerics/Optimizersv4/include/itkRegistrationParameterScalesFromJacobian.hxx @@ -112,8 +112,8 @@ RegistrationParameterScalesFromJacobian::EstimateLocalStepScales(const // checking each sample point for (SizeValueType c = 0; c < numSamples; ++c) { - VirtualPointType & point = this->m_SamplePoints[c]; - IndexValueType localId = + const VirtualPointType & point = this->m_SamplePoints[c]; + const IndexValueType localId = this->m_Metric->ComputeParameterOffsetFromVirtualPoint(point, NumericTraits::OneValue()); localStepScales[localId] = sampleScales[c]; } @@ -160,7 +160,7 @@ RegistrationParameterScalesFromJacobian::ComputeSampleStepScales(const } else { - SizeValueType offset = this->m_Metric->ComputeParameterOffsetFromVirtualPoint(point, numPara); + const SizeValueType offset = this->m_Metric->ComputeParameterOffsetFromVirtualPoint(point, numPara); ParametersType localStep(numPara); for (SizeValueType p = 0; p < numPara; ++p) diff --git a/Modules/Numerics/Optimizersv4/include/itkRegistrationParameterScalesFromShiftBase.hxx b/Modules/Numerics/Optimizersv4/include/itkRegistrationParameterScalesFromShiftBase.hxx index e824da540e4..325f6458791 100644 --- a/Modules/Numerics/Optimizersv4/include/itkRegistrationParameterScalesFromShiftBase.hxx +++ b/Modules/Numerics/Optimizersv4/include/itkRegistrationParameterScalesFromShiftBase.hxx @@ -64,7 +64,7 @@ RegistrationParameterScalesFromShiftBase::EstimateScales(ScalesType & p } else { - VirtualIndexType centralIndex = this->GetVirtualDomainCentralIndex(); + const VirtualIndexType centralIndex = this->GetVirtualDomainCentralIndex(); offset = this->m_Metric->ComputeParameterOffsetFromVirtualIndex(centralIndex, numLocalPara); } } @@ -149,8 +149,8 @@ RegistrationParameterScalesFromShiftBase::EstimateStepScale(const Param } else { - FloatType factor = this->m_SmallParameterVariation / maxStep; - ParametersType smallStep(step.size()); + const FloatType factor = this->m_SmallParameterVariation / maxStep; + ParametersType smallStep(step.size()); // Use a small step to have a linear approximation. smallStep = step * factor; return this->ComputeMaximumVoxelShift(smallStep) / factor; @@ -188,8 +188,8 @@ RegistrationParameterScalesFromShiftBase::EstimateLocalStepScales(const const auto numSamples = static_cast(this->m_SamplePoints.size()); for (SizeValueType c = 0; c < numSamples; ++c) { - VirtualPointType & point = this->m_SamplePoints[c]; - IndexValueType localId = this->m_Metric->ComputeParameterOffsetFromVirtualPoint(point, numPara) / numPara; + const VirtualPointType & point = this->m_SamplePoints[c]; + const IndexValueType localId = this->m_Metric->ComputeParameterOffsetFromVirtualPoint(point, numPara) / numPara; localStepScales[localId] = sampleShifts[c]; } } diff --git a/Modules/Numerics/Optimizersv4/include/itkRegularStepGradientDescentOptimizerv4.hxx b/Modules/Numerics/Optimizersv4/include/itkRegularStepGradientDescentOptimizerv4.hxx index bc2a735464c..b1258100384 100644 --- a/Modules/Numerics/Optimizersv4/include/itkRegularStepGradientDescentOptimizerv4.hxx +++ b/Modules/Numerics/Optimizersv4/include/itkRegularStepGradientDescentOptimizerv4.hxx @@ -213,7 +213,7 @@ RegularStepGradientDescentOptimizerv4::ModifyGrad // Take the modulo of the index to handle gradients from transforms // with local support. The gradient array stores the gradient of local // parameters at each local index with linear packing. - IndexValueType index = j % scales.Size(); + const IndexValueType index = j % scales.Size(); this->m_Gradient[j] = this->m_Gradient[j] * factor[index]; this->m_PreviousGradient[j] = this->m_PreviousGradient[j] * factor[index]; } diff --git a/Modules/Numerics/Optimizersv4/include/itkWindowConvergenceMonitoringFunction.hxx b/Modules/Numerics/Optimizersv4/include/itkWindowConvergenceMonitoringFunction.hxx index 89da691fda5..4f1860866bd 100644 --- a/Modules/Numerics/Optimizersv4/include/itkWindowConvergenceMonitoringFunction.hxx +++ b/Modules/Numerics/Optimizersv4/include/itkWindowConvergenceMonitoringFunction.hxx @@ -119,7 +119,7 @@ WindowConvergenceMonitoringFunction::GetConvergenceValue() const -> Rea endPoint[0] = NumericTraits::OneValue(); typename BSplinerFunctionType::GradientType gradient = bsplinerFunction->EvaluateGradientAtParametricPoint(endPoint); - RealType convergenceValue = -gradient[0][0]; + const RealType convergenceValue = -gradient[0][0]; return convergenceValue; } diff --git a/Modules/Numerics/Optimizersv4/src/itkAmoebaOptimizerv4.cxx b/Modules/Numerics/Optimizersv4/src/itkAmoebaOptimizerv4.cxx index a95de2ba751..850bf8bd945 100644 --- a/Modules/Numerics/Optimizersv4/src/itkAmoebaOptimizerv4.cxx +++ b/Modules/Numerics/Optimizersv4/src/itkAmoebaOptimizerv4.cxx @@ -121,8 +121,8 @@ AmoebaOptimizerv4::StartOptimization(bool /* doOnlyInitialization */) // expected parameter vector matches the one we have etc...) this->ValidateSettings(); - ParametersType parameters = this->m_Metric->GetParameters(); - unsigned int n = parameters.GetSize(); + ParametersType parameters = this->m_Metric->GetParameters(); + const unsigned int n = parameters.GetSize(); InternalParametersType delta(m_InitialSimplexDelta); @@ -192,7 +192,7 @@ AmoebaOptimizerv4::StartOptimization(bool /* doOnlyInitialization */) parameters = bestPosition; delta = delta * (1.0 / pow(2.0, static_cast(i)) * (rand() > RAND_MAX / 2 ? 1 : -1)); m_VnlOptimizer->minimize(parameters, delta); - double currentValue = adaptor->f(parameters); + const double currentValue = adaptor->f(parameters); // be consistent with the underlying vnl amoeba implementation double maxAbs = 0.0; for (unsigned int j = 0; j < n; ++j) @@ -250,8 +250,8 @@ AmoebaOptimizerv4::ValidateSettings() { // if we got here it is safe to get the number of parameters the cost // function expects - ParametersType parameters = this->m_Metric->GetParameters(); - unsigned int n = parameters.GetSize(); + const ParametersType parameters = this->m_Metric->GetParameters(); + const unsigned int n = parameters.GetSize(); // the user gave us data to use for the initial simplex, check that it // matches the number of parameters (simplex dimension is n+1 - the initial diff --git a/Modules/Numerics/Optimizersv4/src/itkLBFGSBOptimizerv4.cxx b/Modules/Numerics/Optimizersv4/src/itkLBFGSBOptimizerv4.cxx index 53f100f8abe..ad2b3c34250 100644 --- a/Modules/Numerics/Optimizersv4/src/itkLBFGSBOptimizerv4.cxx +++ b/Modules/Numerics/Optimizersv4/src/itkLBFGSBOptimizerv4.cxx @@ -201,7 +201,7 @@ LBFGSBOptimizerv4::StartOptimization(bool /*doOnlyInitialization*/) // Check if all the bounds parameters are the same size as the initial // parameters. - unsigned int numberOfParameters = m_Metric->GetNumberOfParameters(); + const unsigned int numberOfParameters = m_Metric->GetNumberOfParameters(); if (this->GetInitialPosition().Size() < numberOfParameters) { diff --git a/Modules/Numerics/Optimizersv4/src/itkObjectToObjectOptimizerBase.cxx b/Modules/Numerics/Optimizersv4/src/itkObjectToObjectOptimizerBase.cxx index 2471dd87284..3aa82e1dd3e 100644 --- a/Modules/Numerics/Optimizersv4/src/itkObjectToObjectOptimizerBase.cxx +++ b/Modules/Numerics/Optimizersv4/src/itkObjectToObjectOptimizerBase.cxx @@ -132,8 +132,8 @@ ObjectToObjectOptimizerBaseTemplate::StartOptimiz /* Check if the scales are identity. Consider to be identity if * within a tolerance, to allow for automatically estimated scales * that may not be exactly 1.0 when in priciniple they should be. */ - SValueType difference = itk::Math::abs(NumericTraits::OneValue() - this->m_Scales[i]); - auto tolerance = static_cast(0.01); + const SValueType difference = itk::Math::abs(NumericTraits::OneValue() - this->m_Scales[i]); + auto tolerance = static_cast(0.01); if (difference > tolerance) { this->m_ScalesAreIdentity = false; @@ -163,8 +163,8 @@ ObjectToObjectOptimizerBaseTemplate::StartOptimiz this->m_WeightsAreIdentity = true; for (SizeType i = 0; i < this->m_Weights.Size(); ++i) { - SValueType difference = itk::Math::abs(NumericTraits::OneValue() - this->m_Weights[i]); - auto tolerance = static_cast(1e-4); + const SValueType difference = itk::Math::abs(NumericTraits::OneValue() - this->m_Weights[i]); + auto tolerance = static_cast(1e-4); if (difference > tolerance) { this->m_WeightsAreIdentity = false; diff --git a/Modules/Numerics/Optimizersv4/src/itkSingleValuedNonLinearVnlOptimizerv4.cxx b/Modules/Numerics/Optimizersv4/src/itkSingleValuedNonLinearVnlOptimizerv4.cxx index 831497b4a4c..8fc4ee95168 100644 --- a/Modules/Numerics/Optimizersv4/src/itkSingleValuedNonLinearVnlOptimizerv4.cxx +++ b/Modules/Numerics/Optimizersv4/src/itkSingleValuedNonLinearVnlOptimizerv4.cxx @@ -52,7 +52,7 @@ SingleValuedNonLinearVnlOptimizerv4::StartOptimization(bool doOnlyInitialization // where the per-iteration results of the vnl optimizer are accessible. if (!this->GetScalesAreIdentity()) { - ScalesType scales = this->GetScales(); + const ScalesType scales = this->GetScales(); this->GetNonConstCostFunctionAdaptor()->SetScales(scales); } } diff --git a/Modules/Numerics/Optimizersv4/test/itkAmoebaOptimizerv4Test.cxx b/Modules/Numerics/Optimizersv4/test/itkAmoebaOptimizerv4Test.cxx index 128dd43c089..88de71c220e 100644 --- a/Modules/Numerics/Optimizersv4/test/itkAmoebaOptimizerv4Test.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkAmoebaOptimizerv4Test.cxx @@ -72,17 +72,17 @@ class itkAmoebaOptimizerv4TestMetric1 : public itk::ObjectToObjectMetricBase MeasureType GetValue() const override { - double x = this->m_Parameters[0]; - double y = this->m_Parameters[1]; - double val = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; + const double x = this->m_Parameters[0]; + const double y = this->m_Parameters[1]; + const double val = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; return val; } void GetDerivative(DerivativeType & derivative) const override { - double x = this->m_Parameters[0]; - double y = this->m_Parameters[1]; + const double x = this->m_Parameters[0]; + const double y = this->m_Parameters[1]; derivative = DerivativeType(SpaceDimension); derivative[0] = -(3 * x + 2 * y - 2); @@ -184,8 +184,8 @@ class itkAmoebaOptimizerv4TestMetric2 : public itk::ObjectToObjectMetricBase double GetValue() const override { - double x = this->m_Parameters[0]; - double val; + const double x = this->m_Parameters[0]; + double val; if (x < 0) { val = x * x + 4 * x; @@ -315,8 +315,8 @@ AmoebaTest2(); int itkAmoebaOptimizerv4Test(int, char *[]) { - int result1 = AmoebaTest1(); - int result2 = AmoebaTest2(); + const int result1 = AmoebaTest1(); + const int result2 = AmoebaTest2(); std::cout << "All Tests Completed." << std::endl; @@ -345,11 +345,11 @@ AmoebaTest1() ITK_TEST_EXPECT_TRUE(itkOptimizer->CanUseScales()); - bool doEstimateScales = true; + const bool doEstimateScales = true; ITK_TEST_SET_GET_BOOLEAN(itkOptimizer, DoEstimateScales, doEstimateScales); // set optimizer parameters - itk::SizeValueType numberOfIterations = 10; + const itk::SizeValueType numberOfIterations = 10; itkOptimizer->SetNumberOfIterations(numberOfIterations); ITK_TEST_SET_GET_VALUE(numberOfIterations, itkOptimizer->GetNumberOfIterations()); @@ -367,10 +367,10 @@ AmoebaTest1() itkOptimizer->SetFunctionConvergenceTolerance(fTolerance); ITK_TEST_SET_GET_VALUE(fTolerance, itkOptimizer->GetFunctionConvergenceTolerance()); - OptimizerType::DerivativeType cachedDerivative{}; + const OptimizerType::DerivativeType cachedDerivative{}; ITK_TEST_EXPECT_EQUAL(cachedDerivative, itkOptimizer->GetCachedDerivative()); - OptimizerType::ParametersType cachedCurrentPos{}; + const OptimizerType::ParametersType cachedCurrentPos{}; ITK_TEST_EXPECT_EQUAL(cachedCurrentPos, itkOptimizer->GetCachedCurrentPosition()); auto metric = itkAmoebaOptimizerv4TestMetric1::New(); @@ -434,8 +434,8 @@ AmoebaTest1() OptimizerType::ParametersType finalPosition; finalPosition = itkOptimizer->GetCurrentPosition(); - double trueParameters[2] = { 2, -2 }; - bool pass = true; + const double trueParameters[2] = { 2, -2 }; + bool pass = true; std::cout << "Right answer = " << trueParameters[0] << " , " << trueParameters[1] << std::endl; std::cout << "Final position = " << finalPosition << std::endl; @@ -456,7 +456,7 @@ AmoebaTest1() // Get the final value of the optimizer std::cout << "Testing optimizers GetValue() : "; - OptimizerType::MeasureType finalValue = itkOptimizer->GetValue(); + const OptimizerType::MeasureType finalValue = itkOptimizer->GetValue(); if (itk::Math::abs(finalValue + 9.99998) > 0.01) { std::cerr << "failed\n"; @@ -481,13 +481,13 @@ AmoebaTest2() auto itkOptimizer = OptimizerType::New(); // set optimizer parameters - unsigned int maxIterations = 100; + const unsigned int maxIterations = 100; itkOptimizer->SetNumberOfIterations(maxIterations); - double xTolerance = 0.01; + const double xTolerance = 0.01; itkOptimizer->SetParametersConvergenceTolerance(xTolerance); - double fTolerance = 0.001; + const double fTolerance = 0.001; itkOptimizer->SetFunctionConvergenceTolerance(fTolerance); // the initial simplex is constructed as: @@ -532,7 +532,7 @@ AmoebaTest2() { // we should have converged to the local minimum, -2 OptimizerType::ParametersType finalParameters = itkOptimizer->GetCurrentPosition(); - double knownParameters = -2.0; + const double knownParameters = -2.0; std::cout << "Standard Amoeba:\n"; std::cout << "Known parameters = " << knownParameters << " "; std::cout << "Estimated parameters = " << finalParameters << std::endl; diff --git a/Modules/Numerics/Optimizersv4/test/itkAutoScaledGradientDescentRegistrationOnVectorTest.cxx b/Modules/Numerics/Optimizersv4/test/itkAutoScaledGradientDescentRegistrationOnVectorTest.cxx index a2f90717338..f2a39a14e4d 100644 --- a/Modules/Numerics/Optimizersv4/test/itkAutoScaledGradientDescentRegistrationOnVectorTest.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkAutoScaledGradientDescentRegistrationOnVectorTest.cxx @@ -136,15 +136,15 @@ itkAutoScaledGradientDescentRegistrationOnVectorTestTemplated(int number auto transformForward = true; ITK_TEST_SET_GET_BOOLEAN(shiftScalesEstimator, TransformForward, transformForward); - itk::IndexValueType centralRegionRadius = 5; + const itk::IndexValueType centralRegionRadius = 5; shiftScalesEstimator->SetCentralRegionRadius(centralRegionRadius); ITK_TEST_SET_GET_VALUE(centralRegionRadius, shiftScalesEstimator->GetCentralRegionRadius()); - typename ShiftScalesEstimatorType::VirtualPointSetType::ConstPointer virtualDomainPointSet{}; + const typename ShiftScalesEstimatorType::VirtualPointSetType::ConstPointer virtualDomainPointSet{}; shiftScalesEstimator->SetVirtualDomainPointSet(virtualDomainPointSet); ITK_TEST_SET_GET_VALUE(virtualDomainPointSet, shiftScalesEstimator->GetVirtualDomainPointSet()); - typename ShiftScalesEstimatorType::ParametersValueType smallParameterVariation = 0.01; + const typename ShiftScalesEstimatorType::ParametersValueType smallParameterVariation = 0.01; shiftScalesEstimator->SetSmallParameterVariation(smallParameterVariation); ITK_TEST_SET_GET_VALUE(smallParameterVariation, shiftScalesEstimator->GetSmallParameterVariation()); @@ -186,8 +186,8 @@ itkAutoScaledGradientDescentRegistrationOnVectorTestTemplated(int number // // results // - ParametersType finalParameters = movingTransform->GetParameters(); - ParametersType fixedParameters = movingTransform->GetFixedParameters(); + ParametersType finalParameters = movingTransform->GetParameters(); + const ParametersType fixedParameters = movingTransform->GetFixedParameters(); std::cout << "Estimated scales = " << optimizer->GetScales() << std::endl; std::cout << "finalParameters = " << finalParameters << std::endl; std::cout << "fixedParameters = " << fixedParameters << std::endl; @@ -254,12 +254,12 @@ itkAutoScaledGradientDescentRegistrationOnVectorTest(int argc, char ** const arg std::cout << std::endl << "Optimizing translation transform with shift scales" << std::endl; using TranslationTransformType = itk::TranslationTransform; - int ret1 = itkAutoScaledGradientDescentRegistrationOnVectorTestTemplated( + const int ret1 = itkAutoScaledGradientDescentRegistrationOnVectorTestTemplated( numberOfIterations, shiftOfStep, "shift"); std::cout << std::endl << "Optimizing translation transform with Jacobian scales" << std::endl; using TranslationTransformType = itk::TranslationTransform; - int ret2 = itkAutoScaledGradientDescentRegistrationOnVectorTestTemplated( + const int ret2 = itkAutoScaledGradientDescentRegistrationOnVectorTestTemplated( numberOfIterations, 0.0, "jacobian"); if (ret1 == EXIT_SUCCESS && ret2 == EXIT_SUCCESS) diff --git a/Modules/Numerics/Optimizersv4/test/itkAutoScaledGradientDescentRegistrationTest.cxx b/Modules/Numerics/Optimizersv4/test/itkAutoScaledGradientDescentRegistrationTest.cxx index 595b31865d0..8924584676a 100644 --- a/Modules/Numerics/Optimizersv4/test/itkAutoScaledGradientDescentRegistrationTest.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkAutoScaledGradientDescentRegistrationTest.cxx @@ -219,8 +219,8 @@ itkAutoScaledGradientDescentRegistrationTestTemplated(int numberOfIterat // // results // - ParametersType finalParameters = movingTransform->GetParameters(); - ParametersType fixedParameters = movingTransform->GetFixedParameters(); + ParametersType finalParameters = movingTransform->GetParameters(); + const ParametersType fixedParameters = movingTransform->GetFixedParameters(); std::cout << "Estimated scales = " << optimizer->GetScales() << std::endl; std::cout << "finalParameters = " << finalParameters << std::endl; std::cout << "fixedParameters = " << fixedParameters << std::endl; @@ -305,8 +305,8 @@ itkAutoScaledGradientDescentRegistrationTest(int argc, char ** const argv) std::cout << std::endl << "Optimizing translation transform with shift scales" << std::endl; using TranslationTransformType = itk::TranslationTransform; - bool usePhysicalSpaceForShift = false; - int ret1 = + const bool usePhysicalSpaceForShift = false; + const int ret1 = itkAutoScaledGradientDescentRegistrationTestTemplated(numberOfIterations, shiftOfStep, "shift", @@ -317,7 +317,7 @@ itkAutoScaledGradientDescentRegistrationTest(int argc, char ** const argv) std::cout << std::endl << "Optimizing translation transform with Jacobian scales" << std::endl; using TranslationTransformType = itk::TranslationTransform; - int ret2 = + const int ret2 = itkAutoScaledGradientDescentRegistrationTestTemplated(numberOfIterations, 0.0, "jacobian", diff --git a/Modules/Numerics/Optimizersv4/test/itkConjugateGradientLineSearchOptimizerv4Test.cxx b/Modules/Numerics/Optimizersv4/test/itkConjugateGradientLineSearchOptimizerv4Test.cxx index 3533c4d151c..8eb11a23607 100644 --- a/Modules/Numerics/Optimizersv4/test/itkConjugateGradientLineSearchOptimizerv4Test.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkConjugateGradientLineSearchOptimizerv4Test.cxx @@ -81,8 +81,8 @@ class ConjugateGradientLineSearchOptimizerv4TestMetric : public itk::ObjectToObj derivative.SetSize(2); } - double x = m_Parameters[0]; - double y = m_Parameters[1]; + const double x = m_Parameters[0]; + const double y = m_Parameters[1]; std::cout << "GetValueAndDerivative( "; std::cout << x << ' '; @@ -105,10 +105,10 @@ class ConjugateGradientLineSearchOptimizerv4TestMetric : public itk::ObjectToObj MeasureType GetValue() const override { - double x = m_Parameters[0]; - double y = m_Parameters[1]; + const double x = m_Parameters[0]; + const double y = m_Parameters[1]; - MeasureType value = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; + const MeasureType value = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; return value; } @@ -184,7 +184,7 @@ ConjugateGradientLineSearchOptimizerv4RunTest(itk::ConjugateGradientLineSearchOp // // check results to see if it is within range // - double trueParameters[2] = { 2, -2 }; + const double trueParameters[2] = { 2, -2 }; for (unsigned int j = 0; j < 2; ++j) { if (itk::Math::abs(finalPosition[j] - trueParameters[j]) > 0.01) @@ -213,7 +213,7 @@ itkConjugateGradientLineSearchOptimizerv4Test(int, char *[]) auto itkOptimizer = OptimizerType::New(); // Declaration of the Metric - ConjugateGradientLineSearchOptimizerv4TestMetric::Pointer metric = + const ConjugateGradientLineSearchOptimizerv4TestMetric::Pointer metric = ConjugateGradientLineSearchOptimizerv4TestMetric::New(); itkOptimizer->SetMetric(metric); diff --git a/Modules/Numerics/Optimizersv4/test/itkExhaustiveOptimizerv4Test.cxx b/Modules/Numerics/Optimizersv4/test/itkExhaustiveOptimizerv4Test.cxx index 56d83aed5e5..091dce3f4aa 100644 --- a/Modules/Numerics/Optimizersv4/test/itkExhaustiveOptimizerv4Test.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkExhaustiveOptimizerv4Test.cxx @@ -64,12 +64,12 @@ class ExhaustiveOptv4Metric : public itk::ObjectToObjectMetricBase MeasureType GetValue() const override { - double x = this->m_Parameters[0]; - double y = this->m_Parameters[1]; + const double x = this->m_Parameters[0]; + const double y = this->m_Parameters[1]; std::cout << "GetValue ( " << x << " , " << y << ") = "; - MeasureType val = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; + const MeasureType val = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; std::cout << val << std::endl; @@ -79,8 +79,8 @@ class ExhaustiveOptv4Metric : public itk::ObjectToObjectMetricBase void GetDerivative(DerivativeType & derivative) const override { - double x = this->m_Parameters[0]; - double y = this->m_Parameters[1]; + const double x = this->m_Parameters[0]; + const double y = this->m_Parameters[1]; std::cout << "GetDerivative ( " << x << " , " << y << ") = "; @@ -168,7 +168,7 @@ class IndexObserver : public itk::Command if (nullptr != optimizer) { OptimizerType::ParametersType currentIndex = optimizer->GetCurrentIndex(); - itk::SizeValueType currentIteration = optimizer->GetCurrentIteration(); + const itk::SizeValueType currentIteration = optimizer->GetCurrentIteration(); if (currentIndex.GetSize() == 2) { @@ -267,12 +267,12 @@ itkExhaustiveOptimizerv4Test(int, char *[]) } - bool minimumValuePass = itk::Math::abs(itkOptimizer->GetMinimumMetricValue() - -10) < 1E-3; + const bool minimumValuePass = itk::Math::abs(itkOptimizer->GetMinimumMetricValue() - -10) < 1E-3; std::cout << "MinimumMetricValue = " << itkOptimizer->GetMinimumMetricValue() << std::endl; std::cout << "Minimum Position = " << itkOptimizer->GetMinimumMetricValuePosition() << std::endl; - bool maximumValuePass = itk::Math::abs(itkOptimizer->GetMaximumMetricValue() - 926) < 1E-3; + const bool maximumValuePass = itk::Math::abs(itkOptimizer->GetMaximumMetricValue() - 926) < 1E-3; std::cout << "MaximumMetricValue = " << itkOptimizer->GetMaximumMetricValue() << std::endl; std::cout << "Maximum Position = " << itkOptimizer->GetMaximumMetricValuePosition() << std::endl; @@ -286,7 +286,7 @@ itkExhaustiveOptimizerv4Test(int, char *[]) bool visitedIndicesPass = true; std::vector visitedIndices = idxObserver->m_VisitedIndices; - size_t requiredNumberOfSteps = (2 * steps[0] + 1) * (2 * steps[1] + 1); + const size_t requiredNumberOfSteps = (2 * steps[0] + 1) * (2 * steps[1] + 1); if (visitedIndices.size() != requiredNumberOfSteps) { visitedIndicesPass = false; @@ -307,8 +307,8 @@ itkExhaustiveOptimizerv4Test(int, char *[]) // // check results to see if it is within range // - bool trueParamsPass = true; - double trueParameters[2] = { 2, -2 }; + bool trueParamsPass = true; + const double trueParameters[2] = { 2, -2 }; for (unsigned int j = 0; j < 2; ++j) { if (itk::Math::abs(finalPosition[j] - trueParameters[j]) > 0.01) diff --git a/Modules/Numerics/Optimizersv4/test/itkGradientDescentLineSearchOptimizerv4Test.cxx b/Modules/Numerics/Optimizersv4/test/itkGradientDescentLineSearchOptimizerv4Test.cxx index 229a21e6c26..64e6c80fc92 100644 --- a/Modules/Numerics/Optimizersv4/test/itkGradientDescentLineSearchOptimizerv4Test.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkGradientDescentLineSearchOptimizerv4Test.cxx @@ -83,8 +83,8 @@ class GradientDescentLineSearchOptimizerv4TestMetric : public itk::ObjectToObjec derivative.SetSize(2); } - double x = m_Parameters[0]; - double y = m_Parameters[1]; + const double x = m_Parameters[0]; + const double y = m_Parameters[1]; std::cout << "GetValueAndDerivative( "; std::cout << x << ' '; @@ -107,10 +107,10 @@ class GradientDescentLineSearchOptimizerv4TestMetric : public itk::ObjectToObjec MeasureType GetValue() const override { - double x = m_Parameters[0]; - double y = m_Parameters[1]; + const double x = m_Parameters[0]; + const double y = m_Parameters[1]; - MeasureType value = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; + const MeasureType value = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; return value; } @@ -219,7 +219,7 @@ itkGradientDescentLineSearchOptimizerv4Test(int, char *[]) // Declaration of the Metric - GradientDescentLineSearchOptimizerv4TestMetric::Pointer metric = + const GradientDescentLineSearchOptimizerv4TestMetric::Pointer metric = GradientDescentLineSearchOptimizerv4TestMetric::New(); itkOptimizer->SetMetric(metric); @@ -253,19 +253,19 @@ itkGradientDescentLineSearchOptimizerv4Test(int, char *[]) scales.Fill(0.5); itkOptimizer->SetScales(scales); - typename OptimizerType::InternalComputationValueType epsilon = 1.e-4; + const typename OptimizerType::InternalComputationValueType epsilon = 1.e-4; itkOptimizer->SetEpsilon(epsilon); ITK_TEST_SET_GET_VALUE(epsilon, itkOptimizer->GetEpsilon()); - typename OptimizerType::InternalComputationValueType lowerLimit = -10; + const typename OptimizerType::InternalComputationValueType lowerLimit = -10; itkOptimizer->SetLowerLimit(lowerLimit); ITK_TEST_SET_GET_VALUE(lowerLimit, itkOptimizer->GetLowerLimit()); - typename OptimizerType::InternalComputationValueType upperLimit = 10; + const typename OptimizerType::InternalComputationValueType upperLimit = 10; itkOptimizer->SetUpperLimit(upperLimit); ITK_TEST_SET_GET_VALUE(upperLimit, itkOptimizer->GetUpperLimit()); - unsigned int maximumLineSearchIterations = 100; + const unsigned int maximumLineSearchIterations = 100; itkOptimizer->SetMaximumLineSearchIterations(maximumLineSearchIterations); ITK_TEST_SET_GET_VALUE(maximumLineSearchIterations, itkOptimizer->GetMaximumLineSearchIterations()); diff --git a/Modules/Numerics/Optimizersv4/test/itkGradientDescentOptimizerBasev4Test.cxx b/Modules/Numerics/Optimizersv4/test/itkGradientDescentOptimizerBasev4Test.cxx index 23fe7ecdae2..8c99aa4affa 100644 --- a/Modules/Numerics/Optimizersv4/test/itkGradientDescentOptimizerBasev4Test.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkGradientDescentOptimizerBasev4Test.cxx @@ -173,7 +173,7 @@ itkGradientDescentOptimizerBasev4Test(int, char *[]) auto metric = MetricType::New(); auto optimizer = GradientDescentOptimizerBasev4TestOptimizer::New(); - bool doEstimateScales = true; + const bool doEstimateScales = true; ITK_TEST_SET_GET_BOOLEAN(optimizer, DoEstimateScales, doEstimateScales); optimizer->SetMetric(metric); diff --git a/Modules/Numerics/Optimizersv4/test/itkGradientDescentOptimizerv4Test.cxx b/Modules/Numerics/Optimizersv4/test/itkGradientDescentOptimizerv4Test.cxx index a37d100c2af..0b4a82d0c48 100644 --- a/Modules/Numerics/Optimizersv4/test/itkGradientDescentOptimizerv4Test.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkGradientDescentOptimizerv4Test.cxx @@ -82,8 +82,8 @@ class GradientDescentOptimizerv4TestMetric : public itk::ObjectToObjectMetricBas derivative.SetSize(2); } - double x = m_Parameters[0]; - double y = m_Parameters[1]; + const double x = m_Parameters[0]; + const double y = m_Parameters[1]; std::cout << "GetValueAndDerivative( "; std::cout << x << ' '; @@ -180,7 +180,7 @@ GradientDescentOptimizerv4RunTest(itk::GradientDescentOptimizerv4::Pointer & std::cout << "ConvergenceValue: " << itkOptimizer->GetConvergenceValue() << std::endl; // check results to see if it is within range - ParametersType::ValueType eps = 0.03; + const ParametersType::ValueType eps = 0.03; for (unsigned int j = 0; j < 2; ++j) { if (itk::Math::abs(finalPosition[j] - trueParameters[j]) > eps) @@ -229,25 +229,25 @@ itkGradientDescentOptimizerv4Test(int, char *[]) initialPosition[1] = -100; metric->SetParameters(initialPosition); - double learningRate = 0.1; + const double learningRate = 0.1; itkOptimizer->SetLearningRate(learningRate); ITK_TEST_SET_GET_VALUE(learningRate, itkOptimizer->GetLearningRate()); - itk::SizeValueType numberOfIterations = 50; + const itk::SizeValueType numberOfIterations = 50; itkOptimizer->SetNumberOfIterations(numberOfIterations); ITK_TEST_SET_GET_VALUE(numberOfIterations, itkOptimizer->GetNumberOfIterations()); - double maximumStepSizeInPhysicalUnits = 0.0; + const double maximumStepSizeInPhysicalUnits = 0.0; itkOptimizer->SetMaximumStepSizeInPhysicalUnits(maximumStepSizeInPhysicalUnits); ITK_TEST_SET_GET_VALUE(maximumStepSizeInPhysicalUnits, itkOptimizer->GetMaximumStepSizeInPhysicalUnits()); - bool doEstimateLearningRateAtEachIteration = false; + const bool doEstimateLearningRateAtEachIteration = false; ITK_TEST_SET_GET_BOOLEAN(itkOptimizer, DoEstimateLearningRateAtEachIteration, doEstimateLearningRateAtEachIteration); - bool doEstimateLearningRateOnce = true; + const bool doEstimateLearningRateOnce = true; ITK_TEST_SET_GET_BOOLEAN(itkOptimizer, DoEstimateLearningRateOnce, doEstimateLearningRateOnce); - bool returnBestParametersAndValue = false; + const bool returnBestParametersAndValue = false; ITK_TEST_SET_GET_BOOLEAN(itkOptimizer, ReturnBestParametersAndValue, returnBestParametersAndValue); // Truth diff --git a/Modules/Numerics/Optimizersv4/test/itkGradientDescentOptimizerv4Test2.cxx b/Modules/Numerics/Optimizersv4/test/itkGradientDescentOptimizerv4Test2.cxx index c842fa851ec..26dc9155319 100644 --- a/Modules/Numerics/Optimizersv4/test/itkGradientDescentOptimizerv4Test2.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkGradientDescentOptimizerv4Test2.cxx @@ -171,14 +171,14 @@ itkGradientDescentOptimizerv4Test2(int, char *[]) } itkOptimizer->SetScales(scales); - ParametersType truth(metric->GetNumberOfParameters()); - NumberOfParametersType numLocal = metric->GetNumberOfLocalParameters(); - NumberOfParametersType numLoops = metric->GetNumberOfParameters() / numLocal; + ParametersType truth(metric->GetNumberOfParameters()); + const NumberOfParametersType numLocal = metric->GetNumberOfLocalParameters(); + const NumberOfParametersType numLoops = metric->GetNumberOfParameters() / numLocal; for (NumberOfParametersType i = 0; i < numLoops; ++i) { for (NumberOfParametersType j = 0; j < numLocal; ++j) { - NumberOfParametersType ind = i * numLocal + j; + const NumberOfParametersType ind = i * numLocal + j; truth[ind] = initialPosition[ind] + (ind) / scales[j]; } } diff --git a/Modules/Numerics/Optimizersv4/test/itkLBFGS2Optimizerv4Test.cxx b/Modules/Numerics/Optimizersv4/test/itkLBFGS2Optimizerv4Test.cxx index 2f11e9f57b8..669fda5f416 100644 --- a/Modules/Numerics/Optimizersv4/test/itkLBFGS2Optimizerv4Test.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkLBFGS2Optimizerv4Test.cxx @@ -66,12 +66,12 @@ class itkLBFGS2Optimizerv4TestMetric : public itk::ObjectToObjectMetricBase MeasureType GetValue() const override { - double x = this->m_Parameters[0]; - double y = this->m_Parameters[1]; + const double x = this->m_Parameters[0]; + const double y = this->m_Parameters[1]; std::cout << "GetValue ( " << x << " , " << y << ") = "; - double val = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; + const double val = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; std::cout << val << std::endl; @@ -81,8 +81,8 @@ class itkLBFGS2Optimizerv4TestMetric : public itk::ObjectToObjectMetricBase void GetDerivative(DerivativeType & derivative) const override { - double x = this->m_Parameters[0]; - double y = this->m_Parameters[1]; + const double x = this->m_Parameters[0]; + const double y = this->m_Parameters[1]; std::cout << "GetDerivative ( " << x << " , " << y << ") = "; @@ -173,7 +173,7 @@ itkLBFGS2Optimizerv4Test(int, char *[]) itkOptimizer->SetHessianApproximationAccuracy(hessianApproximationAccuracy); ITK_TEST_SET_GET_VALUE(hessianApproximationAccuracy, itkOptimizer->GetHessianApproximationAccuracy()); - typename OptimizerType::PrecisionType solutionAccuracy = 1e-5; + const typename OptimizerType::PrecisionType solutionAccuracy = 1e-5; itkOptimizer->SetSolutionAccuracy(solutionAccuracy); ITK_TEST_SET_GET_VALUE(solutionAccuracy, itkOptimizer->GetSolutionAccuracy()); @@ -181,7 +181,7 @@ itkLBFGS2Optimizerv4Test(int, char *[]) itkOptimizer->SetDeltaConvergenceDistance(deltaConvergenceDistance); ITK_TEST_SET_GET_VALUE(deltaConvergenceDistance, itkOptimizer->GetDeltaConvergenceDistance()); - typename OptimizerType::PrecisionType deltaConvergenceTolerance = 0; + const typename OptimizerType::PrecisionType deltaConvergenceTolerance = 0; itkOptimizer->SetDeltaConvergenceTolerance(deltaConvergenceTolerance); ITK_TEST_SET_GET_VALUE(deltaConvergenceTolerance, itkOptimizer->GetDeltaConvergenceTolerance()); @@ -195,7 +195,7 @@ itkLBFGS2Optimizerv4Test(int, char *[]) itkOptimizer->SetNumberOfIterations(maximumIterations); ITK_TEST_SET_GET_VALUE(numberOfIterations, itkOptimizer->GetNumberOfIterations()); - typename OptimizerType::LineSearchMethodEnum lineSearchMethod = + const typename OptimizerType::LineSearchMethodEnum lineSearchMethod = OptimizerType::LineSearchMethodEnum::LINESEARCH_DEFAULT; itkOptimizer->SetLineSearch(lineSearchMethod); ITK_TEST_SET_GET_VALUE(lineSearchMethod, itkOptimizer->GetLineSearch()); @@ -204,29 +204,29 @@ itkLBFGS2Optimizerv4Test(int, char *[]) itkOptimizer->SetMaximumLineSearchEvaluations(maximumLineSearchEvaluations); ITK_TEST_SET_GET_VALUE(maximumLineSearchEvaluations, itkOptimizer->GetMaximumLineSearchEvaluations()); - typename OptimizerType::PrecisionType minimumLineSearchStep = 1e-20; + const typename OptimizerType::PrecisionType minimumLineSearchStep = 1e-20; itkOptimizer->SetMinimumLineSearchStep(minimumLineSearchStep); ITK_TEST_SET_GET_VALUE(minimumLineSearchStep, itkOptimizer->GetMinimumLineSearchStep()); - typename OptimizerType::PrecisionType maximumLineSearchStep = 1e+20; + const typename OptimizerType::PrecisionType maximumLineSearchStep = 1e+20; itkOptimizer->SetMaximumLineSearchStep(maximumLineSearchStep); ITK_TEST_SET_GET_VALUE(maximumLineSearchStep, itkOptimizer->GetMaximumLineSearchStep()); - typename OptimizerType::PrecisionType lineSearchAccuracy = 1e-4; + const typename OptimizerType::PrecisionType lineSearchAccuracy = 1e-4; itkOptimizer->SetLineSearchAccuracy(lineSearchAccuracy); ITK_TEST_SET_GET_VALUE(lineSearchAccuracy, itkOptimizer->GetLineSearchAccuracy()); - typename OptimizerType::PrecisionType wolfeCoefficient = 0; + const typename OptimizerType::PrecisionType wolfeCoefficient = 0; itkOptimizer->SetWolfeCoefficient(wolfeCoefficient); ITK_TEST_SET_GET_VALUE(wolfeCoefficient, itkOptimizer->GetWolfeCoefficient()); - typename OptimizerType::PrecisionType lineSearchGradientAccuracy = 0.9; + const typename OptimizerType::PrecisionType lineSearchGradientAccuracy = 0.9; itkOptimizer->SetLineSearchGradientAccuracy(lineSearchGradientAccuracy); ITK_TEST_SET_GET_VALUE(lineSearchGradientAccuracy, itkOptimizer->GetLineSearchGradientAccuracy()); // itkOptimizer->SetMachinePrecisionTolerance(): - typename OptimizerType::PrecisionType orthantwiseCoefficient = 0; + const typename OptimizerType::PrecisionType orthantwiseCoefficient = 0; itkOptimizer->SetOrthantwiseCoefficient(orthantwiseCoefficient); ITK_TEST_SET_GET_VALUE(orthantwiseCoefficient, itkOptimizer->GetOrthantwiseCoefficient()); @@ -292,8 +292,8 @@ itkLBFGS2Optimizerv4Test(int, char *[]) // // check results to see if it is within range // - bool pass = true; - double trueParameters[2] = { 2, -2 }; + bool pass = true; + const double trueParameters[2] = { 2, -2 }; for (unsigned int j = 0; j < 2; ++j) { if (itk::Math::FloatAlmostEqual(finalPosition[j], trueParameters[j])) @@ -310,7 +310,7 @@ itkLBFGS2Optimizerv4Test(int, char *[]) // Get the final value of the optimizer std::cout << "Testing GetValue() : "; - OptimizerType::MeasureType finalValue = itkOptimizer->GetValue(); + const OptimizerType::MeasureType finalValue = itkOptimizer->GetValue(); if (itk::Math::abs(finalValue + 10.0) > 0.01) { std::cout << "[FAILURE]" << std::endl; diff --git a/Modules/Numerics/Optimizersv4/test/itkLBFGSBOptimizerv4Test.cxx b/Modules/Numerics/Optimizersv4/test/itkLBFGSBOptimizerv4Test.cxx index 6023a4bca4e..b3b489b42a2 100644 --- a/Modules/Numerics/Optimizersv4/test/itkLBFGSBOptimizerv4Test.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkLBFGSBOptimizerv4Test.cxx @@ -119,10 +119,10 @@ class LBFGSBOptimizerv4TestMetric : public itk::ObjectToObjectMetricBase GetValue() const override { - double x = m_Parameters[0]; - double y = m_Parameters[1]; + const double x = m_Parameters[0]; + const double y = m_Parameters[1]; - double val = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; + const double val = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; std::cout << "GetValue ( " << x << " , " << y << ") = " << val << std::endl; @@ -132,8 +132,8 @@ class LBFGSBOptimizerv4TestMetric : public itk::ObjectToObjectMetricBase void GetDerivative(DerivativeType & derivative) const override { - double x = m_Parameters[0]; - double y = m_Parameters[1]; + const double x = m_Parameters[0]; + const double y = m_Parameters[1]; derivative = DerivativeType(SpaceDimension); derivative[0] = -(3 * x + 2 * y - 2); @@ -243,7 +243,7 @@ itkLBFGSBOptimizerv4Test(int, char *[]) itkOptimizer->SetMetric(metric); - bool trace = false; + const bool trace = false; ITK_TEST_SET_GET_BOOLEAN(itkOptimizer, Trace, trace); const double F_Convergence_Factor = 1e+7; // Function value tolerance @@ -259,11 +259,11 @@ itkLBFGSBOptimizerv4Test(int, char *[]) itkOptimizer->SetNumberOfIterations(Max_Iterations); ITK_TEST_SET_GET_VALUE(Max_Iterations, itkOptimizer->GetNumberOfIterations()); - unsigned int maximumNumberOfEvaluations = 100; + const unsigned int maximumNumberOfEvaluations = 100; itkOptimizer->SetMaximumNumberOfFunctionEvaluations(maximumNumberOfEvaluations); ITK_TEST_SET_GET_VALUE(maximumNumberOfEvaluations, itkOptimizer->GetMaximumNumberOfFunctionEvaluations()); - unsigned int maximumNumberOfCorrections = 5; + const unsigned int maximumNumberOfCorrections = 5; itkOptimizer->SetMaximumNumberOfCorrections(maximumNumberOfCorrections); ITK_TEST_SET_GET_VALUE(maximumNumberOfCorrections, itkOptimizer->GetMaximumNumberOfCorrections()); diff --git a/Modules/Numerics/Optimizersv4/test/itkLBFGSOptimizerv4Test.cxx b/Modules/Numerics/Optimizersv4/test/itkLBFGSOptimizerv4Test.cxx index afb07286232..379b5a21b45 100644 --- a/Modules/Numerics/Optimizersv4/test/itkLBFGSOptimizerv4Test.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkLBFGSOptimizerv4Test.cxx @@ -66,12 +66,12 @@ class itkLBFGSOptimizerv4TestMetric : public itk::ObjectToObjectMetricBase MeasureType GetValue() const override { - double x = this->m_Parameters[0]; - double y = this->m_Parameters[1]; + const double x = this->m_Parameters[0]; + const double y = this->m_Parameters[1]; std::cout << "GetValue ( " << x << " , " << y << ") = "; - double val = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; + const double val = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; std::cout << val << std::endl; @@ -81,8 +81,8 @@ class itkLBFGSOptimizerv4TestMetric : public itk::ObjectToObjectMetricBase void GetDerivative(DerivativeType & derivative) const override { - double x = this->m_Parameters[0]; - double y = this->m_Parameters[1]; + const double x = this->m_Parameters[0]; + const double y = this->m_Parameters[1]; std::cout << "GetDerivative ( " << x << " , " << y << ") = "; @@ -170,7 +170,7 @@ itkLBFGSOptimizerv4Test(int, char *[]) auto metric = itkLBFGSOptimizerv4TestMetric::New(); // Set some optimizer parameters - bool trace = false; + const bool trace = false; itkOptimizer->SetTrace(trace); ITK_TEST_SET_GET_VALUE(trace, itkOptimizer->GetTrace()); @@ -190,10 +190,10 @@ itkLBFGSOptimizerv4Test(int, char *[]) itkOptimizer->SetDefaultStepLength(defaultStepLength); ITK_TEST_SET_GET_VALUE(defaultStepLength, itkOptimizer->GetDefaultStepLength()); - OptimizerType::DerivativeType cachedDerivative{}; + const OptimizerType::DerivativeType cachedDerivative{}; ITK_TEST_EXPECT_EQUAL(cachedDerivative, itkOptimizer->GetCachedDerivative()); - OptimizerType::ParametersType cachedCurrentPos{}; + const OptimizerType::ParametersType cachedCurrentPos{}; ITK_TEST_EXPECT_EQUAL(cachedCurrentPos, itkOptimizer->GetCachedCurrentPosition()); std::cout << "GetValue() before optimizer starts: " << itkOptimizer->GetValue() << std::endl; @@ -266,8 +266,8 @@ itkLBFGSOptimizerv4Test(int, char *[]) // // check results to see if it is within range // - bool pass = true; - double trueParameters[2] = { 2, -2 }; + bool pass = true; + const double trueParameters[2] = { 2, -2 }; for (unsigned int j = 0; j < 2; ++j) { if (itk::Math::FloatAlmostEqual(finalPosition[j], trueParameters[j])) @@ -284,7 +284,7 @@ itkLBFGSOptimizerv4Test(int, char *[]) // Get the final value of the optimizer std::cout << "Testing GetValue() : "; - OptimizerType::MeasureType finalValue = itkOptimizer->GetValue(); + const OptimizerType::MeasureType finalValue = itkOptimizer->GetValue(); if (itk::Math::abs(finalValue + 10.0) > 0.01) { std::cout << "[FAILURE]" << std::endl; diff --git a/Modules/Numerics/Optimizersv4/test/itkMultiGradientOptimizerv4Test.cxx b/Modules/Numerics/Optimizersv4/test/itkMultiGradientOptimizerv4Test.cxx index bb68bf63a70..8b43fea0247 100644 --- a/Modules/Numerics/Optimizersv4/test/itkMultiGradientOptimizerv4Test.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkMultiGradientOptimizerv4Test.cxx @@ -83,8 +83,8 @@ class MultiGradientOptimizerv4TestMetric : public itk::ObjectToObjectMetricBase derivative.SetSize(2); } - double x = (*m_Parameters)[0]; - double y = (*m_Parameters)[1]; + const double x = (*m_Parameters)[0]; + const double y = (*m_Parameters)[1]; std::cout << "GetValueAndDerivative( "; std::cout << x << ' '; @@ -107,9 +107,9 @@ class MultiGradientOptimizerv4TestMetric : public itk::ObjectToObjectMetricBase MeasureType GetValue() const override { - double x = (*m_Parameters)[0]; - double y = (*m_Parameters)[1]; - double metric = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; + const double x = (*m_Parameters)[0]; + const double y = (*m_Parameters)[1]; + const double metric = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; std::cout << (*m_Parameters) << " metric " << metric << std::endl; return metric; } @@ -198,8 +198,8 @@ class MultiGradientOptimizerv4TestMetric2 : public itk::ObjectToObjectMetricBase derivative.SetSize(2); } - double x = (*m_Parameters)[0]; - double y = (*m_Parameters)[1]; + const double x = (*m_Parameters)[0]; + const double y = (*m_Parameters)[1]; std::cout << "GetValueAndDerivative( "; std::cout << x << ' '; @@ -222,9 +222,9 @@ class MultiGradientOptimizerv4TestMetric2 : public itk::ObjectToObjectMetricBase MeasureType GetValue() const override { - double x = (*m_Parameters)[0]; - double y = (*m_Parameters)[1]; - double metric = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - x + 4 * y; + const double x = (*m_Parameters)[0]; + const double y = (*m_Parameters)[1]; + const double metric = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - x + 4 * y; std::cout << (*m_Parameters) << " metric " << metric << std::endl; return metric; } @@ -349,7 +349,7 @@ itkMultiGradientOptimizerv4Test(int, char *[]) OptimizerType::OptimizersListType optimizersList = itkOptimizer->GetOptimizersList(); /** Declare the first optimizer for metric 1 */ - OptimizerType::LocalOptimizerPointer locoptimizer = OptimizerType::LocalOptimizerType::New(); + const OptimizerType::LocalOptimizerPointer locoptimizer = OptimizerType::LocalOptimizerType::New(); locoptimizer->SetLearningRate(1.e-1); locoptimizer->SetNumberOfIterations(25); locoptimizer->SetMetric(metric); @@ -357,7 +357,7 @@ itkMultiGradientOptimizerv4Test(int, char *[]) optimizersList.push_back(locoptimizer); /** Declare the 2nd optimizer for metric 2 */ - OptimizerType::LocalOptimizerPointer locoptimizer2 = OptimizerType::LocalOptimizerType::New(); + const OptimizerType::LocalOptimizerPointer locoptimizer2 = OptimizerType::LocalOptimizerType::New(); locoptimizer2->SetLearningRate(1.e-1); locoptimizer2->SetNumberOfIterations(25); locoptimizer2->SetMetric(metric2); diff --git a/Modules/Numerics/Optimizersv4/test/itkMultiStartOptimizerv4Test.cxx b/Modules/Numerics/Optimizersv4/test/itkMultiStartOptimizerv4Test.cxx index 92c0441438b..8857e7d24e5 100644 --- a/Modules/Numerics/Optimizersv4/test/itkMultiStartOptimizerv4Test.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkMultiStartOptimizerv4Test.cxx @@ -79,8 +79,8 @@ class MultiStartOptimizerv4TestMetric : public itk::ObjectToObjectMetricBase derivative.SetSize(2); } - double x = m_Parameters[0]; - double y = m_Parameters[1]; + const double x = m_Parameters[0]; + const double y = m_Parameters[1]; std::cout << "GetValueAndDerivative( "; std::cout << x << ' '; @@ -103,9 +103,9 @@ class MultiStartOptimizerv4TestMetric : public itk::ObjectToObjectMetricBase MeasureType GetValue() const override { - double x = m_Parameters[0]; - double y = m_Parameters[1]; - double metric = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; + const double x = m_Parameters[0]; + const double y = m_Parameters[1]; + const double metric = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; std::cout << m_Parameters << " metric " << metric << std::endl; return metric; } @@ -295,7 +295,7 @@ itkMultiStartOptimizerv4Test(int, char *[]) } metric->SetParameters(parametersList[0]); itkOptimizer->SetParametersList(parametersList); - OptimizerType::LocalOptimizerPointer optimizer = OptimizerType::LocalOptimizerType::New(); + const OptimizerType::LocalOptimizerPointer optimizer = OptimizerType::LocalOptimizerType::New(); optimizer->SetLearningRate(1.e-1); optimizer->SetNumberOfIterations(25); itkOptimizer->SetLocalOptimizer(optimizer); diff --git a/Modules/Numerics/Optimizersv4/test/itkObjectToObjectOptimizerBaseTest.cxx b/Modules/Numerics/Optimizersv4/test/itkObjectToObjectOptimizerBaseTest.cxx index 62cf977eb31..c3ac21b8099 100644 --- a/Modules/Numerics/Optimizersv4/test/itkObjectToObjectOptimizerBaseTest.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkObjectToObjectOptimizerBaseTest.cxx @@ -171,7 +171,8 @@ itkObjectToObjectOptimizerBaseTest(int, char *[]) std::cout << "value: " << optimizer->GetCurrentMetricValue() << std::endl; /* Test set/get of scales */ - ObjectToObjectOptimizerBaseTestOptimizer::NumberOfParametersType scalesSize = metric->GetNumberOfLocalParameters(); + const ObjectToObjectOptimizerBaseTestOptimizer::NumberOfParametersType scalesSize = + metric->GetNumberOfLocalParameters(); using ScalesType = ObjectToObjectOptimizerBaseTestOptimizer::ScalesType; ScalesType scales(scalesSize); scales.Fill(3.19); @@ -206,7 +207,8 @@ itkObjectToObjectOptimizerBaseTest(int, char *[]) } /* Test that weights are init'ed by default to identity */ - ObjectToObjectOptimizerBaseTestOptimizer::NumberOfParametersType weightsSize = metric->GetNumberOfLocalParameters(); + const ObjectToObjectOptimizerBaseTestOptimizer::NumberOfParametersType weightsSize = + metric->GetNumberOfLocalParameters(); ITK_TRY_EXPECT_NO_EXCEPTION(optimizer->StartOptimization()); ScalesType weightsReturn = optimizer->GetWeights(); if (weightsReturn.Size() != 0 || !optimizer->GetWeightsAreIdentity()) diff --git a/Modules/Numerics/Optimizersv4/test/itkOnePlusOneEvolutionaryOptimizerv4Test.cxx b/Modules/Numerics/Optimizersv4/test/itkOnePlusOneEvolutionaryOptimizerv4Test.cxx index 87c5ab169cf..0e942894652 100644 --- a/Modules/Numerics/Optimizersv4/test/itkOnePlusOneEvolutionaryOptimizerv4Test.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkOnePlusOneEvolutionaryOptimizerv4Test.cxx @@ -66,14 +66,14 @@ class OnePlusOneMetric : public itk::ObjectToObjectMetricBase MeasureType GetValue() const override { - double x = m_Parameters[0]; - double y = m_Parameters[1]; + const double x = m_Parameters[0]; + const double y = m_Parameters[1]; std::cout << "GetValue( "; std::cout << x << ' '; std::cout << y << ") = "; - MeasureType measure = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; + const MeasureType measure = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; std::cout << measure << std::endl; @@ -174,7 +174,7 @@ class OnePlusOneCommandIterationUpdate : public itk::Command { return; } - double currentValue = optimizer->GetValue(); + const double currentValue = optimizer->GetValue(); // Only print out when the Metric value changes if (itk::Math::abs(m_LastMetricValue - currentValue) > 1e-7) { @@ -202,11 +202,11 @@ itkOnePlusOneEvolutionaryOptimizerv4Test(int, char *[]) itkOptimizer, OnePlusOneEvolutionaryOptimizerv4, ObjectToObjectOptimizerBaseTemplate); - itk::OnePlusOneCommandIterationUpdate::Pointer observer = itk::OnePlusOneCommandIterationUpdate::New(); + const itk::OnePlusOneCommandIterationUpdate::Pointer observer = itk::OnePlusOneCommandIterationUpdate::New(); itkOptimizer->AddObserver(itk::IterationEvent(), observer); // Declaration of the CostFunction - itk::OnePlusOneMetric::Pointer metric = itk::OnePlusOneMetric::New(); + const itk::OnePlusOneMetric::Pointer metric = itk::OnePlusOneMetric::New(); itkOptimizer->SetMetric(metric); using ParametersType = itk::OnePlusOneMetric::ParametersType; @@ -221,27 +221,27 @@ itkOnePlusOneEvolutionaryOptimizerv4Test(int, char *[]) itkOptimizer->Initialize(10); - double growthFactor = 1.05; + const double growthFactor = 1.05; itkOptimizer->SetGrowthFactor(growthFactor); ITK_TEST_SET_GET_VALUE(growthFactor, itkOptimizer->GetGrowthFactor()); - double shrinkFactor = std::pow(growthFactor, -0.25); + const double shrinkFactor = std::pow(growthFactor, -0.25); itkOptimizer->SetShrinkFactor(shrinkFactor); ITK_TEST_SET_GET_VALUE(shrinkFactor, itkOptimizer->GetShrinkFactor()); - double initialRadius = 1.01; + const double initialRadius = 1.01; itkOptimizer->SetInitialRadius(initialRadius); ITK_TEST_SET_GET_VALUE(initialRadius, itkOptimizer->GetInitialRadius()); - double epsilon = 0.1; + const double epsilon = 0.1; itkOptimizer->SetEpsilon(epsilon); ITK_TEST_SET_GET_VALUE(epsilon, itkOptimizer->GetEpsilon()); - unsigned int maximumIteration = 8000; + const unsigned int maximumIteration = 8000; itkOptimizer->SetMaximumIteration(maximumIteration); ITK_TEST_SET_GET_VALUE(maximumIteration, itkOptimizer->GetMaximumIteration()); - double metricWorstPossibleValue = 0; + const double metricWorstPossibleValue = 0; itkOptimizer->SetMetricWorstPossibleValue(metricWorstPossibleValue); ITK_TEST_SET_GET_VALUE(metricWorstPossibleValue, itkOptimizer->GetMetricWorstPossibleValue()); @@ -249,7 +249,7 @@ itkOnePlusOneEvolutionaryOptimizerv4Test(int, char *[]) auto generator = GeneratorType::New(); itkOptimizer->SetNormalVariateGenerator(generator); - bool catchGetValueException = false; + const bool catchGetValueException = false; ITK_TEST_SET_GET_BOOLEAN(itkOptimizer, CatchGetValueException, catchGetValueException); // Set the initial position by setting the metric @@ -268,8 +268,8 @@ itkOnePlusOneEvolutionaryOptimizerv4Test(int, char *[]) // // check results to see if it is within range // - bool pass = true; - double trueParameters[2] = { 2, -2 }; + bool pass = true; + const double trueParameters[2] = { 2, -2 }; for (unsigned int j = 0; j < 2; ++j) { if (itk::Math::abs(finalPosition[j] - trueParameters[j]) > 0.01) diff --git a/Modules/Numerics/Optimizersv4/test/itkOptimizerParameterScalesEstimatorTest.cxx b/Modules/Numerics/Optimizersv4/test/itkOptimizerParameterScalesEstimatorTest.cxx index 993eae2f77a..5e993db7c30 100644 --- a/Modules/Numerics/Optimizersv4/test/itkOptimizerParameterScalesEstimatorTest.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkOptimizerParameterScalesEstimatorTest.cxx @@ -47,7 +47,7 @@ class OptimizerParameterScalesEstimatorTest : public itk::OptimizerParameterScal double EstimateStepScale(const ParametersType & step) override { - double norm = step.two_norm(); + const double norm = step.two_norm(); return norm; } diff --git a/Modules/Numerics/Optimizersv4/test/itkPowellOptimizerv4Test.cxx b/Modules/Numerics/Optimizersv4/test/itkPowellOptimizerv4Test.cxx index fb49b4838b7..0ba96f7ef0e 100644 --- a/Modules/Numerics/Optimizersv4/test/itkPowellOptimizerv4Test.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkPowellOptimizerv4Test.cxx @@ -66,14 +66,14 @@ class PowellBoundedMetric : public itk::ObjectToObjectMetricBase { ++POWELL_CALLS_TO_GET_VALUE; - double x = this->m_Parameters[0]; - double y = m_Parameters[1]; + const double x = this->m_Parameters[0]; + const double y = m_Parameters[1]; std::cout << " GetValue( "; std::cout << x << ' '; std::cout << y << ") = "; - MeasureType measure = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; + const MeasureType measure = 0.5 * (3 * x * x + 4 * x * y + 6 * y * y) - 2 * x + 8 * y; std::cout << measure << std::endl; @@ -224,8 +224,8 @@ itkPowellOptimizerv4Test(int argc, char * argv[]) // // check results to see if it is within range // - bool pass = true; - double trueParameters[2] = { 2, -2 }; + bool pass = true; + const double trueParameters[2] = { 2, -2 }; for (unsigned int j = 0; j < 2; ++j) { if (itk::Math::abs(finalPosition[j] - trueParameters[j]) > 0.01) diff --git a/Modules/Numerics/Optimizersv4/test/itkQuasiNewtonOptimizerv4Test.cxx b/Modules/Numerics/Optimizersv4/test/itkQuasiNewtonOptimizerv4Test.cxx index 7fda3dc8ef5..51d5507e8b6 100644 --- a/Modules/Numerics/Optimizersv4/test/itkQuasiNewtonOptimizerv4Test.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkQuasiNewtonOptimizerv4Test.cxx @@ -177,8 +177,8 @@ itkQuasiNewtonOptimizerv4TestTemplated(int numberOfIterations, // // results // - ParametersType finalParameters = movingTransform->GetParameters(); - ParametersType fixedParameters = movingTransform->GetFixedParameters(); + ParametersType finalParameters = movingTransform->GetParameters(); + const ParametersType fixedParameters = movingTransform->GetFixedParameters(); std::cout << "Estimated scales = " << optimizer->GetScales() << std::endl; std::cout << "finalParameters = " << finalParameters << std::endl; std::cout << "fixedParameters = " << fixedParameters << std::endl; @@ -245,11 +245,12 @@ itkQuasiNewtonOptimizerv4Test(int argc, char ** const argv) std::cout << std::endl << "Optimizing translation transform with shift scales" << std::endl; using TranslationTransformType = itk::TranslationTransform; - int ret1 = itkQuasiNewtonOptimizerv4TestTemplated(numberOfIterations, shiftOfStep, "shift"); + const int ret1 = + itkQuasiNewtonOptimizerv4TestTemplated(numberOfIterations, shiftOfStep, "shift"); std::cout << std::endl << "Optimizing translation transform with Jacobian scales" << std::endl; using TranslationTransformType = itk::TranslationTransform; - int ret2 = + const int ret2 = itkQuasiNewtonOptimizerv4TestTemplated(numberOfIterations, shiftOfStep, "jacobian"); if (ret1 == EXIT_SUCCESS && ret2 == EXIT_SUCCESS) diff --git a/Modules/Numerics/Optimizersv4/test/itkRegistrationParameterScalesEstimatorTest.cxx b/Modules/Numerics/Optimizersv4/test/itkRegistrationParameterScalesEstimatorTest.cxx index ca3a0eb20e1..38e31b509c9 100644 --- a/Modules/Numerics/Optimizersv4/test/itkRegistrationParameterScalesEstimatorTest.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkRegistrationParameterScalesEstimatorTest.cxx @@ -164,7 +164,7 @@ class RegistrationParameterScalesEstimatorTest : public itk::RegistrationParamet this->SetNumberOfRandomSamples(1000); this->SampleVirtualDomain(); - itk::SizeValueType numPara = this->GetTransform()->GetNumberOfParameters(); + const itk::SizeValueType numPara = this->GetTransform()->GetNumberOfParameters(); parameterScales.SetSize(numPara); ParametersType norms(numPara); @@ -177,7 +177,7 @@ class RegistrationParameterScalesEstimatorTest : public itk::RegistrationParamet // checking each sample point for (itk::SizeValueType c = 0; c < numSamples; ++c) { - VirtualPointType point = this->m_SamplePoints[c]; + const VirtualPointType point = this->m_SamplePoints[c]; ParametersType squaredNorms(numPara); this->ComputeSquaredJacobianNorms(point, squaredNorms); @@ -200,7 +200,7 @@ class RegistrationParameterScalesEstimatorTest : public itk::RegistrationParamet double EstimateStepScale(const ParametersType & step) override { - double norm = step.two_norm(); + const double norm = step.two_norm(); return norm; } @@ -231,9 +231,9 @@ itkRegistrationParameterScalesEstimatorTest(int, char *[]) using MovingImageType = itk::Image; using VirtualImageType = itk::Image; - auto fixedImage = FixedImageType::New(); - auto movingImage = MovingImageType::New(); - VirtualImageType::Pointer virtualImage = fixedImage; + auto fixedImage = FixedImageType::New(); + auto movingImage = MovingImageType::New(); + const VirtualImageType::Pointer virtualImage = fixedImage; auto size = MovingImageType::SizeType::Filled(100); @@ -265,7 +265,7 @@ itkRegistrationParameterScalesEstimatorTest(int, char *[]) // Scales for the affine transform from max squared norm of transform jacobians using RegistrationParameterScalesEstimatorTestType = RegistrationParameterScalesEstimatorTest; - RegistrationParameterScalesEstimatorTestType::Pointer jacobianScaleEstimator = + const RegistrationParameterScalesEstimatorTestType::Pointer jacobianScaleEstimator = RegistrationParameterScalesEstimatorTestType::New(); jacobianScaleEstimator->SetMetric(metric); diff --git a/Modules/Numerics/Optimizersv4/test/itkRegistrationParameterScalesFromIndexShiftTest.cxx b/Modules/Numerics/Optimizersv4/test/itkRegistrationParameterScalesFromIndexShiftTest.cxx index 956af65aa88..4a2ea5b9e63 100644 --- a/Modules/Numerics/Optimizersv4/test/itkRegistrationParameterScalesFromIndexShiftTest.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkRegistrationParameterScalesFromIndexShiftTest.cxx @@ -124,9 +124,9 @@ itkRegistrationParameterScalesFromIndexShiftTest(int, char *[]) using MovingImageType = itk::Image; using VirtualImageType = itk::Image; - auto fixedImage = FixedImageType::New(); - auto movingImage = MovingImageType::New(); - VirtualImageType::Pointer virtualImage = fixedImage; + auto fixedImage = FixedImageType::New(); + auto movingImage = MovingImageType::New(); + const VirtualImageType::Pointer virtualImage = fixedImage; auto size = MovingImageType::SizeType::Filled(100); @@ -157,7 +157,7 @@ itkRegistrationParameterScalesFromIndexShiftTest(int, char *[]) // Testing RegistrationParameterScalesFromIndexShift using RegistrationParameterScalesFromShiftType = itk::RegistrationParameterScalesFromIndexShift; - RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = + const RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = RegistrationParameterScalesFromShiftType::New(); shiftScaleEstimator->SetMetric(metric); @@ -225,9 +225,9 @@ itkRegistrationParameterScalesFromIndexShiftTest(int, char *[]) // MovingTransformType::ParametersType movingStep(movingTransform->GetNumberOfParameters()); movingStep = movingTransform->GetParameters(); // the step is an identity transform - FloatType stepScale = shiftScaleEstimator->EstimateStepScale(movingStep); + const FloatType stepScale = shiftScaleEstimator->EstimateStepScale(movingStep); std::cout << "The step scale of shift for the affine transform = " << stepScale << std::endl; - FloatType learningRate = 1.0 / stepScale; + const FloatType learningRate = 1.0 / stepScale; std::cout << "The learning rate of shift for the affine transform = " << learningRate << std::endl; // compute truth @@ -260,7 +260,7 @@ itkRegistrationParameterScalesFromIndexShiftTest(int, char *[]) using FieldType = DisplacementTransformType::DisplacementFieldType; using VectorType = itk::Vector; - VectorType zero{}; + const VectorType zero{}; auto field = FieldType::New(); field->SetRegions(virtualImage->GetLargestPossibleRegion()); @@ -307,13 +307,13 @@ itkRegistrationParameterScalesFromIndexShiftTest(int, char *[]) // DisplacementTransformType::ParametersType displacementStep(displacementTransform->GetNumberOfParameters()); displacementStep.Fill(1.0); - FloatType localStepScale = shiftScaleEstimator->EstimateStepScale(displacementStep); + const FloatType localStepScale = shiftScaleEstimator->EstimateStepScale(displacementStep); std::cout << "The step scale of shift for the displacement field transform = " << localStepScale << std::endl; - FloatType localLearningRate = 1.0 / localStepScale; + const FloatType localLearningRate = 1.0 / localStepScale; std::cout << "The learning rate of shift for the displacement field transform = " << localLearningRate << std::endl; - bool localStepScalePass = false; - FloatType theoreticalLocalStepScale = std::sqrt(2.0); + bool localStepScalePass = false; + const FloatType theoreticalLocalStepScale = std::sqrt(2.0); if (itk::Math::abs((localStepScale - theoreticalLocalStepScale) / theoreticalLocalStepScale) < 0.01) { localStepScalePass = true; diff --git a/Modules/Numerics/Optimizersv4/test/itkRegistrationParameterScalesFromJacobianTest.cxx b/Modules/Numerics/Optimizersv4/test/itkRegistrationParameterScalesFromJacobianTest.cxx index 8c1273b705c..2f3bd73da82 100644 --- a/Modules/Numerics/Optimizersv4/test/itkRegistrationParameterScalesFromJacobianTest.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkRegistrationParameterScalesFromJacobianTest.cxx @@ -124,9 +124,9 @@ itkRegistrationParameterScalesFromJacobianTest(int, char *[]) using MovingImageType = itk::Image; using VirtualImageType = itk::Image; - auto fixedImage = FixedImageType::New(); - auto movingImage = MovingImageType::New(); - VirtualImageType::Pointer virtualImage = fixedImage; + auto fixedImage = FixedImageType::New(); + auto movingImage = MovingImageType::New(); + const VirtualImageType::Pointer virtualImage = fixedImage; auto size = MovingImageType::SizeType::Filled(100); @@ -158,7 +158,7 @@ itkRegistrationParameterScalesFromJacobianTest(int, char *[]) // Scales for the affine transform from transform jacobians using RegistrationParameterScalesFromJacobianType = itk::RegistrationParameterScalesFromJacobian; - RegistrationParameterScalesFromJacobianType::Pointer jacobianScaleEstimator = + const RegistrationParameterScalesFromJacobianType::Pointer jacobianScaleEstimator = RegistrationParameterScalesFromJacobianType::New(); jacobianScaleEstimator->SetMetric(metric); @@ -226,9 +226,9 @@ itkRegistrationParameterScalesFromJacobianTest(int, char *[]) // Testing the step scale for the affine transform MovingTransformType::ParametersType movingStep(movingTransform->GetNumberOfParameters()); movingStep = movingTransform->GetParameters(); - FloatType stepScale = jacobianScaleEstimator->EstimateStepScale(movingStep); + const FloatType stepScale = jacobianScaleEstimator->EstimateStepScale(movingStep); std::cout << "The step scale of Jacobian for the affine transform = " << stepScale << std::endl; - FloatType learningRate = 1.0 / stepScale; + const FloatType learningRate = 1.0 / stepScale; std::cout << "The learning rate of Jacobian for the affine transform = " << learningRate << std::endl; FloatType theoreticalStepScale = 0.0; @@ -265,7 +265,7 @@ itkRegistrationParameterScalesFromJacobianTest(int, char *[]) using FieldType = DisplacementTransformType::DisplacementFieldType; using VectorType = itk::Vector; - VectorType zero{}; + const VectorType zero{}; auto field = FieldType::New(); field->SetRegions(virtualImage->GetLargestPossibleRegion()); @@ -311,14 +311,14 @@ itkRegistrationParameterScalesFromJacobianTest(int, char *[]) // Testing the step scale for the displacement field transform DisplacementTransformType::ParametersType displacementStep(displacementTransform->GetNumberOfParameters()); displacementStep.Fill(1.0); - FloatType localStepScale = jacobianScaleEstimator->EstimateStepScale(displacementStep); + const FloatType localStepScale = jacobianScaleEstimator->EstimateStepScale(displacementStep); std::cout << "The step scale of Jacobian for the displacement field transform = " << localStepScale << std::endl; - FloatType localLearningRate = 1.0 / localStepScale; + const FloatType localLearningRate = 1.0 / localStepScale; std::cout << "The learning rate of Jacobian for the displacement field transform = " << localLearningRate << std::endl; - bool localStepScalePass = false; - FloatType theoreticalLocalStepScale = std::sqrt(2.0); + bool localStepScalePass = false; + const FloatType theoreticalLocalStepScale = std::sqrt(2.0); if (itk::Math::abs((localStepScale - theoreticalLocalStepScale) / theoreticalLocalStepScale) < 0.01) { localStepScalePass = true; diff --git a/Modules/Numerics/Optimizersv4/test/itkRegistrationParameterScalesFromPhysicalShiftPointSetTest.cxx b/Modules/Numerics/Optimizersv4/test/itkRegistrationParameterScalesFromPhysicalShiftPointSetTest.cxx index 3576d4d60a6..017b4eb2c9b 100644 --- a/Modules/Numerics/Optimizersv4/test/itkRegistrationParameterScalesFromPhysicalShiftPointSetTest.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkRegistrationParameterScalesFromPhysicalShiftPointSetTest.cxx @@ -136,7 +136,7 @@ itkRegistrationParameterScalesFromPhysicalShiftPointSetTest(int, char *[]) // using RegistrationParameterScalesFromPhysicalShiftType = itk::RegistrationParameterScalesFromPhysicalShift; - RegistrationParameterScalesFromPhysicalShiftType::Pointer shiftScaleEstimator = + const RegistrationParameterScalesFromPhysicalShiftType::Pointer shiftScaleEstimator = RegistrationParameterScalesFromPhysicalShiftType::New(); shiftScaleEstimator->SetMetric(metric); @@ -203,9 +203,9 @@ itkRegistrationParameterScalesFromPhysicalShiftPointSetTest(int, char *[]) // MovingTransformType::ParametersType movingStep(movingTransform->GetNumberOfParameters()); movingStep = movingTransform->GetParameters(); // the step is an identity transform - FloatType stepScale = shiftScaleEstimator->EstimateStepScale(movingStep); + const FloatType stepScale = shiftScaleEstimator->EstimateStepScale(movingStep); std::cout << "The step scale of shift for the affine transform = " << stepScale << std::endl; - FloatType learningRate = 1.0 / stepScale; + const FloatType learningRate = 1.0 / stepScale; std::cout << "The learning rate of shift for the affine transform = " << learningRate << std::endl; // compute truth @@ -284,12 +284,12 @@ itkRegistrationParameterScalesFromPhysicalShiftPointSetTest(int, char *[]) using FieldType = DisplacementTransformType::DisplacementFieldType; using VectorType = itk::Vector; - VectorType zero{}; + const VectorType zero{}; using RegionType = itk::ImageRegion; RegionType region; region.SetSize(virtualDomainSize); - RegionType::IndexType index{}; + const RegionType::IndexType index{}; region.SetIndex(index); auto field = FieldType::New(); @@ -341,13 +341,13 @@ itkRegistrationParameterScalesFromPhysicalShiftPointSetTest(int, char *[]) // DisplacementTransformType::ParametersType displacementStep(displacementTransform->GetNumberOfParameters()); displacementStep.Fill(1.0); - FloatType localStepScale = shiftScaleEstimator->EstimateStepScale(displacementStep); + const FloatType localStepScale = shiftScaleEstimator->EstimateStepScale(displacementStep); std::cout << "The step scale of shift for the displacement field transform = " << localStepScale << std::endl; - FloatType localLearningRate = 1.0 / localStepScale; + const FloatType localLearningRate = 1.0 / localStepScale; std::cout << "The learning rate of shift for the displacement field transform = " << localLearningRate << std::endl; - bool localStepScalePass = false; - FloatType theoreticalLocalStepScale = std::sqrt(2.0); + bool localStepScalePass = false; + const FloatType theoreticalLocalStepScale = std::sqrt(2.0); if (itk::Math::abs((localStepScale - theoreticalLocalStepScale) / theoreticalLocalStepScale) < 0.01) { localStepScalePass = true; @@ -365,7 +365,7 @@ itkRegistrationParameterScalesFromPhysicalShiftPointSetTest(int, char *[]) // Test that not setting a virtual domain point set for sampling fill fail // std::cout << "Test without setting virtual domain point set." << std::endl; - RegistrationParameterScalesFromPhysicalShiftType::Pointer shiftScaleEstimator2 = + const RegistrationParameterScalesFromPhysicalShiftType::Pointer shiftScaleEstimator2 = RegistrationParameterScalesFromPhysicalShiftType::New(); shiftScaleEstimator2->SetMetric(metric); ITK_TRY_EXPECT_EXCEPTION(shiftScaleEstimator2->EstimateStepScale(displacementStep)); diff --git a/Modules/Numerics/Optimizersv4/test/itkRegistrationParameterScalesFromPhysicalShiftTest.cxx b/Modules/Numerics/Optimizersv4/test/itkRegistrationParameterScalesFromPhysicalShiftTest.cxx index 925a6b1e794..15a5cd5e28c 100644 --- a/Modules/Numerics/Optimizersv4/test/itkRegistrationParameterScalesFromPhysicalShiftTest.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkRegistrationParameterScalesFromPhysicalShiftTest.cxx @@ -124,9 +124,9 @@ itkRegistrationParameterScalesFromPhysicalShiftTest(int, char *[]) using MovingImageType = itk::Image; using VirtualImageType = itk::Image; - auto fixedImage = FixedImageType::New(); - auto movingImage = MovingImageType::New(); - VirtualImageType::Pointer virtualImage = fixedImage; + auto fixedImage = FixedImageType::New(); + auto movingImage = MovingImageType::New(); + const VirtualImageType::Pointer virtualImage = fixedImage; auto size = MovingImageType::SizeType::Filled(100); @@ -158,7 +158,7 @@ itkRegistrationParameterScalesFromPhysicalShiftTest(int, char *[]) // using RegistrationParameterScalesFromPhysicalShiftType = itk::RegistrationParameterScalesFromPhysicalShift; - RegistrationParameterScalesFromPhysicalShiftType::Pointer shiftScaleEstimator = + const RegistrationParameterScalesFromPhysicalShiftType::Pointer shiftScaleEstimator = RegistrationParameterScalesFromPhysicalShiftType::New(); shiftScaleEstimator->SetMetric(metric); @@ -227,9 +227,9 @@ itkRegistrationParameterScalesFromPhysicalShiftTest(int, char *[]) // MovingTransformType::ParametersType movingStep(movingTransform->GetNumberOfParameters()); movingStep = movingTransform->GetParameters(); // the step is an identity transform - FloatType stepScale = shiftScaleEstimator->EstimateStepScale(movingStep); + const FloatType stepScale = shiftScaleEstimator->EstimateStepScale(movingStep); std::cout << "The step scale of shift for the affine transform = " << stepScale << std::endl; - FloatType learningRate = 1.0 / stepScale; + const FloatType learningRate = 1.0 / stepScale; std::cout << "The learning rate of shift for the affine transform = " << learningRate << std::endl; // compute truth @@ -307,7 +307,7 @@ itkRegistrationParameterScalesFromPhysicalShiftTest(int, char *[]) using FieldType = DisplacementTransformType::DisplacementFieldType; using VectorType = itk::Vector; - VectorType zero{}; + const VectorType zero{}; auto field = FieldType::New(); field->SetRegions(virtualImage->GetLargestPossibleRegion()); @@ -354,13 +354,13 @@ itkRegistrationParameterScalesFromPhysicalShiftTest(int, char *[]) // DisplacementTransformType::ParametersType displacementStep(displacementTransform->GetNumberOfParameters()); displacementStep.Fill(1.0); - FloatType localStepScale = shiftScaleEstimator->EstimateStepScale(displacementStep); + const FloatType localStepScale = shiftScaleEstimator->EstimateStepScale(displacementStep); std::cout << "The step scale of shift for the displacement field transform = " << localStepScale << std::endl; - FloatType localLearningRate = 1.0 / localStepScale; + const FloatType localLearningRate = 1.0 / localStepScale; std::cout << "The learning rate of shift for the displacement field transform = " << localLearningRate << std::endl; - bool localStepScalePass = false; - FloatType theoreticalLocalStepScale = std::sqrt(2.0); + bool localStepScalePass = false; + const FloatType theoreticalLocalStepScale = std::sqrt(2.0); if (itk::Math::abs((localStepScale - theoreticalLocalStepScale) / theoreticalLocalStepScale) < 0.01) { localStepScalePass = true; diff --git a/Modules/Numerics/Optimizersv4/test/itkRegularStepGradientDescentOptimizerv4Test.cxx b/Modules/Numerics/Optimizersv4/test/itkRegularStepGradientDescentOptimizerv4Test.cxx index b5693956820..85a2f6aa390 100644 --- a/Modules/Numerics/Optimizersv4/test/itkRegularStepGradientDescentOptimizerv4Test.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkRegularStepGradientDescentOptimizerv4Test.cxx @@ -82,8 +82,8 @@ class RSGv4TestMetric : public itk::ObjectToObjectMetricBase derivative.SetSize(2); } - double x = m_Parameters[0]; - double y = m_Parameters[1]; + const double x = m_Parameters[0]; + const double y = m_Parameters[1]; std::cout << "GetValueAndDerivative( "; std::cout << x << ' '; @@ -183,7 +183,7 @@ RegularStepGradientDescentOptimizerv4TestHelper( initialPosition[1] = -100; metric->SetParameters(initialPosition); - typename OptimizerType::InternalComputationValueType learningRate = 100; + const typename OptimizerType::InternalComputationValueType learningRate = 100; optimizer->SetLearningRate(learningRate); optimizer->SetNumberOfIterations(numberOfIterations); @@ -241,8 +241,8 @@ RegularStepGradientDescentOptimizerv4TestHelper( // // Check results to see if it is within range // - bool pass = true; - double trueParameters[2] = { 2, -2 }; + bool pass = true; + const double trueParameters[2] = { 2, -2 }; for (unsigned int j = 0; j < 2; ++j) { if (itk::Math::FloatAlmostEqual(finalPosition[j], trueParameters[j])) @@ -275,15 +275,15 @@ itkRegularStepGradientDescentOptimizerv4Test(int, char *[]) bool testStatus = EXIT_SUCCESS; - bool doEstimateLearningRateAtEachIteration = false; - bool doEstimateLearningRateOnce = false; + const bool doEstimateLearningRateAtEachIteration = false; + const bool doEstimateLearningRateOnce = false; - itk::SizeValueType numberOfIterations = 900; + const itk::SizeValueType numberOfIterations = 900; - OptimizerType::InternalComputationValueType relaxationFactor = 0.5; - OptimizerType::InternalComputationValueType minimumStepLength = 1e-6; - OptimizerType::InternalComputationValueType gradientMagnitudeTolerance = 1e-6; - OptimizerType::MeasureType currentLearningRateRelaxation = 0; + const OptimizerType::InternalComputationValueType relaxationFactor = 0.5; + const OptimizerType::InternalComputationValueType minimumStepLength = 1e-6; + const OptimizerType::InternalComputationValueType gradientMagnitudeTolerance = 1e-6; + const OptimizerType::MeasureType currentLearningRateRelaxation = 0; testStatus = RegularStepGradientDescentOptimizerv4TestHelper(numberOfIterations, doEstimateLearningRateAtEachIteration, @@ -300,8 +300,8 @@ itkRegularStepGradientDescentOptimizerv4Test(int, char *[]) " estimate learning rate once: false." << std::endl; { - bool doEstimateLearningRateAtEachIteration2 = true; - bool doEstimateLearningRateOnce2 = false; + const bool doEstimateLearningRateAtEachIteration2 = true; + const bool doEstimateLearningRateOnce2 = false; testStatus = RegularStepGradientDescentOptimizerv4TestHelper(numberOfIterations, doEstimateLearningRateAtEachIteration2, doEstimateLearningRateOnce2, @@ -317,8 +317,8 @@ itkRegularStepGradientDescentOptimizerv4Test(int, char *[]) " estimate learning rate once: true." << std::endl; { - bool doEstimateLearningRateAtEachIteration3 = false; - bool doEstimateLearningRateOnce3 = true; + const bool doEstimateLearningRateAtEachIteration3 = false; + const bool doEstimateLearningRateOnce3 = true; testStatus = RegularStepGradientDescentOptimizerv4TestHelper(numberOfIterations, doEstimateLearningRateAtEachIteration3, @@ -335,8 +335,8 @@ itkRegularStepGradientDescentOptimizerv4Test(int, char *[]) " estimate learning rate once: true." << std::endl; { - bool doEstimateLearningRateAtEachIteration4 = true; - bool doEstimateLearningRateOnce4 = true; + const bool doEstimateLearningRateAtEachIteration4 = true; + const bool doEstimateLearningRateOnce4 = true; testStatus = RegularStepGradientDescentOptimizerv4TestHelper(numberOfIterations, doEstimateLearningRateAtEachIteration4, @@ -350,7 +350,7 @@ itkRegularStepGradientDescentOptimizerv4Test(int, char *[]) // Run now with a different relaxation factor std::cout << "\nRun test with a different relaxation factor: 0.8, instead of default value: 0.5." << std::endl; { - OptimizerType::InternalComputationValueType relaxationFactor2 = 0.8; + const OptimizerType::InternalComputationValueType relaxationFactor2 = 0.8; testStatus = RegularStepGradientDescentOptimizerv4TestHelper(numberOfIterations, doEstimateLearningRateAtEachIteration, @@ -365,7 +365,7 @@ itkRegularStepGradientDescentOptimizerv4Test(int, char *[]) // Verify that the optimizer doesn't run if the number of iterations is set to zero. std::cout << "\nCheck the optimizer when number of iterations is set to zero:" << std::endl; { - itk::SizeValueType numberOfIterations2 = 0; + const itk::SizeValueType numberOfIterations2 = 0; testStatus = RegularStepGradientDescentOptimizerv4TestHelper(numberOfIterations2, doEstimateLearningRateAtEachIteration, @@ -381,8 +381,8 @@ itkRegularStepGradientDescentOptimizerv4Test(int, char *[]) // std::cout << "\nTest the Exception if the GradientMagnitudeTolerance is set to a negative value:" << std::endl; { - OptimizerType::InternalComputationValueType gradientMagnitudeTolerance2 = -1.0; - bool expectedExceptionReceived = + const OptimizerType::InternalComputationValueType gradientMagnitudeTolerance2 = -1.0; + const bool expectedExceptionReceived = RegularStepGradientDescentOptimizerv4TestHelper(numberOfIterations, doEstimateLearningRateAtEachIteration, doEstimateLearningRateOnce, @@ -405,10 +405,10 @@ itkRegularStepGradientDescentOptimizerv4Test(int, char *[]) // std::cout << "\nTest the Exception if the RelaxationFactor is set to a negative value:" << std::endl; { - itk::SizeValueType numberOfIterations3 = 100; - OptimizerType::InternalComputationValueType relaxationFactor3 = -1.0; - OptimizerType::InternalComputationValueType gradientMagnitudeTolerance3 = 0.01; - bool expectedExceptionReceived = + const itk::SizeValueType numberOfIterations3 = 100; + const OptimizerType::InternalComputationValueType relaxationFactor3 = -1.0; + const OptimizerType::InternalComputationValueType gradientMagnitudeTolerance3 = 0.01; + const bool expectedExceptionReceived = RegularStepGradientDescentOptimizerv4TestHelper(numberOfIterations3, doEstimateLearningRateAtEachIteration, doEstimateLearningRateOnce, @@ -430,10 +430,10 @@ itkRegularStepGradientDescentOptimizerv4Test(int, char *[]) // std::cout << "\nTest the Exception if the RelaxationFactor is set to a value larger than one:" << std::endl; { - itk::SizeValueType numberOfIterations4 = 100; - OptimizerType::InternalComputationValueType relaxationFactor4 = 1.1; - OptimizerType::InternalComputationValueType gradientMagnitudeTolerance4 = 0.01; - bool expectedExceptionReceived = + const itk::SizeValueType numberOfIterations4 = 100; + const OptimizerType::InternalComputationValueType relaxationFactor4 = 1.1; + const OptimizerType::InternalComputationValueType gradientMagnitudeTolerance4 = 0.01; + const bool expectedExceptionReceived = RegularStepGradientDescentOptimizerv4TestHelper(numberOfIterations4, doEstimateLearningRateAtEachIteration, doEstimateLearningRateOnce, diff --git a/Modules/Numerics/Polynomials/include/itkMultivariateLegendrePolynomial.h b/Modules/Numerics/Polynomials/include/itkMultivariateLegendrePolynomial.h index 1c52ff22dc6..4596912f07e 100644 --- a/Modules/Numerics/Polynomials/include/itkMultivariateLegendrePolynomial.h +++ b/Modules/Numerics/Polynomials/include/itkMultivariateLegendrePolynomial.h @@ -172,13 +172,13 @@ class ITKPolynomials_EXPORT MultivariateLegendrePolynomial if (index[1] != m_PrevY) { // normalized y [-1, 1] - double norm_y = m_NormFactor[1] * static_cast(index[1] - 1); + const double norm_y = m_NormFactor[1] * static_cast(index[1] - 1); this->CalculateXCoef(norm_y, m_CoefficientArray); m_PrevY = index[1]; } // normalized x [-1, 1] - double norm_x = m_NormFactor[0] * static_cast(index[0] - 1); + const double norm_x = m_NormFactor[0] * static_cast(index[0] - 1); return LegendreSum(norm_x, m_Degree, m_CachedXCoef); } @@ -187,7 +187,7 @@ class ITKPolynomials_EXPORT MultivariateLegendrePolynomial if (index[2] != m_PrevZ) { // normalized z [-1, 1] - double norm_z = m_NormFactor[2] * static_cast(index[2] - 1); + const double norm_z = m_NormFactor[2] * static_cast(index[2] - 1); this->CalculateYCoef(norm_z, m_CoefficientArray); m_PrevZ = index[2]; } @@ -195,13 +195,13 @@ class ITKPolynomials_EXPORT MultivariateLegendrePolynomial if (index[1] != m_PrevY) { // normalized y [-1, 1] - double norm_y = m_NormFactor[1] * static_cast(index[1] - 1); + const double norm_y = m_NormFactor[1] * static_cast(index[1] - 1); this->CalculateXCoef(norm_y, m_CachedYCoef); m_PrevY = index[1]; } // normalized x [-1, 1] - double norm_x = m_NormFactor[0] * static_cast(index[0] - 1); + const double norm_x = m_NormFactor[0] * static_cast(index[0] - 1); return this->LegendreSum(norm_x, m_Degree, m_CachedXCoef); } return 0; diff --git a/Modules/Numerics/Polynomials/src/itkMultivariateLegendrePolynomial.cxx b/Modules/Numerics/Polynomials/src/itkMultivariateLegendrePolynomial.cxx index 4dda32385b9..e042b6c806b 100644 --- a/Modules/Numerics/Polynomials/src/itkMultivariateLegendrePolynomial.cxx +++ b/Modules/Numerics/Polynomials/src/itkMultivariateLegendrePolynomial.cxx @@ -61,7 +61,7 @@ MultivariateLegendrePolynomial::~MultivariateLegendrePolynomial() = default; void MultivariateLegendrePolynomial::Print(std::ostream & os) const { - itk::Indent indent(4); + const itk::Indent indent(4); this->PrintSelf(os, indent); } @@ -192,8 +192,8 @@ MultivariateLegendrePolynomial::CalculateYCoef(double norm_z, const CoefficientA const unsigned int lymax = m_Degree - lx; for (unsigned int ly = 0; ly <= lymax; ly++, c_index++) { - unsigned int z_index = c_index; - unsigned int lzmax = m_Degree - lx - ly; + unsigned int z_index = c_index; + const unsigned int lzmax = m_Degree - lx - ly; for (unsigned int lz = 0; lz <= lzmax; ++lz) { m_CachedZCoef[lz] = coef[z_index]; @@ -219,7 +219,7 @@ MultivariateLegendrePolynomial::LegendreSum(const double x, int n, const Coeffic for (int k = n - 1; k > 0; k--) { - double yk = x * ykp1 * (2 * k + 1) / (k + 1) - ykp2 * (k + 1) / (k + 2) + coef[k + offset]; + const double yk = x * ykp1 * (2 * k + 1) / (k + 1) - ykp2 * (k + 1) / (k + 2) + coef[k + offset]; ykp2 = ykp1; ykp1 = yk; } diff --git a/Modules/Numerics/Statistics/include/itkCovarianceSampleFilter.hxx b/Modules/Numerics/Statistics/include/itkCovarianceSampleFilter.hxx index 20bcb55887d..efc4636cf6b 100644 --- a/Modules/Numerics/Statistics/include/itkCovarianceSampleFilter.hxx +++ b/Modules/Numerics/Statistics/include/itkCovarianceSampleFilter.hxx @@ -56,7 +56,7 @@ template auto CovarianceSampleFilter::MakeOutput(DataObjectPointerArraySizeType index) -> DataObjectPointer { - MeasurementVectorSizeType measurementVectorSize = this->GetMeasurementVectorSize(); + const MeasurementVectorSizeType measurementVectorSize = this->GetMeasurementVectorSize(); if (index == 0) { @@ -110,7 +110,7 @@ CovarianceSampleFilter::GenerateData() // set up input / output const SampleType * input = this->GetInput(); - MeasurementVectorSizeType measurementVectorSize = input->GetMeasurementVectorSize(); + const MeasurementVectorSizeType measurementVectorSize = input->GetMeasurementVectorSize(); auto * decoratedOutput = itkDynamicCastInDebugMode(this->ProcessObject::GetOutput(0)); diff --git a/Modules/Numerics/Statistics/include/itkDistanceMetric.h b/Modules/Numerics/Statistics/include/itkDistanceMetric.h index 40924025526..49898e86f04 100644 --- a/Modules/Numerics/Statistics/include/itkDistanceMetric.h +++ b/Modules/Numerics/Statistics/include/itkDistanceMetric.h @@ -114,7 +114,7 @@ class ITK_TEMPLATE_EXPORT DistanceMetric : public FunctionBase else { // If this is a non-resizable vector type - MeasurementVectorSizeType defaultLength = NumericTraits::GetLength({}); + const MeasurementVectorSizeType defaultLength = NumericTraits::GetLength({}); // and the new length is different from the default one, then throw an // exception if (defaultLength != s) diff --git a/Modules/Numerics/Statistics/include/itkDistanceMetric.hxx b/Modules/Numerics/Statistics/include/itkDistanceMetric.hxx index 958400b604a..59a3a92fe84 100644 --- a/Modules/Numerics/Statistics/include/itkDistanceMetric.hxx +++ b/Modules/Numerics/Statistics/include/itkDistanceMetric.hxx @@ -30,7 +30,7 @@ DistanceMetric::DistanceMetric() // initialize the vector size to it. if (!MeasurementVectorTraits::IsResizable({})) { - MeasurementVectorSizeType defaultLength = NumericTraits::GetLength({}); + const MeasurementVectorSizeType defaultLength = NumericTraits::GetLength({}); this->m_MeasurementVectorSize = defaultLength; this->m_Origin.SetSize(this->m_MeasurementVectorSize); diff --git a/Modules/Numerics/Statistics/include/itkDistanceToCentroidMembershipFunction.hxx b/Modules/Numerics/Statistics/include/itkDistanceToCentroidMembershipFunction.hxx index 8d1924270b1..9dbc033f4f2 100644 --- a/Modules/Numerics/Statistics/include/itkDistanceToCentroidMembershipFunction.hxx +++ b/Modules/Numerics/Statistics/include/itkDistanceToCentroidMembershipFunction.hxx @@ -69,8 +69,8 @@ template typename LightObject::Pointer DistanceToCentroidMembershipFunction::InternalClone() const { - LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer membershipFunction = dynamic_cast(loPtr.GetPointer()); + LightObject::Pointer loPtr = Superclass::InternalClone(); + const typename Self::Pointer membershipFunction = dynamic_cast(loPtr.GetPointer()); if (membershipFunction.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Numerics/Statistics/include/itkEuclideanDistanceMetric.hxx b/Modules/Numerics/Statistics/include/itkEuclideanDistanceMetric.hxx index 6e0009f1513..c9c5725c1be 100644 --- a/Modules/Numerics/Statistics/include/itkEuclideanDistanceMetric.hxx +++ b/Modules/Numerics/Statistics/include/itkEuclideanDistanceMetric.hxx @@ -27,7 +27,7 @@ template inline double EuclideanDistanceMetric::Evaluate(const MeasurementVectorType & x) const { - MeasurementVectorSizeType measurementVectorSize = this->GetMeasurementVectorSize(); + const MeasurementVectorSizeType measurementVectorSize = this->GetMeasurementVectorSize(); if (measurementVectorSize == 0) { @@ -54,7 +54,7 @@ template inline double EuclideanDistanceMetric::Evaluate(const MeasurementVectorType & x1, const MeasurementVectorType & x2) const { - MeasurementVectorSizeType measurementVectorSize = NumericTraits::GetLength(x1); + const MeasurementVectorSizeType measurementVectorSize = NumericTraits::GetLength(x1); if (measurementVectorSize != NumericTraits::GetLength(x2)) { diff --git a/Modules/Numerics/Statistics/include/itkEuclideanSquareDistanceMetric.hxx b/Modules/Numerics/Statistics/include/itkEuclideanSquareDistanceMetric.hxx index bc931e74454..acc24e0dffb 100644 --- a/Modules/Numerics/Statistics/include/itkEuclideanSquareDistanceMetric.hxx +++ b/Modules/Numerics/Statistics/include/itkEuclideanSquareDistanceMetric.hxx @@ -27,7 +27,7 @@ template inline double EuclideanSquareDistanceMetric::Evaluate(const MeasurementVectorType & x) const { - MeasurementVectorSizeType measurementVectorSize = this->GetMeasurementVectorSize(); + const MeasurementVectorSizeType measurementVectorSize = this->GetMeasurementVectorSize(); if (measurementVectorSize == 0) { @@ -43,7 +43,7 @@ EuclideanSquareDistanceMetric::Evaluate(const MeasurementVectorType & x for (unsigned int i = 0; i < measurementVectorSize; ++i) { - double temp = this->GetOrigin()[i] - x[i]; + const double temp = this->GetOrigin()[i] - x[i]; distance += temp * temp; } @@ -55,7 +55,7 @@ inline double EuclideanSquareDistanceMetric::Evaluate(const MeasurementVectorType & x1, const MeasurementVectorType & x2) const { - MeasurementVectorSizeType measurementVectorSize = NumericTraits::GetLength(x1); + const MeasurementVectorSizeType measurementVectorSize = NumericTraits::GetLength(x1); if (measurementVectorSize != NumericTraits::GetLength(x2)) { @@ -65,7 +65,7 @@ EuclideanSquareDistanceMetric::Evaluate(const MeasurementVectorType & x double distance = 0.0; for (unsigned int i = 0; i < measurementVectorSize; ++i) { - double temp = x1[i] - x2[i]; + const double temp = x1[i] - x2[i]; distance += temp * temp; } return distance; diff --git a/Modules/Numerics/Statistics/include/itkExpectationMaximizationMixtureModelEstimator.hxx b/Modules/Numerics/Statistics/include/itkExpectationMaximizationMixtureModelEstimator.hxx index 5504fad82d3..117d6b843db 100644 --- a/Modules/Numerics/Statistics/include/itkExpectationMaximizationMixtureModelEstimator.hxx +++ b/Modules/Numerics/Statistics/include/itkExpectationMaximizationMixtureModelEstimator.hxx @@ -150,31 +150,31 @@ ExpectationMaximizationMixtureModelEstimator::CalculateDensities() return false; } - size_t numberOfComponents = m_ComponentVector.size(); + const size_t numberOfComponents = m_ComponentVector.size(); std::vector tempWeights(numberOfComponents, 0.); - typename TSample::ConstIterator iter = m_Sample->Begin(); - typename TSample::ConstIterator last = m_Sample->End(); + typename TSample::ConstIterator iter = m_Sample->Begin(); + const typename TSample::ConstIterator last = m_Sample->End(); // Note: The data type of componentIndex should be unsigned int // because itk::Array only supports 'unsigned int' number of elements. using FrequencyType = typename TSample::AbsoluteFrequencyType; - FrequencyType zeroFrequency{}; - constexpr double minDouble = NumericTraits::epsilon(); - SizeValueType measurementVectorIndex = 0; + const FrequencyType zeroFrequency{}; + constexpr double minDouble = NumericTraits::epsilon(); + SizeValueType measurementVectorIndex = 0; while (iter != last) { typename TSample::MeasurementVectorType mvector = iter.GetMeasurementVector(); - FrequencyType frequency = iter.GetFrequency(); + const FrequencyType frequency = iter.GetFrequency(); double densitySum = 0.0; if (frequency > zeroFrequency) { for (unsigned int componentIndex = 0; componentIndex < numberOfComponents; ++componentIndex) { - double t_prop = m_Proportions[componentIndex]; - double t_value = m_ComponentVector[componentIndex]->Evaluate(mvector); - double density = t_prop * t_value; + const double t_prop = m_Proportions[componentIndex]; + const double t_value = m_ComponentVector[componentIndex]->Evaluate(mvector); + const double density = t_prop * t_value; tempWeights[componentIndex] = density; densitySum += density; } @@ -215,7 +215,7 @@ ExpectationMaximizationMixtureModelEstimator::CalculateExpectation() co if (m_Sample) { - SizeValueType size = m_Sample->Size(); + const SizeValueType size = m_Sample->Size(); for (size_t componentIndex = 0; componentIndex < m_ComponentVector.size(); ++componentIndex) @@ -267,9 +267,9 @@ template bool ExpectationMaximizationMixtureModelEstimator::UpdateProportions() { - size_t numberOfComponents = m_ComponentVector.size(); - size_t sampleSize = m_Sample->Size(); - auto totalFrequency = static_cast(m_Sample->GetTotalFrequency()); + const size_t numberOfComponents = m_ComponentVector.size(); + const size_t sampleSize = m_Sample->Size(); + auto totalFrequency = static_cast(m_Sample->GetTotalFrequency()); bool updated = false; @@ -329,10 +329,10 @@ template auto ExpectationMaximizationMixtureModelEstimator::GetOutput() const -> const MembershipFunctionVectorObjectType * { - size_t numberOfComponents = m_ComponentVector.size(); + const size_t numberOfComponents = m_ComponentVector.size(); MembershipFunctionVectorType & membershipFunctionsVector = m_MembershipFunctionsObject->Get(); - typename SampleType::MeasurementVectorSizeType measurementVectorSize = m_Sample->GetMeasurementVectorSize(); + const typename SampleType::MeasurementVectorSizeType measurementVectorSize = m_Sample->GetMeasurementVectorSize(); typename GaussianMembershipFunctionType::MeanVectorType mean; NumericTraits::SetLength(mean, measurementVectorSize); @@ -376,7 +376,7 @@ auto ExpectationMaximizationMixtureModelEstimator::GetMembershipFunctionsWeightsArray() const -> const MembershipFunctionsWeightsArrayObjectType * { - size_t numberOfComponents = m_ComponentVector.size(); + const size_t numberOfComponents = m_ComponentVector.size(); ProportionVectorType & membershipFunctionsWeightVector = m_MembershipFunctionsWeightArrayObject->Get(); membershipFunctionsWeightVector.SetSize(static_cast(numberOfComponents)); diff --git a/Modules/Numerics/Statistics/include/itkGaussianMembershipFunction.hxx b/Modules/Numerics/Statistics/include/itkGaussianMembershipFunction.hxx index b5c4112711d..5c2e32a5639 100644 --- a/Modules/Numerics/Statistics/include/itkGaussianMembershipFunction.hxx +++ b/Modules/Numerics/Statistics/include/itkGaussianMembershipFunction.hxx @@ -109,10 +109,10 @@ GaussianMembershipFunction::SetCovariance(const CovarianceMa m_Covariance = cov; // the inverse of the covariance matrix is first computed by SVD - vnl_matrix_inverse inv_cov(m_Covariance.GetVnlMatrix()); + const vnl_matrix_inverse inv_cov(m_Covariance.GetVnlMatrix()); // the determinant is then costless this way - double det = inv_cov.determinant_magnitude(); + const double det = inv_cov.determinant_magnitude(); if (det < 0.) { @@ -176,8 +176,8 @@ template typename LightObject::Pointer GaussianMembershipFunction::InternalClone() const { - LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer membershipFunction = dynamic_cast(loPtr.GetPointer()); + LightObject::Pointer loPtr = Superclass::InternalClone(); + const typename Self::Pointer membershipFunction = dynamic_cast(loPtr.GetPointer()); if (membershipFunction.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Numerics/Statistics/include/itkGaussianMixtureModelComponent.hxx b/Modules/Numerics/Statistics/include/itkGaussianMixtureModelComponent.hxx index 914d8b3b8d5..5244c894fa2 100644 --- a/Modules/Numerics/Statistics/include/itkGaussianMixtureModelComponent.hxx +++ b/Modules/Numerics/Statistics/include/itkGaussianMixtureModelComponent.hxx @@ -90,7 +90,7 @@ GaussianMixtureModelComponent::SetParameters(const ParametersType & par unsigned int paramIndex = 0; bool changed = false; - MeasurementVectorSizeType measurementVectorSize = this->GetSample()->GetMeasurementVectorSize(); + const MeasurementVectorSizeType measurementVectorSize = this->GetSample()->GetMeasurementVectorSize(); for (unsigned int i = 0; i < measurementVectorSize; ++i) { @@ -166,14 +166,14 @@ template void GaussianMixtureModelComponent::GenerateData() { - MeasurementVectorSizeType measurementVectorSize = this->GetSample()->GetMeasurementVectorSize(); + const MeasurementVectorSizeType measurementVectorSize = this->GetSample()->GetMeasurementVectorSize(); this->AreParametersModified(false); const WeightArrayType & weights = this->GetWeights(); - typename TSample::ConstIterator iter = this->GetSample()->Begin(); - typename TSample::ConstIterator end = this->GetSample()->End(); + typename TSample::ConstIterator iter = this->GetSample()->Begin(); + const typename TSample::ConstIterator end = this->GetSample()->End(); typename TSample::MeasurementVectorType measurements; @@ -194,7 +194,7 @@ GaussianMixtureModelComponent::GenerateData() typename MeanEstimatorType::MeasurementVectorType meanEstimate = m_MeanEstimator->GetMean(); for (MeasurementVectorSizeType i = 0; i < measurementVectorSize; ++i) { - double changes = itk::Math::abs(m_Mean[i] - meanEstimate[i]); + const double changes = itk::Math::abs(m_Mean[i] - meanEstimate[i]); if (changes > this->GetMinimalParametersChange()) { @@ -228,8 +228,8 @@ GaussianMixtureModelComponent::GenerateData() { for (MeasurementVectorSizeType j = 0; j < measurementVectorSize; ++j) { - double temp = m_Covariance.GetVnlMatrix().get(i, j) - covEstimate.GetVnlMatrix().get(i, j); - double changes = itk::Math::abs(temp); + const double temp = m_Covariance.GetVnlMatrix().get(i, j) - covEstimate.GetVnlMatrix().get(i, j); + const double changes = itk::Math::abs(temp); if (changes > this->GetMinimalParametersChange()) { changed = true; diff --git a/Modules/Numerics/Statistics/include/itkGaussianRandomSpatialNeighborSubsampler.hxx b/Modules/Numerics/Statistics/include/itkGaussianRandomSpatialNeighborSubsampler.hxx index 1b54cc74f0a..60d7c996913 100644 --- a/Modules/Numerics/Statistics/include/itkGaussianRandomSpatialNeighborSubsampler.hxx +++ b/Modules/Numerics/Statistics/include/itkGaussianRandomSpatialNeighborSubsampler.hxx @@ -35,7 +35,7 @@ GaussianRandomSpatialNeighborSubsampler::InternalClone() const { typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); @@ -60,7 +60,7 @@ GaussianRandomSpatialNeighborSubsampler::GetIntegerVariate(Ran do { - RealType randVar = this->m_RandomNumberGenerator->GetNormalVariate(mean, m_Variance); + const RealType randVar = this->m_RandomNumberGenerator->GetNormalVariate(mean, m_Variance); randInt = static_cast(std::floor(randVar)); } while ((randInt < lowerBound) || (randInt > upperBound)); return randInt; diff --git a/Modules/Numerics/Statistics/include/itkHistogram.h b/Modules/Numerics/Statistics/include/itkHistogram.h index 4ba8ea1ee10..da094194db1 100644 --- a/Modules/Numerics/Statistics/include/itkHistogram.h +++ b/Modules/Numerics/Statistics/include/itkHistogram.h @@ -468,7 +468,7 @@ class ITK_TEMPLATE_EXPORT Histogram : public Sample> Iterator Begin() { - Iterator iter(0, this); + const Iterator iter(0, this); return iter; } @@ -482,7 +482,7 @@ class ITK_TEMPLATE_EXPORT Histogram : public Sample> ConstIterator Begin() const { - ConstIterator iter(0, this); + const ConstIterator iter(0, this); return iter; } diff --git a/Modules/Numerics/Statistics/include/itkHistogram.hxx b/Modules/Numerics/Statistics/include/itkHistogram.hxx index 7a9bbe91606..e01fd511de1 100644 --- a/Modules/Numerics/Statistics/include/itkHistogram.hxx +++ b/Modules/Numerics/Statistics/include/itkHistogram.hxx @@ -476,7 +476,7 @@ Histogram::GetMeasurementVector(const IndexTy const unsigned int measurementVectorSize = this->GetMeasurementVectorSize(); for (unsigned int i = 0; i < measurementVectorSize; ++i) { - MeasurementType value = (m_Min[i][index[i]] + m_Max[i][index[i]]); + const MeasurementType value = (m_Min[i][index[i]] + m_Max[i][index[i]]); m_TempMeasurementVector[i] = static_cast(value / 2.0); } return m_TempMeasurementVector; @@ -563,12 +563,12 @@ auto Histogram::GetFrequency(InstanceIdentifier n, unsigned int dimension) const -> AbsoluteFrequencyType { - InstanceIdentifier nextOffset = this->m_OffsetTable[dimension + 1]; - InstanceIdentifier current = this->m_OffsetTable[dimension] * n; - InstanceIdentifier includeLength = this->m_OffsetTable[dimension]; - InstanceIdentifier include; - InstanceIdentifier includeEnd; - InstanceIdentifier last = this->m_OffsetTable[this->GetMeasurementVectorSize()]; + const InstanceIdentifier nextOffset = this->m_OffsetTable[dimension + 1]; + InstanceIdentifier current = this->m_OffsetTable[dimension] * n; + const InstanceIdentifier includeLength = this->m_OffsetTable[dimension]; + InstanceIdentifier include; + InstanceIdentifier includeEnd; + const InstanceIdentifier last = this->m_OffsetTable[this->GetMeasurementVectorSize()]; AbsoluteFrequencyType frequency = 0; @@ -618,11 +618,11 @@ Histogram::Quantile(unsigned int dimension, d ++n; } while (n < size && p_n < p); - double binProportion = f_n / totalFrequency; + const double binProportion = f_n / totalFrequency; - double min = static_cast(this->GetBinMin(dimension, n - 1)); - double max = static_cast(this->GetBinMax(dimension, n - 1)); - double interval = max - min; + const double min = static_cast(this->GetBinMin(dimension, n - 1)); + const double max = static_cast(this->GetBinMax(dimension, n - 1)); + const double interval = max - min; return min + ((p - p_n_prev) / binProportion) * interval; } else @@ -640,10 +640,10 @@ Histogram::Quantile(unsigned int dimension, d ++m; } while (m < size && p_n > p); - double binProportion = f_n / totalFrequency; - double min = static_cast(this->GetBinMin(dimension, n + 1)); - double max = static_cast(this->GetBinMax(dimension, n + 1)); - double interval = max - min; + const double binProportion = f_n / totalFrequency; + const double min = static_cast(this->GetBinMin(dimension, n + 1)); + const double max = static_cast(this->GetBinMax(dimension, n + 1)); + const double interval = max - min; return max - ((p_n_prev - p) / binProportion) * interval; } } @@ -653,11 +653,11 @@ double Histogram::Mean(unsigned int dimension) const { const unsigned int size = this->GetSize(dimension); - double totalFrequency = this->GetTotalFrequency(); + const double totalFrequency = this->GetTotalFrequency(); double sum = 0; for (unsigned int i = 0; i < size; ++i) { - double frequency = this->GetFrequency(i, dimension); + const double frequency = this->GetFrequency(i, dimension); sum += frequency * this->GetMeasurement(i, dimension); } return sum / totalFrequency; diff --git a/Modules/Numerics/Statistics/include/itkHistogramToImageFilter.hxx b/Modules/Numerics/Statistics/include/itkHistogramToImageFilter.hxx index 809746cb849..b14e53ef73e 100644 --- a/Modules/Numerics/Statistics/include/itkHistogramToImageFilter.hxx +++ b/Modules/Numerics/Statistics/include/itkHistogramToImageFilter.hxx @@ -85,7 +85,8 @@ HistogramToImageFilter::GenerateOutputInformation SpacingType spacing; // Set the image size to the number of bins along each dimension. // TODO: is it possible to have a size 0 on one of the dimension? if yes, the size must be checked - unsigned int minDim = std::min(static_cast(ImageDimension), inputHistogram->GetMeasurementVectorSize()); + const unsigned int minDim = + std::min(static_cast(ImageDimension), inputHistogram->GetMeasurementVectorSize()); for (unsigned int i = 0; i < minDim; ++i) { size[i] = inputHistogram->GetSize(i); diff --git a/Modules/Numerics/Statistics/include/itkHistogramToRunLengthFeaturesFilter.hxx b/Modules/Numerics/Statistics/include/itkHistogramToRunLengthFeaturesFilter.hxx index 6aa42926bc3..5cf9501102c 100644 --- a/Modules/Numerics/Statistics/include/itkHistogramToRunLengthFeaturesFilter.hxx +++ b/Modules/Numerics/Statistics/include/itkHistogramToRunLengthFeaturesFilter.hxx @@ -92,13 +92,13 @@ HistogramToRunLengthFeaturesFilter::GenerateData() using HistogramIterator = typename HistogramType::ConstIterator; for (HistogramIterator hit = inputHistogram->Begin(); hit != inputHistogram->End(); ++hit) { - MeasurementType frequency = hit.GetFrequency(); + const MeasurementType frequency = hit.GetFrequency(); if (Math::ExactlyEquals(frequency, MeasurementType{})) { continue; } - MeasurementVectorType measurement = hit.GetMeasurementVector(); - IndexType index = inputHistogram->GetIndex(hit.GetInstanceIdentifier()); + const MeasurementVectorType measurement = hit.GetMeasurementVector(); + IndexType index = inputHistogram->GetIndex(hit.GetInstanceIdentifier()); auto i2 = static_cast((index[0] + 1) * (index[0] + 1)); auto j2 = static_cast((index[1] + 1) * (index[1] + 1)); diff --git a/Modules/Numerics/Statistics/include/itkHistogramToTextureFeaturesFilter.hxx b/Modules/Numerics/Statistics/include/itkHistogramToTextureFeaturesFilter.hxx index 2d6bac74a49..9230afc5b5e 100644 --- a/Modules/Numerics/Statistics/include/itkHistogramToTextureFeaturesFilter.hxx +++ b/Modules/Numerics/Statistics/include/itkHistogramToTextureFeaturesFilter.hxx @@ -79,8 +79,8 @@ HistogramToTextureFeaturesFilter::GenerateData() for (HistogramIterator hit = inputHistogram->Begin(); hit != inputHistogram->End(); ++hit) { - AbsoluteFrequencyType frequency = hit.GetFrequency(); - RelativeFrequencyType relativeFrequency = frequency / totalFrequency; + const AbsoluteFrequencyType frequency = hit.GetFrequency(); + const RelativeFrequencyType relativeFrequency = frequency / totalFrequency; m_RelativeFrequencyContainer.push_back(relativeFrequency); } @@ -120,7 +120,7 @@ HistogramToTextureFeaturesFilter::GenerateData() for (HistogramIterator hit = inputHistogram->Begin(); hit != inputHistogram->End(); ++hit) { - RelativeFrequencyType frequency = *rFreqIterator; + const RelativeFrequencyType frequency = *rFreqIterator; ++rFreqIterator; if (Math::AlmostEquals(frequency, RelativeFrequencyType{})) { @@ -182,8 +182,8 @@ HistogramToTextureFeaturesFilter::ComputeMeansAndVariances(double & const HistogramType * inputHistogram = this->GetInput(); // Initialize everything - typename HistogramType::SizeValueType binsPerAxis = inputHistogram->GetSize(0); - const auto marginalSums = std::make_unique(binsPerAxis); + const typename HistogramType::SizeValueType binsPerAxis = inputHistogram->GetSize(0); + const auto marginalSums = std::make_unique(binsPerAxis); pixelMean = 0; typename RelativeFrequencyContainerType::const_iterator rFreqIterator = m_RelativeFrequencyContainer.begin(); @@ -193,8 +193,8 @@ HistogramToTextureFeaturesFilter::ComputeMeansAndVariances(double & HistogramIterator hit = inputHistogram->Begin(); while (hit != inputHistogram->End()) { - RelativeFrequencyType frequency = *rFreqIterator; - IndexType index = inputHistogram->GetIndex(hit.GetInstanceIdentifier()); + const RelativeFrequencyType frequency = *rFreqIterator; + IndexType index = inputHistogram->GetIndex(hit.GetInstanceIdentifier()); pixelMean += index[0] * frequency; marginalSums[index[0]] += frequency; ++hit; @@ -215,13 +215,13 @@ HistogramToTextureFeaturesFilter::ComputeMeansAndVariances(double & marginalDevSquared = 0; for (unsigned int arrayIndex = 1; arrayIndex < binsPerAxis; ++arrayIndex) { - int k = arrayIndex + 1; - double M_k_minus_1 = marginalMean; - double S_k_minus_1 = marginalDevSquared; - double x_k = marginalSums[arrayIndex]; + const int k = arrayIndex + 1; + const double M_k_minus_1 = marginalMean; + const double S_k_minus_1 = marginalDevSquared; + const double x_k = marginalSums[arrayIndex]; - double M_k = M_k_minus_1 + (x_k - M_k_minus_1) / k; - double S_k = S_k_minus_1 + (x_k - M_k_minus_1) * (x_k - M_k); + const double M_k = M_k_minus_1 + (x_k - M_k_minus_1) / k; + const double S_k = S_k_minus_1 + (x_k - M_k_minus_1) * (x_k - M_k); marginalMean = M_k; marginalDevSquared = S_k; @@ -233,8 +233,8 @@ HistogramToTextureFeaturesFilter::ComputeMeansAndVariances(double & pixelVariance = 0; for (hit = inputHistogram->Begin(); hit != inputHistogram->End(); ++hit) { - RelativeFrequencyType frequency = *rFreqIterator; - IndexType index = inputHistogram->GetIndex(hit.GetInstanceIdentifier()); + const RelativeFrequencyType frequency = *rFreqIterator; + IndexType index = inputHistogram->GetIndex(hit.GetInstanceIdentifier()); pixelVariance += (index[0] - pixelMean) * (index[0] - pixelMean) * frequency; ++rFreqIterator; } diff --git a/Modules/Numerics/Statistics/include/itkImageClassifierFilter.hxx b/Modules/Numerics/Statistics/include/itkImageClassifierFilter.hxx index 3546e31f7d9..97ae083a37d 100644 --- a/Modules/Numerics/Statistics/include/itkImageClassifierFilter.hxx +++ b/Modules/Numerics/Statistics/include/itkImageClassifierFilter.hxx @@ -169,7 +169,7 @@ ImageClassifierFilter::GenerateData() discriminantScores[i] = membershipFunctionsWeightsArray[i] * membershipFunctions[i]->Evaluate(measurements); } - unsigned int classIndex = static_cast(m_DecisionRule->Evaluate(discriminantScores)); + const unsigned int classIndex = static_cast(m_DecisionRule->Evaluate(discriminantScores)); auto value = static_cast(classLabels[classIndex]); outItr.Set(value); diff --git a/Modules/Numerics/Statistics/include/itkImageToHistogramFilter.hxx b/Modules/Numerics/Statistics/include/itkImageToHistogramFilter.hxx index 5d774a3f185..8ece83d92f9 100644 --- a/Modules/Numerics/Statistics/include/itkImageToHistogramFilter.hxx +++ b/Modules/Numerics/Statistics/include/itkImageToHistogramFilter.hxx @@ -282,8 +282,8 @@ ImageToHistogramFilter::ThreadedMergeHistogram(HistogramPointer && histo using HistogramIterator = typename HistogramType::ConstIterator; - HistogramIterator hit = tomergeHistogram->Begin(); - HistogramIterator end = tomergeHistogram->End(); + HistogramIterator hit = tomergeHistogram->Begin(); + const HistogramIterator end = tomergeHistogram->End(); typename HistogramType::IndexType index; @@ -308,8 +308,8 @@ ImageToHistogramFilter::ApplyMarginalScale(HistogramMeasurementVectorTyp { if (!NumericTraits::is_integer) { - HistogramMeasurementType marginalScale = this->GetMarginalScale(); - const double margin = + const HistogramMeasurementType marginalScale = this->GetMarginalScale(); + const double margin = (static_cast(max[i] - min[i]) / static_cast(size[i])) / static_cast(marginalScale); diff --git a/Modules/Numerics/Statistics/include/itkImageToListSampleAdaptor.h b/Modules/Numerics/Statistics/include/itkImageToListSampleAdaptor.h index 5e1cd3a34cb..998c1b55dcf 100644 --- a/Modules/Numerics/Statistics/include/itkImageToListSampleAdaptor.h +++ b/Modules/Numerics/Statistics/include/itkImageToListSampleAdaptor.h @@ -256,10 +256,10 @@ class ITK_TEMPLATE_EXPORT ImageToListSampleAdaptor Iterator Begin() { - ImagePointer nonConstImage = const_cast(m_Image.GetPointer()); - ImageIteratorType imageIterator(nonConstImage, nonConstImage->GetLargestPossibleRegion()); + const ImagePointer nonConstImage = const_cast(m_Image.GetPointer()); + ImageIteratorType imageIterator(nonConstImage, nonConstImage->GetLargestPossibleRegion()); imageIterator.GoToBegin(); - Iterator iter(imageIterator, 0); + const Iterator iter(imageIterator, 0); return iter; } @@ -267,11 +267,11 @@ class ITK_TEMPLATE_EXPORT ImageToListSampleAdaptor Iterator End() { - ImagePointer nonConstImage = const_cast(m_Image.GetPointer()); + const ImagePointer nonConstImage = const_cast(m_Image.GetPointer()); const typename ImageType::RegionType & largestRegion = nonConstImage->GetLargestPossibleRegion(); ImageIteratorType imageIterator(nonConstImage, largestRegion); imageIterator.GoToEnd(); - Iterator iter(imageIterator, largestRegion.GetNumberOfPixels()); + const Iterator iter(imageIterator, largestRegion.GetNumberOfPixels()); return iter; } @@ -282,7 +282,7 @@ class ITK_TEMPLATE_EXPORT ImageToListSampleAdaptor { ImageConstIteratorType imageConstIterator(m_Image, m_Image->GetLargestPossibleRegion()); imageConstIterator.GoToBegin(); - ConstIterator iter(imageConstIterator, 0); + const ConstIterator iter(imageConstIterator, 0); return iter; } @@ -294,7 +294,7 @@ class ITK_TEMPLATE_EXPORT ImageToListSampleAdaptor const typename ImageType::RegionType & largestRegion = m_Image->GetLargestPossibleRegion(); ImageConstIteratorType imageConstIterator(m_Image, largestRegion); imageConstIterator.GoToEnd(); - ConstIterator iter(imageConstIterator, largestRegion.GetNumberOfPixels()); + const ConstIterator iter(imageConstIterator, largestRegion.GetNumberOfPixels()); return iter; } diff --git a/Modules/Numerics/Statistics/include/itkImageToNeighborhoodSampleAdaptor.h b/Modules/Numerics/Statistics/include/itkImageToNeighborhoodSampleAdaptor.h index 5173683b6bb..a2f436c3735 100644 --- a/Modules/Numerics/Statistics/include/itkImageToNeighborhoodSampleAdaptor.h +++ b/Modules/Numerics/Statistics/include/itkImageToNeighborhoodSampleAdaptor.h @@ -275,7 +275,7 @@ class ITK_TEMPLATE_EXPORT ImageToNeighborhoodSampleAdaptor { NeighborhoodIteratorType nIterator(m_Radius, m_Image, m_Region); nIterator.GoToBegin(); - Iterator iter(nIterator, 0); + const Iterator iter(nIterator, 0); return iter; } @@ -285,7 +285,7 @@ class ITK_TEMPLATE_EXPORT ImageToNeighborhoodSampleAdaptor { NeighborhoodIteratorType nIterator(m_Radius, m_Image, m_Region); nIterator.GoToEnd(); - Iterator iter(nIterator, m_Region.GetNumberOfPixels()); + const Iterator iter(nIterator, m_Region.GetNumberOfPixels()); return iter; } diff --git a/Modules/Numerics/Statistics/include/itkImageToNeighborhoodSampleAdaptor.hxx b/Modules/Numerics/Statistics/include/itkImageToNeighborhoodSampleAdaptor.hxx index 6a3ca6f0904..173a14be27f 100644 --- a/Modules/Numerics/Statistics/include/itkImageToNeighborhoodSampleAdaptor.hxx +++ b/Modules/Numerics/Statistics/include/itkImageToNeighborhoodSampleAdaptor.hxx @@ -58,7 +58,7 @@ ImageToNeighborhoodSampleAdaptor::GetMeasurementVect ImageHelper::ComputeIndex( m_Region.GetIndex(), id, m_OffsetTable, reqIndex); - OffsetType offset = reqIndex - m_NeighborIndexInternal; + const OffsetType offset = reqIndex - m_NeighborIndexInternal; m_NeighborIndexInternal = reqIndex; m_MeasurementVectorInternal[0] += offset; @@ -238,7 +238,7 @@ template std::ostream & operator<<(std::ostream & os, const std::vector> & mv) { - itk::ConstNeighborhoodIterator nbhd = mv[0]; + const itk::ConstNeighborhoodIterator nbhd = mv[0]; os << "Neighborhood: " << std::endl; os << " Radius: " << nbhd.GetRadius() << std::endl; os << " Size: " << nbhd.GetSize() << std::endl; diff --git a/Modules/Numerics/Statistics/include/itkJointDomainImageToListSampleAdaptor.h b/Modules/Numerics/Statistics/include/itkJointDomainImageToListSampleAdaptor.h index ac737293f35..04736899994 100644 --- a/Modules/Numerics/Statistics/include/itkJointDomainImageToListSampleAdaptor.h +++ b/Modules/Numerics/Statistics/include/itkJointDomainImageToListSampleAdaptor.h @@ -295,7 +295,7 @@ class ITK_TEMPLATE_EXPORT JointDomainImageToListSampleAdaptor Iterator Begin() { - Iterator iter(this, 0); + const Iterator iter(this, 0); return iter; } @@ -304,7 +304,7 @@ class ITK_TEMPLATE_EXPORT JointDomainImageToListSampleAdaptor Iterator End() { - Iterator iter(this, m_Image->GetPixelContainer()->Size()); + const Iterator iter(this, m_Image->GetPixelContainer()->Size()); return iter; } diff --git a/Modules/Numerics/Statistics/include/itkKalmanLinearEstimator.h b/Modules/Numerics/Statistics/include/itkKalmanLinearEstimator.h index 42fcc8e623d..7d23643ff5e 100644 --- a/Modules/Numerics/Statistics/include/itkKalmanLinearEstimator.h +++ b/Modules/Numerics/Statistics/include/itkKalmanLinearEstimator.h @@ -151,9 +151,9 @@ void KalmanLinearEstimator::UpdateWithNewMeasure(const ValueType & newMeasure, const VectorType & newPredictor) { - ValueType measurePrediction = dot_product(newPredictor, m_Estimator); + const ValueType measurePrediction = dot_product(newPredictor, m_Estimator); - ValueType errorMeasurePrediction = newMeasure - measurePrediction; + const ValueType errorMeasurePrediction = newMeasure - measurePrediction; VectorType Corrector = m_Variance * newPredictor; @@ -171,7 +171,7 @@ KalmanLinearEstimator::UpdateVariance(const VectorType & { VectorType aux = m_Variance * newPredictor; - ValueType denominator = 1.0 / (1.0 + dot_product(aux, newPredictor)); + const ValueType denominator = 1.0 / (1.0 + dot_product(aux, newPredictor)); for (unsigned int col = 0; col < VEstimatorDimension; ++col) { diff --git a/Modules/Numerics/Statistics/include/itkKdTree.hxx b/Modules/Numerics/Statistics/include/itkKdTree.hxx index 03a8d1da128..f99e917b55c 100644 --- a/Modules/Numerics/Statistics/include/itkKdTree.hxx +++ b/Modules/Numerics/Statistics/include/itkKdTree.hxx @@ -478,7 +478,7 @@ KdTree::BoundsOverlapBall(const MeasurementVectorType & query, MeasurementVectorType & upperBound, double radius) const { - double squaredSearchRadius = itk::Math::sqr(radius); + const double squaredSearchRadius = itk::Math::sqr(radius); double sum = 0.0; for (unsigned int d = 0; d < this->m_MeasurementVectorSize; ++d) @@ -591,7 +591,7 @@ KdTree::PlotTree(KdTreeNodeType * node, std::ostream & os) const KdTreeNodeType * left = node->Left(); KdTreeNodeType * right = node->Right(); - char partitionDimensionCharSymbol = ('X' + partitionDimension); + const char partitionDimensionCharSymbol = ('X' + partitionDimension); if (node->IsTerminal()) { diff --git a/Modules/Numerics/Statistics/include/itkKdTreeBasedKmeansEstimator.hxx b/Modules/Numerics/Statistics/include/itkKdTreeBasedKmeansEstimator.hxx index 882e0e195c5..4bf7b1b8dfe 100644 --- a/Modules/Numerics/Statistics/include/itkKdTreeBasedKmeansEstimator.hxx +++ b/Modules/Numerics/Statistics/include/itkKdTreeBasedKmeansEstimator.hxx @@ -150,9 +150,9 @@ KdTreeBasedKmeansEstimator::Filter(KdTreeNodeType * node, for (unsigned int i = 0; i < static_cast(node->Size()); ++i) { - typename TKdTree::InstanceIdentifier tempId = node->GetInstanceIdentifier(i); + const typename TKdTree::InstanceIdentifier tempId = node->GetInstanceIdentifier(i); this->GetPoint(individualPoint, m_KdTree->GetMeasurementVector(tempId)); - int closest = this->GetClosestCandidate(individualPoint, validIndexes); + const int closest = this->GetClosestCandidate(individualPoint, validIndexes); for (unsigned int j = 0; j < m_MeasurementVectorSize; ++j) { m_CandidateVector[closest].WeightedCentroid[j] += individualPoint[j]; @@ -171,7 +171,7 @@ KdTreeBasedKmeansEstimator::Filter(KdTreeNodeType * node, CentroidType centroid; node->GetCentroid(centroid); - int closest = this->GetClosestCandidate(centroid, validIndexes); + const int closest = this->GetClosestCandidate(centroid, validIndexes); ParameterType closestPosition = m_CandidateVector[closest].Centroid; auto iter = validIndexes.begin(); @@ -392,18 +392,19 @@ KdTreeBasedKmeansEstimator::GetOutput() const -> const MembershipFuncti { // INSERT CHECKS if all the required inputs are set and optimization has been // run. - unsigned int numberOfClasses = m_Parameters.size() / m_MeasurementVectorSize; + const unsigned int numberOfClasses = m_Parameters.size() / m_MeasurementVectorSize; MembershipFunctionVectorType & membershipFunctionsVector = m_MembershipFunctionsObject->Get(); for (unsigned int i = 0; i < numberOfClasses; ++i) { - DistanceToCentroidMembershipFunctionPointer membershipFunction = DistanceToCentroidMembershipFunctionType::New(); + const DistanceToCentroidMembershipFunctionPointer membershipFunction = + DistanceToCentroidMembershipFunctionType::New(); membershipFunction->SetMeasurementVectorSize(m_MeasurementVectorSize); typename DistanceToCentroidMembershipFunctionType::CentroidType centroid; centroid.SetSize(m_MeasurementVectorSize); for (unsigned int j = 0; j < m_MeasurementVectorSize; ++j) { - unsigned int parameterIndex = i * m_MeasurementVectorSize + j; + const unsigned int parameterIndex = i * m_MeasurementVectorSize + j; centroid[j] = m_Parameters[parameterIndex]; } membershipFunction->SetCentroid(centroid); diff --git a/Modules/Numerics/Statistics/include/itkKdTreeGenerator.hxx b/Modules/Numerics/Statistics/include/itkKdTreeGenerator.hxx index 501cb1c3956..54b9ac0fecc 100644 --- a/Modules/Numerics/Statistics/include/itkKdTreeGenerator.hxx +++ b/Modules/Numerics/Statistics/include/itkKdTreeGenerator.hxx @@ -88,7 +88,7 @@ KdTreeGenerator::GenerateData() m_Tree->SetBucketSize(m_BucketSize); } - SubsamplePointer subsample = this->GetSubsample(); + const SubsamplePointer subsample = this->GetSubsample(); // Sanity check. Verify that the subsample has measurement vectors of the // same length as the sample generated by the tree. @@ -130,7 +130,7 @@ KdTreeGenerator::GenerateNonterminalNode(unsigned int beginI MeasurementType maxSpread; unsigned int medianIndex; - SubsamplePointer subsample = this->GetSubsample(); + const SubsamplePointer subsample = this->GetSubsample(); // find most widely spread dimension Algorithm::FindSampleBoundAndMean( diff --git a/Modules/Numerics/Statistics/include/itkListSample.h b/Modules/Numerics/Statistics/include/itkListSample.h index c90ef4381ca..6f0b9cec103 100644 --- a/Modules/Numerics/Statistics/include/itkListSample.h +++ b/Modules/Numerics/Statistics/include/itkListSample.h @@ -245,7 +245,7 @@ class ITK_TEMPLATE_EXPORT ListSample : public Sample Iterator Begin() { - Iterator iter(m_InternalContainer.begin(), 0); + const Iterator iter(m_InternalContainer.begin(), 0); return iter; } @@ -254,7 +254,7 @@ class ITK_TEMPLATE_EXPORT ListSample : public Sample Iterator End() { - Iterator iter(m_InternalContainer.end(), static_cast(m_InternalContainer.size())); + const Iterator iter(m_InternalContainer.end(), static_cast(m_InternalContainer.size())); return iter; } @@ -263,7 +263,7 @@ class ITK_TEMPLATE_EXPORT ListSample : public Sample ConstIterator Begin() const { - ConstIterator iter(m_InternalContainer.begin(), 0); + const ConstIterator iter(m_InternalContainer.begin(), 0); return iter; } @@ -272,7 +272,7 @@ class ITK_TEMPLATE_EXPORT ListSample : public Sample ConstIterator End() const { - ConstIterator iter(m_InternalContainer.end(), static_cast(m_InternalContainer.size())); + const ConstIterator iter(m_InternalContainer.end(), static_cast(m_InternalContainer.size())); return iter; } diff --git a/Modules/Numerics/Statistics/include/itkMahalanobisDistanceMembershipFunction.hxx b/Modules/Numerics/Statistics/include/itkMahalanobisDistanceMembershipFunction.hxx index 809f24a835d..dfe61f27119 100644 --- a/Modules/Numerics/Statistics/include/itkMahalanobisDistanceMembershipFunction.hxx +++ b/Modules/Numerics/Statistics/include/itkMahalanobisDistanceMembershipFunction.hxx @@ -96,10 +96,10 @@ MahalanobisDistanceMembershipFunction::SetCovariance(const CovarianceMa m_Covariance = cov; // the inverse of the covariance matrix is first computed by SVD - vnl_matrix_inverse inv_cov(m_Covariance.GetVnlMatrix()); + const vnl_matrix_inverse inv_cov(m_Covariance.GetVnlMatrix()); // the determinant is then costless this way - double det = inv_cov.determinant_magnitude(); + const double det = inv_cov.determinant_magnitude(); if (det < 0.) { @@ -176,8 +176,8 @@ template typename LightObject::Pointer MahalanobisDistanceMembershipFunction::InternalClone() const { - LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer membershipFunction = dynamic_cast(loPtr.GetPointer()); + LightObject::Pointer loPtr = Superclass::InternalClone(); + const typename Self::Pointer membershipFunction = dynamic_cast(loPtr.GetPointer()); if (membershipFunction.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Numerics/Statistics/include/itkMahalanobisDistanceMetric.hxx b/Modules/Numerics/Statistics/include/itkMahalanobisDistanceMetric.hxx index 4f19057fedf..778ac34527b 100644 --- a/Modules/Numerics/Statistics/include/itkMahalanobisDistanceMetric.hxx +++ b/Modules/Numerics/Statistics/include/itkMahalanobisDistanceMetric.hxx @@ -27,7 +27,7 @@ template MahalanobisDistanceMetric::MahalanobisDistanceMetric() { - MeasurementVectorSizeType size = this->GetMeasurementVectorSize(); + const MeasurementVectorSizeType size = this->GetMeasurementVectorSize(); this->m_Covariance.set_size(size, size); this->m_InverseCovariance.set_size(size, size); @@ -156,7 +156,7 @@ MahalanobisDistanceMetric::Evaluate(const MeasurementVectorType & measu tempMat = tempVec * m_InverseCovariance; // Compute |y - mean | * inverse(cov) * |y - mean|^T - double temp = std::sqrt(dot_product(tempMat.as_ref(), tempVec.as_ref())); + const double temp = std::sqrt(dot_product(tempMat.as_ref(), tempVec.as_ref())); return temp; } @@ -188,7 +188,7 @@ MahalanobisDistanceMetric::Evaluate(const MeasurementVectorType & x1, c tempMat = tempVec * m_InverseCovariance; // Compute |x1 - x2 | * inverse(cov) * |x1 - x2|^T - double temp = std::sqrt(dot_product(tempMat.as_ref(), tempVec.as_ref())); + const double temp = std::sqrt(dot_product(tempMat.as_ref(), tempVec.as_ref())); return temp; } diff --git a/Modules/Numerics/Statistics/include/itkManhattanDistanceMetric.hxx b/Modules/Numerics/Statistics/include/itkManhattanDistanceMetric.hxx index a6a7aa00ea7..0fc0653ba8e 100644 --- a/Modules/Numerics/Statistics/include/itkManhattanDistanceMetric.hxx +++ b/Modules/Numerics/Statistics/include/itkManhattanDistanceMetric.hxx @@ -27,7 +27,7 @@ template inline double ManhattanDistanceMetric::Evaluate(const MeasurementVectorType & x) const { - MeasurementVectorSizeType measurementVectorSize = this->GetMeasurementVectorSize(); + const MeasurementVectorSizeType measurementVectorSize = this->GetMeasurementVectorSize(); if (measurementVectorSize == 0) { @@ -40,7 +40,7 @@ ManhattanDistanceMetric::Evaluate(const MeasurementVectorType & x) cons double distance = 0.0; for (unsigned int i = 0; i < measurementVectorSize; ++i) { - double temp = itk::Math::abs(this->GetOrigin()[i] - x[i]); + const double temp = itk::Math::abs(this->GetOrigin()[i] - x[i]); distance += temp; } return distance; @@ -50,7 +50,7 @@ template inline double ManhattanDistanceMetric::Evaluate(const MeasurementVectorType & x1, const MeasurementVectorType & x2) const { - MeasurementVectorSizeType measurementVectorSize = NumericTraits::GetLength(x1); + const MeasurementVectorSizeType measurementVectorSize = NumericTraits::GetLength(x1); if (measurementVectorSize != NumericTraits::GetLength(x2)) { @@ -60,7 +60,7 @@ ManhattanDistanceMetric::Evaluate(const MeasurementVectorType & x1, con double distance = 0.0; for (unsigned int i = 0; i < measurementVectorSize; ++i) { - double temp = itk::Math::abs(x1[i] - x2[i]); + const double temp = itk::Math::abs(x1[i] - x2[i]); distance += temp; } return distance; diff --git a/Modules/Numerics/Statistics/include/itkMaskedImageToHistogramFilter.hxx b/Modules/Numerics/Statistics/include/itkMaskedImageToHistogramFilter.hxx index 28a6bc0ccd8..d93461ba5ed 100644 --- a/Modules/Numerics/Statistics/include/itkMaskedImageToHistogramFilter.hxx +++ b/Modules/Numerics/Statistics/include/itkMaskedImageToHistogramFilter.hxx @@ -37,11 +37,11 @@ void MaskedImageToHistogramFilter::ThreadedComputeMinimumAndMaximum( const RegionType & inputRegionForThread) { - unsigned int nbOfComponents = this->GetInput()->GetNumberOfComponentsPerPixel(); + const unsigned int nbOfComponents = this->GetInput()->GetNumberOfComponentsPerPixel(); HistogramMeasurementVectorType min(nbOfComponents); HistogramMeasurementVectorType max(nbOfComponents); - MaskPixelType maskValue = this->GetMaskValue(); + const MaskPixelType maskValue = this->GetMaskValue(); ImageRegionConstIterator inputIt(this->GetInput(), inputRegionForThread); ImageRegionConstIterator maskIt(this->GetMaskImage(), inputRegionForThread); @@ -91,7 +91,7 @@ MaskedImageToHistogramFilter::ThreadedStreamedGenerateData(c inputIt.GoToBegin(); maskIt.GoToBegin(); HistogramMeasurementVectorType m(nbOfComponents); - MaskPixelType maskValue = this->GetMaskValue(); + const MaskPixelType maskValue = this->GetMaskValue(); typename HistogramType::IndexType index; while (!inputIt.IsAtEnd()) diff --git a/Modules/Numerics/Statistics/include/itkMeasurementVectorTraits.h b/Modules/Numerics/Statistics/include/itkMeasurementVectorTraits.h index d9767982902..931a053450a 100644 --- a/Modules/Numerics/Statistics/include/itkMeasurementVectorTraits.h +++ b/Modules/Numerics/Statistics/include/itkMeasurementVectorTraits.h @@ -65,7 +65,7 @@ class MeasurementVectorTraits // If the default constructor creates a vector of // length zero, we assume that it is resizable, // otherwise that is a pretty useless measurement vector. - MeasurementVectorLength len = NumericTraits::GetLength({}); + const MeasurementVectorLength len = NumericTraits::GetLength({}); return (len == 0); } diff --git a/Modules/Numerics/Statistics/include/itkMembershipFunctionBase.h b/Modules/Numerics/Statistics/include/itkMembershipFunctionBase.h index 0e54ffac8f2..68732a28029 100644 --- a/Modules/Numerics/Statistics/include/itkMembershipFunctionBase.h +++ b/Modules/Numerics/Statistics/include/itkMembershipFunctionBase.h @@ -110,7 +110,7 @@ class ITK_TEMPLATE_EXPORT MembershipFunctionBase : public FunctionBase::GetLength({}); + const MeasurementVectorSizeType defaultLength = NumericTraits::GetLength({}); // and the new length is different from the default one, then throw an // exception if (defaultLength != s) diff --git a/Modules/Numerics/Statistics/include/itkMembershipSample.h b/Modules/Numerics/Statistics/include/itkMembershipSample.h index 7029b4a0ce7..828a5ec3124 100644 --- a/Modules/Numerics/Statistics/include/itkMembershipSample.h +++ b/Modules/Numerics/Statistics/include/itkMembershipSample.h @@ -273,7 +273,7 @@ class ITK_TEMPLATE_EXPORT MembershipSample : public DataObject Iterator Begin() { - Iterator iter(this, 0); + const Iterator iter(this, 0); return iter; } @@ -283,7 +283,7 @@ class ITK_TEMPLATE_EXPORT MembershipSample : public DataObject Iterator End() { - Iterator iter(this, m_Sample->Size()); + const Iterator iter(this, m_Sample->Size()); return iter; } @@ -291,7 +291,7 @@ class ITK_TEMPLATE_EXPORT MembershipSample : public DataObject ConstIterator Begin() const { - ConstIterator iter(this, 0); + const ConstIterator iter(this, 0); return iter; } @@ -299,7 +299,7 @@ class ITK_TEMPLATE_EXPORT MembershipSample : public DataObject ConstIterator End() const { - ConstIterator iter(this, m_Sample->Size()); + const ConstIterator iter(this, m_Sample->Size()); return iter; } diff --git a/Modules/Numerics/Statistics/include/itkMembershipSample.hxx b/Modules/Numerics/Statistics/include/itkMembershipSample.hxx index 7a7ef04b1c2..744cd8cb02d 100644 --- a/Modules/Numerics/Statistics/include/itkMembershipSample.hxx +++ b/Modules/Numerics/Statistics/include/itkMembershipSample.hxx @@ -90,7 +90,7 @@ template auto MembershipSample::GetClassSample(const ClassLabelType & classLabel) const -> const ClassSampleType * { - int classIndex = this->GetInternalClassLabel(classLabel); + const int classIndex = this->GetInternalClassLabel(classLabel); if (classIndex < 0) { return nullptr; diff --git a/Modules/Numerics/Statistics/include/itkPointSetToListSampleAdaptor.h b/Modules/Numerics/Statistics/include/itkPointSetToListSampleAdaptor.h index 98d8f4ac7ac..80203d45952 100644 --- a/Modules/Numerics/Statistics/include/itkPointSetToListSampleAdaptor.h +++ b/Modules/Numerics/Statistics/include/itkPointSetToListSampleAdaptor.h @@ -222,8 +222,9 @@ class ITK_TEMPLATE_EXPORT PointSetToListSampleAdaptor : public ListSample(m_PointsContainer.GetPointer()); - Iterator iter(nonConstPointsDataContainer->Begin(), 0); + const PointsContainerPointer nonConstPointsDataContainer = + const_cast(m_PointsContainer.GetPointer()); + const Iterator iter(nonConstPointsDataContainer->Begin(), 0); return iter; } @@ -232,9 +233,10 @@ class ITK_TEMPLATE_EXPORT PointSetToListSampleAdaptor : public ListSample(m_PointsContainer.GetPointer()); + const PointsContainerPointer nonConstPointsDataContainer = + const_cast(m_PointsContainer.GetPointer()); - Iterator iter(nonConstPointsDataContainer->End(), m_PointsContainer->Size()); + const Iterator iter(nonConstPointsDataContainer->End(), m_PointsContainer->Size()); return iter; } @@ -243,7 +245,7 @@ class ITK_TEMPLATE_EXPORT PointSetToListSampleAdaptor : public ListSampleBegin(), 0); + const ConstIterator iter(m_PointsContainer->Begin(), 0); return iter; } @@ -252,7 +254,7 @@ class ITK_TEMPLATE_EXPORT PointSetToListSampleAdaptor : public ListSampleEnd(), m_PointsContainer->Size()); + const ConstIterator iter(m_PointsContainer->End(), m_PointsContainer->Size()); return iter; } diff --git a/Modules/Numerics/Statistics/include/itkRegionConstrainedSubsampler.hxx b/Modules/Numerics/Statistics/include/itkRegionConstrainedSubsampler.hxx index dcb8f4f33be..d33fbc15f91 100644 --- a/Modules/Numerics/Statistics/include/itkRegionConstrainedSubsampler.hxx +++ b/Modules/Numerics/Statistics/include/itkRegionConstrainedSubsampler.hxx @@ -37,7 +37,7 @@ RegionConstrainedSubsampler::InternalClone() const { typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Numerics/Statistics/include/itkSample.h b/Modules/Numerics/Statistics/include/itkSample.h index 27773757171..c66502176e7 100644 --- a/Modules/Numerics/Statistics/include/itkSample.h +++ b/Modules/Numerics/Statistics/include/itkSample.h @@ -143,7 +143,7 @@ class Sample : public DataObject else { // If this is a non-resizable vector type - MeasurementVectorSizeType defaultLength = NumericTraits::GetLength({}); + const MeasurementVectorSizeType defaultLength = NumericTraits::GetLength({}); // and the new length is different from the default one, then throw an // exception if (defaultLength != s) diff --git a/Modules/Numerics/Statistics/include/itkSampleClassifierFilter.hxx b/Modules/Numerics/Statistics/include/itkSampleClassifierFilter.hxx index 896468a0829..cb2ced57946 100644 --- a/Modules/Numerics/Statistics/include/itkSampleClassifierFilter.hxx +++ b/Modules/Numerics/Statistics/include/itkSampleClassifierFilter.hxx @@ -155,12 +155,12 @@ SampleClassifierFilter::GenerateData() output->SetSample(this->GetInput()); output->SetNumberOfClasses(this->m_NumberOfClasses); - typename TSample::ConstIterator iter = sample->Begin(); - typename TSample::ConstIterator end = sample->End(); + typename TSample::ConstIterator iter = sample->Begin(); + const typename TSample::ConstIterator end = sample->End(); while (iter != end) { - typename TSample::MeasurementVectorType measurements = iter.GetMeasurementVector(); + const typename TSample::MeasurementVectorType measurements = iter.GetMeasurementVector(); for (unsigned int i = 0; i < this->m_NumberOfClasses; ++i) { discriminantScores[i] = membershipFunctionsWeightsArray[i] * membershipFunctions[i]->Evaluate(measurements); diff --git a/Modules/Numerics/Statistics/include/itkSampleToHistogramFilter.hxx b/Modules/Numerics/Statistics/include/itkSampleToHistogramFilter.hxx index e4f3c661f65..4de60ef3e85 100644 --- a/Modules/Numerics/Statistics/include/itkSampleToHistogramFilter.hxx +++ b/Modules/Numerics/Statistics/include/itkSampleToHistogramFilter.hxx @@ -125,7 +125,7 @@ SampleToHistogramFilter::GenerateData() HistogramSizeType histogramSize = histogramSizeObject->Get(); - HistogramMeasurementType marginalScale = marginalScaleObject->Get(); + const HistogramMeasurementType marginalScale = marginalScaleObject->Get(); auto * outputHistogram = static_cast(this->ProcessObject::GetOutput(0)); @@ -249,8 +249,8 @@ SampleToHistogramFilter::GenerateData() // the upper and lower bound from the FindSampleBound function outputHistogram->Initialize(histogramSize, h_lower, h_upper); - typename SampleType::ConstIterator iter = inputSample->Begin(); - typename SampleType::ConstIterator last = inputSample->End(); + typename SampleType::ConstIterator iter = inputSample->Begin(); + const typename SampleType::ConstIterator last = inputSample->End(); typename SampleType::MeasurementVectorType lvector; diff --git a/Modules/Numerics/Statistics/include/itkScalarImageToCooccurrenceListSampleFilter.hxx b/Modules/Numerics/Statistics/include/itkScalarImageToCooccurrenceListSampleFilter.hxx index d7ca2677c3e..c681396c53d 100644 --- a/Modules/Numerics/Statistics/include/itkScalarImageToCooccurrenceListSampleFilter.hxx +++ b/Modules/Numerics/Statistics/include/itkScalarImageToCooccurrenceListSampleFilter.hxx @@ -95,9 +95,9 @@ ScalarImageToCooccurrenceListSampleFilter::GenerateData() output->SetMeasurementVectorSize(measurementVectorSize); - typename FaceCalculatorType::FaceListType faceList = faceCalculator(input, input->GetRequestedRegion(), radius); + const typename FaceCalculatorType::FaceListType faceList = faceCalculator(input, input->GetRequestedRegion(), radius); - OffsetType center_offset{}; + const OffsetType center_offset{}; bool isInside; diff --git a/Modules/Numerics/Statistics/include/itkScalarImageToCooccurrenceMatrixFilter.hxx b/Modules/Numerics/Statistics/include/itkScalarImageToCooccurrenceMatrixFilter.hxx index 9f2d283eef6..91fbe603889 100644 --- a/Modules/Numerics/Statistics/include/itkScalarImageToCooccurrenceMatrixFilter.hxx +++ b/Modules/Numerics/Statistics/include/itkScalarImageToCooccurrenceMatrixFilter.hxx @@ -64,7 +64,7 @@ void ScalarImageToCooccurrenceMatrixFilter::SetOffset( const OffsetType offset) { - OffsetVectorPointer offsetVector = OffsetVector::New(); + const OffsetVectorPointer offsetVector = OffsetVector::New(); offsetVector->push_back(offset); this->SetOffsets(offsetVector); @@ -146,7 +146,7 @@ ScalarImageToCooccurrenceMatrixFilter minRadius) { minRadius = distance; @@ -325,7 +325,7 @@ ScalarImageToCooccurrenceMatrixFilter(this->ProcessObject::GetOutput(0)); - typename HistogramType::AbsoluteFrequencyType totalFrequency = output->GetTotalFrequency(); + const typename HistogramType::AbsoluteFrequencyType totalFrequency = output->GetTotalFrequency(); typename HistogramType::Iterator hit = output->Begin(); while (hit != output->End()) diff --git a/Modules/Numerics/Statistics/include/itkScalarImageToRunLengthFeaturesFilter.hxx b/Modules/Numerics/Statistics/include/itkScalarImageToRunLengthFeaturesFilter.hxx index e7276f57e62..91fa637cfa7 100644 --- a/Modules/Numerics/Statistics/include/itkScalarImageToRunLengthFeaturesFilter.hxx +++ b/Modules/Numerics/Statistics/include/itkScalarImageToRunLengthFeaturesFilter.hxx @@ -44,7 +44,7 @@ ScalarImageToRunLengthFeaturesFilter::Scal // Set the requested features to the default value: // {Energy, Entropy, InverseDifferenceMoment, Inertia, ClusterShade, // ClusterProminence} - FeatureNameVectorPointer requestedFeatures = FeatureNameVector::New(); + const FeatureNameVectorPointer requestedFeatures = FeatureNameVector::New(); // can't directly set this->m_RequestedFeatures since it is const! requestedFeatures->push_back(static_cast(itk::Statistics::RunLengthFeatureEnum::ShortRunEmphasis)); @@ -73,11 +73,11 @@ ScalarImageToRunLengthFeaturesFilter::Scal // select all "previous" neighbors that are face+edge+vertex // connected to the current pixel. do not include the center pixel. - unsigned int centerIndex = hood.GetCenterNeighborhoodIndex(); - OffsetVectorPointer offsets = OffsetVector::New(); + const unsigned int centerIndex = hood.GetCenterNeighborhoodIndex(); + const OffsetVectorPointer offsets = OffsetVector::New(); for (unsigned int d = 0; d < centerIndex; ++d) { - OffsetType offset = hood.GetOffset(d); + const OffsetType offset = hood.GetOffset(d); offsets->push_back(offset); } this->SetOffsets(offsets); @@ -110,9 +110,9 @@ template void ScalarImageToRunLengthFeaturesFilter::FullCompute() { - size_t numOffsets = this->m_Offsets->size(); - size_t numFeatures = this->m_RequestedFeatures->size(); - double ** features = new double *[numOffsets]; + const size_t numOffsets = this->m_Offsets->size(); + const size_t numFeatures = this->m_RequestedFeatures->size(); + double ** features = new double *[numOffsets]; for (size_t i = 0; i < numOffsets; ++i) { features[i] = new double[numFeatures]; @@ -170,15 +170,15 @@ ScalarImageToRunLengthFeaturesFilter::Full // Run through the recurrence (k = 2 ... N) for (size_t offsetNum = 1; offsetNum < numOffsets; ++offsetNum) { - int k = offsetNum + 1; + const int k = offsetNum + 1; for (size_t featureNum = 0; featureNum < numFeatures; ++featureNum) { - double M_k_minus_1 = tempFeatureMeans[featureNum]; - double S_k_minus_1 = tempFeatureDevs[featureNum]; - double x_k = features[offsetNum][featureNum]; + const double M_k_minus_1 = tempFeatureMeans[featureNum]; + const double S_k_minus_1 = tempFeatureDevs[featureNum]; + const double x_k = features[offsetNum][featureNum]; - double M_k = M_k_minus_1 + (x_k - M_k_minus_1) / k; - double S_k = S_k_minus_1 + (x_k - M_k_minus_1) * (x_k - M_k); + const double M_k = M_k_minus_1 + (x_k - M_k_minus_1) / k; + const double S_k = S_k_minus_1 + (x_k - M_k_minus_1) * (x_k - M_k); tempFeatureMeans[featureNum] = M_k; tempFeatureDevs[featureNum] = S_k; @@ -212,7 +212,7 @@ void ScalarImageToRunLengthFeaturesFilter::FastCompute() { // Compute the feature for the first offset - typename OffsetVector::ConstIterator offsetIt = this->m_Offsets->Begin(); + const typename OffsetVector::ConstIterator offsetIt = this->m_Offsets->Begin(); this->m_RunLengthMatrixGenerator->SetOffset(offsetIt.Value()); this->m_RunLengthMatrixGenerator->Update(); diff --git a/Modules/Numerics/Statistics/include/itkScalarImageToRunLengthMatrixFilter.hxx b/Modules/Numerics/Statistics/include/itkScalarImageToRunLengthMatrixFilter.hxx index 1876bdcf906..f9fb5e54fa9 100644 --- a/Modules/Numerics/Statistics/include/itkScalarImageToRunLengthMatrixFilter.hxx +++ b/Modules/Numerics/Statistics/include/itkScalarImageToRunLengthMatrixFilter.hxx @@ -60,7 +60,7 @@ template void ScalarImageToRunLengthMatrixFilter::SetOffset(const OffsetType offset) { - OffsetVectorPointer offsetVector = OffsetVector::New(); + const OffsetVectorPointer offsetVector = OffsetVector::New(); offsetVector->push_back(offset); this->SetOffsets(offsetVector); } @@ -174,7 +174,7 @@ ScalarImageToRunLengthMatrixFilter::Ge for (neighborIt.GoToBegin(); !neighborIt.IsAtEnd(); ++neighborIt) { const PixelType centerPixelIntensity = neighborIt.GetCenterPixel(); - IndexType centerIndex = neighborIt.GetIndex(); + const IndexType centerIndex = neighborIt.GetIndex(); if (centerPixelIntensity < this->m_Min || centerPixelIntensity > this->m_Max || alreadyVisitedImage->GetPixel(centerIndex) || (this->GetMaskImage() && this->GetMaskImage()->GetPixel(centerIndex) != this->m_InsidePixelValue)) @@ -185,9 +185,9 @@ ScalarImageToRunLengthMatrixFilter::Ge itkDebugMacro("===> offset = " << offset << std::endl); - MeasurementType centerBinMin = this->GetOutput()->GetBinMinFromValue(0, centerPixelIntensity); - MeasurementType centerBinMax = this->GetOutput()->GetBinMaxFromValue(0, centerPixelIntensity); - MeasurementType lastBinMax = this->GetOutput()->GetDimensionMaxs(0)[this->GetOutput()->GetSize(0) - 1]; + const MeasurementType centerBinMin = this->GetOutput()->GetBinMinFromValue(0, centerPixelIntensity); + const MeasurementType centerBinMax = this->GetOutput()->GetBinMaxFromValue(0, centerPixelIntensity); + const MeasurementType lastBinMax = this->GetOutput()->GetDimensionMaxs(0)[this->GetOutput()->GetSize(0) - 1]; PixelType pixelIntensity(PixelType{}); IndexType index = centerIndex + offset; diff --git a/Modules/Numerics/Statistics/include/itkScalarImageToTextureFeaturesFilter.hxx b/Modules/Numerics/Statistics/include/itkScalarImageToTextureFeaturesFilter.hxx index 5937584bae8..5e3e603ee24 100644 --- a/Modules/Numerics/Statistics/include/itkScalarImageToTextureFeaturesFilter.hxx +++ b/Modules/Numerics/Statistics/include/itkScalarImageToTextureFeaturesFilter.hxx @@ -46,7 +46,7 @@ ScalarImageToTextureFeaturesFilterpush_back( static_cast(itk::Statistics::HistogramToTextureFeaturesFilterEnums::TextureFeature::Energy)); @@ -72,9 +72,9 @@ ScalarImageToTextureFeaturesFilter::FullCompute() { - size_t numOffsets = m_Offsets->size(); - size_t numFeatures = m_RequestedFeatures->size(); - double ** features = new double *[numOffsets]; + const size_t numOffsets = m_Offsets->size(); + const size_t numFeatures = m_RequestedFeatures->size(); + double ** features = new double *[numOffsets]; for (size_t i = 0; i < numOffsets; ++i) { features[i] = new double[numFeatures]; @@ -163,15 +163,15 @@ ScalarImageToTextureFeaturesFilter::FastCompute() { // Compute the feature for the first offset - typename OffsetVector::ConstIterator offsetIt = m_Offsets->Begin(); + const typename OffsetVector::ConstIterator offsetIt = m_Offsets->Begin(); this->m_GLCMGenerator->SetOffset(offsetIt.Value()); this->m_GLCMCalculator->Update(); diff --git a/Modules/Numerics/Statistics/include/itkSpatialNeighborSubsampler.hxx b/Modules/Numerics/Statistics/include/itkSpatialNeighborSubsampler.hxx index d1050c2ca10..9030f68436c 100644 --- a/Modules/Numerics/Statistics/include/itkSpatialNeighborSubsampler.hxx +++ b/Modules/Numerics/Statistics/include/itkSpatialNeighborSubsampler.hxx @@ -37,7 +37,7 @@ SpatialNeighborSubsampler::InternalClone() const { typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Numerics/Statistics/include/itkStandardDeviationPerComponentSampleFilter.hxx b/Modules/Numerics/Statistics/include/itkStandardDeviationPerComponentSampleFilter.hxx index 40d934ae09e..fff6f3e58f4 100644 --- a/Modules/Numerics/Statistics/include/itkStandardDeviationPerComponentSampleFilter.hxx +++ b/Modules/Numerics/Statistics/include/itkStandardDeviationPerComponentSampleFilter.hxx @@ -113,7 +113,7 @@ StandardDeviationPerComponentSampleFilter::GenerateData() { const SampleType * input = this->GetInput(); - MeasurementVectorSizeType measurementVectorSize = input->GetMeasurementVectorSize(); + const MeasurementVectorSizeType measurementVectorSize = input->GetMeasurementVectorSize(); auto * decoratedStandardDeviationOutput = itkDynamicCastInDebugMode(this->ProcessObject::GetOutput(0)); @@ -141,8 +141,8 @@ StandardDeviationPerComponentSampleFilter::GenerateData() using TotalAbsoluteFrequencyType = typename TSample::TotalAbsoluteFrequencyType; TotalAbsoluteFrequencyType totalFrequency{}; - typename TSample::ConstIterator iter = input->Begin(); - typename TSample::ConstIterator end = input->End(); + typename TSample::ConstIterator iter = input->Begin(); + const typename TSample::ConstIterator end = input->End(); MeasurementVectorType diff; MeasurementVectorType measurements; @@ -159,7 +159,7 @@ StandardDeviationPerComponentSampleFilter::GenerateData() for (unsigned int i = 0; i < measurementVectorSize; ++i) { - double value = measurements[i]; + const double value = measurements[i]; sum[i] += frequency * value; sumOfSquares[i] += frequency * value * value; } diff --git a/Modules/Numerics/Statistics/include/itkStatisticsAlgorithm.hxx b/Modules/Numerics/Statistics/include/itkStatisticsAlgorithm.hxx index c50af28e1ba..2692244378d 100644 --- a/Modules/Numerics/Statistics/include/itkStatisticsAlgorithm.hxx +++ b/Modules/Numerics/Statistics/include/itkStatisticsAlgorithm.hxx @@ -143,7 +143,7 @@ Partition(TSubsample * sample, // partitionValue, that were placed at the end of the list, and move them to // the interface between smaller and larger values. // - int beginOfSectionEqualToPartition = moveToFrontIndex; + const int beginOfSectionEqualToPartition = moveToFrontIndex; moveToBackIndex = endIndex - 1; while (moveToFrontIndex < moveToBackIndex) { @@ -181,9 +181,9 @@ Partition(TSubsample * sample, sample->Swap(moveToBackIndex, moveToFrontIndex); } } - int endOfSectionEqualToPartition = moveToFrontIndex - 1; + const int endOfSectionEqualToPartition = moveToFrontIndex - 1; - int storeIndex = (beginOfSectionEqualToPartition + endOfSectionEqualToPartition) / 2; + const int storeIndex = (beginOfSectionEqualToPartition + endOfSectionEqualToPartition) / 2; const SampleMeasurementType pivotValue = sample->GetMeasurementVectorByIndex(storeIndex)[activeDimension]; if (pivotValue != partitionValue) @@ -194,8 +194,8 @@ Partition(TSubsample * sample, // partitionValue. for (int kk = beginIndex; kk < storeIndex; ++kk) { - SampleMeasurementType nodeValue = sample->GetMeasurementVectorByIndex(kk)[activeDimension]; - SampleMeasurementType boundaryValue = sample->GetMeasurementVectorByIndex(storeIndex)[activeDimension]; + const SampleMeasurementType nodeValue = sample->GetMeasurementVectorByIndex(kk)[activeDimension]; + const SampleMeasurementType boundaryValue = sample->GetMeasurementVectorByIndex(storeIndex)[activeDimension]; if (nodeValue > boundaryValue) { sample->Swap(kk, storeIndex); @@ -357,9 +357,9 @@ QuickSelect(TSubsample * sample, { using SampleMeasurementType = typename TSubsample::MeasurementType; - int begin = beginIndex; - int end = endIndex - 1; - int kthIndex = kth + beginIndex; + int begin = beginIndex; + int end = endIndex - 1; + const int kthIndex = kth + beginIndex; SampleMeasurementType tempMedian; @@ -385,7 +385,7 @@ QuickSelect(TSubsample * sample, // Partition expects the end argument to be one past-the-end of the array. // The index pivotNewIndex returned by Partition is in the range // [begin,end]. - int pivotNewIndex = Partition(sample, activeDimension, begin, end + 1, tempMedian); + const int pivotNewIndex = Partition(sample, activeDimension, begin, end + 1, tempMedian); if (kthIndex == pivotNewIndex) { @@ -433,7 +433,7 @@ inline typename TSubsample::MeasurementType QuickSelect(TSubsample * sample, unsigned int activeDimension, int beginIndex, int endIndex, int kth) { using SampleMeasurementType = typename TSubsample::MeasurementType; - SampleMeasurementType medianGuess = NumericTraits::NonpositiveMin(); + const SampleMeasurementType medianGuess = NumericTraits::NonpositiveMin(); return QuickSelect(sample, activeDimension, beginIndex, endIndex, kth, medianGuess); } @@ -502,7 +502,7 @@ NthElement(TSubsample * sample, unsigned int activeDimension, int beginIndex, in const auto tempMedian = MedianOfThree(v1, v2, v3); - int cut = UnguardedPartition(sample, activeDimension, beginElement, endElement, tempMedian); + const int cut = UnguardedPartition(sample, activeDimension, beginElement, endElement, tempMedian); if (cut <= nthIndex) { @@ -558,10 +558,10 @@ DownHeap(TSubsample * sample, unsigned int activeDimension, int beginIndex, int int largerChild; using SampleMeasurementType = typename TSubsample::MeasurementType; - SampleMeasurementType currentNodeValue = sample->GetMeasurementVectorByIndex(currentNode)[activeDimension]; - SampleMeasurementType leftChildValue; - SampleMeasurementType rightChildValue; - SampleMeasurementType largerChildValue; + const SampleMeasurementType currentNodeValue = sample->GetMeasurementVectorByIndex(currentNode)[activeDimension]; + SampleMeasurementType leftChildValue; + SampleMeasurementType rightChildValue; + SampleMeasurementType largerChildValue; while (true) { diff --git a/Modules/Numerics/Statistics/include/itkSubsample.h b/Modules/Numerics/Statistics/include/itkSubsample.h index 2ac3920c79c..8dd94233a85 100644 --- a/Modules/Numerics/Statistics/include/itkSubsample.h +++ b/Modules/Numerics/Statistics/include/itkSubsample.h @@ -255,7 +255,7 @@ class ITK_TEMPLATE_EXPORT Subsample : public TSample Iterator Begin() { - Iterator iter(m_IdHolder.begin(), this); + const Iterator iter(m_IdHolder.begin(), this); return iter; } @@ -265,7 +265,7 @@ class ITK_TEMPLATE_EXPORT Subsample : public TSample Iterator End() { - Iterator iter(m_IdHolder.end(), this); + const Iterator iter(m_IdHolder.end(), this); return iter; } @@ -273,7 +273,7 @@ class ITK_TEMPLATE_EXPORT Subsample : public TSample ConstIterator Begin() const { - ConstIterator iter(m_IdHolder.begin(), this); + const ConstIterator iter(m_IdHolder.begin(), this); return iter; } @@ -281,7 +281,7 @@ class ITK_TEMPLATE_EXPORT Subsample : public TSample ConstIterator End() const { - ConstIterator iter(m_IdHolder.end(), this); + const ConstIterator iter(m_IdHolder.end(), this); return iter; } diff --git a/Modules/Numerics/Statistics/include/itkSubsample.hxx b/Modules/Numerics/Statistics/include/itkSubsample.hxx index 7c208fdf623..ff6a988e069 100644 --- a/Modules/Numerics/Statistics/include/itkSubsample.hxx +++ b/Modules/Numerics/Statistics/include/itkSubsample.hxx @@ -75,9 +75,9 @@ void Subsample::InitializeWithAllInstances() { m_IdHolder.resize(m_Sample->Size()); - auto idIter = m_IdHolder.begin(); - typename TSample::ConstIterator iter = m_Sample->Begin(); - typename TSample::ConstIterator last = m_Sample->End(); + auto idIter = m_IdHolder.begin(); + typename TSample::ConstIterator iter = m_Sample->Begin(); + const typename TSample::ConstIterator last = m_Sample->End(); m_TotalFrequency = AbsoluteFrequencyType{}; while (iter != last) { @@ -128,7 +128,7 @@ Subsample::GetMeasurementVector(InstanceIdentifier id) const -> const M } // translate the id to its Sample container id - InstanceIdentifier idInTheSample = m_IdHolder[id]; + const InstanceIdentifier idInTheSample = m_IdHolder[id]; return m_Sample->GetMeasurementVector(idInTheSample); } @@ -142,7 +142,7 @@ Subsample::GetFrequency(InstanceIdentifier id) const -> AbsoluteFrequen } // translate the id to its Sample container id - InstanceIdentifier idInTheSample = m_IdHolder[id]; + const InstanceIdentifier idInTheSample = m_IdHolder[id]; return m_Sample->GetFrequency(idInTheSample); } @@ -162,7 +162,7 @@ Subsample::Swap(unsigned int index1, unsigned int index2) itkExceptionMacro("Index out of range"); } - InstanceIdentifier temp = m_IdHolder[index1]; + const InstanceIdentifier temp = m_IdHolder[index1]; m_IdHolder[index1] = m_IdHolder[index2]; m_IdHolder[index2] = temp; this->Modified(); diff --git a/Modules/Numerics/Statistics/include/itkSubsamplerBase.hxx b/Modules/Numerics/Statistics/include/itkSubsamplerBase.hxx index a24df5f853b..dc5ddc56d82 100644 --- a/Modules/Numerics/Statistics/include/itkSubsamplerBase.hxx +++ b/Modules/Numerics/Statistics/include/itkSubsamplerBase.hxx @@ -38,7 +38,7 @@ SubsamplerBase::InternalClone() const { typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); diff --git a/Modules/Numerics/Statistics/include/itkUniformRandomSpatialNeighborSubsampler.hxx b/Modules/Numerics/Statistics/include/itkUniformRandomSpatialNeighborSubsampler.hxx index 5a70b78fc50..5d331703e92 100644 --- a/Modules/Numerics/Statistics/include/itkUniformRandomSpatialNeighborSubsampler.hxx +++ b/Modules/Numerics/Statistics/include/itkUniformRandomSpatialNeighborSubsampler.hxx @@ -39,7 +39,7 @@ UniformRandomSpatialNeighborSubsampler::InternalClone() const { typename LightObject::Pointer loPtr = Superclass::InternalClone(); - typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); + const typename Self::Pointer rval = dynamic_cast(loPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro("downcast to type " << this->GetNameOfClass() << " failed."); @@ -123,7 +123,7 @@ UniformRandomSpatialNeighborSubsampler::Search(const InstanceI unsigned int pointsFound = 0; - std::set usedIds; + const std::set usedIds; typename RegionType::OffsetValueType offset; // The trouble with decoupling the region from the sample is that @@ -178,7 +178,7 @@ UniformRandomSpatialNeighborSubsampler::GetIntegerVariate(Rand RandomIntType itkNotUsed(mean)) -> RandomIntType { - RandomIntType sizeRange = upperBound - lowerBound; + const RandomIntType sizeRange = upperBound - lowerBound; // mean ignored since we are uniformly sampling return lowerBound + m_RandomNumberGenerator->GetIntegerVariate(sizeRange); } diff --git a/Modules/Numerics/Statistics/include/itkVectorContainerToListSampleAdaptor.h b/Modules/Numerics/Statistics/include/itkVectorContainerToListSampleAdaptor.h index 5bb35c42be3..dc44d8c34ed 100644 --- a/Modules/Numerics/Statistics/include/itkVectorContainerToListSampleAdaptor.h +++ b/Modules/Numerics/Statistics/include/itkVectorContainerToListSampleAdaptor.h @@ -237,7 +237,7 @@ class ITK_TEMPLATE_EXPORT VectorContainerToListSampleAdaptor : public ListSample ConstIterator Begin() const { - ConstIterator iter(this->m_VectorContainer->Begin(), 0); + const ConstIterator iter(this->m_VectorContainer->Begin(), 0); return iter; } @@ -246,7 +246,7 @@ class ITK_TEMPLATE_EXPORT VectorContainerToListSampleAdaptor : public ListSample ConstIterator End() const { - ConstIterator iter(this->m_VectorContainer->End(), this->m_VectorContainer->Size()); + const ConstIterator iter(this->m_VectorContainer->End(), this->m_VectorContainer->Size()); return iter; } diff --git a/Modules/Numerics/Statistics/include/itkWeightedCentroidKdTreeGenerator.hxx b/Modules/Numerics/Statistics/include/itkWeightedCentroidKdTreeGenerator.hxx index 516906acfc3..c109d9f34c9 100644 --- a/Modules/Numerics/Statistics/include/itkWeightedCentroidKdTreeGenerator.hxx +++ b/Modules/Numerics/Statistics/include/itkWeightedCentroidKdTreeGenerator.hxx @@ -49,7 +49,7 @@ WeightedCentroidKdTreeGenerator::GenerateNonterminalNode(unsigned int MeasurementType maxSpread; unsigned int medianIndex; - SubsamplePointer subsample = this->GetSubsample(); + const SubsamplePointer subsample = this->GetSubsample(); // Sanity check. Verify that the subsample has measurement vectors of the // same length as the sample generated by the tree. diff --git a/Modules/Numerics/Statistics/include/itkWeightedCovarianceSampleFilter.hxx b/Modules/Numerics/Statistics/include/itkWeightedCovarianceSampleFilter.hxx index 2230f0f2e1c..0369069207a 100644 --- a/Modules/Numerics/Statistics/include/itkWeightedCovarianceSampleFilter.hxx +++ b/Modules/Numerics/Statistics/include/itkWeightedCovarianceSampleFilter.hxx @@ -64,7 +64,7 @@ WeightedCovarianceSampleFilter::ComputeCovarianceMatrixWithWeightingFun // set up input / output const SampleType * input = this->GetInput(); - MeasurementVectorSizeType measurementVectorSize = input->GetMeasurementVectorSize(); + const MeasurementVectorSizeType measurementVectorSize = input->GetMeasurementVectorSize(); auto * decoratedOutput = itkDynamicCastInDebugMode(this->ProcessObject::GetOutput(0)); @@ -161,7 +161,7 @@ WeightedCovarianceSampleFilter::ComputeCovarianceMatrixWithWeights() // set up input / output const SampleType * input = this->GetInput(); - MeasurementVectorSizeType measurementVectorSize = input->GetMeasurementVectorSize(); + const MeasurementVectorSizeType measurementVectorSize = input->GetMeasurementVectorSize(); auto * decoratedOutput = itkDynamicCastInDebugMode(this->ProcessObject::GetOutput(0)); diff --git a/Modules/Numerics/Statistics/include/itkWeightedMeanSampleFilter.hxx b/Modules/Numerics/Statistics/include/itkWeightedMeanSampleFilter.hxx index 604f6cd4f93..8485392dfc1 100644 --- a/Modules/Numerics/Statistics/include/itkWeightedMeanSampleFilter.hxx +++ b/Modules/Numerics/Statistics/include/itkWeightedMeanSampleFilter.hxx @@ -83,8 +83,8 @@ WeightedMeanSampleFilter::ComputeMeanWithWeights() WeightValueType totalWeight{}; - typename SampleType::ConstIterator iter = input->Begin(); - typename SampleType::ConstIterator end = input->End(); + typename SampleType::ConstIterator iter = input->Begin(); + const typename SampleType::ConstIterator end = input->End(); for (unsigned int sampleVectorIndex = 0; iter != end; ++iter, ++sampleVectorIndex) { diff --git a/Modules/Numerics/Statistics/src/itkChiSquareDistribution.cxx b/Modules/Numerics/Statistics/src/itkChiSquareDistribution.cxx index 73ff795aca0..f1cfa3e032a 100644 --- a/Modules/Numerics/Statistics/src/itkChiSquareDistribution.cxx +++ b/Modules/Numerics/Statistics/src/itkChiSquareDistribution.cxx @@ -146,7 +146,7 @@ ChiSquareDistribution::InverseCDF(double p, SizeValueType degreesOfFreedom) dof = static_cast(degreesOfFreedom); nx = GaussianDistribution::InverseCDF(p); - double f = 2.0 / (9.0 * dof); + const double f = 2.0 / (9.0 * dof); x = dof * std::pow(1.0 - f + nx * std::sqrt(f), 3.0); // The approximation above is only accurate for large degrees of diff --git a/Modules/Numerics/Statistics/src/itkDenseFrequencyContainer2.cxx b/Modules/Numerics/Statistics/src/itkDenseFrequencyContainer2.cxx index b7d65750f18..1539140ffa7 100644 --- a/Modules/Numerics/Statistics/src/itkDenseFrequencyContainer2.cxx +++ b/Modules/Numerics/Statistics/src/itkDenseFrequencyContainer2.cxx @@ -48,7 +48,7 @@ DenseFrequencyContainer2::SetFrequency(const InstanceIdentifier id, const Absolu { return false; } - AbsoluteFrequencyType frequency = this->GetFrequency(id); + const AbsoluteFrequencyType frequency = this->GetFrequency(id); (*m_FrequencyContainer)[id] = value; m_TotalFrequency += (value - frequency); return true; @@ -71,7 +71,7 @@ DenseFrequencyContainer2::IncreaseFrequency(const InstanceIdentifier id, const A { return false; } - AbsoluteFrequencyType frequency = this->GetFrequency(id); + const AbsoluteFrequencyType frequency = this->GetFrequency(id); (*m_FrequencyContainer)[id] = frequency + value; m_TotalFrequency += value; return true; diff --git a/Modules/Numerics/Statistics/src/itkGaussianDistribution.cxx b/Modules/Numerics/Statistics/src/itkGaussianDistribution.cxx index def4e5d17f5..f5f24c30f95 100644 --- a/Modules/Numerics/Statistics/src/itkGaussianDistribution.cxx +++ b/Modules/Numerics/Statistics/src/itkGaussianDistribution.cxx @@ -159,7 +159,7 @@ GaussianDistribution::PDF(double x) double GaussianDistribution::PDF(double x, double mean, double variance) { - double xminusmean = x - mean; + const double xminusmean = x - mean; return (itk::Math::one_over_sqrt2pi / std::sqrt(variance)) * std::exp(-0.5 * xminusmean * xminusmean / variance); } @@ -189,7 +189,7 @@ double GaussianDistribution::CDF(double x, double mean, double variance) { // convert to zero mean unit variance - double u = (x - mean) / std::sqrt(variance); + const double u = (x - mean) / std::sqrt(variance); return 0.5 * (vnl_erf(itk::Math::sqrt1_2 * u) + 1.0); } @@ -208,7 +208,7 @@ GaussianDistribution::CDF(double x, const ParametersType & p) double GaussianDistribution::InverseCDF(double p) { - double dp = (p <= 0.5) ? (p) : (1.0 - p); /* make between 0 and 0.5 */ + const double dp = (p <= 0.5) ? (p) : (1.0 - p); /* make between 0 and 0.5 */ // if original value is invalid, return +infinity or -infinity // changed from original code to reflect the fact that the @@ -229,16 +229,16 @@ GaussianDistribution::InverseCDF(double p) /** Step 1: use 26.2.23 from Abramowitz and Stegun */ - double dt = std::sqrt(-2.0 * std::log(dp)); - double dx = dt - ((.010328e+0 * dt + .802853e+0) * dt + 2.515517e+0) / + const double dt = std::sqrt(-2.0 * std::log(dp)); + double dx = dt - ((.010328e+0 * dt + .802853e+0) * dt + 2.515517e+0) / (((.001308e+0 * dt + .189269e+0) * dt + 1.432788e+0) * dt + 1.e+0); /** Step 2: do 3 Newton steps to improve this */ for (int newt = 0; newt < 3; ++newt) { - double dq = 0.5e+0 * vnl_erfc(dx * itk::Math::sqrt1_2) - dp; - double ddq = std::exp(-0.5e+0 * dx * dx) / 2.506628274631000e+0; + const double dq = 0.5e+0 * vnl_erfc(dx * itk::Math::sqrt1_2) - dp; + const double ddq = std::exp(-0.5e+0 * dx * dx) / 2.506628274631000e+0; dx = dx + dq / ddq; } diff --git a/Modules/Numerics/Statistics/src/itkMaximumRatioDecisionRule.cxx b/Modules/Numerics/Statistics/src/itkMaximumRatioDecisionRule.cxx index 2bd6234ac92..149142a1047 100644 --- a/Modules/Numerics/Statistics/src/itkMaximumRatioDecisionRule.cxx +++ b/Modules/Numerics/Statistics/src/itkMaximumRatioDecisionRule.cxx @@ -111,7 +111,7 @@ MaximumRatioDecisionRule::Evaluate(const MembershipVectorType & discriminantScor MembershipValueType best = NumericTraits::NonpositiveMin(); for (ClassIdentifierType i = 0; i < discriminantScores.size(); ++i) { - MembershipValueType temp = discriminantScores[i] * m_PriorProbabilities[i]; + const MembershipValueType temp = discriminantScores[i] * m_PriorProbabilities[i]; if (temp > best) { best = temp; diff --git a/Modules/Numerics/Statistics/src/itkSparseFrequencyContainer2.cxx b/Modules/Numerics/Statistics/src/itkSparseFrequencyContainer2.cxx index efb6a087ee2..247c7082e7a 100644 --- a/Modules/Numerics/Statistics/src/itkSparseFrequencyContainer2.cxx +++ b/Modules/Numerics/Statistics/src/itkSparseFrequencyContainer2.cxx @@ -47,7 +47,7 @@ SparseFrequencyContainer2::SetFrequency(const InstanceIdentifier id, const Absol { // No need to test for bounds because in a map container the // element is allocated if the key doesn't exist yet - AbsoluteFrequencyType frequency = this->GetFrequency(id); + const AbsoluteFrequencyType frequency = this->GetFrequency(id); m_FrequencyContainer[id] = value; m_TotalFrequency += (value - frequency); @@ -74,7 +74,7 @@ SparseFrequencyContainer2::IncreaseFrequency(const InstanceIdentifier id, const { // No need to test for bounds because in a map container the // element is allocated if the key doesn't exist yet - AbsoluteFrequencyType frequency = this->GetFrequency(id); + const AbsoluteFrequencyType frequency = this->GetFrequency(id); m_FrequencyContainer[id] = frequency + value; m_TotalFrequency += value; diff --git a/Modules/Numerics/Statistics/src/itkTDistribution.cxx b/Modules/Numerics/Statistics/src/itkTDistribution.cxx index b1b7b73ecce..f2f46e39faf 100644 --- a/Modules/Numerics/Statistics/src/itkTDistribution.cxx +++ b/Modules/Numerics/Statistics/src/itkTDistribution.cxx @@ -76,11 +76,11 @@ TDistribution::GetDegreesOfFreedom() const double TDistribution::PDF(double x, SizeValueType degreesOfFreedom) { - auto dof = static_cast(degreesOfFreedom); - double dofplusoneon2 = 0.5 * (dof + 1.0); - double dofon2 = 0.5 * dof; - double pdf = (dgamma_(&dofplusoneon2) / dgamma_(&dofon2)) / - (std::sqrt(dof * itk::Math::pi) * std::pow(1.0 + ((x * x) / dof), dofplusoneon2)); + auto dof = static_cast(degreesOfFreedom); + double dofplusoneon2 = 0.5 * (dof + 1.0); + double dofon2 = 0.5 * dof; + const double pdf = (dgamma_(&dofplusoneon2) / dgamma_(&dofon2)) / + (std::sqrt(dof * itk::Math::pi) * std::pow(1.0 + ((x * x) / dof), dofplusoneon2)); return pdf; } @@ -123,10 +123,10 @@ TDistribution::CDF(double x, SizeValueType degreesOfFreedom) // = 0.5 + 0.5 * (1 - Ix(v/2. 1/2)) // = 1 - 0.5 * Ix(v/2, 1/2) - double dof = static_cast(degreesOfFreedom); - double bx = dof / (dof + (x * x)); - double pin = dof / 2.0; - double qin = 0.5; + const double dof = static_cast(degreesOfFreedom); + double bx = dof / (dof + (x * x)); + double pin = dof / 2.0; + double qin = 0.5; if (x >= 0.0) { @@ -162,16 +162,16 @@ TDistribution::InverseCDF(double p, SizeValueType degreesOfFreedom) } // Based on Abramowitz and Stegun 26.7.5 - double dof = static_cast(degreesOfFreedom); - double dof2 = dof * dof; - double dof3 = dof * dof2; - double dof4 = dof * dof3; - - double gaussX = GaussianDistribution::InverseCDF(p); - double gaussX3 = std::pow(gaussX, 3.0); - double gaussX5 = std::pow(gaussX, 5.0); - double gaussX7 = std::pow(gaussX, 7.0); - double gaussX9 = std::pow(gaussX, 9.0); + const double dof = static_cast(degreesOfFreedom); + const double dof2 = dof * dof; + const double dof3 = dof * dof2; + const double dof4 = dof * dof3; + + const double gaussX = GaussianDistribution::InverseCDF(p); + const double gaussX3 = std::pow(gaussX, 3.0); + const double gaussX5 = std::pow(gaussX, 5.0); + const double gaussX7 = std::pow(gaussX, 7.0); + const double gaussX9 = std::pow(gaussX, 9.0); double x = gaussX + (gaussX3 + gaussX) / (4.0 * dof) + (5.0 * gaussX5 + 16.0 * gaussX3 + 3 * gaussX) / (96.0 * dof2) + diff --git a/Modules/Numerics/Statistics/test/itkChiSquareDistributionTest.cxx b/Modules/Numerics/Statistics/test/itkChiSquareDistributionTest.cxx index 25eeecfe947..1e741b3ccb3 100644 --- a/Modules/Numerics/Statistics/test/itkChiSquareDistributionTest.cxx +++ b/Modules/Numerics/Statistics/test/itkChiSquareDistributionTest.cxx @@ -27,7 +27,7 @@ itkChiSquareDistributionTest(int, char *[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope // scope. - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); std::cout << "itkChiSquareDistribution Test \n \n"; @@ -47,12 +47,12 @@ itkChiSquareDistributionTest(int, char *[]) // expected values for Chi-Square cdf with 1 degree of freedom at // values of 0:1:5 - double expected1[] = { 0, - 6.826894921370859e-001, - 8.427007929497149e-001, - 9.167354833364458e-001, - 9.544997361036416e-001, - 9.746526813225318e-001 }; + const double expected1[] = { 0, + 6.826894921370859e-001, + 8.427007929497149e-001, + 9.167354833364458e-001, + 9.544997361036416e-001, + 9.746526813225318e-001 }; std::cout << "Testing distribution with 1 degree of freedom" << std::endl; @@ -136,17 +136,17 @@ itkChiSquareDistributionTest(int, char *[]) // expected values for Chi-Square cdf with 11 degrees of freedom at // values of 0:2:20 - double expected11[] = { 0, - 1.504118282583805e-003, - 3.008297612122607e-002, - 1.266357467726155e-001, - 2.866961703699681e-001, - 4.696128489989594e-001, - 6.363567794831719e-001, - 7.670065225437422e-001, - 8.588691197329420e-001, - 9.184193863071046e-001, - 9.546593255659396e-001 }; + const double expected11[] = { 0, + 1.504118282583805e-003, + 3.008297612122607e-002, + 1.266357467726155e-001, + 2.866961703699681e-001, + 4.696128489989594e-001, + 6.363567794831719e-001, + 7.670065225437422e-001, + 8.588691197329420e-001, + 9.184193863071046e-001, + 9.546593255659396e-001 }; std::cout << "-----------------------------------------------" << std::endl << std::endl; std::cout << "Testing distribution with 11 degrees of freedom" << std::endl; @@ -227,8 +227,8 @@ itkChiSquareDistributionTest(int, char *[]) // expected values for Chi-Square cdf with 100 degrees of freedom at // values of 50:20:150 - double expected100[] = { 6.953305247616148e-006, 9.845502476408603e-003, 2.468020344001694e-001, - 7.677952194991408e-001, 9.764876021901918e-001, 9.990960679576461e-001 }; + const double expected100[] = { 6.953305247616148e-006, 9.845502476408603e-003, 2.468020344001694e-001, + 7.677952194991408e-001, 9.764876021901918e-001, 9.990960679576461e-001 }; std::cout << "-----------------------------------------------" << std::endl << std::endl; std::cout << "Testing distribution with 100 degrees of freedom" << std::endl; @@ -323,7 +323,7 @@ itkChiSquareDistributionTest(int, char *[]) for (int i = 0; i <= 5; ++i) { - double x = static_cast(50 + 20 * i); + const double x = static_cast(50 + 20 * i); const double value = distributionFunction->EvaluateCDF(x, params); @@ -475,7 +475,7 @@ itkChiSquareDistributionTest(int, char *[]) DistributionType::ParametersType parameters(distributionFunction->GetNumberOfParameters()); parameters[0] = 1.0; - long dof = 2; + const long dof = 2; std::cout << "Variance() = " << distributionFunction->GetVariance() << std::endl; std::cout << "PDF(x,p) = " << distributionFunction->PDF(last_x, parameters) << std::endl; @@ -513,7 +513,7 @@ itkChiSquareDistributionTest(int, char *[]) ITK_TRY_EXPECT_EXCEPTION(distributionFunction->EvaluateInverseCDF(last_x, wrongParameters)); distributionFunction->SetParameters(wrongParameters); - unsigned long newdof = 17; + const unsigned long newdof = 17; distributionFunction->SetDegreesOfFreedom(newdof); ITK_TEST_SET_GET_VALUE(newdof, distributionFunction->GetDegreesOfFreedom()); @@ -521,7 +521,7 @@ itkChiSquareDistributionTest(int, char *[]) distributionFunction->CDF(-1.0, dof); // Exercise print with a parameter array of zero elements. - DistributionType::ParametersType parameters0(0); + const DistributionType::ParametersType parameters0(0); distributionFunction->SetParameters(parameters0); distributionFunction->Print(std::cout); diff --git a/Modules/Numerics/Statistics/test/itkCovarianceSampleFilterTest.cxx b/Modules/Numerics/Statistics/test/itkCovarianceSampleFilterTest.cxx index 076bca2792e..9ba4ffcf6a0 100644 --- a/Modules/Numerics/Statistics/test/itkCovarianceSampleFilterTest.cxx +++ b/Modules/Numerics/Statistics/test/itkCovarianceSampleFilterTest.cxx @@ -36,10 +36,10 @@ itkCovarianceSampleFilterTest(int, char *[]) using ImageType = itk::Image; using MaskImageType = itk::Image; - auto image = ImageType::New(); - ImageType::RegionType region; - ImageType::SizeType size; - ImageType::IndexType index{}; + auto image = ImageType::New(); + ImageType::RegionType region; + ImageType::SizeType size; + const ImageType::IndexType index{}; size.Fill(5); region.SetIndex(index); region.SetSize(size); @@ -139,7 +139,7 @@ itkCovarianceSampleFilterTest(int, char *[]) const CovarianceSampleFilterType::MatrixDecoratedType * decorator = covarianceFilter->GetCovarianceMatrixOutput(); - CovarianceSampleFilterType::MatrixType covarianceMatrix = decorator->Get(); + const CovarianceSampleFilterType::MatrixType covarianceMatrix = decorator->Get(); std::cout << "Covariance matrix: " << covarianceMatrix << std::endl; diff --git a/Modules/Numerics/Statistics/test/itkCovarianceSampleFilterTest3.cxx b/Modules/Numerics/Statistics/test/itkCovarianceSampleFilterTest3.cxx index bc4984689ad..888cb92b162 100644 --- a/Modules/Numerics/Statistics/test/itkCovarianceSampleFilterTest3.cxx +++ b/Modules/Numerics/Statistics/test/itkCovarianceSampleFilterTest3.cxx @@ -43,7 +43,7 @@ class MyCovarianceSampleFilter : public CovarianceSampleFilter void CreateInvalidOutput() { - unsigned int index = 3; + const unsigned int index = 3; Superclass::MakeOutput(index); } unsigned int @@ -120,8 +120,8 @@ itkCovarianceSampleFilterTest3(int, char *[]) memberFunction->SetMean(mean); memberFunction->SetCovariance(covariance); - HistogramType::Iterator itr = histogram->Begin(); - HistogramType::Iterator end = histogram->End(); + HistogramType::Iterator itr = histogram->Begin(); + const HistogramType::Iterator end = histogram->End(); using AbsoluteFrequencyType = HistogramType::AbsoluteFrequencyType; diff --git a/Modules/Numerics/Statistics/test/itkDecisionRuleTest.cxx b/Modules/Numerics/Statistics/test/itkDecisionRuleTest.cxx index 271fec07dac..324ccdff0c2 100644 --- a/Modules/Numerics/Statistics/test/itkDecisionRuleTest.cxx +++ b/Modules/Numerics/Statistics/test/itkDecisionRuleTest.cxx @@ -86,13 +86,13 @@ itkDecisionRuleTest(int, char *[]) MembershipVectorType membershipScoreVector; - double membershipScore1 = 0.1; + const double membershipScore1 = 0.1; membershipScoreVector.push_back(membershipScore1); - double membershipScore2 = 0.5; + const double membershipScore2 = 0.5; membershipScoreVector.push_back(membershipScore2); - double membershipScore3 = 1.9; + const double membershipScore3 = 1.9; membershipScoreVector.push_back(membershipScore3); // the maximum score is the third component. The decision rule should diff --git a/Modules/Numerics/Statistics/test/itkDenseFrequencyContainer2Test.cxx b/Modules/Numerics/Statistics/test/itkDenseFrequencyContainer2Test.cxx index 260ea767740..9450144b990 100644 --- a/Modules/Numerics/Statistics/test/itkDenseFrequencyContainer2Test.cxx +++ b/Modules/Numerics/Statistics/test/itkDenseFrequencyContainer2Test.cxx @@ -63,8 +63,8 @@ itkDenseFrequencyContainer2Test(int, char *[]) } // Test Set/Get frequency of an out of bound bin - unsigned int binOutOfBound = numberOfBins; - const auto frequency = static_cast(binOutOfBound * binOutOfBound); + const unsigned int binOutOfBound = numberOfBins; + const auto frequency = static_cast(binOutOfBound * binOutOfBound); if (container->SetFrequency(binOutOfBound, frequency)) { @@ -118,8 +118,8 @@ itkDenseFrequencyContainer2Test(int, char *[]) return EXIT_FAILURE; } } - unsigned int binOutOfBound = numberOfBins; - const auto frequency = static_cast(binOutOfBound); + const unsigned int binOutOfBound = numberOfBins; + const auto frequency = static_cast(binOutOfBound); if (container->IncreaseFrequency(binOutOfBound, frequency)) { diff --git a/Modules/Numerics/Statistics/test/itkDistanceMetricTest.cxx b/Modules/Numerics/Statistics/test/itkDistanceMetricTest.cxx index 8bf2dbd30a9..b2d6effb5f8 100644 --- a/Modules/Numerics/Statistics/test/itkDistanceMetricTest.cxx +++ b/Modules/Numerics/Statistics/test/itkDistanceMetricTest.cxx @@ -45,14 +45,14 @@ class MyDistanceMetric : public DistanceMetric double Evaluate(const TMeasurementVector &) const override { - double score = 1; + const double score = 1; return score; } double Evaluate(const TMeasurementVector &, const TMeasurementVector &) const override { - double score = 1; + const double score = 1; return score; } }; @@ -85,7 +85,7 @@ itkDistanceMetricTest(int, char *[]) // try changing the measurement vector size, it should throw an exception try { - MeasurementVectorSizeType newSize = 20; + const MeasurementVectorSizeType newSize = 20; distance->SetMeasurementVectorSize(newSize); std::cerr << "Changing measurement vector size is not allowed for a fixed array vector\n" @@ -101,7 +101,7 @@ itkDistanceMetricTest(int, char *[]) // thrown try { - MeasurementVectorSizeType sameSize = 17; + const MeasurementVectorSizeType sameSize = 17; distance->SetMeasurementVectorSize(sameSize); } catch (const itk::ExceptionObject & excpt) @@ -114,8 +114,8 @@ itkDistanceMetricTest(int, char *[]) // try setting an origin vector with a different size it should throw an exception try { - DistanceMetricType::OriginType origin; - MeasurementVectorSizeType newSize = 25; + DistanceMetricType::OriginType origin; + const MeasurementVectorSizeType newSize = 25; origin.SetSize(newSize); distance->SetOrigin(origin); diff --git a/Modules/Numerics/Statistics/test/itkDistanceMetricTest2.cxx b/Modules/Numerics/Statistics/test/itkDistanceMetricTest2.cxx index 6f37c7b4f14..40e333e485d 100644 --- a/Modules/Numerics/Statistics/test/itkDistanceMetricTest2.cxx +++ b/Modules/Numerics/Statistics/test/itkDistanceMetricTest2.cxx @@ -45,14 +45,14 @@ class MyDistanceMetric : public DistanceMetric double Evaluate(const TMeasurementVector &) const override { - double score = 1; + const double score = 1; return score; } double Evaluate(const TMeasurementVector &, const TMeasurementVector &) const override { - double score = 1; + const double score = 1; return score; } }; @@ -80,7 +80,7 @@ itkDistanceMetricTest2(int, char *[]) distance->Print(std::cout); - MeasurementVectorSizeType measurementVectorSize = 3; + const MeasurementVectorSizeType measurementVectorSize = 3; distance->SetMeasurementVectorSize(measurementVectorSize); if (distance->GetMeasurementVectorSize() != measurementVectorSize) @@ -93,7 +93,7 @@ itkDistanceMetricTest2(int, char *[]) // thrown try { - MeasurementVectorSizeType sameSize = 3; + const MeasurementVectorSizeType sameSize = 3; distance->SetMeasurementVectorSize(sameSize); } catch (const itk::ExceptionObject & excpt) @@ -106,8 +106,8 @@ itkDistanceMetricTest2(int, char *[]) // try setting an origin vector with a different size it should throw an exception try { - DistanceMetricType::OriginType origin; - MeasurementVectorSizeType newSize = 4; + DistanceMetricType::OriginType origin; + const MeasurementVectorSizeType newSize = 4; origin.SetSize(newSize); distance->SetOrigin(origin); diff --git a/Modules/Numerics/Statistics/test/itkDistanceToCentroidMembershipFunctionTest.cxx b/Modules/Numerics/Statistics/test/itkDistanceToCentroidMembershipFunctionTest.cxx index e6398db02dd..9ce73a35e01 100644 --- a/Modules/Numerics/Statistics/test/itkDistanceToCentroidMembershipFunctionTest.cxx +++ b/Modules/Numerics/Statistics/test/itkDistanceToCentroidMembershipFunctionTest.cxx @@ -61,7 +61,7 @@ itkDistanceToCentroidMembershipFunctionTest(int, char *[]) // size try { - MeasurementVectorSizeType measurementVector2 = MeasurementVectorSize + 1; + const MeasurementVectorSizeType measurementVector2 = MeasurementVectorSize + 1; function->SetMeasurementVectorSize(measurementVector2); std::cerr << "Exception should have been thrown since we are trying to resize non-resizeable measurement vector type " @@ -98,8 +98,8 @@ itkDistanceToCentroidMembershipFunctionTest(int, char *[]) measurement[1] = 3.3; measurement[2] = 4.0; - double trueValue = 3.31662; - double distanceComputed = function->Evaluate(measurement); + const double trueValue = 3.31662; + const double distanceComputed = function->Evaluate(measurement); if (itk::Math::abs(distanceComputed - trueValue) > tolerance) { @@ -109,7 +109,7 @@ itkDistanceToCentroidMembershipFunctionTest(int, char *[]) } // Exercise the Clone method. - MembershipFunctionType::Pointer clonedFunction = function->Clone(); + const MembershipFunctionType::Pointer clonedFunction = function->Clone(); if (clonedFunction.IsNull()) { return EXIT_FAILURE; diff --git a/Modules/Numerics/Statistics/test/itkEuclideanDistanceMetricTest.cxx b/Modules/Numerics/Statistics/test/itkEuclideanDistanceMetricTest.cxx index a73bac48287..660049c4172 100644 --- a/Modules/Numerics/Statistics/test/itkEuclideanDistanceMetricTest.cxx +++ b/Modules/Numerics/Statistics/test/itkEuclideanDistanceMetricTest.cxx @@ -76,8 +76,8 @@ itkEuclideanDistanceMetricTest(int, char *[]) measurement[1] = 3.3; measurement[2] = 4.0; - double trueValue = 3.31662; - double distanceComputed = distance->Evaluate(measurement); + const double trueValue = 3.31662; + const double distanceComputed = distance->Evaluate(measurement); constexpr double tolerance = 0.001; if (itk::Math::abs(distanceComputed - trueValue) > tolerance) @@ -94,8 +94,8 @@ itkEuclideanDistanceMetricTest(int, char *[]) measurement2[1] = 3.5; measurement2[2] = 3.5; - double trueValue2 = 1.136; - double distanceComputed2 = distance->Evaluate(measurement, measurement2); + const double trueValue2 = 1.136; + const double distanceComputed2 = distance->Evaluate(measurement, measurement2); if (itk::Math::abs(distanceComputed2 - trueValue2) > tolerance) { diff --git a/Modules/Numerics/Statistics/test/itkEuclideanSquareDistanceMetricTest.cxx b/Modules/Numerics/Statistics/test/itkEuclideanSquareDistanceMetricTest.cxx index 408abcb8499..29b271b044d 100644 --- a/Modules/Numerics/Statistics/test/itkEuclideanSquareDistanceMetricTest.cxx +++ b/Modules/Numerics/Statistics/test/itkEuclideanSquareDistanceMetricTest.cxx @@ -78,8 +78,8 @@ itkEuclideanSquareDistanceMetricTest(int, char *[]) measurement[1] = 3.3; measurement[2] = 4.0; - double trueValue = 11.0; - double distanceComputed = distance->Evaluate(measurement); + const double trueValue = 11.0; + const double distanceComputed = distance->Evaluate(measurement); constexpr double tolerance = 0.001; if (itk::Math::abs(distanceComputed - trueValue) > tolerance) @@ -96,8 +96,8 @@ itkEuclideanSquareDistanceMetricTest(int, char *[]) measurement2[1] = 3.5; measurement2[2] = 3.5; - double trueValue2 = 1.29; - double distanceComputed2 = distance->Evaluate(measurement, measurement2); + const double trueValue2 = 1.29; + const double distanceComputed2 = distance->Evaluate(measurement, measurement2); if (itk::Math::abs(distanceComputed2 - trueValue2) > tolerance) { diff --git a/Modules/Numerics/Statistics/test/itkExpectationMaximizationMixtureModelEstimatorTest.cxx b/Modules/Numerics/Statistics/test/itkExpectationMaximizationMixtureModelEstimatorTest.cxx index 35558a88075..cee355428be 100644 --- a/Modules/Numerics/Statistics/test/itkExpectationMaximizationMixtureModelEstimatorTest.cxx +++ b/Modules/Numerics/Statistics/test/itkExpectationMaximizationMixtureModelEstimatorTest.cxx @@ -41,12 +41,12 @@ itkExpectationMaximizationMixtureModelEstimatorTest(int argc, char * argv[]) return EXIT_FAILURE; } - char * dataFileName = argv[1]; - int dataSize = 2000; - int maximumIteration = 200; + char * dataFileName = argv[1]; + const int dataSize = 2000; + const int maximumIteration = 200; using ParametersType = itk::Array; - double minStandardDeviation = 28.54746; - unsigned int numberOfClasses = 2; + const double minStandardDeviation = 28.54746; + const unsigned int numberOfClasses = 2; std::vector trueParameters(numberOfClasses); ParametersType params(6); params[0] = 99.261; @@ -92,8 +92,8 @@ itkExpectationMaximizationMixtureModelEstimatorTest(int argc, char * argv[]) initialProportions[1] = 0.5; /* Loading point data */ - auto pointSet = PointSetType::New(); - PointSetType::PointsContainerPointer pointsContainer = PointSetType::PointsContainer::New(); + auto pointSet = PointSetType::New(); + const PointSetType::PointsContainerPointer pointsContainer = PointSetType::PointsContainer::New(); pointsContainer->Reserve(dataSize); pointSet->SetPoints(pointsContainer); diff --git a/Modules/Numerics/Statistics/test/itkGaussianDistributionTest.cxx b/Modules/Numerics/Statistics/test/itkGaussianDistributionTest.cxx index e618a32ebe0..ea12c20c9fe 100644 --- a/Modules/Numerics/Statistics/test/itkGaussianDistributionTest.cxx +++ b/Modules/Numerics/Statistics/test/itkGaussianDistributionTest.cxx @@ -26,7 +26,7 @@ itkGaussianDistributionTest(int, char *[]) { // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); std::cout << "itkGaussianDistribution Test \n \n"; @@ -49,7 +49,7 @@ itkGaussianDistributionTest(int, char *[]) int status = EXIT_SUCCESS; // Tolerance for the values. - double tol = 1e-8; + const double tol = 1e-8; std::cout << "Tolerance used for test: "; std::cout.width(22); std::cout.precision(15); @@ -58,9 +58,10 @@ itkGaussianDistributionTest(int, char *[]) // expected values for Gaussian cdf with mean 0 and variance 1 at // values of -5:1:5 - double expected1[] = { 2.866515718791942e-007, 3.167124183311998e-005, 1.349898031630095e-003, 2.275013194817922e-002, - 1.586552539314571e-001, 5.000000000000000e-001, 8.413447460685429e-001, 9.772498680518208e-001, - 9.986501019683699e-001, 9.999683287581669e-001, 9.999997133484281e-001 }; + const double expected1[] = { 2.866515718791942e-007, 3.167124183311998e-005, 1.349898031630095e-003, + 2.275013194817922e-002, 1.586552539314571e-001, 5.000000000000000e-001, + 8.413447460685429e-001, 9.772498680518208e-001, 9.986501019683699e-001, + 9.999683287581669e-001, 9.999997133484281e-001 }; std::cout << "Gaussian CDF" << std::endl; for (i = -5; i <= 5; ++i) @@ -128,9 +129,10 @@ itkGaussianDistributionTest(int, char *[]) std::cout << "Testing mean = " << distributionFunction->GetMean() << ", variance = " << distributionFunction->GetVariance() << std::endl; - double expected2[] = { 7.687298972140230e-013, 9.830802207714426e-011, 7.708628950140045e-009, 3.715491861707074e-007, - 1.104524849929275e-005, 2.034760087224798e-004, 2.338867490523635e-003, 1.694742676234465e-002, - 7.864960352514258e-002, 2.397500610934768e-001, 5.000000000000000e-001 }; + const double expected2[] = { 7.687298972140230e-013, 9.830802207714426e-011, 7.708628950140045e-009, + 3.715491861707074e-007, 1.104524849929275e-005, 2.034760087224798e-004, + 2.338867490523635e-003, 1.694742676234465e-002, 7.864960352514258e-002, + 2.397500610934768e-001, 5.000000000000000e-001 }; std::cout << "Gaussian CDF" << std::endl; for (i = -5; i <= 5; ++i) @@ -172,9 +174,10 @@ itkGaussianDistributionTest(int, char *[]) distributionFunction->SetMean(0.0); // clear settings distributionFunction->SetVariance(1.0); // clear settings - double expected3[] = { 7.687298972140230e-013, 9.830802207714426e-011, 7.708628950140045e-009, 3.715491861707074e-007, - 1.104524849929275e-005, 2.034760087224798e-004, 2.338867490523635e-003, 1.694742676234465e-002, - 7.864960352514258e-002, 2.397500610934768e-001, 5.000000000000000e-001 }; + const double expected3[] = { 7.687298972140230e-013, 9.830802207714426e-011, 7.708628950140045e-009, + 3.715491861707074e-007, 1.104524849929275e-005, 2.034760087224798e-004, + 2.338867490523635e-003, 1.694742676234465e-002, 7.864960352514258e-002, + 2.397500610934768e-001, 5.000000000000000e-001 }; std::cout << "Gaussian CDF (parameter vector API)" << std::endl; for (i = -5; i <= 5; ++i) @@ -209,9 +212,10 @@ itkGaussianDistributionTest(int, char *[]) // same test but using the separate parameters std::cout << "Testing mean = " << params[0] << ", variance = " << params[1] << std::endl; - double expected4[] = { 7.687298972140230e-013, 9.830802207714426e-011, 7.708628950140045e-009, 3.715491861707074e-007, - 1.104524849929275e-005, 2.034760087224798e-004, 2.338867490523635e-003, 1.694742676234465e-002, - 7.864960352514258e-002, 2.397500610934768e-001, 5.000000000000000e-001 }; + const double expected4[] = { 7.687298972140230e-013, 9.830802207714426e-011, 7.708628950140045e-009, + 3.715491861707074e-007, 1.104524849929275e-005, 2.034760087224798e-004, + 2.338867490523635e-003, 1.694742676234465e-002, 7.864960352514258e-002, + 2.397500610934768e-001, 5.000000000000000e-001 }; std::cout << "Gaussian CDF (separate parameter API)" << std::endl; for (i = -5; i <= 5; ++i) @@ -332,12 +336,12 @@ itkGaussianDistributionTest(int, char *[]) ITK_TRY_EXPECT_EXCEPTION(distributionFunction->InverseCDF(x, wrongParameters)); distributionFunction->SetParameters(wrongParameters); - double newMean = 17.0; + const double newMean = 17.0; distributionFunction->SetMean(newMean); ITK_TEST_SET_GET_VALUE(newMean, distributionFunction->GetMean()); distributionFunction->SetParameters(wrongParameters); - double newVariance = 42.0; + const double newVariance = 42.0; distributionFunction->SetVariance(newVariance); ITK_TEST_SET_GET_VALUE(newVariance, distributionFunction->GetVariance()); @@ -363,7 +367,7 @@ itkGaussianDistributionTest(int, char *[]) std::cout << "EvaluateInverseCDF(x,m,v) = " << distributionFunction->EvaluateInverseCDF(x, mean2, variance2) << std::endl; - DistributionType::ParametersType parameters0(0); + const DistributionType::ParametersType parameters0(0); distributionFunction->SetParameters(parameters0); distributionFunction->Print(std::cout); diff --git a/Modules/Numerics/Statistics/test/itkGaussianMembershipFunctionTest.cxx b/Modules/Numerics/Statistics/test/itkGaussianMembershipFunctionTest.cxx index 2b1bd6bfd8c..4af5aed1b16 100644 --- a/Modules/Numerics/Statistics/test/itkGaussianMembershipFunctionTest.cxx +++ b/Modules/Numerics/Statistics/test/itkGaussianMembershipFunctionTest.cxx @@ -37,7 +37,7 @@ itkGaussianMembershipFunctionTest(int, char *[]) // Test if an exception will be thrown if we try to resize the measurement vector // size - MeasurementVectorSizeType measurementVector2 = MeasurementVectorSize + 1; + const MeasurementVectorSizeType measurementVector2 = MeasurementVectorSize + 1; ITK_TRY_EXPECT_EXCEPTION(function->SetMeasurementVectorSize(measurementVector2)); // Test non-square covariance matrix exception @@ -79,8 +79,8 @@ itkGaussianMembershipFunctionTest(int, char *[]) itk::NumericTraits::SetLength(measurement, MeasurementVectorSize); measurement[0] = 1.5; - double trueValue = 0.3989; - double distanceComputed = function->Evaluate(measurement); + const double trueValue = 0.3989; + const double distanceComputed = function->Evaluate(measurement); if (itk::Math::abs(distanceComputed - trueValue) > tolerance) { diff --git a/Modules/Numerics/Statistics/test/itkGaussianMixtureModelComponentTest.cxx b/Modules/Numerics/Statistics/test/itkGaussianMixtureModelComponentTest.cxx index b0939334aa1..602ba5b5e14 100644 --- a/Modules/Numerics/Statistics/test/itkGaussianMixtureModelComponentTest.cxx +++ b/Modules/Numerics/Statistics/test/itkGaussianMixtureModelComponentTest.cxx @@ -36,10 +36,10 @@ itkGaussianMixtureModelComponentTest(int argc, char * argv[]) return EXIT_FAILURE; } - char * dataFileName = argv[1]; - int dataSize = 2000; + char * dataFileName = argv[1]; + const int dataSize = 2000; using ParametersType = itk::Array; - unsigned int numberOfClasses = 2; + const unsigned int numberOfClasses = 2; ParametersType params(6); @@ -69,8 +69,8 @@ itkGaussianMixtureModelComponentTest(int argc, char * argv[]) initialProportions[1] = 0.5; /* Loading point data */ - auto pointSet = PointSetType::New(); - PointSetType::PointsContainerPointer pointsContainer = PointSetType::PointsContainer::New(); + auto pointSet = PointSetType::New(); + const PointSetType::PointsContainerPointer pointsContainer = PointSetType::PointsContainer::New(); pointsContainer->Reserve(dataSize); pointSet->SetPoints(pointsContainer); @@ -112,7 +112,7 @@ itkGaussianMixtureModelComponentTest(int argc, char * argv[]) (components[i])->SetParameters(initialParameters[i]); } - ComponentPointer testComponent = ComponentType::New(); + const ComponentPointer testComponent = ComponentType::New(); std::cout << testComponent->GetNameOfClass() << std::endl; testComponent->Print(std::cout); diff --git a/Modules/Numerics/Statistics/test/itkGaussianRandomSpatialNeighborSubsamplerTest.cxx b/Modules/Numerics/Statistics/test/itkGaussianRandomSpatialNeighborSubsamplerTest.cxx index 4c8704099d7..7a373030526 100644 --- a/Modules/Numerics/Statistics/test/itkGaussianRandomSpatialNeighborSubsamplerTest.cxx +++ b/Modules/Numerics/Statistics/test/itkGaussianRandomSpatialNeighborSubsamplerTest.cxx @@ -48,10 +48,10 @@ itkGaussianRandomSpatialNeighborSubsamplerTest(int argc, char * argv[]) using SamplerType = itk::Statistics::GaussianRandomSpatialNeighborSubsampler; using WriterType = itk::ImageFileWriter; - auto inImage = FloatImage::New(); - auto sz = SizeType::Filled(35); - IndexType idx{}; - RegionType region{ idx, sz }; + auto inImage = FloatImage::New(); + auto sz = SizeType::Filled(35); + const IndexType idx{}; + const RegionType region{ idx, sz }; inImage->SetRegions(region); inImage->AllocateInitialized(); @@ -69,7 +69,7 @@ itkGaussianRandomSpatialNeighborSubsamplerTest(int argc, char * argv[]) sampler_orig->CanSelectQueryOff(); // test clone mechanism - SamplerType::Pointer sampler = sampler_orig->Clone().GetPointer(); + const SamplerType::Pointer sampler = sampler_orig->Clone().GetPointer(); if (sampler->GetSample() != sampler_orig->GetSample()) { std::cerr << "Clone did not copy the sample correctly!" << std::endl; diff --git a/Modules/Numerics/Statistics/test/itkHistogramTest.cxx b/Modules/Numerics/Statistics/test/itkHistogramTest.cxx index 3ca02c5b3a0..00f64e03a4e 100644 --- a/Modules/Numerics/Statistics/test/itkHistogramTest.cxx +++ b/Modules/Numerics/Statistics/test/itkHistogramTest.cxx @@ -44,7 +44,7 @@ itkHistogramTest(int, char *[]) // initializes a 64 x 64 x 64 histogram with equal size interval HistogramType::SizeType size(numberOfComponents); size.Fill(64); - unsigned long totalSize = size[0] * size[1] * size[2]; + const unsigned long totalSize = size[0] * size[1] * size[2]; MeasurementVectorType lowerBound(numberOfComponents); MeasurementVectorType upperBound(numberOfComponents); @@ -334,8 +334,8 @@ itkHistogramTest(int, char *[]) MeasurementVectorType measurement = histogram->GetMeasurementVector(index); for (unsigned int kid0 = 0; kid0 < numberOfComponents; ++kid0) { - float expectedValF = 8.0; - float obtainedValF = measurement[kid0]; + const float expectedValF = 8.0; + const float obtainedValF = measurement[kid0]; if (itk::Math::NotAlmostEquals(obtainedValF, expectedValF)) { std::cerr << "Test failed!" << std::endl; @@ -352,8 +352,8 @@ itkHistogramTest(int, char *[]) measurement = histogram->GetMeasurementVector(index); for (unsigned int kid1 = 0; kid1 < numberOfComponents; ++kid1) { - float expectedValF = 8.0; - float obtainedValF = measurement[kid1]; + const float expectedValF = 8.0; + const float obtainedValF = measurement[kid1]; if (itk::Math::NotAlmostEquals(obtainedValF, expectedValF)) { std::cerr << "Test failed!" << std::endl; @@ -369,8 +369,8 @@ itkHistogramTest(int, char *[]) measurement = histogram->GetMeasurementVector(instanceId); for (unsigned int kid2 = 0; kid2 < numberOfComponents; ++kid2) { - float expectedValF = 8.0; - float obtainedValF = measurement[kid2]; + const float expectedValF = 8.0; + const float obtainedValF = measurement[kid2]; if (itk::Math::NotAlmostEquals(obtainedValF, expectedValF)) { std::cerr << "Test failed!" << std::endl; @@ -502,16 +502,16 @@ itkHistogramTest(int, char *[]) ITK_TEST_EXPECT_TRUE(histogram->GetIndex(measurementVectorAbove, aboveUpperIndex)); // Get the mean value for a dimension - unsigned int dimension = 0; - double mean = histogram->Mean(dimension); + const unsigned int dimension = 0; + const double mean = histogram->Mean(dimension); std::cout << "Mean value along dimension " << dimension << " : " << mean << std::endl; HistogramType::Iterator itr = histogram->Begin(); HistogramType::Iterator end = histogram->End(); - HistogramType::TotalAbsoluteFrequencyType totalFrequency = histogram->GetTotalFrequency(); + const HistogramType::TotalAbsoluteFrequencyType totalFrequency = histogram->GetTotalFrequency(); - InstanceIdentifier histogramSize = histogram->Size(); + const InstanceIdentifier histogramSize = histogram->Size(); while (itr != end) { @@ -519,7 +519,7 @@ itkHistogramTest(int, char *[]) ++itr; } - HistogramType::TotalAbsoluteFrequencyType newTotalFrequency = histogram->GetTotalFrequency(); + const HistogramType::TotalAbsoluteFrequencyType newTotalFrequency = histogram->GetTotalFrequency(); ITK_TEST_EXPECT_EQUAL(newTotalFrequency, histogramSize + totalFrequency); // Exercise GetIndex() method in the iterator. @@ -546,8 +546,8 @@ itkHistogramTest(int, char *[]) HistogramType::BinMinVectorType binDimensionMinimums = histogram->GetDimensionMins(dim); for (unsigned int k = 0; k < size2[dim]; ++k) { - HistogramType::MeasurementType minA = binMinimums[dim][k]; - HistogramType::MeasurementType minB = binDimensionMinimums[k]; + const HistogramType::MeasurementType minA = binMinimums[dim][k]; + const HistogramType::MeasurementType minB = binDimensionMinimums[k]; if (itk::Math::abs(minA - minB) > epsilon) { std::cerr.precision(static_cast(itk::Math::abs(std::log10(epsilon)))); @@ -560,7 +560,7 @@ itkHistogramTest(int, char *[]) return EXIT_FAILURE; } - HistogramType::MeasurementType minC = histogram->GetBinMin(dim, k); + const HistogramType::MeasurementType minC = histogram->GetBinMin(dim, k); if (itk::Math::abs(minA - minC) > epsilon) { std::cerr.precision(static_cast(itk::Math::abs(std::log10(epsilon)))); @@ -581,8 +581,8 @@ itkHistogramTest(int, char *[]) HistogramType::BinMaxVectorType binDimensionMaximums = histogram->GetDimensionMaxs(dim); for (unsigned int k = 0; k < size2[dim]; ++k) { - HistogramType::MeasurementType maxA = binMaximums[dim][k]; - HistogramType::MeasurementType maxB = binDimensionMaximums[k]; + const HistogramType::MeasurementType maxA = binMaximums[dim][k]; + const HistogramType::MeasurementType maxB = binDimensionMaximums[k]; if (itk::Math::abs(maxA - maxB) > epsilon) { std::cerr.precision(static_cast(itk::Math::abs(std::log10(epsilon)))); @@ -595,7 +595,7 @@ itkHistogramTest(int, char *[]) return EXIT_FAILURE; } - HistogramType::MeasurementType maxC = histogram->GetBinMax(dim, k); + const HistogramType::MeasurementType maxC = histogram->GetBinMax(dim, k); if (itk::Math::abs(maxA - maxC) > epsilon) { std::cerr.precision(static_cast(itk::Math::abs(std::log10(epsilon)))); @@ -614,8 +614,8 @@ itkHistogramTest(int, char *[]) // Test methods specific to Iterators { using IteratorType = HistogramType::Iterator; - IteratorType iter = histogram->Begin(); - IteratorType iter2 = histogram->End(); + const IteratorType iter = histogram->Begin(); + IteratorType iter2 = histogram->End(); iter2 = iter; ITK_TEST_EXPECT_TRUE(iter == iter2); @@ -632,42 +632,42 @@ itkHistogramTest(int, char *[]) ITK_TEST_EXPECT_EQUAL(counter, histogram->Size()); - IteratorType iter4(iter2); + const IteratorType iter4(iter2); ITK_TEST_EXPECT_TRUE(iter4 == iter2); - IteratorType iter5 = iter2; + const IteratorType iter5 = iter2; ITK_TEST_EXPECT_TRUE(iter5 == iter2); - itk::Statistics::Sample::InstanceIdentifier id2 = 7; - IteratorType iter6(id2, histogram); + const itk::Statistics::Sample::InstanceIdentifier id2 = 7; + const IteratorType iter6(id2, histogram); ITK_TEST_EXPECT_EQUAL(iter6.GetInstanceIdentifier(), id2); } // Test methods specific to ConstIterators { using ConstIteratorType = HistogramType::ConstIterator; - ConstIteratorType iter = histogram->Begin(); - ConstIteratorType iter2 = histogram->End(); + const ConstIteratorType iter = histogram->Begin(); + ConstIteratorType iter2 = histogram->End(); iter2 = iter; ITK_TEST_EXPECT_TRUE(!(iter != iter2)); ITK_TEST_EXPECT_TRUE(iter == iter2); - ConstIteratorType iter3(iter2); + const ConstIteratorType iter3(iter2); ITK_TEST_EXPECT_TRUE(iter3 == iter2); const HistogramType * constHistogram = histogram.GetPointer(); - ConstIteratorType iter4(constHistogram->Begin()); - ConstIteratorType iter5(histogram->Begin()); + const ConstIteratorType iter4(constHistogram->Begin()); + const ConstIteratorType iter5(histogram->Begin()); ITK_TEST_EXPECT_TRUE(iter5 == iter4); - ConstIteratorType iter6(constHistogram); - ConstIteratorType iter7(histogram); + const ConstIteratorType iter6(constHistogram); + const ConstIteratorType iter7(histogram); ITK_TEST_EXPECT_TRUE(iter6 == iter7); - ConstIteratorType iter8(histogram); - itk::Statistics::Sample::InstanceIdentifier id3 = 0; + const ConstIteratorType iter8(histogram); + const itk::Statistics::Sample::InstanceIdentifier id3 = 0; ITK_TEST_EXPECT_EQUAL(iter8.GetInstanceIdentifier(), id3); unsigned int counter = 0; diff --git a/Modules/Numerics/Statistics/test/itkHistogramToTextureFeaturesFilterNaNTest.cxx b/Modules/Numerics/Statistics/test/itkHistogramToTextureFeaturesFilterNaNTest.cxx index 1a9d0918328..3e4b28b47da 100644 --- a/Modules/Numerics/Statistics/test/itkHistogramToTextureFeaturesFilterNaNTest.cxx +++ b/Modules/Numerics/Statistics/test/itkHistogramToTextureFeaturesFilterNaNTest.cxx @@ -51,7 +51,7 @@ itkHistogramToTextureFeaturesFilterNaNTest(int, char *[]) filter->SetInput(generator->GetOutput()); filter->Update(); - TextureFilterType::MeasurementType correlation = filter->GetCorrelation(); + const TextureFilterType::MeasurementType correlation = filter->GetCorrelation(); std::cout << "Correlation: " << correlation << std::endl; if (itk::Math::isnan(correlation)) { diff --git a/Modules/Numerics/Statistics/test/itkHistogramToTextureFeaturesFilterTest.cxx b/Modules/Numerics/Statistics/test/itkHistogramToTextureFeaturesFilterTest.cxx index a238132b9f1..d2f0fd7cc5a 100644 --- a/Modules/Numerics/Statistics/test/itkHistogramToTextureFeaturesFilterTest.cxx +++ b/Modules/Numerics/Statistics/test/itkHistogramToTextureFeaturesFilterTest.cxx @@ -137,23 +137,23 @@ itkHistogramToTextureFeaturesFilterTest(int, char *[]) return EXIT_FAILURE; } - double trueEnergy = 0.295; - double trueEntropy = 2.26096; - double trueCorrelation = 0.12819; - double trueInverseDifferenceMoment = 0.85; - double trueInertia = 0.3; - double trueClusterShade = 139.1879; - double trueClusterProminence = 2732.557; - double trueHaralickCorrelation = 2264.549; - - double energy = filter->GetEnergy(); - double entropy = filter->GetEntropy(); - double correlation = filter->GetCorrelation(); - double inverseDifferenceMoment = filter->GetInverseDifferenceMoment(); - double inertia = filter->GetInertia(); - double clusterShade = filter->GetClusterShade(); - double clusterProminence = filter->GetClusterProminence(); - double haralickCorrelation = filter->GetHaralickCorrelation(); + const double trueEnergy = 0.295; + const double trueEntropy = 2.26096; + const double trueCorrelation = 0.12819; + const double trueInverseDifferenceMoment = 0.85; + const double trueInertia = 0.3; + const double trueClusterShade = 139.1879; + const double trueClusterProminence = 2732.557; + const double trueHaralickCorrelation = 2264.549; + + const double energy = filter->GetEnergy(); + const double entropy = filter->GetEntropy(); + const double correlation = filter->GetCorrelation(); + const double inverseDifferenceMoment = filter->GetInverseDifferenceMoment(); + const double inertia = filter->GetInertia(); + const double clusterShade = filter->GetClusterShade(); + const double clusterProminence = filter->GetClusterProminence(); + const double haralickCorrelation = filter->GetHaralickCorrelation(); if (itk::Math::abs(energy - trueEnergy) > 0.001) @@ -217,25 +217,28 @@ itkHistogramToTextureFeaturesFilterTest(int, char *[]) } // Get the texture features using GetFeature() method - double energy2 = filter->GetFeature(itk::Statistics::HistogramToTextureFeaturesFilterEnums::TextureFeature::Energy); + const double energy2 = + filter->GetFeature(itk::Statistics::HistogramToTextureFeaturesFilterEnums::TextureFeature::Energy); - double entropy2 = filter->GetFeature(itk::Statistics::HistogramToTextureFeaturesFilterEnums::TextureFeature::Entropy); + const double entropy2 = + filter->GetFeature(itk::Statistics::HistogramToTextureFeaturesFilterEnums::TextureFeature::Entropy); - double correlation2 = + const double correlation2 = filter->GetFeature(itk::Statistics::HistogramToTextureFeaturesFilterEnums::TextureFeature::Correlation); - double inverseDifferenceMoment2 = + const double inverseDifferenceMoment2 = filter->GetFeature(itk::Statistics::HistogramToTextureFeaturesFilterEnums::TextureFeature::InverseDifferenceMoment); - double inertia2 = filter->GetFeature(itk::Statistics::HistogramToTextureFeaturesFilterEnums::TextureFeature::Inertia); + const double inertia2 = + filter->GetFeature(itk::Statistics::HistogramToTextureFeaturesFilterEnums::TextureFeature::Inertia); - double clusterShade2 = + const double clusterShade2 = filter->GetFeature(itk::Statistics::HistogramToTextureFeaturesFilterEnums::TextureFeature::ClusterShade); - double clusterProminence2 = + const double clusterProminence2 = filter->GetFeature(itk::Statistics::HistogramToTextureFeaturesFilterEnums::TextureFeature::ClusterProminence); - double haralickCorrelation2 = + const double haralickCorrelation2 = filter->GetFeature(itk::Statistics::HistogramToTextureFeaturesFilterEnums::TextureFeature::HaralickCorrelation); if (itk::Math::abs(energy2 - trueEnergy) > 0.001) diff --git a/Modules/Numerics/Statistics/test/itkImageToHistogramFilterTest.cxx b/Modules/Numerics/Statistics/test/itkImageToHistogramFilterTest.cxx index 3187ac67390..992b7ef5ae2 100644 --- a/Modules/Numerics/Statistics/test/itkImageToHistogramFilterTest.cxx +++ b/Modules/Numerics/Statistics/test/itkImageToHistogramFilterTest.cxx @@ -80,13 +80,13 @@ itkImageToHistogramFilterTest(int, char *[]) using HistogramSizeType = HistogramFilterType::HistogramSizeType; using HistogramType = HistogramFilterType::HistogramType; - auto filter = HistogramFilterType::New(); - itk::SimpleFilterWatcher watcher(filter, "filter"); + auto filter = HistogramFilterType::New(); + const itk::SimpleFilterWatcher watcher(filter, "filter"); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, ImageToHistogramFilter, ImageSink); - unsigned int numberOfStreamDivisions = 1; + const unsigned int numberOfStreamDivisions = 1; filter->SetNumberOfStreamDivisions(numberOfStreamDivisions); ITK_TEST_SET_GET_VALUE(numberOfStreamDivisions, filter->GetNumberOfStreamDivisions()); @@ -138,7 +138,7 @@ itkImageToHistogramFilterTest(int, char *[]) } } - InputHistogramMeasurementVectorObjectType::Pointer histogramBinMinimumObject = + const InputHistogramMeasurementVectorObjectType::Pointer histogramBinMinimumObject = InputHistogramMeasurementVectorObjectType::New(); histogramBinMinimumObject->Set(histogramBinMinimum1); filter->SetHistogramBinMinimumInput(histogramBinMinimumObject); @@ -235,7 +235,7 @@ itkImageToHistogramFilterTest(int, char *[]) } - InputHistogramMeasurementVectorObjectType::Pointer histogramBinMaximumObject = + const InputHistogramMeasurementVectorObjectType::Pointer histogramBinMaximumObject = InputHistogramMeasurementVectorObjectType::New(); histogramBinMaximumObject->Set(histogramBinMaximum1); @@ -288,7 +288,7 @@ itkImageToHistogramFilterTest(int, char *[]) filter->SetHistogramBinMaximum(histogramBinMaximum1); - itk::ModifiedTimeType modifiedTime = filter->GetMTime(); + const itk::ModifiedTimeType modifiedTime = filter->GetMTime(); filter->SetHistogramBinMaximum(histogramBinMaximum1); if (filter->GetMTime() != modifiedTime) diff --git a/Modules/Numerics/Statistics/test/itkImageToHistogramFilterTest2.cxx b/Modules/Numerics/Statistics/test/itkImageToHistogramFilterTest2.cxx index 7487f51a6d5..0bb99fd8d5e 100644 --- a/Modules/Numerics/Statistics/test/itkImageToHistogramFilterTest2.cxx +++ b/Modules/Numerics/Statistics/test/itkImageToHistogramFilterTest2.cxx @@ -58,8 +58,8 @@ itkImageToHistogramFilterTest2(int argc, char * argv[]) using HistogramFilterType = itk::Statistics::ImageToHistogramFilter; - auto histogramFilter = HistogramFilterType::New(); - itk::SimpleFilterWatcher watcher(histogramFilter, "filter"); + auto histogramFilter = HistogramFilterType::New(); + const itk::SimpleFilterWatcher watcher(histogramFilter, "filter"); using HistogramMeasurementVectorType = HistogramFilterType::HistogramMeasurementVectorType; diff --git a/Modules/Numerics/Statistics/test/itkImageToListSampleAdaptorTest.cxx b/Modules/Numerics/Statistics/test/itkImageToListSampleAdaptorTest.cxx index 751279bd850..f42b7a364ce 100644 --- a/Modules/Numerics/Statistics/test/itkImageToListSampleAdaptorTest.cxx +++ b/Modules/Numerics/Statistics/test/itkImageToListSampleAdaptorTest.cxx @@ -34,12 +34,12 @@ itkImageToListSampleAdaptorTestTemplate() using SourceType = itk::RandomImageSource; auto source = SourceType::New(); - itk::SizeValueType size[Dimension] = { 17, 8, 20 }; - itk::SizeValueType totalSize = size[0] * size[1] * size[2]; + itk::SizeValueType size[Dimension] = { 17, 8, 20 }; + const itk::SizeValueType totalSize = size[0] * size[1] * size[2]; source->SetSize(size); - float minValue = -100.0; - float maxValue = 1000.0; + const float minValue = -100.0; + const float maxValue = 1000.0; source->SetMin(static_cast(minValue)); source->SetMax(static_cast(maxValue)); @@ -78,7 +78,7 @@ itkImageToListSampleAdaptorTestTemplate() try { - typename ImageToListSampleAdaptorType::MeasurementVectorType m = sample->GetMeasurementVector(0); + const typename ImageToListSampleAdaptorType::MeasurementVectorType m = sample->GetMeasurementVector(0); std::cerr << "Exception should have been thrown since the input image is not set yet " << m << std::endl; } catch (const itk::ExceptionObject & excp) @@ -88,7 +88,7 @@ itkImageToListSampleAdaptorTestTemplate() try { - typename ImageToListSampleAdaptorType::ImageConstPointer image = sample->GetImage(); + const typename ImageToListSampleAdaptorType::ImageConstPointer image = sample->GetImage(); std::cerr << "Exception should have been thrown since the input image is not set yet" << std::endl; } catch (const itk::ExceptionObject & excp) @@ -165,7 +165,7 @@ itkImageToListSampleAdaptorTestTemplate() IteratorType s_iter = sample->Begin(); // copy constructor - IteratorType bs_iter(s_iter); + const IteratorType bs_iter(s_iter); if (bs_iter != s_iter) { std::cerr << "Iterator::Copy Constructor failed" << std::endl; @@ -224,7 +224,7 @@ itkImageToListSampleAdaptorTestTemplate() ConstIteratorType s_iter = sample->Begin(); // copy constructor - ConstIteratorType bs_iter(s_iter); + const ConstIteratorType bs_iter(s_iter); if (bs_iter != s_iter) { std::cerr << "Iterator::Copy Constructor (from const) failed" << std::endl; @@ -241,8 +241,8 @@ itkImageToListSampleAdaptorTestTemplate() } // copy from non-const iterator - typename ImageToListSampleAdaptorType::Iterator nonconst_iter = sample->Begin(); - typename ImageToListSampleAdaptorType::ConstIterator s2_iter(nonconst_iter); + const typename ImageToListSampleAdaptorType::Iterator nonconst_iter = sample->Begin(); + typename ImageToListSampleAdaptorType::ConstIterator s2_iter(nonconst_iter); if (s2_iter != s_iter) { std::cerr << "Iterator::Copy Constructor (from non-const) failed" << std::endl; diff --git a/Modules/Numerics/Statistics/test/itkImageToListSampleAdaptorTest2.cxx b/Modules/Numerics/Statistics/test/itkImageToListSampleAdaptorTest2.cxx index ebe8c783dd4..f6e4c388943 100644 --- a/Modules/Numerics/Statistics/test/itkImageToListSampleAdaptorTest2.cxx +++ b/Modules/Numerics/Statistics/test/itkImageToListSampleAdaptorTest2.cxx @@ -40,7 +40,7 @@ itkImageToListSampleAdaptorTest2(int, char *[]) start.Fill(0); size.Fill(10); - ImageType::RegionType region(start, size); + const ImageType::RegionType region(start, size); image->SetRegions(region); image->Allocate(); using IteratorType = itk::ImageRegionIteratorWithIndex; @@ -93,8 +93,8 @@ itkImageToListSampleAdaptorTest2(int, char *[]) // using ConstIterator = ImageToListSampleAdaptorType::ConstIterator; - ConstIterator itrBegin = adaptor->Begin(); - ConstIterator itrEnd = adaptor->End(); + const ConstIterator itrBegin = adaptor->Begin(); + const ConstIterator itrEnd = adaptor->End(); ConstIterator citr = itrBegin; @@ -127,7 +127,7 @@ itkImageToListSampleAdaptorTest2(int, char *[]) vStart.Fill(0); vSize.Fill(10); - VariableLengthImageType::RegionType vRegion(vStart, vSize); + const VariableLengthImageType::RegionType vRegion(vStart, vSize); vImage->SetRegions(vRegion); vImage->Allocate(); @@ -191,7 +191,7 @@ itkImageToListSampleAdaptorTest2(int, char *[]) // using RGBPixelType = itk::RGBPixel; - unsigned int rgbMeasurementVectorSize = 3; + const unsigned int rgbMeasurementVectorSize = 3; using RGBImageType = itk::Image; @@ -203,7 +203,7 @@ itkImageToListSampleAdaptorTest2(int, char *[]) rgbStart.Fill(0); rgbSize.Fill(10); - RGBImageType::RegionType rgbRegion(rgbStart, rgbSize); + const RGBImageType::RegionType rgbRegion(rgbStart, rgbSize); rgbImage->SetRegions(rgbRegion); rgbImage->Allocate(); diff --git a/Modules/Numerics/Statistics/test/itkImageToListSampleFilterTest.cxx b/Modules/Numerics/Statistics/test/itkImageToListSampleFilterTest.cxx index 5b05a348a54..8fd2405d068 100644 --- a/Modules/Numerics/Statistics/test/itkImageToListSampleFilterTest.cxx +++ b/Modules/Numerics/Statistics/test/itkImageToListSampleFilterTest.cxx @@ -43,7 +43,7 @@ CreateImage() size[0] = 10; size[1] = 10; - ImageType::RegionType region(start, size); + const ImageType::RegionType region(start, size); image->SetRegions(region); image->Allocate(); using IteratorType = itk::ImageRegionIteratorWithIndex; @@ -70,7 +70,7 @@ CreateMaskImage() start.Fill(0); size.Fill(10); - MaskImageType::RegionType region(start, size); + const MaskImageType::RegionType region(start, size); image->SetRegions(region); image->AllocateInitialized(); @@ -83,7 +83,7 @@ CreateMaskImage() sizeMask[0] = 7; sizeMask[1] = 3; - MaskImageType::RegionType regionMask(startMask, sizeMask); + const MaskImageType::RegionType regionMask(startMask, sizeMask); using IteratorType = itk::ImageRegionIteratorWithIndex; IteratorType it(image, regionMask); it.GoToBegin(); @@ -111,7 +111,7 @@ CreateLargerMaskImage() size[0] = 13; size[1] = 17; - MaskImageType::RegionType region(start, size); + const MaskImageType::RegionType region(start, size); image->SetRegions(region); image->AllocateInitialized(); return image; @@ -121,8 +121,8 @@ CreateLargerMaskImage() int itkImageToListSampleFilterTest(int, char *[]) { - ImageType::Pointer image = CreateImage(); - MaskImageType::Pointer maskImage = CreateMaskImage(); + const ImageType::Pointer image = CreateImage(); + const MaskImageType::Pointer maskImage = CreateMaskImage(); // Generate a list sample from "image" confined to the mask, "maskImage". using ImageToListSampleFilterType = itk::Statistics::ImageToListSampleFilter; @@ -173,7 +173,7 @@ itkImageToListSampleFilterTest(int, char *[]) filter->Print(std::cout); - ImageToListSampleFilterType::MaskPixelType pixelType = filter->GetMaskValue(); + const ImageToListSampleFilterType::MaskPixelType pixelType = filter->GetMaskValue(); if (pixelType != 255) { diff --git a/Modules/Numerics/Statistics/test/itkImageToListSampleFilterTest2.cxx b/Modules/Numerics/Statistics/test/itkImageToListSampleFilterTest2.cxx index 9b04dde9b25..0ef9c730bba 100644 --- a/Modules/Numerics/Statistics/test/itkImageToListSampleFilterTest2.cxx +++ b/Modules/Numerics/Statistics/test/itkImageToListSampleFilterTest2.cxx @@ -42,7 +42,7 @@ itkImageToListSampleFilterTest2(int, char *[]) start.Fill(0); size.Fill(10); - ImageType::RegionType region(start, size); + const ImageType::RegionType region(start, size); image->SetRegions(region); image->Allocate(); using IteratorType = itk::ImageRegionIteratorWithIndex; @@ -73,7 +73,7 @@ itkImageToListSampleFilterTest2(int, char *[]) sizeMask[1] = 3; sizeMask[2] = 4; - MaskImageType::RegionType regionMask(startMask, sizeMask); + const MaskImageType::RegionType regionMask(startMask, sizeMask); using MaskIteratorType = itk::ImageRegionIteratorWithIndex; MaskIteratorType mit(maskImage, regionMask); mit.GoToBegin(); diff --git a/Modules/Numerics/Statistics/test/itkImageToListSampleFilterTest3.cxx b/Modules/Numerics/Statistics/test/itkImageToListSampleFilterTest3.cxx index 9a9fc5ba9db..440917317f9 100644 --- a/Modules/Numerics/Statistics/test/itkImageToListSampleFilterTest3.cxx +++ b/Modules/Numerics/Statistics/test/itkImageToListSampleFilterTest3.cxx @@ -47,7 +47,7 @@ itkImageToListSampleFilterTest3(int, char *[]) start.Fill(0); size.Fill(10); - ImageType::RegionType region(start, size); + const ImageType::RegionType region(start, size); image->SetRegions(region); image->Allocate(); using IteratorType = itk::ImageRegionIteratorWithIndex; @@ -82,7 +82,7 @@ itkImageToListSampleFilterTest3(int, char *[]) sizeMask[1] = 3; sizeMask[2] = 4; - MaskImageType::RegionType regionMask(startMask, sizeMask); + const MaskImageType::RegionType regionMask(startMask, sizeMask); using MaskIteratorType = itk::ImageRegionIteratorWithIndex; MaskIteratorType mit(maskImage, regionMask); mit.GoToBegin(); diff --git a/Modules/Numerics/Statistics/test/itkJointDomainImageToListSampleAdaptorTest.cxx b/Modules/Numerics/Statistics/test/itkJointDomainImageToListSampleAdaptorTest.cxx index 446f05cf950..c2b82548f1f 100644 --- a/Modules/Numerics/Statistics/test/itkJointDomainImageToListSampleAdaptorTest.cxx +++ b/Modules/Numerics/Statistics/test/itkJointDomainImageToListSampleAdaptorTest.cxx @@ -40,8 +40,8 @@ itkJointDomainImageToListSampleAdaptorTest(int, char *[]) start.Fill(0); size.Fill(10); - unsigned long totalSize = size[0] * size[1] * size[2]; - ImageType::RegionType region(start, size); + const unsigned long totalSize = size[0] * size[1] * size[2]; + const ImageType::RegionType region(start, size); image->SetRegions(region); image->Allocate(); @@ -237,7 +237,7 @@ itkJointDomainImageToListSampleAdaptorTest(int, char *[]) IteratorType s_iter = adaptor->Begin(); // copy constructor - IteratorType bs_iter(s_iter); + const IteratorType bs_iter(s_iter); if (bs_iter != s_iter) { std::cerr << "Iterator::Copy Constructor failed" << std::endl; @@ -297,7 +297,7 @@ itkJointDomainImageToListSampleAdaptorTest(int, char *[]) ConstIteratorType s_iter = adaptor->Begin(); // copy constructor - ConstIteratorType bs_iter(s_iter); + const ConstIteratorType bs_iter(s_iter); if (bs_iter != s_iter) { std::cerr << "Iterator::Copy Constructor (from const) failed" << std::endl; @@ -314,8 +314,8 @@ itkJointDomainImageToListSampleAdaptorTest(int, char *[]) } // copy from non-const iterator - JointDomainImageToListSampleAdaptorType::Iterator nonconst_iter = adaptor->Begin(); - JointDomainImageToListSampleAdaptorType::ConstIterator s2_iter(nonconst_iter); + const JointDomainImageToListSampleAdaptorType::Iterator nonconst_iter = adaptor->Begin(); + JointDomainImageToListSampleAdaptorType::ConstIterator s2_iter(nonconst_iter); if (s2_iter != s_iter) { std::cerr << "Iterator::Copy Constructor (from non-const) failed" << std::endl; diff --git a/Modules/Numerics/Statistics/test/itkKalmanLinearEstimatorTest.cxx b/Modules/Numerics/Statistics/test/itkKalmanLinearEstimatorTest.cxx index ba6872ae8f4..73cf5246065 100644 --- a/Modules/Numerics/Statistics/test/itkKalmanLinearEstimatorTest.cxx +++ b/Modules/Numerics/Statistics/test/itkKalmanLinearEstimatorTest.cxx @@ -84,7 +84,7 @@ itkKalmanLinearEstimatorTest(int, char *[]) } } - VectorType estimation = filter.GetEstimator(); + const VectorType estimation = filter.GetEstimator(); std::cout << std::endl << "The Right answer should be : " << std::endl; std::cout << planeEquation; @@ -92,8 +92,8 @@ itkKalmanLinearEstimatorTest(int, char *[]) std::cout << std::endl << "The Estimation is : " << std::endl; std::cout << estimation; - VectorType error = estimation - planeEquation; - ValueType errorMagnitude = dot_product(error, error); + const VectorType error = estimation - planeEquation; + const ValueType errorMagnitude = dot_product(error, error); std::cout << std::endl << "Errors : " << std::endl; std::cout << error; diff --git a/Modules/Numerics/Statistics/test/itkKdTreeBasedKmeansEstimatorTest.cxx b/Modules/Numerics/Statistics/test/itkKdTreeBasedKmeansEstimatorTest.cxx index 883499b87d5..63b1f63de83 100644 --- a/Modules/Numerics/Statistics/test/itkKdTreeBasedKmeansEstimatorTest.cxx +++ b/Modules/Numerics/Statistics/test/itkKdTreeBasedKmeansEstimatorTest.cxx @@ -39,10 +39,10 @@ itkKdTreeBasedKmeansEstimatorTest(int argc, char * argv[]) } - char * dataFileName = argv[1]; - int dataSize = 2000; - int bucketSize = std::stoi(argv[2]); - double minStandardDeviation = std::stod(argv[3]); + char * dataFileName = argv[1]; + const int dataSize = 2000; + const int bucketSize = std::stoi(argv[2]); + const double minStandardDeviation = std::stod(argv[3]); itk::Array trueMeans(4); trueMeans[0] = 99.261; @@ -55,12 +55,12 @@ itkKdTreeBasedKmeansEstimatorTest(int argc, char * argv[]) initialMeans[1] = 80.0; initialMeans[2] = 180.0; initialMeans[3] = 180.0; - int maximumIteration = 200; + const int maximumIteration = 200; /* Loading point data */ using PointSetType = itk::PointSet; - auto pointSet = PointSetType::New(); - PointSetType::PointsContainerPointer pointsContainer = PointSetType::PointsContainer::New(); + auto pointSet = PointSetType::New(); + const PointSetType::PointsContainerPointer pointsContainer = PointSetType::PointsContainer::New(); pointsContainer->Reserve(dataSize); pointSet->SetPoints(pointsContainer); @@ -160,7 +160,7 @@ itkKdTreeBasedKmeansEstimatorTest(int argc, char * argv[]) std::cout << " Mean displacement: " << std::endl; std::cout << " " << displacement << std::endl << std::endl; - double tolearancePercent = std::stod(argv[4]); + const double tolearancePercent = std::stod(argv[4]); // if the displacement of the estimates are within tolearancePercent% of // standardDeviation then we assume it is successful diff --git a/Modules/Numerics/Statistics/test/itkKdTreeGeneratorTest.cxx b/Modules/Numerics/Statistics/test/itkKdTreeGeneratorTest.cxx index 7ecc4e00df0..95fb57f5687 100644 --- a/Modules/Numerics/Statistics/test/itkKdTreeGeneratorTest.cxx +++ b/Modules/Numerics/Statistics/test/itkKdTreeGeneratorTest.cxx @@ -51,7 +51,7 @@ itkKdTreeGeneratorTest(int, char *[]) treeGenerator->SetSample(sample); ITK_TEST_SET_GET_VALUE(sample, treeGenerator->GetSourceSample()); - unsigned int bucketSize = 16; + const unsigned int bucketSize = 16; treeGenerator->SetBucketSize(bucketSize); ITK_TEST_SET_GET_VALUE(bucketSize, treeGenerator->GetBucketSize()); @@ -60,7 +60,7 @@ itkKdTreeGeneratorTest(int, char *[]) using TreeType = TreeGeneratorType::KdTreeType; using NodeType = TreeType::KdTreeNodeType; - TreeType::Pointer tree = treeGenerator->GetOutput(); + const TreeType::Pointer tree = treeGenerator->GetOutput(); NodeType * root = tree->GetRoot(); @@ -96,7 +96,7 @@ itkKdTreeGeneratorTest(int, char *[]) } distanceMetric->SetOrigin(origin); - unsigned int numberOfNeighbors = 3; + const unsigned int numberOfNeighbors = 3; TreeType::InstanceIdentifierVectorType neighbors; tree->Search(queryPoint, numberOfNeighbors, neighbors); @@ -110,7 +110,7 @@ itkKdTreeGeneratorTest(int, char *[]) << "] : " << distanceMetric->Evaluate(tree->GetMeasurementVector(neighbors[i])) << std::endl; } - double radius = 437.0; + const double radius = 437.0; tree->Search(queryPoint, radius, neighbors); @@ -151,7 +151,7 @@ itkKdTreeGeneratorTest(int, char *[]) using TreeType = TreeGeneratorType::KdTreeType; using NodeType = TreeType::KdTreeNodeType; - TreeType::Pointer tree = treeGenerator->GetOutput(); + const TreeType::Pointer tree = treeGenerator->GetOutput(); NodeType * root = tree->GetRoot(); @@ -187,7 +187,7 @@ itkKdTreeGeneratorTest(int, char *[]) } distanceMetric->SetOrigin(origin); - unsigned int numberOfNeighbors = 3; + const unsigned int numberOfNeighbors = 3; TreeType::InstanceIdentifierVectorType neighbors; tree->Search(queryPoint, numberOfNeighbors, neighbors); @@ -201,7 +201,7 @@ itkKdTreeGeneratorTest(int, char *[]) << "] : " << distanceMetric->Evaluate(tree->GetMeasurementVector(neighbors[i])) << std::endl; } - double radius = 437.0; + const double radius = 437.0; tree->Search(queryPoint, radius, neighbors); diff --git a/Modules/Numerics/Statistics/test/itkKdTreeTest1.cxx b/Modules/Numerics/Statistics/test/itkKdTreeTest1.cxx index 8f68a04b1eb..2f3d7ee03b7 100644 --- a/Modules/Numerics/Statistics/test/itkKdTreeTest1.cxx +++ b/Modules/Numerics/Statistics/test/itkKdTreeTest1.cxx @@ -37,7 +37,7 @@ itkKdTreeTest1(int argc, char * argv[]) // Random number generator using NumberGeneratorType = itk::Statistics::MersenneTwisterRandomVariateGenerator; - NumberGeneratorType::Pointer randomNumberGenerator = NumberGeneratorType::GetInstance(); + const NumberGeneratorType::Pointer randomNumberGenerator = NumberGeneratorType::GetInstance(); randomNumberGenerator->Initialize(); using MeasurementVectorType = itk::Array; @@ -73,11 +73,11 @@ itkKdTreeTest1(int argc, char * argv[]) using TreeType = TreeGeneratorType::KdTreeType; - TreeType::Pointer tree = treeGenerator->GetOutput(); + const TreeType::Pointer tree = treeGenerator->GetOutput(); MeasurementVectorType queryPoint(measurementVectorSize); - unsigned int numberOfNeighbors = 1; + const unsigned int numberOfNeighbors = 1; TreeType::InstanceIdentifierVectorType neighbors; MeasurementVectorType result(measurementVectorSize); @@ -159,8 +159,8 @@ itkKdTreeTest1(int argc, char * argv[]) // // Compute the distance to the "presumed" nearest neighbor // - double result_dist = std::sqrt((result[0] - queryPoint[0]) * (result[0] - queryPoint[0]) + - (result[1] - queryPoint[1]) * (result[1] - queryPoint[1])); + const double result_dist = std::sqrt((result[0] - queryPoint[0]) * (result[0] - queryPoint[0]) + + (result[1] - queryPoint[1]) * (result[1] - queryPoint[1])); // // Compute the distance to all other points, to verify diff --git a/Modules/Numerics/Statistics/test/itkKdTreeTest2.cxx b/Modules/Numerics/Statistics/test/itkKdTreeTest2.cxx index 6e122acd0c4..386f2abc255 100644 --- a/Modules/Numerics/Statistics/test/itkKdTreeTest2.cxx +++ b/Modules/Numerics/Statistics/test/itkKdTreeTest2.cxx @@ -75,7 +75,7 @@ itkKdTreeTest2(int argc, char * argv[]) bool testFailed = false; - TreeType::Pointer tree = treeGenerator->GetOutput(); + const TreeType::Pointer tree = treeGenerator->GetOutput(); using DistanceMetricType = itk::Statistics::EuclideanDistanceMetric; auto distanceMetric = DistanceMetricType::New(); @@ -104,7 +104,7 @@ itkKdTreeTest2(int argc, char * argv[]) distanceMetric->SetOrigin(origin); - unsigned int numberOfNeighbors = 1; + const unsigned int numberOfNeighbors = 1; TreeType::InstanceIdentifierVectorType neighbors; tree->Search(queryPoint, numberOfNeighbors, neighbors); diff --git a/Modules/Numerics/Statistics/test/itkKdTreeTest3.cxx b/Modules/Numerics/Statistics/test/itkKdTreeTest3.cxx index 3de2506541b..8ed46c88365 100644 --- a/Modules/Numerics/Statistics/test/itkKdTreeTest3.cxx +++ b/Modules/Numerics/Statistics/test/itkKdTreeTest3.cxx @@ -38,7 +38,7 @@ itkKdTreeTest3(int argc, char * argv[]) // Random number generator using NumberGeneratorType = itk::Statistics::MersenneTwisterRandomVariateGenerator; - NumberGeneratorType::Pointer randomNumberGenerator = NumberGeneratorType::GetInstance(); + const NumberGeneratorType::Pointer randomNumberGenerator = NumberGeneratorType::GetInstance(); randomNumberGenerator->Initialize(); using MeasurementVectorType = itk::Array; @@ -72,7 +72,7 @@ itkKdTreeTest3(int argc, char * argv[]) using TreeType = TreeGeneratorType::KdTreeType; - TreeType::Pointer tree = treeGenerator->GetOutput(); + const TreeType::Pointer tree = treeGenerator->GetOutput(); MeasurementVectorType queryPoint(measurementVectorSize); @@ -84,9 +84,9 @@ itkKdTreeTest3(int argc, char * argv[]) TreeType::InstanceIdentifierVectorType neighbors1; TreeType::InstanceIdentifierVectorType neighbors2; - MeasurementVectorType result(measurementVectorSize); - MeasurementVectorType test_point(measurementVectorSize); - MeasurementVectorType min_point(measurementVectorSize); + const MeasurementVectorType result(measurementVectorSize); + const MeasurementVectorType test_point(measurementVectorSize); + const MeasurementVectorType min_point(measurementVectorSize); unsigned int numberOfFailedPoints1 = 0; diff --git a/Modules/Numerics/Statistics/test/itkKdTreeTestSamplePoints.cxx b/Modules/Numerics/Statistics/test/itkKdTreeTestSamplePoints.cxx index 45d25935868..9e982d65107 100644 --- a/Modules/Numerics/Statistics/test/itkKdTreeTestSamplePoints.cxx +++ b/Modules/Numerics/Statistics/test/itkKdTreeTestSamplePoints.cxx @@ -68,11 +68,11 @@ itkKdTreeTestSamplePoints(int, char *[]) using TreeType = TreeGeneratorType::KdTreeType; - TreeType::Pointer tree = treeGenerator->GetOutput(); + const TreeType::Pointer tree = treeGenerator->GetOutput(); MeasurementVectorType queryPoint(measurementVectorSize); - unsigned int numberOfNeighbors = 1; + const unsigned int numberOfNeighbors = 1; TreeType::InstanceIdentifierVectorType neighbors; MeasurementVectorType result(measurementVectorSize); @@ -143,8 +143,8 @@ itkKdTreeTestSamplePoints(int, char *[]) // // Compute the distance to the "presumed" nearest neighbor // - double result_dist = std::sqrt((result[0] - queryPoint[0]) * (result[0] - queryPoint[0]) + - (result[1] - queryPoint[1]) * (result[1] - queryPoint[1])); + const double result_dist = std::sqrt((result[0] - queryPoint[0]) * (result[0] - queryPoint[0]) + + (result[1] - queryPoint[1]) * (result[1] - queryPoint[1])); // // Compute the distance to all other points, to verify diff --git a/Modules/Numerics/Statistics/test/itkListSampleTest.cxx b/Modules/Numerics/Statistics/test/itkListSampleTest.cxx index 528789d48ae..dd96dbd31e1 100644 --- a/Modules/Numerics/Statistics/test/itkListSampleTest.cxx +++ b/Modules/Numerics/Statistics/test/itkListSampleTest.cxx @@ -30,10 +30,10 @@ itkListSampleTest(int argc, char * argv[]) using MeasurementVectorType = itk::Array; using SampleType = itk::Statistics::ListSample; - SampleType::MeasurementVectorSizeType measurementVectorSize = std::stoi(argv[1]); + const SampleType::MeasurementVectorSizeType measurementVectorSize = std::stoi(argv[1]); std::cerr << "Measurement vector size: " << measurementVectorSize << std::endl; - unsigned int sampleSize = 25; + const unsigned int sampleSize = 25; auto sample = SampleType::New(); @@ -115,7 +115,7 @@ itkListSampleTest(int argc, char * argv[]) } std::cerr << "Trying SetMeasurementVector(4,mv)..."; - float tmp = mv[0]; + const float tmp = mv[0]; mv[0] += 1.0; sample->SetMeasurementVector(4, mv); if (mv != sample->GetMeasurementVector(4)) @@ -165,7 +165,7 @@ itkListSampleTest(int argc, char * argv[]) IteratorType s_iter = sample->Begin(); // copy constructor - IteratorType bs_iter(s_iter); + const IteratorType bs_iter(s_iter); if (bs_iter != s_iter) { std::cerr << "FAILED" << std::endl; @@ -259,7 +259,7 @@ itkListSampleTest(int argc, char * argv[]) ConstIteratorType s_iter = sample->Begin(); // copy constructor - ConstIteratorType bs_iter(s_iter); + const ConstIteratorType bs_iter(s_iter); if (bs_iter != s_iter) { std::cerr << "FAILED" << std::endl; @@ -286,8 +286,8 @@ itkListSampleTest(int argc, char * argv[]) // copy from non-const iterator std::cerr << "Trying Iterator::Copy Constructor (from non-const)..."; - SampleType::Iterator nonconst_iter = sample->Begin(); - SampleType::ConstIterator s2_iter(nonconst_iter); + const SampleType::Iterator nonconst_iter = sample->Begin(); + SampleType::ConstIterator s2_iter(nonconst_iter); if (s2_iter != s_iter) { std::cerr << "FAILED" << std::endl; @@ -398,7 +398,7 @@ itkListSampleTest(int argc, char * argv[]) constexpr unsigned int initialSize = 19; variableSizeSample->SetMeasurementVectorSize(initialSize); - unsigned int returnedSize = variableSizeSample->GetMeasurementVectorSize(); + const unsigned int returnedSize = variableSizeSample->GetMeasurementVectorSize(); if (initialSize != returnedSize) { @@ -449,7 +449,7 @@ itkListSampleTest(int argc, char * argv[]) bool exceptionWorks = false; try { - MeasurementVectorType measurement = sample->GetMeasurementVector(largestId + 10); + const MeasurementVectorType measurement = sample->GetMeasurementVector(largestId + 10); std::cerr << measurement << std::endl; } catch (const itk::ExceptionObject & excp) @@ -492,8 +492,8 @@ itkListSampleTest(int argc, char * argv[]) // Testing methods specific to Iterators { using IteratorType = SampleType::Iterator; - IteratorType iter = sample->Begin(); - IteratorType iter2 = sample->Begin(); + const IteratorType iter = sample->Begin(); + IteratorType iter2 = sample->Begin(); std::cerr << "Trying Iterator operator=()..."; iter2 = iter; @@ -538,7 +538,7 @@ itkListSampleTest(int argc, char * argv[]) } std::cerr << "Trying Iterator copy constructor..."; - IteratorType iter4(iter2); + const IteratorType iter4(iter2); if (iter4 != iter2) { std::cerr << "FAILED" << std::endl; @@ -550,7 +550,7 @@ itkListSampleTest(int argc, char * argv[]) } std::cerr << "Trying Iterator operator=..."; - IteratorType iter5 = iter2; + const IteratorType iter5 = iter2; if (iter5 != iter2) { std::cerr << "FAILED" << std::endl; @@ -583,8 +583,8 @@ itkListSampleTest(int argc, char * argv[]) { std::cerr << "Trying ConstIterator operator!=() and operator=()..."; using ConstIteratorType = SampleType::ConstIterator; - ConstIteratorType iter = sample->Begin(); - ConstIteratorType iter2 = sample->End(); + const ConstIteratorType iter = sample->Begin(); + ConstIteratorType iter2 = sample->End(); iter2 = iter; @@ -605,7 +605,7 @@ itkListSampleTest(int argc, char * argv[]) } std::cerr << "Trying ConstIterator copy constructor..."; - ConstIteratorType iter3(iter2); + const ConstIteratorType iter3(iter2); if (iter3 != iter2) { std::cerr << "FAILED" << std::endl; @@ -619,8 +619,8 @@ itkListSampleTest(int argc, char * argv[]) std::cerr << "Trying Constructor from const container Begin() differs from non-const Begin()..."; const SampleType * constSample = sample.GetPointer(); - ConstIteratorType iter4(constSample->Begin()); - ConstIteratorType iter5(sample->Begin()); + const ConstIteratorType iter4(constSample->Begin()); + const ConstIteratorType iter5(sample->Begin()); if (iter4 != iter5) { std::cerr << "FAILED" << std::endl; @@ -632,8 +632,8 @@ itkListSampleTest(int argc, char * argv[]) } std::cerr << "Trying ConstIterator Constructor from const container differs from non-const container..."; - ConstIteratorType iter6(constSample); - ConstIteratorType iter7(sample); + const ConstIteratorType iter6(constSample); + const ConstIteratorType iter7(sample); if (iter6 != iter7) { std::cerr << "FAILED" << std::endl; @@ -645,7 +645,7 @@ itkListSampleTest(int argc, char * argv[]) } std::cerr << "Trying Constructor with instance identifier 0..."; - ConstIteratorType iter8(sample); + const ConstIteratorType iter8(sample); if (iter8.GetInstanceIdentifier() != 0) { std::cerr << "FAILED" << std::endl; diff --git a/Modules/Numerics/Statistics/test/itkMahalanobisDistanceMetricTest.cxx b/Modules/Numerics/Statistics/test/itkMahalanobisDistanceMetricTest.cxx index ff7816cb35c..46a624358b9 100644 --- a/Modules/Numerics/Statistics/test/itkMahalanobisDistanceMetricTest.cxx +++ b/Modules/Numerics/Statistics/test/itkMahalanobisDistanceMetricTest.cxx @@ -87,8 +87,8 @@ itkMahalanobisDistanceMetricTest(int, char *[]) return EXIT_FAILURE; } - double epsilon = 1e-200; - double doubleMax = 1e+25; + const double epsilon = 1e-200; + const double doubleMax = 1e+25; distance->SetEpsilon(epsilon); distance->SetDoubleMax(doubleMax); @@ -117,8 +117,8 @@ itkMahalanobisDistanceMetricTest(int, char *[]) // Test if an exception is thrown if a covariance matrix is set with different // size - DistanceMetricType::CovarianceMatrixType covarianceMatrix2; - DistanceMetricType::MeasurementVectorSizeType measurementSize2 = 4; + DistanceMetricType::CovarianceMatrixType covarianceMatrix2; + const DistanceMetricType::MeasurementVectorSizeType measurementSize2 = 4; covarianceMatrix2.set_size(measurementSize2, measurementSize2); try @@ -186,7 +186,7 @@ itkMahalanobisDistanceMetricTest(int, char *[]) } // Run the distance metric with a single component measurement vector size - DistanceMetricType::MeasurementVectorSizeType singleComponentMeasurementVectorSize = 1; + const DistanceMetricType::MeasurementVectorSizeType singleComponentMeasurementVectorSize = 1; distance->SetMeasurementVectorSize(singleComponentMeasurementVectorSize); diff --git a/Modules/Numerics/Statistics/test/itkManhattanDistanceMetricTest.cxx b/Modules/Numerics/Statistics/test/itkManhattanDistanceMetricTest.cxx index 8368ba55f8a..86fa6f9b7bf 100644 --- a/Modules/Numerics/Statistics/test/itkManhattanDistanceMetricTest.cxx +++ b/Modules/Numerics/Statistics/test/itkManhattanDistanceMetricTest.cxx @@ -77,8 +77,8 @@ itkManhattanDistanceMetricTest(int, char *[]) measurement[1] = 3.3; measurement[2] = 4.0; - double trueValue = 5.0; - double distanceComputed = distance->Evaluate(measurement); + const double trueValue = 5.0; + const double distanceComputed = distance->Evaluate(measurement); constexpr double tolerance = 0.001; if (itk::Math::abs(distanceComputed - trueValue) > tolerance) @@ -95,8 +95,8 @@ itkManhattanDistanceMetricTest(int, char *[]) measurement2[1] = 3.5; measurement2[2] = 3.5; - double trueValue2 = 1.7; - double distanceComputed2 = distance->Evaluate(measurement, measurement2); + const double trueValue2 = 1.7; + const double distanceComputed2 = distance->Evaluate(measurement, measurement2); if (itk::Math::abs(distanceComputed2 - trueValue2) > tolerance) { diff --git a/Modules/Numerics/Statistics/test/itkMeanSampleFilterTest.cxx b/Modules/Numerics/Statistics/test/itkMeanSampleFilterTest.cxx index b6fdbd638e5..403f878fdad 100644 --- a/Modules/Numerics/Statistics/test/itkMeanSampleFilterTest.cxx +++ b/Modules/Numerics/Statistics/test/itkMeanSampleFilterTest.cxx @@ -100,7 +100,7 @@ itkMeanSampleFilterTest(int, char *[]) std::cout << meanOutput[0] << ' ' << mean[0] << ' ' << meanOutput[1] << ' ' << mean[1] << ' ' << std::endl; - FilterType::MeasurementVectorType::ValueType epsilon = 1e-6; + const FilterType::MeasurementVectorType::ValueType epsilon = 1e-6; if ((itk::Math::abs(meanOutput[0] - mean[0]) > epsilon) || (itk::Math::abs(meanOutput[1] - mean[1]) > epsilon)) { diff --git a/Modules/Numerics/Statistics/test/itkMeanSampleFilterTest2.cxx b/Modules/Numerics/Statistics/test/itkMeanSampleFilterTest2.cxx index 71bcede1f86..49e0227f28e 100644 --- a/Modules/Numerics/Statistics/test/itkMeanSampleFilterTest2.cxx +++ b/Modules/Numerics/Statistics/test/itkMeanSampleFilterTest2.cxx @@ -81,7 +81,7 @@ itkMeanSampleFilterTest2(int, char *[]) << std::endl; // FilterType::MeasurementVectorType::ValueType is an int in this case - FilterType::MeasurementVectorType::ValueType epsilon = 0; + const FilterType::MeasurementVectorType::ValueType epsilon = 0; if ((itk::Math::abs(meanOutput[0] - expectedMean[0]) > epsilon) || (itk::Math::abs(meanOutput[1] - expectedMean[1]) > epsilon)) diff --git a/Modules/Numerics/Statistics/test/itkMeanSampleFilterTest3.cxx b/Modules/Numerics/Statistics/test/itkMeanSampleFilterTest3.cxx index 3e248444c91..a2c6c791464 100644 --- a/Modules/Numerics/Statistics/test/itkMeanSampleFilterTest3.cxx +++ b/Modules/Numerics/Statistics/test/itkMeanSampleFilterTest3.cxx @@ -81,8 +81,8 @@ itkMeanSampleFilterTest3(int, char *[]) memberFunction->SetMean(mean); memberFunction->SetCovariance(covariance); - HistogramType::Iterator itr = histogram->Begin(); - HistogramType::Iterator end = histogram->End(); + HistogramType::Iterator itr = histogram->Begin(); + const HistogramType::Iterator end = histogram->End(); using AbsoluteFrequencyType = HistogramType::AbsoluteFrequencyType; @@ -120,7 +120,7 @@ itkMeanSampleFilterTest3(int, char *[]) std::cout << "GetMeasurementVectorSize = " << filter->GetMeasurementVectorSize() << std::endl; - double epsilon = 1; + const double epsilon = 1; for (unsigned int i = 0; i < MeasurementVectorSize; ++i) { diff --git a/Modules/Numerics/Statistics/test/itkMembershipFunctionBaseTest.cxx b/Modules/Numerics/Statistics/test/itkMembershipFunctionBaseTest.cxx index 5c7374d0ed1..170fa589624 100644 --- a/Modules/Numerics/Statistics/test/itkMembershipFunctionBaseTest.cxx +++ b/Modules/Numerics/Statistics/test/itkMembershipFunctionBaseTest.cxx @@ -49,7 +49,7 @@ class MyMembershipFunctionBase : public MembershipFunctionBaseSetMeasurementVectorSize(newSize); // for code coverage if (function->GetMeasurementVectorSize() != newSize) diff --git a/Modules/Numerics/Statistics/test/itkMembershipSampleTest1.cxx b/Modules/Numerics/Statistics/test/itkMembershipSampleTest1.cxx index 6857ef0c6a6..a93812e7b85 100644 --- a/Modules/Numerics/Statistics/test/itkMembershipSampleTest1.cxx +++ b/Modules/Numerics/Statistics/test/itkMembershipSampleTest1.cxx @@ -59,7 +59,7 @@ itkMembershipSampleTest1(int, char *[]) membershipSample->Print(std::cout); // Add measurement vectors to the list sample - unsigned int sampleSize = 10; + const unsigned int sampleSize = 10; MeasurementVectorType mv; std::cout << "Sample length = " << sample->GetMeasurementVectorSize() << std::endl; @@ -75,8 +75,8 @@ itkMembershipSampleTest1(int, char *[]) } // Add instances to the membership sample - SampleType::ConstIterator begin = sample->Begin(); - SampleType::ConstIterator end = sample->End(); + const SampleType::ConstIterator begin = sample->Begin(); + const SampleType::ConstIterator end = sample->End(); SampleType::ConstIterator iter = begin; @@ -90,7 +90,7 @@ itkMembershipSampleTest1(int, char *[]) { classLabel = 1; } - SampleType::InstanceIdentifier id = iter.GetInstanceIdentifier(); + const SampleType::InstanceIdentifier id = iter.GetInstanceIdentifier(); membershipSample->AddInstance(classLabel, id); ++iter; ++sampleCounter; @@ -106,7 +106,7 @@ itkMembershipSampleTest1(int, char *[]) IteratorType s_iter = membershipSample->Begin(); - IteratorType bs_iter(s_iter); + const IteratorType bs_iter(s_iter); if (bs_iter != s_iter) { std::cerr << "Iterator::Copy Constructor failed" << std::endl; @@ -181,7 +181,7 @@ itkMembershipSampleTest1(int, char *[]) ConstIteratorType s_iter = membershipSample->Begin(); // copy constructor - ConstIteratorType bs_iter(s_iter); + const ConstIteratorType bs_iter(s_iter); if (bs_iter != s_iter) { std::cerr << "Iterator::Copy Constructor (from const) failed" << std::endl; @@ -198,8 +198,8 @@ itkMembershipSampleTest1(int, char *[]) } // copy from non-const iterator - MembershipSampleType::Iterator nonconst_iter = membershipSample->Begin(); - MembershipSampleType::ConstIterator s2_iter(nonconst_iter); + const MembershipSampleType::Iterator nonconst_iter = membershipSample->Begin(); + MembershipSampleType::ConstIterator s2_iter(nonconst_iter); if (s2_iter != s_iter) { std::cerr << "Iterator::Copy Constructor (from non-const) failed" << std::endl; diff --git a/Modules/Numerics/Statistics/test/itkMembershipSampleTest2.cxx b/Modules/Numerics/Statistics/test/itkMembershipSampleTest2.cxx index ad2e26fe07f..f282d2bf93f 100644 --- a/Modules/Numerics/Statistics/test/itkMembershipSampleTest2.cxx +++ b/Modules/Numerics/Statistics/test/itkMembershipSampleTest2.cxx @@ -59,7 +59,7 @@ itkMembershipSampleTest2(int, char *[]) membershipSample->Print(std::cout); // Add measurement vectors to the list sample - unsigned int sampleSize = 10; + const unsigned int sampleSize = 10; MeasurementVectorType mv; itk::NumericTraits::SetLength(mv, MeasurementVectorSize); @@ -76,8 +76,8 @@ itkMembershipSampleTest2(int, char *[]) } // Add instances to the membership sample - SampleType::ConstIterator begin = sample->Begin(); - SampleType::ConstIterator end = sample->End(); + const SampleType::ConstIterator begin = sample->Begin(); + const SampleType::ConstIterator end = sample->End(); SampleType::ConstIterator iter = begin; @@ -91,7 +91,7 @@ itkMembershipSampleTest2(int, char *[]) { classLabel = 1; } - SampleType::InstanceIdentifier id = iter.GetInstanceIdentifier(); + const SampleType::InstanceIdentifier id = iter.GetInstanceIdentifier(); membershipSample->AddInstance(classLabel, id); ++iter; ++sampleCounter; @@ -107,7 +107,7 @@ itkMembershipSampleTest2(int, char *[]) IteratorType s_iter = membershipSample->Begin(); - IteratorType bs_iter(s_iter); + const IteratorType bs_iter(s_iter); if (bs_iter != s_iter) { std::cerr << "Iterator::Copy Constructor failed" << std::endl; @@ -182,7 +182,7 @@ itkMembershipSampleTest2(int, char *[]) ConstIteratorType s_iter = membershipSample->Begin(); // copy constructor - ConstIteratorType bs_iter(s_iter); + const ConstIteratorType bs_iter(s_iter); if (bs_iter != s_iter) { std::cerr << "Iterator::Copy Constructor (from const) failed" << std::endl; @@ -199,8 +199,8 @@ itkMembershipSampleTest2(int, char *[]) } // copy from non-const iterator - MembershipSampleType::Iterator nonconst_iter = membershipSample->Begin(); - MembershipSampleType::ConstIterator s2_iter(nonconst_iter); + const MembershipSampleType::Iterator nonconst_iter = membershipSample->Begin(); + MembershipSampleType::ConstIterator s2_iter(nonconst_iter); if (s2_iter != s_iter) { std::cerr << "Iterator::Copy Constructor (from non-const) failed" << std::endl; diff --git a/Modules/Numerics/Statistics/test/itkMembershipSampleTest3.cxx b/Modules/Numerics/Statistics/test/itkMembershipSampleTest3.cxx index aa04f2febe8..54b3cbe552e 100644 --- a/Modules/Numerics/Statistics/test/itkMembershipSampleTest3.cxx +++ b/Modules/Numerics/Statistics/test/itkMembershipSampleTest3.cxx @@ -60,7 +60,7 @@ itkMembershipSampleTest3(int, char *[]) membershipSample->Print(std::cout); // Add measurement vectors to the list sample - unsigned int sampleSize = 10; + const unsigned int sampleSize = 10; MeasurementVectorType mv; itk::NumericTraits::SetLength(mv, MeasurementVectorSize); @@ -77,8 +77,8 @@ itkMembershipSampleTest3(int, char *[]) } // Add instances to the membership sample - SampleType::ConstIterator begin = sample->Begin(); - SampleType::ConstIterator end = sample->End(); + const SampleType::ConstIterator begin = sample->Begin(); + const SampleType::ConstIterator end = sample->End(); SampleType::ConstIterator iter = begin; @@ -92,7 +92,7 @@ itkMembershipSampleTest3(int, char *[]) { classLabel = 1; } - SampleType::InstanceIdentifier id = iter.GetInstanceIdentifier(); + const SampleType::InstanceIdentifier id = iter.GetInstanceIdentifier(); membershipSample->AddInstance(classLabel, id); ++iter; ++sampleCounter; @@ -108,7 +108,7 @@ itkMembershipSampleTest3(int, char *[]) IteratorType s_iter = membershipSample->Begin(); - IteratorType bs_iter(s_iter); + const IteratorType bs_iter(s_iter); if (bs_iter != s_iter) { std::cerr << "Iterator::Copy Constructor failed" << std::endl; @@ -183,7 +183,7 @@ itkMembershipSampleTest3(int, char *[]) ConstIteratorType s_iter = membershipSample->Begin(); // copy constructor - ConstIteratorType bs_iter(s_iter); + const ConstIteratorType bs_iter(s_iter); if (bs_iter != s_iter) { std::cerr << "Iterator::Copy Constructor (from const) failed" << std::endl; @@ -200,8 +200,8 @@ itkMembershipSampleTest3(int, char *[]) } // copy from non-const iterator - MembershipSampleType::Iterator nonconst_iter = membershipSample->Begin(); - MembershipSampleType::ConstIterator s2_iter(nonconst_iter); + const MembershipSampleType::Iterator nonconst_iter = membershipSample->Begin(); + MembershipSampleType::ConstIterator s2_iter(nonconst_iter); if (s2_iter != s_iter) { std::cerr << "Iterator::Copy Constructor (from non-const) failed" << std::endl; diff --git a/Modules/Numerics/Statistics/test/itkMembershipSampleTest4.cxx b/Modules/Numerics/Statistics/test/itkMembershipSampleTest4.cxx index a569b160cad..d41b0c43144 100644 --- a/Modules/Numerics/Statistics/test/itkMembershipSampleTest4.cxx +++ b/Modules/Numerics/Statistics/test/itkMembershipSampleTest4.cxx @@ -60,7 +60,7 @@ itkMembershipSampleTest4(int, char *[]) membershipSample->Print(std::cout); // Add measurement vectors to the list sample - unsigned int sampleSize = 10; + const unsigned int sampleSize = 10; MeasurementVectorType mv; itk::NumericTraits::SetLength(mv, MeasurementVectorSize); @@ -77,8 +77,8 @@ itkMembershipSampleTest4(int, char *[]) } // Add instances to the membership sample - SampleType::ConstIterator begin = sample->Begin(); - SampleType::ConstIterator end = sample->End(); + const SampleType::ConstIterator begin = sample->Begin(); + const SampleType::ConstIterator end = sample->End(); SampleType::ConstIterator iter = begin; @@ -92,7 +92,7 @@ itkMembershipSampleTest4(int, char *[]) { classLabel = 1; } - SampleType::InstanceIdentifier id = iter.GetInstanceIdentifier(); + const SampleType::InstanceIdentifier id = iter.GetInstanceIdentifier(); membershipSample->AddInstance(classLabel, id); ++iter; ++sampleCounter; @@ -108,7 +108,7 @@ itkMembershipSampleTest4(int, char *[]) IteratorType s_iter = membershipSample->Begin(); - IteratorType bs_iter(s_iter); + const IteratorType bs_iter(s_iter); if (bs_iter != s_iter) { std::cerr << "Iterator::Copy Constructor failed" << std::endl; @@ -183,7 +183,7 @@ itkMembershipSampleTest4(int, char *[]) ConstIteratorType s_iter = membershipSample->Begin(); // copy constructor - ConstIteratorType bs_iter(s_iter); + const ConstIteratorType bs_iter(s_iter); if (bs_iter != s_iter) { std::cerr << "Iterator::Copy Constructor (from const) failed" << std::endl; @@ -200,8 +200,8 @@ itkMembershipSampleTest4(int, char *[]) } // copy from non-const iterator - MembershipSampleType::Iterator nonconst_iter = membershipSample->Begin(); - MembershipSampleType::ConstIterator s2_iter(nonconst_iter); + const MembershipSampleType::Iterator nonconst_iter = membershipSample->Begin(); + MembershipSampleType::ConstIterator s2_iter(nonconst_iter); if (s2_iter != s_iter) { std::cerr << "Iterator::Copy Constructor (from non-const) failed" << std::endl; diff --git a/Modules/Numerics/Statistics/test/itkPointSetToListSampleAdaptorTest.cxx b/Modules/Numerics/Statistics/test/itkPointSetToListSampleAdaptorTest.cxx index 2157b124fc3..ee44babe850 100644 --- a/Modules/Numerics/Statistics/test/itkPointSetToListSampleAdaptorTest.cxx +++ b/Modules/Numerics/Statistics/test/itkPointSetToListSampleAdaptorTest.cxx @@ -30,7 +30,7 @@ itkPointSetToListSampleAdaptorTest(int, char *[]) auto pointSet = PointSetType::New(); PointSetType::PointType point; - unsigned int numberOfPoints = 10; + const unsigned int numberOfPoints = 10; for (unsigned int i = 0; i < numberOfPoints; ++i) { point[0] = i * 3; @@ -68,7 +68,7 @@ itkPointSetToListSampleAdaptorTest(int, char *[]) try { - PointSetToListSampleAdaptorType::MeasurementVectorType m = listSample->GetMeasurementVector(0); + const PointSetToListSampleAdaptorType::MeasurementVectorType m = listSample->GetMeasurementVector(0); std::cerr << "Exception should have been thrown since the input point set is not set yet" << std::endl; std::cerr << "The invalid listSample->GetMeasurementVector is: " << m << std::endl; exceptionsProperlyCaught = false; @@ -147,8 +147,8 @@ itkPointSetToListSampleAdaptorTest(int, char *[]) for (unsigned int i = 0; i < numberOfPoints; ++i) { - PointSetToListSampleAdaptorType::InstanceIdentifier id = i; - PointSetType::PointType tempPointSet(0.0); + const PointSetToListSampleAdaptorType::InstanceIdentifier id = i; + PointSetType::PointType tempPointSet(0.0); pointSet->GetPoint(i, &tempPointSet); if (listSample->GetMeasurementVector(id) != tempPointSet) @@ -167,7 +167,7 @@ itkPointSetToListSampleAdaptorTest(int, char *[]) IteratorType s_iter = listSample->Begin(); // copy constructor - IteratorType bs_iter(s_iter); + const IteratorType bs_iter(s_iter); if (bs_iter != s_iter) { std::cerr << "Iterator::Copy Constructor failed" << std::endl; @@ -225,7 +225,7 @@ itkPointSetToListSampleAdaptorTest(int, char *[]) ConstIteratorType s_iter = listSample->Begin(); // copy constructor - ConstIteratorType bs_iter(s_iter); + const ConstIteratorType bs_iter(s_iter); if (bs_iter != s_iter) { std::cerr << "Iterator::Copy Constructor (from const) failed" << std::endl; @@ -242,8 +242,8 @@ itkPointSetToListSampleAdaptorTest(int, char *[]) } // copy from non-const iterator - PointSetToListSampleAdaptorType::Iterator nonconst_iter = listSample->Begin(); - PointSetToListSampleAdaptorType::ConstIterator s2_iter(nonconst_iter); + const PointSetToListSampleAdaptorType::Iterator nonconst_iter = listSample->Begin(); + PointSetToListSampleAdaptorType::ConstIterator s2_iter(nonconst_iter); if (s2_iter != s_iter) { std::cerr << "Iterator::Copy Constructor (from non-const) failed" << std::endl; diff --git a/Modules/Numerics/Statistics/test/itkRandomVariateGeneratorBaseTest.cxx b/Modules/Numerics/Statistics/test/itkRandomVariateGeneratorBaseTest.cxx index 795263f5199..0b2738b9617 100644 --- a/Modules/Numerics/Statistics/test/itkRandomVariateGeneratorBaseTest.cxx +++ b/Modules/Numerics/Statistics/test/itkRandomVariateGeneratorBaseTest.cxx @@ -39,7 +39,7 @@ class VariateGeneratorTestHelper : public RandomVariateGeneratorBase double GetVariate() override { - double theAnswerToTheQuestionOfLifeTheUniverseAndEverything = 42.0; + const double theAnswerToTheQuestionOfLifeTheUniverseAndEverything = 42.0; return theAnswerToTheQuestionOfLifeTheUniverseAndEverything; } diff --git a/Modules/Numerics/Statistics/test/itkSampleTest.cxx b/Modules/Numerics/Statistics/test/itkSampleTest.cxx index cbde578a832..5c3d56b6e69 100644 --- a/Modules/Numerics/Statistics/test/itkSampleTest.cxx +++ b/Modules/Numerics/Statistics/test/itkSampleTest.cxx @@ -152,12 +152,12 @@ itkSampleTest(int, char *[]) using AbsoluteFrequencyType = SampleType::AbsoluteFrequencyType; - AbsoluteFrequencyType frequency = 17; + const AbsoluteFrequencyType frequency = 17; sample->AddMeasurementVector(measure, frequency); - MeasurementVectorType measureBack = sample->GetMeasurementVector(0); - AbsoluteFrequencyType frequencyBack = sample->GetFrequency(0); + MeasurementVectorType measureBack = sample->GetMeasurementVector(0); + const AbsoluteFrequencyType frequencyBack = sample->GetFrequency(0); if (frequencyBack != frequency) { diff --git a/Modules/Numerics/Statistics/test/itkSampleTest2.cxx b/Modules/Numerics/Statistics/test/itkSampleTest2.cxx index f1bdd6a4f40..8c2f3e8cf78 100644 --- a/Modules/Numerics/Statistics/test/itkSampleTest2.cxx +++ b/Modules/Numerics/Statistics/test/itkSampleTest2.cxx @@ -159,12 +159,12 @@ itkSampleTest2(int, char *[]) using AbsoluteFrequencyType = SampleType::AbsoluteFrequencyType; - AbsoluteFrequencyType frequency = 17; + const AbsoluteFrequencyType frequency = 17; sample->AddMeasurementVector(measure, frequency); - MeasurementVectorType measureBack = sample->GetMeasurementVector(0); - AbsoluteFrequencyType frequencyBack = sample->GetFrequency(0); + MeasurementVectorType measureBack = sample->GetMeasurementVector(0); + const AbsoluteFrequencyType frequencyBack = sample->GetFrequency(0); if (frequencyBack != frequency) { diff --git a/Modules/Numerics/Statistics/test/itkSampleTest3.cxx b/Modules/Numerics/Statistics/test/itkSampleTest3.cxx index c419b8f90cc..9baa27f11a3 100644 --- a/Modules/Numerics/Statistics/test/itkSampleTest3.cxx +++ b/Modules/Numerics/Statistics/test/itkSampleTest3.cxx @@ -160,12 +160,12 @@ itkSampleTest3(int, char *[]) using AbsoluteFrequencyType = SampleType::AbsoluteFrequencyType; - AbsoluteFrequencyType frequency = 17; + const AbsoluteFrequencyType frequency = 17; sample->AddMeasurementVector(measure, frequency); - MeasurementVectorType measureBack = sample->GetMeasurementVector(0); - AbsoluteFrequencyType frequencyBack = sample->GetFrequency(0); + MeasurementVectorType measureBack = sample->GetMeasurementVector(0); + const AbsoluteFrequencyType frequencyBack = sample->GetFrequency(0); if (frequencyBack != frequency) { diff --git a/Modules/Numerics/Statistics/test/itkSampleTest4.cxx b/Modules/Numerics/Statistics/test/itkSampleTest4.cxx index 72975c42b29..def9638ad01 100644 --- a/Modules/Numerics/Statistics/test/itkSampleTest4.cxx +++ b/Modules/Numerics/Statistics/test/itkSampleTest4.cxx @@ -160,12 +160,12 @@ itkSampleTest4(int, char *[]) using AbsoluteFrequencyType = SampleType::AbsoluteFrequencyType; - AbsoluteFrequencyType frequency = 17; + const AbsoluteFrequencyType frequency = 17; sample->AddMeasurementVector(measure, frequency); - MeasurementVectorType measureBack = sample->GetMeasurementVector(0); - AbsoluteFrequencyType frequencyBack = sample->GetFrequency(0); + MeasurementVectorType measureBack = sample->GetMeasurementVector(0); + const AbsoluteFrequencyType frequencyBack = sample->GetFrequency(0); if (frequencyBack != frequency) { diff --git a/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest.cxx b/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest.cxx index eb02ceabc02..ccf74253a19 100644 --- a/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest.cxx +++ b/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest.cxx @@ -393,7 +393,7 @@ itkSampleToHistogramFilterTest(int, char *[]) } - InputHistogramMeasurementVectorObjectType::Pointer histogramBinMinimumObject = + const InputHistogramMeasurementVectorObjectType::Pointer histogramBinMinimumObject = InputHistogramMeasurementVectorObjectType::New(); histogramBinMinimumObject->Set(histogramBinMinimum1); @@ -513,7 +513,7 @@ itkSampleToHistogramFilterTest(int, char *[]) } - InputHistogramMeasurementVectorObjectType::Pointer histogramBinMaximumObject = + const InputHistogramMeasurementVectorObjectType::Pointer histogramBinMaximumObject = InputHistogramMeasurementVectorObjectType::New(); histogramBinMaximumObject->Set(histogramBinMaximum1); diff --git a/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest3.cxx b/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest3.cxx index 9b372d2615a..0fb76a17890 100644 --- a/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest3.cxx +++ b/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest3.cxx @@ -127,8 +127,8 @@ itkSampleToHistogramFilterTest3(int, char *[]) } - HistogramType::ConstIterator histogramItr = histogram->Begin(); - HistogramType::ConstIterator histogramEnd = histogram->End(); + HistogramType::ConstIterator histogramItr = histogram->Begin(); + const HistogramType::ConstIterator histogramEnd = histogram->End(); constexpr unsigned int expectedFrequency1 = 1; while (histogramItr != histogramEnd) diff --git a/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest4.cxx b/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest4.cxx index 9fb106cbeae..6d3a34de95c 100644 --- a/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest4.cxx +++ b/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest4.cxx @@ -143,8 +143,8 @@ itkSampleToHistogramFilterTest4(int, char *[]) } - HistogramType::ConstIterator histogramItr = histogram->Begin(); - HistogramType::ConstIterator histogramEnd = histogram->End(); + HistogramType::ConstIterator histogramItr = histogram->Begin(); + const HistogramType::ConstIterator histogramEnd = histogram->End(); constexpr unsigned int expectedFrequency1 = 1; while (histogramItr != histogramEnd) diff --git a/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest5.cxx b/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest5.cxx index 92e05e108c4..86b84751dbf 100644 --- a/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest5.cxx +++ b/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest5.cxx @@ -113,8 +113,8 @@ itkSampleToHistogramFilterTest5(int argc, char * argv[]) } - HistogramType::ConstIterator histogramItr = histogram->Begin(); - HistogramType::ConstIterator histogramEnd = histogram->End(); + HistogramType::ConstIterator histogramItr = histogram->Begin(); + const HistogramType::ConstIterator histogramEnd = histogram->End(); using PrintType = itk::NumericTraits::PrintType; diff --git a/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest6.cxx b/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest6.cxx index 2292226bc06..3d836a4b904 100644 --- a/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest6.cxx +++ b/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest6.cxx @@ -136,8 +136,8 @@ itkSampleToHistogramFilterTest6(int, char *[]) } - HistogramType::ConstIterator histogramItr = histogram->Begin(); - HistogramType::ConstIterator histogramEnd = histogram->End(); + HistogramType::ConstIterator histogramItr = histogram->Begin(); + const HistogramType::ConstIterator histogramEnd = histogram->End(); constexpr unsigned int expectedFrequency1 = 1; while (histogramItr != histogramEnd) diff --git a/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest7.cxx b/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest7.cxx index 3bab630f492..41a24b101db 100644 --- a/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest7.cxx +++ b/Modules/Numerics/Statistics/test/itkSampleToHistogramFilterTest7.cxx @@ -127,8 +127,8 @@ itkSampleToHistogramFilterTest7(int, char *[]) } - HistogramType::ConstIterator histogramItr = histogram->Begin(); - HistogramType::ConstIterator histogramEnd = histogram->End(); + HistogramType::ConstIterator histogramItr = histogram->Begin(); + const HistogramType::ConstIterator histogramEnd = histogram->End(); constexpr unsigned int expectedFrequency1 = 1; while (histogramItr != histogramEnd) diff --git a/Modules/Numerics/Statistics/test/itkScalarImageToCooccurrenceListSampleFilterTest.cxx b/Modules/Numerics/Statistics/test/itkScalarImageToCooccurrenceListSampleFilterTest.cxx index 823412c93e4..de2e01f9946 100644 --- a/Modules/Numerics/Statistics/test/itkScalarImageToCooccurrenceListSampleFilterTest.cxx +++ b/Modules/Numerics/Statistics/test/itkScalarImageToCooccurrenceListSampleFilterTest.cxx @@ -38,10 +38,10 @@ itkScalarImageToCooccurrenceListSampleFilterTest(int, char *[]) auto image = InputImageType::New(); - InputImageType::SizeType inputImageSize = { { IMGWIDTH, IMGHEIGHT } }; + const InputImageType::SizeType inputImageSize = { { IMGWIDTH, IMGHEIGHT } }; - InputImageType::IndexType index{}; - InputImageType::RegionType region; + const InputImageType::IndexType index{}; + InputImageType::RegionType region; region.SetSize(inputImageSize); region.SetIndex(index); @@ -107,7 +107,7 @@ itkScalarImageToCooccurrenceListSampleFilterTest(int, char *[]) filter->SetInput(image); - CooccurrenceListType::OffsetType offset = { { 1, 0 } }; + const CooccurrenceListType::OffsetType offset = { { 1, 0 } }; filter->UseNeighbor(offset); @@ -211,8 +211,8 @@ itkScalarImageToCooccurrenceListSampleFilterTest(int, char *[]) while (s_iter != sample->End()) { - MeasurementVectorType v = s_iter.GetMeasurementVector(); - MeasurementVectorType vbase = *it; + const MeasurementVectorType v = s_iter.GetMeasurementVector(); + const MeasurementVectorType vbase = *it; if (vbase != v) { diff --git a/Modules/Numerics/Statistics/test/itkScalarImageToCooccurrenceMatrixFilterTest.cxx b/Modules/Numerics/Statistics/test/itkScalarImageToCooccurrenceMatrixFilterTest.cxx index 41ec0d9fc52..ca0b6b855c4 100644 --- a/Modules/Numerics/Statistics/test/itkScalarImageToCooccurrenceMatrixFilterTest.cxx +++ b/Modules/Numerics/Statistics/test/itkScalarImageToCooccurrenceMatrixFilterTest.cxx @@ -42,10 +42,10 @@ itkScalarImageToCooccurrenceMatrixFilterTest(int, char *[]) auto image = InputImageType::New(); - InputImageType::SizeType inputImageSize = { { IMGWIDTH, IMGHEIGHT } }; + const InputImageType::SizeType inputImageSize = { { IMGWIDTH, IMGHEIGHT } }; - InputImageType::IndexType index{}; - InputImageType::RegionType region; + const InputImageType::IndexType index{}; + InputImageType::RegionType region; region.SetSize(inputImageSize); region.SetIndex(index); @@ -153,9 +153,9 @@ itkScalarImageToCooccurrenceMatrixFilterTest(int, char *[]) filter->SetInput(image); - InputImageType::OffsetType offset1 = { { 0, 1 } }; - InputImageType::OffsetType offset2 = { { 1, 0 } }; - FilterType::OffsetVectorPointer offsetV = FilterType::OffsetVector::New(); + const InputImageType::OffsetType offset1 = { { 0, 1 } }; + const InputImageType::OffsetType offset2 = { { 1, 0 } }; + const FilterType::OffsetVectorPointer offsetV = FilterType::OffsetVector::New(); offsetV->push_back(offset1); offsetV->push_back(offset2); @@ -173,8 +173,8 @@ itkScalarImageToCooccurrenceMatrixFilterTest(int, char *[]) // First make sure the bins are sized properly: - float max = hist->GetBinMax(0, 255); - float min = hist->GetBinMin(0, 255); + const float max = hist->GetBinMax(0, 255); + const float min = hist->GetBinMin(0, 255); if (itk::Math::NotAlmostEquals(max, 256) || itk::Math::NotAlmostEquals(min, 255)) { @@ -265,7 +265,7 @@ itkScalarImageToCooccurrenceMatrixFilterTest(int, char *[]) auto filter2 = FilterType::New(); filter2->SetInput(image); - InputImageType::OffsetType offset3 = { { 0, 1 } }; + const InputImageType::OffsetType offset3 = { { 0, 1 } }; filter2->SetOffset(offset3); filter2->SetNumberOfBinsPerAxis(2); @@ -299,7 +299,7 @@ itkScalarImageToCooccurrenceMatrixFilterTest(int, char *[]) auto filter3 = FilterType::New(); filter3->SetInput(image); - InputImageType::OffsetType offset4 = { { 1, 1 } }; + const InputImageType::OffsetType offset4 = { { 1, 1 } }; filter3->SetOffset(offset4); diff --git a/Modules/Numerics/Statistics/test/itkScalarImageToCooccurrenceMatrixFilterTest2.cxx b/Modules/Numerics/Statistics/test/itkScalarImageToCooccurrenceMatrixFilterTest2.cxx index fbdba7095f7..8d05c785b36 100644 --- a/Modules/Numerics/Statistics/test/itkScalarImageToCooccurrenceMatrixFilterTest2.cxx +++ b/Modules/Numerics/Statistics/test/itkScalarImageToCooccurrenceMatrixFilterTest2.cxx @@ -44,10 +44,10 @@ itkScalarImageToCooccurrenceMatrixFilterTest2(int, char *[]) auto mask = InputImageType::New(); - InputImageType::SizeType inputImageSize = { { IMGWIDTH, IMGHEIGHT } }; + const InputImageType::SizeType inputImageSize = { { IMGWIDTH, IMGHEIGHT } }; - InputImageType::IndexType index{}; - InputImageType::RegionType region; + const InputImageType::IndexType index{}; + InputImageType::RegionType region; region.SetSize(inputImageSize); region.SetIndex(index); @@ -128,9 +128,9 @@ itkScalarImageToCooccurrenceMatrixFilterTest2(int, char *[]) filter->SetInput(image); - InputImageType::OffsetType offset1 = { { 0, 1 } }; - InputImageType::OffsetType offset2 = { { 1, 0 } }; - FilterType::OffsetVectorPointer offsetV = FilterType::OffsetVector::New(); + const InputImageType::OffsetType offset1 = { { 0, 1 } }; + const InputImageType::OffsetType offset2 = { { 1, 0 } }; + const FilterType::OffsetVectorPointer offsetV = FilterType::OffsetVector::New(); offsetV->push_back(offset1); offsetV->push_back(offset2); diff --git a/Modules/Numerics/Statistics/test/itkScalarImageToHistogramGeneratorTest.cxx b/Modules/Numerics/Statistics/test/itkScalarImageToHistogramGeneratorTest.cxx index 653602e6e67..a869fa33846 100644 --- a/Modules/Numerics/Statistics/test/itkScalarImageToHistogramGeneratorTest.cxx +++ b/Modules/Numerics/Statistics/test/itkScalarImageToHistogramGeneratorTest.cxx @@ -45,7 +45,7 @@ itkScalarImageToHistogramGeneratorTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); - itk::MinimumMaximumImageFilter::Pointer minmaxFilter = + const itk::MinimumMaximumImageFilter::Pointer minmaxFilter = itk::MinimumMaximumImageFilter::New(); minmaxFilter->SetInput(reader->GetOutput()); minmaxFilter->Update(); @@ -80,7 +80,7 @@ itkScalarImageToHistogramGeneratorTest(int argc, char * argv[]) const unsigned int histogramSize = histogram->Size(); outputFile << "Histogram size " << histogramSize << std::endl; - unsigned int channel = 0; // red channel + const unsigned int channel = 0; // red channel outputFile << "Histogram of the scalar component" << std::endl; for (unsigned int bin = 0; bin < histogramSize; ++bin) { diff --git a/Modules/Numerics/Statistics/test/itkScalarImageToRunLengthFeaturesFilterTest.cxx b/Modules/Numerics/Statistics/test/itkScalarImageToRunLengthFeaturesFilterTest.cxx index 5579d5a52a5..8bb5bc4b064 100644 --- a/Modules/Numerics/Statistics/test/itkScalarImageToRunLengthFeaturesFilterTest.cxx +++ b/Modules/Numerics/Statistics/test/itkScalarImageToRunLengthFeaturesFilterTest.cxx @@ -41,10 +41,10 @@ itkScalarImageToRunLengthFeaturesFilterTest(int, char *[]) auto image = InputImageType::New(); - InputImageType::SizeType inputImageSize = { { IMGWIDTH, IMGHEIGHT } }; + const InputImageType::SizeType inputImageSize = { { IMGWIDTH, IMGHEIGHT } }; - InputImageType::IndexType index{}; - InputImageType::RegionType region; + const InputImageType::IndexType index{}; + InputImageType::RegionType region; region.SetSize(inputImageSize); region.SetIndex(index); @@ -199,9 +199,9 @@ itkScalarImageToRunLengthFeaturesFilterTest(int, char *[]) RunLengthFilterType::FeatureValueVectorPointer means = texFilter->GetFeatureMeans(); RunLengthFilterType::FeatureValueVectorPointer stds = texFilter->GetFeatureStandardDeviations(); - double expectedMeans[10] = { 0.76, 7, 10.4, 20, 0.0826667, 15.4, 0.0628267, 11.704, 0.578667, 107.8 }; - double expectedDeviations[10] = { 0.415692, 10.3923, 4.50333, 8.66025, 0, - 0, 0.0343639, 6.40166, 0.859097, 160.041494 }; + const double expectedMeans[10] = { 0.76, 7, 10.4, 20, 0.0826667, 15.4, 0.0628267, 11.704, 0.578667, 107.8 }; + const double expectedDeviations[10] = { 0.415692, 10.3923, 4.50333, 8.66025, 0, + 0, 0.0343639, 6.40166, 0.859097, 160.041494 }; RunLengthFilterType::FeatureValueVector::ConstIterator mIt; RunLengthFilterType::FeatureValueVector::ConstIterator sIt; @@ -232,8 +232,8 @@ itkScalarImageToRunLengthFeaturesFilterTest(int, char *[]) means = texFilter->GetFeatureMeans(); stds = texFilter->GetFeatureStandardDeviations(); - double expectedMeans2[10] = { 1, 1, 13, 25, 0.0826667, 15.4, 0.0826667, 15.4, 0.0826667, 15.4 }; - double expectedDeviations2[10] = { 0 }; + const double expectedMeans2[10] = { 1, 1, 13, 25, 0.0826667, 15.4, 0.0826667, 15.4, 0.0826667, 15.4 }; + const double expectedDeviations2[10] = { 0 }; for (counter = 0, mIt = means->Begin(); mIt != means->End(); ++mIt, counter++) { @@ -293,8 +293,8 @@ itkScalarImageToRunLengthFeaturesFilterTest(int, char *[]) means = texFilter->GetFeatureMeans(); stds = texFilter->GetFeatureStandardDeviations(); - double expectedMeans3[10] = { 1, 1, 13, 25, 0.0826667, 15.4, 0.0826667, 15.4, 0.0826667, 15.4 }; - double expectedDeviations3[10] = { 0 }; + const double expectedMeans3[10] = { 1, 1, 13, 25, 0.0826667, 15.4, 0.0826667, 15.4, 0.0826667, 15.4 }; + const double expectedDeviations3[10] = { 0 }; for (counter = 0, mIt = means->Begin(); mIt != means->End(); ++mIt, counter++) { @@ -317,7 +317,8 @@ itkScalarImageToRunLengthFeaturesFilterTest(int, char *[]) } // Test Set/Get Requested features - RunLengthFilterType::FeatureNameVectorPointer requestedFeatures = RunLengthFilterType::FeatureNameVector::New(); + const RunLengthFilterType::FeatureNameVectorPointer requestedFeatures = + RunLengthFilterType::FeatureNameVector::New(); requestedFeatures->push_back(static_cast(itk::Statistics::RunLengthFeatureEnum::ShortRunEmphasis)); requestedFeatures->push_back(static_cast(itk::Statistics::RunLengthFeatureEnum::GreyLevelNonuniformity)); diff --git a/Modules/Numerics/Statistics/test/itkScalarImageToRunLengthMatrixFilterTest.cxx b/Modules/Numerics/Statistics/test/itkScalarImageToRunLengthMatrixFilterTest.cxx index 36f2fccb2f4..2cbbbf43383 100644 --- a/Modules/Numerics/Statistics/test/itkScalarImageToRunLengthMatrixFilterTest.cxx +++ b/Modules/Numerics/Statistics/test/itkScalarImageToRunLengthMatrixFilterTest.cxx @@ -45,13 +45,13 @@ itkScalarImageToRunLengthMatrixFilterTest(int, char *[]) auto mask = InputImageType::New(); - InputImageType::SizeType inputImageSize = { { IMGWIDTH, IMGHEIGHT } }; + const InputImageType::SizeType inputImageSize = { { IMGWIDTH, IMGHEIGHT } }; InputImageType::RegionType region; region.SetSize(inputImageSize); { - InputImageType::IndexType index{}; + const InputImageType::IndexType index{}; region.SetIndex(index); } @@ -117,9 +117,9 @@ itkScalarImageToRunLengthMatrixFilterTest(int, char *[]) filter->SetInput(image); - InputImageType::OffsetType offset1 = { { 0, -1 } }; - InputImageType::OffsetType offset2 = { { -1, 0 } }; - FilterType::OffsetVectorPointer offsetV = FilterType::OffsetVector::New(); + const InputImageType::OffsetType offset1 = { { 0, -1 } }; + const InputImageType::OffsetType offset2 = { { -1, 0 } }; + const FilterType::OffsetVectorPointer offsetV = FilterType::OffsetVector::New(); offsetV->push_back(offset1); offsetV->push_back(offset2); @@ -138,7 +138,7 @@ itkScalarImageToRunLengthMatrixFilterTest(int, char *[]) //-------------------------------------------------------------------------- bool passed = true; - unsigned int frequencies[5][5] = { + const unsigned int frequencies[5][5] = { { 0, 3, 0, 0, 0 }, { 0, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 } }; @@ -158,7 +158,7 @@ itkScalarImageToRunLengthMatrixFilterTest(int, char *[]) } } } - unsigned int totalF = hist->GetTotalFrequency(); + const unsigned int totalF = hist->GetTotalFrequency(); if (totalF != 4) { std::cerr << "Expected total frequency = 4, calculated = " << totalF << std::endl; @@ -231,7 +231,7 @@ itkScalarImageToRunLengthMatrixFilterTest(int, char *[]) filter->Update(); hist = filter->GetOutput(); - unsigned int frequencies2[5][5] = { + const unsigned int frequencies2[5][5] = { { 0, 12, 0, 10, 0 }, { 0, 0, 0, 0, 0 }, { 0, 3, 0, 2, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 } }; diff --git a/Modules/Numerics/Statistics/test/itkScalarImageToTextureFeaturesFilterTest.cxx b/Modules/Numerics/Statistics/test/itkScalarImageToTextureFeaturesFilterTest.cxx index 5404286ed01..f35719f6dd0 100644 --- a/Modules/Numerics/Statistics/test/itkScalarImageToTextureFeaturesFilterTest.cxx +++ b/Modules/Numerics/Statistics/test/itkScalarImageToTextureFeaturesFilterTest.cxx @@ -44,10 +44,10 @@ itkScalarImageToTextureFeaturesFilterTest(int, char *[]) auto image = InputImageType::New(); - InputImageType::SizeType inputImageSize = { { IMGWIDTH, IMGHEIGHT } }; + const InputImageType::SizeType inputImageSize = { { IMGWIDTH, IMGHEIGHT } }; - InputImageType::IndexType index{}; - InputImageType::RegionType region; + const InputImageType::IndexType index{}; + InputImageType::RegionType region; region.SetSize(inputImageSize); region.SetIndex(index); @@ -198,8 +198,8 @@ itkScalarImageToTextureFeaturesFilterTest(int, char *[]) TextureFilterType::FeatureValueVectorPointer means = texFilter->GetFeatureMeans(); TextureFilterType::FeatureValueVectorPointer stds = texFilter->GetFeatureStandardDeviations(); - double expectedMeans[6] = { 0.505, 0.992738, 0.625, 0.75, 0.0959999, 0.2688 }; - double expectedDeviations[6] = { 0.00866027, 0.0125788, 0.216506351, 0.433012702, 0.166277, 0.465575 }; + const double expectedMeans[6] = { 0.505, 0.992738, 0.625, 0.75, 0.0959999, 0.2688 }; + const double expectedDeviations[6] = { 0.00866027, 0.0125788, 0.216506351, 0.433012702, 0.166277, 0.465575 }; TextureFilterType::FeatureValueVector::ConstIterator mIt; TextureFilterType::FeatureValueVector::ConstIterator sIt; @@ -231,8 +231,8 @@ itkScalarImageToTextureFeaturesFilterTest(int, char *[]) means = texFilter->GetFeatureMeans(); stds = texFilter->GetFeatureStandardDeviations(); - double expectedMeans2[6] = { 0.5, 1.0, 0.5, 1.0, 0.0, 0.0 }; - double expectedDeviations2[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; + const double expectedMeans2[6] = { 0.5, 1.0, 0.5, 1.0, 0.0, 0.0 }; + const double expectedDeviations2[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; for (counter = 0, mIt = means->Begin(); mIt != means->End(); ++mIt, counter++) { @@ -285,8 +285,8 @@ itkScalarImageToTextureFeaturesFilterTest(int, char *[]) means = texFilter->GetFeatureMeans(); stds = texFilter->GetFeatureStandardDeviations(); - double expectedMeans3[6] = { 0.5, 1.0, 0.5, 1.0, 0.0, 0.0 }; - double expectedDeviations3[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; + const double expectedMeans3[6] = { 0.5, 1.0, 0.5, 1.0, 0.0, 0.0 }; + const double expectedDeviations3[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; for (counter = 0, mIt = means->Begin(); mIt != means->End(); ++mIt, counter++) { @@ -309,7 +309,7 @@ itkScalarImageToTextureFeaturesFilterTest(int, char *[]) } // Test Set/Get Requested features - TextureFilterType::FeatureNameVectorPointer requestedFeatures = TextureFilterType::FeatureNameVector::New(); + const TextureFilterType::FeatureNameVectorPointer requestedFeatures = TextureFilterType::FeatureNameVector::New(); requestedFeatures->push_back( static_cast(itk::Statistics::HistogramToTextureFeaturesFilterEnums::TextureFeature::Inertia)); diff --git a/Modules/Numerics/Statistics/test/itkSpatialNeighborSubsamplerTest.cxx b/Modules/Numerics/Statistics/test/itkSpatialNeighborSubsamplerTest.cxx index 9a25a0caf67..ed0608b0375 100644 --- a/Modules/Numerics/Statistics/test/itkSpatialNeighborSubsamplerTest.cxx +++ b/Modules/Numerics/Statistics/test/itkSpatialNeighborSubsamplerTest.cxx @@ -74,10 +74,10 @@ itkSpatialNeighborSubsamplerTest(int, char *[]) using SamplerType = itk::Statistics::SpatialNeighborSubsampler; using IteratorType = itk::ImageRegionConstIteratorWithIndex; - auto inImage = ImageType::New(); - auto sz = SizeType::Filled(25); - IndexType idx{}; - RegionType region{ idx, sz }; + auto inImage = ImageType::New(); + auto sz = SizeType::Filled(25); + const IndexType idx{}; + const RegionType region{ idx, sz }; inImage->SetRegions(region); inImage->AllocateInitialized(); @@ -88,7 +88,7 @@ itkSpatialNeighborSubsamplerTest(int, char *[]) IndexType idxConstraint; idxConstraint[0] = 0; idxConstraint[1] = 5; - RegionType regionConstraint{ idxConstraint, szConstraint }; + const RegionType regionConstraint{ idxConstraint, szConstraint }; auto sample = AdaptorType::New(); sample->SetImage(inImage); @@ -106,7 +106,7 @@ itkSpatialNeighborSubsamplerTest(int, char *[]) sampler_orig->CanSelectQueryOn(); // test clone mechanism - SamplerType::Pointer sampler = sampler_orig->Clone().GetPointer(); + const SamplerType::Pointer sampler = sampler_orig->Clone().GetPointer(); if (sampler->GetSample() != sampler_orig->GetSample()) { std::cerr << "Clone did not copy the sample correctly!" << std::endl; @@ -137,7 +137,7 @@ itkSpatialNeighborSubsamplerTest(int, char *[]) IndexType queryIdx; queryIdx[0] = 2; queryIdx[1] = 6; - ImageType::OffsetValueType queryOffset = inImage->ComputeOffset(queryIdx); + const ImageType::OffsetValueType queryOffset = inImage->ComputeOffset(queryIdx); sampler->Search(queryOffset, subsample); IndexType index; @@ -158,14 +158,14 @@ itkSpatialNeighborSubsamplerTest(int, char *[]) IndexType validStart; validStart[0] = 0; validStart[1] = 5; - RegionType validRegion{ validStart, validSz }; + const RegionType validRegion{ validStart, validSz }; IteratorType it(inImage, region); it.GoToBegin(); while (!it.IsAtEnd()) { - PixelType curValue = it.Get(); - IndexType curIdx = it.GetIndex(); + const PixelType curValue = it.Get(); + const IndexType curIdx = it.GetIndex(); if (validRegion.IsInside(curIdx)) { // inside the region, value must be 255 diff --git a/Modules/Numerics/Statistics/test/itkStandardDeviationPerComponentSampleFilterTest.cxx b/Modules/Numerics/Statistics/test/itkStandardDeviationPerComponentSampleFilterTest.cxx index 2f0e393b27f..d8413875536 100644 --- a/Modules/Numerics/Statistics/test/itkStandardDeviationPerComponentSampleFilterTest.cxx +++ b/Modules/Numerics/Statistics/test/itkStandardDeviationPerComponentSampleFilterTest.cxx @@ -37,10 +37,10 @@ itkStandardDeviationPerComponentSampleFilterTest(int, char *[]) using ImageType = itk::Image; using MaskImageType = itk::Image; - auto image = ImageType::New(); - ImageType::RegionType region; - ImageType::SizeType size; - ImageType::IndexType index{}; + auto image = ImageType::New(); + ImageType::RegionType region; + ImageType::SizeType size; + const ImageType::IndexType index{}; size.Fill(5); region.SetIndex(index); region.SetSize(size); @@ -87,7 +87,7 @@ itkStandardDeviationPerComponentSampleFilterTest(int, char *[]) using StandardDeviationPerComponentSampleFilterType = itk::Statistics::StandardDeviationPerComponentSampleFilter; - StandardDeviationPerComponentSampleFilterType::Pointer standardDeviationFilter = + const StandardDeviationPerComponentSampleFilterType::Pointer standardDeviationFilter = StandardDeviationPerComponentSampleFilterType::New(); std::cout << standardDeviationFilter->GetNameOfClass() << std::endl; diff --git a/Modules/Numerics/Statistics/test/itkStatisticsAlgorithmTest.cxx b/Modules/Numerics/Statistics/test/itkStatisticsAlgorithmTest.cxx index 5ad7721246a..3dfcfaf2479 100644 --- a/Modules/Numerics/Statistics/test/itkStatisticsAlgorithmTest.cxx +++ b/Modules/Numerics/Statistics/test/itkStatisticsAlgorithmTest.cxx @@ -68,7 +68,7 @@ itkStatisticsAlgorithmTest(int, char *[]) for (unsigned int i = 1; i < numberOfSamples; ++i) { - float value = i + 3; + const float value = i + 3; measure[0] = value; measure[1] = value * value; sample->PushBack(measure); diff --git a/Modules/Numerics/Statistics/test/itkStatisticsAlgorithmTest2.cxx b/Modules/Numerics/Statistics/test/itkStatisticsAlgorithmTest2.cxx index 0734b1663bb..cc3877f8a53 100644 --- a/Modules/Numerics/Statistics/test/itkStatisticsAlgorithmTest2.cxx +++ b/Modules/Numerics/Statistics/test/itkStatisticsAlgorithmTest2.cxx @@ -111,9 +111,9 @@ itkStatisticsAlgorithmTest2(int, char *[]) auto size = ImageType::SizeType::Filled(5); - ImageType::IndexType index{}; + const ImageType::IndexType index{}; - ImageType::RegionType region{ index, size }; + const ImageType::RegionType region{ index, size }; image->SetLargestPossibleRegion(region); image->SetBufferedRegion(region); @@ -167,7 +167,7 @@ itkStatisticsAlgorithmTest2(int, char *[]) // QuickSelect algorithm test resetData(image, refVector); - SubsampleType::MeasurementType median = itk::Statistics::Algorithm::QuickSelect( + const SubsampleType::MeasurementType median = itk::Statistics::Algorithm::QuickSelect( subsample, testDimension, 0, subsample->Size(), subsample->Size() / 2); if (refVector[subsample->Size() / 2] != median) { diff --git a/Modules/Numerics/Statistics/test/itkSubsampleTest.cxx b/Modules/Numerics/Statistics/test/itkSubsampleTest.cxx index 972aa2a3f63..98665eb0418 100644 --- a/Modules/Numerics/Statistics/test/itkSubsampleTest.cxx +++ b/Modules/Numerics/Statistics/test/itkSubsampleTest.cxx @@ -35,12 +35,12 @@ itkSubsampleTest(int, char *[]) using SourceType = itk::RandomImageSource; auto source = SourceType::New(); - itk::SizeValueType size[3] = { 17, 8, 20 }; - itk::SizeValueType totalSize = size[0] * size[1] * size[2]; + itk::SizeValueType size[3] = { 17, 8, 20 }; + const itk::SizeValueType totalSize = size[0] * size[1] * size[2]; source->SetSize(size); - float minValue = -100.0; - float maxValue = 1000.0; + const float minValue = -100.0; + const float maxValue = 1000.0; source->SetMin(static_cast(minValue)); source->SetMax(static_cast(maxValue)); @@ -107,7 +107,7 @@ itkSubsampleTest(int, char *[]) // test if an exception is thrown, if a sample with id outside the // range of the Sample is added to the SubSample - int idOutisdeRange = listSample->Size() + 2; + const int idOutisdeRange = listSample->Size() + 2; try { @@ -125,7 +125,7 @@ itkSubsampleTest(int, char *[]) using MeasurementVectorType = SubsampleType::MeasurementVectorType; try { - MeasurementVectorType vec = subsample->GetMeasurementVector(idOutisdeRange); + const MeasurementVectorType vec = subsample->GetMeasurementVector(idOutisdeRange); std::cerr << "Exception should have been thrown since the id specified is outside the range of the sample container" << std::endl; std::cerr << "The invalid subsample->GetMeasurementVector() is: " << vec << std::endl; @@ -166,8 +166,8 @@ itkSubsampleTest(int, char *[]) // try accessing a measurement vector by index that is out of range try { - unsigned int index = listSample->Size() + 2; - MeasurementVectorType measurementVector = subsample->GetMeasurementVectorByIndex(index); + const unsigned int index = listSample->Size() + 2; + const MeasurementVectorType measurementVector = subsample->GetMeasurementVectorByIndex(index); std::cerr << "Exception should have been thrown since the index specified is outside the range of the sample container" << std::endl; @@ -184,8 +184,8 @@ itkSubsampleTest(int, char *[]) // try accessing a measurement vector frequency by index that is out of range try { - unsigned int index = listSample->Size() + 2; - SubsampleType::AbsoluteFrequencyType frequency = subsample->GetFrequencyByIndex(index); + const unsigned int index = listSample->Size() + 2; + const SubsampleType::AbsoluteFrequencyType frequency = subsample->GetFrequencyByIndex(index); std::cout << "Frequency: " << frequency << std::endl; std::cerr << "Exception should have been thrown since the index specified is outside the range of the sample container" @@ -201,8 +201,8 @@ itkSubsampleTest(int, char *[]) // using an index that is out of range try { - unsigned int index = listSample->Size() + 2; - ListSampleType::InstanceIdentifier id = subsample->GetInstanceIdentifier(index); + const unsigned int index = listSample->Size() + 2; + const ListSampleType::InstanceIdentifier id = subsample->GetInstanceIdentifier(index); std::cerr << "Exception should have been thrown since the index specified is outside the range of the sample container" << std::endl; @@ -223,8 +223,8 @@ itkSubsampleTest(int, char *[]) std::cout << subsample->GetTotalFrequency() << std::endl; auto index = ArrayPixelImageType::IndexType::Filled(2); // index {2, 2, 2} = instance identifier (offset from image) - ArrayPixelImageType::PixelType pixel = filter->GetInput()->GetPixel(index); - ListSampleType::InstanceIdentifier ind = + ArrayPixelImageType::PixelType pixel = filter->GetInput()->GetPixel(index); + const ListSampleType::InstanceIdentifier ind = static_cast(filter->GetInput()->ComputeOffset(index)); if (itk::Math::NotExactlyEquals(pixel[0], subsample->GetMeasurementVector(ind)[0])) diff --git a/Modules/Numerics/Statistics/test/itkSubsampleTest2.cxx b/Modules/Numerics/Statistics/test/itkSubsampleTest2.cxx index 06a57659db4..a649ba5f7f0 100644 --- a/Modules/Numerics/Statistics/test/itkSubsampleTest2.cxx +++ b/Modules/Numerics/Statistics/test/itkSubsampleTest2.cxx @@ -28,10 +28,10 @@ itkSubsampleTest2(int, char *[]) using SampleType = itk::Statistics::ListSample; - SampleType::MeasurementVectorSizeType measurementVectorSize = 3; + const SampleType::MeasurementVectorSizeType measurementVectorSize = 3; std::cerr << "Measurement vector size: " << measurementVectorSize << std::endl; - unsigned int sampleSize = 10; + const unsigned int sampleSize = 10; auto sample = SampleType::New(); @@ -134,8 +134,8 @@ itkSubsampleTest2(int, char *[]) ++citer; } - IteratorType iter1 = subSample2->Begin(); - IteratorType iter2 = subSample2->Begin(); + const IteratorType iter1 = subSample2->Begin(); + const IteratorType iter2 = subSample2->Begin(); citer = iter1; @@ -173,8 +173,8 @@ itkSubsampleTest2(int, char *[]) // Testing methods specific to Iterators { - IteratorType iter7 = subSample2->Begin(); - IteratorType iter8 = subSample2->End(); + const IteratorType iter7 = subSample2->Begin(); + IteratorType iter8 = subSample2->End(); iter8 = iter7; if (iter8 != iter7) @@ -203,22 +203,22 @@ itkSubsampleTest2(int, char *[]) return EXIT_FAILURE; } - IteratorType iter4(iter8); + const IteratorType iter4(iter8); if (iter4 != iter8) { std::cerr << "Iterator copy constructor failed" << std::endl; return EXIT_FAILURE; } - IteratorType iter5 = iter8; + const IteratorType iter5 = iter8; if (iter5 != iter8) { std::cerr << "Iterator operator= failed" << std::endl; return EXIT_FAILURE; } - IteratorType iter6(subSample2); - unsigned int targetEntry = 2; + IteratorType iter6(subSample2); + const unsigned int targetEntry = 2; for (unsigned int kk = 0; kk < targetEntry; ++kk) { std::cout << "GetInstanceIdentifier() = " << iter6.GetInstanceIdentifier() << std::endl; @@ -236,8 +236,8 @@ itkSubsampleTest2(int, char *[]) // Testing methods specific to ConstIterators { - ConstIteratorType iter11 = subSample2->Begin(); - ConstIteratorType iter12 = subSample2->End(); + const ConstIteratorType iter11 = subSample2->Begin(); + ConstIteratorType iter12 = subSample2->End(); iter12 = iter11; @@ -253,7 +253,7 @@ itkSubsampleTest2(int, char *[]) return EXIT_FAILURE; } - ConstIteratorType iter3(iter12); + const ConstIteratorType iter3(iter12); if (iter3 != iter12) { std::cerr << "ConstIterator copy constructor failed" << std::endl; @@ -262,23 +262,23 @@ itkSubsampleTest2(int, char *[]) const CascadedSubsampleType * constSample = subSample2.GetPointer(); - ConstIteratorType iter4(constSample->Begin()); - ConstIteratorType iter5(subSample2->Begin()); + const ConstIteratorType iter4(constSample->Begin()); + const ConstIteratorType iter5(subSample2->Begin()); if (iter4 != iter5) { std::cerr << "Constructor from const container Begin() differs from non-const Begin() " << std::endl; return EXIT_FAILURE; } - ConstIteratorType iter6(constSample); - ConstIteratorType iter7(subSample2); + const ConstIteratorType iter6(constSample); + const ConstIteratorType iter7(subSample2); if (iter6 != iter7) { std::cerr << "ConstIterator Constructor from const container differs from non-const container" << std::endl; return EXIT_FAILURE; } - ConstIteratorType iter8(subSample2); + const ConstIteratorType iter8(subSample2); if (iter8.GetInstanceIdentifier() != 0) { std::cerr << "Constructor with instance identifier 0 failed" << std::endl; @@ -286,8 +286,8 @@ itkSubsampleTest2(int, char *[]) } - ConstIteratorType iter9(subSample2); - unsigned int targetEntry = 2; + ConstIteratorType iter9(subSample2); + const unsigned int targetEntry = 2; for (unsigned int kk = 0; kk < targetEntry; ++kk) { std::cout << "Instance identifier = " << iter9.GetInstanceIdentifier() << std::endl; diff --git a/Modules/Numerics/Statistics/test/itkSubsampleTest3.cxx b/Modules/Numerics/Statistics/test/itkSubsampleTest3.cxx index b29b70fd436..ad9cb65284a 100644 --- a/Modules/Numerics/Statistics/test/itkSubsampleTest3.cxx +++ b/Modules/Numerics/Statistics/test/itkSubsampleTest3.cxx @@ -85,7 +85,7 @@ itkSubsampleTest3(int, char *[]) std::cout << meanOutput[0] << ' ' << mean[0] << ' ' << meanOutput[1] << ' ' << mean[1] << ' ' << std::endl; - FilterType::MeasurementVectorType::ValueType epsilon = 1e-6; + const FilterType::MeasurementVectorType::ValueType epsilon = 1e-6; if ((itk::Math::abs(meanOutput[0] - mean[0]) > epsilon) || (itk::Math::abs(meanOutput[1] - mean[1]) > epsilon)) { diff --git a/Modules/Numerics/Statistics/test/itkTDistributionTest.cxx b/Modules/Numerics/Statistics/test/itkTDistributionTest.cxx index ffc54bc896f..74429656d79 100644 --- a/Modules/Numerics/Statistics/test/itkTDistributionTest.cxx +++ b/Modules/Numerics/Statistics/test/itkTDistributionTest.cxx @@ -26,7 +26,7 @@ itkTDistributionTest(int, char *[]) { // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); std::cout << "itkTDistribution Test \n \n"; @@ -52,9 +52,10 @@ itkTDistributionTest(int, char *[]) // expected values for Student-t cdf with 1 degree of freedom at // values of -5:1:5 - double expected1[] = { 6.283295818900114e-002, 7.797913037736926e-002, 1.024163823495667e-001, 1.475836176504333e-001, - 2.500000000000000e-001, 5.000000000000000e-001, 7.500000000000000e-001, 8.524163823495667e-001, - 8.975836176504333e-001, 9.220208696226308e-001, 9.371670418109989e-001 }; + const double expected1[] = { 6.283295818900114e-002, 7.797913037736926e-002, 1.024163823495667e-001, + 1.475836176504333e-001, 2.500000000000000e-001, 5.000000000000000e-001, + 7.500000000000000e-001, 8.524163823495667e-001, 8.975836176504333e-001, + 9.220208696226308e-001, 9.371670418109989e-001 }; std::cout << "Testing distribution with 1 degree of freedom" << std::endl; @@ -136,10 +137,10 @@ itkTDistributionTest(int, char *[]) // expected values for Student-t cdf with 11 degrees of freedom at // values of -5:1:5 - double expected11[] = { 2.012649090622596e-004, 1.043096783487477e-003, 6.039919735960683e-003, - 3.540197753401686e-002, 1.694003480981013e-001, 5.000000000000000e-001, - 8.305996519018988e-001, 9.645980224659831e-001, 9.939600802640394e-001, - 9.989569032165125e-001, 9.997987350909378e-001 }; + const double expected11[] = { 2.012649090622596e-004, 1.043096783487477e-003, 6.039919735960683e-003, + 3.540197753401686e-002, 1.694003480981013e-001, 5.000000000000000e-001, + 8.305996519018988e-001, 9.645980224659831e-001, 9.939600802640394e-001, + 9.989569032165125e-001, 9.997987350909378e-001 }; std::cout << "-----------------------------------------------" << std::endl << std::endl; std::cout << "Testing distribution with 11 degrees of freedom" << std::endl; @@ -387,7 +388,7 @@ itkTDistributionTest(int, char *[]) parameters[0] = 5.0; distributionFunction->SetParameters(parameters); - unsigned long dof = 5; + const unsigned long dof = 5; std::cout << "Variance() = " << distributionFunction->GetVariance() << std::endl; std::cout << "PDF(x,p) = " << distributionFunction->PDF(x, parameters) << std::endl; @@ -452,7 +453,7 @@ itkTDistributionTest(int, char *[]) std::cout << "Exercise negative argument " << std::endl; std::cout << "InverseCDF(x,p) = " << distributionFunction->InverseCDF(-1.0, dof) << std::endl; - unsigned long newdof = 17; + const unsigned long newdof = 17; distributionFunction->SetDegreesOfFreedom(newdof); ITK_TEST_SET_GET_VALUE(newdof, distributionFunction->GetDegreesOfFreedom()); @@ -462,7 +463,7 @@ itkTDistributionTest(int, char *[]) distributionFunction->SetParameters(parameters2); distributionFunction->SetDegreesOfFreedom(16); - DistributionType::ParametersType parameters0(0); + const DistributionType::ParametersType parameters0(0); distributionFunction->SetParameters(parameters0); distributionFunction->Print(std::cout); diff --git a/Modules/Numerics/Statistics/test/itkUniformRandomSpatialNeighborSubsamplerTest.cxx b/Modules/Numerics/Statistics/test/itkUniformRandomSpatialNeighborSubsamplerTest.cxx index b1984a500f5..a84d51a1082 100644 --- a/Modules/Numerics/Statistics/test/itkUniformRandomSpatialNeighborSubsamplerTest.cxx +++ b/Modules/Numerics/Statistics/test/itkUniformRandomSpatialNeighborSubsamplerTest.cxx @@ -49,11 +49,11 @@ itkUniformRandomSpatialNeighborSubsamplerTest(int argc, char * argv[]) using SamplerType = itk::Statistics::UniformRandomSpatialNeighborSubsampler; using WriterType = itk::ImageFileWriter; - auto inImage = FloatImage::New(); - typename SizeType::value_type regionSizeVal = 35; - auto sz = SizeType::Filled(regionSizeVal); - IndexType idx{}; - RegionType region{ idx, sz }; + auto inImage = FloatImage::New(); + const typename SizeType::value_type regionSizeVal = 35; + auto sz = SizeType::Filled(regionSizeVal); + const IndexType idx{}; + const RegionType region{ idx, sz }; inImage->SetRegions(region); inImage->AllocateInitialized(); @@ -106,7 +106,7 @@ itkUniformRandomSpatialNeighborSubsamplerTest(int argc, char * argv[]) ITK_TEST_SET_GET_BOOLEAN(samplerOrig, UseClockForSeed, useClockForSeed); // Test clone mechanism - SamplerType::Pointer sampler = samplerOrig->Clone().GetPointer(); + const SamplerType::Pointer sampler = samplerOrig->Clone().GetPointer(); ITK_TEST_SET_GET_VALUE(samplerOrig->GetSample(), sampler->GetSample()); ITK_TEST_SET_GET_VALUE(samplerOrig->GetSampleRegion(), sampler->GetSampleRegion()); diff --git a/Modules/Numerics/Statistics/test/itkVectorContainerToListSampleAdaptorTest.cxx b/Modules/Numerics/Statistics/test/itkVectorContainerToListSampleAdaptorTest.cxx index 8288d07330c..32373d66566 100644 --- a/Modules/Numerics/Statistics/test/itkVectorContainerToListSampleAdaptorTest.cxx +++ b/Modules/Numerics/Statistics/test/itkVectorContainerToListSampleAdaptorTest.cxx @@ -36,7 +36,7 @@ itkVectorContainerToListSampleAdaptorTest(int, char *[]) // Test the exceptions ITK_TRY_EXPECT_EXCEPTION(adaptor->Size()); - typename AdaptorType::InstanceIdentifier instance = 0; + const typename AdaptorType::InstanceIdentifier instance = 0; ITK_TRY_EXPECT_EXCEPTION(adaptor->GetMeasurementVector(instance)); ITK_TRY_EXPECT_EXCEPTION(adaptor->GetFrequency(instance)); @@ -44,8 +44,8 @@ itkVectorContainerToListSampleAdaptorTest(int, char *[]) ITK_TRY_EXPECT_EXCEPTION(adaptor->GetTotalFrequency()); // Set the vector container - unsigned int containerSize = 3; - auto container = ContainerType::New(); + const unsigned int containerSize = 3; + auto container = ContainerType::New(); container->Reserve(containerSize); for (unsigned int i = 0; i < container->Size(); ++i) { @@ -56,16 +56,16 @@ itkVectorContainerToListSampleAdaptorTest(int, char *[]) adaptor->SetVectorContainer(container); ITK_TEST_SET_GET_VALUE(container, adaptor->GetVectorContainer()); - typename AdaptorType::InstanceIdentifier expectedSize = 3; - typename AdaptorType::InstanceIdentifier size = adaptor->Size(); + const typename AdaptorType::InstanceIdentifier expectedSize = 3; + const typename AdaptorType::InstanceIdentifier size = adaptor->Size(); ITK_TEST_EXPECT_EQUAL(expectedSize, size); - typename AdaptorType::AbsoluteFrequencyType expectedFreq = 1; - typename AdaptorType::AbsoluteFrequencyType freq = adaptor->GetFrequency(instance); + const typename AdaptorType::AbsoluteFrequencyType expectedFreq = 1; + const typename AdaptorType::AbsoluteFrequencyType freq = adaptor->GetFrequency(instance); ITK_TEST_EXPECT_EQUAL(expectedFreq, freq); - typename AdaptorType::TotalAbsoluteFrequencyType expectedTotalFreq = 3; - typename AdaptorType::TotalAbsoluteFrequencyType totalFreq = adaptor->GetTotalFrequency(); + const typename AdaptorType::TotalAbsoluteFrequencyType expectedTotalFreq = 3; + const typename AdaptorType::TotalAbsoluteFrequencyType totalFreq = adaptor->GetTotalFrequency(); ITK_TEST_EXPECT_EQUAL(expectedTotalFreq, totalFreq); diff --git a/Modules/Numerics/Statistics/test/itkWeightedCentroidKdTreeGeneratorTest1.cxx b/Modules/Numerics/Statistics/test/itkWeightedCentroidKdTreeGeneratorTest1.cxx index 4728c3ef67c..d2a83488e12 100644 --- a/Modules/Numerics/Statistics/test/itkWeightedCentroidKdTreeGeneratorTest1.cxx +++ b/Modules/Numerics/Statistics/test/itkWeightedCentroidKdTreeGeneratorTest1.cxx @@ -36,7 +36,7 @@ itkWeightedCentroidKdTreeGeneratorTest1(int argc, char * argv[]) // Random number generator using NumberGeneratorType = itk::Statistics::MersenneTwisterRandomVariateGenerator; - NumberGeneratorType::Pointer randomNumberGenerator = NumberGeneratorType::GetInstance(); + const NumberGeneratorType::Pointer randomNumberGenerator = NumberGeneratorType::GetInstance(); randomNumberGenerator->Initialize(); using MeasurementVectorType = itk::Array; @@ -72,12 +72,12 @@ itkWeightedCentroidKdTreeGeneratorTest1(int argc, char * argv[]) using TreeType = TreeGeneratorType::KdTreeType; - TreeType::Pointer tree = treeGenerator->GetOutput(); + const TreeType::Pointer tree = treeGenerator->GetOutput(); MeasurementVectorType queryPoint(measurementVectorSize); MeasurementVectorType origin(measurementVectorSize); - unsigned int numberOfNeighbors = 1; + const unsigned int numberOfNeighbors = 1; TreeType::InstanceIdentifierVectorType neighbors; MeasurementVectorType result(measurementVectorSize); @@ -152,8 +152,8 @@ itkWeightedCentroidKdTreeGeneratorTest1(int argc, char * argv[]) // // Compute the distance to the "presumed" nearest neighbor // - double result_dist = std::sqrt((result[0] - queryPoint[0]) * (result[0] - queryPoint[0]) + - (result[1] - queryPoint[1]) * (result[1] - queryPoint[1])); + const double result_dist = std::sqrt((result[0] - queryPoint[0]) * (result[0] - queryPoint[0]) + + (result[1] - queryPoint[1]) * (result[1] - queryPoint[1])); // // Compute the distance to all other points, to verify diff --git a/Modules/Numerics/Statistics/test/itkWeightedCentroidKdTreeGeneratorTest8.cxx b/Modules/Numerics/Statistics/test/itkWeightedCentroidKdTreeGeneratorTest8.cxx index 92071e854e4..40a58bfb9e2 100644 --- a/Modules/Numerics/Statistics/test/itkWeightedCentroidKdTreeGeneratorTest8.cxx +++ b/Modules/Numerics/Statistics/test/itkWeightedCentroidKdTreeGeneratorTest8.cxx @@ -37,7 +37,7 @@ itkWeightedCentroidKdTreeGeneratorTest8(int argc, char * argv[]) // Random number generator using NumberGeneratorType = itk::Statistics::MersenneTwisterRandomVariateGenerator; - NumberGeneratorType::Pointer randomNumberGenerator = NumberGeneratorType::GetInstance(); + const NumberGeneratorType::Pointer randomNumberGenerator = NumberGeneratorType::GetInstance(); randomNumberGenerator->Initialize(); constexpr unsigned int measurementVectorSize = 2; @@ -73,11 +73,11 @@ itkWeightedCentroidKdTreeGeneratorTest8(int argc, char * argv[]) using TreeType = TreeGeneratorType::KdTreeType; - TreeType::Pointer tree = treeGenerator->GetOutput(); + const TreeType::Pointer tree = treeGenerator->GetOutput(); MeasurementVectorType queryPoint; - unsigned int numberOfNeighbors = 1; + const unsigned int numberOfNeighbors = 1; TreeType::InstanceIdentifierVectorType neighbors; MeasurementVectorType result; @@ -154,8 +154,8 @@ itkWeightedCentroidKdTreeGeneratorTest8(int argc, char * argv[]) // // Compute the distance to the "presumed" nearest neighbor // - double result_dist = std::sqrt((result[0] - queryPoint[0]) * (result[0] - queryPoint[0]) + - (result[1] - queryPoint[1]) * (result[1] - queryPoint[1])); + const double result_dist = std::sqrt((result[0] - queryPoint[0]) * (result[0] - queryPoint[0]) + + (result[1] - queryPoint[1]) * (result[1] - queryPoint[1])); // // Compute the distance to all other points, to verify diff --git a/Modules/Numerics/Statistics/test/itkWeightedCentroidKdTreeGeneratorTest9.cxx b/Modules/Numerics/Statistics/test/itkWeightedCentroidKdTreeGeneratorTest9.cxx index fa996d839ef..1576adf9fda 100644 --- a/Modules/Numerics/Statistics/test/itkWeightedCentroidKdTreeGeneratorTest9.cxx +++ b/Modules/Numerics/Statistics/test/itkWeightedCentroidKdTreeGeneratorTest9.cxx @@ -74,11 +74,11 @@ itkWeightedCentroidKdTreeGeneratorTest9(int argc, char * argv[]) using TreeType = TreeGeneratorType::KdTreeType; - TreeType::Pointer tree = treeGenerator->GetOutput(); + const TreeType::Pointer tree = treeGenerator->GetOutput(); MeasurementVectorType queryPoint(measurementVectorSize); - unsigned int numberOfNeighbors = 1; + const unsigned int numberOfNeighbors = 1; TreeType::InstanceIdentifierVectorType neighbors; MeasurementVectorType result(measurementVectorSize); @@ -156,8 +156,8 @@ itkWeightedCentroidKdTreeGeneratorTest9(int argc, char * argv[]) // // Compute the distance to the "presumed" nearest neighbor // - double result_dist = std::sqrt((result[0] - queryPoint[0]) * (result[0] - queryPoint[0]) + - (result[1] - queryPoint[1]) * (result[1] - queryPoint[1])); + const double result_dist = std::sqrt((result[0] - queryPoint[0]) * (result[0] - queryPoint[0]) + + (result[1] - queryPoint[1]) * (result[1] - queryPoint[1])); // // Compute the distance to all other points, to verify diff --git a/Modules/Numerics/Statistics/test/itkWeightedCovarianceSampleFilterTest.cxx b/Modules/Numerics/Statistics/test/itkWeightedCovarianceSampleFilterTest.cxx index fcee17913ac..78e8300f37b 100644 --- a/Modules/Numerics/Statistics/test/itkWeightedCovarianceSampleFilterTest.cxx +++ b/Modules/Numerics/Statistics/test/itkWeightedCovarianceSampleFilterTest.cxx @@ -47,7 +47,7 @@ class MyWeightedCovarianceSampleFilter : public WeightedCovarianceSampleFilter::SetLength(meanExpected33, MeasurementVectorSize); diff --git a/Modules/Numerics/Statistics/test/itkWeightedCovarianceSampleFilterTest2.cxx b/Modules/Numerics/Statistics/test/itkWeightedCovarianceSampleFilterTest2.cxx index 6d0c605b69f..c11537a8428 100644 --- a/Modules/Numerics/Statistics/test/itkWeightedCovarianceSampleFilterTest2.cxx +++ b/Modules/Numerics/Statistics/test/itkWeightedCovarianceSampleFilterTest2.cxx @@ -47,7 +47,7 @@ class MyWeightedCovarianceSampleFilter : public WeightedCovarianceSampleFilter epsilon) || (itk::Math::abs(meanOutput[1] - mean[1]) > epsilon)) { diff --git a/Modules/Registration/Common/include/itkBSplineTransformParametersAdaptor.hxx b/Modules/Registration/Common/include/itkBSplineTransformParametersAdaptor.hxx index a77e92fb5a3..9f901a03d98 100644 --- a/Modules/Registration/Common/include/itkBSplineTransformParametersAdaptor.hxx +++ b/Modules/Registration/Common/include/itkBSplineTransformParametersAdaptor.hxx @@ -122,7 +122,7 @@ BSplineTransformParametersAdaptor::SetRequiredFixedParameters(const // Set the physical dimensions parameters for (SizeValueType i = 0; i < SpaceDimension; ++i) { - FixedParametersValueType gridSpacing = this->m_RequiredFixedParameters[2 * SpaceDimension + i]; + const FixedParametersValueType gridSpacing = this->m_RequiredFixedParameters[2 * SpaceDimension + i]; this->m_RequiredTransformDomainPhysicalDimensions[i] = gridSpacing * static_cast(this->m_RequiredTransformDomainMeshSize[i]); } @@ -131,7 +131,7 @@ BSplineTransformParametersAdaptor::SetRequiredFixedParameters(const OriginType origin; for (SizeValueType i = 0; i < SpaceDimension; ++i) { - FixedParametersValueType gridSpacing = this->m_RequiredFixedParameters[2 * SpaceDimension + i]; + const FixedParametersValueType gridSpacing = this->m_RequiredFixedParameters[2 * SpaceDimension + i]; origin[i] = 0.5 * gridSpacing * (TransformType::SplineOrder - 1); } origin = this->m_RequiredTransformDomainDirection * origin; @@ -163,7 +163,7 @@ BSplineTransformParametersAdaptor::UpdateRequiredFixedParameters() OriginType origin; for (SizeValueType i = 0; i < SpaceDimension; ++i) { - FixedParametersValueType gridSpacing = + const FixedParametersValueType gridSpacing = this->m_RequiredTransformDomainPhysicalDimensions[i] / static_cast(this->m_RequiredTransformDomainMeshSize[i]); origin[i] = -0.5 * gridSpacing * (TransformType::SplineOrder - 1); @@ -178,7 +178,7 @@ BSplineTransformParametersAdaptor::UpdateRequiredFixedParameters() // Set the spacing parameters for (SizeValueType i = 0; i < SpaceDimension; ++i) { - FixedParametersValueType gridSpacing = + const FixedParametersValueType gridSpacing = this->m_RequiredTransformDomainPhysicalDimensions[i] / static_cast(this->m_RequiredTransformDomainMeshSize[i]); this->m_RequiredFixedParameters[2 * SpaceDimension + i] = static_cast(gridSpacing); @@ -225,7 +225,7 @@ BSplineTransformParametersAdaptor::AdaptTransformParameters() } const RegionType & coefficientImageRegion = this->m_Transform->GetCoefficientImages()[0]->GetLargestPossibleRegion(); - IndexType newGridIndex = coefficientImageRegion.GetIndex(); + const IndexType newGridIndex = coefficientImageRegion.GetIndex(); // Resample the coefficient images using CoefficientUpsampleFunctionType = BSplineResampleImageFunction; diff --git a/Modules/Registration/Common/include/itkBlockMatchingImageFilter.hxx b/Modules/Registration/Common/include/itkBlockMatchingImageFilter.hxx index 8ae601844b4..6d2348d409b 100644 --- a/Modules/Registration/Common/include/itkBlockMatchingImageFilter.hxx +++ b/Modules/Registration/Common/include/itkBlockMatchingImageFilter.hxx @@ -174,7 +174,7 @@ BlockMatchingImageFilterm_PointsCount = SizeValueType{}; - FeaturePointsConstPointer featurePoints = this->GetFeaturePoints(); + const FeaturePointsConstPointer featurePoints = this->GetFeaturePoints(); if (featurePoints) { this->m_PointsCount = featurePoints->GetNumberOfPoints(); @@ -198,31 +198,31 @@ void BlockMatchingImageFilter:: AfterThreadedGenerateData() { - FeaturePointsConstPointer featurePoints = this->GetFeaturePoints(); + const FeaturePointsConstPointer featurePoints = this->GetFeaturePoints(); const typename FeaturePointsType::PointsContainer * points; if (featurePoints) { points = featurePoints->GetPoints(); - DisplacementsPointer displacements = this->GetDisplacements(); + const DisplacementsPointer displacements = this->GetDisplacements(); using DisplacementsPointsContainerPointerType = typename DisplacementsType::PointsContainerPointer; using DisplacementsPointsContainerType = typename DisplacementsType::PointsContainer; - DisplacementsPointsContainerPointerType displacementsPoints = DisplacementsPointsContainerType::New(); + const DisplacementsPointsContainerPointerType displacementsPoints = DisplacementsPointsContainerType::New(); using DisplacementsPointDataContainerPointerType = typename DisplacementsType::PointDataContainerPointer; using DisplacementsPointDataContainerType = typename DisplacementsType::PointDataContainer; - DisplacementsPointDataContainerPointerType displacementsData = DisplacementsPointDataContainerType::New(); + const DisplacementsPointDataContainerPointerType displacementsData = DisplacementsPointDataContainerType::New(); - SimilaritiesPointer similarities = this->GetSimilarities(); + const SimilaritiesPointer similarities = this->GetSimilarities(); using SimilaritiesPointsContainerPointerType = typename SimilaritiesType::PointsContainerPointer; using SimilaritiesPointsContainerType = typename SimilaritiesType::PointsContainer; - SimilaritiesPointsContainerPointerType similaritiesPoints = SimilaritiesPointsContainerType::New(); + const SimilaritiesPointsContainerPointerType similaritiesPoints = SimilaritiesPointsContainerType::New(); using SimilaritiesPointDataContainerPointerType = typename SimilaritiesType::PointDataContainerPointer; using SimilaritiesPointDataContainerType = typename SimilaritiesType::PointDataContainer; - SimilaritiesPointDataContainerPointerType similaritiesData = SimilaritiesPointDataContainerType::New(); + const SimilaritiesPointDataContainerPointerType similaritiesData = SimilaritiesPointDataContainerType::New(); // insert displacements and similarities for (SizeValueType i = 0; i < this->m_PointsCount; ++i) @@ -253,8 +253,8 @@ ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION BlockMatchingImageFilter::ThreaderCallback( void * arg) { - auto * str = (ThreadStruct *)(((MultiThreaderBase::WorkUnitInfo *)(arg))->UserData); - ThreadIdType workUnitID = ((MultiThreaderBase::WorkUnitInfo *)(arg))->WorkUnitID; + auto * str = (ThreadStruct *)(((MultiThreaderBase::WorkUnitInfo *)(arg))->UserData); + const ThreadIdType workUnitID = ((MultiThreaderBase::WorkUnitInfo *)(arg))->WorkUnitID; str->Filter->ThreadedGenerateData(workUnitID); @@ -270,15 +270,15 @@ void BlockMatchingImageFilter::ThreadedGenerateData( ThreadIdType threadId) { - FixedImageConstPointer fixedImage = this->GetFixedImage(); - MovingImageConstPointer movingImage = this->GetMovingImage(); - FeaturePointsConstPointer featurePoints = this->GetFeaturePoints(); + const FixedImageConstPointer fixedImage = this->GetFixedImage(); + const MovingImageConstPointer movingImage = this->GetMovingImage(); + const FeaturePointsConstPointer featurePoints = this->GetFeaturePoints(); - SizeValueType workUnitCount = this->GetNumberOfWorkUnits(); + const SizeValueType workUnitCount = this->GetNumberOfWorkUnits(); // compute first point and number of points (count) for this thread - SizeValueType count = m_PointsCount / workUnitCount; - SizeValueType first = threadId * count; + SizeValueType count = m_PointsCount / workUnitCount; + const SizeValueType first = threadId * count; if (threadId + 1 == workUnitCount) // last thread { count += this->m_PointsCount % workUnitCount; @@ -302,9 +302,9 @@ BlockMatchingImageFilterGetPoint(idx); - const auto fixedIndex = fixedImage->TransformPhysicalPointToIndex(originalLocation); - const auto movingIndex = movingImage->TransformPhysicalPointToIndex(originalLocation); + const FeaturePointsPhysicalCoordinates originalLocation = featurePoints->GetPoint(idx); + const auto fixedIndex = fixedImage->TransformPhysicalPointToIndex(originalLocation); + const auto movingIndex = movingImage->TransformPhysicalPointToIndex(originalLocation); // the block is selected for a minimum similarity metric SimilaritiesValue similarity{}; @@ -313,7 +313,7 @@ BlockMatchingImageFilterm_SearchRadius; + const ImageIndexType start = fixedIndex - this->m_SearchRadius; window.SetIndex(start); center.SetIndex(movingIndex); diff --git a/Modules/Registration/Common/include/itkCenteredVersorTransformInitializer.hxx b/Modules/Registration/Common/include/itkCenteredVersorTransformInitializer.hxx index 18514ec8574..c04b65b834d 100644 --- a/Modules/Registration/Common/include/itkCenteredVersorTransformInitializer.hxx +++ b/Modules/Registration/Common/include/itkCenteredVersorTransformInitializer.hxx @@ -41,10 +41,10 @@ CenteredVersorTransformInitializer::InitializeTransfo using FixedMatrixType = typename Superclass::FixedImageCalculatorType::MatrixType; using MovingMatrixType = typename Superclass::MovingImageCalculatorType::MatrixType; - FixedMatrixType fixedPrincipalAxis = this->GetFixedCalculator()->GetPrincipalAxes(); - MovingMatrixType movingPrincipalAxis = this->GetMovingCalculator()->GetPrincipalAxes(); + const FixedMatrixType fixedPrincipalAxis = this->GetFixedCalculator()->GetPrincipalAxes(); + const MovingMatrixType movingPrincipalAxis = this->GetMovingCalculator()->GetPrincipalAxes(); - MovingMatrixType rotationMatrix = movingPrincipalAxis * fixedPrincipalAxis.GetInverse(); + const MovingMatrixType rotationMatrix = movingPrincipalAxis * fixedPrincipalAxis.GetInverse(); this->GetModifiableTransform()->SetMatrix(rotationMatrix); } diff --git a/Modules/Registration/Common/include/itkCompareHistogramImageToImageMetric.hxx b/Modules/Registration/Common/include/itkCompareHistogramImageToImageMetric.hxx index ce129085de0..9f55b8cf013 100644 --- a/Modules/Registration/Common/include/itkCompareHistogramImageToImageMetric.hxx +++ b/Modules/Registration/Common/include/itkCompareHistogramImageToImageMetric.hxx @@ -114,7 +114,8 @@ CompareHistogramImageToImageMetric::FormTrainingHisto typename Superclass::InputPointType inputPoint; this->m_TrainingFixedImage->TransformIndexToPhysicalPoint(index, inputPoint); - typename Superclass::OutputPointType transformedPoint = this->m_TrainingTransform->TransformPoint(inputPoint); + const typename Superclass::OutputPointType transformedPoint = + this->m_TrainingTransform->TransformPoint(inputPoint); if (this->m_TrainingInterpolator->IsInsideBuffer(transformedPoint)) { diff --git a/Modules/Registration/Common/include/itkConstantVelocityFieldTransformParametersAdaptor.hxx b/Modules/Registration/Common/include/itkConstantVelocityFieldTransformParametersAdaptor.hxx index 99edd3a58a7..8254022501f 100644 --- a/Modules/Registration/Common/include/itkConstantVelocityFieldTransformParametersAdaptor.hxx +++ b/Modules/Registration/Common/include/itkConstantVelocityFieldTransformParametersAdaptor.hxx @@ -214,7 +214,7 @@ ConstantVelocityFieldTransformParametersAdaptor::AdaptTransformParam resampler->SetTransform(identityTransform); resampler->SetInterpolator(interpolator); - typename ConstantVelocityFieldType::Pointer newConstantVelocityField = resampler->GetOutput(); + const typename ConstantVelocityFieldType::Pointer newConstantVelocityField = resampler->GetOutput(); newConstantVelocityField->Update(); newConstantVelocityField->DisconnectPipeline(); diff --git a/Modules/Registration/Common/include/itkCorrelationCoefficientHistogramImageToImageMetric.hxx b/Modules/Registration/Common/include/itkCorrelationCoefficientHistogramImageToImageMetric.hxx index 65977dc809a..4fe57356a2f 100644 --- a/Modules/Registration/Common/include/itkCorrelationCoefficientHistogramImageToImageMetric.hxx +++ b/Modules/Registration/Common/include/itkCorrelationCoefficientHistogramImageToImageMetric.hxx @@ -42,8 +42,8 @@ CorrelationCoefficientHistogramImageToImageMetric::Me for (unsigned int i = 0; i < this->m_HistogramSize[0]; ++i) { - MeasureType valX = histogram.GetMeasurement(i, 0); - HistogramFrequencyType freq = histogram.GetFrequency(i, 0); + const MeasureType valX = histogram.GetMeasurement(i, 0); + const HistogramFrequencyType freq = histogram.GetFrequency(i, 0); meanX += valX * freq; } @@ -61,8 +61,8 @@ CorrelationCoefficientHistogramImageToImageMetric::Me for (unsigned int i = 0; i < this->m_HistogramSize[1]; ++i) { - MeasureType valY = histogram.GetMeasurement(i, 1); - HistogramFrequencyType freq = histogram.GetFrequency(i, 1); + const MeasureType valY = histogram.GetMeasurement(i, 1); + const HistogramFrequencyType freq = histogram.GetFrequency(i, 1); meanY += valY * freq; } @@ -108,9 +108,9 @@ auto CorrelationCoefficientHistogramImageToImageMetric::Covariance( HistogramType & histogram) const -> MeasureType { - MeasureType var{}; - MeasureType meanX = MeanX(histogram); - MeasureType meanY = MeanY(histogram); + MeasureType var{}; + const MeasureType meanX = MeanX(histogram); + const MeasureType meanY = MeanY(histogram); for (unsigned int j = 0; j < this->m_HistogramSize[1]; ++j) { diff --git a/Modules/Registration/Common/include/itkDisplacementFieldTransformParametersAdaptor.hxx b/Modules/Registration/Common/include/itkDisplacementFieldTransformParametersAdaptor.hxx index 4b3c97dd721..3e645606317 100644 --- a/Modules/Registration/Common/include/itkDisplacementFieldTransformParametersAdaptor.hxx +++ b/Modules/Registration/Common/include/itkDisplacementFieldTransformParametersAdaptor.hxx @@ -210,7 +210,7 @@ DisplacementFieldTransformParametersAdaptor::AdaptTransformParameter resampler->SetTransform(identityTransform); resampler->SetInterpolator(interpolator); - typename DisplacementFieldType::Pointer newDisplacementField = resampler->GetOutput(); + const typename DisplacementFieldType::Pointer newDisplacementField = resampler->GetOutput(); newDisplacementField->Update(); newDisplacementField->DisconnectPipeline(); diff --git a/Modules/Registration/Common/include/itkEuclideanDistancePointMetric.hxx b/Modules/Registration/Common/include/itkEuclideanDistancePointMetric.hxx index 2fd31cd3c11..e34b6f62731 100644 --- a/Modules/Registration/Common/include/itkEuclideanDistancePointMetric.hxx +++ b/Modules/Registration/Common/include/itkEuclideanDistancePointMetric.hxx @@ -33,7 +33,7 @@ template ::GetNumberOfValues() const { - MovingPointSetConstPointer movingPointSet = this->GetMovingPointSet(); + const MovingPointSetConstPointer movingPointSet = this->GetMovingPointSet(); if (!movingPointSet) { @@ -48,22 +48,22 @@ auto EuclideanDistancePointMetric::GetValue( const TransformParametersType & parameters) const -> MeasureType { - FixedPointSetConstPointer fixedPointSet = this->GetFixedPointSet(); + const FixedPointSetConstPointer fixedPointSet = this->GetFixedPointSet(); if (!fixedPointSet) { itkExceptionMacro("Fixed point set has not been assigned"); } - MovingPointSetConstPointer movingPointSet = this->GetMovingPointSet(); + const MovingPointSetConstPointer movingPointSet = this->GetMovingPointSet(); if (!movingPointSet) { itkExceptionMacro("Moving point set has not been assigned"); } - MovingPointIterator pointItr = movingPointSet->GetPoints()->Begin(); - MovingPointIterator pointEnd = movingPointSet->GetPoints()->End(); + MovingPointIterator pointItr = movingPointSet->GetPoints()->Begin(); + const MovingPointIterator pointEnd = movingPointSet->GetPoints()->End(); MeasureType measure; measure.set_size(movingPointSet->GetPoints()->Size()); @@ -75,7 +75,7 @@ EuclideanDistancePointMetric::Get { typename Superclass::InputPointType inputPoint; inputPoint.CastFrom(pointItr.Value()); - typename Superclass::OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); + const typename Superclass::OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); double minimumDistance = NumericTraits::max(); bool closestPoint = false; @@ -99,8 +99,8 @@ EuclideanDistancePointMetric::Get // points and find the closest distance if (!closestPoint) { - FixedPointIterator pointItr2 = fixedPointSet->GetPoints()->Begin(); - FixedPointIterator pointEnd2 = fixedPointSet->GetPoints()->End(); + FixedPointIterator pointItr2 = fixedPointSet->GetPoints()->Begin(); + const FixedPointIterator pointEnd2 = fixedPointSet->GetPoints()->End(); while (pointItr2 != pointEnd2) { diff --git a/Modules/Registration/Common/include/itkHistogramImageToImageMetric.hxx b/Modules/Registration/Common/include/itkHistogramImageToImageMetric.hxx index 8b1cb0c621e..4e3aea94ec9 100644 --- a/Modules/Registration/Common/include/itkHistogramImageToImageMetric.hxx +++ b/Modules/Registration/Common/include/itkHistogramImageToImageMetric.hxx @@ -90,7 +90,7 @@ HistogramImageToImageMetric::Initialize() if (!m_LowerBoundSetByUser || !m_UpperBoundSetByUser) { // Calculate min and max image values in fixed image. - FixedImageConstPointerType pFixedImage = this->m_FixedImage; + const FixedImageConstPointerType pFixedImage = this->m_FixedImage; ImageRegionConstIterator fiIt(pFixedImage, pFixedImage->GetBufferedRegion()); fiIt.GoToBegin(); FixedImagePixelType minFixed = fiIt.Value(); @@ -98,7 +98,7 @@ HistogramImageToImageMetric::Initialize() ++fiIt; while (!fiIt.IsAtEnd()) { - FixedImagePixelType value = fiIt.Value(); + const FixedImagePixelType value = fiIt.Value(); if (value < minFixed) { @@ -113,7 +113,7 @@ HistogramImageToImageMetric::Initialize() } // Calculate min and max image values in moving image. - MovingImageConstPointerType pMovingImage = this->m_MovingImage; + const MovingImageConstPointerType pMovingImage = this->m_MovingImage; ImageRegionConstIterator miIt(pMovingImage, pMovingImage->GetBufferedRegion()); miIt.GoToBegin(); MovingImagePixelType minMoving = miIt.Value(); @@ -121,7 +121,7 @@ HistogramImageToImageMetric::Initialize() ++miIt; while (!miIt.IsAtEnd()) { - MovingImagePixelType value = miIt.Value(); + const MovingImagePixelType value = miIt.Value(); if (value < minMoving) { @@ -210,7 +210,7 @@ HistogramImageToImageMetric::GetDerivative(const Tran newParameters[i] -= m_DerivativeStepLength / m_DerivativeStepLengthScales[i]; this->ComputeHistogram(newParameters, *pHistogram2); - MeasureType e0 = EvaluateMeasure(*pHistogram2); + const MeasureType e0 = EvaluateMeasure(*pHistogram2); pHistogram2 = HistogramType::New(); pHistogram2->SetMeasurementVectorSize(2); @@ -220,7 +220,7 @@ HistogramImageToImageMetric::GetDerivative(const Tran newParameters[i] += m_DerivativeStepLength / m_DerivativeStepLengthScales[i]; this->ComputeHistogram(newParameters, *pHistogram2); - MeasureType e1 = EvaluateMeasure(*pHistogram2); + const MeasureType e1 = EvaluateMeasure(*pHistogram2); derivative[i] = (e1 - e0) / (2 * m_DerivativeStepLength / m_DerivativeStepLengthScales[i]); } @@ -242,7 +242,7 @@ void HistogramImageToImageMetric::ComputeHistogram(const TransformParametersType & parameters, HistogramType & histogram) const { - FixedImageConstPointerType fixedImage = this->m_FixedImage; + const FixedImageConstPointerType fixedImage = this->m_FixedImage; if (!fixedImage) { @@ -279,7 +279,7 @@ HistogramImageToImageMetric::ComputeHistogram(const T continue; } - OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); + const OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); if (this->m_MovingImageMask && !this->m_MovingImageMask->IsInsideInWorldSpace(transformedPoint)) { @@ -340,14 +340,14 @@ HistogramImageToImageMetric::CopyHistogram(HistogramT target.Initialize(size, min, max); // Copy the values. - typename HistogramType::Iterator sourceIt = source.Begin(); - typename HistogramType::Iterator sourceEnd = source.End(); - typename HistogramType::Iterator targetIt = target.Begin(); - typename HistogramType::Iterator targetEnd = target.End(); + typename HistogramType::Iterator sourceIt = source.Begin(); + const typename HistogramType::Iterator sourceEnd = source.End(); + typename HistogramType::Iterator targetIt = target.Begin(); + const typename HistogramType::Iterator targetEnd = target.End(); while (sourceIt != sourceEnd && targetIt != targetEnd) { - typename HistogramType::AbsoluteFrequencyType freq = sourceIt.GetFrequency(); + const typename HistogramType::AbsoluteFrequencyType freq = sourceIt.GetFrequency(); if (freq > 0) { diff --git a/Modules/Registration/Common/include/itkImageRegistrationMethod.hxx b/Modules/Registration/Common/include/itkImageRegistrationMethod.hxx index 97202a2168b..765f8d8a8c6 100644 --- a/Modules/Registration/Common/include/itkImageRegistrationMethod.hxx +++ b/Modules/Registration/Common/include/itkImageRegistrationMethod.hxx @@ -42,7 +42,7 @@ ImageRegistrationMethod::ImageRegistrationMethod() m_FixedImageRegionDefined = false; - TransformOutputPointer transformDecorator = + const TransformOutputPointer transformDecorator = itkDynamicCastInDebugMode(this->MakeOutput(0).GetPointer()); this->ProcessObject::SetNthOutput(0, transformDecorator.GetPointer()); diff --git a/Modules/Registration/Common/include/itkImageToImageMetric.hxx b/Modules/Registration/Common/include/itkImageToImageMetric.hxx index f2a1f7fdddd..65bd54bfadb 100644 --- a/Modules/Registration/Common/include/itkImageToImageMetric.hxx +++ b/Modules/Registration/Common/include/itkImageToImageMetric.hxx @@ -438,7 +438,7 @@ ImageToImageMetric::SampleFixedImageIndexes(FixedImag for (SizeValueType i = 0; i < len; ++i) { // Get sampled index - FixedImageIndexType index = m_FixedImageIndexes[i]; + const FixedImageIndexType index = m_FixedImageIndexes[i]; // Translate index to point m_FixedImage->TransformIndexToPhysicalPoint(index, iter->point); @@ -471,8 +471,8 @@ ImageToImageMetric::SampleFixedImageRegion(FixedImage { randIter.ReinitializeSeed(m_RandomSeed++); } - typename FixedImageSampleContainer::iterator iter; - typename FixedImageSampleContainer::const_iterator end = samples.end(); + typename FixedImageSampleContainer::iterator iter; + const typename FixedImageSampleContainer::const_iterator end = samples.end(); if (m_FixedImageMask.IsNotNull() || m_UseFixedImageSamplesIntensityThreshold) { @@ -507,7 +507,7 @@ ImageToImageMetric::SampleFixedImageRegion(FixedImage } // Get sampled index - FixedImageIndexType index = randIter.GetIndex(); + const FixedImageIndexType index = randIter.GetIndex(); // Check if the Index is inside the mask, translate index to point m_FixedImage->TransformIndexToPhysicalPoint(index, inputPoint); @@ -553,7 +553,7 @@ ImageToImageMetric::SampleFixedImageRegion(FixedImage for (iter = samples.begin(); iter != end; ++iter) { // Get sampled index - FixedImageIndexType index = randIter.GetIndex(); + const FixedImageIndexType index = randIter.GetIndex(); // Translate index to point m_FixedImage->TransformIndexToPhysicalPoint(index, iter->point); // Get sampled fixed image value @@ -581,8 +581,8 @@ ImageToImageMetric::SampleFullFixedImageRegion(FixedI regionIter.GoToBegin(); - typename FixedImageSampleContainer::iterator iter; - typename FixedImageSampleContainer::const_iterator end = samples.end(); + typename FixedImageSampleContainer::iterator iter; + const typename FixedImageSampleContainer::const_iterator end = samples.end(); if (m_FixedImageMask.IsNotNull() || m_UseFixedImageSamplesIntensityThreshold) { @@ -593,7 +593,7 @@ ImageToImageMetric::SampleFullFixedImageRegion(FixedI while (iter != end) { // Get sampled index - FixedImageIndexType index = regionIter.GetIndex(); + const FixedImageIndexType index = regionIter.GetIndex(); // Check if the Index is inside the mask, translate index to point m_FixedImage->TransformIndexToPhysicalPoint(index, inputPoint); @@ -640,7 +640,7 @@ ImageToImageMetric::SampleFullFixedImageRegion(FixedI for (iter = samples.begin(); iter != end; ++iter) { // Get sampled index - FixedImageIndexType index = regionIter.GetIndex(); + const FixedImageIndexType index = regionIter.GetIndex(); // Translate index to point m_FixedImage->TransformIndexToPhysicalPoint(index, iter->point); @@ -661,7 +661,7 @@ template void ImageToImageMetric::ComputeGradient() { - GradientImageFilterPointer gradientFilter = GradientImageFilterType::New(); + const GradientImageFilterPointer gradientFilter = GradientImageFilterType::New(); gradientFilter->SetInput(m_MovingImage); @@ -731,9 +731,9 @@ ImageToImageMetric::PreComputeTransformValues() MovingImagePointType mappedPoint; // Declare iterators for iteration over the sample container - typename FixedImageSampleContainer::const_iterator fiter; - typename FixedImageSampleContainer::const_iterator fend = m_FixedImageSamples.end(); - SizeValueType counter = 0; + typename FixedImageSampleContainer::const_iterator fiter; + const typename FixedImageSampleContainer::const_iterator fend = m_FixedImageSamples.end(); + SizeValueType counter = 0; for (fiter = m_FixedImageSamples.begin(); fiter != fend; ++fiter, counter++) { diff --git a/Modules/Registration/Common/include/itkImageToSpatialObjectRegistrationMethod.hxx b/Modules/Registration/Common/include/itkImageToSpatialObjectRegistrationMethod.hxx index ce90aad5f96..fe8d2ce5982 100644 --- a/Modules/Registration/Common/include/itkImageToSpatialObjectRegistrationMethod.hxx +++ b/Modules/Registration/Common/include/itkImageToSpatialObjectRegistrationMethod.hxx @@ -40,7 +40,7 @@ ImageToSpatialObjectRegistrationMethod::Image m_InitialTransformParameters.Fill(0.0f); m_LastTransformParameters.Fill(0.0f); - TransformOutputPointer transformDecorator = + const TransformOutputPointer transformDecorator = itkDynamicCastInDebugMode(this->MakeOutput(0).GetPointer()); this->ProcessObject::SetNthOutput(0, transformDecorator.GetPointer()); diff --git a/Modules/Registration/Common/include/itkKappaStatisticImageToImageMetric.hxx b/Modules/Registration/Common/include/itkKappaStatisticImageToImageMetric.hxx index 09759392cb4..c009b278586 100644 --- a/Modules/Registration/Common/include/itkKappaStatisticImageToImageMetric.hxx +++ b/Modules/Registration/Common/include/itkKappaStatisticImageToImageMetric.hxx @@ -43,7 +43,7 @@ KappaStatisticImageToImageMetric::GetValue(const Tran // Get the fixed image // - FixedImageConstPointer fixedImage = this->m_FixedImage; + const FixedImageConstPointer fixedImage = this->m_FixedImage; if (!fixedImage) { itkExceptionMacro("Fixed image has not been assigned"); @@ -57,7 +57,7 @@ KappaStatisticImageToImageMetric::GetValue(const Tran // Get the moving image // - MovingImageConstPointer movingImage = this->m_MovingImage; + const MovingImageConstPointer movingImage = this->m_MovingImage; if (!movingImage) { itkExceptionMacro("Moving image has not been assigned"); @@ -107,7 +107,7 @@ KappaStatisticImageToImageMetric::GetValue(const Tran // the point in the fixed image (physical coordinates) // // - OutputPointType transformedPoint = this->m_Transform->TransformPoint(fixedInputPoint); + const OutputPointType transformedPoint = this->m_Transform->TransformPoint(fixedInputPoint); if (this->m_MovingImageMask && !this->m_MovingImageMask->IsInsideInWorldSpace(transformedPoint)) { @@ -160,7 +160,7 @@ KappaStatisticImageToImageMetric::GetDerivative(const itkExceptionMacro("The gradient image is null, maybe you forgot to call Initialize()"); } - FixedImageConstPointer fixedImage = this->m_FixedImage; + const FixedImageConstPointer fixedImage = this->m_FixedImage; if (!fixedImage) { itkExceptionMacro("Fixed image has not been assigned"); @@ -217,7 +217,7 @@ KappaStatisticImageToImageMetric::GetDerivative(const ++fixedArea; } - OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); + const OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); if (this->m_MovingImageMask && !this->m_MovingImageMask->IsInsideInWorldSpace(transformedPoint)) { @@ -276,7 +276,7 @@ KappaStatisticImageToImageMetric::GetDerivative(const } else { - double areaSum = static_cast(fixedArea) + static_cast(movingArea); + const double areaSum = static_cast(fixedArea) + static_cast(movingArea); for (unsigned int par = 0; par < ParametersDimension; ++par) { derivative[par] = -(areaSum * sum1[par] - 2.0 * intersection * sum2[par]) / (areaSum * areaSum); diff --git a/Modules/Registration/Common/include/itkKullbackLeiblerCompareHistogramImageToImageMetric.hxx b/Modules/Registration/Common/include/itkKullbackLeiblerCompareHistogramImageToImageMetric.hxx index 713b2e9a90f..675e50ff5cf 100644 --- a/Modules/Registration/Common/include/itkKullbackLeiblerCompareHistogramImageToImageMetric.hxx +++ b/Modules/Registration/Common/include/itkKullbackLeiblerCompareHistogramImageToImageMetric.hxx @@ -51,17 +51,17 @@ KullbackLeiblerCompareHistogramImageToImageMetric::Ev MeasureType KullbackLeibler{}; - HistogramIteratorType measured_it = histogram.Begin(); - HistogramIteratorType measured_end = histogram.End(); + HistogramIteratorType measured_it = histogram.Begin(); + const HistogramIteratorType measured_end = histogram.End(); - HistogramIteratorType training_it = this->GetTrainingHistogram()->Begin(); - HistogramIteratorType training_end = this->GetTrainingHistogram()->End(); + HistogramIteratorType training_it = this->GetTrainingHistogram()->Begin(); + const HistogramIteratorType training_end = this->GetTrainingHistogram()->End(); while (measured_it != measured_end) { // Every bin gets epsilon added to it - double TrainingFreq = training_it.GetFrequency() + m_Epsilon; - double MeasuredFreq = measured_it.GetFrequency() + m_Epsilon; + const double TrainingFreq = training_it.GetFrequency() + m_Epsilon; + const double MeasuredFreq = measured_it.GetFrequency() + m_Epsilon; KullbackLeibler += MeasuredFreq * std::log(MeasuredFreq / TrainingFreq); @@ -75,14 +75,14 @@ KullbackLeiblerCompareHistogramImageToImageMetric::Ev } // Get the total frequency for each histogram. - HistogramFrequencyType totalTrainingFreq = this->GetTrainingHistogram()->GetTotalFrequency(); - HistogramFrequencyType totalMeasuredFreq = histogram.GetTotalFrequency(); + const HistogramFrequencyType totalTrainingFreq = this->GetTrainingHistogram()->GetTotalFrequency(); + const HistogramFrequencyType totalMeasuredFreq = histogram.GetTotalFrequency(); // The actual number of total frequency is a bit larger // than the number of counts because we add m_Epsilon to every bin - double AdjustedTotalTrainingFreq = + const double AdjustedTotalTrainingFreq = totalTrainingFreq + this->GetHistogramSize()[0] * this->GetHistogramSize()[1] * m_Epsilon; - double AdjustedTotalMeasuredFreq = + const double AdjustedTotalMeasuredFreq = totalMeasuredFreq + this->GetHistogramSize()[0] * this->GetHistogramSize()[1] * m_Epsilon; KullbackLeibler = KullbackLeibler / static_cast(AdjustedTotalMeasuredFreq) - diff --git a/Modules/Registration/Common/include/itkLandmarkBasedTransformInitializer.hxx b/Modules/Registration/Common/include/itkLandmarkBasedTransformInitializer.hxx index 0dc994120f0..8eec7fc12ee 100644 --- a/Modules/Registration/Common/include/itkLandmarkBasedTransformInitializer.hxx +++ b/Modules/Registration/Common/include/itkLandmarkBasedTransformInitializer.hxx @@ -157,7 +157,7 @@ LandmarkBasedTransformInitializer::Intern filter->SetNumberOfLevels(3); - typename FilterType::ArrayType close{}; + const typename FilterType::ArrayType close{}; filter->SetCloseDimension(close); filter->Update(); @@ -314,16 +314,16 @@ LandmarkBasedTransformInitializer::Intern // [Solve Qa=C] // :: Solving code is from // https://www.itk.org/pipermail/insight-users/2008-December/028207.html - vnl_matrix transposeAffine = vnl_qr(Q).solve(C); - vnl_matrix Affine = transposeAffine.transpose(); + const vnl_matrix transposeAffine = vnl_qr(Q).solve(C); + vnl_matrix Affine = transposeAffine.transpose(); - vnl_matrix AffineRotation(Affine.get_n_columns(0, ImageDimension)); + const vnl_matrix AffineRotation(Affine.get_n_columns(0, ImageDimension)); // [Convert ITK Affine Transformation from vnl] // // Define Matrix Type. - itk::Matrix mA(AffineRotation); - itk::Vector mT; + const itk::Matrix mA(AffineRotation); + itk::Vector mT; for (unsigned int t = 0; t < ImageDimension; ++t) { mT[t] = Affine(t, ImageDimension); @@ -440,7 +440,7 @@ LandmarkBasedTransformInitializer::Intern itk::Matrix, vnl_vector, vnl_matrix>; - SymmetricEigenAnalysisType symmetricEigenSystem; + const SymmetricEigenAnalysisType symmetricEigenSystem; symmetricEigenSystem.ComputeEigenValuesAndVectors(N, eigenValues, eigenVectors); @@ -580,7 +580,7 @@ LandmarkBasedTransformInitializer::Intern itk::Matrix, vnl_vector, vnl_matrix>; - SymmetricEigenAnalysisType symmetricEigenSystem; + const SymmetricEigenAnalysisType symmetricEigenSystem; symmetricEigenSystem.ComputeEigenValuesAndVectors(N, eigenValues, eigenVectors); diff --git a/Modules/Registration/Common/include/itkMatchCardinalityImageToImageMetric.hxx b/Modules/Registration/Common/include/itkMatchCardinalityImageToImageMetric.hxx index 352fe344d86..cb8e05c05ef 100644 --- a/Modules/Registration/Common/include/itkMatchCardinalityImageToImageMetric.hxx +++ b/Modules/Registration/Common/include/itkMatchCardinalityImageToImageMetric.hxx @@ -46,7 +46,7 @@ MatchCardinalityImageToImageMetric::GetNonconstValue( { itkDebugMacro("GetValue( " << parameters << " ) "); - FixedImageConstPointer fixedImage = this->m_FixedImage; + const FixedImageConstPointer fixedImage = this->m_FixedImage; if (!fixedImage) { itkExceptionMacro("Fixed image has not been assigned"); @@ -112,7 +112,7 @@ MatchCardinalityImageToImageMetric::ThreadedGetValue( const FixedImageRegionType & regionForThread, ThreadIdType threadId) { - FixedImageConstPointer fixedImage = this->GetFixedImage(); + const FixedImageConstPointer fixedImage = this->GetFixedImage(); if (!fixedImage) { @@ -126,7 +126,7 @@ MatchCardinalityImageToImageMetric::ThreadedGetValue( SizeValueType threadNumberOfPixelsCounted = 0; while (!ti.IsAtEnd()) { - typename FixedImageType::IndexType index = ti.GetIndex(); + const typename FixedImageType::IndexType index = ti.GetIndex(); typename Superclass::InputPointType inputPoint; fixedImage->TransformIndexToPhysicalPoint(index, inputPoint); @@ -137,7 +137,7 @@ MatchCardinalityImageToImageMetric::ThreadedGetValue( continue; } - typename Superclass::OutputPointType transformedPoint = this->GetTransform()->TransformPoint(inputPoint); + const typename Superclass::OutputPointType transformedPoint = this->GetTransform()->TransformPoint(inputPoint); if (this->GetMovingImageMask() && !this->GetMovingImageMask()->IsInsideInWorldSpace(transformedPoint)) { @@ -197,9 +197,9 @@ MatchCardinalityImageToImageMetric::SplitFixedRegion( } // determine the actual number of pieces that will be generated - typename FixedImageRegionType::SizeType::SizeValueType range = fixedRegionSize[splitAxis]; - auto valuesPerThread = Math::Ceil(range / static_cast(num)); - ThreadIdType maxThreadIdUsed = Math::Ceil(range / static_cast(valuesPerThread)) - 1; + const typename FixedImageRegionType::SizeType::SizeValueType range = fixedRegionSize[splitAxis]; + auto valuesPerThread = Math::Ceil(range / static_cast(num)); + const ThreadIdType maxThreadIdUsed = Math::Ceil(range / static_cast(valuesPerThread)) - 1; // Split the region if (i < maxThreadIdUsed) @@ -227,15 +227,15 @@ template ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION MatchCardinalityImageToImageMetric::ThreaderCallback(void * arg) { - ThreadIdType workUnitID = ((MultiThreaderBase::WorkUnitInfo *)(arg))->WorkUnitID; - ThreadIdType workUnitCount = ((MultiThreaderBase::WorkUnitInfo *)(arg))->NumberOfWorkUnits; + const ThreadIdType workUnitID = ((MultiThreaderBase::WorkUnitInfo *)(arg))->WorkUnitID; + const ThreadIdType workUnitCount = ((MultiThreaderBase::WorkUnitInfo *)(arg))->NumberOfWorkUnits; ThreadStruct * str = (ThreadStruct *)(((MultiThreaderBase::WorkUnitInfo *)(arg))->UserData); // execute the actual method with appropriate computation region // first find out how many pieces extent can be split into. FixedImageRegionType splitRegion; - ThreadIdType total = str->Metric->SplitFixedRegion(workUnitID, workUnitCount, splitRegion); + const ThreadIdType total = str->Metric->SplitFixedRegion(workUnitID, workUnitCount, splitRegion); if (workUnitID < total) { diff --git a/Modules/Registration/Common/include/itkMattesMutualInformationImageToImageMetric.hxx b/Modules/Registration/Common/include/itkMattesMutualInformationImageToImageMetric.hxx index e696bb3c1b7..4647fae63d7 100644 --- a/Modules/Registration/Common/include/itkMattesMutualInformationImageToImageMetric.hxx +++ b/Modules/Registration/Common/include/itkMattesMutualInformationImageToImageMetric.hxx @@ -578,7 +578,7 @@ MattesMutualInformationImageToImageMetric::GetValueAn } // Determine parzen window arguments (see eqn 6 of Mattes paper [2]). - PDFValueType movingImageParzenWindowTerm = + const PDFValueType movingImageParzenWindowTerm = movingImageValue / this->m_MovingImageBinSize - this->m_MovingImageNormalizedMin; auto movingImageParzenWindowIndex = static_cast(movingImageParzenWindowTerm); diff --git a/Modules/Registration/Common/include/itkMeanReciprocalSquareDifferenceImageToImageMetric.hxx b/Modules/Registration/Common/include/itkMeanReciprocalSquareDifferenceImageToImageMetric.hxx index bd3feb6bf39..a46df9f2f17 100644 --- a/Modules/Registration/Common/include/itkMeanReciprocalSquareDifferenceImageToImageMetric.hxx +++ b/Modules/Registration/Common/include/itkMeanReciprocalSquareDifferenceImageToImageMetric.hxx @@ -47,7 +47,7 @@ auto MeanReciprocalSquareDifferenceImageToImageMetric::GetValue( const TransformParametersType & parameters) const -> MeasureType { - FixedImageConstPointer fixedImage = this->m_FixedImage; + const FixedImageConstPointer fixedImage = this->m_FixedImage; if (!fixedImage) { @@ -83,7 +83,7 @@ MeanReciprocalSquareDifferenceImageToImageMetric::Get } const TransformType * transform = this->m_Transform; - OutputPointType transformedPoint = transform->TransformPoint(inputPoint); + const OutputPointType transformedPoint = transform->TransformPoint(inputPoint); if (this->m_MovingImageMask && !this->m_MovingImageMask->IsInsideInWorldSpace(transformedPoint)) { diff --git a/Modules/Registration/Common/include/itkMeanReciprocalSquareDifferencePointSetToImageMetric.hxx b/Modules/Registration/Common/include/itkMeanReciprocalSquareDifferencePointSetToImageMetric.hxx index 6a1b0ef298c..fb5ae4262f9 100644 --- a/Modules/Registration/Common/include/itkMeanReciprocalSquareDifferencePointSetToImageMetric.hxx +++ b/Modules/Registration/Common/include/itkMeanReciprocalSquareDifferencePointSetToImageMetric.hxx @@ -35,23 +35,23 @@ auto MeanReciprocalSquareDifferencePointSetToImageMetric::GetValue( const TransformParametersType & parameters) const -> MeasureType { - FixedPointSetConstPointer fixedPointSet = this->GetFixedPointSet(); + const FixedPointSetConstPointer fixedPointSet = this->GetFixedPointSet(); if (!fixedPointSet) { itkExceptionMacro("Fixed point set has not been assigned"); } - PointIterator pointItr = fixedPointSet->GetPoints()->Begin(); - PointIterator pointEnd = fixedPointSet->GetPoints()->End(); + PointIterator pointItr = fixedPointSet->GetPoints()->Begin(); + const PointIterator pointEnd = fixedPointSet->GetPoints()->End(); - PointDataIterator pointDataItr = fixedPointSet->GetPointData()->Begin(); - PointDataIterator pointDataEnd = fixedPointSet->GetPointData()->End(); + PointDataIterator pointDataItr = fixedPointSet->GetPointData()->Begin(); + const PointDataIterator pointDataEnd = fixedPointSet->GetPointData()->End(); MeasureType measure{}; this->m_NumberOfPixelsCounted = 0; - double lambdaSquared = std::pow(this->m_Lambda, 2); + const double lambdaSquared = std::pow(this->m_Lambda, 2); this->SetTransformParameters(parameters); @@ -59,7 +59,7 @@ MeanReciprocalSquareDifferencePointSetToImageMetricm_Transform->TransformPoint(inputPoint); + const OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); if (this->m_Interpolator->IsInsideBuffer(transformedPoint)) { @@ -98,7 +98,7 @@ MeanReciprocalSquareDifferencePointSetToImageMetricGetFixedPointSet(); + const FixedPointSetConstPointer fixedPointSet = this->GetFixedPointSet(); if (!fixedPointSet) { @@ -107,7 +107,7 @@ MeanReciprocalSquareDifferencePointSetToImageMetricm_NumberOfPixelsCounted = 0; - double lambdaSquared = std::pow(this->m_Lambda, 2); + const double lambdaSquared = std::pow(this->m_Lambda, 2); this->SetTransformParameters(parameters); @@ -115,11 +115,11 @@ MeanReciprocalSquareDifferencePointSetToImageMetricGetPoints()->Begin(); - PointIterator pointEnd = fixedPointSet->GetPoints()->End(); + PointIterator pointItr = fixedPointSet->GetPoints()->Begin(); + const PointIterator pointEnd = fixedPointSet->GetPoints()->End(); - PointDataIterator pointDataItr = fixedPointSet->GetPointData()->Begin(); - PointDataIterator pointDataEnd = fixedPointSet->GetPointData()->End(); + PointDataIterator pointDataItr = fixedPointSet->GetPointData()->Begin(); + const PointDataIterator pointDataEnd = fixedPointSet->GetPointData()->End(); TransformJacobianType jacobian(TMovingImage::ImageDimension, this->m_Transform->GetNumberOfParameters()); TransformJacobianType jacobianCache; @@ -128,7 +128,7 @@ MeanReciprocalSquareDifferencePointSetToImageMetricm_Transform->TransformPoint(inputPoint); + const OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); if (this->m_Interpolator->IsInsideBuffer(transformedPoint)) { @@ -196,7 +196,7 @@ MeanReciprocalSquareDifferencePointSetToImageMetricGetFixedPointSet(); + const FixedPointSetConstPointer fixedPointSet = this->GetFixedPointSet(); if (!fixedPointSet) { @@ -207,17 +207,17 @@ MeanReciprocalSquareDifferencePointSetToImageMetricSetTransformParameters(parameters); - double lambdaSquared = std::pow(this->m_Lambda, 2); + const double lambdaSquared = std::pow(this->m_Lambda, 2); const unsigned int ParametersDimension = this->GetNumberOfParameters(); derivative = DerivativeType(ParametersDimension); derivative.Fill(typename DerivativeType::ValueType{}); - PointIterator pointItr = fixedPointSet->GetPoints()->Begin(); - PointIterator pointEnd = fixedPointSet->GetPoints()->End(); + PointIterator pointItr = fixedPointSet->GetPoints()->Begin(); + const PointIterator pointEnd = fixedPointSet->GetPoints()->End(); - PointDataIterator pointDataItr = fixedPointSet->GetPointData()->Begin(); - PointDataIterator pointDataEnd = fixedPointSet->GetPointData()->End(); + PointDataIterator pointDataItr = fixedPointSet->GetPointData()->Begin(); + const PointDataIterator pointDataEnd = fixedPointSet->GetPointData()->End(); TransformJacobianType jacobian(TMovingImage::ImageDimension, this->m_Transform->GetNumberOfParameters()); TransformJacobianType jacobianCache(TMovingImage::ImageDimension, TMovingImage::ImageDimension); @@ -225,7 +225,7 @@ MeanReciprocalSquareDifferencePointSetToImageMetricm_Transform->TransformPoint(inputPoint); + const OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); if (this->m_Interpolator->IsInsideBuffer(transformedPoint)) { diff --git a/Modules/Registration/Common/include/itkMeanSquaresHistogramImageToImageMetric.hxx b/Modules/Registration/Common/include/itkMeanSquaresHistogramImageToImageMetric.hxx index 124cf8744e7..f693e1cb732 100644 --- a/Modules/Registration/Common/include/itkMeanSquaresHistogramImageToImageMetric.hxx +++ b/Modules/Registration/Common/include/itkMeanSquaresHistogramImageToImageMetric.hxx @@ -26,14 +26,14 @@ auto MeanSquaresHistogramImageToImageMetric::EvaluateMeasure(HistogramType & histogram) const -> MeasureType { - MeasureType measure{}; - HistogramIteratorType it = histogram.Begin(); - HistogramIteratorType end = histogram.End(); - HistogramFrequencyType totalNumberOfSamples{}; + MeasureType measure{}; + HistogramIteratorType it = histogram.Begin(); + const HistogramIteratorType end = histogram.End(); + HistogramFrequencyType totalNumberOfSamples{}; while (it != end) { - HistogramFrequencyType freq = it.GetFrequency(); + const HistogramFrequencyType freq = it.GetFrequency(); if (freq > 0) { HistogramMeasurementVectorType value = it.GetMeasurementVector(); diff --git a/Modules/Registration/Common/include/itkMeanSquaresImageToImageMetric.hxx b/Modules/Registration/Common/include/itkMeanSquaresImageToImageMetric.hxx index ed0e00717b3..2142c931b15 100644 --- a/Modules/Registration/Common/include/itkMeanSquaresImageToImageMetric.hxx +++ b/Modules/Registration/Common/include/itkMeanSquaresImageToImageMetric.hxx @@ -81,7 +81,7 @@ MeanSquaresImageToImageMetric::GetValueThreadProcessS const MovingImagePointType & itkNotUsed(mappedPoint), double movingImageValue) const { - double diff = movingImageValue - this->m_FixedImageSamples[fixedImageSample].value; + const double diff = movingImageValue - this->m_FixedImageSamples[fixedImageSample].value; m_PerThread[threadId].m_MSE += diff * diff; @@ -139,13 +139,13 @@ MeanSquaresImageToImageMetric::GetValueAndDerivativeT double movingImageValue, const ImageDerivativesType & movingImageGradientValue) const { - double diff = movingImageValue - this->m_FixedImageSamples[fixedImageSample].value; + const double diff = movingImageValue - this->m_FixedImageSamples[fixedImageSample].value; AlignedPerThreadType & threadS = m_PerThread[threadId]; threadS.m_MSE += diff * diff; - FixedImagePointType fixedImagePoint = this->m_FixedImageSamples[fixedImageSample].point; + const FixedImagePointType fixedImagePoint = this->m_FixedImageSamples[fixedImageSample].point; // Need to use one of the threader transforms if we're // not in thread 0. diff --git a/Modules/Registration/Common/include/itkMeanSquaresPointSetToImageMetric.hxx b/Modules/Registration/Common/include/itkMeanSquaresPointSetToImageMetric.hxx index 646b94722fe..23859e38646 100644 --- a/Modules/Registration/Common/include/itkMeanSquaresPointSetToImageMetric.hxx +++ b/Modules/Registration/Common/include/itkMeanSquaresPointSetToImageMetric.hxx @@ -30,18 +30,18 @@ auto MeanSquaresPointSetToImageMetric::GetValue( const TransformParametersType & parameters) const -> MeasureType { - FixedPointSetConstPointer fixedPointSet = this->GetFixedPointSet(); + const FixedPointSetConstPointer fixedPointSet = this->GetFixedPointSet(); if (!fixedPointSet) { itkExceptionMacro("Fixed point set has not been assigned"); } - PointIterator pointItr = fixedPointSet->GetPoints()->Begin(); - PointIterator pointEnd = fixedPointSet->GetPoints()->End(); + PointIterator pointItr = fixedPointSet->GetPoints()->Begin(); + const PointIterator pointEnd = fixedPointSet->GetPoints()->End(); - PointDataIterator pointDataItr = fixedPointSet->GetPointData()->Begin(); - PointDataIterator pointDataEnd = fixedPointSet->GetPointData()->End(); + PointDataIterator pointDataItr = fixedPointSet->GetPointData()->Begin(); + const PointDataIterator pointDataEnd = fixedPointSet->GetPointData()->End(); MeasureType measure{}; @@ -54,7 +54,7 @@ MeanSquaresPointSetToImageMetric::GetValue( { InputPointType inputPoint; inputPoint.CastFrom(pointItr.Value()); - OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); + const OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); if (this->m_Interpolator->IsInsideBuffer(transformedPoint)) { @@ -95,7 +95,7 @@ MeanSquaresPointSetToImageMetric::GetDerivative( itkExceptionMacro("The gradient image is null, maybe you forgot to call Initialize()"); } - FixedPointSetConstPointer fixedPointSet = this->GetFixedPointSet(); + const FixedPointSetConstPointer fixedPointSet = this->GetFixedPointSet(); if (!fixedPointSet) { @@ -110,11 +110,11 @@ MeanSquaresPointSetToImageMetric::GetDerivative( derivative = DerivativeType(ParametersDimension); derivative.Fill(typename DerivativeType::ValueType{}); - PointIterator pointItr = fixedPointSet->GetPoints()->Begin(); - PointIterator pointEnd = fixedPointSet->GetPoints()->End(); + PointIterator pointItr = fixedPointSet->GetPoints()->Begin(); + const PointIterator pointEnd = fixedPointSet->GetPoints()->End(); - PointDataIterator pointDataItr = fixedPointSet->GetPointData()->Begin(); - PointDataIterator pointDataEnd = fixedPointSet->GetPointData()->End(); + PointDataIterator pointDataItr = fixedPointSet->GetPointData()->Begin(); + const PointDataIterator pointDataEnd = fixedPointSet->GetPointData()->End(); TransformJacobianType jacobian(TMovingImage::ImageDimension, this->m_Transform->GetNumberOfParameters()); TransformJacobianType jacobianCache; @@ -123,7 +123,7 @@ MeanSquaresPointSetToImageMetric::GetDerivative( { InputPointType inputPoint; inputPoint.CastFrom(pointItr.Value()); - OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); + const OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); if (this->m_Interpolator->IsInsideBuffer(transformedPoint)) { @@ -191,7 +191,7 @@ MeanSquaresPointSetToImageMetric::GetValueAndDeriv itkExceptionMacro("The gradient image is null, maybe you forgot to call Initialize()"); } - FixedPointSetConstPointer fixedPointSet = this->GetFixedPointSet(); + const FixedPointSetConstPointer fixedPointSet = this->GetFixedPointSet(); if (!fixedPointSet) { @@ -207,11 +207,11 @@ MeanSquaresPointSetToImageMetric::GetValueAndDeriv derivative = DerivativeType(ParametersDimension); derivative.Fill(typename DerivativeType::ValueType{}); - PointIterator pointItr = fixedPointSet->GetPoints()->Begin(); - PointIterator pointEnd = fixedPointSet->GetPoints()->End(); + PointIterator pointItr = fixedPointSet->GetPoints()->Begin(); + const PointIterator pointEnd = fixedPointSet->GetPoints()->End(); - PointDataIterator pointDataItr = fixedPointSet->GetPointData()->Begin(); - PointDataIterator pointDataEnd = fixedPointSet->GetPointData()->End(); + PointDataIterator pointDataItr = fixedPointSet->GetPointData()->Begin(); + const PointDataIterator pointDataEnd = fixedPointSet->GetPointData()->End(); TransformJacobianType jacobian(TMovingImage::ImageDimension, this->m_Transform->GetNumberOfParameters()); TransformJacobianType jacobianCache(TMovingImage::ImageDimension, TMovingImage::ImageDimension); @@ -220,7 +220,7 @@ MeanSquaresPointSetToImageMetric::GetValueAndDeriv { InputPointType inputPoint; inputPoint.CastFrom(pointItr.Value()); - OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); + const OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); if (this->m_Interpolator->IsInsideBuffer(transformedPoint)) { diff --git a/Modules/Registration/Common/include/itkMultiResolutionImageRegistrationMethod.hxx b/Modules/Registration/Common/include/itkMultiResolutionImageRegistrationMethod.hxx index c2592b2ae35..fd5e58886da 100644 --- a/Modules/Registration/Common/include/itkMultiResolutionImageRegistrationMethod.hxx +++ b/Modules/Registration/Common/include/itkMultiResolutionImageRegistrationMethod.hxx @@ -57,7 +57,7 @@ MultiResolutionImageRegistrationMethod::MultiResoluti m_InitialTransformParametersOfNextLevel.Fill(0.0f); m_LastTransformParameters.Fill(0.0f); - TransformOutputPointer transformDecorator = + const TransformOutputPointer transformDecorator = itkDynamicCastInDebugMode(this->MakeOutput(0).GetPointer()); this->ProcessObject::SetNthOutput(0, transformDecorator.GetPointer()); @@ -224,7 +224,7 @@ MultiResolutionImageRegistrationMethod::PreparePyrami ScheduleType schedule = m_FixedImagePyramid->GetSchedule(); itkDebugMacro("FixedImage schedule: " << schedule); - ScheduleType movingschedule = m_MovingImagePyramid->GetSchedule(); + const ScheduleType movingschedule = m_MovingImagePyramid->GetSchedule(); itkDebugMacro("MovingImage schedule: " << movingschedule); SizeType inputSize = m_FixedImageRegion.GetSize(); diff --git a/Modules/Registration/Common/include/itkMultiResolutionPyramidImageFilter.hxx b/Modules/Registration/Common/include/itkMultiResolutionPyramidImageFilter.hxx index aef072f7579..53db4abfce3 100644 --- a/Modules/Registration/Common/include/itkMultiResolutionPyramidImageFilter.hxx +++ b/Modules/Registration/Common/include/itkMultiResolutionPyramidImageFilter.hxx @@ -78,7 +78,7 @@ MultiResolutionPyramidImageFilter::SetNumberOfLevels( // add extra outputs for (unsigned int idx = numOutputs; idx < m_NumberOfLevels; ++idx) { - typename DataObject::Pointer output = this->MakeOutput(idx); + const typename DataObject::Pointer output = this->MakeOutput(idx); this->SetNthOutput(idx, output.GetPointer()); } } @@ -202,7 +202,7 @@ void MultiResolutionPyramidImageFilter::GenerateData() { // Get the input and output pointers - InputImageConstPointer inputPtr = this->GetInput(); + const InputImageConstPointer inputPtr = this->GetInput(); // Create caster, smoother and resampleShrinker filters using CasterType = CastImageFilter; @@ -254,7 +254,7 @@ MultiResolutionPyramidImageFilter::GenerateData() this->UpdateProgress(static_cast(ilevel) / static_cast(m_NumberOfLevels)); // Allocate memory for each output - OutputImagePointer outputPtr = this->GetOutput(ilevel); + const OutputImagePointer outputPtr = this->GetOutput(ilevel); outputPtr->SetBufferedRegion(outputPtr->GetRequestedRegion()); outputPtr->Allocate(); @@ -308,7 +308,7 @@ MultiResolutionPyramidImageFilter::GenerateOutputInfo Superclass::GenerateOutputInformation(); // get pointers to the input and output - InputImageConstPointer inputPtr = this->GetInput(); + const InputImageConstPointer inputPtr = this->GetInput(); if (!inputPtr) { @@ -328,7 +328,7 @@ MultiResolutionPyramidImageFilter::GenerateOutputInfo // and the output image start index for (unsigned int ilevel = 0; ilevel < m_NumberOfLevels; ++ilevel) { - OutputImagePointer outputPtr = this->GetOutput(ilevel); + const OutputImagePointer outputPtr = this->GetOutput(ilevel); if (!outputPtr) { continue; @@ -422,7 +422,7 @@ MultiResolutionPyramidImageFilter::GenerateOutputRequ for (unsigned int idim = 0; idim < TOutputImage::ImageDimension; ++idim) { - unsigned int factor = m_Schedule[refLevel][idim]; + const unsigned int factor = m_Schedule[refLevel][idim]; baseIndex[idim] *= static_cast(factor); baseSize[idim] *= static_cast(factor); } @@ -470,7 +470,7 @@ MultiResolutionPyramidImageFilter::GenerateInputReque Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - InputImagePointer inputPtr = const_cast(this->GetInput()); + const InputImagePointer inputPtr = const_cast(this->GetInput()); if (!inputPtr) { itkExceptionMacro("Input has not been set."); @@ -487,7 +487,7 @@ MultiResolutionPyramidImageFilter::GenerateInputReque for (unsigned int idim = 0; idim < ImageDimension; ++idim) { - unsigned int factor = m_Schedule[refLevel][idim]; + const unsigned int factor = m_Schedule[refLevel][idim]; baseIndex[idim] *= static_cast(factor); baseSize[idim] *= static_cast(factor); } diff --git a/Modules/Registration/Common/include/itkMutualInformationHistogramImageToImageMetric.hxx b/Modules/Registration/Common/include/itkMutualInformationHistogramImageToImageMetric.hxx index ea06bcc0a5a..0844a8cd42a 100644 --- a/Modules/Registration/Common/include/itkMutualInformationHistogramImageToImageMetric.hxx +++ b/Modules/Registration/Common/include/itkMutualInformationHistogramImageToImageMetric.hxx @@ -57,8 +57,8 @@ MutualInformationHistogramImageToImageMetric::Evaluat entropyY = -entropyY / static_cast(totalFreq) + std::log(totalFreq); - HistogramIteratorType it = histogram.Begin(); - HistogramIteratorType end = histogram.End(); + HistogramIteratorType it = histogram.Begin(); + const HistogramIteratorType end = histogram.End(); while (it != end) { auto freq = static_cast(it.GetFrequency()); diff --git a/Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx b/Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx index e7a79b8936b..7bd9bbe7b20 100644 --- a/Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx +++ b/Modules/Registration/Common/include/itkMutualInformationImageToImageMetric.hxx @@ -99,8 +99,8 @@ MutualInformationImageToImageMetric::SampleFixedImage randIter.SetNumberOfSamples(m_NumberOfSpatialSamples); randIter.GoToBegin(); - typename SpatialSampleContainer::iterator iter; - typename SpatialSampleContainer::const_iterator end = samples.end(); + typename SpatialSampleContainer::iterator iter; + const typename SpatialSampleContainer::const_iterator end = samples.end(); bool allOutside = true; @@ -112,12 +112,12 @@ MutualInformationImageToImageMetric::SampleFixedImage // Number of random picks made from the portion of fixed image within the // fixed mask - SizeValueType numberOfFixedImagePixelsVisited = 0; - SizeValueType dryRunTolerance = this->GetFixedImageRegion().GetNumberOfPixels(); + SizeValueType numberOfFixedImagePixelsVisited = 0; + const SizeValueType dryRunTolerance = this->GetFixedImageRegion().GetNumberOfPixels(); for (iter = samples.begin(); iter != end; ++iter) { // Get sampled index - FixedImageIndexType index = randIter.GetIndex(); + const FixedImageIndexType index = randIter.GetIndex(); // Get sampled fixed image value iter->FixedImageValue = randIter.Get(); // Translate index to point @@ -141,7 +141,7 @@ MutualInformationImageToImageMetric::SampleFixedImage } } - MovingImagePointType mappedPoint = this->m_Transform->TransformPoint(iter->FixedImagePointValue); + const MovingImagePointType mappedPoint = this->m_Transform->TransformPoint(iter->FixedImagePointValue); // If the transformed point after transformation does not lie within the // MovingImageMask, skip it. @@ -201,10 +201,10 @@ MutualInformationImageToImageMetric::GetValue(const P SumType dSumMoving; SumType dSumJoint; - typename SpatialSampleContainer::const_iterator aiter; - typename SpatialSampleContainer::const_iterator aend = m_SampleA.end(); - typename SpatialSampleContainer::const_iterator biter; - typename SpatialSampleContainer::const_iterator bend = m_SampleB.end(); + typename SpatialSampleContainer::const_iterator aiter; + const typename SpatialSampleContainer::const_iterator aend = m_SampleA.end(); + typename SpatialSampleContainer::const_iterator biter; + const typename SpatialSampleContainer::const_iterator bend = m_SampleB.end(); for (biter = m_SampleB.begin(); biter != bend; ++biter) { dSumFixed.ResetToZero(); @@ -245,7 +245,7 @@ MutualInformationImageToImageMetric::GetValue(const P auto nsamp = static_cast(m_NumberOfSpatialSamples); - double threshold = -0.5 * nsamp * std::log(m_MinProbability); + const double threshold = -0.5 * nsamp * std::log(m_MinProbability); if (dLogSumMoving.GetSum() > threshold || dLogSumFixed.GetSum() > threshold || dLogSumJoint.GetSum() > threshold) { // at least half the samples in B did not occur within @@ -267,8 +267,8 @@ MutualInformationImageToImageMetric::GetValueAndDeriv DerivativeType & derivative) const { value = MeasureType{}; - unsigned int numberOfParameters = this->m_Transform->GetNumberOfParameters(); - DerivativeType temp(numberOfParameters); + const unsigned int numberOfParameters = this->m_Transform->GetNumberOfParameters(); + DerivativeType temp(numberOfParameters); temp.Fill(0); derivative = temp; @@ -293,10 +293,10 @@ MutualInformationImageToImageMetric::GetValueAndDeriv SumType dDenominatorMoving; SumType dDenominatorJoint; - typename SpatialSampleContainer::iterator aiter; - typename SpatialSampleContainer::const_iterator aend = m_SampleA.end(); - typename SpatialSampleContainer::iterator biter; - typename SpatialSampleContainer::const_iterator bend = m_SampleB.end(); + typename SpatialSampleContainer::iterator aiter; + const typename SpatialSampleContainer::const_iterator aend = m_SampleA.end(); + typename SpatialSampleContainer::iterator biter; + const typename SpatialSampleContainer::const_iterator bend = m_SampleB.end(); // precalculate all the image derivatives for sample A using DerivativeContainer = std::vector; @@ -385,7 +385,7 @@ MutualInformationImageToImageMetric::GetValueAndDeriv auto nsamp = static_cast(m_NumberOfSpatialSamples); - double threshold = -0.5 * nsamp * std::log(m_MinProbability); + const double threshold = -0.5 * nsamp * std::log(m_MinProbability); if (dLogSumMoving.GetSum() > threshold || dLogSumFixed.GetSum() > threshold || dLogSumJoint.GetSum() > threshold) { // at least half the samples in B did not occur within @@ -419,7 +419,7 @@ MutualInformationImageToImageMetric::CalculateDerivat DerivativeType & derivatives, TransformJacobianType & jacobian) const { - MovingImagePointType mappedPoint = this->m_Transform->TransformPoint(point); + const MovingImagePointType mappedPoint = this->m_Transform->TransformPoint(point); CovariantVector imageDerivatives; @@ -435,7 +435,7 @@ MutualInformationImageToImageMetric::CalculateDerivat this->m_Transform->ComputeJacobianWithRespectToParameters(point, jacobian); - unsigned int numberOfParameters = this->m_Transform->GetNumberOfParameters(); + const unsigned int numberOfParameters = this->m_Transform->GetNumberOfParameters(); for (unsigned int k = 0; k < numberOfParameters; ++k) { derivatives[k] = 0.0; diff --git a/Modules/Registration/Common/include/itkNormalizedCorrelationImageToImageMetric.hxx b/Modules/Registration/Common/include/itkNormalizedCorrelationImageToImageMetric.hxx index 6556bb796eb..b89b5d19dfe 100644 --- a/Modules/Registration/Common/include/itkNormalizedCorrelationImageToImageMetric.hxx +++ b/Modules/Registration/Common/include/itkNormalizedCorrelationImageToImageMetric.hxx @@ -34,7 +34,7 @@ auto NormalizedCorrelationImageToImageMetric::GetValue( const TransformParametersType & parameters) const -> MeasureType { - FixedImageConstPointer fixedImage = this->m_FixedImage; + const FixedImageConstPointer fixedImage = this->m_FixedImage; if (!fixedImage) { @@ -74,7 +74,7 @@ NormalizedCorrelationImageToImageMetric::GetValue( continue; } - OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); + const OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); if (this->m_MovingImageMask && !this->m_MovingImageMask->IsInsideInWorldSpace(transformedPoint)) { @@ -132,7 +132,7 @@ NormalizedCorrelationImageToImageMetric::GetDerivativ itkExceptionMacro("The gradient image is null, maybe you forgot to call Initialize()"); } - FixedImageConstPointer fixedImage = this->m_FixedImage; + const FixedImageConstPointer fixedImage = this->m_FixedImage; if (!fixedImage) { @@ -184,7 +184,7 @@ NormalizedCorrelationImageToImageMetric::GetDerivativ continue; } - OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); + const OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); if (this->m_MovingImageMask && !this->m_MovingImageMask->IsInsideInWorldSpace(transformedPoint)) { @@ -228,7 +228,7 @@ NormalizedCorrelationImageToImageMetric::GetDerivativ continue; } - OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); + const OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); if (this->m_MovingImageMask && !this->m_MovingImageMask->IsInsideInWorldSpace(transformedPoint)) { @@ -315,7 +315,7 @@ NormalizedCorrelationImageToImageMetric::GetValueAndD itkExceptionMacro("The gradient image is null, maybe you forgot to call Initialize()"); } - FixedImageConstPointer fixedImage = this->m_FixedImage; + const FixedImageConstPointer fixedImage = this->m_FixedImage; if (!fixedImage) { @@ -370,7 +370,7 @@ NormalizedCorrelationImageToImageMetric::GetValueAndD continue; } - OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); + const OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); if (this->m_MovingImageMask && !this->m_MovingImageMask->IsInsideInWorldSpace(transformedPoint)) { @@ -413,7 +413,7 @@ NormalizedCorrelationImageToImageMetric::GetValueAndD continue; } - OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); + const OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); if (this->m_MovingImageMask && !this->m_MovingImageMask->IsInsideInWorldSpace(transformedPoint)) { diff --git a/Modules/Registration/Common/include/itkNormalizedCorrelationPointSetToImageMetric.hxx b/Modules/Registration/Common/include/itkNormalizedCorrelationPointSetToImageMetric.hxx index 89148241ebd..6497bd8f6ea 100644 --- a/Modules/Registration/Common/include/itkNormalizedCorrelationPointSetToImageMetric.hxx +++ b/Modules/Registration/Common/include/itkNormalizedCorrelationPointSetToImageMetric.hxx @@ -34,18 +34,18 @@ auto NormalizedCorrelationPointSetToImageMetric::GetValue( const TransformParametersType & parameters) const -> MeasureType { - FixedPointSetConstPointer fixedPointSet = this->GetFixedPointSet(); + const FixedPointSetConstPointer fixedPointSet = this->GetFixedPointSet(); if (!fixedPointSet) { itkExceptionMacro("Fixed point set has not been assigned"); } - PointIterator pointItr = fixedPointSet->GetPoints()->Begin(); - PointIterator pointEnd = fixedPointSet->GetPoints()->End(); + PointIterator pointItr = fixedPointSet->GetPoints()->Begin(); + const PointIterator pointEnd = fixedPointSet->GetPoints()->End(); - PointDataIterator pointDataItr = fixedPointSet->GetPointData()->Begin(); - PointDataIterator pointDataEnd = fixedPointSet->GetPointData()->End(); + PointDataIterator pointDataItr = fixedPointSet->GetPointData()->Begin(); + const PointDataIterator pointDataEnd = fixedPointSet->GetPointData()->End(); MeasureType measure; @@ -65,7 +65,7 @@ NormalizedCorrelationPointSetToImageMetric::GetVal { InputPointType inputPoint; inputPoint.CastFrom(pointItr.Value()); - OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); + const OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); if (this->m_Interpolator->IsInsideBuffer(transformedPoint)) { @@ -118,7 +118,7 @@ NormalizedCorrelationPointSetToImageMetric::GetDer itkExceptionMacro("The gradient image is null, maybe you forgot to call Initialize()"); } - FixedPointSetConstPointer fixedPointSet = this->GetFixedPointSet(); + const FixedPointSetConstPointer fixedPointSet = this->GetFixedPointSet(); if (!fixedPointSet) { @@ -152,11 +152,11 @@ NormalizedCorrelationPointSetToImageMetric::GetDer DerivativeType derivativeO(ParametersDimension); derivativeO.Fill(typename DerivativeType::ValueType{}); - PointIterator pointItr = fixedPointSet->GetPoints()->Begin(); - PointIterator pointEnd = fixedPointSet->GetPoints()->End(); + PointIterator pointItr = fixedPointSet->GetPoints()->Begin(); + const PointIterator pointEnd = fixedPointSet->GetPoints()->End(); - PointDataIterator pointDataItr = fixedPointSet->GetPointData()->Begin(); - PointDataIterator pointDataEnd = fixedPointSet->GetPointData()->End(); + PointDataIterator pointDataItr = fixedPointSet->GetPointData()->Begin(); + const PointDataIterator pointDataEnd = fixedPointSet->GetPointData()->End(); TransformJacobianType jacobian(TMovingImage::ImageDimension, this->m_Transform->GetNumberOfParameters()); TransformJacobianType jacobianCache(TMovingImage::ImageDimension, TMovingImage::ImageDimension); @@ -165,7 +165,7 @@ NormalizedCorrelationPointSetToImageMetric::GetDer { InputPointType inputPoint; inputPoint.CastFrom(pointItr.Value()); - OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); + const OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); if (this->m_Interpolator->IsInsideBuffer(transformedPoint)) { @@ -261,7 +261,7 @@ NormalizedCorrelationPointSetToImageMetric::GetVal itkExceptionMacro("The gradient image is null, maybe you forgot to call Initialize()"); } - FixedPointSetConstPointer fixedPointSet = this->GetFixedPointSet(); + const FixedPointSetConstPointer fixedPointSet = this->GetFixedPointSet(); if (!fixedPointSet) { @@ -295,11 +295,11 @@ NormalizedCorrelationPointSetToImageMetric::GetVal DerivativeType derivativeO(ParametersDimension); derivativeO.Fill(typename DerivativeType::ValueType{}); - PointIterator pointItr = fixedPointSet->GetPoints()->Begin(); - PointIterator pointEnd = fixedPointSet->GetPoints()->End(); + PointIterator pointItr = fixedPointSet->GetPoints()->Begin(); + const PointIterator pointEnd = fixedPointSet->GetPoints()->End(); - PointDataIterator pointDataItr = fixedPointSet->GetPointData()->Begin(); - PointDataIterator pointDataEnd = fixedPointSet->GetPointData()->End(); + PointDataIterator pointDataItr = fixedPointSet->GetPointData()->Begin(); + const PointDataIterator pointDataEnd = fixedPointSet->GetPointData()->End(); TransformJacobianType jacobian(TMovingImage::ImageDimension, this->m_Transform->GetNumberOfParameters()); TransformJacobianType jacobianCache(TMovingImage::ImageDimension, TMovingImage::ImageDimension); @@ -308,7 +308,7 @@ NormalizedCorrelationPointSetToImageMetric::GetVal { InputPointType inputPoint; inputPoint.CastFrom(pointItr.Value()); - OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); + const OutputPointType transformedPoint = this->m_Transform->TransformPoint(inputPoint); if (this->m_Interpolator->IsInsideBuffer(transformedPoint)) { diff --git a/Modules/Registration/Common/include/itkNormalizedMutualInformationHistogramImageToImageMetric.hxx b/Modules/Registration/Common/include/itkNormalizedMutualInformationHistogramImageToImageMetric.hxx index 3939804f85d..d993a3fbfab 100644 --- a/Modules/Registration/Common/include/itkNormalizedMutualInformationHistogramImageToImageMetric.hxx +++ b/Modules/Registration/Common/include/itkNormalizedMutualInformationHistogramImageToImageMetric.hxx @@ -59,8 +59,8 @@ NormalizedMutualInformationHistogramImageToImageMetric(totalFreq) + std::log(totalFreq); - HistogramIteratorType it = histogram.Begin(); - HistogramIteratorType end = histogram.End(); + HistogramIteratorType it = histogram.Begin(); + const HistogramIteratorType end = histogram.End(); while (it != end) { auto freq = static_cast(it.GetFrequency()); diff --git a/Modules/Registration/Common/include/itkPointSetToImageMetric.hxx b/Modules/Registration/Common/include/itkPointSetToImageMetric.hxx index 34877d6acc5..575d48b90f3 100644 --- a/Modules/Registration/Common/include/itkPointSetToImageMetric.hxx +++ b/Modules/Registration/Common/include/itkPointSetToImageMetric.hxx @@ -79,7 +79,7 @@ PointSetToImageMetric::Initialize() if (m_ComputeGradient) { - GradientImageFilterPointer gradientFilter = GradientImageFilterType::New(); + const GradientImageFilterPointer gradientFilter = GradientImageFilterType::New(); gradientFilter->SetInput(m_MovingImage); diff --git a/Modules/Registration/Common/include/itkPointSetToImageRegistrationMethod.hxx b/Modules/Registration/Common/include/itkPointSetToImageRegistrationMethod.hxx index 822055aa725..6160642bf1b 100644 --- a/Modules/Registration/Common/include/itkPointSetToImageRegistrationMethod.hxx +++ b/Modules/Registration/Common/include/itkPointSetToImageRegistrationMethod.hxx @@ -33,7 +33,7 @@ PointSetToImageRegistrationMethod::PointSetToImage m_InitialTransformParameters.Fill(0); m_LastTransformParameters.Fill(0); - TransformOutputPointer transformDecorator = + const TransformOutputPointer transformDecorator = itkDynamicCastInDebugMode(this->MakeOutput(0).GetPointer()); this->ProcessObject::SetNthOutput(0, transformDecorator.GetPointer()); diff --git a/Modules/Registration/Common/include/itkPointSetToPointSetRegistrationMethod.hxx b/Modules/Registration/Common/include/itkPointSetToPointSetRegistrationMethod.hxx index f4d82da0736..957e7143862 100644 --- a/Modules/Registration/Common/include/itkPointSetToPointSetRegistrationMethod.hxx +++ b/Modules/Registration/Common/include/itkPointSetToPointSetRegistrationMethod.hxx @@ -33,7 +33,7 @@ PointSetToPointSetRegistrationMethod::PointSetT m_InitialTransformParameters.Fill(0); m_LastTransformParameters.Fill(0); - TransformOutputPointer transformDecorator = + const TransformOutputPointer transformDecorator = itkDynamicCastInDebugMode(this->MakeOutput(0).GetPointer()); this->ProcessObject::SetNthOutput(0, transformDecorator.GetPointer()); diff --git a/Modules/Registration/Common/include/itkRecursiveMultiResolutionPyramidImageFilter.hxx b/Modules/Registration/Common/include/itkRecursiveMultiResolutionPyramidImageFilter.hxx index 2199fd48567..1d6ece46ab9 100644 --- a/Modules/Registration/Common/include/itkRecursiveMultiResolutionPyramidImageFilter.hxx +++ b/Modules/Registration/Common/include/itkRecursiveMultiResolutionPyramidImageFilter.hxx @@ -49,7 +49,7 @@ RecursiveMultiResolutionPyramidImageFilter::GenerateD } // Get the input and output pointers - InputImageConstPointer inputPtr = this->GetInput(); + const InputImageConstPointer inputPtr = this->GetInput(); // Create caster, smoother and resampleShrink filters using CasterType = CastImageFilter; @@ -100,12 +100,12 @@ RecursiveMultiResolutionPyramidImageFilter::GenerateD this->UpdateProgress(1.0 - static_cast(1 + ilevel) / static_cast(this->GetNumberOfLevels())); // Allocate memory for each output - OutputImagePointer outputPtr = this->GetOutput(ilevel); + const OutputImagePointer outputPtr = this->GetOutput(ilevel); outputPtr->SetBufferedRegion(outputPtr->GetRequestedRegion()); outputPtr->Allocate(); // cached a copy of the largest possible region - typename TOutputImage::RegionType LPRegion = outputPtr->GetLargestPossibleRegion(); + const typename TOutputImage::RegionType LPRegion = outputPtr->GetLargestPossibleRegion(); // Check shrink factors and compute variances bool allOnes = true; @@ -218,7 +218,7 @@ RecursiveMultiResolutionPyramidImageFilter::GenerateO } // find the index for this output - unsigned int refLevel = static_cast(refOutputPtr->GetSourceOutputIndex()); + const unsigned int refLevel = static_cast(refOutputPtr->GetSourceOutputIndex()); using OutputPixelType = typename TOutputImage::PixelType; using OperatorType = GaussianOperator; @@ -329,7 +329,7 @@ RecursiveMultiResolutionPyramidImageFilter::GenerateI Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - InputImagePointer inputPtr = const_cast(this->GetInput()); + const InputImagePointer inputPtr = const_cast(this->GetInput()); if (!inputPtr) { itkExceptionMacro("Input has not been set."); @@ -347,7 +347,7 @@ RecursiveMultiResolutionPyramidImageFilter::GenerateI unsigned int idim; for (idim = 0; idim < ImageDimension; ++idim) { - unsigned int factor = this->GetSchedule()[refLevel][idim]; + const unsigned int factor = this->GetSchedule()[refLevel][idim]; baseIndex[idim] *= static_cast(factor); baseSize[idim] *= static_cast(factor); } diff --git a/Modules/Registration/Common/include/itkSimpleMultiResolutionImageRegistrationUI.h b/Modules/Registration/Common/include/itkSimpleMultiResolutionImageRegistrationUI.h index b8587f78cba..f13eb318691 100644 --- a/Modules/Registration/Common/include/itkSimpleMultiResolutionImageRegistrationUI.h +++ b/Modules/Registration/Common/include/itkSimpleMultiResolutionImageRegistrationUI.h @@ -109,14 +109,14 @@ class ITK_TEMPLATE_EXPORT SimpleMultiResolutionImageRegistrationUI2 // Try to cast the optimizer to a gradient descent type, // return if casting didn't work. - itk::GradientDescentOptimizer::Pointer optimizer = + const itk::GradientDescentOptimizer::Pointer optimizer = dynamic_cast(this->m_Registrator->GetModifiableOptimizer()); if (!optimizer) { return; } - unsigned int level = this->m_Registrator->GetCurrentLevel(); + const unsigned int level = this->m_Registrator->GetCurrentLevel(); if (m_NumberOfIterations.Size() >= level + 1) { optimizer->SetNumberOfIterations(m_NumberOfIterations[level]); diff --git a/Modules/Registration/Common/include/itkTimeVaryingBSplineVelocityFieldTransformParametersAdaptor.h b/Modules/Registration/Common/include/itkTimeVaryingBSplineVelocityFieldTransformParametersAdaptor.h index f9895ca0829..826aba9dc53 100644 --- a/Modules/Registration/Common/include/itkTimeVaryingBSplineVelocityFieldTransformParametersAdaptor.h +++ b/Modules/Registration/Common/include/itkTimeVaryingBSplineVelocityFieldTransformParametersAdaptor.h @@ -166,7 +166,7 @@ class ITK_TEMPLATE_EXPORT TimeVaryingBSplineVelocityFieldTransformParametersAdap SpacingType requiredLatticeSpacing; for (SizeValueType i = 0; i < TotalDimension; ++i) { - FixedParametersValueType domainPhysicalDimensions = + const FixedParametersValueType domainPhysicalDimensions = static_cast(this->m_RequiredTransformDomainSize[i] - 1.0) * this->m_RequiredTransformDomainSpacing[i]; requiredLatticeSpacing[i] = diff --git a/Modules/Registration/Common/include/itkTimeVaryingBSplineVelocityFieldTransformParametersAdaptor.hxx b/Modules/Registration/Common/include/itkTimeVaryingBSplineVelocityFieldTransformParametersAdaptor.hxx index 6599085e140..2b4b834c1bc 100644 --- a/Modules/Registration/Common/include/itkTimeVaryingBSplineVelocityFieldTransformParametersAdaptor.hxx +++ b/Modules/Registration/Common/include/itkTimeVaryingBSplineVelocityFieldTransformParametersAdaptor.hxx @@ -142,10 +142,10 @@ TimeVaryingBSplineVelocityFieldTransformParametersAdaptor::UpdateReq OriginType origin; for (SizeValueType i = 0; i < TotalDimension; ++i) { - FixedParametersValueType domainPhysicalDimensions = + const FixedParametersValueType domainPhysicalDimensions = (this->m_RequiredTransformDomainSize[i] - 1.0) * this->m_RequiredTransformDomainSpacing[i]; - FixedParametersValueType gridSpacing = + const FixedParametersValueType gridSpacing = domainPhysicalDimensions / static_cast(this->m_RequiredTransformDomainMeshSize[i]); origin[i] = -0.5 * gridSpacing * (this->m_SplineOrder - 1); } @@ -209,10 +209,10 @@ TimeVaryingBSplineVelocityFieldTransformParametersAdaptor::SetRequir OriginType origin; for (SizeValueType i = 0; i < TotalDimension; ++i) { - FixedParametersValueType domainPhysicalDimensions = + const FixedParametersValueType domainPhysicalDimensions = static_cast(this->m_RequiredTransformDomainSize[i] - 1.0) * this->m_RequiredTransformDomainSpacing[i]; - FixedParametersValueType gridSpacing = + const FixedParametersValueType gridSpacing = domainPhysicalDimensions / static_cast(this->m_RequiredTransformDomainMeshSize[i]); origin[i] = 0.5 * gridSpacing * (this->m_SplineOrder - 1); } @@ -251,14 +251,14 @@ TimeVaryingBSplineVelocityFieldTransformParametersAdaptor::AdaptTran return; } - SizeType requiredLatticeSize = this->GetRequiredControlPointLatticeSize(); - OriginType requiredLatticeOrigin = this->GetRequiredControlPointLatticeOrigin(); - SpacingType requiredLatticeSpacing = this->GetRequiredControlPointLatticeSpacing(); - DirectionType requiredLatticeDirection = this->GetRequiredControlPointLatticeDirection(); + const SizeType requiredLatticeSize = this->GetRequiredControlPointLatticeSize(); + const OriginType requiredLatticeOrigin = this->GetRequiredControlPointLatticeOrigin(); + const SpacingType requiredLatticeSpacing = this->GetRequiredControlPointLatticeSpacing(); + const DirectionType requiredLatticeDirection = this->GetRequiredControlPointLatticeDirection(); const RegionType & latticeRegion = this->m_Transform->GetTimeVaryingVelocityFieldControlPointLattice()->GetLargestPossibleRegion(); - IndexType requiredLatticeIndex = latticeRegion.GetIndex(); + const IndexType requiredLatticeIndex = latticeRegion.GetIndex(); using ComponentImageType = Image; @@ -267,7 +267,7 @@ TimeVaryingBSplineVelocityFieldTransformParametersAdaptor::AdaptTran using UpsampleFilterType = ResampleImageFilter; using DecompositionFilterType = BSplineDecompositionImageFilter; - TimeVaryingVelocityFieldControlPointLatticePointer requiredLattice = + const TimeVaryingVelocityFieldControlPointLatticePointer requiredLattice = TimeVaryingVelocityFieldControlPointLatticeType::New(); requiredLattice->SetRegions(requiredLatticeSize); requiredLattice->SetOrigin(requiredLatticeOrigin); diff --git a/Modules/Registration/Common/include/itkTimeVaryingVelocityFieldTransformParametersAdaptor.hxx b/Modules/Registration/Common/include/itkTimeVaryingVelocityFieldTransformParametersAdaptor.hxx index c7474d9eb50..f671a2386c8 100644 --- a/Modules/Registration/Common/include/itkTimeVaryingVelocityFieldTransformParametersAdaptor.hxx +++ b/Modules/Registration/Common/include/itkTimeVaryingVelocityFieldTransformParametersAdaptor.hxx @@ -211,7 +211,7 @@ TimeVaryingVelocityFieldTransformParametersAdaptor::AdaptTransformPa resampler->SetTransform(identityTransform); resampler->SetInterpolator(interpolator); - typename TimeVaryingVelocityFieldType::Pointer newTimeVaryingVelocityField = resampler->GetOutput(); + const typename TimeVaryingVelocityFieldType::Pointer newTimeVaryingVelocityField = resampler->GetOutput(); newTimeVaryingVelocityField->Update(); newTimeVaryingVelocityField->DisconnectPipeline(); diff --git a/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration10.cxx b/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration10.cxx index fc3e7d17860..5145935f6a7 100644 --- a/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration10.cxx +++ b/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration10.cxx @@ -101,8 +101,8 @@ main(int argc, char * argv[]) using FixedImageReaderType = itk::ImageFileReader; using MovingImageReaderType = itk::ImageFileReader; - FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); - MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); + const FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); + const MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); fixedImageReader->SetFileName(argv[1]); movingImageReader->SetFileName(argv[2]); @@ -112,14 +112,14 @@ main(int argc, char * argv[]) using FixedImageCasterType = itk::CastImageFilter; using MovingImageCasterType = itk::CastImageFilter; - FixedImageCasterType::Pointer fixedImageCaster = FixedImageCasterType::New(); - MovingImageCasterType::Pointer movingImageCaster = MovingImageCasterType::New(); + const FixedImageCasterType::Pointer fixedImageCaster = FixedImageCasterType::New(); + const MovingImageCasterType::Pointer movingImageCaster = MovingImageCasterType::New(); fixedImageCaster->SetInput(fixedImageReader->GetOutput()); movingImageCaster->SetInput(movingImageReader->GetOutput()); using MatchingFilterType = itk::HistogramMatchingImageFilter; - MatchingFilterType::Pointer matcher = MatchingFilterType::New(); + const MatchingFilterType::Pointer matcher = MatchingFilterType::New(); matcher->SetInput(movingImageCaster->GetOutput()); matcher->SetReferenceImage(fixedImageCaster->GetOutput()); @@ -135,16 +135,16 @@ main(int argc, char * argv[]) DisplacementFieldType, itk::FastSymmetricForcesDemonsRegistrationFunction>; - RegistrationFilterType::Pointer filter = RegistrationFilterType::New(); + const RegistrationFilterType::Pointer filter = RegistrationFilterType::New(); filter->SetTimeStep(1); filter->SetConstraintWeight(0.1); - CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); + const CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); filter->AddObserver(itk::IterationEvent(), observer); using MultiResRegistrationFilterType = itk::MultiResolutionPDEDeformableRegistration; - MultiResRegistrationFilterType::Pointer multires = MultiResRegistrationFilterType::New(); + const MultiResRegistrationFilterType::Pointer multires = MultiResRegistrationFilterType::New(); multires->SetRegistrationFilter(filter); multires->SetNumberOfLevels(3); multires->SetFixedImage(fixedImageCaster->GetOutput()); @@ -156,9 +156,9 @@ main(int argc, char * argv[]) using WarperType = itk::WarpImageFilter; using InterpolatorType = itk::LinearInterpolateImageFunction; - WarperType::Pointer warper = WarperType::New(); - InterpolatorType::Pointer interpolator = InterpolatorType::New(); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const WarperType::Pointer warper = WarperType::New(); + const InterpolatorType::Pointer interpolator = InterpolatorType::New(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); warper->SetInput(movingImageReader->GetOutput()); warper->SetInterpolator(interpolator); @@ -173,8 +173,8 @@ main(int argc, char * argv[]) using CastFilterType = itk::CastImageFilter; using WriterType = itk::ImageFileWriter; - WriterType::Pointer writer = WriterType::New(); - CastFilterType::Pointer caster = CastFilterType::New(); + const WriterType::Pointer writer = WriterType::New(); + const CastFilterType::Pointer caster = CastFilterType::New(); writer->SetFileName(argv[3]); @@ -187,7 +187,7 @@ main(int argc, char * argv[]) using FieldWriterType = itk::ImageFileWriter; - FieldWriterType::Pointer fieldWriter = FieldWriterType::New(); + const FieldWriterType::Pointer fieldWriter = FieldWriterType::New(); fieldWriter->SetFileName(argv[4]); fieldWriter->SetInput(multires->GetOutput()); diff --git a/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration12.cxx b/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration12.cxx index 30a89b37157..82e7796efbf 100644 --- a/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration12.cxx +++ b/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration12.cxx @@ -154,10 +154,10 @@ main(int argc, char * argv[]) using RegistrationType = itk::ImageRegistrationMethod; - MetricType::Pointer metric = MetricType::New(); - OptimizerType::Pointer optimizer = OptimizerType::New(); - InterpolatorType::Pointer interpolator = InterpolatorType::New(); - RegistrationType::Pointer registration = RegistrationType::New(); + const MetricType::Pointer metric = MetricType::New(); + const OptimizerType::Pointer optimizer = OptimizerType::New(); + const InterpolatorType::Pointer interpolator = InterpolatorType::New(); + const RegistrationType::Pointer registration = RegistrationType::New(); registration->SetMetric(metric); @@ -171,31 +171,31 @@ main(int argc, char * argv[]) // \index{itk::RegistrationMethod!SetTransform()} // // - TransformType::Pointer transform = TransformType::New(); + const TransformType::Pointer transform = TransformType::New(); registration->SetTransform(transform); using FixedImageReaderType = itk::ImageFileReader; using MovingImageReaderType = itk::ImageFileReader; - FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); - MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); + const FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); + const MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); fixedImageReader->SetFileName(argv[1]); movingImageReader->SetFileName(argv[2]); - FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); registration->SetFixedImage(fixedImage); registration->SetMovingImage(movingImageReader->GetOutput()); fixedImageReader->Update(); - FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); + const FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); registration->SetFixedImageRegion(fixedRegion); - unsigned int numberOfGridNodesInOneDimension = 7; + const unsigned int numberOfGridNodesInOneDimension = 7; TransformType::PhysicalDimensionsType fixedPhysicalDimensions; TransformType::MeshSizeType meshSize; @@ -257,7 +257,7 @@ main(int argc, char * argv[]) // Create the Command observer and register it with the optimizer. // - CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); + const CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); optimizer->AddObserver(itk::IterationEvent(), observer); metric->SetNumberOfHistogramBins(50); @@ -313,7 +313,7 @@ main(int argc, char * argv[]) return EXIT_FAILURE; } - OptimizerType::ParametersType finalParameters = registration->GetLastTransformParameters(); + const OptimizerType::ParametersType finalParameters = registration->GetLastTransformParameters(); // Report the time and memory taken by the registration @@ -325,7 +325,7 @@ main(int argc, char * argv[]) using ResampleFilterType = itk::ResampleImageFilter; - ResampleFilterType::Pointer resample = ResampleFilterType::New(); + const ResampleFilterType::Pointer resample = ResampleFilterType::New(); resample->SetTransform(transform); resample->SetInput(movingImageReader->GetOutput()); @@ -350,8 +350,8 @@ main(int argc, char * argv[]) using WriterType = itk::ImageFileWriter; - WriterType::Pointer writer = WriterType::New(); - CastFilterType::Pointer caster = CastFilterType::New(); + const WriterType::Pointer writer = WriterType::New(); + const CastFilterType::Pointer caster = CastFilterType::New(); writer->SetFileName(argv[3]); @@ -374,9 +374,9 @@ main(int argc, char * argv[]) using DifferenceFilterType = itk::SquaredDifferenceImageFilter; - DifferenceFilterType::Pointer difference = DifferenceFilterType::New(); + const DifferenceFilterType::Pointer difference = DifferenceFilterType::New(); - WriterType::Pointer writer2 = WriterType::New(); + const WriterType::Pointer writer2 = WriterType::New(); writer2->SetInput(difference->GetOutput()); @@ -427,7 +427,7 @@ main(int argc, char * argv[]) using VectorType = itk::Vector; using DisplacementFieldType = itk::Image; - DisplacementFieldType::Pointer field = DisplacementFieldType::New(); + const DisplacementFieldType::Pointer field = DisplacementFieldType::New(); field->SetRegions(fixedRegion); field->SetOrigin(fixedImage->GetOrigin()); field->SetSpacing(fixedImage->GetSpacing()); @@ -456,7 +456,7 @@ main(int argc, char * argv[]) } using FieldWriterType = itk::ImageFileWriter; - FieldWriterType::Pointer fieldWriter = FieldWriterType::New(); + const FieldWriterType::Pointer fieldWriter = FieldWriterType::New(); fieldWriter->SetInput(field); diff --git a/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration4.cxx b/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration4.cxx index ab036e8774f..f6b81bde526 100644 --- a/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration4.cxx +++ b/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration4.cxx @@ -117,10 +117,10 @@ main(int argc, char * argv[]) using RegistrationType = itk::ImageRegistrationMethod; - MetricType::Pointer metric = MetricType::New(); - OptimizerType::Pointer optimizer = OptimizerType::New(); - InterpolatorType::Pointer interpolator = InterpolatorType::New(); - RegistrationType::Pointer registration = RegistrationType::New(); + const MetricType::Pointer metric = MetricType::New(); + const OptimizerType::Pointer optimizer = OptimizerType::New(); + const InterpolatorType::Pointer interpolator = InterpolatorType::New(); + const RegistrationType::Pointer registration = RegistrationType::New(); registration->SetMetric(metric); @@ -134,26 +134,26 @@ main(int argc, char * argv[]) // \index{itk::RegistrationMethod!SetTransform()} // - TransformType::Pointer transform = TransformType::New(); + const TransformType::Pointer transform = TransformType::New(); registration->SetTransform(transform); using FixedImageReaderType = itk::ImageFileReader; using MovingImageReaderType = itk::ImageFileReader; - FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); - MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); + const FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); + const MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); fixedImageReader->SetFileName(argv[1]); movingImageReader->SetFileName(argv[2]); - FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); registration->SetFixedImage(fixedImage); registration->SetMovingImage(movingImageReader->GetOutput()); fixedImageReader->Update(); - FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); + const FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); registration->SetFixedImageRegion(fixedRegion); @@ -162,7 +162,7 @@ main(int argc, char * argv[]) TransformType::MeshSizeType meshSize; TransformType::OriginType fixedOrigin; - unsigned int numberOfGridNodesInOneDimension = 8; + const unsigned int numberOfGridNodesInOneDimension = 8; for (unsigned int i = 0; i < SpaceDimension; ++i) { @@ -233,7 +233,7 @@ main(int argc, char * argv[]) return EXIT_FAILURE; } - OptimizerType::ParametersType finalParameters = registration->GetLastTransformParameters(); + const OptimizerType::ParametersType finalParameters = registration->GetLastTransformParameters(); std::cout << "Last Transform Parameters" << std::endl; std::cout << finalParameters << std::endl; @@ -258,7 +258,7 @@ main(int argc, char * argv[]) using ResampleFilterType = itk::ResampleImageFilter; - ResampleFilterType::Pointer resample = ResampleFilterType::New(); + const ResampleFilterType::Pointer resample = ResampleFilterType::New(); resample->SetTransform(transform); resample->SetInput(movingImageReader->GetOutput()); @@ -278,8 +278,8 @@ main(int argc, char * argv[]) using WriterType = itk::ImageFileWriter; - WriterType::Pointer writer = WriterType::New(); - CastFilterType::Pointer caster = CastFilterType::New(); + const WriterType::Pointer writer = WriterType::New(); + const CastFilterType::Pointer caster = CastFilterType::New(); writer->SetFileName(argv[3]); @@ -302,9 +302,9 @@ main(int argc, char * argv[]) using DifferenceFilterType = itk::SquaredDifferenceImageFilter; - DifferenceFilterType::Pointer difference = DifferenceFilterType::New(); + const DifferenceFilterType::Pointer difference = DifferenceFilterType::New(); - WriterType::Pointer writer2 = WriterType::New(); + const WriterType::Pointer writer2 = WriterType::New(); writer2->SetInput(difference->GetOutput()); @@ -353,7 +353,7 @@ main(int argc, char * argv[]) using VectorType = itk::Vector; using DisplacementFieldType = itk::Image; - DisplacementFieldType::Pointer field = DisplacementFieldType::New(); + const DisplacementFieldType::Pointer field = DisplacementFieldType::New(); field->SetRegions(fixedRegion); field->SetOrigin(fixedImage->GetOrigin()); field->SetSpacing(fixedImage->GetSpacing()); @@ -382,7 +382,7 @@ main(int argc, char * argv[]) } using FieldWriterType = itk::ImageFileWriter; - FieldWriterType::Pointer fieldWriter = FieldWriterType::New(); + const FieldWriterType::Pointer fieldWriter = FieldWriterType::New(); fieldWriter->SetInput(field); diff --git a/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration6.cxx b/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration6.cxx index 5bbe40112c1..1448edf6d42 100644 --- a/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration6.cxx +++ b/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration6.cxx @@ -108,10 +108,10 @@ main(int argc, char * argv[]) using RegistrationType = itk::ImageRegistrationMethod; - MetricType::Pointer metric = MetricType::New(); - OptimizerType::Pointer optimizer = OptimizerType::New(); - InterpolatorType::Pointer interpolator = InterpolatorType::New(); - RegistrationType::Pointer registration = RegistrationType::New(); + const MetricType::Pointer metric = MetricType::New(); + const OptimizerType::Pointer optimizer = OptimizerType::New(); + const InterpolatorType::Pointer interpolator = InterpolatorType::New(); + const RegistrationType::Pointer registration = RegistrationType::New(); registration->SetMetric(metric); @@ -128,26 +128,26 @@ main(int argc, char * argv[]) // \index{itk::RegistrationMethod!SetTransform()} // - TransformType::Pointer transformLow = TransformType::New(); + const TransformType::Pointer transformLow = TransformType::New(); registration->SetTransform(transformLow); using FixedImageReaderType = itk::ImageFileReader; using MovingImageReaderType = itk::ImageFileReader; - FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); - MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); + const FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); + const MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); fixedImageReader->SetFileName(argv[1]); movingImageReader->SetFileName(argv[2]); - FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); registration->SetFixedImage(fixedImage); registration->SetMovingImage(movingImageReader->GetOutput()); fixedImageReader->Update(); - FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); + const FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); registration->SetFixedImageRegion(fixedRegion); @@ -216,7 +216,7 @@ main(int argc, char * argv[]) // \code{BSplineTransform}. // - TransformType::Pointer transformHigh = TransformType::New(); + const TransformType::Pointer transformHigh = TransformType::New(); numberOfGridNodes = 12; @@ -250,13 +250,13 @@ main(int argc, char * argv[]) { using ParametersImageType = TransformType::ImageType; using ResamplerType = itk::ResampleImageFilter; - ResamplerType::Pointer upsampler = ResamplerType::New(); + const ResamplerType::Pointer upsampler = ResamplerType::New(); using FunctionType = itk::BSplineResampleImageFunction; - FunctionType::Pointer function = FunctionType::New(); + const FunctionType::Pointer function = FunctionType::New(); using IdentityTransformType = itk::IdentityTransform; - IdentityTransformType::Pointer identity = IdentityTransformType::New(); + const IdentityTransformType::Pointer identity = IdentityTransformType::New(); upsampler->SetInput(transformLow->GetCoefficientImages()[k]); upsampler->SetInterpolator(function); @@ -267,13 +267,13 @@ main(int argc, char * argv[]) upsampler->SetOutputDirection(fixedImage->GetDirection()); using DecompositionType = itk::BSplineDecompositionImageFilter; - DecompositionType::Pointer decomposition = DecompositionType::New(); + const DecompositionType::Pointer decomposition = DecompositionType::New(); decomposition->SetSplineOrder(SplineOrder); decomposition->SetInput(upsampler->GetOutput()); decomposition->Update(); - ParametersImageType::Pointer newCoefficients = decomposition->GetOutput(); + const ParametersImageType::Pointer newCoefficients = decomposition->GetOutput(); // copy the coefficients into the parameter array using Iterator = itk::ImageRegionIterator; @@ -319,7 +319,7 @@ main(int argc, char * argv[]) using ResampleFilterType = itk::ResampleImageFilter; - ResampleFilterType::Pointer resample = ResampleFilterType::New(); + const ResampleFilterType::Pointer resample = ResampleFilterType::New(); resample->SetTransform(transformHigh); resample->SetInput(movingImageReader->GetOutput()); @@ -339,8 +339,8 @@ main(int argc, char * argv[]) using WriterType = itk::ImageFileWriter; - WriterType::Pointer writer = WriterType::New(); - CastFilterType::Pointer caster = CastFilterType::New(); + const WriterType::Pointer writer = WriterType::New(); + const CastFilterType::Pointer caster = CastFilterType::New(); writer->SetFileName(argv[3]); @@ -363,9 +363,9 @@ main(int argc, char * argv[]) using DifferenceFilterType = itk::SquaredDifferenceImageFilter; - DifferenceFilterType::Pointer difference = DifferenceFilterType::New(); + const DifferenceFilterType::Pointer difference = DifferenceFilterType::New(); - WriterType::Pointer writer2 = WriterType::New(); + const WriterType::Pointer writer2 = WriterType::New(); writer2->SetInput(difference->GetOutput()); @@ -414,7 +414,7 @@ main(int argc, char * argv[]) using VectorType = itk::Vector; using DisplacementFieldType = itk::Image; - DisplacementFieldType::Pointer field = DisplacementFieldType::New(); + const DisplacementFieldType::Pointer field = DisplacementFieldType::New(); field->SetRegions(fixedRegion); field->SetOrigin(fixedImage->GetOrigin()); field->SetSpacing(fixedImage->GetSpacing()); @@ -443,7 +443,7 @@ main(int argc, char * argv[]) } using FieldWriterType = itk::ImageFileWriter; - FieldWriterType::Pointer fieldWriter = FieldWriterType::New(); + const FieldWriterType::Pointer fieldWriter = FieldWriterType::New(); fieldWriter->SetInput(field); diff --git a/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration7.cxx b/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration7.cxx index fdc2730cde9..ea1cf28c1d4 100644 --- a/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration7.cxx +++ b/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration7.cxx @@ -155,10 +155,10 @@ main(int argc, char * argv[]) using RegistrationType = itk::ImageRegistrationMethod; - MetricType::Pointer metric = MetricType::New(); - OptimizerType::Pointer optimizer = OptimizerType::New(); - InterpolatorType::Pointer interpolator = InterpolatorType::New(); - RegistrationType::Pointer registration = RegistrationType::New(); + const MetricType::Pointer metric = MetricType::New(); + const OptimizerType::Pointer optimizer = OptimizerType::New(); + const InterpolatorType::Pointer interpolator = InterpolatorType::New(); + const RegistrationType::Pointer registration = RegistrationType::New(); registration->SetMetric(metric); @@ -172,30 +172,30 @@ main(int argc, char * argv[]) // \index{itk::RegistrationMethod!SetTransform()} // - TransformType::Pointer transform = TransformType::New(); + const TransformType::Pointer transform = TransformType::New(); registration->SetTransform(transform); using FixedImageReaderType = itk::ImageFileReader; using MovingImageReaderType = itk::ImageFileReader; - FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); - MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); + const FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); + const MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); fixedImageReader->SetFileName(argv[1]); movingImageReader->SetFileName(argv[2]); - FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); registration->SetFixedImage(fixedImage); registration->SetMovingImage(movingImageReader->GetOutput()); fixedImageReader->Update(); - FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); + const FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); registration->SetFixedImageRegion(fixedRegion); - unsigned int numberOfGridNodes = 8; + const unsigned int numberOfGridNodes = 8; TransformType::PhysicalDimensionsType fixedPhysicalDimensions; TransformType::MeshSizeType meshSize; @@ -257,7 +257,7 @@ main(int argc, char * argv[]) // Create the Command observer and register it with the optimizer. // - CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); + const CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); optimizer->AddObserver(itk::IterationEvent(), observer); @@ -287,7 +287,7 @@ main(int argc, char * argv[]) return EXIT_FAILURE; } - OptimizerType::ParametersType finalParameters = registration->GetLastTransformParameters(); + const OptimizerType::ParametersType finalParameters = registration->GetLastTransformParameters(); std::cout << "Last Transform Parameters" << std::endl; std::cout << finalParameters << std::endl; @@ -302,7 +302,7 @@ main(int argc, char * argv[]) using ResampleFilterType = itk::ResampleImageFilter; - ResampleFilterType::Pointer resample = ResampleFilterType::New(); + const ResampleFilterType::Pointer resample = ResampleFilterType::New(); resample->SetTransform(transform); resample->SetInput(movingImageReader->GetOutput()); @@ -322,8 +322,8 @@ main(int argc, char * argv[]) using WriterType = itk::ImageFileWriter; - WriterType::Pointer writer = WriterType::New(); - CastFilterType::Pointer caster = CastFilterType::New(); + const WriterType::Pointer writer = WriterType::New(); + const CastFilterType::Pointer caster = CastFilterType::New(); writer->SetFileName(argv[3]); @@ -346,9 +346,9 @@ main(int argc, char * argv[]) using DifferenceFilterType = itk::SquaredDifferenceImageFilter; - DifferenceFilterType::Pointer difference = DifferenceFilterType::New(); + const DifferenceFilterType::Pointer difference = DifferenceFilterType::New(); - WriterType::Pointer writer2 = WriterType::New(); + const WriterType::Pointer writer2 = WriterType::New(); writer2->SetInput(difference->GetOutput()); @@ -399,7 +399,7 @@ main(int argc, char * argv[]) using VectorType = itk::Vector; using DisplacementFieldType = itk::Image; - DisplacementFieldType::Pointer field = DisplacementFieldType::New(); + const DisplacementFieldType::Pointer field = DisplacementFieldType::New(); field->SetRegions(fixedRegion); field->SetOrigin(fixedImage->GetOrigin()); field->SetSpacing(fixedImage->GetSpacing()); @@ -428,7 +428,7 @@ main(int argc, char * argv[]) } using FieldWriterType = itk::ImageFileWriter; - FieldWriterType::Pointer fieldWriter = FieldWriterType::New(); + const FieldWriterType::Pointer fieldWriter = FieldWriterType::New(); fieldWriter->SetInput(field); diff --git a/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration8.cxx b/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration8.cxx index f027ba26db2..e16af7ea212 100644 --- a/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration8.cxx +++ b/Modules/Registration/Common/test/RegistrationITKv3/DeformableRegistration8.cxx @@ -155,10 +155,10 @@ main(int argc, char * argv[]) using RegistrationType = itk::ImageRegistrationMethod; - MetricType::Pointer metric = MetricType::New(); - OptimizerType::Pointer optimizer = OptimizerType::New(); - InterpolatorType::Pointer interpolator = InterpolatorType::New(); - RegistrationType::Pointer registration = RegistrationType::New(); + const MetricType::Pointer metric = MetricType::New(); + const OptimizerType::Pointer optimizer = OptimizerType::New(); + const InterpolatorType::Pointer interpolator = InterpolatorType::New(); + const RegistrationType::Pointer registration = RegistrationType::New(); registration->SetMetric(metric); @@ -172,27 +172,27 @@ main(int argc, char * argv[]) // \index{itk::RegistrationMethod!SetTransform()} // - TransformType::Pointer transform = TransformType::New(); + const TransformType::Pointer transform = TransformType::New(); registration->SetTransform(transform); using FixedImageReaderType = itk::ImageFileReader; using MovingImageReaderType = itk::ImageFileReader; - FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); - MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); + const FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); + const MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); fixedImageReader->SetFileName(argv[1]); movingImageReader->SetFileName(argv[2]); - FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); registration->SetFixedImage(fixedImage); registration->SetMovingImage(movingImageReader->GetOutput()); fixedImageReader->Update(); - FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); + const FixedImageType::RegionType fixedRegion = fixedImage->GetBufferedRegion(); registration->SetFixedImageRegion(fixedRegion); @@ -265,7 +265,7 @@ main(int argc, char * argv[]) // Create the Command observer and register it with the optimizer. // - CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); + const CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); optimizer->AddObserver(itk::IterationEvent(), observer); @@ -335,7 +335,7 @@ main(int argc, char * argv[]) return EXIT_FAILURE; } - OptimizerType::ParametersType finalParameters = registration->GetLastTransformParameters(); + const OptimizerType::ParametersType finalParameters = registration->GetLastTransformParameters(); // Report the time and memory taken by the registration @@ -347,7 +347,7 @@ main(int argc, char * argv[]) using ResampleFilterType = itk::ResampleImageFilter; - ResampleFilterType::Pointer resample = ResampleFilterType::New(); + const ResampleFilterType::Pointer resample = ResampleFilterType::New(); resample->SetTransform(transform); resample->SetInput(movingImageReader->GetOutput()); @@ -372,8 +372,8 @@ main(int argc, char * argv[]) using WriterType = itk::ImageFileWriter; - WriterType::Pointer writer = WriterType::New(); - CastFilterType::Pointer caster = CastFilterType::New(); + const WriterType::Pointer writer = WriterType::New(); + const CastFilterType::Pointer caster = CastFilterType::New(); writer->SetFileName(argv[3]); @@ -396,9 +396,9 @@ main(int argc, char * argv[]) using DifferenceFilterType = itk::SquaredDifferenceImageFilter; - DifferenceFilterType::Pointer difference = DifferenceFilterType::New(); + const DifferenceFilterType::Pointer difference = DifferenceFilterType::New(); - WriterType::Pointer writer2 = WriterType::New(); + const WriterType::Pointer writer2 = WriterType::New(); writer2->SetInput(difference->GetOutput()); @@ -449,7 +449,7 @@ main(int argc, char * argv[]) using VectorType = itk::Vector; using DisplacementFieldType = itk::Image; - DisplacementFieldType::Pointer field = DisplacementFieldType::New(); + const DisplacementFieldType::Pointer field = DisplacementFieldType::New(); field->SetRegions(fixedRegion); field->SetOrigin(fixedImage->GetOrigin()); field->SetSpacing(fixedImage->GetSpacing()); @@ -478,7 +478,7 @@ main(int argc, char * argv[]) } using FieldWriterType = itk::ImageFileWriter; - FieldWriterType::Pointer fieldWriter = FieldWriterType::New(); + const FieldWriterType::Pointer fieldWriter = FieldWriterType::New(); fieldWriter->SetInput(field); diff --git a/Modules/Registration/Common/test/RegistrationITKv3/DeformationFieldJacobian.cxx b/Modules/Registration/Common/test/RegistrationITKv3/DeformationFieldJacobian.cxx index fa761c73959..0743f70d8ba 100644 --- a/Modules/Registration/Common/test/RegistrationITKv3/DeformationFieldJacobian.cxx +++ b/Modules/Registration/Common/test/RegistrationITKv3/DeformationFieldJacobian.cxx @@ -46,11 +46,11 @@ main(int argc, char * argv[]) using FilterType = itk::DisplacementFieldJacobianDeterminantFilter; // Set up deformation field reader - ReaderType::Pointer reader = ReaderType::New(); + const ReaderType::Pointer reader = ReaderType::New(); reader->SetFileName(argv[1]); // Connect deformation-to-Jacobian filter - FilterType::Pointer filter = FilterType::New(); + const FilterType::Pointer filter = FilterType::New(); filter->SetInput(reader->GetOutput()); // filter->SetUseImageSpacingOn(); filter->Update(); @@ -58,7 +58,7 @@ main(int argc, char * argv[]) using WriterType = itk::ImageFileWriter; // Write Jacobian determinant image. - WriterType::Pointer writer = WriterType::New(); + const WriterType::Pointer writer = WriterType::New(); writer->SetFileName(argv[2]); writer->SetInput(filter->GetOutput()); diff --git a/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration1.cxx b/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration1.cxx index fc03facf568..08e6dbc2deb 100644 --- a/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration1.cxx +++ b/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration1.cxx @@ -167,11 +167,11 @@ main(int argc, char * argv[]) // \doxygen{SmartPointer}. // - MetricType::Pointer metric = MetricType::New(); - TransformType::Pointer transform = TransformType::New(); - OptimizerType::Pointer optimizer = OptimizerType::New(); - InterpolatorType::Pointer interpolator = InterpolatorType::New(); - RegistrationType::Pointer registration = RegistrationType::New(); + const MetricType::Pointer metric = MetricType::New(); + const TransformType::Pointer transform = TransformType::New(); + const OptimizerType::Pointer optimizer = OptimizerType::New(); + const InterpolatorType::Pointer interpolator = InterpolatorType::New(); + const RegistrationType::Pointer registration = RegistrationType::New(); // @@ -192,8 +192,8 @@ main(int argc, char * argv[]) using FixedImageReaderType = itk::ImageFileReader; using MovingImageReaderType = itk::ImageFileReader; - FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); - MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); + const FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); + const MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); fixedImageReader->SetFileName(argv[1]); movingImageReader->SetFileName(argv[2]); @@ -299,7 +299,7 @@ main(int argc, char * argv[]) // Connect an observer - CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); + const CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); optimizer->AddObserver(itk::IterationEvent(), observer); @@ -431,7 +431,7 @@ main(int argc, char * argv[]) // its input. // - ResampleFilterType::Pointer resampler = ResampleFilterType::New(); + const ResampleFilterType::Pointer resampler = ResampleFilterType::New(); resampler->SetInput(movingImageReader->GetOutput()); @@ -463,7 +463,7 @@ main(int argc, char * argv[]) // the regions that are mapped outside of the moving image. // - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resampler->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resampler->SetOutputOrigin(fixedImage->GetOrigin()); resampler->SetOutputSpacing(fixedImage->GetSpacing()); @@ -505,8 +505,8 @@ main(int argc, char * argv[]) // method. // - WriterType::Pointer writer = WriterType::New(); - CastFilterType::Pointer caster = CastFilterType::New(); + const WriterType::Pointer writer = WriterType::New(); + const CastFilterType::Pointer caster = CastFilterType::New(); writer->SetFileName(argv[3]); @@ -542,7 +542,7 @@ main(int argc, char * argv[]) using DifferenceFilterType = itk::SubtractImageFilter; - DifferenceFilterType::Pointer difference = DifferenceFilterType::New(); + const DifferenceFilterType::Pointer difference = DifferenceFilterType::New(); difference->SetInput1(fixedImageReader->GetOutput()); difference->SetInput2(resampler->GetOutput()); @@ -570,7 +570,7 @@ main(int argc, char * argv[]) using RescalerType = itk::RescaleIntensityImageFilter; - RescalerType::Pointer intensityRescaler = RescalerType::New(); + const RescalerType::Pointer intensityRescaler = RescalerType::New(); intensityRescaler->SetInput(difference->GetOutput()); intensityRescaler->SetOutputMinimum(0); @@ -583,7 +583,7 @@ main(int argc, char * argv[]) // Its output can be passed to another writer. // - WriterType::Pointer writer2 = WriterType::New(); + const WriterType::Pointer writer2 = WriterType::New(); writer2->SetInput(intensityRescaler->GetOutput()); @@ -605,7 +605,7 @@ main(int argc, char * argv[]) // representation of the moving image in the grid of the fixed image. // - TransformType::Pointer identityTransform = TransformType::New(); + const TransformType::Pointer identityTransform = TransformType::New(); identityTransform->SetIdentity(); resampler->SetTransform(identityTransform); diff --git a/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration11.cxx b/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration11.cxx index b1335f6d9f4..b94179439c1 100644 --- a/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration11.cxx +++ b/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration11.cxx @@ -79,7 +79,7 @@ class CommandIterationUpdate : public itk::Command { return; } - double currentValue = optimizer->GetValue(); + const double currentValue = optimizer->GetValue(); // Only print out when the Metric value changes if (itk::Math::abs(m_LastMetricValue - currentValue) > 1e-7) { @@ -131,16 +131,16 @@ main(int argc, char * argv[]) using MetricType = itk::MattesMutualInformationImageToImageMetric; - TransformType::Pointer transform = TransformType::New(); - OptimizerType::Pointer optimizer = OptimizerType::New(); - InterpolatorType::Pointer interpolator = InterpolatorType::New(); - RegistrationType::Pointer registration = RegistrationType::New(); + const TransformType::Pointer transform = TransformType::New(); + const OptimizerType::Pointer optimizer = OptimizerType::New(); + const InterpolatorType::Pointer interpolator = InterpolatorType::New(); + const RegistrationType::Pointer registration = RegistrationType::New(); registration->SetOptimizer(optimizer); registration->SetTransform(transform); registration->SetInterpolator(interpolator); - MetricType::Pointer metric = MetricType::New(); + const MetricType::Pointer metric = MetricType::New(); registration->SetMetric(metric); metric->SetNumberOfHistogramBins(20); @@ -158,8 +158,8 @@ main(int argc, char * argv[]) using FixedImageReaderType = itk::ImageFileReader; using MovingImageReaderType = itk::ImageFileReader; - FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); - MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); + const FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); + const MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); fixedImageReader->SetFileName(argv[1]); movingImageReader->SetFileName(argv[2]); @@ -194,7 +194,7 @@ main(int argc, char * argv[]) using GeneratorType = itk::Statistics::NormalVariateGenerator; - GeneratorType::Pointer generator = GeneratorType::New(); + const GeneratorType::Pointer generator = GeneratorType::New(); // @@ -224,7 +224,7 @@ main(int argc, char * argv[]) // Create the Command observer and register it with the optimizer. // - CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); + const CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); optimizer->AddObserver(itk::IterationEvent(), observer); @@ -244,12 +244,12 @@ main(int argc, char * argv[]) ParametersType finalParameters = registration->GetLastTransformParameters(); - double TranslationAlongX = finalParameters[0]; - double TranslationAlongY = finalParameters[1]; + const double TranslationAlongX = finalParameters[0]; + const double TranslationAlongY = finalParameters[1]; - unsigned int numberOfIterations = optimizer->GetCurrentIteration(); + const unsigned int numberOfIterations = optimizer->GetCurrentIteration(); - double bestValue = optimizer->GetValue(); + const double bestValue = optimizer->GetValue(); // Print out results @@ -277,17 +277,17 @@ main(int argc, char * argv[]) using ResampleFilterType = itk::ResampleImageFilter; - TransformType::Pointer finalTransform = TransformType::New(); + const TransformType::Pointer finalTransform = TransformType::New(); finalTransform->SetParameters(finalParameters); finalTransform->SetFixedParameters(transform->GetFixedParameters()); - ResampleFilterType::Pointer resample = ResampleFilterType::New(); + const ResampleFilterType::Pointer resample = ResampleFilterType::New(); resample->SetTransform(finalTransform); resample->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resample->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resample->SetOutputOrigin(fixedImage->GetOrigin()); @@ -301,8 +301,8 @@ main(int argc, char * argv[]) using CastFilterType = itk::CastImageFilter; using WriterType = itk::ImageFileWriter; - WriterType::Pointer writer = WriterType::New(); - CastFilterType::Pointer caster = CastFilterType::New(); + const WriterType::Pointer writer = WriterType::New(); + const CastFilterType::Pointer caster = CastFilterType::New(); writer->SetFileName(argv[3]); diff --git a/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration13.cxx b/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration13.cxx index 9379ae9b10d..c54e262a94c 100644 --- a/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration13.cxx +++ b/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration13.cxx @@ -112,17 +112,17 @@ main(int argc, char * argv[]) using MetricType = itk::MattesMutualInformationImageToImageMetric; - TransformType::Pointer transform = TransformType::New(); - OptimizerType::Pointer optimizer = OptimizerType::New(); - InterpolatorType::Pointer interpolator = InterpolatorType::New(); - RegistrationType::Pointer registration = RegistrationType::New(); + const TransformType::Pointer transform = TransformType::New(); + const OptimizerType::Pointer optimizer = OptimizerType::New(); + const InterpolatorType::Pointer interpolator = InterpolatorType::New(); + const RegistrationType::Pointer registration = RegistrationType::New(); registration->SetOptimizer(optimizer); registration->SetTransform(transform); registration->SetInterpolator(interpolator); - MetricType::Pointer metric = MetricType::New(); + const MetricType::Pointer metric = MetricType::New(); registration->SetMetric(metric); @@ -156,8 +156,8 @@ main(int argc, char * argv[]) using FixedImageReaderType = itk::ImageFileReader; using MovingImageReaderType = itk::ImageFileReader; - FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); - MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); + const FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); + const MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); fixedImageReader->SetFileName(argv[1]); movingImageReader->SetFileName(argv[2]); @@ -184,7 +184,7 @@ main(int argc, char * argv[]) // Here we adopt the first approach. The \code{GeometryOn()} method // toggles between the approaches. using TransformInitializerType = itk::CenteredTransformInitializer; - TransformInitializerType::Pointer initializer = TransformInitializerType::New(); + const TransformInitializerType::Pointer initializer = TransformInitializerType::New(); initializer->SetTransform(transform); initializer->SetFixedImage(fixedImageReader->GetOutput()); @@ -222,7 +222,7 @@ main(int argc, char * argv[]) // Create the Command observer and register it with the optimizer. // - CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); + const CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); optimizer->AddObserver(itk::IterationEvent(), observer); @@ -249,9 +249,9 @@ main(int argc, char * argv[]) const double finalTranslationX = finalParameters[3]; const double finalTranslationY = finalParameters[4]; - unsigned int numberOfIterations = optimizer->GetCurrentIteration(); + const unsigned int numberOfIterations = optimizer->GetCurrentIteration(); - double bestValue = optimizer->GetValue(); + const double bestValue = optimizer->GetValue(); // Print out results // @@ -271,17 +271,17 @@ main(int argc, char * argv[]) using ResampleFilterType = itk::ResampleImageFilter; - TransformType::Pointer finalTransform = TransformType::New(); + const TransformType::Pointer finalTransform = TransformType::New(); finalTransform->SetParameters(finalParameters); finalTransform->SetFixedParameters(transform->GetFixedParameters()); - ResampleFilterType::Pointer resample = ResampleFilterType::New(); + const ResampleFilterType::Pointer resample = ResampleFilterType::New(); resample->SetTransform(finalTransform); resample->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resample->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resample->SetOutputOrigin(fixedImage->GetOrigin()); @@ -294,7 +294,7 @@ main(int argc, char * argv[]) using WriterType = itk::ImageFileWriter; - WriterType::Pointer writer = WriterType::New(); + const WriterType::Pointer writer = WriterType::New(); writer->SetFileName(argv[3]); diff --git a/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration14.cxx b/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration14.cxx index a9e8cee167f..8459708bf2e 100644 --- a/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration14.cxx +++ b/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration14.cxx @@ -71,7 +71,7 @@ class CommandIterationUpdate : public itk::Command { return; } - double currentValue = optimizer->GetValue(); + const double currentValue = optimizer->GetValue(); // Only print out when the Metric value changes if (itk::Math::abs(m_LastMetricValue - currentValue) > 1e-7) { @@ -119,17 +119,17 @@ main(int argc, char * argv[]) using MetricType = itk::NormalizedMutualInformationHistogramImageToImageMetric; - TransformType::Pointer transform = TransformType::New(); - OptimizerType::Pointer optimizer = OptimizerType::New(); - InterpolatorType::Pointer interpolator = InterpolatorType::New(); - RegistrationType::Pointer registration = RegistrationType::New(); + const TransformType::Pointer transform = TransformType::New(); + const OptimizerType::Pointer optimizer = OptimizerType::New(); + const InterpolatorType::Pointer interpolator = InterpolatorType::New(); + const RegistrationType::Pointer registration = RegistrationType::New(); registration->SetOptimizer(optimizer); registration->SetTransform(transform); registration->SetInterpolator(interpolator); - MetricType::Pointer metric = MetricType::New(); + const MetricType::Pointer metric = MetricType::New(); registration->SetMetric(metric); @@ -159,8 +159,8 @@ main(int argc, char * argv[]) using FixedImageReaderType = itk::ImageFileReader; using MovingImageReaderType = itk::ImageFileReader; - FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); - MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); + const FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); + const MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); fixedImageReader->SetFileName(argv[1]); movingImageReader->SetFileName(argv[2]); @@ -170,11 +170,11 @@ main(int argc, char * argv[]) fixedImageReader->Update(); movingImageReader->Update(); - FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::ConstPointer fixedImage = fixedImageReader->GetOutput(); registration->SetFixedImageRegion(fixedImage->GetBufferedRegion()); using TransformInitializerType = itk::CenteredTransformInitializer; - TransformInitializerType::Pointer initializer = TransformInitializerType::New(); + const TransformInitializerType::Pointer initializer = TransformInitializerType::New(); initializer->SetTransform(transform); initializer->SetFixedImage(fixedImageReader->GetOutput()); initializer->SetMovingImage(movingImageReader->GetOutput()); @@ -196,7 +196,7 @@ main(int argc, char * argv[]) transform->SetTranslation(initialTranslation); using ParametersType = RegistrationType::ParametersType; - ParametersType initialParameters = transform->GetParameters(); + const ParametersType initialParameters = transform->GetParameters(); registration->SetInitialTransformParameters(initialParameters); std::cout << "Initial transform parameters = "; std::cout << initialParameters << std::endl; @@ -204,9 +204,9 @@ main(int argc, char * argv[]) using OptimizerScalesType = OptimizerType::ScalesType; OptimizerScalesType optimizerScales(transform->GetNumberOfParameters()); - FixedImageType::RegionType region = fixedImage->GetLargestPossibleRegion(); - FixedImageType::SizeType size = region.GetSize(); - FixedImageType::SpacingType spacing = fixedImage->GetSpacing(); + const FixedImageType::RegionType region = fixedImage->GetLargestPossibleRegion(); + FixedImageType::SizeType size = region.GetSize(); + FixedImageType::SpacingType spacing = fixedImage->GetSpacing(); optimizerScales[0] = 1.0 / 0.1; // make angle move slowly optimizerScales[1] = 10000.0; // prevent the center from moving @@ -217,7 +217,7 @@ main(int argc, char * argv[]) optimizer->SetScales(optimizerScales); using GeneratorType = itk::Statistics::NormalVariateGenerator; - GeneratorType::Pointer generator = GeneratorType::New(); + const GeneratorType::Pointer generator = GeneratorType::New(); generator->Initialize(12345); optimizer->MaximizeOn(); optimizer->SetNormalVariateGenerator(generator); @@ -240,7 +240,7 @@ main(int argc, char * argv[]) // Create the Command observer and register it with the optimizer. // - CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); + const CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); optimizer->AddObserver(itk::IterationEvent(), observer); try { @@ -279,11 +279,11 @@ main(int argc, char * argv[]) std::cout << " Metric value = " << bestValue << std::endl; using ResampleFilterType = itk::ResampleImageFilter; - TransformType::Pointer finalTransform = TransformType::New(); + const TransformType::Pointer finalTransform = TransformType::New(); finalTransform->SetParameters(finalParameters); finalTransform->SetFixedParameters(transform->GetFixedParameters()); - ResampleFilterType::Pointer resample = ResampleFilterType::New(); + const ResampleFilterType::Pointer resample = ResampleFilterType::New(); resample->SetTransform(finalTransform); resample->SetInput(movingImageReader->GetOutput()); resample->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); @@ -295,7 +295,7 @@ main(int argc, char * argv[]) using OutputImageType = itk::Image; using WriterType = itk::ImageFileWriter; - WriterType::Pointer writer = WriterType::New(); + const WriterType::Pointer writer = WriterType::New(); writer->SetFileName(argv[3]); writer->SetInput(resample->GetOutput()); writer->Update(); diff --git a/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration3.cxx b/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration3.cxx index 9e6f8d3b74e..adb32974572 100644 --- a/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration3.cxx +++ b/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration3.cxx @@ -249,24 +249,24 @@ main(int argc, char * argv[]) using MetricType = itk::MeanSquaresImageToImageMetric; - TransformType::Pointer transform = TransformType::New(); - OptimizerType::Pointer optimizer = OptimizerType::New(); - InterpolatorType::Pointer interpolator = InterpolatorType::New(); - RegistrationType::Pointer registration = RegistrationType::New(); + const TransformType::Pointer transform = TransformType::New(); + const OptimizerType::Pointer optimizer = OptimizerType::New(); + const InterpolatorType::Pointer interpolator = InterpolatorType::New(); + const RegistrationType::Pointer registration = RegistrationType::New(); registration->SetOptimizer(optimizer); registration->SetTransform(transform); registration->SetInterpolator(interpolator); - MetricType::Pointer metric = MetricType::New(); + const MetricType::Pointer metric = MetricType::New(); registration->SetMetric(metric); using FixedImageReaderType = itk::ImageFileReader; using MovingImageReaderType = itk::ImageFileReader; - FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); - MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); + const FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); + const MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); fixedImageReader->SetFileName(argv[1]); movingImageReader->SetFileName(argv[2]); @@ -299,7 +299,7 @@ main(int argc, char * argv[]) // method and assigned to a SmartPointer. // - CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); + const CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); // @@ -411,17 +411,17 @@ main(int argc, char * argv[]) // using ResampleFilterType = itk::ResampleImageFilter; - TransformType::Pointer finalTransform = TransformType::New(); + const TransformType::Pointer finalTransform = TransformType::New(); finalTransform->SetParameters(finalParameters); finalTransform->SetFixedParameters(transform->GetFixedParameters()); - ResampleFilterType::Pointer resample = ResampleFilterType::New(); + const ResampleFilterType::Pointer resample = ResampleFilterType::New(); resample->SetTransform(finalTransform); resample->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resample->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resample->SetOutputOrigin(fixedImage->GetOrigin()); @@ -441,8 +441,8 @@ main(int argc, char * argv[]) using WriterType = itk::ImageFileWriter; - WriterType::Pointer writer = WriterType::New(); - CastFilterType::Pointer caster = CastFilterType::New(); + const WriterType::Pointer writer = WriterType::New(); + const CastFilterType::Pointer caster = CastFilterType::New(); writer->SetFileName(argv[3]); diff --git a/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration4.cxx b/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration4.cxx index 093071272f1..a882d87f287 100644 --- a/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration4.cxx +++ b/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration4.cxx @@ -140,10 +140,10 @@ main(int argc, char * argv[]) using MetricType = itk::MattesMutualInformationImageToImageMetric; - TransformType::Pointer transform = TransformType::New(); - OptimizerType::Pointer optimizer = OptimizerType::New(); - InterpolatorType::Pointer interpolator = InterpolatorType::New(); - RegistrationType::Pointer registration = RegistrationType::New(); + const TransformType::Pointer transform = TransformType::New(); + const OptimizerType::Pointer optimizer = OptimizerType::New(); + const InterpolatorType::Pointer interpolator = InterpolatorType::New(); + const RegistrationType::Pointer registration = RegistrationType::New(); registration->SetOptimizer(optimizer); registration->SetTransform(transform); @@ -155,7 +155,7 @@ main(int argc, char * argv[]) // connected to the registration object. // - MetricType::Pointer metric = MetricType::New(); + const MetricType::Pointer metric = MetricType::New(); registration->SetMetric(metric); @@ -218,8 +218,8 @@ main(int argc, char * argv[]) using FixedImageReaderType = itk::ImageFileReader; using MovingImageReaderType = itk::ImageFileReader; - FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); - MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); + const FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); + const MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); fixedImageReader->SetFileName(argv[1]); movingImageReader->SetFileName(argv[2]); @@ -273,7 +273,7 @@ main(int argc, char * argv[]) // Create the Command observer and register it with the optimizer. // - CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); + const CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); optimizer->AddObserver(itk::IterationEvent(), observer); @@ -292,14 +292,14 @@ main(int argc, char * argv[]) ParametersType finalParameters = registration->GetLastTransformParameters(); - double TranslationAlongX = finalParameters[0]; - double TranslationAlongY = finalParameters[1]; + const double TranslationAlongX = finalParameters[0]; + const double TranslationAlongY = finalParameters[1]; // For stability reasons it may be desirable to round up the values of translation // - unsigned int numberOfIterations = optimizer->GetCurrentIteration(); + const unsigned int numberOfIterations = optimizer->GetCurrentIteration(); - double bestValue = optimizer->GetValue(); + const double bestValue = optimizer->GetValue(); // Print out results @@ -329,17 +329,17 @@ main(int argc, char * argv[]) using ResampleFilterType = itk::ResampleImageFilter; - TransformType::Pointer finalTransform = TransformType::New(); + const TransformType::Pointer finalTransform = TransformType::New(); finalTransform->SetParameters(finalParameters); finalTransform->SetFixedParameters(transform->GetFixedParameters()); - ResampleFilterType::Pointer resample = ResampleFilterType::New(); + const ResampleFilterType::Pointer resample = ResampleFilterType::New(); resample->SetTransform(finalTransform); resample->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); PixelType defaultPixelValue = 100; @@ -363,8 +363,8 @@ main(int argc, char * argv[]) using WriterType = itk::ImageFileWriter; - WriterType::Pointer writer = WriterType::New(); - CastFilterType::Pointer caster = CastFilterType::New(); + const WriterType::Pointer writer = WriterType::New(); + const CastFilterType::Pointer caster = CastFilterType::New(); writer->SetFileName(argv[3]); @@ -397,7 +397,7 @@ main(int argc, char * argv[]) // using CheckerBoardFilterType = itk::CheckerBoardImageFilter; - CheckerBoardFilterType::Pointer checker = CheckerBoardFilterType::New(); + const CheckerBoardFilterType::Pointer checker = CheckerBoardFilterType::New(); checker->SetInput1(fixedImage); checker->SetInput2(resample->GetOutput()); @@ -408,7 +408,7 @@ main(int argc, char * argv[]) resample->SetDefaultPixelValue(0); // Before registration - TransformType::Pointer identityTransform = TransformType::New(); + const TransformType::Pointer identityTransform = TransformType::New(); identityTransform->SetIdentity(); resample->SetTransform(identityTransform); diff --git a/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration5.cxx b/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration5.cxx index acaacbf7948..ef6b7baf8b0 100644 --- a/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration5.cxx +++ b/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration5.cxx @@ -143,10 +143,10 @@ main(int argc, char * argv[]) using InterpolatorType = itk::LinearInterpolateImageFunction; using RegistrationType = itk::ImageRegistrationMethod; - MetricType::Pointer metric = MetricType::New(); - OptimizerType::Pointer optimizer = OptimizerType::New(); - InterpolatorType::Pointer interpolator = InterpolatorType::New(); - RegistrationType::Pointer registration = RegistrationType::New(); + const MetricType::Pointer metric = MetricType::New(); + const OptimizerType::Pointer optimizer = OptimizerType::New(); + const InterpolatorType::Pointer interpolator = InterpolatorType::New(); + const RegistrationType::Pointer registration = RegistrationType::New(); registration->SetMetric(metric); registration->SetOptimizer(optimizer); @@ -162,15 +162,15 @@ main(int argc, char * argv[]) // \index{itk::RegistrationMethod!SetTransform()} // - TransformType::Pointer transform = TransformType::New(); + const TransformType::Pointer transform = TransformType::New(); registration->SetTransform(transform); using FixedImageReaderType = itk::ImageFileReader; using MovingImageReaderType = itk::ImageFileReader; - FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); - MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); + const FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); + const MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); fixedImageReader->SetFileName(argv[1]); movingImageReader->SetFileName(argv[2]); @@ -206,7 +206,7 @@ main(int argc, char * argv[]) // the fixed image. // - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); const SpacingType fixedSpacing = fixedImage->GetSpacing(); const OriginType fixedOrigin = fixedImage->GetOrigin(); @@ -223,7 +223,7 @@ main(int argc, char * argv[]) // The center of the moving image is computed in a similar way. // - MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); + const MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); const SpacingType movingSpacing = movingImage->GetSpacing(); const OriginType movingOrigin = movingImage->GetOrigin(); @@ -315,7 +315,7 @@ main(int argc, char * argv[]) // Create the Command observer and register it with the optimizer. // - CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); + const CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); optimizer->AddObserver(itk::IterationEvent(), observer); try @@ -442,12 +442,12 @@ main(int argc, char * argv[]) using ResampleFilterType = itk::ResampleImageFilter; - TransformType::Pointer finalTransform = TransformType::New(); + const TransformType::Pointer finalTransform = TransformType::New(); finalTransform->SetParameters(finalParameters); finalTransform->SetFixedParameters(transform->GetFixedParameters()); - ResampleFilterType::Pointer resample = ResampleFilterType::New(); + const ResampleFilterType::Pointer resample = ResampleFilterType::New(); resample->SetTransform(finalTransform); resample->SetInput(movingImageReader->GetOutput()); @@ -460,7 +460,7 @@ main(int argc, char * argv[]) using WriterFixedType = itk::ImageFileWriter; - WriterFixedType::Pointer writer = WriterFixedType::New(); + const WriterFixedType::Pointer writer = WriterFixedType::New(); writer->SetFileName(argv[3]); @@ -481,7 +481,7 @@ main(int argc, char * argv[]) using DifferenceFilterType = itk::SubtractImageFilter; - DifferenceFilterType::Pointer difference = DifferenceFilterType::New(); + const DifferenceFilterType::Pointer difference = DifferenceFilterType::New(); using OutputPixelType = unsigned char; @@ -489,7 +489,7 @@ main(int argc, char * argv[]) using RescalerType = itk::RescaleIntensityImageFilter; - RescalerType::Pointer intensityRescaler = RescalerType::New(); + const RescalerType::Pointer intensityRescaler = RescalerType::New(); intensityRescaler->SetOutputMinimum(0); intensityRescaler->SetOutputMaximum(255); @@ -503,7 +503,7 @@ main(int argc, char * argv[]) using WriterType = itk::ImageFileWriter; - WriterType::Pointer writer2 = WriterType::New(); + const WriterType::Pointer writer2 = WriterType::New(); writer2->SetInput(intensityRescaler->GetOutput()); @@ -520,7 +520,7 @@ main(int argc, char * argv[]) // Compute the difference image between the // fixed and resampled moving image after registration. - TransformType::Pointer identityTransform = TransformType::New(); + const TransformType::Pointer identityTransform = TransformType::New(); identityTransform->SetIdentity(); resample->SetTransform(identityTransform); if (argc > 5) diff --git a/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration6.cxx b/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration6.cxx index a8c615982bb..18770fdbf38 100644 --- a/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration6.cxx +++ b/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration6.cxx @@ -165,10 +165,10 @@ main(int argc, char * argv[]) using InterpolatorType = itk::LinearInterpolateImageFunction; using RegistrationType = itk::ImageRegistrationMethod; - MetricType::Pointer metric = MetricType::New(); - OptimizerType::Pointer optimizer = OptimizerType::New(); - InterpolatorType::Pointer interpolator = InterpolatorType::New(); - RegistrationType::Pointer registration = RegistrationType::New(); + const MetricType::Pointer metric = MetricType::New(); + const OptimizerType::Pointer optimizer = OptimizerType::New(); + const InterpolatorType::Pointer interpolator = InterpolatorType::New(); + const RegistrationType::Pointer registration = RegistrationType::New(); registration->SetMetric(metric); @@ -187,13 +187,13 @@ main(int argc, char * argv[]) // \index{itk::RegistrationMethod!SetTransform()} // - TransformType::Pointer transform = TransformType::New(); + const TransformType::Pointer transform = TransformType::New(); registration->SetTransform(transform); using FixedImageReaderType = itk::ImageFileReader; using MovingImageReaderType = itk::ImageFileReader; - FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); - MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); + const FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); + const MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); fixedImageReader->SetFileName(argv[1]); movingImageReader->SetFileName(argv[2]); @@ -223,7 +223,7 @@ main(int argc, char * argv[]) using TransformInitializerType = itk::CenteredTransformInitializer; - TransformInitializerType::Pointer initializer = TransformInitializerType::New(); + const TransformInitializerType::Pointer initializer = TransformInitializerType::New(); // // The initializer is now connected to the transform and to the fixed and @@ -291,7 +291,7 @@ main(int argc, char * argv[]) // Create the Command observer and register it with the optimizer. // - CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); + const CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); optimizer->AddObserver(itk::IterationEvent(), observer); try @@ -375,8 +375,8 @@ main(int argc, char * argv[]) transform->SetParameters(finalParameters); - TransformType::MatrixType matrix = transform->GetMatrix(); - TransformType::OffsetType offset = transform->GetOffset(); + const TransformType::MatrixType matrix = transform->GetMatrix(); + const TransformType::OffsetType offset = transform->GetOffset(); std::cout << "Matrix = " << std::endl << matrix << std::endl; std::cout << "Offset = " << std::endl << offset << std::endl; @@ -496,16 +496,16 @@ main(int argc, char * argv[]) using ResampleFilterType = itk::ResampleImageFilter; - TransformType::Pointer finalTransform = TransformType::New(); + const TransformType::Pointer finalTransform = TransformType::New(); finalTransform->SetParameters(finalParameters); finalTransform->SetFixedParameters(transform->GetFixedParameters()); - ResampleFilterType::Pointer resample = ResampleFilterType::New(); + const ResampleFilterType::Pointer resample = ResampleFilterType::New(); resample->SetTransform(finalTransform); resample->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resample->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resample->SetOutputOrigin(fixedImage->GetOrigin()); @@ -522,8 +522,8 @@ main(int argc, char * argv[]) using WriterType = itk::ImageFileWriter; - WriterType::Pointer writer = WriterType::New(); - CastFilterType::Pointer caster = CastFilterType::New(); + const WriterType::Pointer writer = WriterType::New(); + const CastFilterType::Pointer caster = CastFilterType::New(); writer->SetFileName(argv[3]); @@ -540,7 +540,7 @@ main(int argc, char * argv[]) using DifferenceFilterType = itk::SubtractImageFilter; - DifferenceFilterType::Pointer difference = DifferenceFilterType::New(); + const DifferenceFilterType::Pointer difference = DifferenceFilterType::New(); using OutputPixelType = unsigned char; @@ -548,7 +548,7 @@ main(int argc, char * argv[]) using RescalerType = itk::RescaleIntensityImageFilter; - RescalerType::Pointer intensityRescaler = RescalerType::New(); + const RescalerType::Pointer intensityRescaler = RescalerType::New(); intensityRescaler->SetOutputMinimum(0); intensityRescaler->SetOutputMaximum(255); @@ -562,7 +562,7 @@ main(int argc, char * argv[]) using WriterType = itk::ImageFileWriter; - WriterType::Pointer writer2 = WriterType::New(); + const WriterType::Pointer writer2 = WriterType::New(); writer2->SetInput(intensityRescaler->GetOutput()); @@ -579,7 +579,7 @@ main(int argc, char * argv[]) // Compute the difference image between the // fixed and resampled moving image after registration. - TransformType::Pointer identityTransform = TransformType::New(); + const TransformType::Pointer identityTransform = TransformType::New(); identityTransform->SetIdentity(); resample->SetTransform(identityTransform); if (argc > 4) diff --git a/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration7.cxx b/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration7.cxx index 513799baeac..efdb7a2517c 100644 --- a/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration7.cxx +++ b/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration7.cxx @@ -156,10 +156,10 @@ main(int argc, char * argv[]) using InterpolatorType = itk::LinearInterpolateImageFunction; using RegistrationType = itk::ImageRegistrationMethod; - MetricType::Pointer metric = MetricType::New(); - OptimizerType::Pointer optimizer = OptimizerType::New(); - InterpolatorType::Pointer interpolator = InterpolatorType::New(); - RegistrationType::Pointer registration = RegistrationType::New(); + const MetricType::Pointer metric = MetricType::New(); + const OptimizerType::Pointer optimizer = OptimizerType::New(); + const InterpolatorType::Pointer interpolator = InterpolatorType::New(); + const RegistrationType::Pointer registration = RegistrationType::New(); registration->SetMetric(metric); registration->SetOptimizer(optimizer); @@ -175,15 +175,15 @@ main(int argc, char * argv[]) // \index{itk::RegistrationMethod!SetTransform()} // - TransformType::Pointer transform = TransformType::New(); + const TransformType::Pointer transform = TransformType::New(); registration->SetTransform(transform); using FixedImageReaderType = itk::ImageFileReader; using MovingImageReaderType = itk::ImageFileReader; - FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); - MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); + const FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); + const MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); fixedImageReader->SetFileName(argv[1]); movingImageReader->SetFileName(argv[2]); @@ -205,7 +205,7 @@ main(int argc, char * argv[]) using TransformInitializerType = itk::CenteredTransformInitializer; - TransformInitializerType::Pointer initializer = TransformInitializerType::New(); + const TransformInitializerType::Pointer initializer = TransformInitializerType::New(); initializer->SetTransform(transform); @@ -301,7 +301,7 @@ main(int argc, char * argv[]) // Create the Command observer and register it with the optimizer. // - CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); + const CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); optimizer->AddObserver(itk::IterationEvent(), observer); @@ -434,17 +434,17 @@ main(int argc, char * argv[]) using ResampleFilterType = itk::ResampleImageFilter; - TransformType::Pointer finalTransform = TransformType::New(); + const TransformType::Pointer finalTransform = TransformType::New(); finalTransform->SetParameters(finalParameters); finalTransform->SetFixedParameters(transform->GetFixedParameters()); - ResampleFilterType::Pointer resampler = ResampleFilterType::New(); + const ResampleFilterType::Pointer resampler = ResampleFilterType::New(); resampler->SetTransform(finalTransform); resampler->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resampler->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resampler->SetOutputOrigin(fixedImage->GetOrigin()); @@ -461,8 +461,8 @@ main(int argc, char * argv[]) using WriterType = itk::ImageFileWriter; - WriterType::Pointer writer = WriterType::New(); - CastFilterType::Pointer caster = CastFilterType::New(); + const WriterType::Pointer writer = WriterType::New(); + const CastFilterType::Pointer caster = CastFilterType::New(); writer->SetFileName(argv[3]); @@ -475,12 +475,12 @@ main(int argc, char * argv[]) using DifferenceFilterType = itk::SubtractImageFilter; - DifferenceFilterType::Pointer difference = DifferenceFilterType::New(); + const DifferenceFilterType::Pointer difference = DifferenceFilterType::New(); using RescalerType = itk::RescaleIntensityImageFilter; - RescalerType::Pointer intensityRescaler = RescalerType::New(); + const RescalerType::Pointer intensityRescaler = RescalerType::New(); intensityRescaler->SetInput(difference->GetOutput()); intensityRescaler->SetOutputMinimum(0); @@ -491,7 +491,7 @@ main(int argc, char * argv[]) resampler->SetDefaultPixelValue(1); - WriterType::Pointer writer2 = WriterType::New(); + const WriterType::Pointer writer2 = WriterType::New(); writer2->SetInput(intensityRescaler->GetOutput()); @@ -505,7 +505,7 @@ main(int argc, char * argv[]) using IdentityTransformType = itk::IdentityTransform; - IdentityTransformType::Pointer identity = IdentityTransformType::New(); + const IdentityTransformType::Pointer identity = IdentityTransformType::New(); // Compute the difference image between the // fixed and moving image before registration. diff --git a/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration8.cxx b/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration8.cxx index 5848b1d8356..4c9c31a87c9 100644 --- a/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration8.cxx +++ b/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration8.cxx @@ -156,10 +156,10 @@ main(int argc, char * argv[]) using InterpolatorType = itk::LinearInterpolateImageFunction; using RegistrationType = itk::ImageRegistrationMethod; - MetricType::Pointer metric = MetricType::New(); - OptimizerType::Pointer optimizer = OptimizerType::New(); - InterpolatorType::Pointer interpolator = InterpolatorType::New(); - RegistrationType::Pointer registration = RegistrationType::New(); + const MetricType::Pointer metric = MetricType::New(); + const OptimizerType::Pointer optimizer = OptimizerType::New(); + const InterpolatorType::Pointer interpolator = InterpolatorType::New(); + const RegistrationType::Pointer registration = RegistrationType::New(); registration->SetMetric(metric); registration->SetOptimizer(optimizer); @@ -174,12 +174,12 @@ main(int argc, char * argv[]) // \index{itk::Versor\-Rigid3D\-Transform!Pointer} // \index{itk::Registration\-Method!SetTransform()} // - TransformType::Pointer transform = TransformType::New(); + const TransformType::Pointer transform = TransformType::New(); registration->SetTransform(transform); using FixedImageReaderType = itk::ImageFileReader; using MovingImageReaderType = itk::ImageFileReader; - FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); - MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); + const FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); + const MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); fixedImageReader->SetFileName(argv[1]); movingImageReader->SetFileName(argv[2]); registration->SetFixedImage(fixedImageReader->GetOutput()); @@ -202,7 +202,7 @@ main(int argc, char * argv[]) // \index{itk::Centered\-Transform\-Initializer!SmartPointer} // using TransformInitializerType = itk::CenteredTransformInitializer; - TransformInitializerType::Pointer initializer = TransformInitializerType::New(); + const TransformInitializerType::Pointer initializer = TransformInitializerType::New(); // // The initializer is now connected to the transform and to the fixed and @@ -271,7 +271,7 @@ main(int argc, char * argv[]) // Create the Command observer and register it with the optimizer. // - CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); + const CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); optimizer->AddObserver(itk::IterationEvent(), observer); try @@ -356,8 +356,8 @@ main(int argc, char * argv[]) // rotation matrix and offset resulting form the $6$ parameters. // transform->SetParameters(finalParameters); - TransformType::MatrixType matrix = transform->GetMatrix(); - TransformType::OffsetType offset = transform->GetOffset(); + const TransformType::MatrixType matrix = transform->GetMatrix(); + const TransformType::OffsetType offset = transform->GetOffset(); std::cout << "Matrix = " << std::endl << matrix << std::endl; std::cout << "Offset = " << std::endl << offset << std::endl; @@ -455,14 +455,14 @@ main(int argc, char * argv[]) // using ResampleFilterType = itk::ResampleImageFilter; - TransformType::Pointer finalTransform = TransformType::New(); + const TransformType::Pointer finalTransform = TransformType::New(); finalTransform->SetCenter(transform->GetCenter()); finalTransform->SetParameters(finalParameters); finalTransform->SetFixedParameters(transform->GetFixedParameters()); - ResampleFilterType::Pointer resampler = ResampleFilterType::New(); + const ResampleFilterType::Pointer resampler = ResampleFilterType::New(); resampler->SetTransform(finalTransform); resampler->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resampler->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resampler->SetOutputOrigin(fixedImage->GetOrigin()); resampler->SetOutputSpacing(fixedImage->GetSpacing()); @@ -474,8 +474,8 @@ main(int argc, char * argv[]) using CastFilterType = itk::CastImageFilter; using WriterType = itk::ImageFileWriter; - WriterType::Pointer writer = WriterType::New(); - CastFilterType::Pointer caster = CastFilterType::New(); + const WriterType::Pointer writer = WriterType::New(); + const CastFilterType::Pointer caster = CastFilterType::New(); writer->SetFileName(argv[3]); @@ -484,17 +484,17 @@ main(int argc, char * argv[]) writer->Update(); using DifferenceFilterType = itk::SubtractImageFilter; - DifferenceFilterType::Pointer difference = DifferenceFilterType::New(); + const DifferenceFilterType::Pointer difference = DifferenceFilterType::New(); using RescalerType = itk::RescaleIntensityImageFilter; - RescalerType::Pointer intensityRescaler = RescalerType::New(); + const RescalerType::Pointer intensityRescaler = RescalerType::New(); intensityRescaler->SetInput(difference->GetOutput()); intensityRescaler->SetOutputMinimum(0); intensityRescaler->SetOutputMaximum(255); difference->SetInput1(fixedImageReader->GetOutput()); difference->SetInput2(resampler->GetOutput()); resampler->SetDefaultPixelValue(1); - WriterType::Pointer writer2 = WriterType::New(); + const WriterType::Pointer writer2 = WriterType::New(); writer2->SetInput(intensityRescaler->GetOutput()); // Compute the difference image between the @@ -506,7 +506,7 @@ main(int argc, char * argv[]) } using IdentityTransformType = itk::IdentityTransform; - IdentityTransformType::Pointer identity = IdentityTransformType::New(); + const IdentityTransformType::Pointer identity = IdentityTransformType::New(); // Compute the difference image between the // fixed and moving image before registration. if (argc > 4) @@ -523,13 +523,13 @@ main(int argc, char * argv[]) // using OutputSliceType = itk::Image; using ExtractFilterType = itk::ExtractImageFilter; - ExtractFilterType::Pointer extractor = ExtractFilterType::New(); + const ExtractFilterType::Pointer extractor = ExtractFilterType::New(); extractor->SetDirectionCollapseToSubmatrix(); extractor->InPlaceOn(); - FixedImageType::RegionType inputRegion = fixedImage->GetLargestPossibleRegion(); - FixedImageType::SizeType size = inputRegion.GetSize(); - FixedImageType::IndexType start = inputRegion.GetIndex(); + const FixedImageType::RegionType inputRegion = fixedImage->GetLargestPossibleRegion(); + FixedImageType::SizeType size = inputRegion.GetSize(); + FixedImageType::IndexType start = inputRegion.GetIndex(); // Select one slice as output size[2] = 0; start[2] = 90; @@ -538,7 +538,7 @@ main(int argc, char * argv[]) desiredRegion.SetIndex(start); extractor->SetExtractionRegion(desiredRegion); using SliceWriterType = itk::ImageFileWriter; - SliceWriterType::Pointer sliceWriter = SliceWriterType::New(); + const SliceWriterType::Pointer sliceWriter = SliceWriterType::New(); sliceWriter->SetInput(extractor->GetOutput()); if (argc > 6) { diff --git a/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration9.cxx b/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration9.cxx index ca6d3774511..7042b77e3ea 100644 --- a/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration9.cxx +++ b/Modules/Registration/Common/test/RegistrationITKv3/ImageRegistration9.cxx @@ -107,7 +107,7 @@ class CommandIterationUpdate : public itk::Command vnl_svd svd(p); vnl_matrix r(2, 2); r = svd.U() * vnl_transpose(svd.V()); - double angle = std::asin(r[1][0]); + const double angle = std::asin(r[1][0]); std::cout << " AffineAngle: " << angle * 180.0 / itk::Math::pi << std::endl; } }; @@ -157,10 +157,10 @@ main(int argc, char * argv[]) using InterpolatorType = itk::LinearInterpolateImageFunction; using RegistrationType = itk::ImageRegistrationMethod; - MetricType::Pointer metric = MetricType::New(); - OptimizerType::Pointer optimizer = OptimizerType::New(); - InterpolatorType::Pointer interpolator = InterpolatorType::New(); - RegistrationType::Pointer registration = RegistrationType::New(); + const MetricType::Pointer metric = MetricType::New(); + const OptimizerType::Pointer optimizer = OptimizerType::New(); + const InterpolatorType::Pointer interpolator = InterpolatorType::New(); + const RegistrationType::Pointer registration = RegistrationType::New(); registration->SetMetric(metric); registration->SetOptimizer(optimizer); @@ -176,14 +176,14 @@ main(int argc, char * argv[]) // \index{itk::RegistrationMethod!SetTransform()} // - TransformType::Pointer transform = TransformType::New(); + const TransformType::Pointer transform = TransformType::New(); registration->SetTransform(transform); using FixedImageReaderType = itk::ImageFileReader; using MovingImageReaderType = itk::ImageFileReader; - FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); - MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); + const FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); + const MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); fixedImageReader->SetFileName(argv[1]); movingImageReader->SetFileName(argv[2]); @@ -204,7 +204,7 @@ main(int argc, char * argv[]) // using TransformInitializerType = itk::CenteredTransformInitializer; - TransformInitializerType::Pointer initializer = TransformInitializerType::New(); + const TransformInitializerType::Pointer initializer = TransformInitializerType::New(); initializer->SetTransform(transform); initializer->SetFixedImage(fixedImageReader->GetOutput()); initializer->SetMovingImage(movingImageReader->GetOutput()); @@ -292,7 +292,7 @@ main(int argc, char * argv[]) // Create the Command observer and register it with the optimizer. // - CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); + const CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); optimizer->AddObserver(itk::IterationEvent(), observer); @@ -362,7 +362,7 @@ main(int argc, char * argv[]) vnl_svd svd(p); vnl_matrix r(2, 2); r = svd.U() * vnl_transpose(svd.V()); - double angle = std::asin(r[1][0]); + const double angle = std::asin(r[1][0]); const double angleInDegrees = angle * 180.0 / itk::Math::pi; @@ -464,17 +464,17 @@ main(int argc, char * argv[]) // difference images, so that they look better! using ResampleFilterType = itk::ResampleImageFilter; - TransformType::Pointer finalTransform = TransformType::New(); + const TransformType::Pointer finalTransform = TransformType::New(); finalTransform->SetParameters(finalParameters); finalTransform->SetFixedParameters(transform->GetFixedParameters()); - ResampleFilterType::Pointer resampler = ResampleFilterType::New(); + const ResampleFilterType::Pointer resampler = ResampleFilterType::New(); resampler->SetTransform(finalTransform); resampler->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resampler->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); resampler->SetOutputOrigin(fixedImage->GetOrigin()); @@ -491,8 +491,8 @@ main(int argc, char * argv[]) using WriterType = itk::ImageFileWriter; - WriterType::Pointer writer = WriterType::New(); - CastFilterType::Pointer caster = CastFilterType::New(); + const WriterType::Pointer writer = WriterType::New(); + const CastFilterType::Pointer caster = CastFilterType::New(); writer->SetFileName(argv[3]); @@ -505,16 +505,16 @@ main(int argc, char * argv[]) using DifferenceFilterType = itk::SubtractImageFilter; - DifferenceFilterType::Pointer difference = DifferenceFilterType::New(); + const DifferenceFilterType::Pointer difference = DifferenceFilterType::New(); difference->SetInput1(fixedImageReader->GetOutput()); difference->SetInput2(resampler->GetOutput()); - WriterType::Pointer writer2 = WriterType::New(); + const WriterType::Pointer writer2 = WriterType::New(); using RescalerType = itk::RescaleIntensityImageFilter; - RescalerType::Pointer intensityRescaler = RescalerType::New(); + const RescalerType::Pointer intensityRescaler = RescalerType::New(); intensityRescaler->SetInput(difference->GetOutput()); intensityRescaler->SetOutputMinimum(0); @@ -533,7 +533,7 @@ main(int argc, char * argv[]) using IdentityTransformType = itk::IdentityTransform; - IdentityTransformType::Pointer identity = IdentityTransformType::New(); + const IdentityTransformType::Pointer identity = IdentityTransformType::New(); // Compute the difference image between the // fixed and moving image before registration. diff --git a/Modules/Registration/Common/test/RegistrationITKv3/MeanSquaresImageMetric1.cxx b/Modules/Registration/Common/test/RegistrationITKv3/MeanSquaresImageMetric1.cxx index e06c68a8f07..89ecdd3dc68 100644 --- a/Modules/Registration/Common/test/RegistrationITKv3/MeanSquaresImageMetric1.cxx +++ b/Modules/Registration/Common/test/RegistrationITKv3/MeanSquaresImageMetric1.cxx @@ -69,8 +69,8 @@ main(int argc, char * argv[]) using ReaderType = itk::ImageFileReader; - ReaderType::Pointer fixedReader = ReaderType::New(); - ReaderType::Pointer movingReader = ReaderType::New(); + const ReaderType::Pointer fixedReader = ReaderType::New(); + const ReaderType::Pointer movingReader = ReaderType::New(); fixedReader->SetFileName(argv[1]); movingReader->SetFileName(argv[2]); @@ -94,7 +94,7 @@ main(int argc, char * argv[]) using MetricType = itk::MeanSquaresImageToImageMetric; - MetricType::Pointer metric = MetricType::New(); + const MetricType::Pointer metric = MetricType::New(); // @@ -104,18 +104,18 @@ main(int argc, char * argv[]) using TransformType = itk::TranslationTransform; - TransformType::Pointer transform = TransformType::New(); + const TransformType::Pointer transform = TransformType::New(); using InterpolatorType = itk::NearestNeighborInterpolateImageFunction; - InterpolatorType::Pointer interpolator = InterpolatorType::New(); + const InterpolatorType::Pointer interpolator = InterpolatorType::New(); transform->SetIdentity(); - ImageType::ConstPointer fixedImage = fixedReader->GetOutput(); - ImageType::ConstPointer movingImage = movingReader->GetOutput(); + const ImageType::ConstPointer fixedImage = fixedReader->GetOutput(); + const ImageType::ConstPointer movingImage = movingReader->GetOutput(); // diff --git a/Modules/Registration/Common/test/RegistrationITKv3/MultiResImageRegistration1.cxx b/Modules/Registration/Common/test/RegistrationITKv3/MultiResImageRegistration1.cxx index 0f4a6f014e1..7f612dfb135 100644 --- a/Modules/Registration/Common/test/RegistrationITKv3/MultiResImageRegistration1.cxx +++ b/Modules/Registration/Common/test/RegistrationITKv3/MultiResImageRegistration1.cxx @@ -314,14 +314,14 @@ main(int argc, const char * argv[]) // All the components are instantiated using their \code{New()} method // and connected to the registration object as in previous example. // - TransformType::Pointer transform = TransformType::New(); - OptimizerType::Pointer optimizer = OptimizerType::New(); - InterpolatorType::Pointer interpolator = InterpolatorType::New(); - RegistrationType::Pointer registration = RegistrationType::New(); - MetricType::Pointer metric = MetricType::New(); + const TransformType::Pointer transform = TransformType::New(); + const OptimizerType::Pointer optimizer = OptimizerType::New(); + const InterpolatorType::Pointer interpolator = InterpolatorType::New(); + const RegistrationType::Pointer registration = RegistrationType::New(); + const MetricType::Pointer metric = MetricType::New(); - FixedImagePyramidType::Pointer fixedImagePyramid = FixedImagePyramidType::New(); - MovingImagePyramidType::Pointer movingImagePyramid = MovingImagePyramidType::New(); + const FixedImagePyramidType::Pointer fixedImagePyramid = FixedImagePyramidType::New(); + const MovingImagePyramidType::Pointer movingImagePyramid = MovingImagePyramidType::New(); registration->SetOptimizer(optimizer); registration->SetTransform(transform); @@ -334,8 +334,8 @@ main(int argc, const char * argv[]) using FixedImageReaderType = itk::ImageFileReader; using MovingImageReaderType = itk::ImageFileReader; - FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); - MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); + const FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New(); + const MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New(); fixedImageReader->SetFileName(fixedImageFile); movingImageReader->SetFileName(movingImageFile); @@ -349,8 +349,8 @@ main(int argc, const char * argv[]) using FixedCastFilterType = itk::CastImageFilter; using MovingCastFilterType = itk::CastImageFilter; - FixedCastFilterType::Pointer fixedCaster = FixedCastFilterType::New(); - MovingCastFilterType::Pointer movingCaster = MovingCastFilterType::New(); + const FixedCastFilterType::Pointer fixedCaster = FixedCastFilterType::New(); + const MovingCastFilterType::Pointer movingCaster = MovingCastFilterType::New(); // // The output of the readers is connected as input to the cast @@ -420,7 +420,7 @@ main(int argc, const char * argv[]) // Create the Command observer and register it with the optimizer. // - CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); + const CommandIterationUpdate::Pointer observer = CommandIterationUpdate::New(); optimizer->AddObserver(itk::IterationEvent(), observer); @@ -431,7 +431,7 @@ main(int argc, const char * argv[]) // using CommandType = RegistrationInterfaceCommand; - CommandType::Pointer command = CommandType::New(); + const CommandType::Pointer command = CommandType::New(); registration->AddObserver(itk::IterationEvent(), command); // @@ -459,12 +459,12 @@ main(int argc, const char * argv[]) ParametersType finalParameters = registration->GetLastTransformParameters(); - double TranslationAlongX = finalParameters[0]; - double TranslationAlongY = finalParameters[1]; + const double TranslationAlongX = finalParameters[0]; + const double TranslationAlongY = finalParameters[1]; - unsigned int numberOfIterations = optimizer->GetCurrentIteration(); + const unsigned int numberOfIterations = optimizer->GetCurrentIteration(); - double bestValue = optimizer->GetValue(); + const double bestValue = optimizer->GetValue(); // Print out results @@ -520,17 +520,17 @@ main(int argc, const char * argv[]) using ResampleFilterType = itk::ResampleImageFilter; - TransformType::Pointer finalTransform = TransformType::New(); + const TransformType::Pointer finalTransform = TransformType::New(); finalTransform->SetParameters(finalParameters); finalTransform->SetFixedParameters(transform->GetFixedParameters()); - ResampleFilterType::Pointer resample = ResampleFilterType::New(); + const ResampleFilterType::Pointer resample = ResampleFilterType::New(); resample->SetTransform(finalTransform); resample->SetInput(movingImageReader->GetOutput()); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); resample->SetSize(fixedImage->GetLargestPossibleRegion().GetSize()); @@ -549,8 +549,8 @@ main(int argc, const char * argv[]) using WriterType = itk::ImageFileWriter; - WriterType::Pointer writer = WriterType::New(); - CastFilterType::Pointer caster = CastFilterType::New(); + const WriterType::Pointer writer = WriterType::New(); + const CastFilterType::Pointer caster = CastFilterType::New(); writer->SetFileName(outImagefile); @@ -565,7 +565,7 @@ main(int argc, const char * argv[]) // using CheckerBoardFilterType = itk::CheckerBoardImageFilter; - CheckerBoardFilterType::Pointer checker = CheckerBoardFilterType::New(); + const CheckerBoardFilterType::Pointer checker = CheckerBoardFilterType::New(); checker->SetInput1(fixedImage); checker->SetInput2(resample->GetOutput()); @@ -576,7 +576,7 @@ main(int argc, const char * argv[]) resample->SetDefaultPixelValue(0); // Before registration - TransformType::Pointer identityTransform = TransformType::New(); + const TransformType::Pointer identityTransform = TransformType::New(); identityTransform->SetIdentity(); resample->SetTransform(identityTransform); diff --git a/Modules/Registration/Common/test/itkBSplineExponentialDiffeomorphicTransformParametersAdaptorTest.cxx b/Modules/Registration/Common/test/itkBSplineExponentialDiffeomorphicTransformParametersAdaptorTest.cxx index 053ca094da6..edb2b541428 100644 --- a/Modules/Registration/Common/test/itkBSplineExponentialDiffeomorphicTransformParametersAdaptorTest.cxx +++ b/Modules/Registration/Common/test/itkBSplineExponentialDiffeomorphicTransformParametersAdaptorTest.cxx @@ -50,7 +50,7 @@ itkBSplineExponentialDiffeomorphicTransformParametersAdaptorTest(int, char *[]) displacementField->SetDirection(direction); displacementField->Allocate(); - TransformType::OutputVectorType zeroVector{}; + const TransformType::OutputVectorType zeroVector{}; displacementField->FillBuffer(zeroVector); @@ -68,11 +68,11 @@ itkBSplineExponentialDiffeomorphicTransformParametersAdaptorTest(int, char *[]) transform->SetConstantVelocityField(displacementField); transform->IntegrateVelocityField(); - auto point = itk::MakeFilled(50.0); - TransformType::OutputPointType outputPointBeforeAdapt = transform->TransformPoint(point); + auto point = itk::MakeFilled(50.0); + const TransformType::OutputPointType outputPointBeforeAdapt = transform->TransformPoint(point); - SpacingType spacingBefore = transform->GetConstantVelocityField()->GetSpacing(); - SizeType sizeBefore = transform->GetConstantVelocityField()->GetLargestPossibleRegion().GetSize(); + const SpacingType spacingBefore = transform->GetConstantVelocityField()->GetSpacing(); + const SizeType sizeBefore = transform->GetConstantVelocityField()->GetLargestPossibleRegion().GetSize(); /** * Instantiate the adaptor @@ -116,13 +116,13 @@ itkBSplineExponentialDiffeomorphicTransformParametersAdaptorTest(int, char *[]) } - SpacingType spacingAfter = transform->GetConstantVelocityField()->GetSpacing(); - SizeType sizeAfter = transform->GetConstantVelocityField()->GetLargestPossibleRegion().GetSize(); + const SpacingType spacingAfter = transform->GetConstantVelocityField()->GetSpacing(); + const SizeType sizeAfter = transform->GetConstantVelocityField()->GetLargestPossibleRegion().GetSize(); std::cout << "Spacing: " << spacingBefore << "(before), " << spacingAfter << "(after)." << std::endl; std::cout << "Size: " << sizeBefore << "(before), " << sizeAfter << "(after)." << std::endl; - TransformType::ParametersType fixedParameters = adaptor->GetRequiredFixedParameters(); + const TransformType::ParametersType fixedParameters = adaptor->GetRequiredFixedParameters(); std::cout << "Fixed parameters: " << fixedParameters << std::endl; adaptor->SetRequiredFixedParameters(fixedParameters); @@ -158,7 +158,7 @@ itkBSplineExponentialDiffeomorphicTransformParametersAdaptorTest(int, char *[]) return EXIT_FAILURE; } - TransformType::OutputPointType outputPointAfterAdapt = transform->TransformPoint(point); + const TransformType::OutputPointType outputPointAfterAdapt = transform->TransformPoint(point); std::cout << point << " to (before) " << outputPointBeforeAdapt << std::endl; std::cout << point << " to (after) " << outputPointAfterAdapt << std::endl; diff --git a/Modules/Registration/Common/test/itkBSplineSmoothingOnUpdateDisplacementFieldTransformParametersAdaptorTest.cxx b/Modules/Registration/Common/test/itkBSplineSmoothingOnUpdateDisplacementFieldTransformParametersAdaptorTest.cxx index 00a19e765ba..414dd483fbd 100644 --- a/Modules/Registration/Common/test/itkBSplineSmoothingOnUpdateDisplacementFieldTransformParametersAdaptorTest.cxx +++ b/Modules/Registration/Common/test/itkBSplineSmoothingOnUpdateDisplacementFieldTransformParametersAdaptorTest.cxx @@ -51,7 +51,7 @@ itkBSplineSmoothingOnUpdateDisplacementFieldTransformParametersAdaptorTest(int, displacementField->SetDirection(direction); displacementField->Allocate(); - TransformType::OutputVectorType zeroVector{}; + const TransformType::OutputVectorType zeroVector{}; displacementField->FillBuffer(zeroVector); @@ -68,11 +68,11 @@ itkBSplineSmoothingOnUpdateDisplacementFieldTransformParametersAdaptorTest(int, auto transform = TransformType::New(); transform->SetDisplacementField(displacementField); - auto point = itk::MakeFilled(50.0); - TransformType::OutputPointType outputPointBeforeAdapt = transform->TransformPoint(point); + auto point = itk::MakeFilled(50.0); + const TransformType::OutputPointType outputPointBeforeAdapt = transform->TransformPoint(point); - SpacingType spacingBefore = transform->GetDisplacementField()->GetSpacing(); - SizeType sizeBefore = transform->GetDisplacementField()->GetLargestPossibleRegion().GetSize(); + const SpacingType spacingBefore = transform->GetDisplacementField()->GetSpacing(); + const SizeType sizeBefore = transform->GetDisplacementField()->GetLargestPossibleRegion().GetSize(); /** * Instantiate the adaptor @@ -122,13 +122,13 @@ itkBSplineSmoothingOnUpdateDisplacementFieldTransformParametersAdaptorTest(int, } - SpacingType spacingAfter = transform->GetDisplacementField()->GetSpacing(); - SizeType sizeAfter = transform->GetDisplacementField()->GetLargestPossibleRegion().GetSize(); + const SpacingType spacingAfter = transform->GetDisplacementField()->GetSpacing(); + const SizeType sizeAfter = transform->GetDisplacementField()->GetLargestPossibleRegion().GetSize(); std::cout << "Spacing: " << spacingBefore << "(before), " << spacingAfter << "(after)." << std::endl; std::cout << "Size: " << sizeBefore << "(before), " << sizeAfter << "(after)." << std::endl; - TransformType::ParametersType fixedParameters = adaptor->GetRequiredFixedParameters(); + const TransformType::ParametersType fixedParameters = adaptor->GetRequiredFixedParameters(); std::cout << "Fixed parameters: " << fixedParameters << std::endl; adaptor->SetRequiredFixedParameters(fixedParameters); @@ -163,7 +163,7 @@ itkBSplineSmoothingOnUpdateDisplacementFieldTransformParametersAdaptorTest(int, return EXIT_FAILURE; } - TransformType::OutputPointType outputPointAfterAdapt = transform->TransformPoint(point); + const TransformType::OutputPointType outputPointAfterAdapt = transform->TransformPoint(point); std::cout << point << " to (before) " << outputPointBeforeAdapt << std::endl; std::cout << point << " to (after) " << outputPointAfterAdapt << std::endl; diff --git a/Modules/Registration/Common/test/itkBSplineTransformParametersAdaptorTest.cxx b/Modules/Registration/Common/test/itkBSplineTransformParametersAdaptorTest.cxx index be295903971..a777d7ca330 100644 --- a/Modules/Registration/Common/test/itkBSplineTransformParametersAdaptorTest.cxx +++ b/Modules/Registration/Common/test/itkBSplineTransformParametersAdaptorTest.cxx @@ -57,8 +57,8 @@ itkBSplineTransformParametersAdaptorTest(int, char *[]) * Allocate memory for the parameters */ using ParametersType = TransformType::ParametersType; - unsigned long numberOfParameters = transform->GetNumberOfParameters(); - ParametersType parameters(numberOfParameters); + const unsigned long numberOfParameters = transform->GetNumberOfParameters(); + ParametersType parameters(numberOfParameters); parameters.Fill(ParametersType::ValueType{}); /** @@ -72,7 +72,7 @@ itkBSplineTransformParametersAdaptorTest(int, char *[]) auto point = itk::MakeFilled(50.0); - TransformType::OutputPointType outputPointBeforeAdapt = transform->TransformPoint(point); + const TransformType::OutputPointType outputPointBeforeAdapt = transform->TransformPoint(point); /** @@ -87,7 +87,8 @@ itkBSplineTransformParametersAdaptorTest(int, char *[]) requiredMeshSize[d] = (d + 1) * meshSize[d]; } - TransformType::SizeType gridSizeBefore = transform->GetCoefficientImages()[0]->GetLargestPossibleRegion().GetSize(); + const TransformType::SizeType gridSizeBefore = + transform->GetCoefficientImages()[0]->GetLargestPossibleRegion().GetSize(); using AdaptorType = itk::BSplineTransformParametersAdaptor; auto adaptor = AdaptorType::New(); @@ -106,7 +107,7 @@ itkBSplineTransformParametersAdaptorTest(int, char *[]) return EXIT_FAILURE; } - ParametersType fixedParameters = adaptor->GetRequiredFixedParameters(); + const ParametersType fixedParameters = adaptor->GetRequiredFixedParameters(); std::cout << "Fixed parameters: " << fixedParameters << std::endl; adaptor->SetRequiredFixedParameters(fixedParameters); @@ -131,9 +132,10 @@ itkBSplineTransformParametersAdaptorTest(int, char *[]) return EXIT_FAILURE; } - TransformType::SizeType gridSizeAfter = transform->GetCoefficientImages()[0]->GetLargestPossibleRegion().GetSize(); + const TransformType::SizeType gridSizeAfter = + transform->GetCoefficientImages()[0]->GetLargestPossibleRegion().GetSize(); - TransformType::OutputPointType outputPointAfterAdapt = transform->TransformPoint(point); + const TransformType::OutputPointType outputPointAfterAdapt = transform->TransformPoint(point); std::cout << "Grid size before: " << gridSizeBefore << std::endl; std::cout << "Grid size after: " << gridSizeAfter << std::endl; diff --git a/Modules/Registration/Common/test/itkBlockMatchingImageFilterTest.cxx b/Modules/Registration/Common/test/itkBlockMatchingImageFilterTest.cxx index 7461cac8f4d..f27fe6035ed 100644 --- a/Modules/Registration/Common/test/itkBlockMatchingImageFilterTest.cxx +++ b/Modules/Registration/Common/test/itkBlockMatchingImageFilterTest.cxx @@ -165,15 +165,15 @@ itkBlockMatchingImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(colormapImageFilter->Update()); - OutputImageType::Pointer outputImage = colormapImageFilter->GetOutput(); + const OutputImageType::Pointer outputImage = colormapImageFilter->GetOutput(); // Highlight the feature points identified in the output image using PointIteratorType = PointSetType::PointsContainer::ConstIterator; using PointDataIteratorType = BlockMatchingFilterType::DisplacementsType::PointDataContainer::ConstIterator; - PointIteratorType pointItr = featureSelectionFilter->GetOutput()->GetPoints()->Begin(); - PointIteratorType pointEnd = featureSelectionFilter->GetOutput()->GetPoints()->End(); - PointDataIteratorType displItr = displacements->GetPointData()->Begin(); + PointIteratorType pointItr = featureSelectionFilter->GetOutput()->GetPoints()->Begin(); + const PointIteratorType pointEnd = featureSelectionFilter->GetOutput()->GetPoints()->End(); + PointDataIteratorType displItr = displacements->GetPointData()->Begin(); // define colors OutputPixelType red; @@ -196,7 +196,7 @@ itkBlockMatchingImageFilterTest(int argc, char * argv[]) { if (outputImage->TransformPhysicalPointToIndex(pointItr.Value(), index)) { - OutputImageType::IndexType displ = + const OutputImageType::IndexType displ = outputImage->TransformPhysicalPointToIndex(pointItr.Value() + displItr.Value()); // draw line between old and new location of a point in blue diff --git a/Modules/Registration/Common/test/itkCenteredTransformInitializerTest.cxx b/Modules/Registration/Common/test/itkCenteredTransformInitializerTest.cxx index d5187484caa..ddb1b6db486 100644 --- a/Modules/Registration/Common/test/itkCenteredTransformInitializerTest.cxx +++ b/Modules/Registration/Common/test/itkCenteredTransformInitializerTest.cxx @@ -270,7 +270,7 @@ itkCenteredTransformInitializerTest(int, char *[]) index[1] = 0; index[2] = 0; - RegionType region{ index, size }; + const RegionType region{ index, size }; auto fixedImage = FixedImageType::New(); @@ -335,9 +335,9 @@ itkCenteredTransformInitializerTest(int, char *[]) movingIndex[1] = 20; movingIndex[2] = 30; - RegionType fixedRegion{ fixedIndex, size }; + const RegionType fixedRegion{ fixedIndex, size }; - RegionType movingRegion{ movingIndex, size }; + const RegionType movingRegion{ movingIndex, size }; using VersorType = itk::Versor; VersorType x; @@ -347,8 +347,8 @@ itkCenteredTransformInitializerTest(int, char *[]) VersorType z; z.SetRotationAroundZ(1.5); - DirectionType fixedDirection = (x * y * z).GetMatrix(); - DirectionType movingDirection = (z * y * x).GetMatrix(); + const DirectionType fixedDirection = (x * y * z).GetMatrix(); + const DirectionType movingDirection = (z * y * x).GetMatrix(); auto fixedImage = FixedImageType::New(); diff --git a/Modules/Registration/Common/test/itkCenteredVersorTransformInitializerTest.cxx b/Modules/Registration/Common/test/itkCenteredVersorTransformInitializerTest.cxx index f760aa5112f..ff60906950b 100644 --- a/Modules/Registration/Common/test/itkCenteredVersorTransformInitializerTest.cxx +++ b/Modules/Registration/Common/test/itkCenteredVersorTransformInitializerTest.cxx @@ -78,7 +78,7 @@ itkCenteredVersorTransformInitializerTest(int, char *[]) index[1] = 0; index[2] = 0; - RegionType region{ index, size }; + const RegionType region{ index, size }; auto fixedImage = FixedImageType::New(); diff --git a/Modules/Registration/Common/test/itkCompareHistogramImageToImageMetricTest.cxx b/Modules/Registration/Common/test/itkCompareHistogramImageToImageMetricTest.cxx index 84a65c86f59..e58b492a642 100644 --- a/Modules/Registration/Common/test/itkCompareHistogramImageToImageMetricTest.cxx +++ b/Modules/Registration/Common/test/itkCompareHistogramImageToImageMetricTest.cxx @@ -49,8 +49,8 @@ itkCompareHistogramImageToImageMetricTest(int, char *[]) FixedImageType::SpacingValueType fixedImageSpacing[] = { 1.0f, 1.0f }; MovingImageType::SpacingValueType movingImageSpacing[] = { 1.0f, 1.0f }; - FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; - MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; + const FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; + const MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; auto movingImageSource = MovingImageSourceType::New(); auto fixedImageSource = FixedImageSourceType::New(); @@ -70,8 +70,8 @@ itkCompareHistogramImageToImageMetricTest(int, char *[]) ITK_TRY_EXPECT_NO_EXCEPTION(movingImageSource->Update()); // Force the filter to run ITK_TRY_EXPECT_NO_EXCEPTION(fixedImageSource->Update()); // Force the filter to run - MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); - FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); + const MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); // Set up the metric. using MetricType = itk::KullbackLeiblerCompareHistogramImageToImageMetric; @@ -89,7 +89,7 @@ itkCompareHistogramImageToImageMetricTest(int, char *[]) metric->SetEpsilon(epsilon); ITK_TEST_SET_GET_VALUE(epsilon, metric->GetEpsilon()); - unsigned int nBins = 256; + const unsigned int nBins = 256; MetricType::HistogramType::SizeType histSize; histSize.SetSize(2); @@ -158,8 +158,8 @@ itkCompareHistogramImageToImageMetricTest(int, char *[]) metric->Initialize(); // Print out metric value and derivative. - MetricType::MeasureType measure = metric->GetValue(parameters); - MetricType::DerivativeType derivative; + const MetricType::MeasureType measure = metric->GetValue(parameters); + MetricType::DerivativeType derivative; metric->GetDerivative(parameters, derivative); std::cout << "Metric value = " << measure << std::endl << "Derivative = " << derivative << std::endl; diff --git a/Modules/Registration/Common/test/itkCorrelationCoefficientHistogramImageToImageMetricTest.cxx b/Modules/Registration/Common/test/itkCorrelationCoefficientHistogramImageToImageMetricTest.cxx index eb1f3a6cfc9..d2a6d31baf4 100644 --- a/Modules/Registration/Common/test/itkCorrelationCoefficientHistogramImageToImageMetricTest.cxx +++ b/Modules/Registration/Common/test/itkCorrelationCoefficientHistogramImageToImageMetricTest.cxx @@ -49,8 +49,8 @@ itkCorrelationCoefficientHistogramImageToImageMetricTest(int, char *[]) FixedImageType::SpacingValueType fixedImageSpacing[] = { 1.0f, 1.0f }; MovingImageType::SpacingValueType movingImageSpacing[] = { 1.0f, 1.0f }; - FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; - MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; + const FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; + const MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; auto movingImageSource = MovingImageSourceType::New(); auto fixedImageSource = FixedImageSourceType::New(); @@ -70,8 +70,8 @@ itkCorrelationCoefficientHistogramImageToImageMetricTest(int, char *[]) movingImageSource->Update(); // Force the filter to run fixedImageSource->Update(); // Force the filter to run - MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); - FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); + const MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); // Set up the metric. using MetricType = itk::CorrelationCoefficientHistogramImageToImageMetric; @@ -81,7 +81,7 @@ itkCorrelationCoefficientHistogramImageToImageMetricTest(int, char *[]) auto metric = MetricType::New(); - unsigned int nBins = 256; + const unsigned int nBins = 256; MetricType::HistogramType::SizeType histSize; histSize.SetSize(2); histSize[0] = nBins; @@ -130,8 +130,8 @@ itkCorrelationCoefficientHistogramImageToImageMetricTest(int, char *[]) metric->Initialize(); // Print out metric value and derivative. - MetricType::MeasureType measure = metric->GetValue(parameters); - MetricType::DerivativeType derivative; + const MetricType::MeasureType measure = metric->GetValue(parameters); + MetricType::DerivativeType derivative; metric->GetDerivative(parameters, derivative); std::cout << "Metric value = " << measure << std::endl << "Derivative = " << derivative << std::endl; diff --git a/Modules/Registration/Common/test/itkDisplacementFieldTransformParametersAdaptorTest.cxx b/Modules/Registration/Common/test/itkDisplacementFieldTransformParametersAdaptorTest.cxx index e99daac52bf..d9c09f6550e 100644 --- a/Modules/Registration/Common/test/itkDisplacementFieldTransformParametersAdaptorTest.cxx +++ b/Modules/Registration/Common/test/itkDisplacementFieldTransformParametersAdaptorTest.cxx @@ -50,7 +50,7 @@ itkDisplacementFieldTransformParametersAdaptorTest(int, char *[]) displacementField->SetDirection(direction); displacementField->Allocate(); - TransformType::OutputVectorType zeroVector{}; + const TransformType::OutputVectorType zeroVector{}; displacementField->FillBuffer(zeroVector); auto nonzeroVector = itk::MakeFilled(10.3); @@ -66,11 +66,11 @@ itkDisplacementFieldTransformParametersAdaptorTest(int, char *[]) auto transform = TransformType::New(); transform->SetDisplacementField(displacementField); - auto point = itk::MakeFilled(50.0); - TransformType::OutputPointType outputPointBeforeAdapt = transform->TransformPoint(point); + auto point = itk::MakeFilled(50.0); + const TransformType::OutputPointType outputPointBeforeAdapt = transform->TransformPoint(point); - SpacingType spacingBefore = transform->GetDisplacementField()->GetSpacing(); - SizeType sizeBefore = transform->GetDisplacementField()->GetLargestPossibleRegion().GetSize(); + const SpacingType spacingBefore = transform->GetDisplacementField()->GetSpacing(); + const SizeType sizeBefore = transform->GetDisplacementField()->GetLargestPossibleRegion().GetSize(); /** * Instantiate the adaptor @@ -104,13 +104,13 @@ itkDisplacementFieldTransformParametersAdaptorTest(int, char *[]) return EXIT_FAILURE; } - SpacingType spacingAfter = transform->GetDisplacementField()->GetSpacing(); - SizeType sizeAfter = transform->GetDisplacementField()->GetLargestPossibleRegion().GetSize(); + const SpacingType spacingAfter = transform->GetDisplacementField()->GetSpacing(); + const SizeType sizeAfter = transform->GetDisplacementField()->GetLargestPossibleRegion().GetSize(); std::cout << "Spacing: " << spacingBefore << "(before), " << spacingAfter << "(after)." << std::endl; std::cout << "Size: " << sizeBefore << "(before), " << sizeAfter << "(after)." << std::endl; - TransformType::ParametersType fixedParameters = adaptor->GetRequiredFixedParameters(); + const TransformType::ParametersType fixedParameters = adaptor->GetRequiredFixedParameters(); std::cout << "Fixed parameters: " << fixedParameters << std::endl; adaptor->SetRequiredFixedParameters(fixedParameters); @@ -135,7 +135,7 @@ itkDisplacementFieldTransformParametersAdaptorTest(int, char *[]) return EXIT_FAILURE; } - TransformType::OutputPointType outputPointAfterAdapt = transform->TransformPoint(point); + const TransformType::OutputPointType outputPointAfterAdapt = transform->TransformPoint(point); if (outputPointBeforeAdapt.EuclideanDistanceTo(outputPointAfterAdapt) > 1e-6) { diff --git a/Modules/Registration/Common/test/itkEuclideanDistancePointMetricTest.cxx b/Modules/Registration/Common/test/itkEuclideanDistancePointMetricTest.cxx index 1203dfd3b6b..cfbebec02fb 100644 --- a/Modules/Registration/Common/test/itkEuclideanDistancePointMetricTest.cxx +++ b/Modules/Registration/Common/test/itkEuclideanDistancePointMetricTest.cxx @@ -96,7 +96,7 @@ itkEuclideanDistancePointMetricTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(metric, EuclideanDistancePointMetric, PointSetToPointSetMetric); - bool computeSquaredDistance = static_cast(std::stoi(argv[1])); + const bool computeSquaredDistance = static_cast(std::stoi(argv[1])); if (CompareMeshSources(computeSquaredDistance) > Epsilon) { diff --git a/Modules/Registration/Common/test/itkGaussianExponentialDiffeomorphicTransformParametersAdaptorTest.cxx b/Modules/Registration/Common/test/itkGaussianExponentialDiffeomorphicTransformParametersAdaptorTest.cxx index 3ce61794ada..1284aec574f 100644 --- a/Modules/Registration/Common/test/itkGaussianExponentialDiffeomorphicTransformParametersAdaptorTest.cxx +++ b/Modules/Registration/Common/test/itkGaussianExponentialDiffeomorphicTransformParametersAdaptorTest.cxx @@ -51,7 +51,7 @@ itkGaussianExponentialDiffeomorphicTransformParametersAdaptorTest(int, char *[]) displacementField->SetDirection(direction); displacementField->Allocate(); - TransformType::OutputVectorType zeroVector{}; + const TransformType::OutputVectorType zeroVector{}; displacementField->FillBuffer(zeroVector); @@ -69,11 +69,11 @@ itkGaussianExponentialDiffeomorphicTransformParametersAdaptorTest(int, char *[]) transform->SetConstantVelocityField(displacementField); transform->IntegrateVelocityField(); - auto point = itk::MakeFilled(50.0); - TransformType::OutputPointType outputPointBeforeAdapt = transform->TransformPoint(point); + auto point = itk::MakeFilled(50.0); + const TransformType::OutputPointType outputPointBeforeAdapt = transform->TransformPoint(point); - SpacingType spacingBefore = transform->GetConstantVelocityField()->GetSpacing(); - SizeType sizeBefore = transform->GetConstantVelocityField()->GetLargestPossibleRegion().GetSize(); + const SpacingType spacingBefore = transform->GetConstantVelocityField()->GetSpacing(); + const SizeType sizeBefore = transform->GetConstantVelocityField()->GetLargestPossibleRegion().GetSize(); /** * Instantiate the adaptor @@ -98,8 +98,8 @@ itkGaussianExponentialDiffeomorphicTransformParametersAdaptorTest(int, char *[]) adaptor->SetRequiredOrigin(displacementField->GetOrigin()); adaptor->SetRequiredDirection(displacementField->GetDirection()); - float updateSmoothingVariance = 3.0; - float velocitySmoothingVariance = 0; + const float updateSmoothingVariance = 3.0; + const float velocitySmoothingVariance = 0; adaptor->SetGaussianSmoothingVarianceForTheUpdateField(updateSmoothingVariance); adaptor->SetGaussianSmoothingVarianceForTheConstantVelocityField(velocitySmoothingVariance); @@ -114,13 +114,13 @@ itkGaussianExponentialDiffeomorphicTransformParametersAdaptorTest(int, char *[]) } - SpacingType spacingAfter = transform->GetConstantVelocityField()->GetSpacing(); - SizeType sizeAfter = transform->GetConstantVelocityField()->GetLargestPossibleRegion().GetSize(); + const SpacingType spacingAfter = transform->GetConstantVelocityField()->GetSpacing(); + const SizeType sizeAfter = transform->GetConstantVelocityField()->GetLargestPossibleRegion().GetSize(); std::cout << "Spacing: " << spacingBefore << "(before), " << spacingAfter << "(after)." << std::endl; std::cout << "Size: " << sizeBefore << "(before), " << sizeAfter << "(after)." << std::endl; - TransformType::ParametersType fixedParameters = adaptor->GetRequiredFixedParameters(); + const TransformType::ParametersType fixedParameters = adaptor->GetRequiredFixedParameters(); std::cout << "Fixed parameters: " << fixedParameters << std::endl; adaptor->SetRequiredFixedParameters(fixedParameters); @@ -157,7 +157,7 @@ itkGaussianExponentialDiffeomorphicTransformParametersAdaptorTest(int, char *[]) return EXIT_FAILURE; } - TransformType::OutputPointType outputPointAfterAdapt = transform->TransformPoint(point); + const TransformType::OutputPointType outputPointAfterAdapt = transform->TransformPoint(point); std::cout << point << " to (before) " << outputPointBeforeAdapt << std::endl; std::cout << point << " to (after) " << outputPointAfterAdapt << std::endl; diff --git a/Modules/Registration/Common/test/itkGaussianSmoothingOnUpdateDisplacementFieldTransformParametersAdaptorTest.cxx b/Modules/Registration/Common/test/itkGaussianSmoothingOnUpdateDisplacementFieldTransformParametersAdaptorTest.cxx index c1f5a04b2a8..a6fcc07c8c2 100644 --- a/Modules/Registration/Common/test/itkGaussianSmoothingOnUpdateDisplacementFieldTransformParametersAdaptorTest.cxx +++ b/Modules/Registration/Common/test/itkGaussianSmoothingOnUpdateDisplacementFieldTransformParametersAdaptorTest.cxx @@ -51,7 +51,7 @@ itkGaussianSmoothingOnUpdateDisplacementFieldTransformParametersAdaptorTest(int, displacementField->SetDirection(direction); displacementField->Allocate(); - TransformType::OutputVectorType zeroVector{}; + const TransformType::OutputVectorType zeroVector{}; displacementField->FillBuffer(zeroVector); @@ -68,11 +68,11 @@ itkGaussianSmoothingOnUpdateDisplacementFieldTransformParametersAdaptorTest(int, auto transform = TransformType::New(); transform->SetDisplacementField(displacementField); - auto point = itk::MakeFilled(50.0); - TransformType::OutputPointType outputPointBeforeAdapt = transform->TransformPoint(point); + auto point = itk::MakeFilled(50.0); + const TransformType::OutputPointType outputPointBeforeAdapt = transform->TransformPoint(point); - SpacingType spacingBefore = transform->GetDisplacementField()->GetSpacing(); - SizeType sizeBefore = transform->GetDisplacementField()->GetLargestPossibleRegion().GetSize(); + const SpacingType spacingBefore = transform->GetDisplacementField()->GetSpacing(); + const SizeType sizeBefore = transform->GetDisplacementField()->GetLargestPossibleRegion().GetSize(); /** * Instantiate the adaptor @@ -109,13 +109,13 @@ itkGaussianSmoothingOnUpdateDisplacementFieldTransformParametersAdaptorTest(int, } - SpacingType spacingAfter = transform->GetDisplacementField()->GetSpacing(); - SizeType sizeAfter = transform->GetDisplacementField()->GetLargestPossibleRegion().GetSize(); + const SpacingType spacingAfter = transform->GetDisplacementField()->GetSpacing(); + const SizeType sizeAfter = transform->GetDisplacementField()->GetLargestPossibleRegion().GetSize(); std::cout << "Spacing: " << spacingBefore << "(before), " << spacingAfter << "(after)." << std::endl; std::cout << "Size: " << sizeBefore << "(before), " << sizeAfter << "(after)." << std::endl; - TransformType::ParametersType fixedParameters = adaptor->GetRequiredFixedParameters(); + const TransformType::ParametersType fixedParameters = adaptor->GetRequiredFixedParameters(); std::cout << "Fixed parameters: " << fixedParameters << std::endl; adaptor->SetRequiredFixedParameters(fixedParameters); @@ -152,7 +152,7 @@ itkGaussianSmoothingOnUpdateDisplacementFieldTransformParametersAdaptorTest(int, return EXIT_FAILURE; } - TransformType::OutputPointType outputPointAfterAdapt = transform->TransformPoint(point); + const TransformType::OutputPointType outputPointAfterAdapt = transform->TransformPoint(point); std::cout << point << " to (before) " << outputPointBeforeAdapt << std::endl; std::cout << point << " to (after) " << outputPointAfterAdapt << std::endl; diff --git a/Modules/Registration/Common/test/itkGradientDifferenceImageToImageMetricTest.cxx b/Modules/Registration/Common/test/itkGradientDifferenceImageToImageMetricTest.cxx index f8e1a03cd66..e95d07bcc61 100644 --- a/Modules/Registration/Common/test/itkGradientDifferenceImageToImageMetricTest.cxx +++ b/Modules/Registration/Common/test/itkGradientDifferenceImageToImageMetricTest.cxx @@ -45,8 +45,8 @@ itkGradientDifferenceImageToImageMetricTest(int, char *[]) FixedImageType::SpacingValueType fixedImageSpacing[] = { 1.0f, 1.0f }; MovingImageType::SpacingValueType movingImageSpacing[] = { 1.0f, 1.0f }; - FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; - MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; + const FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; + const MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; auto movingImageSource = MovingImageSourceType::New(); auto fixedImageSource = FixedImageSourceType::New(); @@ -66,8 +66,8 @@ itkGradientDifferenceImageToImageMetricTest(int, char *[]) movingImageSource->Update(); // Force the filter to run fixedImageSource->Update(); // Force the filter to run - MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); - FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); + const MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); // Set up the metric. using MetricType = itk::GradientDifferenceImageToImageMetric; @@ -81,7 +81,7 @@ itkGradientDifferenceImageToImageMetricTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(metric, GradientDifferenceImageToImageMetric, ImageToImageMetric); - double derivativeDelta = 0.001; + const double derivativeDelta = 0.001; metric->SetDerivativeDelta(derivativeDelta); ITK_TEST_SET_GET_VALUE(derivativeDelta, metric->GetDerivativeDelta()); diff --git a/Modules/Registration/Common/test/itkHistogramImageToImageMetricTest.cxx b/Modules/Registration/Common/test/itkHistogramImageToImageMetricTest.cxx index ba97731bac2..2af44a5918a 100644 --- a/Modules/Registration/Common/test/itkHistogramImageToImageMetricTest.cxx +++ b/Modules/Registration/Common/test/itkHistogramImageToImageMetricTest.cxx @@ -45,8 +45,8 @@ itkHistogramImageToImageMetricTest(int, char *[]) FixedImageType::SpacingValueType fixedImageSpacing[] = { 1.0f, 1.0f }; MovingImageType::SpacingValueType movingImageSpacing[] = { 1.0f, 1.0f }; - FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; - MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; + const FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; + const MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; auto movingImageSource = MovingImageSourceType::New(); auto fixedImageSource = FixedImageSourceType::New(); @@ -66,8 +66,8 @@ itkHistogramImageToImageMetricTest(int, char *[]) movingImageSource->Update(); // Force the filter to run fixedImageSource->Update(); // Force the filter to run - MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); - FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); + const MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); // Set up the metric. using MetricType = itk::MeanSquaresHistogramImageToImageMetric; @@ -78,7 +78,7 @@ itkHistogramImageToImageMetricTest(int, char *[]) auto metric = MetricType::New(); - unsigned int nBins = 256; + const unsigned int nBins = 256; MetricType::HistogramType::SizeType histSize; histSize.SetSize(2); histSize[0] = nBins; @@ -191,8 +191,8 @@ itkHistogramImageToImageMetricTest(int, char *[]) std::cout << "Exercise the SetLowerBound() and SetUpperBound() methods " << std::endl; - MetricType::MeasurementVectorType lowerBound{}; - MetricType::MeasurementVectorType upperBound{}; + const MetricType::MeasurementVectorType lowerBound{}; + const MetricType::MeasurementVectorType upperBound{}; metric->SetLowerBound(lowerBound); metric->SetUpperBound(upperBound); @@ -217,9 +217,9 @@ itkHistogramImageToImageMetricTest(int, char *[]) // Force an exception try { - ParametersType parameters2(2); - DerivativeType derivatives2(2); - ScalesType badScales(1); + const ParametersType parameters2(2); + DerivativeType derivatives2(2); + const ScalesType badScales(1); metric->SetDerivativeStepLengthScales(badScales); metric->Initialize(); metric->GetDerivative(parameters2, derivatives2); diff --git a/Modules/Registration/Common/test/itkImageRegistrationMethodTest.cxx b/Modules/Registration/Common/test/itkImageRegistrationMethodTest.cxx index 2f2c3375b3e..f064e4474e5 100644 --- a/Modules/Registration/Common/test/itkImageRegistrationMethodTest.cxx +++ b/Modules/Registration/Common/test/itkImageRegistrationMethodTest.cxx @@ -72,7 +72,7 @@ itkImageRegistrationMethodTest(int, char *[]) auto size = FixedImageType::SizeType::Filled(4); // the size of image have to be at least 4 in each dimension to // compute gradient image inside the metric. - FixedImageType::RegionType region(size); + const FixedImageType::RegionType region(size); fixedImage->SetRegions(region); fixedImage->Allocate(); fixedImage->FillBuffer(3.0); diff --git a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_1.cxx b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_1.cxx index fe40b19501d..971debbd775 100644 --- a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_1.cxx +++ b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_1.cxx @@ -88,8 +88,8 @@ itkImageRegistrationMethodTest_1(int argc, char * argv[]) imageSource->GenerateImages(size); - FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); - MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); + const FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); + const MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); // // Connect all the components required for Registratio @@ -188,9 +188,9 @@ itkImageRegistrationMethodTest_1(int argc, char * argv[]) // // Get the transform as the Output of the Registration filter // - RegistrationType::TransformOutputConstPointer transformDecorator = registration->GetOutput(); + const RegistrationType::TransformOutputConstPointer transformDecorator = registration->GetOutput(); - TransformType::ConstPointer finalTransform = static_cast(transformDecorator->Get()); + const TransformType::ConstPointer finalTransform = static_cast(transformDecorator->Get()); if (!pass) diff --git a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_10.cxx b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_10.cxx index ba4402485d7..c0ddbb2b2c8 100644 --- a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_10.cxx +++ b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_10.cxx @@ -83,8 +83,8 @@ itkImageRegistrationMethodTest_10(int argc, char * argv[]) imageSource->GenerateImages(size); - FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); - MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); + const FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); + const MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); // // Connect all the components required for Registratio diff --git a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_11.cxx b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_11.cxx index 01d394ab2f1..3be75a77af1 100644 --- a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_11.cxx +++ b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_11.cxx @@ -117,12 +117,12 @@ itkImageRegistrationMethodTest_11(int, char *[]) // // Now verify that they can be set to nullptr // - MetricType::Pointer metric3 = nullptr; - TransformType::Pointer transform3 = nullptr; - OptimizerType::Pointer optimizer3 = nullptr; - FixedImageType::Pointer fixedImage3 = nullptr; - MovingImageType::Pointer movingImage3 = nullptr; - InterpolatorType::Pointer interpolator3 = nullptr; + const MetricType::Pointer metric3 = nullptr; + const TransformType::Pointer transform3 = nullptr; + const OptimizerType::Pointer optimizer3 = nullptr; + const FixedImageType::Pointer fixedImage3 = nullptr; + const MovingImageType::Pointer movingImage3 = nullptr; + const InterpolatorType::Pointer interpolator3 = nullptr; registration->SetMetric(metric3); diff --git a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_12.cxx b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_12.cxx index 297fa9af113..3958d6c48de 100644 --- a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_12.cxx +++ b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_12.cxx @@ -84,8 +84,8 @@ itkImageRegistrationMethodTest_12(int argc, char * argv[]) imageSource->GenerateImages(size); - FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); - MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); + const FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); + const MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); // // Connect all the components required for Registratio diff --git a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_13.cxx b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_13.cxx index 8f30170700c..58300e7c0f5 100644 --- a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_13.cxx +++ b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_13.cxx @@ -137,12 +137,12 @@ itkImageRegistrationMethodTest_13(int, char *[]) * Set up the two input images. * One image scaled and shifted with respect to the other. **********************************************************/ - double displacement[dimension] = { 7, 3, 2 }; - double scale[dimension] = { 0.80, 1.0, 1.0 }; + const double displacement[dimension] = { 7, 3, 2 }; + const double scale[dimension] = { 0.80, 1.0, 1.0 }; - FixedImageType::SizeType size = { { 100, 100, 40 } }; - FixedImageType::IndexType index = { { 0, 0, 0 } }; - FixedImageType::RegionType region{ index, size }; + FixedImageType::SizeType size = { { 100, 100, 40 } }; + const FixedImageType::IndexType index = { { 0, 0, 0 } }; + const FixedImageType::RegionType region{ index, size }; fixedImage->SetRegions(region); fixedImage->Allocate(); @@ -253,8 +253,8 @@ itkImageRegistrationMethodTest_13(int, char *[]) * Run the registration - reducing learning rate as we go ************************************************************/ constexpr unsigned int numberOfLoops = 3; - unsigned int iter[numberOfLoops] = { 300, 300, 350 }; - double rates[numberOfLoops] = { 1e-3, 5e-4, 1e-4 }; + const unsigned int iter[numberOfLoops] = { 300, 300, 350 }; + const double rates[numberOfLoops] = { 1e-3, 5e-4, 1e-4 }; for (j = 0; j < numberOfLoops; ++j) { @@ -323,7 +323,7 @@ itkImageRegistrationMethodTest_13(int, char *[]) /************************************************* * Check for parzen window exception **************************************************/ - double oldValue = metric->GetMovingImageStandardDeviation(); + const double oldValue = metric->GetMovingImageStandardDeviation(); metric->SetMovingImageStandardDeviation(0.005); try @@ -397,7 +397,7 @@ F(itk::Vector & v) x -= 8; y += 3; z += 0; - double r = std::sqrt(x * x + y * y + z * z); + const double r = std::sqrt(x * x + y * y + z * z); if (r > 35) { value = 2 * (itk::Math::abs(x) + 0.8 * itk::Math::abs(y) + 0.5 * itk::Math::abs(z)); diff --git a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_14.cxx b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_14.cxx index c7ee4386b5a..d61d062f67c 100644 --- a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_14.cxx +++ b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_14.cxx @@ -143,12 +143,12 @@ itkImageRegistrationMethodTest_14(int, char *[]) * Set up the two input images. * One image rotated (xy plane) and shifted with respect to the other. **********************************************************/ - double displacement[dimension] = { 7, 3, 2 }; - double angle = 10.0 / 180.0 * itk::Math::pi; + const double displacement[dimension] = { 7, 3, 2 }; + const double angle = 10.0 / 180.0 * itk::Math::pi; - FixedImageType::SizeType size = { { 100, 100, 40 } }; - FixedImageType::IndexType index = { { 0, 0, 0 } }; - FixedImageType::RegionType region{ index, size }; + FixedImageType::SizeType size = { { 100, 100, 40 } }; + const FixedImageType::IndexType index = { { 0, 0, 0 } }; + const FixedImageType::RegionType region{ index, size }; fixedImage->SetRegions(region); fixedImage->Allocate(); @@ -262,8 +262,8 @@ itkImageRegistrationMethodTest_14(int, char *[]) * Run the registration - reducing learning rate as we go ************************************************************/ constexpr unsigned int numberOfLoops = 3; - unsigned int iter[numberOfLoops] = { 300, 300, 350 }; - double rates[numberOfLoops] = { 1e-3, 5e-4, 1e-4 }; + const unsigned int iter[numberOfLoops] = { 300, 300, 350 }; + const double rates[numberOfLoops] = { 1e-3, 5e-4, 1e-4 }; for (unsigned int j = 0; j < numberOfLoops; ++j) { @@ -332,7 +332,7 @@ itkImageRegistrationMethodTest_14(int, char *[]) /************************************************* * Check for parzen window exception **************************************************/ - double oldValue = metric->GetMovingImageStandardDeviation(); + const double oldValue = metric->GetMovingImageStandardDeviation(); metric->SetMovingImageStandardDeviation(0.005); try @@ -405,7 +405,7 @@ F(itk::Vector & v) x -= 8; y += 3; z += 0; - double r = std::sqrt(x * x + y * y + z * z); + const double r = std::sqrt(x * x + y * y + z * z); if (r > 35) { value = 2 * (itk::Math::abs(x) + 0.8 * itk::Math::abs(y) + 0.5 * itk::Math::abs(z)); diff --git a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_15.cxx b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_15.cxx index d9ece5ab95d..e68127fb881 100644 --- a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_15.cxx +++ b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_15.cxx @@ -120,8 +120,8 @@ itkImageRegistrationMethodTest_15(int, char *[]) * Set up the two input images. * One image scaled and shifted with respect to the other. **********************************************************/ - double displacement[dimension] = { 3, 1, 1 }; - double scale[dimension] = { 0.90, 1.0, 1.0 }; + const double displacement[dimension] = { 3, 1, 1 }; + const double scale[dimension] = { 0.90, 1.0, 1.0 }; FixedImageType::SizeType size = { { 100, 100, 40 } }; FixedImageType::IndexType index = { { 0, 0, 0 } }; @@ -251,8 +251,8 @@ itkImageRegistrationMethodTest_15(int, char *[]) * Run the registration ************************************************************/ constexpr unsigned int numberOfLoops = 2; - unsigned int iter[numberOfLoops] = { 50, 0 }; - double rates[numberOfLoops] = { 1e-3, 5e-4 }; + const unsigned int iter[numberOfLoops] = { 50, 0 }; + const double rates[numberOfLoops] = { 1e-3, 5e-4 }; for (j = 0; j < numberOfLoops; ++j) @@ -340,7 +340,7 @@ F(itk::Vector & v) x -= 8; y += 3; z += 0; - double r = std::sqrt(x * x + y * y + z * z); + const double r = std::sqrt(x * x + y * y + z * z); if (r > 35) { value = 2 * (itk::Math::abs(x) + 0.8 * itk::Math::abs(y) + 0.5 * itk::Math::abs(z)); diff --git a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_16.cxx b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_16.cxx index 6c001dbe328..2c43a9e0c19 100644 --- a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_16.cxx +++ b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_16.cxx @@ -91,8 +91,8 @@ DoRegistration() imageSource->GenerateImages(size); - typename FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); - typename MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); + const typename FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); + const typename MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); // // Connect all the components required for Registratio @@ -118,9 +118,9 @@ DoRegistration() scales.Fill(1.0); - unsigned long numberOfIterations = 100; - double translationScale = 1e-6; - double learningRate = 1e-8; + const unsigned long numberOfIterations = 100; + const double translationScale = 1e-6; + const double learningRate = 1e-8; for (unsigned int i = 0; i < dimension; ++i) { @@ -176,16 +176,16 @@ DoRegistration() int itkImageRegistrationMethodTest_16(int itkNotUsed(argc), char *[] itkNotUsed(argv)) { - bool result_uc = DoRegistration(); - bool result_c = DoRegistration(); - bool result_us = DoRegistration(); - bool result_s = DoRegistration(); - bool result_ui = DoRegistration(); - bool result_i = DoRegistration(); - bool result_ul = DoRegistration(); - bool result_l = DoRegistration(); - bool result_f = DoRegistration(); - bool result_d = DoRegistration(); + const bool result_uc = DoRegistration(); + const bool result_c = DoRegistration(); + const bool result_us = DoRegistration(); + const bool result_s = DoRegistration(); + const bool result_ui = DoRegistration(); + const bool result_i = DoRegistration(); + const bool result_ul = DoRegistration(); + const bool result_l = DoRegistration(); + const bool result_f = DoRegistration(); + const bool result_d = DoRegistration(); std::cout << ": " << result_uc << std::endl; std::cout << ": " << result_c << std::endl; diff --git a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_17.cxx b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_17.cxx index dfd46ce5720..1155f4fcae6 100644 --- a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_17.cxx +++ b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_17.cxx @@ -126,8 +126,8 @@ itkImageRegistrationMethodTest_17(int, char *[]) * Set up the two input images. * One image scaled and shifted with respect to the other. **********************************************************/ - double displacement[dimension] = { 3, 1, 1 }; - double scale[dimension] = { 0.90, 1.0, 1.0 }; + const double displacement[dimension] = { 3, 1, 1 }; + const double scale[dimension] = { 0.90, 1.0, 1.0 }; FixedImageType::SizeType size = { { 100, 100, 40 } }; FixedImageType::IndexType index = { { 0, 0, 0 } }; @@ -259,8 +259,8 @@ itkImageRegistrationMethodTest_17(int, char *[]) * Run the registration ************************************************************/ constexpr unsigned int numberOfLoops = 2; - unsigned int iter[numberOfLoops] = { 50, 0 }; - double rates[numberOfLoops] = { 1e-3, 5e-4 }; + const unsigned int iter[numberOfLoops] = { 50, 0 }; + const double rates[numberOfLoops] = { 1e-3, 5e-4 }; for (j = 0; j < numberOfLoops; ++j) @@ -348,7 +348,7 @@ F(itk::Vector & v) x -= 8; y += 3; z += 0; - double r = std::sqrt(x * x + y * y + z * z); + const double r = std::sqrt(x * x + y * y + z * z); if (r > 35) { value = 2 * (itk::Math::abs(x) + 0.8 * itk::Math::abs(y) + 0.5 * itk::Math::abs(z)); diff --git a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_2.cxx b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_2.cxx index 6a8955d6a40..8120bade60e 100644 --- a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_2.cxx +++ b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_2.cxx @@ -83,8 +83,8 @@ itkImageRegistrationMethodTest_2(int argc, char * argv[]) imageSource->GenerateImages(size); - FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); - MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); + const FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); + const MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); // // Connect all the components required for Registratio diff --git a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_3.cxx b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_3.cxx index 1ec814f4804..5a9bc997581 100644 --- a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_3.cxx +++ b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_3.cxx @@ -84,8 +84,8 @@ itkImageRegistrationMethodTest_3(int argc, char * argv[]) imageSource->GenerateImages(size); - FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); - MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); + const FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); + const MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); // // Connect all the components required for Registratio diff --git a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_4.cxx b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_4.cxx index b6343f49467..ea04de89b10 100644 --- a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_4.cxx +++ b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_4.cxx @@ -84,8 +84,8 @@ itkImageRegistrationMethodTest_4(int argc, char * argv[]) imageSource->GenerateImages(size); - FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); - MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); + const FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); + const MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); // // Connect all the components required for Registratio diff --git a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_5.cxx b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_5.cxx index 1d36506001c..ae109dadfb3 100644 --- a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_5.cxx +++ b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_5.cxx @@ -83,8 +83,8 @@ itkImageRegistrationMethodTest_5_Func(int argc, char * argv[], bool subtractMean imageSource->GenerateImages(size); - FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); - MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); + const FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); + const MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); // // Connect all the components required for Registratio @@ -204,10 +204,10 @@ int itkImageRegistrationMethodTest_5(int argc, char * argv[]) { // test metric without factoring out the mean. - int fail1 = itkImageRegistrationMethodTest_5_Func(argc, argv, false); + const int fail1 = itkImageRegistrationMethodTest_5_Func(argc, argv, false); // test metric with factoring out the mean. - int fail2 = itkImageRegistrationMethodTest_5_Func(argc, argv, true); + const int fail2 = itkImageRegistrationMethodTest_5_Func(argc, argv, true); if (fail1 || fail2) { diff --git a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_6.cxx b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_6.cxx index 100fcc16c9a..c205fd26568 100644 --- a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_6.cxx +++ b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_6.cxx @@ -83,8 +83,8 @@ itkImageRegistrationMethodTest_6(int argc, char * argv[]) imageSource->GenerateImages(size); - FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); - MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); + const FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); + const MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); // // Connect all the components required for Registratio diff --git a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_7.cxx b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_7.cxx index db1fd771cf4..c972c63226e 100644 --- a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_7.cxx +++ b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_7.cxx @@ -84,8 +84,8 @@ itkImageRegistrationMethodTest_7(int argc, char * argv[]) imageSource->GenerateImages(size); - FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); - MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); + const FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); + const MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); // // Connect all the components required for Registratio diff --git a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_8.cxx b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_8.cxx index 363ef9fe0c3..a8d0c928b2d 100644 --- a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_8.cxx +++ b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_8.cxx @@ -84,8 +84,8 @@ itkImageRegistrationMethodTest_8(int argc, char * argv[]) imageSource->GenerateImages(size); - FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); - MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); + const FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); + const MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); // // Connect all the components required for Registratio diff --git a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_9.cxx b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_9.cxx index 4ba8163f747..5d64b3809e2 100644 --- a/Modules/Registration/Common/test/itkImageRegistrationMethodTest_9.cxx +++ b/Modules/Registration/Common/test/itkImageRegistrationMethodTest_9.cxx @@ -85,8 +85,8 @@ itkImageRegistrationMethodTest_9(int argc, char * argv[]) imageSource->GenerateImages(size); - FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); - MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); + const FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); + const MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); // // Connect all the components required for Registratio diff --git a/Modules/Registration/Common/test/itkImageToSpatialObjectRegistrationTest.cxx b/Modules/Registration/Common/test/itkImageToSpatialObjectRegistrationTest.cxx index 5ac41e256b3..192d228b854 100644 --- a/Modules/Registration/Common/test/itkImageToSpatialObjectRegistrationTest.cxx +++ b/Modules/Registration/Common/test/itkImageToSpatialObjectRegistrationTest.cxx @@ -175,7 +175,7 @@ class SimpleImageToSpatialObjectMetric : public ImageToSpatialObjectMetricm_Transform->TransformPoint(*it); + const PointType transformedPoint = this->m_Transform->TransformPoint(*it); index = this->m_FixedImage->TransformPhysicalPointToIndex(transformedPoint); if (index[0] > 0L && index[1] > 0L && index[0] < static_cast(this->m_FixedImage->GetLargestPossibleRegion().GetSize()[0]) && @@ -341,7 +341,7 @@ itkImageToSpatialObjectRegistrationTest(int, char *[]) optimizer->MaximizeOn(); - itk::Statistics::NormalVariateGenerator::Pointer generator = itk::Statistics::NormalVariateGenerator::New(); + const itk::Statistics::NormalVariateGenerator::Pointer generator = itk::Statistics::NormalVariateGenerator::New(); generator->Initialize(12345); optimizer->SetNormalVariateGenerator(generator); diff --git a/Modules/Registration/Common/test/itkKappaStatisticImageToImageMetricTest.cxx b/Modules/Registration/Common/test/itkKappaStatisticImageToImageMetricTest.cxx index a6ac0c8762c..be20ec72b92 100644 --- a/Modules/Registration/Common/test/itkKappaStatisticImageToImageMetricTest.cxx +++ b/Modules/Registration/Common/test/itkKappaStatisticImageToImageMetricTest.cxx @@ -56,7 +56,7 @@ itkKappaStatisticImageToImageMetricTest(int, char *[]) using InterpolatorType = itk::NearestNeighborInterpolateImageFunction; - double epsilon = 0.000001; + const double epsilon = 0.000001; auto transform = TransformType::New(); auto interpolator = InterpolatorType::New(); @@ -101,7 +101,7 @@ itkKappaStatisticImageToImageMetricTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(metric, KappaStatisticImageToImageMetric, ImageToImageMetric); - MetricType::RealType foregroundValue = 255; + const MetricType::RealType foregroundValue = 255; metric->SetForegroundValue(foregroundValue); ITK_TEST_SET_GET_VALUE(foregroundValue, metric->GetForegroundValue()); @@ -115,7 +115,7 @@ itkKappaStatisticImageToImageMetricTest(int, char *[]) transform->SetIdentity(); metric->SetTransform(transform); - TransformType::ParametersType parameters = transform->GetParameters(); + const TransformType::ParametersType parameters = transform->GetParameters(); // Test error conditions // @@ -230,7 +230,7 @@ itkKappaStatisticImageToImageMetricTest(int, char *[]) metric->GetDerivative(parameters, derivative); // The value 0.0477502 was computed by hand - double expectedDerivativeMeasure = -0.0477502; + const double expectedDerivativeMeasure = -0.0477502; for (unsigned int i = 0; i < derivative.size(); ++i) { if (!itk::Math::FloatAlmostEqual(static_cast(derivative[i]), expectedDerivativeMeasure, 10, epsilon)) diff --git a/Modules/Registration/Common/test/itkKullbackLeiblerCompareHistogramImageToImageMetricTest.cxx b/Modules/Registration/Common/test/itkKullbackLeiblerCompareHistogramImageToImageMetricTest.cxx index 9a1d97a30b2..69f8b781398 100644 --- a/Modules/Registration/Common/test/itkKullbackLeiblerCompareHistogramImageToImageMetricTest.cxx +++ b/Modules/Registration/Common/test/itkKullbackLeiblerCompareHistogramImageToImageMetricTest.cxx @@ -52,9 +52,9 @@ itkKullbackLeiblerCompareHistogramImageToImageMetricTest(int, char *[]) ImageDimension = MovingImageType::ImageDimension }; - MovingImageType::SizeType size = { { 16, 16 } }; - MovingImageType::IndexType index = { { 0, 0 } }; - MovingImageType::RegionType region{ index, size }; + const MovingImageType::SizeType size = { { 16, 16 } }; + const MovingImageType::IndexType index = { { 0, 0 } }; + const MovingImageType::RegionType region{ index, size }; auto imgMoving = MovingImageType::New(); imgMoving->SetRegions(region); @@ -196,7 +196,7 @@ itkKullbackLeiblerCompareHistogramImageToImageMetricTest(int, char *[]) // set the number of samples to use // metric->SetNumberOfSpatialSamples( 100 ); - unsigned int nBins = 64; + const unsigned int nBins = 64; MetricType::HistogramType::SizeType histSize; histSize.SetSize(2); histSize[0] = nBins; @@ -233,8 +233,8 @@ itkKullbackLeiblerCompareHistogramImageToImageMetricTest(int, char *[]) //------------------------------------------------------------ // Set up an affine transform parameters //------------------------------------------------------------ - unsigned int numberOfParameters = transformer->GetNumberOfParameters(); - ParametersType parameters(numberOfParameters); + const unsigned int numberOfParameters = transformer->GetNumberOfParameters(); + ParametersType parameters(numberOfParameters); // set the parameters to the identity unsigned long count = 0; diff --git a/Modules/Registration/Common/test/itkLandmarkBasedTransformInitializerTest.cxx b/Modules/Registration/Common/test/itkLandmarkBasedTransformInitializerTest.cxx index cf63e765e75..eb5b9023335 100644 --- a/Modules/Registration/Common/test/itkLandmarkBasedTransformInitializerTest.cxx +++ b/Modules/Registration/Common/test/itkLandmarkBasedTransformInitializerTest.cxx @@ -56,7 +56,7 @@ Init3DPoints(typename TTransformInitializer::LandmarkPointContainer & fixedLandm typename TTransformInitializer::LandmarkPointType point; typename TTransformInitializer::LandmarkPointType tmp; - double angle = 10 * nPI / 180.0; + const double angle = 10 * nPI / 180.0; typename TTransformInitializer::LandmarkPointType translation; translation[0] = 6; @@ -144,7 +144,8 @@ ExecuteAndExamine(typename TransformInitializerType::Pointer init typename TransformInitializerType::LandmarkPointContainer movingLandmarks, unsigned int failLimit = 0) { - typename TransformInitializerType::TransformType::Pointer transform = TransformInitializerType::TransformType::New(); + const typename TransformInitializerType::TransformType::Pointer transform = + TransformInitializerType::TransformType::New(); initializer->SetTransform(transform); initializer->InitializeTransform(); @@ -159,13 +160,13 @@ ExecuteAndExamine(typename TransformInitializerType::Pointer init typename TransformInitializerType::PointsContainerConstIterator mitr = movingLandmarks.begin(); using OutputVectorType = typename TransformInitializerType::OutputVectorType; - OutputVectorType error; - typename OutputVectorType::RealValueType tolerance = 0.1; - unsigned int failed = 0; + OutputVectorType error; + const typename OutputVectorType::RealValueType tolerance = 0.1; + unsigned int failed = 0; while (mitr != movingLandmarks.end()) { - typename TransformInitializerType::LandmarkPointType transformedPoint = transform->TransformPoint(*fitr); + const typename TransformInitializerType::LandmarkPointType transformedPoint = transform->TransformPoint(*fitr); std::cout << " Fixed Landmark: " << *fitr << " Moving landmark " << *mitr << " Transformed fixed Landmark : " << transformedPoint; @@ -248,8 +249,8 @@ itkLandmarkBasedTransformInitializerTest(int, char *[]) using FixedImageType = itk::Image; using MovingImageType = itk::Image; - FixedImageType::Pointer fixedImage = CreateTestImage(); - MovingImageType::Pointer movingImage = CreateTestImage(); + const FixedImageType::Pointer fixedImage = CreateTestImage(); + const MovingImageType::Pointer movingImage = CreateTestImage(); // Set the transform type using TransformType = itk::Rigid2DTransform; @@ -271,7 +272,7 @@ itkLandmarkBasedTransformInitializerTest(int, char *[]) // translated by the 'translation'. Offset can be used to move the fixed // landmarks around. const double nPI = 4.0 * std::atan(1.0); - double angle = 10 * nPI / 180.0; + const double angle = 10 * nPI / 180.0; TransformInitializerType::LandmarkPointType translation; translation[0] = 6; @@ -332,8 +333,8 @@ itkLandmarkBasedTransformInitializerTest(int, char *[]) { constexpr unsigned int Dimension = 3; using ImageType = itk::Image; - ImageType::Pointer fixedImage = CreateTestImage(); - ImageType::Pointer movingImage = CreateTestImage(); + const ImageType::Pointer fixedImage = CreateTestImage(); + const ImageType::Pointer movingImage = CreateTestImage(); using TransformType = itk::AffineTransform; auto transform = TransformType::New(); @@ -348,7 +349,7 @@ itkLandmarkBasedTransformInitializerTest(int, char *[]) ITK_TRY_EXPECT_EXCEPTION(initializer->InitializeTransform()); const unsigned int numLandmarks(8); - double fixedLandMarkInit[numLandmarks][3] = { + const double fixedLandMarkInit[numLandmarks][3] = { { -1.33671, -279.739, 176.001 }, { 28.0989, -346.692, 183.367 }, { -1.36713, -257.43, 155.36 }, @@ -358,7 +359,7 @@ itkLandmarkBasedTransformInitializerTest(int, char *[]) { 200, 200, 200 }, // dummy { -300, 100, 1000 } // dummy }; - double movingLandmarkInit[numLandmarks][3] = { + const double movingLandmarkInit[numLandmarks][3] = { { -1.65605 + 0.011, -30.0661, 20.1656 }, { 28.1409, -93.1172 + 0.015, -5.34366 }, { -1.55885, -0.499696 - 0.04, 12.7584 }, @@ -369,7 +370,7 @@ itkLandmarkBasedTransformInitializerTest(int, char *[]) { -300, 100, 1000 } // dummy }; - double weights[numLandmarks] = { 10, 1, 10, 1, 1, 1, 0.001, 0.001 }; + const double weights[numLandmarks] = { 10, 1, 10, 1, 1, 1, 0.001, 0.001 }; { // First Test with working Landmarks // These landmark should match properly @@ -442,8 +443,8 @@ itkLandmarkBasedTransformInitializerTest(int, char *[]) using FixedImageType = itk::Image; using MovingImageType = itk::Image; - FixedImageType::Pointer fixedImage = CreateTestImage(); - MovingImageType::Pointer movingImage = CreateTestImage(); + const FixedImageType::Pointer fixedImage = CreateTestImage(); + const MovingImageType::Pointer movingImage = CreateTestImage(); auto origin = itk::MakeFilled(-5); fixedImage->SetOrigin(origin); @@ -464,10 +465,10 @@ itkLandmarkBasedTransformInitializerTest(int, char *[]) Init3DPoints(fixedLandmarks, movingLandmarks, 1); constexpr unsigned int numLandmarks = 4; - double weights[numLandmarks] = { 1, 3, 0.01, 0.5 }; + const double weights[numLandmarks] = { 1, 3, 0.01, 0.5 }; TransformInitializerType::LandmarkWeightType landmarkWeights; - for (double weight : weights) + for (const double weight : weights) { landmarkWeights.push_back(weight); } diff --git a/Modules/Registration/Common/test/itkMatchCardinalityImageToImageMetricTest.cxx b/Modules/Registration/Common/test/itkMatchCardinalityImageToImageMetricTest.cxx index 1bb9e01785a..effb5382d0a 100644 --- a/Modules/Registration/Common/test/itkMatchCardinalityImageToImageMetricTest.cxx +++ b/Modules/Registration/Common/test/itkMatchCardinalityImageToImageMetricTest.cxx @@ -84,7 +84,7 @@ itkMatchCardinalityImageToImageMetricTest(int argc, char * argv[]) } std::cout << "Now measure mismatches..." << std::endl; - bool measureMatches = false; + const bool measureMatches = false; ITK_TEST_SET_GET_BOOLEAN(metric, MeasureMatches, measureMatches); for (float x = -200.0; x <= 200.0; x += 50.0) @@ -107,11 +107,11 @@ itkMatchCardinalityImageToImageMetricTest(int argc, char * argv[]) } - MetricType::ParametersType parameters = transform->GetParameters(); - MetricType::DerivativeType derivative; + const MetricType::ParametersType parameters = transform->GetParameters(); + MetricType::DerivativeType derivative; metric->GetDerivative(parameters, derivative); - MetricType::DerivativeType derivative1{}; + const MetricType::DerivativeType derivative1{}; ITK_TEST_EXPECT_EQUAL(derivative, derivative1); return EXIT_SUCCESS; diff --git a/Modules/Registration/Common/test/itkMattesMutualInformationImageToImageMetricTest.cxx b/Modules/Registration/Common/test/itkMattesMutualInformationImageToImageMetricTest.cxx index 6494ea897b2..feddd4a254d 100644 --- a/Modules/Registration/Common/test/itkMattesMutualInformationImageToImageMetricTest.cxx +++ b/Modules/Registration/Common/test/itkMattesMutualInformationImageToImageMetricTest.cxx @@ -210,7 +210,7 @@ TestMattesMetricWithAffineTransform(TInterpolator * interpolator, metric->SetMovingImage(imgMoving); // set the number of histogram bins - itk::SizeValueType numberOfHistogramBins = 50; + const itk::SizeValueType numberOfHistogramBins = 50; metric->SetNumberOfHistogramBins(numberOfHistogramBins); ITK_TEST_SET_GET_VALUE(numberOfHistogramBins, metric->GetNumberOfHistogramBins()); @@ -270,8 +270,8 @@ TestMattesMetricWithAffineTransform(TInterpolator * interpolator, metric->SetFixedImageMask(soFixedMask); // Make the mask const to enhance code coverage - typename ImageMaskSpatialObjectType::ConstPointer soMovingConstMask = soMovingMask; - typename ImageMaskSpatialObjectType::ConstPointer soFixedConstMask = soFixedMask; + const typename ImageMaskSpatialObjectType::ConstPointer soMovingConstMask = soMovingMask; + const typename ImageMaskSpatialObjectType::ConstPointer soFixedConstMask = soFixedMask; metric->SetMovingImageMask(soMovingConstMask); metric->SetFixedImageMask(soFixedConstMask); @@ -300,8 +300,8 @@ TestMattesMetricWithAffineTransform(TInterpolator * interpolator, //------------------------------------------------------------ // Set up an affine transform parameters //------------------------------------------------------------ - unsigned int numberOfParameters = transformer->GetNumberOfParameters(); - ParametersType parameters(numberOfParameters); + const unsigned int numberOfParameters = transformer->GetNumberOfParameters(); + ParametersType parameters(numberOfParameters); // set the parameters to the identity unsigned long count = 0; @@ -341,7 +341,7 @@ TestMattesMetricWithAffineTransform(TInterpolator * interpolator, { parameters[4] = trans; metric->GetValueAndDerivative(parameters, measure, derivative); - typename MetricType::MeasureType measure2 = metric->GetValue(parameters); + const typename MetricType::MeasureType measure2 = metric->GetValue(parameters); std::cout << trans << '\t' << measure << '\t' << measure2 << '\t' << derivative[4] << std::endl; @@ -360,7 +360,7 @@ TestMattesMetricWithAffineTransform(TInterpolator * interpolator, typename MetricType::MeasureType measurePlus; typename MetricType::MeasureType measureMinus; - double delta = 0.001; + const double delta = 0.001; bool testFailed = false; @@ -384,8 +384,8 @@ TestMattesMetricWithAffineTransform(TInterpolator * interpolator, measurePlus = metric->GetValue(parametersPlus); measureMinus = metric->GetValue(parametersMinus); - double approxDerivative = (measurePlus - measureMinus) / (2 * delta); - double ratio = derivative[i] / approxDerivative; + const double approxDerivative = (measurePlus - measureMinus) / (2 * delta); + const double ratio = derivative[i] / approxDerivative; std::cout << i << '\t'; std::cout << parameters[i] << '\t'; @@ -458,9 +458,9 @@ TestMattesMetricWithBSplineTransform(TInterpolator * interpolator, ImageDimension = MovingImageType::ImageDimension }; - typename MovingImageType::SizeType size = { { 100, 100 } }; - typename MovingImageType::IndexType index = { { 0, 0 } }; - typename MovingImageType::RegionType region{ index, size }; + const typename MovingImageType::SizeType size = { { 100, 100 } }; + const typename MovingImageType::IndexType index = { { 0, 0 } }; + const typename MovingImageType::RegionType region{ index, size }; typename MovingImageType::SpacingType imgSpacing; imgSpacing[0] = 1.5; @@ -590,8 +590,8 @@ TestMattesMetricWithBSplineTransform(TInterpolator * interpolator, //------------------------------------------------------------ // Set up a B-spline deformable transform parameters //------------------------------------------------------------ - unsigned int numberOfParameters = transformer->GetNumberOfParameters(); - ParametersType parameters(numberOfParameters); + const unsigned int numberOfParameters = transformer->GetNumberOfParameters(); + ParametersType parameters(numberOfParameters); parameters.Fill(0.0); //--------------------------------------------------------- @@ -600,7 +600,7 @@ TestMattesMetricWithBSplineTransform(TInterpolator * interpolator, //--------------------------------------------------------- typename MetricType::DerivativeType derivative(numberOfParameters); - unsigned int q = numberOfParameters / 4; + const unsigned int q = numberOfParameters / 4; std::cout << "q = " << q << std::endl; std::cout << "param[q]\tMI\tMI2\tdMI/dparam[q]" << std::endl; @@ -611,7 +611,7 @@ TestMattesMetricWithBSplineTransform(TInterpolator * interpolator, parameters.Fill(trans); typename MetricType::MeasureType measure; metric->GetValueAndDerivative(parameters, measure, derivative); - typename MetricType::MeasureType measure2 = metric->GetValue(parameters); + const typename MetricType::MeasureType measure2 = metric->GetValue(parameters); std::cout << trans << '\t' << measure << '\t' << measure2 << '\t' << derivative[q] << std::endl; @@ -632,7 +632,7 @@ TestMattesMetricWithBSplineTransform(TInterpolator * interpolator, typename MetricType::MeasureType measurePlus; typename MetricType::MeasureType measureMinus; - double delta = 0.1 * imgSpacing[0]; + const double delta = 0.1 * imgSpacing[0]; bool testFailed = false; @@ -666,8 +666,8 @@ TestMattesMetricWithBSplineTransform(TInterpolator * interpolator, { continue; } - double approxDerivative = (measurePlus - measureMinus) / (2 * delta); - double ratio = derivative[i] / approxDerivative; + const double approxDerivative = (measurePlus - measureMinus) / (2 * delta); + const double ratio = derivative[i] / approxDerivative; std::cout << i << '\t'; std::cout << parameters[i] << '\t'; diff --git a/Modules/Registration/Common/test/itkMeanReciprocalSquareDifferenceImageMetricTest.cxx b/Modules/Registration/Common/test/itkMeanReciprocalSquareDifferenceImageMetricTest.cxx index 642bfcf01a8..43f54c0e627 100644 --- a/Modules/Registration/Common/test/itkMeanReciprocalSquareDifferenceImageMetricTest.cxx +++ b/Modules/Registration/Common/test/itkMeanReciprocalSquareDifferenceImageMetricTest.cxx @@ -40,7 +40,7 @@ itkMeanReciprocalSquareDifferenceImageMetricTest(int, char *[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); //------------------------------------------------------------ // Create two simple images @@ -67,8 +67,8 @@ itkMeanReciprocalSquareDifferenceImageMetricTest(int, char *[]) FixedImageType::SpacingValueType fixedImageSpacing[] = { 1.0f, 1.0f }; MovingImageType::SpacingValueType movingImageSpacing[] = { 1.0f, 1.0f }; - FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; - MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; + const FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; + const MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; auto movingImageSource = MovingImageSourceType::New(); auto fixedImageSource = FixedImageSourceType::New(); @@ -88,8 +88,8 @@ itkMeanReciprocalSquareDifferenceImageMetricTest(int, char *[]) movingImageSource->Update(); // Force the filter to run fixedImageSource->Update(); // Force the filter to run - MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); - FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); + const MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); //----------------------------------------------------------- @@ -146,11 +146,11 @@ itkMeanReciprocalSquareDifferenceImageMetricTest(int, char *[]) // The lambda value is the intensity difference that should // make the metric drop by 50% //------------------------------------------------------------ - double lambda = 10.0; + const double lambda = 10.0; metric->SetLambda(lambda); ITK_TEST_SET_GET_VALUE(lambda, metric->GetLambda()); - double delta = 0.00011; + const double delta = 0.00011; metric->SetDelta(delta); ITK_TEST_SET_GET_VALUE(delta, metric->GetDelta()); diff --git a/Modules/Registration/Common/test/itkMeanReciprocalSquareDifferencePointSetToImageMetricTest.cxx b/Modules/Registration/Common/test/itkMeanReciprocalSquareDifferencePointSetToImageMetricTest.cxx index eede9df8bb7..e35983312ed 100644 --- a/Modules/Registration/Common/test/itkMeanReciprocalSquareDifferencePointSetToImageMetricTest.cxx +++ b/Modules/Registration/Common/test/itkMeanReciprocalSquareDifferencePointSetToImageMetricTest.cxx @@ -41,7 +41,7 @@ itkMeanReciprocalSquareDifferencePointSetToImageMetricTest(int, char *[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); //------------------------------------------------------------ // Create two simple images @@ -68,8 +68,8 @@ itkMeanReciprocalSquareDifferencePointSetToImageMetricTest(int, char *[]) FixedImageType::SpacingValueType fixedImageSpacing[] = { 1.0f, 1.0f }; MovingImageType::SpacingValueType movingImageSpacing[] = { 1.0f, 1.0f }; - FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; - MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; + const FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; + const MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; auto movingImageSource = MovingImageSourceType::New(); auto fixedImageSource = FixedImageSourceType::New(); @@ -89,8 +89,8 @@ itkMeanReciprocalSquareDifferencePointSetToImageMetricTest(int, char *[]) movingImageSource->Update(); // Force the filter to run fixedImageSource->Update(); // Force the filter to run - MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); - FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); + const MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); //----------------------------------------------------------- // Create the point set and load it with data by sampling @@ -136,8 +136,8 @@ itkMeanReciprocalSquareDifferencePointSetToImageMetricTest(int, char *[]) } // print the points accessed via iterator - FixedPointSetType::PointsContainer::ConstIterator pointItr = fixedPointSet->GetPoints()->Begin(); - FixedPointSetType::PointsContainer::ConstIterator pointEnd = fixedPointSet->GetPoints()->End(); + FixedPointSetType::PointsContainer::ConstIterator pointItr = fixedPointSet->GetPoints()->Begin(); + const FixedPointSetType::PointsContainer::ConstIterator pointEnd = fixedPointSet->GetPoints()->End(); while (pointItr != pointEnd) { std::cout << pointItr.Value() << std::endl; @@ -157,7 +157,7 @@ itkMeanReciprocalSquareDifferencePointSetToImageMetricTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(metric, MeanReciprocalSquareDifferencePointSetToImageMetric, PointSetToImageMetric); - double lambda = 1.0; + const double lambda = 1.0; metric->SetLambda(lambda); ITK_TEST_SET_GET_VALUE(lambda, metric->GetLambda()); diff --git a/Modules/Registration/Common/test/itkMeanSquaresHistogramImageToImageMetricTest.cxx b/Modules/Registration/Common/test/itkMeanSquaresHistogramImageToImageMetricTest.cxx index 2933313f1df..bbc9884d9b6 100644 --- a/Modules/Registration/Common/test/itkMeanSquaresHistogramImageToImageMetricTest.cxx +++ b/Modules/Registration/Common/test/itkMeanSquaresHistogramImageToImageMetricTest.cxx @@ -50,8 +50,8 @@ itkMeanSquaresHistogramImageToImageMetricTest(int, char *[]) FixedImageType::SpacingValueType fixedImageSpacing[] = { 1.0f, 1.0f }; MovingImageType::SpacingValueType movingImageSpacing[] = { 1.0f, 1.0f }; - FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; - MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; + const FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; + const MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; auto movingImageSource = MovingImageSourceType::New(); auto fixedImageSource = FixedImageSourceType::New(); @@ -71,8 +71,8 @@ itkMeanSquaresHistogramImageToImageMetricTest(int, char *[]) movingImageSource->Update(); // Force the filter to run fixedImageSource->Update(); // Force the filter to run - MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); - FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); + const MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); // Set up the metric. using MetricType = itk::MeanSquaresHistogramImageToImageMetric; @@ -82,7 +82,7 @@ itkMeanSquaresHistogramImageToImageMetricTest(int, char *[]) auto metric = MetricType::New(); - unsigned int nBins = 256; + const unsigned int nBins = 256; MetricType::HistogramType::SizeType histSize; histSize.SetSize(2); histSize[0] = nBins; @@ -133,8 +133,8 @@ itkMeanSquaresHistogramImageToImageMetricTest(int, char *[]) metric->Initialize(); // Print out metric value and derivative. - MetricType::MeasureType measure = metric->GetValue(parameters); - MetricType::DerivativeType derivative; + const MetricType::MeasureType measure = metric->GetValue(parameters); + MetricType::DerivativeType derivative; metric->GetDerivative(parameters, derivative); std::cout << "Metric value = " << measure << std::endl << "Derivative = " << derivative << std::endl; diff --git a/Modules/Registration/Common/test/itkMeanSquaresImageMetricTest.cxx b/Modules/Registration/Common/test/itkMeanSquaresImageMetricTest.cxx index 7e56033480c..93421272d0b 100644 --- a/Modules/Registration/Common/test/itkMeanSquaresImageMetricTest.cxx +++ b/Modules/Registration/Common/test/itkMeanSquaresImageMetricTest.cxx @@ -39,7 +39,7 @@ itkMeanSquaresImageMetricTest(int, char *[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); //------------------------------------------------------------ // Create two simple images @@ -66,8 +66,8 @@ itkMeanSquaresImageMetricTest(int, char *[]) FixedImageType::SpacingValueType fixedImageSpacing[] = { 1.0f, 1.0f }; MovingImageType::SpacingValueType movingImageSpacing[] = { 1.0f, 1.0f }; - FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; - MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; + const FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; + const MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; auto movingImageSource = MovingImageSourceType::New(); auto fixedImageSource = FixedImageSourceType::New(); @@ -87,8 +87,8 @@ itkMeanSquaresImageMetricTest(int, char *[]) movingImageSource->Update(); // Force the filter to run fixedImageSource->Update(); // Force the filter to run - MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); - FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); + const MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); //----------------------------------------------------------- diff --git a/Modules/Registration/Common/test/itkMeanSquaresPointSetToImageMetricTest.cxx b/Modules/Registration/Common/test/itkMeanSquaresPointSetToImageMetricTest.cxx index e29e935ff4b..8e787698685 100644 --- a/Modules/Registration/Common/test/itkMeanSquaresPointSetToImageMetricTest.cxx +++ b/Modules/Registration/Common/test/itkMeanSquaresPointSetToImageMetricTest.cxx @@ -40,7 +40,7 @@ itkMeanSquaresPointSetToImageMetricTest(int, char *[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); //------------------------------------------------------------ // Create two simple images @@ -67,8 +67,8 @@ itkMeanSquaresPointSetToImageMetricTest(int, char *[]) FixedImageType::SpacingValueType fixedImageSpacing[] = { 1.0f, 1.0f }; MovingImageType::SpacingValueType movingImageSpacing[] = { 1.0f, 1.0f }; - FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; - MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; + const FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; + const MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; auto movingImageSource = MovingImageSourceType::New(); auto fixedImageSource = FixedImageSourceType::New(); @@ -88,8 +88,8 @@ itkMeanSquaresPointSetToImageMetricTest(int, char *[]) movingImageSource->Update(); // Force the filter to run fixedImageSource->Update(); // Force the filter to run - MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); - FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); + const MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); //----------------------------------------------------------- // Create the point set and load it with data by sampling @@ -135,8 +135,8 @@ itkMeanSquaresPointSetToImageMetricTest(int, char *[]) } // print the points accessed via iterator - FixedPointSetType::PointsContainer::ConstIterator pointItr = fixedPointSet->GetPoints()->Begin(); - FixedPointSetType::PointsContainer::ConstIterator pointEnd = fixedPointSet->GetPoints()->End(); + FixedPointSetType::PointsContainer::ConstIterator pointItr = fixedPointSet->GetPoints()->Begin(); + const FixedPointSetType::PointsContainer::ConstIterator pointEnd = fixedPointSet->GetPoints()->End(); while (pointItr != pointEnd) { std::cout << pointItr.Value() << std::endl; diff --git a/Modules/Registration/Common/test/itkMultiResolutionImageRegistrationMethodTest.cxx b/Modules/Registration/Common/test/itkMultiResolutionImageRegistrationMethodTest.cxx index aba7583331b..ec4196bb861 100644 --- a/Modules/Registration/Common/test/itkMultiResolutionImageRegistrationMethodTest.cxx +++ b/Modules/Registration/Common/test/itkMultiResolutionImageRegistrationMethodTest.cxx @@ -88,7 +88,7 @@ itkMultiResolutionImageRegistrationMethodTest(int, char *[]) auto size = FixedImageType::SizeType::Filled(8); - FixedImageType::RegionType region(size); + const FixedImageType::RegionType region(size); fixedImage->SetRegions(region); fixedImage->Allocate(); fixedImage->FillBuffer(3.0); @@ -124,7 +124,7 @@ itkMultiResolutionImageRegistrationMethodTest(int, char *[]) registration->SetFixedImageRegion(fixedImage->GetBufferedRegion()); ITK_TEST_SET_GET_VALUE(fixedImage->GetBufferedRegion(), registration->GetFixedImageRegion()); - itk::SizeValueType numberOfLevels = 2; + const itk::SizeValueType numberOfLevels = 2; registration->SetNumberOfLevels(numberOfLevels); ITK_TEST_SET_GET_VALUE(numberOfLevels, registration->GetNumberOfLevels()); @@ -134,8 +134,8 @@ itkMultiResolutionImageRegistrationMethodTest(int, char *[]) registration->SetInitialTransformParameters(initialParameters); ITK_TEST_SET_GET_VALUE(initialParameters, registration->GetInitialTransformParameters()); - typename ParametersType::ValueType initialTransformParametersOfNextLevelVal(0.0); - ParametersType initialTransformParametersOfNextLevel(1, initialTransformParametersOfNextLevelVal); + const typename ParametersType::ValueType initialTransformParametersOfNextLevelVal(0.0); + const ParametersType initialTransformParametersOfNextLevel(1, initialTransformParametersOfNextLevelVal); registration->SetInitialTransformParametersOfNextLevel(initialTransformParametersOfNextLevel); ITK_TEST_SET_GET_VALUE(initialTransformParametersOfNextLevel, registration->GetInitialTransformParametersOfNextLevel()); diff --git a/Modules/Registration/Common/test/itkMultiResolutionImageRegistrationMethodTest_1.cxx b/Modules/Registration/Common/test/itkMultiResolutionImageRegistrationMethodTest_1.cxx index 5d35f3fc675..6a5713a8d8d 100644 --- a/Modules/Registration/Common/test/itkMultiResolutionImageRegistrationMethodTest_1.cxx +++ b/Modules/Registration/Common/test/itkMultiResolutionImageRegistrationMethodTest_1.cxx @@ -118,12 +118,12 @@ itkMultiResolutionImageRegistrationMethodTest_1(int, char *[]) auto fixedImage = FixedImageType::New(); auto movingImage = MovingImageType::New(); - double displacement[dimension] = { 7, 3, 2 }; - double scale[dimension] = { 0.80, 1.0, 1.0 }; + const double displacement[dimension] = { 7, 3, 2 }; + const double scale[dimension] = { 0.80, 1.0, 1.0 }; - FixedImageType::SizeType size = { { 100, 100, 40 } }; - FixedImageType::IndexType index = { { 0, 0, 0 } }; - FixedImageType::RegionType region{ index, size }; + FixedImageType::SizeType size = { { 100, 100, 40 } }; + const FixedImageType::IndexType index = { { 0, 0, 0 } }; + const FixedImageType::RegionType region{ index, size }; fixedImage->SetRegions(region); fixedImage->Allocate(); @@ -249,7 +249,7 @@ itkMultiResolutionImageRegistrationMethodTest_1(int, char *[]) ******************************************************************/ SimpleMultiResolutionImageRegistrationUI2 simpleUI(registration); - unsigned short numberOfLevels = 3; + const unsigned short numberOfLevels = 3; itk::Array niter(numberOfLevels); itk::Array rates(numberOfLevels); @@ -329,7 +329,7 @@ itkMultiResolutionImageRegistrationMethodTest_1(int, char *[]) /************************************************* * Check for parzen window exception **************************************************/ - double oldValue = metric->GetMovingImageStandardDeviation(); + const double oldValue = metric->GetMovingImageStandardDeviation(); metric->SetMovingImageStandardDeviation(0.005); try @@ -473,7 +473,7 @@ itkMultiResolutionImageRegistrationMethodTest_1(int, char *[]) ******************************************************************/ SimpleMultiResolutionImageRegistrationUI2 simpleUI(registration); - unsigned short numberOfLevels = 3; + const unsigned short numberOfLevels = 3; itk::Array niter(numberOfLevels); itk::Array rates(numberOfLevels); @@ -571,7 +571,7 @@ F(itk::Vector & v) x -= 8; y += 3; z += 0; - double r = std::sqrt(x * x + y * y + z * z); + const double r = std::sqrt(x * x + y * y + z * z); if (r > 35) { value = 2 * (itk::Math::abs(x) + 0.8 * itk::Math::abs(y) + 0.5 * itk::Math::abs(z)); diff --git a/Modules/Registration/Common/test/itkMultiResolutionImageRegistrationMethodTest_2.cxx b/Modules/Registration/Common/test/itkMultiResolutionImageRegistrationMethodTest_2.cxx index 052272c40cc..1e69aa12688 100644 --- a/Modules/Registration/Common/test/itkMultiResolutionImageRegistrationMethodTest_2.cxx +++ b/Modules/Registration/Common/test/itkMultiResolutionImageRegistrationMethodTest_2.cxx @@ -114,12 +114,12 @@ itkMultiResolutionImageRegistrationMethodTest_2(int, char *[]) * Set up the two input images. * One image rotated (xy plane) and shifted with respect to the other. **********************************************************/ - double displacement[dimension] = { 7, 3, 2 }; - double angle = 10.0 / 180.0 * itk::Math::pi; + const double displacement[dimension] = { 7, 3, 2 }; + const double angle = 10.0 / 180.0 * itk::Math::pi; - FixedImageType::SizeType size = { { 100, 100, 40 } }; - FixedImageType::IndexType index = { { 0, 0, 0 } }; - FixedImageType::RegionType region{ index, size }; + FixedImageType::SizeType size = { { 100, 100, 40 } }; + const FixedImageType::IndexType index = { { 0, 0, 0 } }; + const FixedImageType::RegionType region{ index, size }; fixedImage->SetRegions(region); fixedImage->Allocate(); @@ -239,7 +239,7 @@ itkMultiResolutionImageRegistrationMethodTest_2(int, char *[]) ******************************************************************/ SimpleMultiResolutionImageRegistrationUI2 simpleUI(registration); - unsigned short numberOfLevels = 3; + const unsigned short numberOfLevels = 3; itk::Array niter(numberOfLevels); niter[0] = 300; @@ -311,7 +311,7 @@ itkMultiResolutionImageRegistrationMethodTest_2(int, char *[]) /************************************************* * Check for parzen window exception **************************************************/ - double oldValue = metric->GetMovingImageStandardDeviation(); + const double oldValue = metric->GetMovingImageStandardDeviation(); metric->SetMovingImageStandardDeviation(0.005); try @@ -385,7 +385,7 @@ F(itk::Vector & v) x -= 8; y += 3; z += 0; - double r = std::sqrt(x * x + y * y + z * z); + const double r = std::sqrt(x * x + y * y + z * z); if (r > 35) { value = 2 * (itk::Math::abs(x) + 0.8 * itk::Math::abs(y) + 0.5 * itk::Math::abs(z)); diff --git a/Modules/Registration/Common/test/itkMultiResolutionPyramidImageFilterTest.cxx b/Modules/Registration/Common/test/itkMultiResolutionPyramidImageFilterTest.cxx index 18d25f09759..8cf6a13c31c 100644 --- a/Modules/Registration/Common/test/itkMultiResolutionPyramidImageFilterTest.cxx +++ b/Modules/Registration/Common/test/itkMultiResolutionPyramidImageFilterTest.cxx @@ -37,7 +37,7 @@ F(double x, double y, double z) x -= 8; y += 3; z += 0; - double r = std::sqrt(x * x + y * y + z * z); + const double r = std::sqrt(x * x + y * y + z * z); if (r > 35) { value = 2 * (itk::Math::abs(x) + 0.8 * itk::Math::abs(y) + 0.5 * itk::Math::abs(z)); @@ -105,7 +105,7 @@ itkMultiResolutionPyramidImageFilterTest(int argc, char * argv[]) bool useShrinkFilter(false); if (argc > 1) { - std::string s(argv[1]); + const std::string s(argv[1]); std::cout << "useShrinkFilter "; if (s == "Shrink") { @@ -121,7 +121,7 @@ itkMultiResolutionPyramidImageFilterTest(int argc, char * argv[]) bool TestRecursive(false); if (argc > 2) { - std::string s(argv[2]); + const std::string s(argv[2]); if (s == "TestRecursive") { TestRecursive = true; @@ -133,9 +133,9 @@ itkMultiResolutionPyramidImageFilterTest(int argc, char * argv[]) // When shrink factors are not divisible, this still does // a best does the best possible job. // InputImageType::SizeType size = {{101,101,41}}; - InputImageType::SizeType size = { { 128, 132, 48 } }; - InputImageType::IndexType index = { { 0, 0, 0 } }; - InputImageType::RegionType region{ index, size }; + InputImageType::SizeType size = { { 128, 132, 48 } }; + const InputImageType::IndexType index = { { 0, 0, 0 } }; + const InputImageType::RegionType region{ index, size }; InputImageType::SpacingType spacing; spacing[0] = 0.5; @@ -225,7 +225,7 @@ itkMultiResolutionPyramidImageFilterTest(int argc, char * argv[]) for (unsigned int k = 0; k < numLevels; ++k) { - unsigned int denominator = 1 << k; + const unsigned int denominator = 1 << k; for (unsigned int j = 0; j < ImageDimension; ++j) { schedule[k][j] = factors[j] / denominator; @@ -257,7 +257,7 @@ itkMultiResolutionPyramidImageFilterTest(int argc, char * argv[]) schedule = ScheduleType(numLevels, ImageDimension, 0); for (unsigned int k = 0; k < numLevels; ++k) { - unsigned int denominator = 1 << k; + const unsigned int denominator = 1 << k; for (unsigned int j = 0; j < ImageDimension; ++j) { schedule[k][j] = factors[j] / denominator; @@ -315,7 +315,7 @@ itkMultiResolutionPyramidImageFilterTest(int argc, char * argv[]) InputImageType::SizeType inputSize = pyramid->GetInput()->GetLargestPossibleRegion().GetSize(); // const InputImageType::PointType& inputOrigin = // pyramid->GetInput()->GetOrigin(); - OutputImageType::PointType InputCenterOfMass = GetCenterOfMass(pyramid->GetInput()); + const OutputImageType::PointType InputCenterOfMass = GetCenterOfMass(pyramid->GetInput()); const InputImageType::SpacingType & inputSpacing = pyramid->GetInput()->GetSpacing(); OutputImageType::SizeType outputSize = pyramid->GetOutput(testLevel)->GetLargestPossibleRegion().GetSize(); @@ -324,7 +324,8 @@ itkMultiResolutionPyramidImageFilterTest(int argc, char * argv[]) const OutputImageType::SpacingType & outputSpacing = pyramid->GetOutput(testLevel)->GetSpacing(); - OutputImageType::PointType OutputCenterOfMass = GetCenterOfMass(pyramid->GetOutput(testLevel)); + const OutputImageType::PointType OutputCenterOfMass = + GetCenterOfMass(pyramid->GetOutput(testLevel)); // NOTE: Origins can not be preserved if the objects physical spaces are to be preserved! // The image center of physical space is what really needs to be preserved across // the different scales. @@ -335,9 +336,9 @@ itkMultiResolutionPyramidImageFilterTest(int argc, char * argv[]) // std::cout << "TEST: "<< j<< ' ' << OutputCenterOfMass << " != " << InputCenterOfMass << std::endl; // if( OutputCenterOfMass != InputCenterOfMass ) { - OutputImageType::PointType::VectorType ErrorCenterOfMass = OutputCenterOfMass - InputCenterOfMass; - constexpr double CenterOfMassEpsilonAllowed = 0.001; - const double ErrorPercentage = + const OutputImageType::PointType::VectorType ErrorCenterOfMass = OutputCenterOfMass - InputCenterOfMass; + constexpr double CenterOfMassEpsilonAllowed = 0.001; + const double ErrorPercentage = (ErrorCenterOfMass.GetNorm() / pyramid->GetOutput(testLevel)->GetSpacing().GetNorm()); if (ErrorPercentage > CenterOfMassEpsilonAllowed) { diff --git a/Modules/Registration/Common/test/itkMutualInformationHistogramImageToImageMetricTest.cxx b/Modules/Registration/Common/test/itkMutualInformationHistogramImageToImageMetricTest.cxx index cb9ede77e0b..faa890e5e34 100644 --- a/Modules/Registration/Common/test/itkMutualInformationHistogramImageToImageMetricTest.cxx +++ b/Modules/Registration/Common/test/itkMutualInformationHistogramImageToImageMetricTest.cxx @@ -49,8 +49,8 @@ itkMutualInformationHistogramImageToImageMetricTest(int, char *[]) FixedImageType::SpacingValueType fixedImageSpacing[] = { 1.0f, 1.0f }; MovingImageType::SpacingValueType movingImageSpacing[] = { 1.0f, 1.0f }; - FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; - MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; + const FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; + const MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; auto movingImageSource = MovingImageSourceType::New(); auto fixedImageSource = FixedImageSourceType::New(); @@ -70,8 +70,8 @@ itkMutualInformationHistogramImageToImageMetricTest(int, char *[]) movingImageSource->Update(); // Force the filter to run fixedImageSource->Update(); // Force the filter to run - MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); - FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); + const MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); // Set up the metric. using MetricType = itk::MutualInformationHistogramImageToImageMetric; @@ -81,7 +81,7 @@ itkMutualInformationHistogramImageToImageMetricTest(int, char *[]) auto metric = MetricType::New(); - unsigned int nBins = 256; + const unsigned int nBins = 256; MetricType::HistogramType::SizeType histSize; histSize.SetSize(2); histSize[0] = nBins; @@ -132,8 +132,8 @@ itkMutualInformationHistogramImageToImageMetricTest(int, char *[]) metric->Initialize(); // Print out metric value and derivative. - MetricType::MeasureType measure = metric->GetValue(parameters); - MetricType::DerivativeType derivative; + const MetricType::MeasureType measure = metric->GetValue(parameters); + MetricType::DerivativeType derivative; metric->GetDerivative(parameters, derivative); std::cout << "Metric value = " << measure << std::endl << "Derivative = " << derivative << std::endl; diff --git a/Modules/Registration/Common/test/itkMutualInformationMetricTest.cxx b/Modules/Registration/Common/test/itkMutualInformationMetricTest.cxx index afa0b84cbfb..a0ca10f8ebb 100644 --- a/Modules/Registration/Common/test/itkMutualInformationMetricTest.cxx +++ b/Modules/Registration/Common/test/itkMutualInformationMetricTest.cxx @@ -48,9 +48,9 @@ itkMutualInformationMetricTest(int, char *[]) ImageDimension = MovingImageType::ImageDimension }; - MovingImageType::SizeType size = { { 100, 100 } }; - MovingImageType::IndexType index = { { 0, 0 } }; - MovingImageType::RegionType region{ index, size }; + const MovingImageType::SizeType size = { { 100, 100 } }; + const MovingImageType::IndexType index = { { 0, 0 } }; + const MovingImageType::RegionType region{ index, size }; auto imgMoving = MovingImageType::New(); imgMoving->SetRegions(region); @@ -154,8 +154,8 @@ itkMutualInformationMetricTest(int, char *[]) //------------------------------------------------------------ // Set up an affine transform parameters //------------------------------------------------------------ - unsigned int numberOfParameters = transformer->GetNumberOfParameters(); - ParametersType parameters(numberOfParameters); + const unsigned int numberOfParameters = transformer->GetNumberOfParameters(); + ParametersType parameters(numberOfParameters); // set the parameters to the identity unsigned long count = 0; @@ -219,7 +219,7 @@ itkMutualInformationMetricTest(int, char *[]) metric->Print(std::cout); - itk::KernelFunctionBase::Pointer theKernel = metric->GetModifiableKernelFunction(); + const itk::KernelFunctionBase::Pointer theKernel = metric->GetModifiableKernelFunction(); metric->SetKernelFunction(theKernel); theKernel->Print(std::cout); diff --git a/Modules/Registration/Common/test/itkNormalizedCorrelationImageMetricTest.cxx b/Modules/Registration/Common/test/itkNormalizedCorrelationImageMetricTest.cxx index 4fe8b050f0a..8911a14f351 100644 --- a/Modules/Registration/Common/test/itkNormalizedCorrelationImageMetricTest.cxx +++ b/Modules/Registration/Common/test/itkNormalizedCorrelationImageMetricTest.cxx @@ -40,7 +40,7 @@ itkNormalizedCorrelationImageMetricTest(int, char *[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); //------------------------------------------------------------ // Create two simple images @@ -67,8 +67,8 @@ itkNormalizedCorrelationImageMetricTest(int, char *[]) FixedImageType::SpacingValueType fixedImageSpacing[] = { 1.0f, 1.0f }; MovingImageType::SpacingValueType movingImageSpacing[] = { 1.0f, 1.0f }; - FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; - MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; + const FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; + const MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; auto movingImageSource = MovingImageSourceType::New(); auto fixedImageSource = FixedImageSourceType::New(); @@ -88,8 +88,8 @@ itkNormalizedCorrelationImageMetricTest(int, char *[]) movingImageSource->Update(); // Force the filter to run fixedImageSource->Update(); // Force the filter to run - MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); - FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); + const MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); //----------------------------------------------------------- @@ -182,7 +182,7 @@ itkNormalizedCorrelationImageMetricTest(int, char *[]) std::cout << "param[1] Metric d(Metric)/d(param[1] " << std::endl; - bool subtractMean = true; + const bool subtractMean = true; ITK_TEST_SET_GET_BOOLEAN(metric, SubtractMean, subtractMean); for (double trans = -10; trans <= 5; trans += 0.2) diff --git a/Modules/Registration/Common/test/itkNormalizedCorrelationPointSetToImageMetricTest.cxx b/Modules/Registration/Common/test/itkNormalizedCorrelationPointSetToImageMetricTest.cxx index 2e85c66dca4..f3411197234 100644 --- a/Modules/Registration/Common/test/itkNormalizedCorrelationPointSetToImageMetricTest.cxx +++ b/Modules/Registration/Common/test/itkNormalizedCorrelationPointSetToImageMetricTest.cxx @@ -41,7 +41,7 @@ itkNormalizedCorrelationPointSetToImageMetricTest(int, char *[]) // Save the format stream variables for std::cout // They will be restored when coutState goes out of scope - itk::StdStreamStateSave coutState(std::cout); + const itk::StdStreamStateSave coutState(std::cout); //------------------------------------------------------------ // Create two simple images @@ -68,8 +68,8 @@ itkNormalizedCorrelationPointSetToImageMetricTest(int, char *[]) FixedImageType::SpacingValueType fixedImageSpacing[] = { 1.0f, 1.0f }; MovingImageType::SpacingValueType movingImageSpacing[] = { 1.0f, 1.0f }; - FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; - MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; + const FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; + const MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; auto movingImageSource = MovingImageSourceType::New(); auto fixedImageSource = FixedImageSourceType::New(); @@ -89,8 +89,8 @@ itkNormalizedCorrelationPointSetToImageMetricTest(int, char *[]) movingImageSource->Update(); // Force the filter to run fixedImageSource->Update(); // Force the filter to run - MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); - FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); + const MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); //----------------------------------------------------------- // Create the point set and load it with data by sampling @@ -219,7 +219,7 @@ itkNormalizedCorrelationPointSetToImageMetricTest(int, char *[]) std::cout << "param[1] Metric d(Metric)/d(param[1] " << std::endl; - bool subtractMean = true; + const bool subtractMean = true; ITK_TEST_SET_GET_BOOLEAN(metric, SubtractMean, subtractMean); parameters[1] = -10.2; diff --git a/Modules/Registration/Common/test/itkNormalizedMutualInformationHistogramImageToImageMetricTest.cxx b/Modules/Registration/Common/test/itkNormalizedMutualInformationHistogramImageToImageMetricTest.cxx index e66057ebcf2..9818c166236 100644 --- a/Modules/Registration/Common/test/itkNormalizedMutualInformationHistogramImageToImageMetricTest.cxx +++ b/Modules/Registration/Common/test/itkNormalizedMutualInformationHistogramImageToImageMetricTest.cxx @@ -50,8 +50,8 @@ itkNormalizedMutualInformationHistogramImageToImageMetricTest(int, char *[]) FixedImageType::SpacingValueType fixedImageSpacing[] = { 1.0f, 1.0f }; MovingImageType::SpacingValueType movingImageSpacing[] = { 1.0f, 1.0f }; - FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; - MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; + const FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; + const MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; auto movingImageSource = MovingImageSourceType::New(); auto fixedImageSource = FixedImageSourceType::New(); @@ -71,8 +71,8 @@ itkNormalizedMutualInformationHistogramImageToImageMetricTest(int, char *[]) movingImageSource->Update(); // Force the filter to run fixedImageSource->Update(); // Force the filter to run - MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); - FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); + const MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); // Set up the metric. using MetricType = itk::NormalizedMutualInformationHistogramImageToImageMetric; @@ -82,7 +82,7 @@ itkNormalizedMutualInformationHistogramImageToImageMetricTest(int, char *[]) auto metric = MetricType::New(); - unsigned int nBins = 256; + const unsigned int nBins = 256; MetricType::HistogramType::SizeType histSize; histSize.SetSize(2); histSize[0] = nBins; @@ -133,8 +133,8 @@ itkNormalizedMutualInformationHistogramImageToImageMetricTest(int, char *[]) metric->Initialize(); // Print out metric value and derivative. - MetricType::MeasureType measure = metric->GetValue(parameters); - MetricType::DerivativeType derivative; + const MetricType::MeasureType measure = metric->GetValue(parameters); + MetricType::DerivativeType derivative; metric->GetDerivative(parameters, derivative); std::cout << "Metric value = " << measure << std::endl << "Derivative = " << derivative << std::endl; diff --git a/Modules/Registration/Common/test/itkPointSetToImageRegistrationTest.cxx b/Modules/Registration/Common/test/itkPointSetToImageRegistrationTest.cxx index 06e068f6a49..2416430354d 100644 --- a/Modules/Registration/Common/test/itkPointSetToImageRegistrationTest.cxx +++ b/Modules/Registration/Common/test/itkPointSetToImageRegistrationTest.cxx @@ -59,8 +59,8 @@ itkPointSetToImageRegistrationTest(int, char *[]) imageSource->GenerateImages(size); // Create the two images - MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); - FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); + const MovingImageType::ConstPointer movingImage = imageSource->GetMovingImage(); + const FixedImageType::ConstPointer fixedImage = imageSource->GetFixedImage(); // Create the point set and load it with data by sampling // the fixed image. @@ -142,10 +142,10 @@ itkPointSetToImageRegistrationTest(int, char *[]) OptimizerType::ScalesType scales(transform->GetNumberOfParameters()); scales.Fill(1.0); - unsigned long numberOfIterations = 50; - double maximumStepLength = 1.0; // no step will be larger than this - double minimumStepLength = 0.01; - double gradientTolerance = 1e-6; // convergence criterion + const unsigned long numberOfIterations = 50; + const double maximumStepLength = 1.0; // no step will be larger than this + const double minimumStepLength = 0.01; + const double gradientTolerance = 1e-6; // convergence criterion optimizer->SetScales(scales); optimizer->SetNumberOfIterations(numberOfIterations); diff --git a/Modules/Registration/Common/test/itkPointSetToPointSetRegistrationTest.cxx b/Modules/Registration/Common/test/itkPointSetToPointSetRegistrationTest.cxx index d2f424179fa..a9a4dc1aeaa 100644 --- a/Modules/Registration/Common/test/itkPointSetToPointSetRegistrationTest.cxx +++ b/Modules/Registration/Common/test/itkPointSetToPointSetRegistrationTest.cxx @@ -117,10 +117,10 @@ itkPointSetToPointSetRegistrationTest(int, char *[]) OptimizerType::ScalesType scales(transform->GetNumberOfParameters()); scales.Fill(1.0); - unsigned long numberOfIterations = 100; - double gradientTolerance = 1e-1; // convergence criterion - double valueTolerance = 1e-1; // convergence criterion - double epsilonFunction = 1e-9; // convergence criterion + const unsigned long numberOfIterations = 100; + const double gradientTolerance = 1e-1; // convergence criterion + const double valueTolerance = 1e-1; // convergence criterion + const double epsilonFunction = 1e-9; // convergence criterion optimizer->SetScales(scales); optimizer->SetNumberOfIterations(numberOfIterations); @@ -207,7 +207,7 @@ itkPointSetToPointSetRegistrationTest(int, char *[]) ITK_TRY_EXPECT_NO_EXCEPTION(psToImageFilter->Update()); - BinaryImageType::Pointer binaryImage = psToImageFilter->GetOutput(); + const BinaryImageType::Pointer binaryImage = psToImageFilter->GetOutput(); using DDFilterType = itk::DanielssonDistanceMapImageFilter; auto ddFilter = DDFilterType::New(); @@ -217,7 +217,7 @@ itkPointSetToPointSetRegistrationTest(int, char *[]) ITK_TRY_EXPECT_NO_EXCEPTION(ddFilter->Update()); - typename DDFilterType::OutputImageType::Pointer distanceMap = ddFilter->GetOutput(); + const typename DDFilterType::OutputImageType::Pointer distanceMap = ddFilter->GetOutput(); metric->SetDistanceMap(distanceMap); ITK_TEST_SET_GET_VALUE(distanceMap, metric->GetDistanceMap()); diff --git a/Modules/Registration/Common/test/itkPointsLocatorTest.cxx b/Modules/Registration/Common/test/itkPointsLocatorTest.cxx index 57fd33fc2ac..7b825f14df1 100644 --- a/Modules/Registration/Common/test/itkPointsLocatorTest.cxx +++ b/Modules/Registration/Common/test/itkPointsLocatorTest.cxx @@ -65,7 +65,7 @@ testPointsLocatorTest() coords[1] = 50; coords[2] = 50; - typename PointsLocatorType::PointIdentifier pointId = pointsLocator->FindClosestPoint(coords); + const typename PointsLocatorType::PointIdentifier pointId = pointsLocator->FindClosestPoint(coords); if (pointId != 49) { std::cerr << "Error with FindClosestPoint(), poindId does not match" << std::endl; @@ -116,7 +116,7 @@ testPointsLocatorTest() std::cout << dist << " * " << distances[i] << std::endl; } - double radius = std::sqrt(3 * itk::Math::sqr(5.1)); + const double radius = std::sqrt(3 * itk::Math::sqr(5.1)); std::cout << "Test: FindPointsWithinRadius()" << std::endl; diff --git a/Modules/Registration/Common/test/itkRecursiveMultiResolutionPyramidImageFilterTest.cxx b/Modules/Registration/Common/test/itkRecursiveMultiResolutionPyramidImageFilterTest.cxx index d4f0d06473a..903b68fc598 100644 --- a/Modules/Registration/Common/test/itkRecursiveMultiResolutionPyramidImageFilterTest.cxx +++ b/Modules/Registration/Common/test/itkRecursiveMultiResolutionPyramidImageFilterTest.cxx @@ -37,7 +37,7 @@ F(double x, double y, double z) x -= 8; y += 3; z += 0; - double r = std::sqrt(x * x + y * y + z * z); + const double r = std::sqrt(x * x + y * y + z * z); if (r > 35) { value = 2 * (itk::Math::abs(x) + 0.8 * itk::Math::abs(y) + 0.5 * itk::Math::abs(z)); @@ -82,7 +82,7 @@ itkRecursiveMultiResolutionPyramidImageFilterTest(int argc, char * argv[]) bool useShrinkFilter(false); if (argc > 1) { - std::string s(argv[1]); + const std::string s(argv[1]); if (s == "Shrink") { useShrinkFilter = true; @@ -95,9 +95,9 @@ itkRecursiveMultiResolutionPyramidImageFilterTest(int argc, char * argv[]) std::cout << std::endl; } - InputImageType::SizeType size = { { 100, 100, 40 } }; - InputImageType::IndexType index = { { 0, 0, 0 } }; - InputImageType::RegionType region{ index, size }; + InputImageType::SizeType size = { { 100, 100, 40 } }; + const InputImageType::IndexType index = { { 0, 0, 0 } }; + const InputImageType::RegionType region{ index, size }; auto imgTarget = InputImageType::New(); imgTarget->SetRegions(region); @@ -158,7 +158,7 @@ itkRecursiveMultiResolutionPyramidImageFilterTest(int argc, char * argv[]) for (unsigned int k = 0; k < numLevels; ++k) { - unsigned int denominator = 1 << k; + const unsigned int denominator = 1 << k; for (unsigned int j = 0; j < ImageDimension; ++j) { schedule[k][j] = factors[j] / denominator; @@ -190,7 +190,7 @@ itkRecursiveMultiResolutionPyramidImageFilterTest(int argc, char * argv[]) schedule = ScheduleType(numLevels, ImageDimension); for (unsigned int k = 0; k < numLevels; ++k) { - unsigned int denominator = 1 << k; + const unsigned int denominator = 1 << k; for (unsigned int j = 0; j < ImageDimension; ++j) { schedule[k][j] = factors[j] / denominator; @@ -233,8 +233,9 @@ itkRecursiveMultiResolutionPyramidImageFilterTest(int argc, char * argv[]) std::cout << "Run RecursiveMultiResolutionPyramidImageFilter in standalone mode with progress"; std::cout << std::endl; - ShowProgressObject progressWatch(pyramid); - itk::SimpleMemberCommand::Pointer command = itk::SimpleMemberCommand::New(); + ShowProgressObject progressWatch(pyramid); + const itk::SimpleMemberCommand::Pointer command = + itk::SimpleMemberCommand::New(); command->SetCallbackFunction(&progressWatch, &ShowProgressObject::ShowProgress); pyramid->AddObserver(itk::ProgressEvent(), command); diff --git a/Modules/Registration/Metricsv4/include/itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx b/Modules/Registration/Metricsv4/include/itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx index 32adff30c33..3153c8ac435 100644 --- a/Modules/Registration/Metricsv4/include/itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx +++ b/Modules/Registration/Metricsv4/include/itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx @@ -139,7 +139,7 @@ ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader< const SizeValueType numberOfFillZero = scanParameters.numberOfFillZero; const SizeValueType hoodlen = scanParameters.windowLength; - InternalComputationValueType zero{}; + const InternalComputationValueType zero{}; scanMem.QsumFixed2 = SumQueueType(numberOfFillZero, zero); scanMem.QsumMoving2 = SumQueueType(numberOfFillZero, zero); scanMem.QsumFixed = SumQueueType(numberOfFillZero, zero); @@ -150,7 +150,7 @@ ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader< using LocalRealType = InternalComputationValueType; // Now add the rest of the values from each hyperplane - SizeValueType diameter = 2 * scanParameters.radius[0]; + const SizeValueType diameter = 2 * scanParameters.radius[0]; const LocalRealType localZero{}; for (SizeValueType i = numberOfFillZero; i < (diameter + NumericTraits::OneValue()); ++i) @@ -166,14 +166,14 @@ ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader< { typename ScanIteratorType::OffsetType internalIndex; typename ScanIteratorType::OffsetType offset; - bool isInBounds = scanIt.IndexInBounds(indct, internalIndex, offset); + const bool isInBounds = scanIt.IndexInBounds(indct, internalIndex, offset); if (!isInBounds) { // std::cout << "DEBUG: error" << std::endl; continue; } - typename VirtualImageType::IndexType index = scanIt.GetIndex(indct); + const typename VirtualImageType::IndexType index = scanIt.GetIndex(indct); VirtualPointType virtualPoint; FixedImagePointType mappedFixedPoint; @@ -244,20 +244,20 @@ ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader< LocalRealType sumFixedMoving = localZero; LocalRealType count = localZero; - SizeValueType diameter = 2 * scanParameters.radius[0]; + const SizeValueType diameter = 2 * scanParameters.radius[0]; for (SizeValueType indct = diameter; indct < hoodlen; indct += (diameter + NumericTraits::OneValue())) { typename ScanIteratorType::OffsetType internalIndex; typename ScanIteratorType::OffsetType offset; - bool isInBounds = scanIt.IndexInBounds(indct, internalIndex, offset); + const bool isInBounds = scanIt.IndexInBounds(indct, internalIndex, offset); if (!isInBounds) { continue; } - typename VirtualImageType::IndexType index = scanIt.GetIndex(indct); + const typename VirtualImageType::IndexType index = scanIt.GetIndex(indct); VirtualPointType virtualPoint; FixedImagePointType mappedFixedPoint; @@ -427,16 +427,17 @@ ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader< ++itFixedMoving; } - LocalRealType fixedMean = sumFixed / count; - LocalRealType movingMean = sumMoving / count; + const LocalRealType fixedMean = sumFixed / count; + const LocalRealType movingMean = sumMoving / count; - LocalRealType sFixedFixed = sumFixed2 - fixedMean * sumFixed - fixedMean * sumFixed + count * fixedMean * fixedMean; - LocalRealType sMovingMoving = + const LocalRealType sFixedFixed = + sumFixed2 - fixedMean * sumFixed - fixedMean * sumFixed + count * fixedMean * fixedMean; + const LocalRealType sMovingMoving = sumMoving2 - movingMean * sumMoving - movingMean * sumMoving + count * movingMean * movingMean; - LocalRealType sFixedMoving = + const LocalRealType sFixedMoving = sumFixedMoving - movingMean * sumFixed - fixedMean * sumMoving + count * movingMean * fixedMean; - typename VirtualImageType::IndexType oindex = scanIt.GetIndex(); + const typename VirtualImageType::IndexType oindex = scanIt.GetIndex(); VirtualPointType virtualPoint; FixedImagePointType mappedFixedPoint; @@ -520,13 +521,13 @@ ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader< using LocalRealType = InternalComputationValueType; - LocalRealType sFixedFixed = scanMem.sFixedFixed; - LocalRealType sMovingMoving = scanMem.sMovingMoving; - LocalRealType sFixedMoving = scanMem.sFixedMoving; - LocalRealType fixedI = scanMem.fixedA; - LocalRealType movingI = scanMem.movingA; + const LocalRealType sFixedFixed = scanMem.sFixedFixed; + const LocalRealType sMovingMoving = scanMem.sMovingMoving; + const LocalRealType sFixedMoving = scanMem.sFixedMoving; + const LocalRealType fixedI = scanMem.fixedA; + const LocalRealType movingI = scanMem.movingA; - LocalRealType sFixedFixed_sMovingMoving = sFixedFixed * sMovingMoving; + const LocalRealType sFixedFixed_sMovingMoving = sFixedFixed * sMovingMoving; if (itk::Math::abs(sFixedFixed_sMovingMoving) > NumericTraits::epsilon()) { @@ -560,7 +561,7 @@ ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader< this->m_Associate->GetMovingTransform()->ComputeJacobianWithRespectToParametersCachedTemporaries( scanMem.virtualPoint, jacobian, jacobianPositional); - NumberOfParametersType numberOfLocalParameters = + const NumberOfParametersType numberOfLocalParameters = this->m_Associate->GetMovingTransform()->GetNumberOfLocalParameters(); for (NumberOfParametersType par = 0; par < numberOfLocalParameters; ++par) diff --git a/Modules/Registration/Metricsv4/include/itkCorrelationImageToImageMetricv4.hxx b/Modules/Registration/Metricsv4/include/itkCorrelationImageToImageMetricv4.hxx index b974d2b70ba..29da8cfcd87 100644 --- a/Modules/Registration/Metricsv4/include/itkCorrelationImageToImageMetricv4.hxx +++ b/Modules/Registration/Metricsv4/include/itkCorrelationImageToImageMetricv4.hxx @@ -87,7 +87,7 @@ CorrelationImageToImageMetricv4m_UseSampledPointSet) // sparse sampling { - SizeValueType numberOfPoints = this->GetNumberOfDomainPoints(); + const SizeValueType numberOfPoints = this->GetNumberOfDomainPoints(); if (numberOfPoints < 1) { itkExceptionMacro("FixedSampledPointSet must have 1 or more points."); diff --git a/Modules/Registration/Metricsv4/include/itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx b/Modules/Registration/Metricsv4/include/itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx index 8d5e251b074..aabae7cf9c4 100644 --- a/Modules/Registration/Metricsv4/include/itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx +++ b/Modules/Registration/Metricsv4/include/itkCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx @@ -120,7 +120,7 @@ CorrelationImageToImageMetricv4GetValueAndDerivativeThreaderm_CorrelationMetricValueDerivativePerThreadVariables[threadId].f2; } - InternalComputationValueType m2f2 = m2 * f2; + const InternalComputationValueType m2f2 = m2 * f2; if (m2f2 <= NumericTraits::epsilon()) { itkDebugMacro("CorrelationImageToImageMetricv4: m2 * f2 <= epsilon"); diff --git a/Modules/Registration/Metricsv4/include/itkEuclideanDistancePointSetToPointSetMetricv4.hxx b/Modules/Registration/Metricsv4/include/itkEuclideanDistancePointSetToPointSetMetricv4.hxx index c204bd772c8..213c97d8f7f 100644 --- a/Modules/Registration/Metricsv4/include/itkEuclideanDistancePointSetToPointSetMetricv4.hxx +++ b/Modules/Registration/Metricsv4/include/itkEuclideanDistancePointSetToPointSetMetricv4.hxx @@ -30,7 +30,7 @@ typename EuclideanDistancePointSetToPointSetMetricv4m_MovingTransformedPointsLocator->FindClosestPoint(point); + const PointIdentifier pointId = this->m_MovingTransformedPointsLocator->FindClosestPoint(point); closestPoint = this->m_MovingTransformedPointSet->GetPoint(pointId); const MeasureType distance = point.EuclideanDistanceTo(closestPoint); @@ -54,7 +54,7 @@ EuclideanDistancePointSetToPointSetMetricv4m_MovingTransformedPointsLocator->FindClosestPoint(point); + const PointIdentifier pointId = this->m_MovingTransformedPointsLocator->FindClosestPoint(point); closestPoint = this->m_MovingTransformedPointSet->GetPoint(pointId); auto distance = point.EuclideanDistanceTo(closestPoint); diff --git a/Modules/Registration/Metricsv4/include/itkExpectationBasedPointSetToPointSetMetricv4.hxx b/Modules/Registration/Metricsv4/include/itkExpectationBasedPointSetToPointSetMetricv4.hxx index 388237d6ea5..f7900081878 100644 --- a/Modules/Registration/Metricsv4/include/itkExpectationBasedPointSetToPointSetMetricv4.hxx +++ b/Modules/Registration/Metricsv4/include/itkExpectationBasedPointSetToPointSetMetricv4.hxx @@ -60,7 +60,7 @@ typename ExpectationBasedPointSetToPointSetMetricv4m_MovingTransformedPointSet->GetPoint(*it); + const PointType neighbor = this->m_MovingTransformedPointSet->GetPoint(*it); const MeasureType distance = point.SquaredEuclideanDistanceTo(neighbor); localValue -= this->m_PreFactor * std::exp(-distance / this->m_Denominator); } @@ -92,7 +92,7 @@ ExpectationBasedPointSetToPointSetMetricv4m_MovingTransformedPointSet->GetPoint(*it); + const PointType neighbor = this->m_MovingTransformedPointSet->GetPoint(*it); const MeasureType distance = point.SquaredEuclideanDistanceTo(neighbor); measureValues[it - neighborhood.begin()] = -this->m_PreFactor * std::exp(-distance / this->m_Denominator); measureSum += measureValues[it - neighborhood.begin()]; @@ -106,8 +106,8 @@ ExpectationBasedPointSetToPointSetMetricv4m_MovingTransformedPointSet->GetPoint(*it); - VectorType neighborVector = neighbor.GetVectorFromOrigin(); + const PointType neighbor = this->m_MovingTransformedPointSet->GetPoint(*it); + const VectorType neighborVector = neighbor.GetVectorFromOrigin(); weightedPoint += (neighborVector * measureValues[it - neighborhood.begin()] / measure); } diff --git a/Modules/Registration/Metricsv4/include/itkImageToImageMetricv4.hxx b/Modules/Registration/Metricsv4/include/itkImageToImageMetricv4.hxx index cc70cbaa0d2..f8cb55ecf56 100644 --- a/Modules/Registration/Metricsv4/include/itkImageToImageMetricv4.hxx +++ b/Modules/Registration/Metricsv4/include/itkImageToImageMetricv4.hxx @@ -123,7 +123,7 @@ ImageToImageMetricv4CopyInformation(this->m_FixedImage); /* CopyInformation does not copy buffered region */ image->SetBufferedRegion(this->m_FixedImage->GetBufferedRegion()); @@ -257,7 +257,7 @@ ImageToImageMetricv4m_UseSampledPointSet) // sparse sampling { - SizeValueType numberOfPoints = this->GetNumberOfDomainPoints(); + const SizeValueType numberOfPoints = this->GetNumberOfDomainPoints(); if (numberOfPoints < 1) { itkExceptionMacro("VirtualSampledPointSet must have 1 or more points."); @@ -589,14 +589,14 @@ ImageToImageMetricv4m_VirtualSampledPointSet->Initialize(); using PointsContainer = typename FixedSampledPointSetType::PointsContainer; - typename PointsContainer::ConstPointer points = this->m_FixedSampledPointSet->GetPoints(); + const typename PointsContainer::ConstPointer points = this->m_FixedSampledPointSet->GetPoints(); if (points.IsNull()) { itkExceptionMacro("Fixed Sample point set is empty."); } typename PointsContainer::ConstIterator fixedIt = points->Begin(); - typename FixedTransformType::InverseTransformBasePointer inverseTransform = + const typename FixedTransformType::InverseTransformBasePointer inverseTransform = this->m_FixedTransform->GetInverseTransform(); if (inverseTransform.IsNull()) { @@ -608,8 +608,8 @@ ImageToImageMetricv4End()) { - typename FixedSampledPointSetType::PointType point = inverseTransform->TransformPoint(fixedIt.Value()); - typename VirtualImageType::IndexType tempIndex; + const typename FixedSampledPointSetType::PointType point = inverseTransform->TransformPoint(fixedIt.Value()); + typename VirtualImageType::IndexType tempIndex; /* Verify that the point is valid. We may be working with a resized virtual domain, * and a fixed sampled point list that was created before the resizing. */ if (this->TransformPhysicalPointToVirtualIndex(point, tempIndex)) @@ -648,7 +648,7 @@ ImageToImageMetricv4GetVirtualRegion(); + const typename VirtualImageType::RegionType region = this->GetVirtualRegion(); return region.GetNumberOfPixels(); } } diff --git a/Modules/Registration/Metricsv4/include/itkImageToImageMetricv4GetValueAndDerivativeThreader.hxx b/Modules/Registration/Metricsv4/include/itkImageToImageMetricv4GetValueAndDerivativeThreader.hxx index 009503353fb..ed36f9b59b8 100644 --- a/Modules/Registration/Metricsv4/include/itkImageToImageMetricv4GetValueAndDerivativeThreader.hxx +++ b/Modules/Registration/Metricsv4/include/itkImageToImageMetricv4GetValueAndDerivativeThreader.hxx @@ -29,7 +29,7 @@ ImageToImageMetricv4GetValueAndDerivativeThreader< ThreadedImageRegionPartitioner, TImageToImageMetricv4>::ThreadedExecution(const DomainType & imageSubRegion, const ThreadIdType threadId) { - typename VirtualImageType::ConstPointer virtualImage = this->m_Associate->GetVirtualImage(); + const typename VirtualImageType::ConstPointer virtualImage = this->m_Associate->GetVirtualImage(); using IteratorType = ImageRegionConstIteratorWithIndex; VirtualPointType virtualPoint; for (IteratorType it(virtualImage, imageSubRegion); !it.IsAtEnd(); ++it) @@ -47,12 +47,12 @@ void ImageToImageMetricv4GetValueAndDerivativeThreader:: ThreadedExecution(const DomainType & indexSubRange, const ThreadIdType threadId) { - typename TImageToImageMetricv4::VirtualPointSetType::ConstPointer virtualSampledPointSet = + const typename TImageToImageMetricv4::VirtualPointSetType::ConstPointer virtualSampledPointSet = this->m_Associate->GetVirtualSampledPointSet(); using ElementIdentifierType = typename TImageToImageMetricv4::VirtualPointSetType::MeshTraits::PointIdentifier; - const ElementIdentifierType begin = indexSubRange[0]; - const ElementIdentifierType end = indexSubRange[1]; - typename VirtualImageType::ConstPointer virtualImage = this->m_Associate->GetVirtualImage(); + const ElementIdentifierType begin = indexSubRange[0]; + const ElementIdentifierType end = indexSubRange[1]; + const typename VirtualImageType::ConstPointer virtualImage = this->m_Associate->GetVirtualImage(); for (ElementIdentifierType i = begin; i <= end; ++i) { const VirtualPointType & virtualPoint = virtualSampledPointSet->GetPoint(i); diff --git a/Modules/Registration/Metricsv4/include/itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.hxx b/Modules/Registration/Metricsv4/include/itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.hxx index f844994df54..89a2d966797 100644 --- a/Modules/Registration/Metricsv4/include/itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.hxx +++ b/Modules/Registration/Metricsv4/include/itkImageToImageMetricv4GetValueAndDerivativeThreaderBase.hxx @@ -283,7 +283,7 @@ ImageToImageMetricv4GetValueAndDerivativeThreaderBasem_Associate->GetUseFloatingPointCorrection()) { - DerivativeValueType correctionResolution = this->m_Associate->GetFloatingPointCorrectionResolution(); + const DerivativeValueType correctionResolution = this->m_Associate->GetFloatingPointCorrectionResolution(); for (NumberOfParametersType p = 0; p < this->m_CachedNumberOfParameters; ++p) { auto test = static_cast( @@ -306,7 +306,7 @@ ImageToImageMetricv4GetValueAndDerivativeThreaderBasem_Associate->ComputeParameterOffsetFromVirtualIndex(virtualIndex, this->m_CachedNumberOfLocalParameters); for (NumberOfParametersType i = 0; i < this->m_CachedNumberOfLocalParameters; ++i) { diff --git a/Modules/Registration/Metricsv4/include/itkJensenHavrdaCharvatTsallisPointSetToPointSetMetricv4.hxx b/Modules/Registration/Metricsv4/include/itkJensenHavrdaCharvatTsallisPointSetToPointSetMetricv4.hxx index aaa4e2a9fa4..ff10a850803 100644 --- a/Modules/Registration/Metricsv4/include/itkJensenHavrdaCharvatTsallisPointSetToPointSetMetricv4.hxx +++ b/Modules/Registration/Metricsv4/include/itkJensenHavrdaCharvatTsallisPointSetToPointSetMetricv4.hxx @@ -103,7 +103,7 @@ JensenHavrdaCharvatTsallisPointSetToPointSetMetricv4m_MovingDensityFunction->GetInputPointSet()->GetNumberOfPoints(); RealType probabilityStar = this->m_MovingDensityFunction->Evaluate(samplePoint) * static_cast(numberOfMovingPoints); @@ -117,7 +117,7 @@ JensenHavrdaCharvatTsallisPointSetToPointSetMetricv4::OneValue(); + const RealType realOne = NumericTraits::OneValue(); if (Math::AlmostEquals(this->m_Alpha, realOne)) { value = (std::log(probabilityStar)); @@ -131,7 +131,7 @@ JensenHavrdaCharvatTsallisPointSetToPointSetMetricv4(2.0 - this->m_Alpha)); + const RealType probabilityStarFactor = std::pow(probabilityStar, static_cast(2.0 - this->m_Alpha)); typename DensityFunctionType::NeighborsIdentifierType neighbors; this->m_MovingDensityFunction->GetPointsLocator()->FindClosestNPoints( @@ -139,7 +139,7 @@ JensenHavrdaCharvatTsallisPointSetToPointSetMetricv4m_MovingDensityFunction->GetGaussian(neighbors[n])->Evaluate(samplePoint); + const RealType gaussian = this->m_MovingDensityFunction->GetGaussian(neighbors[n])->Evaluate(samplePoint); if (Math::AlmostEquals(gaussian, RealType{})) { @@ -156,7 +156,7 @@ JensenHavrdaCharvatTsallisPointSetToPointSetMetricv4m_UseAnisotropicCovariances) { - typename GaussianType::CovarianceMatrixType Ci = + const typename GaussianType::CovarianceMatrixType Ci = this->m_MovingDensityFunction->GetGaussian(neighbors[n])->GetInverseCovariance(); diffMean = Ci * diffMean; } @@ -165,7 +165,7 @@ JensenHavrdaCharvatTsallisPointSetToPointSetMetricv4m_MovingDensityFunction->GetGaussian(neighbors[n])->GetCovariance()(0, 0); } - DerivativeValueType factor = this->m_Prefactor1 * gaussian / probabilityStarFactor; + const DerivativeValueType factor = this->m_Prefactor1 * gaussian / probabilityStarFactor; for (unsigned int i = 0; i < PointDimension; ++i) { derivativeReturn[i] += diffMean[i] * factor; diff --git a/Modules/Registration/Metricsv4/include/itkJointHistogramMutualInformationGetValueAndDerivativeThreader.hxx b/Modules/Registration/Metricsv4/include/itkJointHistogramMutualInformationGetValueAndDerivativeThreader.hxx index f476fc1b35b..06ea78fcf63 100644 --- a/Modules/Registration/Metricsv4/include/itkJointHistogramMutualInformationGetValueAndDerivativeThreader.hxx +++ b/Modules/Registration/Metricsv4/include/itkJointHistogramMutualInformationGetValueAndDerivativeThreader.hxx @@ -131,15 +131,15 @@ JointHistogramMutualInformationGetValueAndDerivativeThreader< { return false; } - InternalComputationValueType jointPDFValue = + const InternalComputationValueType jointPDFValue = this->m_JointHistogramMIPerThreadVariables[threadId].JointPDFInterpolator->Evaluate(jointPDFpoint); - SizeValueType ind = 1; - InternalComputationValueType dJPDF = this->ComputeJointPDFDerivative(jointPDFpoint, threadId, ind); + const SizeValueType ind = 1; + const InternalComputationValueType dJPDF = this->ComputeJointPDFDerivative(jointPDFpoint, threadId, ind); typename MarginalPDFType::PointType mind; mind[0] = jointPDFpoint[ind]; - InternalComputationValueType movingImagePDFValue = + const InternalComputationValueType movingImagePDFValue = this->m_JointHistogramMIPerThreadVariables[threadId].MovingImageMarginalPDFInterpolator->Evaluate(mind); - InternalComputationValueType dMmPDF = this->ComputeMovingImageMarginalPDFDerivative(mind, threadId); + const InternalComputationValueType dMmPDF = this->ComputeMovingImageMarginalPDFDerivative(mind, threadId); const InternalComputationValueType eps = 1.e-16; if (jointPDFValue > eps && movingImagePDFValue > eps) @@ -235,9 +235,9 @@ JointHistogramMutualInformationGetValueAndDerivativeThreader< TJointHistogramMetric>::ComputeMovingImageMarginalPDFDerivative(const MarginalPDFPointType & margPDFpoint, const ThreadIdType threadId) const { - InternalComputationValueType offset = 0.5 * this->m_JointAssociate->m_JointPDFSpacing[0]; - InternalComputationValueType eps = this->m_JointAssociate->m_JointPDFSpacing[0]; - MarginalPDFPointType leftpoint = margPDFpoint; + const InternalComputationValueType offset = 0.5 * this->m_JointAssociate->m_JointPDFSpacing[0]; + const InternalComputationValueType eps = this->m_JointAssociate->m_JointPDFSpacing[0]; + MarginalPDFPointType leftpoint = margPDFpoint; leftpoint[0] -= offset; MarginalPDFPointType rightpoint = margPDFpoint; rightpoint[0] += offset; @@ -257,10 +257,10 @@ JointHistogramMutualInformationGetValueAndDerivativeThreader< { rightpoint[0] = 1.0; } - InternalComputationValueType delta = rightpoint[0] - leftpoint[0]; + const InternalComputationValueType delta = rightpoint[0] - leftpoint[0]; if (delta > InternalComputationValueType{}) { - InternalComputationValueType deriv = + const InternalComputationValueType deriv = this->m_JointHistogramMIPerThreadVariables[threadId].MovingImageMarginalPDFInterpolator->Evaluate(rightpoint) - this->m_JointHistogramMIPerThreadVariables[threadId].MovingImageMarginalPDFInterpolator->Evaluate(leftpoint); return deriv / delta; @@ -283,9 +283,9 @@ JointHistogramMutualInformationGetValueAndDerivativeThreader< const ThreadIdType threadId, const SizeValueType ind) const { - InternalComputationValueType offset = 0.5 * this->m_JointAssociate->m_JointPDFSpacing[ind]; - InternalComputationValueType eps = this->m_JointAssociate->m_JointPDFSpacing[ind]; - JointPDFPointType leftpoint = jointPDFpoint; + const InternalComputationValueType offset = 0.5 * this->m_JointAssociate->m_JointPDFSpacing[ind]; + const InternalComputationValueType eps = this->m_JointAssociate->m_JointPDFSpacing[ind]; + JointPDFPointType leftpoint = jointPDFpoint; leftpoint[ind] -= offset; JointPDFPointType rightpoint = jointPDFpoint; rightpoint[ind] += offset; @@ -310,8 +310,8 @@ JointHistogramMutualInformationGetValueAndDerivativeThreader< rightpoint[ind] = 1.0; } - InternalComputationValueType delta = rightpoint[ind] - leftpoint[ind]; - InternalComputationValueType deriv{}; + const InternalComputationValueType delta = rightpoint[ind] - leftpoint[ind]; + InternalComputationValueType deriv{}; if (delta > InternalComputationValueType{}) { deriv = this->m_JointHistogramMIPerThreadVariables[threadId].JointPDFInterpolator->Evaluate(rightpoint) - diff --git a/Modules/Registration/Metricsv4/include/itkJointHistogramMutualInformationImageToImageMetricv4.hxx b/Modules/Registration/Metricsv4/include/itkJointHistogramMutualInformationImageToImageMetricv4.hxx index 40f8717f827..10df17d4b94 100644 --- a/Modules/Registration/Metricsv4/include/itkJointHistogramMutualInformationImageToImageMetricv4.hxx +++ b/Modules/Registration/Metricsv4/include/itkJointHistogramMutualInformationImageToImageMetricv4.hxx @@ -217,7 +217,7 @@ JointHistogramMutualInformationImageToImageMetricv4m_JointPDF->FillBuffer(pdfzero); this->m_FixedImageMarginalPDF->FillBuffer(pdfzero); this->m_MovingImageMarginalPDF->FillBuffer(pdfzero); @@ -227,7 +227,7 @@ JointHistogramMutualInformationImageToImageMetricv4m_UseSampledPointSet) { - SizeValueType numberOfPoints = this->GetNumberOfDomainPoints(); + const SizeValueType numberOfPoints = this->GetNumberOfDomainPoints(); if (numberOfPoints < 1) { itkExceptionMacro("VirtualSampledPointSet must have 1 or more points."); @@ -361,9 +361,9 @@ JointHistogramMutualInformationImageToImageMetricv4m_MovingImageMarginalPDF->GetPixel(mind); - TInternalComputationValueType denom = px * py; - typename JointPDFType::IndexType index = { static_cast(ii), static_cast(jj) }; + TInternalComputationValueType py = this->m_MovingImageMarginalPDF->GetPixel(mind); + TInternalComputationValueType denom = px * py; + const typename JointPDFType::IndexType index = { static_cast(ii), static_cast(jj) }; TInternalComputationValueType pxy = m_JointPDF->GetPixel(index); TInternalComputationValueType local_mi = 0; diff --git a/Modules/Registration/Metricsv4/include/itkLabeledPointSetToPointSetMetricv4.hxx b/Modules/Registration/Metricsv4/include/itkLabeledPointSetToPointSetMetricv4.hxx index 095aa7a15de..7281318a651 100644 --- a/Modules/Registration/Metricsv4/include/itkLabeledPointSetToPointSetMetricv4.hxx +++ b/Modules/Registration/Metricsv4/include/itkLabeledPointSetToPointSetMetricv4.hxx @@ -58,15 +58,15 @@ LabeledPointSetToPointSetMetricv4m_CommonPointSetLabels.begin(); it != this->m_CommonPointSetLabels.end(); ++it) { - typename PointSetMetricType::Pointer metric = + const typename PointSetMetricType::Pointer metric = dynamic_cast(this->m_PointSetMetric->Clone().GetPointer()); if (metric.IsNull()) { itkExceptionMacro("The metric pointer clone is nullptr."); } - FixedPointSetPointer fixedPointSet = this->GetLabeledFixedPointSet(*it); - MovingPointSetPointer movingPointSet = this->GetLabeledMovingPointSet(*it); + const FixedPointSetPointer fixedPointSet = this->GetLabeledFixedPointSet(*it); + const MovingPointSetPointer movingPointSet = this->GetLabeledMovingPointSet(*it); metric->SetFixedPointSet(fixedPointSet); metric->SetMovingPointSet(movingPointSet); @@ -96,8 +96,8 @@ LabeledPointSetToPointSetMetricv4m_CommonPointSetLabels.begin(); - MeasureType value = this->m_PointSetMetricClones[labelIndex]->GetLocalNeighborhoodValue(point, label); + const unsigned int labelIndex = labelIt - this->m_CommonPointSetLabels.begin(); + const MeasureType value = this->m_PointSetMetricClones[labelIndex]->GetLocalNeighborhoodValue(point, label); return value; } } @@ -117,7 +117,7 @@ LabeledPointSetToPointSetMetricv4m_CommonPointSetLabels.begin(); + const unsigned int labelIndex = labelIt - this->m_CommonPointSetLabels.begin(); this->m_PointSetMetricClones[labelIndex]->GetLocalNeighborhoodValueAndDerivative( point, measure, localDerivative, label); } diff --git a/Modules/Registration/Metricsv4/include/itkManifoldParzenWindowsPointSetFunction.hxx b/Modules/Registration/Metricsv4/include/itkManifoldParzenWindowsPointSetFunction.hxx index 3ea67f18a79..a778bb550d3 100644 --- a/Modules/Registration/Metricsv4/include/itkManifoldParzenWindowsPointSetFunction.hxx +++ b/Modules/Registration/Metricsv4/include/itkManifoldParzenWindowsPointSetFunction.hxx @@ -98,7 +98,7 @@ ManifoldParzenWindowsPointSetFunction::SetInput { PointType neighbor = this->GetInputPointSet()->GetPoint(neighbors[j]); - RealType kernelValue = inputGaussians[index]->Evaluate(neighbor); + const RealType kernelValue = inputGaussians[index]->Evaluate(neighbor); denominator += kernelValue; if (kernelValue > 0.0) @@ -107,7 +107,7 @@ ManifoldParzenWindowsPointSetFunction::SetInput { for (unsigned int n = m; n < PointDimension; ++n) { - RealType covariance = kernelValue * (neighbor[m] - point[m]) * (neighbor[n] - point[n]); + const RealType covariance = kernelValue * (neighbor[m] - point[m]) * (neighbor[n] - point[n]); Cout(m, n) += covariance; Cout(n, m) += covariance; } @@ -151,7 +151,7 @@ ManifoldParzenWindowsPointSetFunction::Evaluate itkExceptionMacro("The input point set has not been specified."); } - unsigned int numberOfNeighbors = + const unsigned int numberOfNeighbors = std::min(this->m_EvaluationKNeighborhood, static_cast(this->m_Gaussians.size())); CompensatedSummation sum; diff --git a/Modules/Registration/Metricsv4/include/itkMattesMutualInformationImageToImageMetricv4.hxx b/Modules/Registration/Metricsv4/include/itkMattesMutualInformationImageToImageMetricv4.hxx index 3ddafd1d91e..b3f8265c559 100644 --- a/Modules/Registration/Metricsv4/include/itkMattesMutualInformationImageToImageMetricv4.hxx +++ b/Modules/Registration/Metricsv4/include/itkMattesMutualInformationImageToImageMetricv4.hxx @@ -110,7 +110,7 @@ MattesMutualInformationImageToImageMetricv4m_VirtualSampledPointSet->GetPoints()->Begin(); - typename Superclass::FixedSampledPointSetType::PointsContainerConstIterator end = + const typename Superclass::FixedSampledPointSetType::PointsContainerConstIterator end = this->m_VirtualSampledPointSet->GetPoints()->End(); if (this->m_FixedTransform.IsNull()) @@ -138,7 +138,7 @@ MattesMutualInformationImageToImageMetricv4m_FixedSampledPointSet->GetPoints()->Begin(); - typename Superclass::FixedSampledPointSetType::PointsContainerConstIterator end = + const typename Superclass::FixedSampledPointSetType::PointsContainerConstIterator end = this->m_FixedSampledPointSet->GetPoints()->End(); while (pit != end) { @@ -614,7 +614,7 @@ MattesMutualInformationImageToImageMetricv4 FirstTryLockHolder(*this->m_ParentJointPDFDerivativesMutexPtr, std::try_to_lock); + const std::unique_lock FirstTryLockHolder(*this->m_ParentJointPDFDerivativesMutexPtr, std::try_to_lock); if (FirstTryLockHolder.owns_lock()) { ReduceBuffer(); @@ -623,7 +623,8 @@ MattesMutualInformationImageToImageMetricv4 SecondTryLockHolder(*this->m_ParentJointPDFDerivativesMutexPtr, std::try_to_lock); + const std::unique_lock SecondTryLockHolder(*this->m_ParentJointPDFDerivativesMutexPtr, + std::try_to_lock); if (SecondTryLockHolder.owns_lock()) { ReduceBuffer(); diff --git a/Modules/Registration/Metricsv4/include/itkMeanSquaresImageToImageMetricv4GetValueAndDerivativeThreader.hxx b/Modules/Registration/Metricsv4/include/itkMeanSquaresImageToImageMetricv4GetValueAndDerivativeThreader.hxx index f2f8bc57861..8bee8315dab 100644 --- a/Modules/Registration/Metricsv4/include/itkMeanSquaresImageToImageMetricv4GetValueAndDerivativeThreader.hxx +++ b/Modules/Registration/Metricsv4/include/itkMeanSquaresImageToImageMetricv4GetValueAndDerivativeThreader.hxx @@ -41,13 +41,13 @@ MeanSquaresImageToImageMetricv4GetValueAndDerivativeThreader< const ThreadIdType threadId) const { /** Only the voxelwise contribution given the point pairs. */ - FixedImagePixelType diff = fixedImageValue - movingImageValue; - const unsigned int nComponents = NumericTraits::GetLength(diff); + const FixedImagePixelType diff = fixedImageValue - movingImageValue; + const unsigned int nComponents = NumericTraits::GetLength(diff); metricValueReturn = MeasureType{}; for (unsigned int nc = 0; nc < nComponents; ++nc) { - MeasureType diffC = DefaultConvertPixelTraits::GetNthComponent(nc, diff); + const MeasureType diffC = DefaultConvertPixelTraits::GetNthComponent(nc, diff); metricValueReturn += diffC * diffC; } @@ -71,7 +71,7 @@ MeanSquaresImageToImageMetricv4GetValueAndDerivativeThreader< localDerivativeReturn[par] = DerivativeValueType{}; for (unsigned int nc = 0; nc < nComponents; ++nc) { - MeasureType diffValue = DefaultConvertPixelTraits::GetNthComponent(nc, diff); + const MeasureType diffValue = DefaultConvertPixelTraits::GetNthComponent(nc, diff); for (SizeValueType dim = 0; dim < ImageToImageMetricv4Type::MovingImageDimension; ++dim) { localDerivativeReturn[par] += 2.0 * diffValue * jacobian(dim, par) * diff --git a/Modules/Registration/Metricsv4/include/itkObjectToObjectMultiMetricv4.hxx b/Modules/Registration/Metricsv4/include/itkObjectToObjectMultiMetricv4.hxx index 69f58d211a0..89f684b42d7 100644 --- a/Modules/Registration/Metricsv4/include/itkObjectToObjectMultiMetricv4.hxx +++ b/Modules/Registration/Metricsv4/include/itkObjectToObjectMultiMetricv4.hxx @@ -260,7 +260,7 @@ ObjectToObjectMultiMetricv4m_MetricValueArray[j] = this->m_MetricQueue[j]->GetValue(); } - MeasureType firstValue = this->m_MetricValueArray[0]; + const MeasureType firstValue = this->m_MetricValueArray[0]; this->m_Value = firstValue; return firstValue; } @@ -301,8 +301,8 @@ ObjectToObjectMultiMetricv4m_MetricQueue[j]->GetValueAndDerivative(metricValue, metricDerivative); this->m_MetricValueArray[j] = metricValue; - DerivativeValueType magnitude = metricDerivative.magnitude(); - DerivativeValueType weightOverMagnitude{}; + const DerivativeValueType magnitude = metricDerivative.magnitude(); + DerivativeValueType weightOverMagnitude{}; totalMagnitude += magnitude; if (magnitude > NumericTraits::epsilon()) diff --git a/Modules/Registration/Metricsv4/include/itkPointSetToPointSetMetricWithIndexv4.hxx b/Modules/Registration/Metricsv4/include/itkPointSetToPointSetMetricWithIndexv4.hxx index 48361a011ea..359a9197d2c 100644 --- a/Modules/Registration/Metricsv4/include/itkPointSetToPointSetMetricWithIndexv4.hxx +++ b/Modules/Registration/Metricsv4/include/itkPointSetToPointSetMetricWithIndexv4.hxx @@ -100,7 +100,7 @@ PointSetToPointSetMetricWithIndexv4GetDisplacementField(); + const typename DisplacementFieldType::ConstPointer field = displacementTransform->GetDisplacementField(); this->SetVirtualDomain( field->GetSpacing(), field->GetOrigin(), field->GetDirection(), field->GetBufferedRegion()); } @@ -177,7 +177,7 @@ typename PointSetToPointSetMetricWithIndexv4CreateRanges(); std::vector> threadValues(ranges.size()); - std::function sumNeighborhoodValues = + const std::function sumNeighborhoodValues = [this, &threadValues, &ranges, &virtualTransformedPointSet, &fixedTransformedPointSet](SizeValueType rangeIndex) { CompensatedSummation threadValue = 0; PixelType pixel; @@ -190,7 +190,7 @@ typename PointSetToPointSetMetricWithIndexv4m_UsePointSetData) { - bool doesPointDataExist = this->m_FixedPointSet->GetPointData(index, &pixel); + const bool doesPointDataExist = this->m_FixedPointSet->GetPointData(index, &pixel); if (!doesPointDataExist) { itkExceptionMacro("The corresponding data for point (pointId = " << index << ") does not exist."); @@ -271,8 +271,8 @@ PointSetToPointSetMetricWithIndexv4CreateRanges(); std::vector> threadValues(ranges.size()); using CompensatedDerivative = typename std::vector>; - std::vector threadDerivatives(ranges.size()); - std::function sumNeighborhoodValues = + std::vector threadDerivatives(ranges.size()); + const std::function sumNeighborhoodValues = [this, &derivative, &threadDerivatives, &threadValues, &ranges, &calculateValue, &numberOfLocalParameters]( SizeValueType rangeIndex) { // Use STL container to make sure no unnecessary checks are performed @@ -310,7 +310,7 @@ PointSetToPointSetMetricWithIndexv4m_UsePointSetData) { - bool doesPointDataExist = this->m_FixedPointSet->GetPointData(index, &pixel); + const bool doesPointDataExist = this->m_FixedPointSet->GetPointData(index, &pixel); if (!doesPointDataExist) { itkExceptionMacro("The corresponding data for point with id " << index << " does not exist."); @@ -447,7 +447,7 @@ PointSetToPointSetMetricWithIndexv4ComputeParameterOffsetFromVirtualPoint(virtualPoint, this->GetNumberOfLocalParameters()); for (NumberOfParametersType i = 0; i < this->GetNumberOfLocalParameters(); ++i) { @@ -496,7 +496,7 @@ PointSetToPointSetMetricWithIndexv4m_MovingTransformedPointSet = MovingTransformedPointSetType::New(); this->m_MovingTransformedPointSet->Initialize(); - typename MovingTransformType::InverseTransformBasePointer inverseTransform = + const typename MovingTransformType::InverseTransformBasePointer inverseTransform = this->m_MovingTransform->GetInverseTransform(); typename MovingPointsContainer::ConstIterator It = this->m_MovingPointSet->GetPoints()->Begin(); @@ -504,7 +504,7 @@ PointSetToPointSetMetricWithIndexv4m_CalculateValueAndDerivativeInTangentSpace) { - PointType point = inverseTransform->TransformPoint(It.Value()); + const PointType point = inverseTransform->TransformPoint(It.Value()); this->m_MovingTransformedPointSet->SetPoint(It.Index(), point); } else @@ -545,7 +545,7 @@ PointSetToPointSetMetricWithIndexv4m_VirtualTransformedPointSet->Initialize(); using InverseTransformBasePointer = typename FixedTransformType::InverseTransformBasePointer; - InverseTransformBasePointer inverseTransform = this->m_FixedTransform->GetInverseTransform(); + const InverseTransformBasePointer inverseTransform = this->m_FixedTransform->GetInverseTransform(); typename FixedPointsContainer::ConstIterator It = this->m_FixedPointSet->GetPoints()->Begin(); while (It != this->m_FixedPointSet->GetPoints()->End()) @@ -553,7 +553,7 @@ PointSetToPointSetMetricWithIndexv4m_CalculateValueAndDerivativeInTangentSpace) { // txf into virtual space - PointType point = inverseTransform->TransformPoint(It.Value()); + const PointType point = inverseTransform->TransformPoint(It.Value()); this->m_VirtualTransformedPointSet->SetPoint(It.Index(), point); this->m_FixedTransformedPointSet->SetPoint(It.Index(), point); } @@ -630,8 +630,8 @@ const typename PointSetToPointSetMetricWithIndexv4::CreateRanges() const { - PointIdentifier nPoints = this->m_FixedTransformedPointSet->GetNumberOfPoints(); - PointIdentifier nWorkUnits = MultiThreaderBase::New()->GetNumberOfWorkUnits(); + const PointIdentifier nPoints = this->m_FixedTransformedPointSet->GetNumberOfPoints(); + PointIdentifier nWorkUnits = MultiThreaderBase::New()->GetNumberOfWorkUnits(); if (nWorkUnits > nPoints || MultiThreaderBase::New()->GetMaximumNumberOfThreads() <= 1) { nWorkUnits = 1; @@ -640,7 +640,7 @@ const typename PointSetToPointSetMetricWithIndexv4(nWorkUnits); + const PointIdentifier endRange = (p * nPoints) / static_cast(nWorkUnits); ranges.push_back(PointIdentifierPair(startRange, endRange)); startRange = endRange; } diff --git a/Modules/Registration/Metricsv4/test/itkANTSNeighborhoodCorrelationImageToImageMetricv4Test.cxx b/Modules/Registration/Metricsv4/test/itkANTSNeighborhoodCorrelationImageToImageMetricv4Test.cxx index b979000d602..5a311d262d0 100644 --- a/Modules/Registration/Metricsv4/test/itkANTSNeighborhoodCorrelationImageToImageMetricv4Test.cxx +++ b/Modules/Registration/Metricsv4/test/itkANTSNeighborhoodCorrelationImageToImageMetricv4Test.cxx @@ -36,11 +36,11 @@ ANTSNeighborhoodCorrelationImageToImageMetricv4Test_PrintDerivativeAsVectorImage { using ImageType = typename ImagePointerType::ObjectType; - typename ImageType::RegionType imageRegion = image->GetBufferedRegion(); + const typename ImageType::RegionType imageRegion = image->GetBufferedRegion(); // only display the first slice - itk::SizeValueType dim0 = imageRegion.GetSize()[0]; - itk::SizeValueType dim1 = imageRegion.GetSize()[1]; + const itk::SizeValueType dim0 = imageRegion.GetSize()[0]; + const itk::SizeValueType dim1 = imageRegion.GetSize()[1]; using IteratorType = itk::ImageRegionConstIterator; IteratorType it(image, imageRegion); @@ -70,13 +70,13 @@ ANTSNeighborhoodCorrelationImageToImageMetricv4Test_PrintImage(ImageType * image { using ImageConstPointerType = typename ImageType::ConstPointer; - ImageConstPointerType image = imageP; + const ImageConstPointerType image = imageP; - typename ImageType::RegionType imageRegion = image->GetBufferedRegion(); + const typename ImageType::RegionType imageRegion = image->GetBufferedRegion(); // only display the first slice - itk::SizeValueType dim0 = imageRegion.GetSize()[0]; - itk::SizeValueType dim1 = imageRegion.GetSize()[1]; + const itk::SizeValueType dim0 = imageRegion.GetSize()[0]; + const itk::SizeValueType dim1 = imageRegion.GetSize()[1]; using IteratorType = itk::ImageRegionConstIterator; IteratorType it(image, imageRegion); @@ -99,11 +99,11 @@ ANTSNeighborhoodCorrelationImageToImageMetricv4Test_PrintImage(const ImagePointe { using ImageType = typename ImagePointerType::ObjectType; - typename ImageType::RegionType imageRegion = image->GetBufferedRegion(); + const typename ImageType::RegionType imageRegion = image->GetBufferedRegion(); // only display the first slice - itk::SizeValueType dim0 = imageRegion.GetSize()[0]; - itk::SizeValueType dim1 = imageRegion.GetSize()[1]; + const itk::SizeValueType dim0 = imageRegion.GetSize()[0]; + const itk::SizeValueType dim1 = imageRegion.GetSize()[1]; using IteratorType = itk::ImageRegionConstIterator; IteratorType it(image, imageRegion); @@ -151,12 +151,12 @@ itkANTSNeighborhoodCorrelationImageToImageMetricv4Test(int, char ** const) constexpr itk::SizeValueType imageSize = 6; - auto size = ImageType::SizeType::Filled(imageSize); - ImageType::IndexType index{}; - ImageType::RegionType region{ index, size }; - auto spacing = itk::MakeFilled(1.0); - ImageType::PointType origin{}; - ImageType::DirectionType direction; + auto size = ImageType::SizeType::Filled(imageSize); + const ImageType::IndexType index{}; + const ImageType::RegionType region{ index, size }; + auto spacing = itk::MakeFilled(1.0); + const ImageType::PointType origin{}; + ImageType::DirectionType direction; direction.SetIdentity(); /* Create simple test images. */ @@ -194,8 +194,8 @@ itkANTSNeighborhoodCorrelationImageToImageMetricv4Test(int, char ** const) ++itMoving; } - VectorType zero; - float def_value = -0.5; + VectorType zero; + const float def_value = -0.5; zero.Fill(def_value); auto field = FieldType::New(); @@ -230,7 +230,7 @@ itkANTSNeighborhoodCorrelationImageToImageMetricv4Test(int, char ** const) using MetricType = itk::ANTSNeighborhoodCorrelationImageToImageMetricv4; using MetricTypePointer = MetricType::Pointer; - MetricTypePointer metric = MetricType::New(); + const MetricTypePointer metric = MetricType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(metric, ANTSNeighborhoodCorrelationImageToImageMetricv4, ImageToImageMetricv4); @@ -303,7 +303,7 @@ itkANTSNeighborhoodCorrelationImageToImageMetricv4Test(int, char ** const) std::cout << "Creating point set..." << std::endl; - PointSetType::Pointer pset(PointSetType::New()); + const PointSetType::Pointer pset(PointSetType::New()); unsigned int ind = 0; itk::ImageRegionIteratorWithIndex It(fixedImage, fixedImage->GetLargestPossibleRegion()); @@ -320,7 +320,7 @@ itkANTSNeighborhoodCorrelationImageToImageMetricv4Test(int, char ** const) std::cout << "Testing metric with point set..." << std::endl; /* run the metric with the sparse threader */ - MetricTypePointer metricSparse = MetricType::New(); + const MetricTypePointer metricSparse = MetricType::New(); metricSparse->SetRadius(neighborhoodRadius); metricSparse->SetFixedImage(fixedImage); metricSparse->SetMovingImage(movingImage); @@ -352,7 +352,7 @@ itkANTSNeighborhoodCorrelationImageToImageMetricv4Test(int, char ** const) std::cout << std::endl << "derivative of moving transform as a field (sparse threader):" << std::endl; ANTSNeighborhoodCorrelationImageToImageMetricv4Test_PrintDerivativeAsVectorImage( fixedImage, derivativeReturnSparse, ImageDimension); - double tolerance = 1e-7; + const double tolerance = 1e-7; if (!derivativeReturn.is_equal(derivativeReturnSparse, tolerance)) { std::cerr << "Results for derivative don't match using dense and sparse threaders: " @@ -366,7 +366,7 @@ itkANTSNeighborhoodCorrelationImageToImageMetricv4Test(int, char ** const) DisplacementTransformType::ParametersType parameters(transformMdisplacement->GetNumberOfParameters()); parameters.Fill(static_cast(1000.0)); transformMdisplacement->SetParameters(parameters); - MetricType::MeasureType expectedMetricMax = itk::NumericTraits::max(); + const MetricType::MeasureType expectedMetricMax = itk::NumericTraits::max(); std::cout << "Testing non-overlapping images. Expect a warning:" << std::endl; MetricType::MeasureType valueReturn; metric->GetValueAndDerivative(valueReturn, derivativeReturn); diff --git a/Modules/Registration/Metricsv4/test/itkANTSNeighborhoodCorrelationImageToImageRegistrationTest.cxx b/Modules/Registration/Metricsv4/test/itkANTSNeighborhoodCorrelationImageToImageRegistrationTest.cxx index 571d4c11d7b..faae3a32854 100644 --- a/Modules/Registration/Metricsv4/test/itkANTSNeighborhoodCorrelationImageToImageRegistrationTest.cxx +++ b/Modules/Registration/Metricsv4/test/itkANTSNeighborhoodCorrelationImageToImageRegistrationTest.cxx @@ -112,9 +112,9 @@ itkANTSNeighborhoodCorrelationImageToImageRegistrationTest(int argc, char * argv // get the images fixedImageReader->Update(); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); movingImageReader->Update(); - MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); + const MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); /** define a resample filter that will ultimately be used to deform the image */ using ResampleFilterType = itk::ResampleImageFilter; @@ -145,7 +145,7 @@ itkANTSNeighborhoodCorrelationImageToImageRegistrationTest(int argc, char * argv << "fixedImage->GetBufferedRegion(): " << fixedImage->GetBufferedRegion() << std::endl; field->Allocate(); // Fill it with 0's - DisplacementTransformType::OutputVectorType zeroVector{}; + const DisplacementTransformType::OutputVectorType zeroVector{}; field->FillBuffer(zeroVector); // Assign to transform displacementTransform->SetDisplacementField(field); @@ -171,13 +171,13 @@ itkANTSNeighborhoodCorrelationImageToImageRegistrationTest(int argc, char * argv metric->SetMovingImage(movingImage); metric->SetFixedTransform(identityTransform); metric->SetMovingTransform(affineTransform); - bool gaussian = false; + const bool gaussian = false; metric->SetUseMovingImageGradientFilter(gaussian); metric->SetUseFixedImageGradientFilter(gaussian); metric->Initialize(); using RegistrationParameterScalesFromShiftType = itk::RegistrationParameterScalesFromPhysicalShift; - RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = + const RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = RegistrationParameterScalesFromShiftType::New(); shiftScaleEstimator->SetMetric(metric); shiftScaleEstimator->SetTransformForward(true); // by default, scales for the moving transform @@ -234,7 +234,7 @@ itkANTSNeighborhoodCorrelationImageToImageRegistrationTest(int argc, char * argv using PointSetType = MetricType::FixedSampledPointSetType; using PointType = PointSetType::PointType; std::cout << "Using sparse point set..." << std::endl; - PointSetType::Pointer pset(PointSetType::New()); + const PointSetType::Pointer pset(PointSetType::New()); unsigned int ind = 0; itk::ImageRegionIteratorWithIndex It(fixedImage, fixedImage->GetLargestPossibleRegion()); for (It.GoToBegin(); !It.IsAtEnd(); ++It) diff --git a/Modules/Registration/Metricsv4/test/itkCorrelationImageToImageMetricv4Test.cxx b/Modules/Registration/Metricsv4/test/itkCorrelationImageToImageMetricv4Test.cxx index 30c0649cc91..10a8aff048f 100644 --- a/Modules/Registration/Metricsv4/test/itkCorrelationImageToImageMetricv4Test.cxx +++ b/Modules/Registration/Metricsv4/test/itkCorrelationImageToImageMetricv4Test.cxx @@ -128,12 +128,12 @@ itkCorrelationImageToImageMetricv4Test(int, char ** const) constexpr unsigned int imageDimensionality = 3; using ImageType = itk::Image; - auto size = ImageType::SizeType::Filled(imageSize); - ImageType::IndexType index{}; - ImageType::RegionType region{ index, size }; - auto spacing = itk::MakeFilled(1.0); - ImageType::PointType origin{}; - ImageType::DirectionType direction; + auto size = ImageType::SizeType::Filled(imageSize); + const ImageType::IndexType index{}; + const ImageType::RegionType region{ index, size }; + auto spacing = itk::MakeFilled(1.0); + const ImageType::PointType origin{}; + ImageType::DirectionType direction; direction.SetIdentity(); /* Create simple test images. */ @@ -165,8 +165,8 @@ itkCorrelationImageToImageMetricv4Test(int, char ** const) itFixed.GoToBegin(); while (!itFixed.IsAtEnd()) { - IndexType ind = itFixed.GetIndex(); - double v = itkCorrelationImageToImageMetricv4Test_GetToyImagePixelValue(ind, p0, imageDimensionality, 0); + const IndexType ind = itFixed.GetIndex(); + const double v = itkCorrelationImageToImageMetricv4Test_GetToyImagePixelValue(ind, p0, imageDimensionality, 0); itFixed.Set(v); ++itFixed; } @@ -182,8 +182,8 @@ itkCorrelationImageToImageMetricv4Test(int, char ** const) while (!itMoving.IsAtEnd()) { - IndexType ind = itMoving.GetIndex(); - double v = itkCorrelationImageToImageMetricv4Test_GetToyImagePixelValue(ind, p1, imageDimensionality, 0); + const IndexType ind = itMoving.GetIndex(); + const double v = itkCorrelationImageToImageMetricv4Test_GetToyImagePixelValue(ind, p1, imageDimensionality, 0); itMoving.Set(v); ++itMoving; } @@ -235,7 +235,7 @@ itkCorrelationImageToImageMetricv4Test(int, char ** const) result = EXIT_FAILURE; } - double myeps = 1e-8; + const double myeps = 1e-8; if (itk::Math::abs(value1 - value2) > 1e-8) { std::cerr << "value1: " << value1 << std::endl; @@ -244,7 +244,7 @@ itkCorrelationImageToImageMetricv4Test(int, char ** const) result = EXIT_FAILURE; } - vnl_vector ddiff = (vnl_vector)derivative1 - (vnl_vector)derivative2; + const vnl_vector ddiff = (vnl_vector)derivative1 - (vnl_vector)derivative2; if (ddiff.two_norm() > myeps) { std::cerr << "derivative1: " << derivative1 << std::endl; @@ -258,7 +258,7 @@ itkCorrelationImageToImageMetricv4Test(int, char ** const) MovingTransformType::ParametersType parameters(imageDimensionality); parameters.Fill(static_cast(1000)); movingTransform->SetParameters(parameters); - MetricType::MeasureType expectedMetricMax = itk::NumericTraits::max(); + const MetricType::MeasureType expectedMetricMax = itk::NumericTraits::max(); std::cout << "Testing non-overlapping images. Expect a warning:" << std::endl; MetricType::MeasureType valueReturn; MetricType::DerivativeType derivativeReturn; diff --git a/Modules/Registration/Metricsv4/test/itkDemonsImageToImageMetricv4RegistrationTest.cxx b/Modules/Registration/Metricsv4/test/itkDemonsImageToImageMetricv4RegistrationTest.cxx index c5934fa1a93..25de11f8196 100644 --- a/Modules/Registration/Metricsv4/test/itkDemonsImageToImageMetricv4RegistrationTest.cxx +++ b/Modules/Registration/Metricsv4/test/itkDemonsImageToImageMetricv4RegistrationTest.cxx @@ -177,7 +177,7 @@ itkDemonsImageToImageMetricv4RegistrationTest(int argc, char * argv[]) std::cout << "fixedImage->GetLargestPossibleRegion(): " << fixedImage->GetLargestPossibleRegion() << std::endl; field->Allocate(); // Fill it with 0's - DisplacementTransformType::OutputVectorType zeroVector{}; + const DisplacementTransformType::OutputVectorType zeroVector{}; field->FillBuffer(zeroVector); // Assign to transform displacementTransform->SetDisplacementField(field); @@ -205,9 +205,9 @@ itkDemonsImageToImageMetricv4RegistrationTest(int argc, char * argv[]) else { using PointType = PointSetType::PointType; - PointSetType::Pointer pset(PointSetType::New()); - unsigned long ind = 0; - unsigned long ct = 0; + const PointSetType::Pointer pset(PointSetType::New()); + unsigned long ind = 0; + unsigned long ct = 0; for (itk::ImageRegionIteratorWithIndex It(fixedImage, fixedImage->GetLargestPossibleRegion()); !It.IsAtEnd(); @@ -235,7 +235,7 @@ itkDemonsImageToImageMetricv4RegistrationTest(int argc, char * argv[]) // scales & step estimator using RegistrationParameterScalesFromShiftType = itk::RegistrationParameterScalesFromPhysicalShift; - RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = + const RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = RegistrationParameterScalesFromShiftType::New(); shiftScaleEstimator->SetMetric(metric); @@ -288,12 +288,12 @@ itkDemonsImageToImageMetricv4RegistrationTest(int argc, char * argv[]) // write out the displacement field using DisplacementWriterType = itk::ImageFileWriter; - auto displacementwriter = DisplacementWriterType::New(); - std::string outfilename(argv[3]); - std::string ext = itksys::SystemTools::GetFilenameExtension(outfilename); - std::string name = itksys::SystemTools::GetFilenameWithoutExtension(outfilename); - std::string path = itksys::SystemTools::GetFilenamePath(outfilename); - std::string defout = path + std::string("/") + name + std::string("_def") + ext; + auto displacementwriter = DisplacementWriterType::New(); + const std::string outfilename(argv[3]); + const std::string ext = itksys::SystemTools::GetFilenameExtension(outfilename); + const std::string name = itksys::SystemTools::GetFilenameWithoutExtension(outfilename); + const std::string path = itksys::SystemTools::GetFilenamePath(outfilename); + const std::string defout = path + std::string("/") + name + std::string("_def") + ext; displacementwriter->SetFileName(defout.c_str()); displacementwriter->SetInput(displacementTransform->GetDisplacementField()); displacementwriter->Update(); diff --git a/Modules/Registration/Metricsv4/test/itkDemonsImageToImageMetricv4Test.cxx b/Modules/Registration/Metricsv4/test/itkDemonsImageToImageMetricv4Test.cxx index d5dfd3a2abb..e116ba99a2a 100644 --- a/Modules/Registration/Metricsv4/test/itkDemonsImageToImageMetricv4Test.cxx +++ b/Modules/Registration/Metricsv4/test/itkDemonsImageToImageMetricv4Test.cxx @@ -36,12 +36,12 @@ itkDemonsImageToImageMetricv4Test(int, char ** const) constexpr unsigned int imageDimensionality = 3; using ImageType = itk::Image; - auto size = ImageType::SizeType::Filled(imageSize); - ImageType::IndexType index{}; - ImageType::RegionType region{ index, size }; - auto spacing = itk::MakeFilled(1.0); - ImageType::PointType origin{}; - ImageType::DirectionType direction; + auto size = ImageType::SizeType::Filled(imageSize); + const ImageType::IndexType index{}; + const ImageType::RegionType region{ index, size }; + auto spacing = itk::MakeFilled(1.0); + const ImageType::PointType origin{}; + ImageType::DirectionType direction; direction.SetIdentity(); /* Create simple test images. */ @@ -96,7 +96,7 @@ itkDemonsImageToImageMetricv4Test(int, char ** const) field->SetRegions(fixedImage->GetLargestPossibleRegion()); field->CopyInformation(fixedImage); field->Allocate(); - DisplacementTransformType::OutputVectorType zeroVector{}; + const DisplacementTransformType::OutputVectorType zeroVector{}; field->FillBuffer(zeroVector); displacementTransform->SetDisplacementField(field); displacementTransform->SetGaussianSmoothingVarianceForTheUpdateField(5); diff --git a/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricRegistrationTest.cxx b/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricRegistrationTest.cxx index 1002fe0079a..b9f539348ec 100644 --- a/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricRegistrationTest.cxx +++ b/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricRegistrationTest.cxx @@ -83,8 +83,8 @@ itkEuclideanDistancePointSetMetricRegistrationTestRun(unsigned int // Create a few points and apply a small rotation to make the moving point set - float theta = itk::Math::pi / static_cast(180.0) * static_cast(1.0); - PointType fixedPoint; + const float theta = itk::Math::pi / static_cast(180.0) * static_cast(1.0); + PointType fixedPoint; fixedPoint[0] = static_cast(0.0); fixedPoint[1] = static_cast(0.0); fixedPoints->SetPoint(0, fixedPoint); @@ -100,7 +100,7 @@ itkEuclideanDistancePointSetMetricRegistrationTestRun(unsigned int fixedPoint[0] = pointMax / static_cast(2.0); fixedPoint[1] = pointMax / static_cast(2.0); fixedPoints->SetPoint(4, fixedPoint); - unsigned int numberOfPoints = fixedPoints->GetNumberOfPoints(); + const unsigned int numberOfPoints = fixedPoints->GetNumberOfPoints(); PointType movingPoint; for (unsigned int n = 0; n < numberOfPoints; ++n) @@ -120,7 +120,7 @@ itkEuclideanDistancePointSetMetricRegistrationTestRun(unsigned int // scales estimator using RegistrationParameterScalesFromShiftType = itk::RegistrationParameterScalesFromPhysicalShift; - typename RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = + const typename RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = RegistrationParameterScalesFromShiftType::New(); shiftScaleEstimator->SetMetric(metric); // needed with pointset metrics @@ -152,7 +152,7 @@ itkEuclideanDistancePointSetMetricRegistrationTestRun(unsigned int typename TTransform::ParametersType params = transform->GetParameters(); for (itk::SizeValueType n = 0; n < transform->GetNumberOfParameters(); n += transform->GetNumberOfLocalParameters()) { - typename TTransform::ParametersValueType zero{}; + const typename TTransform::ParametersValueType zero{}; if (itk::Math::NotExactlyEquals(params[n], zero) && itk::Math::NotExactlyEquals(params[n + 1], zero)) { std::cout << n << ", " << n + 1 << " : " << params[n] << ", " << params[n + 1] << std::endl; @@ -166,9 +166,10 @@ itkEuclideanDistancePointSetMetricRegistrationTestRun(unsigned int // applying the resultant transform and verify result std::cout << "Fixed\tMoving\tMovingTransformed\tFixedTransformed\tDiff" << std::endl; - bool passed = true; - auto tolerance = static_cast(1e-4); - typename TTransform::InverseTransformBasePointer fixedInverse = metric->GetFixedTransform()->GetInverseTransform(); + bool passed = true; + auto tolerance = static_cast(1e-4); + const typename TTransform::InverseTransformBasePointer fixedInverse = + metric->GetFixedTransform()->GetInverseTransform(); for (unsigned int n = 0; n < numberOfPoints; ++n) { // compare the points in moving domain so we don't have to worry about an inverse @@ -261,13 +262,13 @@ itkEuclideanDistancePointSetMetricRegistrationTest(int argc, char * argv[]) direction[d][d] = static_cast(1.0); } - FieldType::PointType origin{}; + const FieldType::PointType origin{}; auto regionSize = RegionType::SizeType::Filled(static_cast(pointMax) + 1); - RegionType::IndexType regionIndex{}; + const RegionType::IndexType regionIndex{}; - RegionType region{ regionIndex, regionSize }; + const RegionType region{ regionIndex, regionSize }; auto displacementField = FieldType::New(); displacementField->SetOrigin(origin); @@ -275,7 +276,7 @@ itkEuclideanDistancePointSetMetricRegistrationTest(int argc, char * argv[]) displacementField->SetSpacing(spacing); displacementField->SetRegions(region); displacementField->Allocate(); - DisplacementFieldTransformType::OutputVectorType zeroVector{}; + const DisplacementFieldTransformType::OutputVectorType zeroVector{}; displacementField->FillBuffer(zeroVector); displacementTransform->SetDisplacementField(displacementField); diff --git a/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricTest.cxx b/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricTest.cxx index f8dcf60d8fa..e85c5c09826 100644 --- a/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricTest.cxx +++ b/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricTest.cxx @@ -41,7 +41,7 @@ itkEuclideanDistancePointSetMetricTestRun() offset[d] = 1.1 + d; } unsigned long count = 0; - float pointSetRadius = 100.0; + const float pointSetRadius = 100.0; for (float theta = 0; theta < 2.0 * itk::Math::pi; theta += 0.1) { PointType fixedPoint; @@ -80,8 +80,8 @@ itkEuclideanDistancePointSetMetricTestRun() metric->SetMovingTransform(translationTransform); metric->Initialize(); - typename PointSetMetricType::MeasureType value = metric->GetValue(); - typename PointSetMetricType::DerivativeType derivative; + const typename PointSetMetricType::MeasureType value = metric->GetValue(); + typename PointSetMetricType::DerivativeType derivative; metric->GetDerivative(derivative); typename PointSetMetricType::MeasureType value2; typename PointSetMetricType::DerivativeType derivative2; diff --git a/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricTest2.cxx b/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricTest2.cxx index 0108a6f0eeb..fef89775f45 100644 --- a/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricTest2.cxx +++ b/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricTest2.cxx @@ -69,7 +69,7 @@ itkEuclideanDistancePointSetMetricTest2Run() fixedPoint[2] = pointMax / 2.0; fixedPoints->SetPoint(6, fixedPoint); } - unsigned int numberOfPoints = fixedPoints->GetNumberOfPoints(); + const unsigned int numberOfPoints = fixedPoints->GetNumberOfPoints(); PointType movingPoint; for (unsigned int n = 0; n < numberOfPoints; ++n) @@ -105,13 +105,13 @@ itkEuclideanDistancePointSetMetricTest2Run() direction[d][d] = 1.0; } - typename FieldType::PointType origin{}; + const typename FieldType::PointType origin{}; auto regionSize = RegionType::SizeType::Filled(static_cast(pointMax + 1.0)); - typename RegionType::IndexType regionIndex{}; + const typename RegionType::IndexType regionIndex{}; - RegionType region{ regionIndex, regionSize }; + const RegionType region{ regionIndex, regionSize }; auto displacementField = FieldType::New(); displacementField->SetOrigin(origin); @@ -119,7 +119,7 @@ itkEuclideanDistancePointSetMetricTest2Run() displacementField->SetSpacing(spacing); displacementField->SetRegions(region); displacementField->Allocate(); - typename DisplacementFieldTransformType::OutputVectorType zeroVector{}; + const typename DisplacementFieldTransformType::OutputVectorType zeroVector{}; displacementField->FillBuffer(zeroVector); displacementTransform->SetDisplacementField(displacementField); @@ -136,8 +136,8 @@ itkEuclideanDistancePointSetMetricTest2Run() metric->Initialize(); // test - typename PointSetMetricType::MeasureType value = metric->GetValue(); - typename PointSetMetricType::DerivativeType derivative; + const typename PointSetMetricType::MeasureType value = metric->GetValue(); + typename PointSetMetricType::DerivativeType derivative; metric->GetDerivative(derivative); typename PointSetMetricType::MeasureType value2; @@ -189,7 +189,7 @@ itkEuclideanDistancePointSetMetricTest2Run() // We should get a warning printed. fixedPoint[0] = 0.0; fixedPoint[1] = 2 * pointMax; - unsigned int numberExpected = fixedPoints->GetNumberOfPoints() - 1; + const unsigned int numberExpected = fixedPoints->GetNumberOfPoints() - 1; fixedPoints->SetPoint(fixedPoints->GetNumberOfPoints() - 1, fixedPoint); metric->GetValueAndDerivative(value2, derivative2); if (metric->GetNumberOfValidPoints() != numberExpected) @@ -225,8 +225,8 @@ itkEuclideanDistancePointSetMetricTest2Run() // Test with invalid virtual domain, i.e. // one that doesn't match the displacement field. - auto badSize = RegionType::SizeType::Filled(static_cast(pointMax / 2.0)); - RegionType badRegion{ regionIndex, badSize }; + auto badSize = RegionType::SizeType::Filled(static_cast(pointMax / 2.0)); + const RegionType badRegion{ regionIndex, badSize }; metric->SetVirtualDomain(spacing, origin, direction, badRegion); ITK_TRY_EXPECT_EXCEPTION(metric->Initialize()); diff --git a/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricTest3.cxx b/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricTest3.cxx index 867f71edf97..2b0353a3bbe 100644 --- a/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricTest3.cxx +++ b/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricTest3.cxx @@ -60,7 +60,7 @@ itkEuclideanDistancePointSetMetricTest3Run(double distanceThreshold) fixedPoint[2] = pointMax; fixedPoints->SetPoint(3, fixedPoint); } - unsigned int numberOfPoints = fixedPoints->GetNumberOfPoints(); + const unsigned int numberOfPoints = fixedPoints->GetNumberOfPoints(); PointType movingPoint; for (unsigned int n = 0; n < numberOfPoints; ++n) @@ -122,8 +122,8 @@ itkEuclideanDistancePointSetMetricTest3Run(double distanceThreshold) metric->Initialize(); // test - typename PointSetMetricType::MeasureType value = metric->GetValue(); - typename PointSetMetricType::DerivativeType derivative; + const typename PointSetMetricType::MeasureType value = metric->GetValue(); + typename PointSetMetricType::DerivativeType derivative; metric->GetDerivative(derivative); typename PointSetMetricType::MeasureType value2; typename PointSetMetricType::DerivativeType derivative2; @@ -154,7 +154,7 @@ itkEuclideanDistancePointSetMetricTest3Run(double distanceThreshold) } } - double valueTest = distanceSum / numberOfPoints; + const double valueTest = distanceSum / numberOfPoints; if (itk::Math::NotExactlyEquals(valueTest, value2)) { std::cerr << "Value calculation is wrong when used threshold : " << distanceThreshold << "valueTest: " << valueTest @@ -205,9 +205,9 @@ itkEuclideanDistancePointSetMetricTest3(int, char *[]) { int result = EXIT_SUCCESS; - double distanceThresholdPositive = 0.5; - double distanceThresholdZero = 0.0; - double distanceThresholdNegative = -8.0; + const double distanceThresholdPositive = 0.5; + const double distanceThresholdZero = 0.0; + const double distanceThresholdNegative = -8.0; const unsigned int dimension2D = 2; const unsigned int dimension3D = 3; diff --git a/Modules/Registration/Metricsv4/test/itkExpectationBasedPointSetMetricRegistrationTest.cxx b/Modules/Registration/Metricsv4/test/itkExpectationBasedPointSetMetricRegistrationTest.cxx index 4322da2f2bb..e9e0da15177 100644 --- a/Modules/Registration/Metricsv4/test/itkExpectationBasedPointSetMetricRegistrationTest.cxx +++ b/Modules/Registration/Metricsv4/test/itkExpectationBasedPointSetMetricRegistrationTest.cxx @@ -109,8 +109,8 @@ itkExpectationBasedPointSetMetricRegistrationTest(int argc, char * argv[]) unsigned long count = 0; for (float theta = 0; theta < 2.0 * itk::Math::pi; theta += 0.1) { - PointType fixedPoint; - float radius = 100.0; + PointType fixedPoint; + const float radius = 100.0; fixedPoint[0] = radius * std::cos(theta); fixedPoint[1] = radius * std::sin(theta); if constexpr (Dimension > 2) @@ -148,7 +148,7 @@ itkExpectationBasedPointSetMetricRegistrationTest(int argc, char * argv[]) // scales estimator using RegistrationParameterScalesFromShiftType = itk::RegistrationParameterScalesFromPhysicalShift; - RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = + const RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = RegistrationParameterScalesFromShiftType::New(); shiftScaleEstimator->SetMetric(metric); // needed with pointset metrics @@ -178,10 +178,12 @@ itkExpectationBasedPointSetMetricRegistrationTest(int argc, char * argv[]) // applying the resultant transform to moving points and verify result std::cout << "Fixed\tMoving\tMovingTransformed\tFixedTransformed\tDiff" << std::endl; - bool passed = true; - PointType::ValueType tolerance = 1e-4; - AffineTransformType::InverseTransformBasePointer movingInverse = metric->GetMovingTransform()->GetInverseTransform(); - AffineTransformType::InverseTransformBasePointer fixedInverse = metric->GetFixedTransform()->GetInverseTransform(); + bool passed = true; + const PointType::ValueType tolerance = 1e-4; + const AffineTransformType::InverseTransformBasePointer movingInverse = + metric->GetMovingTransform()->GetInverseTransform(); + const AffineTransformType::InverseTransformBasePointer fixedInverse = + metric->GetFixedTransform()->GetInverseTransform(); for (unsigned int n = 0; n < metric->GetNumberOfComponents(); ++n) { // compare the points in virtual domain diff --git a/Modules/Registration/Metricsv4/test/itkExpectationBasedPointSetMetricTest.cxx b/Modules/Registration/Metricsv4/test/itkExpectationBasedPointSetMetricTest.cxx index 600500dcd30..19f9b151c23 100644 --- a/Modules/Registration/Metricsv4/test/itkExpectationBasedPointSetMetricTest.cxx +++ b/Modules/Registration/Metricsv4/test/itkExpectationBasedPointSetMetricTest.cxx @@ -44,8 +44,8 @@ itkExpectationBasedPointSetMetricTestRun() unsigned long count = 0; for (float theta = 0; theta < 2.0 * itk::Math::pi; theta += 0.1) { - PointType fixedPoint; - float radius = 100.0; + PointType fixedPoint; + const float radius = 100.0; fixedPoint[0] = radius * std::cos(theta); fixedPoint[1] = radius * std::sin(theta); if constexpr (Dimension > 2) @@ -77,11 +77,11 @@ itkExpectationBasedPointSetMetricTestRun() ITK_EXERCISE_BASIC_OBJECT_METHODS(metric, ExpectationBasedPointSetToPointSetMetricv4, PointSetToPointSetMetricv4); - typename PointSetMetricType::CoordinateType pointSetSigma = 1.0; + const typename PointSetMetricType::CoordinateType pointSetSigma = 1.0; metric->SetPointSetSigma(pointSetSigma); ITK_TEST_SET_GET_VALUE(pointSetSigma, metric->GetPointSetSigma()); - unsigned int evaluationKNeighborhood = 50; + const unsigned int evaluationKNeighborhood = 50; metric->SetEvaluationKNeighborhood(evaluationKNeighborhood); ITK_TEST_SET_GET_VALUE(evaluationKNeighborhood, metric->GetEvaluationKNeighborhood()); @@ -90,8 +90,8 @@ itkExpectationBasedPointSetMetricTestRun() metric->SetMovingTransform(translationTransform); metric->Initialize(); - typename PointSetMetricType::MeasureType value = metric->GetValue(); - typename PointSetMetricType::DerivativeType derivative; + const typename PointSetMetricType::MeasureType value = metric->GetValue(); + typename PointSetMetricType::DerivativeType derivative; metric->GetDerivative(derivative); typename PointSetMetricType::MeasureType value2; diff --git a/Modules/Registration/Metricsv4/test/itkImageToImageMetricv4RegistrationTest.cxx b/Modules/Registration/Metricsv4/test/itkImageToImageMetricv4RegistrationTest.cxx index 9e682abf0f1..6874369eddd 100644 --- a/Modules/Registration/Metricsv4/test/itkImageToImageMetricv4RegistrationTest.cxx +++ b/Modules/Registration/Metricsv4/test/itkImageToImageMetricv4RegistrationTest.cxx @@ -50,13 +50,8 @@ ImageToImageMetricv4RegistrationTestRun(typename TMetric::Pointer metric, using CoordinateRepresentationType = PixelType; // Create two simple images - itk::SizeValueType ImageSize = 100; - itk::OffsetValueType boundary = 6; - if constexpr (Dimension == 3) - { - ImageSize = 60; - boundary = 4; - } + const itk::SizeValueType ImageSize = (Dimension == 3) ? 60 : 100; + const itk::OffsetValueType boundary = (Dimension == 3) ? 4 : 6; // Declare Gaussian Sources using GaussianImageSourceType = itk::GaussianImageSource; @@ -66,7 +61,7 @@ ImageToImageMetricv4RegistrationTestRun(typename TMetric::Pointer metric, auto spacing = itk::MakeFilled(itk::NumericTraits::OneValue()); - typename TImage::PointType origin{}; + const typename TImage::PointType origin{}; auto fixedImageSource = GaussianImageSourceType::New(); @@ -76,7 +71,7 @@ ImageToImageMetricv4RegistrationTestRun(typename TMetric::Pointer metric, fixedImageSource->SetNormalized(false); fixedImageSource->SetScale(1.0f); fixedImageSource->Update(); - typename TImage::Pointer fixedImage = fixedImageSource->GetOutput(); + const typename TImage::Pointer fixedImage = fixedImageSource->GetOutput(); // zero-out the boundary itk::ImageRegionIteratorWithIndex it(fixedImage, fixedImage->GetLargestPossibleRegion()); @@ -94,15 +89,15 @@ ImageToImageMetricv4RegistrationTestRun(typename TMetric::Pointer metric, // shift the fixed image to get the moving image using CyclicShiftFilterType = itk::CyclicShiftImageFilter; - auto shiftFilter = CyclicShiftFilterType::New(); - typename CyclicShiftFilterType::OffsetType imageShift; - typename CyclicShiftFilterType::OffsetValueType maxImageShift = boundary - 1; + auto shiftFilter = CyclicShiftFilterType::New(); + typename CyclicShiftFilterType::OffsetType imageShift; + const typename CyclicShiftFilterType::OffsetValueType maxImageShift = boundary - 1; imageShift.Fill(maxImageShift); imageShift[0] = maxImageShift / 2; shiftFilter->SetInput(fixedImage); shiftFilter->SetShift(imageShift); shiftFilter->Update(); - typename TImage::Pointer movingImage = shiftFilter->GetOutput(); + const typename TImage::Pointer movingImage = shiftFilter->GetOutput(); // create an affine transform using TranslationTransformType = itk::TranslationTransform; @@ -128,7 +123,7 @@ ImageToImageMetricv4RegistrationTestRun(typename TMetric::Pointer metric, { using PointSetType = typename TMetric::FixedSampledPointSetType; using PointType = typename PointSetType::PointType; - typename PointSetType::Pointer pset(PointSetType::New()); + const typename PointSetType::Pointer pset(PointSetType::New()); itk::SizeValueType ind = 0; itk::SizeValueType ct = 0; itk::ImageRegionIteratorWithIndex itS(fixedImage, fixedImage->GetLargestPossibleRegion()); @@ -157,11 +152,11 @@ ImageToImageMetricv4RegistrationTestRun(typename TMetric::Pointer metric, metric->Initialize(); // calculate initial metric value - typename TMetric::MeasureType initialValue = metric->GetValue(); + const typename TMetric::MeasureType initialValue = metric->GetValue(); // scales estimator using RegistrationParameterScalesFromPhysicalShiftType = itk::RegistrationParameterScalesFromPhysicalShift; - typename RegistrationParameterScalesFromPhysicalShiftType::Pointer shiftScaleEstimator = + const typename RegistrationParameterScalesFromPhysicalShiftType::Pointer shiftScaleEstimator = RegistrationParameterScalesFromPhysicalShiftType::New(); shiftScaleEstimator->SetMetric(metric); @@ -186,11 +181,11 @@ ImageToImageMetricv4RegistrationTestRun(typename TMetric::Pointer metric, std::cout << "Transform final parameters: " << translationTransform->GetParameters() << std::endl; // final metric value - typename TMetric::MeasureType finalValue = metric->GetValue(); + const typename TMetric::MeasureType finalValue = metric->GetValue(); std::cout << "metric value: initial: " << initialValue << ", final: " << finalValue << std::endl; // test that the final position is close to the truth - double tolerance = 0.11; + const double tolerance = 0.11; for (itk::SizeValueType n = 0; n < Dimension; ++n) { if (itk::Math::abs(1.0 - (static_cast(imageShift[n]) / translationTransform->GetParameters()[n])) > diff --git a/Modules/Registration/Metricsv4/test/itkImageToImageMetricv4Test.cxx b/Modules/Registration/Metricsv4/test/itkImageToImageMetricv4Test.cxx index 16327f7b25c..b173a9dfa45 100644 --- a/Modules/Registration/Metricsv4/test/itkImageToImageMetricv4Test.cxx +++ b/Modules/Registration/Metricsv4/test/itkImageToImageMetricv4Test.cxx @@ -236,7 +236,7 @@ ImageToImageMetricv4TestComputeIdentityTruthValues(const ImageToImageMetricv4Tes ImageToImageMetricv4TestMetricType::FixedImageGradientType fixedImageDerivative; if (metric->GetUseFixedImageGradientFilter()) { - ImageToImageMetricv4TestMetricType::FixedImageGradientImageType::ConstPointer fixedGradientImage = + const ImageToImageMetricv4TestMetricType::FixedImageGradientImageType::ConstPointer fixedGradientImage = metric->GetFixedImageGradientImage(); fixedImageDerivative = fixedGradientImage->GetPixel(itFixed.GetIndex()); } @@ -244,7 +244,7 @@ ImageToImageMetricv4TestComputeIdentityTruthValues(const ImageToImageMetricv4Tes { using FixedGradientCalculatorPointer = ImageToImageMetricv4TestMetricType::FixedImageGradientCalculatorType::ConstPointer; - FixedGradientCalculatorPointer fixedGradientCalculator = metric->GetFixedImageGradientCalculator(); + const FixedGradientCalculatorPointer fixedGradientCalculator = metric->GetFixedImageGradientCalculator(); ImageToImageMetricv4TestMetricType::FixedImagePointType point; fixedImage->TransformIndexToPhysicalPoint(itFixed.GetIndex(), point); fixedImageDerivative = fixedGradientCalculator->Evaluate(point); @@ -253,7 +253,7 @@ ImageToImageMetricv4TestComputeIdentityTruthValues(const ImageToImageMetricv4Tes } if (metric->GetUseMovingImageGradientFilter()) { - ImageToImageMetricv4TestMetricType::MovingImageGradientImageType::ConstPointer movingGradientImage = + const ImageToImageMetricv4TestMetricType::MovingImageGradientImageType::ConstPointer movingGradientImage = metric->GetMovingImageGradientImage(); movingImageDerivative = movingGradientImage->GetPixel(itMoving.GetIndex()); } @@ -380,18 +380,18 @@ ImageToImageMetricv4TestRunSingleTest(const ImageToImageMetricv4TestMetricPointe int itkImageToImageMetricv4Test(int, char ** const) { - bool origGlobalWarningValue = itk::Object::GetGlobalWarningDisplay(); + const bool origGlobalWarningValue = itk::Object::GetGlobalWarningDisplay(); itk::Object::SetGlobalWarningDisplay(true); using DimensionSizeType = unsigned int; constexpr DimensionSizeType imageSize = 4; - ImageToImageMetricv4TestImageType::SizeType size = { { imageSize, imageSize } }; - ImageToImageMetricv4TestImageType::IndexType index = { { 0, 0 } }; - ImageToImageMetricv4TestImageType::RegionType region{ index, size }; + const ImageToImageMetricv4TestImageType::SizeType size = { { imageSize, imageSize } }; + const ImageToImageMetricv4TestImageType::IndexType index = { { 0, 0 } }; + const ImageToImageMetricv4TestImageType::RegionType region{ index, size }; auto spacing = itk::MakeFilled(1.0); - ImageToImageMetricv4TestImageType::PointType origin{}; - ImageToImageMetricv4TestImageType::DirectionType direction; + const ImageToImageMetricv4TestImageType::PointType origin{}; + ImageToImageMetricv4TestImageType::DirectionType direction; direction.SetIdentity(); // Create simple test images. @@ -438,7 +438,7 @@ itkImageToImageMetricv4Test(int, char ** const) movingTransform->SetIdentity(); // The simplistic test metric - ImageToImageMetricv4TestMetricPointer metric = ImageToImageMetricv4TestMetricType::New(); + const ImageToImageMetricv4TestMetricPointer metric = ImageToImageMetricv4TestMetricType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(metric, ImageToImageMetricv4TestMetric, ImageToImageMetricv4); @@ -494,10 +494,10 @@ itkImageToImageMetricv4Test(int, char ** const) // image gradient calculation options. bool computeNewTruthValues = true; - bool useFixedImageGradientFilter = useFixedFilter == 1; + const bool useFixedImageGradientFilter = useFixedFilter == 1; ITK_TEST_SET_GET_BOOLEAN(metric, UseFixedImageGradientFilter, useFixedImageGradientFilter); - bool useMovingImageGradientFilter = useMovingFilter == 1; + const bool useMovingImageGradientFilter = useMovingFilter == 1; ITK_TEST_SET_GET_BOOLEAN(metric, UseMovingImageGradientFilter, useMovingImageGradientFilter); std::cout << "**********************************" << std::endl; @@ -564,7 +564,7 @@ itkImageToImageMetricv4Test(int, char ** const) field->SetRegions(defregion); field->Allocate(); // Fill it with 0's - DisplacementTransformType::OutputVectorType zeroVector{}; + const DisplacementTransformType::OutputVectorType zeroVector{}; field->FillBuffer(zeroVector); // Assign to transform displacementTransform->SetDisplacementField(field); @@ -581,10 +581,10 @@ itkImageToImageMetricv4Test(int, char ** const) bool useMovingImageGradientFilter = true; ITK_TEST_SET_GET_BOOLEAN(metric, UseMovingImageGradientFilter, useMovingImageGradientFilter); - bool useVirtualSampledPointSet = false; + const bool useVirtualSampledPointSet = false; ITK_TEST_SET_GET_BOOLEAN(metric, UseVirtualSampledPointSet, useVirtualSampledPointSet); - bool useFloatingPointCorrection = false; + const bool useFloatingPointCorrection = false; ITK_TEST_SET_GET_BOOLEAN(metric, UseFloatingPointCorrection, useFloatingPointCorrection); // Tell the metric to compute image gradients for both fixed and moving. @@ -627,7 +627,7 @@ itkImageToImageMetricv4Test(int, char ** const) using PointType = PointSetType::PointType; PointSetType::CoordinateType testPointCoords[2]; - PointSetType::Pointer pset(PointSetType::New()); + const PointSetType::Pointer pset(PointSetType::New()); std::cout << "Creating point set..." << std::endl; DimensionSizeType ind = 0; @@ -646,7 +646,7 @@ itkImageToImageMetricv4Test(int, char ** const) metric->SetFixedSampledPointSet(pset); ITK_TEST_SET_GET_VALUE(pset, metric->GetFixedSampledPointSet()); - bool useSampledPointSet = true; + const bool useSampledPointSet = true; ITK_TEST_SET_GET_BOOLEAN(metric, UseSampledPointSet, useSampledPointSet); #if !defined(ITK_LEGACY_REMOVE) @@ -688,12 +688,12 @@ itkImageToImageMetricv4Test(int, char ** const) metric->GetDerivative(derivative); std::cout << "Derivative: " << derivative << std::endl; - typename ImageToImageMetricv4TestMetricType::DerivativeValueType floatingPointCorrectionResolution = 1.0; + const typename ImageToImageMetricv4TestMetricType::DerivativeValueType floatingPointCorrectionResolution = 1.0; metric->SetFloatingPointCorrectionResolution(floatingPointCorrectionResolution); ITK_TEST_SET_GET_VALUE(floatingPointCorrectionResolution, metric->GetFloatingPointCorrectionResolution()); // Empty method body by default; called for coverage purposes - itk::ThreadIdType thread = 0; + const itk::ThreadIdType thread = 0; metric->FinalizeThread(thread); diff --git a/Modules/Registration/Metricsv4/test/itkJensenHavrdaCharvatTsallisPointSetMetricRegistrationTest.cxx b/Modules/Registration/Metricsv4/test/itkJensenHavrdaCharvatTsallisPointSetMetricRegistrationTest.cxx index 55cc0468abd..fd75249e149 100644 --- a/Modules/Registration/Metricsv4/test/itkJensenHavrdaCharvatTsallisPointSetMetricRegistrationTest.cxx +++ b/Modules/Registration/Metricsv4/test/itkJensenHavrdaCharvatTsallisPointSetMetricRegistrationTest.cxx @@ -113,8 +113,8 @@ itkJensenHavrdaCharvatTsallisPointSetMetricRegistrationTest(int argc, char * arg unsigned long count = 0; for (float theta = 0; theta < 2.0 * itk::Math::pi; theta += 0.1) { - PointType fixedPoint; - float radius = 100.0; + PointType fixedPoint; + const float radius = 100.0; fixedPoint[0] = radius * std::cos(theta); fixedPoint[1] = radius * std::sin(theta); if constexpr (Dimension > 2) @@ -156,7 +156,7 @@ itkJensenHavrdaCharvatTsallisPointSetMetricRegistrationTest(int argc, char * arg // scales estimator using RegistrationParameterScalesFromShiftType = itk::RegistrationParameterScalesFromPhysicalShift; - RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = + const RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = RegistrationParameterScalesFromShiftType::New(); shiftScaleEstimator->SetMetric(metric); // needed with pointset metrics @@ -186,10 +186,12 @@ itkJensenHavrdaCharvatTsallisPointSetMetricRegistrationTest(int argc, char * arg // applying the resultant transform to moving points and verify result std::cout << "Fixed\tMoving\tMovingTransformed\tFixedTransformed\tDiff" << std::endl; - bool passed = true; - PointType::ValueType tolerance = 1e-2; - AffineTransformType::InverseTransformBasePointer movingInverse = metric->GetMovingTransform()->GetInverseTransform(); - AffineTransformType::InverseTransformBasePointer fixedInverse = metric->GetFixedTransform()->GetInverseTransform(); + bool passed = true; + const PointType::ValueType tolerance = 1e-2; + const AffineTransformType::InverseTransformBasePointer movingInverse = + metric->GetMovingTransform()->GetInverseTransform(); + const AffineTransformType::InverseTransformBasePointer fixedInverse = + metric->GetFixedTransform()->GetInverseTransform(); for (unsigned int n = 0; n < metric->GetNumberOfComponents(); ++n) { // compare the points in virtual domain diff --git a/Modules/Registration/Metricsv4/test/itkJensenHavrdaCharvatTsallisPointSetMetricTest.cxx b/Modules/Registration/Metricsv4/test/itkJensenHavrdaCharvatTsallisPointSetMetricTest.cxx index 21aded46bd3..0289012d73a 100644 --- a/Modules/Registration/Metricsv4/test/itkJensenHavrdaCharvatTsallisPointSetMetricTest.cxx +++ b/Modules/Registration/Metricsv4/test/itkJensenHavrdaCharvatTsallisPointSetMetricTest.cxx @@ -50,8 +50,8 @@ itkJensenHavrdaCharvatTsallisPointSetMetricTestRun() unsigned long count = 0; for (float theta = 0; theta < 2.0 * itk::Math::pi; theta += 0.1) { - float radius = 100.0; - PointType fixedPoint; + const float radius = 100.0; + PointType fixedPoint; fixedPoint[0] = radius * std::cos(theta); fixedPoint[1] = radius * std::sin(theta); // simplistic point set test: @@ -83,12 +83,12 @@ itkJensenHavrdaCharvatTsallisPointSetMetricTestRun() // check various alpha values between accepted values of [1.0, 2.0] - unsigned int numberOfAlphaValues = 6; - float alphaValues[] = { 1.0f, 1.2f, 1.4f, 1.6f, 1.8f, 2.0f }; + const unsigned int numberOfAlphaValues = 6; + const float alphaValues[] = { 1.0f, 1.2f, 1.4f, 1.6f, 1.8f, 2.0f }; - unsigned int evaluationKNeighborhood = 50; - auto useAnisotropicCovariances = false; - unsigned int covarianceKNeighborhood = 5; + const unsigned int evaluationKNeighborhood = 50; + auto useAnisotropicCovariances = false; + const unsigned int covarianceKNeighborhood = 5; for (unsigned int i = 0; i < numberOfAlphaValues; ++i) { @@ -106,7 +106,7 @@ itkJensenHavrdaCharvatTsallisPointSetMetricTestRun() metric->SetAlpha(alphaValues[i]); ITK_TEST_SET_GET_VALUE(alphaValues[i], metric->GetAlpha()); - typename PointSetMetricType::RealType pointSetSigma = 1.0; + const typename PointSetMetricType::RealType pointSetSigma = 1.0; metric->SetPointSetSigma(pointSetSigma); ITK_TEST_SET_GET_VALUE(pointSetSigma, metric->GetPointSetSigma()); @@ -118,7 +118,7 @@ itkJensenHavrdaCharvatTsallisPointSetMetricTestRun() metric->SetCovarianceKNeighborhood(covarianceKNeighborhood); ITK_TEST_SET_GET_VALUE(covarianceKNeighborhood, metric->GetCovarianceKNeighborhood()); - typename PointSetMetricType::RealType kernelSigma = 10.0; + const typename PointSetMetricType::RealType kernelSigma = 10.0; metric->SetKernelSigma(kernelSigma); ITK_TEST_SET_GET_VALUE(kernelSigma, metric->GetKernelSigma()); @@ -128,8 +128,8 @@ itkJensenHavrdaCharvatTsallisPointSetMetricTestRun() metric->Initialize(); - typename PointSetMetricType::MeasureType value = metric->GetValue(); - typename PointSetMetricType::DerivativeType derivative; + const typename PointSetMetricType::MeasureType value = metric->GetValue(); + typename PointSetMetricType::DerivativeType derivative; metric->GetDerivative(derivative); typename PointSetMetricType::MeasureType value2; typename PointSetMetricType::DerivativeType derivative2; diff --git a/Modules/Registration/Metricsv4/test/itkJointHistogramMutualInformationImageToImageMetricv4Test.cxx b/Modules/Registration/Metricsv4/test/itkJointHistogramMutualInformationImageToImageMetricv4Test.cxx index 8b2826108d4..8306a55921d 100644 --- a/Modules/Registration/Metricsv4/test/itkJointHistogramMutualInformationImageToImageMetricv4Test.cxx +++ b/Modules/Registration/Metricsv4/test/itkJointHistogramMutualInformationImageToImageMetricv4Test.cxx @@ -35,12 +35,12 @@ itkJointHistogramMutualInformationImageToImageMetricv4Test(int, char *[]) constexpr unsigned int imageDimensionality = 3; using ImageType = itk::Image; - auto size = ImageType::SizeType::Filled(imageSize); - ImageType::IndexType index{}; - ImageType::RegionType region{ index, size }; - auto spacing = itk::MakeFilled(1.0); - ImageType::PointType origin{}; - ImageType::DirectionType direction; + auto size = ImageType::SizeType::Filled(imageSize); + const ImageType::IndexType index{}; + const ImageType::RegionType region{ index, size }; + auto spacing = itk::MakeFilled(1.0); + const ImageType::PointType origin{}; + ImageType::DirectionType direction; direction.SetIdentity(); /* Create simple test images. */ @@ -92,11 +92,11 @@ itkJointHistogramMutualInformationImageToImageMetricv4Test(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(metric, JointHistogramMutualInformationImageToImageMetricv4, ImageToImageMetricv4); - itk::SizeValueType numberOfHistogramBins = 6; + const itk::SizeValueType numberOfHistogramBins = 6; metric->SetNumberOfHistogramBins(numberOfHistogramBins); ITK_TEST_SET_GET_VALUE(numberOfHistogramBins, metric->GetNumberOfHistogramBins()); - double varianceForJointPDFSmoothing = 1.5; + const double varianceForJointPDFSmoothing = 1.5; metric->SetVarianceForJointPDFSmoothing(varianceForJointPDFSmoothing); ITK_TEST_SET_GET_VALUE(varianceForJointPDFSmoothing, metric->GetVarianceForJointPDFSmoothing()); diff --git a/Modules/Registration/Metricsv4/test/itkJointHistogramMutualInformationImageToImageRegistrationTest.cxx b/Modules/Registration/Metricsv4/test/itkJointHistogramMutualInformationImageToImageRegistrationTest.cxx index 792086209a9..a3dd1bdf88c 100644 --- a/Modules/Registration/Metricsv4/test/itkJointHistogramMutualInformationImageToImageRegistrationTest.cxx +++ b/Modules/Registration/Metricsv4/test/itkJointHistogramMutualInformationImageToImageRegistrationTest.cxx @@ -91,9 +91,9 @@ class JointPDFStatus : public itk::Command std::cout << "Current optimizer iteration: " << optimizer->GetCurrentIteration() << '\n'; std::cout << "Current optimizer value: " << optimizer->GetCurrentMetricValue() << '\n'; - std::string ext = itksys::SystemTools::GetFilenameExtension(this->m_OutputFileNameBase); - std::string name = itksys::SystemTools::GetFilenameWithoutExtension(this->m_OutputFileNameBase); - std::string path = itksys::SystemTools::GetFilenamePath(this->m_OutputFileNameBase); + const std::string ext = itksys::SystemTools::GetFilenameExtension(this->m_OutputFileNameBase); + const std::string name = itksys::SystemTools::GetFilenameWithoutExtension(this->m_OutputFileNameBase); + const std::string path = itksys::SystemTools::GetFilenamePath(this->m_OutputFileNameBase); std::ostringstream ostrm; ostrm << name << "_jointpdf_" << this->m_Count << ext; std::cout << "Writing joint pdf to: " << ostrm.str() << std::endl; @@ -189,9 +189,9 @@ itkJointHistogramMutualInformationImageToImageRegistrationTest(int argc, char * // get the images fixedImageReader->Update(); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); movingImageReader->Update(); - MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); + const MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); /** define a resample filter that will ultimately be used to deform the image */ using ResampleFilterType = itk::ResampleImageFilter; @@ -223,7 +223,7 @@ itkJointHistogramMutualInformationImageToImageRegistrationTest(int argc, char * std::cout << "fixedImage->GetLargestPossibleRegion(): " << fixedImage->GetLargestPossibleRegion() << std::endl; field->Allocate(); // Fill it with 0's - DisplacementTransformType::OutputVectorType zeroVector{}; + const DisplacementTransformType::OutputVectorType zeroVector{}; field->FillBuffer(zeroVector); // Assign to transform displacementTransform->SetDisplacementField(field); @@ -242,7 +242,7 @@ itkJointHistogramMutualInformationImageToImageRegistrationTest(int argc, char * metric->SetNumberOfHistogramBins(20); using PointType = PointSetType::PointType; - PointSetType::Pointer pset(PointSetType::New()); + const PointSetType::Pointer pset(PointSetType::New()); unsigned long ind = 0; unsigned long ct = 0; itk::ImageRegionIteratorWithIndex It(fixedImage, fixedImage->GetLargestPossibleRegion()); @@ -283,7 +283,7 @@ itkJointHistogramMutualInformationImageToImageRegistrationTest(int argc, char * metric->Initialize(); using RegistrationParameterScalesFromShiftType = itk::RegistrationParameterScalesFromPhysicalShift; - RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = + const RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = RegistrationParameterScalesFromShiftType::New(); shiftScaleEstimator->SetMetric(metric); @@ -359,12 +359,12 @@ itkJointHistogramMutualInformationImageToImageRegistrationTest(int argc, char * // write out the displacement field using DisplacementWriterType = itk::ImageFileWriter; - auto displacementwriter = DisplacementWriterType::New(); - std::string outfilename(argv[3]); - std::string ext = itksys::SystemTools::GetFilenameExtension(outfilename); - std::string name = itksys::SystemTools::GetFilenameWithoutExtension(outfilename); - std::string path = itksys::SystemTools::GetFilenamePath(outfilename); - std::string defout = path + std::string("/") + name + std::string("_def") + ext; + auto displacementwriter = DisplacementWriterType::New(); + const std::string outfilename(argv[3]); + const std::string ext = itksys::SystemTools::GetFilenameExtension(outfilename); + const std::string name = itksys::SystemTools::GetFilenameWithoutExtension(outfilename); + const std::string path = itksys::SystemTools::GetFilenamePath(outfilename); + const std::string defout = path + std::string("/") + name + std::string("_def") + ext; displacementwriter->SetFileName(defout.c_str()); displacementwriter->SetInput(displacementTransform->GetDisplacementField()); displacementwriter->Update(); diff --git a/Modules/Registration/Metricsv4/test/itkLabeledPointSetMetricRegistrationTest.cxx b/Modules/Registration/Metricsv4/test/itkLabeledPointSetMetricRegistrationTest.cxx index 68c36db422f..6466829f03b 100644 --- a/Modules/Registration/Metricsv4/test/itkLabeledPointSetMetricRegistrationTest.cxx +++ b/Modules/Registration/Metricsv4/test/itkLabeledPointSetMetricRegistrationTest.cxx @@ -84,8 +84,8 @@ itkLabeledPointSetMetricRegistrationTestPerMetric(unsigned int numberOfIteration { auto label = static_cast(1.5 + count / 35); - PointType fixedPoint; - float radius = 100.0; + PointType fixedPoint; + const float radius = 100.0; fixedPoint[0] = radius * std::cos(theta); fixedPoint[1] = radius * std::sin(theta); if (PointSetType::PointDimension > 2) @@ -123,7 +123,7 @@ itkLabeledPointSetMetricRegistrationTestPerMetric(unsigned int numberOfIteration // scales estimator using RegistrationParameterScalesFromShiftType = itk::RegistrationParameterScalesFromPhysicalShift; - typename RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = + const typename RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = RegistrationParameterScalesFromShiftType::New(); shiftScaleEstimator->SetMetric(metric); // needed with pointset metrics @@ -153,11 +153,11 @@ itkLabeledPointSetMetricRegistrationTestPerMetric(unsigned int numberOfIteration // applying the resultant transform to moving points and verify result std::cout << "Fixed\tMoving\tMovingTransformed\tFixedTransformed\tDiff" << std::endl; - bool passed = true; - typename PointType::ValueType tolerance = 1e-2; - typename AffineTransformType::InverseTransformBasePointer movingInverse = + bool passed = true; + const typename PointType::ValueType tolerance = 1e-2; + const typename AffineTransformType::InverseTransformBasePointer movingInverse = metric->GetMovingTransform()->GetInverseTransform(); - typename AffineTransformType::InverseTransformBasePointer fixedInverse = + const typename AffineTransformType::InverseTransformBasePointer fixedInverse = metric->GetFixedTransform()->GetInverseTransform(); for (unsigned int n = 0; n < metric->GetNumberOfComponents(); ++n) { @@ -199,8 +199,8 @@ itkLabeledPointSetMetricRegistrationTest(int argc, char * argv[]) { using PointSetMetricType = itk::EuclideanDistancePointSetToPointSetMetricv4; - auto metric = PointSetMetricType::New(); - int success = + auto metric = PointSetMetricType::New(); + const int success = itkLabeledPointSetMetricRegistrationTestPerMetric(numberOfIterations, metric.GetPointer()); allSuccess *= success; @@ -211,7 +211,7 @@ itkLabeledPointSetMetricRegistrationTest(int argc, char * argv[]) auto metric = PointSetMetricType::New(); metric->SetPointSetSigma(2.0); metric->SetEvaluationKNeighborhood(3); - int success = + const int success = itkLabeledPointSetMetricRegistrationTestPerMetric(numberOfIterations, metric.GetPointer()); allSuccess *= success; @@ -226,7 +226,7 @@ itkLabeledPointSetMetricRegistrationTest(int argc, char * argv[]) metric->SetCovarianceKNeighborhood(5); metric->SetEvaluationKNeighborhood(10); metric->SetAlpha(1.1); - int success = + const int success = itkLabeledPointSetMetricRegistrationTestPerMetric(numberOfIterations, metric.GetPointer()); allSuccess *= success; diff --git a/Modules/Registration/Metricsv4/test/itkLabeledPointSetMetricTest.cxx b/Modules/Registration/Metricsv4/test/itkLabeledPointSetMetricTest.cxx index 6424bd37602..ea4bf4dd02e 100644 --- a/Modules/Registration/Metricsv4/test/itkLabeledPointSetMetricTest.cxx +++ b/Modules/Registration/Metricsv4/test/itkLabeledPointSetMetricTest.cxx @@ -45,7 +45,7 @@ itkLabeledPointSetMetricTestRun() offset[d] = 1.1 + d; } unsigned long count = 0; - float pointSetRadius = 100.0; + const float pointSetRadius = 100.0; for (float theta = 0; theta < 2.0 * itk::Math::pi; theta += 0.1) { LabelType label = 1; @@ -102,8 +102,8 @@ itkLabeledPointSetMetricTestRun() metric->SetMovingTransform(translationTransform); metric->Initialize(); - typename PointSetMetricType::MeasureType value = metric->GetValue(); - typename PointSetMetricType::DerivativeType derivative; + const typename PointSetMetricType::MeasureType value = metric->GetValue(); + typename PointSetMetricType::DerivativeType derivative; metric->GetDerivative(derivative); typename PointSetMetricType::MeasureType value2; typename PointSetMetricType::DerivativeType derivative2; diff --git a/Modules/Registration/Metricsv4/test/itkMattesMutualInformationImageToImageMetricv4RegistrationTest.cxx b/Modules/Registration/Metricsv4/test/itkMattesMutualInformationImageToImageMetricv4RegistrationTest.cxx index 5b6cc66b716..9f6b13a7555 100644 --- a/Modules/Registration/Metricsv4/test/itkMattesMutualInformationImageToImageMetricv4RegistrationTest.cxx +++ b/Modules/Registration/Metricsv4/test/itkMattesMutualInformationImageToImageMetricv4RegistrationTest.cxx @@ -93,9 +93,9 @@ itkMattesMutualInformationImageToImageMetricv4RegistrationTest(int argc, char * // get the images fixedImageReader->Update(); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); movingImageReader->Update(); - MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); + const MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); /** define a resample filter that will ultimately be used to deform the image */ using ResampleFilterType = itk::ResampleImageFilter; @@ -127,7 +127,7 @@ itkMattesMutualInformationImageToImageMetricv4RegistrationTest(int argc, char * std::cout << "fixedImage->GetLargestPossibleRegion(): " << fixedImage->GetLargestPossibleRegion() << std::endl; field->Allocate(); // Fill it with 0's - DisplacementTransformType::OutputVectorType zeroVector{}; + const DisplacementTransformType::OutputVectorType zeroVector{}; field->FillBuffer(zeroVector); // Assign to transform displacementTransform->SetDisplacementField(field); @@ -153,7 +153,7 @@ itkMattesMutualInformationImageToImageMetricv4RegistrationTest(int argc, char * else { using PointType = PointSetType::PointType; - PointSetType::Pointer pset(PointSetType::New()); + const PointSetType::Pointer pset(PointSetType::New()); unsigned long ind = 0; unsigned long ct = 0; itk::ImageRegionIteratorWithIndex It(fixedImage, fixedImage->GetLargestPossibleRegion()); @@ -190,7 +190,7 @@ itkMattesMutualInformationImageToImageMetricv4RegistrationTest(int argc, char * metric->Initialize(); using RegistrationParameterScalesFromShiftType = itk::RegistrationParameterScalesFromPhysicalShift; - RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = + const RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = RegistrationParameterScalesFromShiftType::New(); shiftScaleEstimator->SetMetric(metric); @@ -266,12 +266,12 @@ itkMattesMutualInformationImageToImageMetricv4RegistrationTest(int argc, char * // write out the displacement field using DisplacementWriterType = itk::ImageFileWriter; - auto displacementwriter = DisplacementWriterType::New(); - std::string outfilename(argv[3]); - std::string ext = itksys::SystemTools::GetFilenameExtension(outfilename); - std::string name = itksys::SystemTools::GetFilenameWithoutExtension(outfilename); - std::string path = itksys::SystemTools::GetFilenamePath(outfilename); - std::string defout = path + std::string("/") + name + std::string("_def") + ext; + auto displacementwriter = DisplacementWriterType::New(); + const std::string outfilename(argv[3]); + const std::string ext = itksys::SystemTools::GetFilenameExtension(outfilename); + const std::string name = itksys::SystemTools::GetFilenameWithoutExtension(outfilename); + const std::string path = itksys::SystemTools::GetFilenamePath(outfilename); + const std::string defout = path + std::string("/") + name + std::string("_def") + ext; displacementwriter->SetFileName(defout.c_str()); displacementwriter->SetInput(displacementTransform->GetDisplacementField()); displacementwriter->Update(); diff --git a/Modules/Registration/Metricsv4/test/itkMattesMutualInformationImageToImageMetricv4Test.cxx b/Modules/Registration/Metricsv4/test/itkMattesMutualInformationImageToImageMetricv4Test.cxx index 8598954a644..a6c5f34598c 100644 --- a/Modules/Registration/Metricsv4/test/itkMattesMutualInformationImageToImageMetricv4Test.cxx +++ b/Modules/Registration/Metricsv4/test/itkMattesMutualInformationImageToImageMetricv4Test.cxx @@ -63,10 +63,10 @@ TestMattesMetricWithAffineTransform(TInterpolator * const interpolator, const bo const unsigned int ImageDimension = MovingImageType::ImageDimension; // Image size is scaled to represent sqrt(256^3) - typename MovingImageType::SizeType size = { { static_cast(imageSize), - static_cast(imageSize) } }; - typename MovingImageType::IndexType index = { { 0, 0 } }; - typename MovingImageType::RegionType region{ index, size }; + const typename MovingImageType::SizeType size = { { static_cast(imageSize), + static_cast(imageSize) } }; + const typename MovingImageType::IndexType index = { { 0, 0 } }; + const typename MovingImageType::RegionType region{ index, size }; typename MovingImageType::SpacingType imgSpacing; imgSpacing[0] = 3.0; @@ -220,7 +220,7 @@ TestMattesMetricWithAffineTransform(TInterpolator * const interpolator, const bo metric->SetMovingImage(imgMoving); // set the number of histogram bins - itk::SizeValueType numberOfHistogramBins = 50; + const itk::SizeValueType numberOfHistogramBins = 50; metric->SetNumberOfHistogramBins(numberOfHistogramBins); ITK_TEST_SET_GET_VALUE(numberOfHistogramBins, metric->GetNumberOfHistogramBins()); @@ -253,7 +253,7 @@ TestMattesMetricWithAffineTransform(TInterpolator * const interpolator, const bo { using PointSetType = typename MetricType::FixedSampledPointSetType; using PointType = typename PointSetType::PointType; - typename PointSetType::Pointer pset(PointSetType::New()); + const typename PointSetType::Pointer pset(PointSetType::New()); unsigned int ind = 0; unsigned int ct = 0; itk::ImageRegionIteratorWithIndex It(imgFixed, imgFixed->GetLargestPossibleRegion()); diff --git a/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4OnVectorTest.cxx b/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4OnVectorTest.cxx index dd56c463c83..b70ff97ddf1 100644 --- a/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4OnVectorTest.cxx +++ b/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4OnVectorTest.cxx @@ -38,12 +38,12 @@ itkMeanSquaresImageToImageMetricv4OnVectorTest(int, char ** const) using VectorType = itk::Vector; using ImageType = itk::Image; - auto size = ImageType::SizeType::Filled(imageSize); - ImageType::IndexType index{}; - ImageType::RegionType region{ index, size }; - auto spacing = itk::MakeFilled(1.0); - ImageType::PointType origin{}; - ImageType::DirectionType direction; + auto size = ImageType::SizeType::Filled(imageSize); + const ImageType::IndexType index{}; + const ImageType::RegionType region{ index, size }; + auto spacing = itk::MakeFilled(1.0); + const ImageType::PointType origin{}; + ImageType::DirectionType direction; direction.SetIdentity(); /* Create simple test images. */ diff --git a/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4OnVectorTest2.cxx b/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4OnVectorTest2.cxx index 7f261c791fe..699791bbd1a 100644 --- a/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4OnVectorTest2.cxx +++ b/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4OnVectorTest2.cxx @@ -34,12 +34,12 @@ itkMeanSquaresImageToImageMetricv4OnVectorTest2Run(typename TMetric::MeasureType using ImageType = typename TMetric::FixedImageType; - auto size = ImageType::SizeType::Filled(imageSize); - typename ImageType::IndexType index{}; - typename ImageType::RegionType region{ index, size }; - auto spacing = itk::MakeFilled(1.0); - typename ImageType::PointType origin{}; - typename ImageType::DirectionType direction; + auto size = ImageType::SizeType::Filled(imageSize); + const typename ImageType::IndexType index{}; + const typename ImageType::RegionType region{ index, size }; + auto spacing = itk::MakeFilled(1.0); + const typename ImageType::PointType origin{}; + typename ImageType::DirectionType direction; direction.SetIdentity(); /* Create simple test images. */ @@ -71,8 +71,8 @@ itkMeanSquaresImageToImageMetricv4OnVectorTest2Run(typename TMetric::MeasureType unsigned int count = 1; while (!itFixed.IsAtEnd()) { - PixelType pix1(count); - PixelType pix2(1.0 / count); + const PixelType pix1(count); + const PixelType pix2(1.0 / count); itFixed.Set(pix1); itMoving.Set(pix2); count++; @@ -165,7 +165,7 @@ itkMeanSquaresImageToImageMetricv4OnVectorTest2(int, char ** const) std::cout << "scalarMeasure: " << scalarMeasure << " scalarDerivative: " << scalarDerivative << std::endl; /* Compare */ - double tolerance = 1e-8; + const double tolerance = 1e-8; if (itk::Math::abs(scalarMeasure - (vectorMeasure / vectorLength)) > tolerance) { std::cerr << "Measures do not match within tolerance. scalarMeasure, vectorMeasure: " << scalarMeasure << ", " diff --git a/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4RegistrationTest.cxx b/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4RegistrationTest.cxx index 486ed3c6430..dcd73d8fddb 100644 --- a/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4RegistrationTest.cxx +++ b/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4RegistrationTest.cxx @@ -90,9 +90,9 @@ itkMeanSquaresImageToImageMetricv4RegistrationTest(int argc, char * argv[]) // get the images fixedImageReader->Update(); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); movingImageReader->Update(); - MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); + const MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); /** define a resample filter that will ultimately be used to deform the image */ using ResampleFilterType = itk::ResampleImageFilter; @@ -124,7 +124,7 @@ itkMeanSquaresImageToImageMetricv4RegistrationTest(int argc, char * argv[]) std::cout << "fixedImage->GetLargestPossibleRegion(): " << fixedImage->GetLargestPossibleRegion() << std::endl; field->Allocate(); // Fill it with 0's - DisplacementTransformType::OutputVectorType zeroVector{}; + const DisplacementTransformType::OutputVectorType zeroVector{}; field->FillBuffer(zeroVector); // Assign to transform displacementTransform->SetDisplacementField(field); @@ -142,7 +142,7 @@ itkMeanSquaresImageToImageMetricv4RegistrationTest(int argc, char * argv[]) auto metric = MetricType::New(); using PointType = PointSetType::PointType; - PointSetType::Pointer pset(PointSetType::New()); + const PointSetType::Pointer pset(PointSetType::New()); unsigned long ind = 0; unsigned long ct = 0; itk::ImageRegionIteratorWithIndex It(fixedImage, fixedImage->GetLargestPossibleRegion()); @@ -179,7 +179,7 @@ itkMeanSquaresImageToImageMetricv4RegistrationTest(int argc, char * argv[]) metric->Initialize(); using RegistrationParameterScalesFromShiftType = itk::RegistrationParameterScalesFromPhysicalShift; - RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = + const RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = RegistrationParameterScalesFromShiftType::New(); shiftScaleEstimator->SetMetric(metric); @@ -258,12 +258,12 @@ itkMeanSquaresImageToImageMetricv4RegistrationTest(int argc, char * argv[]) // write out the displacement field using DisplacementWriterType = itk::ImageFileWriter; - auto displacementwriter = DisplacementWriterType::New(); - std::string outfilename(argv[3]); - std::string ext = itksys::SystemTools::GetFilenameExtension(outfilename); - std::string name = itksys::SystemTools::GetFilenameWithoutExtension(outfilename); - std::string path = itksys::SystemTools::GetFilenamePath(outfilename); - std::string defout = path + std::string("/") + name + std::string("_def") + ext; + auto displacementwriter = DisplacementWriterType::New(); + const std::string outfilename(argv[3]); + const std::string ext = itksys::SystemTools::GetFilenameExtension(outfilename); + const std::string name = itksys::SystemTools::GetFilenameWithoutExtension(outfilename); + const std::string path = itksys::SystemTools::GetFilenamePath(outfilename); + const std::string defout = path + std::string("/") + name + std::string("_def") + ext; displacementwriter->SetFileName(defout.c_str()); displacementwriter->SetInput(displacementTransform->GetDisplacementField()); displacementwriter->Update(); diff --git a/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4RegistrationTest2.cxx b/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4RegistrationTest2.cxx index 0be5eed6584..68c6dfbd610 100644 --- a/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4RegistrationTest2.cxx +++ b/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4RegistrationTest2.cxx @@ -104,9 +104,9 @@ itkMeanSquaresImageToImageMetricv4RegistrationTest2(int argc, char * argv[]) movingImageReader->SetFileName(argv[2]); fixedImageReader->Update(); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); movingImageReader->Update(); - MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); + const MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); /** define a resample filter that will ultimately be used to deform the image */ using ResampleFilterType = itk::ResampleImageFilter; @@ -133,7 +133,7 @@ itkMeanSquaresImageToImageMetricv4RegistrationTest2(int argc, char * argv[]) auto metric = MetricType::New(); using PointType = PointSetType::PointType; - PointSetType::Pointer pset(PointSetType::New()); + const PointSetType::Pointer pset(PointSetType::New()); unsigned long ind = 0; itk::ImageRegionIteratorWithIndex it(fixedImage, fixedImage->GetLargestPossibleRegion()); @@ -168,7 +168,7 @@ itkMeanSquaresImageToImageMetricv4RegistrationTest2(int argc, char * argv[]) metric->Initialize(); using RegistrationParameterScalesFromShiftType = itk::RegistrationParameterScalesFromPhysicalShift; - RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = + const RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = RegistrationParameterScalesFromShiftType::New(); shiftScaleEstimator->SetMetric(metric); diff --git a/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4SpeedTest.cxx b/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4SpeedTest.cxx index f2acab04084..dfdd2fec595 100644 --- a/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4SpeedTest.cxx +++ b/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4SpeedTest.cxx @@ -31,20 +31,20 @@ itkMeanSquaresImageToImageMetricv4SpeedTest(int argc, char * argv[]) std::cerr << "usage: " << itkNameOfTestExecutableMacro(argv) << ": image-dimension number-of-reps" << std::endl; return EXIT_FAILURE; } - int imageSize = std::stoi(argv[1]); - int numberOfReps = std::stoi(argv[2]); + const int imageSize = std::stoi(argv[1]); + const int numberOfReps = std::stoi(argv[2]); std::cout << "image dim: " << imageSize << ", reps: " << numberOfReps << std::endl; constexpr unsigned int imageDimensionality = 3; using ImageType = itk::Image; - auto size = ImageType::SizeType::Filled(imageSize); - ImageType::IndexType index{}; - ImageType::RegionType region{ index, size }; - auto spacing = itk::MakeFilled(1.0); - ImageType::PointType origin{}; - ImageType::DirectionType direction; + auto size = ImageType::SizeType::Filled(imageSize); + const ImageType::IndexType index{}; + const ImageType::RegionType region{ index, size }; + auto spacing = itk::MakeFilled(1.0); + const ImageType::PointType origin{}; + ImageType::DirectionType direction; direction.SetIdentity(); /* Create simple test images. */ diff --git a/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4Test.cxx b/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4Test.cxx index 8cf3915fb55..8e209d99084 100644 --- a/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4Test.cxx +++ b/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4Test.cxx @@ -34,12 +34,12 @@ itkMeanSquaresImageToImageMetricv4Test(int, char ** const) constexpr unsigned int imageDimensionality = 3; using ImageType = itk::Image; - auto size = ImageType::SizeType::Filled(imageSize); - ImageType::IndexType index{}; - ImageType::RegionType region{ index, size }; - auto spacing = itk::MakeFilled(1.0); - ImageType::PointType origin{}; - ImageType::DirectionType direction; + auto size = ImageType::SizeType::Filled(imageSize); + const ImageType::IndexType index{}; + const ImageType::RegionType region{ index, size }; + auto spacing = itk::MakeFilled(1.0); + const ImageType::PointType origin{}; + ImageType::DirectionType direction; direction.SetIdentity(); /* Create simple test images. */ diff --git a/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4VectorRegistrationTest.cxx b/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4VectorRegistrationTest.cxx index af3d2288f65..02ba19679cb 100644 --- a/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4VectorRegistrationTest.cxx +++ b/Modules/Registration/Metricsv4/test/itkMeanSquaresImageToImageMetricv4VectorRegistrationTest.cxx @@ -95,9 +95,9 @@ itkMeanSquaresImageToImageMetricv4VectorRegistrationTest(int argc, char * argv[] // get the images fixedImageReader->Update(); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); movingImageReader->Update(); - MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); + const MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); /** define a resample filter that will ultimately be used to deform the image */ using ResampleFilterType = itk::ResampleImageFilter; @@ -128,7 +128,7 @@ itkMeanSquaresImageToImageMetricv4VectorRegistrationTest(int argc, char * argv[] std::cout << "fixedImage->GetLargestPossibleRegion(): " << fixedImage->GetLargestPossibleRegion() << std::endl; field->Allocate(); // Fill it with 0's - DisplacementTransformType::OutputVectorType zeroVector{}; + const DisplacementTransformType::OutputVectorType zeroVector{}; field->FillBuffer(zeroVector); // Assign to transform displacementTransform->SetDisplacementField(field); @@ -150,7 +150,7 @@ itkMeanSquaresImageToImageMetricv4VectorRegistrationTest(int argc, char * argv[] auto metric = MetricType::New(); using PointType = PointSetType::PointType; - PointSetType::Pointer pset(PointSetType::New()); + const PointSetType::Pointer pset(PointSetType::New()); unsigned long ind = 0; unsigned long ct = 0; itk::ImageRegionIteratorWithIndex It(fixedImage, fixedImage->GetLargestPossibleRegion()); @@ -187,7 +187,7 @@ itkMeanSquaresImageToImageMetricv4VectorRegistrationTest(int argc, char * argv[] metric->Initialize(); using RegistrationParameterScalesFromShiftType = itk::RegistrationParameterScalesFromPhysicalShift; - RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = + const RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = RegistrationParameterScalesFromShiftType::New(); shiftScaleEstimator->SetMetric(metric); @@ -289,12 +289,12 @@ itkMeanSquaresImageToImageMetricv4VectorRegistrationTest(int argc, char * argv[] // write out the displacement field using DisplacementWriterType = itk::ImageFileWriter; - auto displacementwriter = DisplacementWriterType::New(); - std::string outfilename(argv[3]); - std::string ext = itksys::SystemTools::GetFilenameExtension(outfilename); - std::string name = itksys::SystemTools::GetFilenameWithoutExtension(outfilename); - std::string path = itksys::SystemTools::GetFilenamePath(outfilename); - std::string defout = path + std::string("/") + name + std::string("_def") + ext; + auto displacementwriter = DisplacementWriterType::New(); + const std::string outfilename(argv[3]); + const std::string ext = itksys::SystemTools::GetFilenameExtension(outfilename); + const std::string name = itksys::SystemTools::GetFilenameWithoutExtension(outfilename); + const std::string path = itksys::SystemTools::GetFilenamePath(outfilename); + const std::string defout = path + std::string("/") + name + std::string("_def") + ext; displacementwriter->SetFileName(defout.c_str()); displacementwriter->SetInput(displacementTransform->GetDisplacementField()); displacementwriter->Update(); diff --git a/Modules/Registration/Metricsv4/test/itkMetricImageGradientTest.cxx b/Modules/Registration/Metricsv4/test/itkMetricImageGradientTest.cxx index 714ca35bf9d..aafb9b5c066 100644 --- a/Modules/Registration/Metricsv4/test/itkMetricImageGradientTest.cxx +++ b/Modules/Registration/Metricsv4/test/itkMetricImageGradientTest.cxx @@ -209,12 +209,12 @@ itkMetricImageGradientTestRunTest(unsigned int imageSize, using ImageType = itk::Image; - auto size = ImageType::SizeType::Filled(imageSize); - typename ImageType::IndexType virtualIndex{}; - typename ImageType::RegionType region{ virtualIndex, size }; - auto spacing = itk::MakeFilled(1.0); - typename ImageType::PointType origin{}; - typename ImageType::DirectionType direction; + auto size = ImageType::SizeType::Filled(imageSize); + typename ImageType::IndexType virtualIndex{}; + const typename ImageType::RegionType region{ virtualIndex, size }; + auto spacing = itk::MakeFilled(1.0); + const typename ImageType::PointType origin{}; + typename ImageType::DirectionType direction; direction.SetIdentity(); // Create simple test images. @@ -228,7 +228,7 @@ itkMetricImageGradientTestRunTest(unsigned int imageSize, // Fill images, with a border itk::ImageRegionIteratorWithIndex it(image, region); it.GoToBegin(); - unsigned int imageBorder = 20; + const unsigned int imageBorder = 20; while (!it.IsAtEnd()) { it.Set(0); @@ -257,14 +257,14 @@ itkMetricImageGradientTestRunTest(unsigned int imageSize, resample->SetOutputParametersFromImage(image); resample->SetDefaultPixelValue(0); resample->Update(); - typename ImageType::Pointer movingImage = resample->GetOutput(); + const typename ImageType::Pointer movingImage = resample->GetOutput(); // The inverse of the transform is what we'd be estimating // as the moving transform during registration // typename TTransform::InverseTransformBasePointer // movingTransform = transform->GetInverseTransform(); - typename TTransform::Pointer movingTransform = transform->GetInverseTransform().GetPointer(); + const typename TTransform::Pointer movingTransform = transform->GetInverseTransform().GetPointer(); // Write out the images if requested, for debugging only if (false) @@ -287,7 +287,7 @@ itkMetricImageGradientTestRunTest(unsigned int imageSize, // Image gradient from moving image typename ImageType::PointType virtualPoint; image->TransformIndexToPhysicalPoint(virtualIndex, virtualPoint); - typename ImageType::PointType mappedPoint = movingTransform->TransformPoint(virtualPoint); + const typename ImageType::PointType mappedPoint = movingTransform->TransformPoint(virtualPoint); using MetricType = itk::VanillaImageToImageMetricv4; @@ -332,21 +332,21 @@ itkMetricImageGradientTestRunTest(unsigned int imageSize, metric->SetUseMovingImageGradientFilter(b2); metric->Initialize(); - bool b = metric->TransformAndEvaluateMovingPoint(virtualPoint, mappedMovingPoint, mappedMovingPixelValue); + const bool b = metric->TransformAndEvaluateMovingPoint(virtualPoint, mappedMovingPoint, mappedMovingPixelValue); // computed explicitly as ground truth if (b) { metric->ComputeMovingImageGradientAtPoint(mappedMovingPoint, mappedMovingImageGradient); - vnl_vector_ref p2 = mappedMovingImageGradient.GetVnlVector(); - vnl_vector_ref p1 = mappedMovingImageGradientGroundtruth.GetVnlVector(); + const vnl_vector_ref p2 = mappedMovingImageGradient.GetVnlVector(); + const vnl_vector_ref p1 = mappedMovingImageGradientGroundtruth.GetVnlVector(); - double norm1 = p1.two_norm(); - double norm2 = p2.two_norm(); + const double norm1 = p1.two_norm(); + const double norm2 = p2.two_norm(); if (norm1 > 0 && norm2 > 0) { - double correlation = dot_product(p2, p1) / (norm1 * norm2); + const double correlation = dot_product(p2, p1) / (norm1 * norm2); sumc += correlation; } @@ -370,20 +370,20 @@ int itkMetricImageGradientTest(int argc, char * argv[]) { using DimensionSizeType = unsigned int; - DimensionSizeType imageSize = 60; - unsigned int dimensionality = 3; - double minimumAverage = itk::NumericTraits::max(); - double rotationDegrees = 0.0; // (3.0); - double maxDegrees = 359.0; - double degreeStep = 15.0; //(3.0); + const DimensionSizeType imageSize = 60; + unsigned int dimensionality = 3; + double minimumAverage = itk::NumericTraits::max(); + double rotationDegrees = 0.0; // (3.0); + const double maxDegrees = 359.0; + const double degreeStep = 15.0; //(3.0); std::string outputPath(""); if (argc >= 2) { - std::string path(argv[1]); + const std::string path(argv[1]); outputPath = path; } - std::string commandName(argv[0]); + const std::string commandName(argv[0]); outputPath += commandName; std::cout << outputPath << std::endl; @@ -425,7 +425,7 @@ itkMetricImageGradientTest(int argc, char * argv[]) using TransformType = itk::AffineTransform; auto transform = TransformType::New(); transform->SetIdentity(); - double angleRad = itk::Math::pi * rotationDegrees / 180; + const double angleRad = itk::Math::pi * rotationDegrees / 180; // transform->SetRotation( angleRad, angleRad, angleRad ); TransformType::OutputVectorType axis1; axis1[0] = 1; @@ -458,7 +458,7 @@ itkMetricImageGradientTest(int argc, char * argv[]) } std::cout << "minimumAverage: " << minimumAverage << std::endl; - double threshold = 0.96; + const double threshold = 0.96; if (minimumAverage < threshold) { std::cerr << "Minimum average of all runs is below threshold of " << threshold << std::endl; diff --git a/Modules/Registration/Metricsv4/test/itkMultiGradientImageToImageMetricv4RegistrationTest.cxx b/Modules/Registration/Metricsv4/test/itkMultiGradientImageToImageMetricv4RegistrationTest.cxx index a94c78cfa2d..6a2cda343f1 100644 --- a/Modules/Registration/Metricsv4/test/itkMultiGradientImageToImageMetricv4RegistrationTest.cxx +++ b/Modules/Registration/Metricsv4/test/itkMultiGradientImageToImageMetricv4RegistrationTest.cxx @@ -85,9 +85,9 @@ itkMultiGradientImageToImageMetricv4RegistrationTest(int argc, char * argv[]) // get the images fixedImageReader->Update(); - FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); movingImageReader->Update(); - MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); + const MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); /** define a resample filter that will ultimately be used to deform the image */ using ResampleFilterType = itk::ResampleImageFilter; @@ -126,7 +126,7 @@ itkMultiGradientImageToImageMetricv4RegistrationTest(int argc, char * argv[]) else { using PointType = PointSetType::PointType; - PointSetType::Pointer pset(PointSetType::New()); + const PointSetType::Pointer pset(PointSetType::New()); unsigned long ind = 0; unsigned long ct = 0; itk::ImageRegionIteratorWithIndex It(fixedImage, fixedImage->GetLargestPossibleRegion()); @@ -166,7 +166,7 @@ itkMultiGradientImageToImageMetricv4RegistrationTest(int argc, char * argv[]) std::cout << "First do an affine registration " << std::endl; using RegistrationParameterScalesFromShiftType = itk::RegistrationParameterScalesFromPhysicalShift; - RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = + const RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = RegistrationParameterScalesFromShiftType::New(); RegistrationParameterScalesFromShiftType::ScalesType scales(affineTransform->GetNumberOfParameters()); shiftScaleEstimator->SetMetric(metric); @@ -183,7 +183,7 @@ itkMultiGradientImageToImageMetricv4RegistrationTest(int argc, char * argv[]) std::cout << "now declare optimizer2 " << std::endl; using RegistrationParameterScalesFromShiftType2 = itk::RegistrationParameterScalesFromPhysicalShift; - RegistrationParameterScalesFromShiftType2::Pointer shiftScaleEstimator2 = + const RegistrationParameterScalesFromShiftType2::Pointer shiftScaleEstimator2 = RegistrationParameterScalesFromShiftType2::New(); shiftScaleEstimator2->SetMetric(metric2); shiftScaleEstimator2->EstimateScales(scales); diff --git a/Modules/Registration/Metricsv4/test/itkMultiStartImageToImageMetricv4RegistrationTest.cxx b/Modules/Registration/Metricsv4/test/itkMultiStartImageToImageMetricv4RegistrationTest.cxx index 5604c4c65a5..85a9a96e3de 100644 --- a/Modules/Registration/Metricsv4/test/itkMultiStartImageToImageMetricv4RegistrationTest.cxx +++ b/Modules/Registration/Metricsv4/test/itkMultiStartImageToImageMetricv4RegistrationTest.cxx @@ -92,13 +92,13 @@ itkMultiStartImageToImageMetricv4RegistrationTest(int argc, char * argv[]) auto fixedcaster = CastFilterType::New(); fixedcaster->SetInput(fixedImageReader->GetOutput()); // resample->GetOutput() fixedcaster->Update(); - InternalImageType::Pointer fixedImage = fixedcaster->GetOutput(); + const InternalImageType::Pointer fixedImage = fixedcaster->GetOutput(); // get the images auto movingcaster = CastFilterType::New(); movingcaster->SetInput(movingImageReader->GetOutput()); movingcaster->Update(); - InternalImageType::Pointer movingImage = movingcaster->GetOutput(); + const InternalImageType::Pointer movingImage = movingcaster->GetOutput(); /** Now set up a rotation about the center of the image */ // create an affine transform @@ -152,7 +152,7 @@ itkMultiStartImageToImageMetricv4RegistrationTest(int argc, char * argv[]) auto metric = MetricType::New(); // metric->SetNumberOfHistogramBins(20); using PointType = PointSetType::PointType; - PointSetType::Pointer pset(PointSetType::New()); + const PointSetType::Pointer pset(PointSetType::New()); unsigned long ind = 0; unsigned long ct = 0; itk::ImageRegionIteratorWithIndex It(fixedImage, fixedImage->GetLargestPossibleRegion()); @@ -178,13 +178,13 @@ itkMultiStartImageToImageMetricv4RegistrationTest(int argc, char * argv[]) } metric->SetFixedTransform(identityTransform); metric->SetMovingTransform(affineTransform); - bool gaussian = false; + const bool gaussian = false; metric->SetUseMovingImageGradientFilter(gaussian); metric->SetUseFixedImageGradientFilter(gaussian); metric->Initialize(); using RegistrationParameterScalesFromShiftType = itk::RegistrationParameterScalesFromPhysicalShift; - RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = + const RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = RegistrationParameterScalesFromShiftType::New(); shiftScaleEstimator->SetMetric(metric); @@ -200,13 +200,13 @@ itkMultiStartImageToImageMetricv4RegistrationTest(int argc, char * argv[]) using MOptimizerType = itk::MultiStartOptimizerv4; auto MOptimizer = MOptimizerType::New(); MOptimizerType::ParametersListType parametersList = MOptimizer->GetParametersList(); - float rotplus = 10; + const float rotplus = 10; // for ( float i = 180; i <= 180; i+=rotplus ) for (float i = 0; i < 360; i += rotplus) { auto aff = AffineTransformType::New(); aff->SetIdentity(); - float rad = static_cast(i) * itk::Math::pi / 180.0; + const float rad = static_cast(i) * itk::Math::pi / 180.0; aff->Translate(moffset); aff->Rotate2D(rad); aff->Translate(foffset); diff --git a/Modules/Registration/Metricsv4/test/itkObjectToObjectMultiMetricv4RegistrationTest.cxx b/Modules/Registration/Metricsv4/test/itkObjectToObjectMultiMetricv4RegistrationTest.cxx index e7ad617118f..12ba7691ab7 100644 --- a/Modules/Registration/Metricsv4/test/itkObjectToObjectMultiMetricv4RegistrationTest.cxx +++ b/Modules/Registration/Metricsv4/test/itkObjectToObjectMultiMetricv4RegistrationTest.cxx @@ -83,8 +83,8 @@ ObjectToObjectMultiMetricv4RegistrationTestCreateImages(typename TImage::Pointer using CoordinateRepresentationType = PixelType; // Create two simple images - itk::SizeValueType ImageSize = 100; - itk::OffsetValueType boundary = 6; + const itk::SizeValueType ImageSize = 100; + const itk::OffsetValueType boundary = 6; // Declare Gaussian Sources using GaussianImageSourceType = itk::GaussianImageSource; @@ -94,7 +94,7 @@ ObjectToObjectMultiMetricv4RegistrationTestCreateImages(typename TImage::Pointer auto spacing = itk::MakeFilled(itk::NumericTraits::OneValue()); - typename TImage::PointType origin{}; + const typename TImage::PointType origin{}; auto fixedImageSource = GaussianImageSourceType::New(); @@ -122,8 +122,8 @@ ObjectToObjectMultiMetricv4RegistrationTestCreateImages(typename TImage::Pointer // shift the fixed image to get the moving image using CyclicShiftFilterType = itk::CyclicShiftImageFilter; - auto shiftFilter = CyclicShiftFilterType::New(); - typename CyclicShiftFilterType::OffsetValueType maxImageShift = boundary - 1; + auto shiftFilter = CyclicShiftFilterType::New(); + const typename CyclicShiftFilterType::OffsetValueType maxImageShift = boundary - 1; imageShift.Fill(maxImageShift); imageShift[0] = maxImageShift / 2; shiftFilter->SetInput(fixedImage); @@ -145,11 +145,11 @@ ObjectToObjectMultiMetricv4RegistrationTestRun(typename TMetric::Pointer & { // calculate initial metric value metric->Initialize(); - typename TMetric::MeasureType initialValue = metric->GetValue(); + const typename TMetric::MeasureType initialValue = metric->GetValue(); // scales estimator using RegistrationParameterScalesFromShiftType = itk::RegistrationParameterScalesFromPhysicalShift; - typename RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = + const typename RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = RegistrationParameterScalesFromShiftType::New(); shiftScaleEstimator->SetMetric(metric); diff --git a/Modules/Registration/Metricsv4/test/itkObjectToObjectMultiMetricv4Test.cxx b/Modules/Registration/Metricsv4/test/itkObjectToObjectMultiMetricv4Test.cxx index 1511a567e17..11a7cf7af03 100644 --- a/Modules/Registration/Metricsv4/test/itkObjectToObjectMultiMetricv4Test.cxx +++ b/Modules/Registration/Metricsv4/test/itkObjectToObjectMultiMetricv4Test.cxx @@ -213,10 +213,10 @@ itkObjectToObjectMultiMetricv4TestRun(bool useDisplacementTransform) using FixedImageSourceType = itk::GaussianImageSource; // Note: the following declarations are classical arrays - FixedImageType::SizeValueType fixedImageSize[] = { 100, 100 }; - FixedImageType::SpacingValueType fixedImageSpacing[] = { 1.0f, 1.0f }; - FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; - auto fixedImageSource = FixedImageSourceType::New(); + FixedImageType::SizeValueType fixedImageSize[] = { 100, 100 }; + FixedImageType::SpacingValueType fixedImageSpacing[] = { 1.0f, 1.0f }; + const FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; + auto fixedImageSource = FixedImageSourceType::New(); fixedImageSource->SetSize(fixedImageSize); fixedImageSource->SetOrigin(fixedImageOrigin); @@ -224,14 +224,14 @@ itkObjectToObjectMultiMetricv4TestRun(bool useDisplacementTransform) fixedImageSource->SetNormalized(false); fixedImageSource->SetScale(1.0f); fixedImageSource->Update(); // Force the filter to run - FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); + const FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); using ShiftScaleFilterType = itk::ShiftScaleImageFilter; auto shiftFilter = ShiftScaleFilterType::New(); shiftFilter->SetInput(fixedImage); shiftFilter->SetShift(2.0); shiftFilter->Update(); - MovingImageType::Pointer movingImage = shiftFilter->GetOutput(); + const MovingImageType::Pointer movingImage = shiftFilter->GetOutput(); // Set up the metric. using MultiMetricType = ObjectToObjectMultiMetricv4TestMultiMetricType; @@ -270,7 +270,7 @@ itkObjectToObjectMultiMetricv4TestRun(bool useDisplacementTransform) using FieldType = DisplacementTransformType::DisplacementFieldType; using VectorType = itk::Vector; - VectorType zero{}; + const VectorType zero{}; auto field = FieldType::New(); field->SetRegions(fixedImage->GetBufferedRegion()); @@ -483,7 +483,7 @@ itkObjectToObjectMultiMetricv4TestRun(bool useDisplacementTransform) ScalesEstimatorMultiType::ScalesType singleScales; singleShiftScaleEstimator->EstimateScales(singleScales); std::cout << "Single metric estimated scales: " << singleScales << std::endl; - ScalesEstimatorMultiType::FloatType singleStep = singleShiftScaleEstimator->EstimateStepScale(step); + const ScalesEstimatorMultiType::FloatType singleStep = singleShiftScaleEstimator->EstimateStepScale(step); std::cout << "Single metric estimated stepScale: " << singleStep << std::endl; auto multiSingleMetric = MultiMetricType::New(); @@ -493,7 +493,7 @@ itkObjectToObjectMultiMetricv4TestRun(bool useDisplacementTransform) ScalesEstimatorMultiType::ScalesType multiSingleScales; shiftScaleEstimator->EstimateScales(multiSingleScales); std::cout << "multi-single estimated scales: " << multiSingleScales << std::endl; - ScalesEstimatorMultiType::FloatType multiSingleStep = shiftScaleEstimator->EstimateStepScale(step); + const ScalesEstimatorMultiType::FloatType multiSingleStep = shiftScaleEstimator->EstimateStepScale(step); std::cout << "multi-single estimated stepScale: " << multiSingleStep << std::endl; auto multiDoubleMetric = MultiMetricType::New(); @@ -504,7 +504,7 @@ itkObjectToObjectMultiMetricv4TestRun(bool useDisplacementTransform) ScalesEstimatorMultiType::ScalesType multiDoubleScales; shiftScaleEstimator->EstimateScales(multiDoubleScales); std::cout << "multi-double estimated scales: " << multiDoubleScales << std::endl; - ScalesEstimatorMultiType::FloatType multiDoubleStep = shiftScaleEstimator->EstimateStepScale(step); + const ScalesEstimatorMultiType::FloatType multiDoubleStep = shiftScaleEstimator->EstimateStepScale(step); std::cout << "multi-double estimated stepScale: " << multiDoubleStep << std::endl; // Check that results are the same for all three estimations diff --git a/Modules/Registration/PDEDeformable/include/itkCurvatureRegistrationFilter.hxx b/Modules/Registration/PDEDeformable/include/itkCurvatureRegistrationFilter.hxx index e566b243219..00a2e96a84e 100644 --- a/Modules/Registration/PDEDeformable/include/itkCurvatureRegistrationFilter.hxx +++ b/Modules/Registration/PDEDeformable/include/itkCurvatureRegistrationFilter.hxx @@ -202,7 +202,7 @@ CurvatureRegistrationFilterGetUpdateBuffer(); + const DisplacementFieldPointer update = this->GetUpdateBuffer(); ImageRegionConstIterator itInDeformation; ImageRegionIterator itOutDeformation; diff --git a/Modules/Registration/PDEDeformable/include/itkDiffeomorphicDemonsRegistrationFilter.hxx b/Modules/Registration/PDEDeformable/include/itkDiffeomorphicDemonsRegistrationFilter.hxx index a313c425624..cda6fa7acee 100644 --- a/Modules/Registration/PDEDeformable/include/itkDiffeomorphicDemonsRegistrationFilter.hxx +++ b/Modules/Registration/PDEDeformable/include/itkDiffeomorphicDemonsRegistrationFilter.hxx @@ -38,7 +38,7 @@ DiffeomorphicDemonsRegistrationFilterSetInterpolator(VectorInterpolator); m_Adder = AdderType::New(); @@ -171,8 +171,8 @@ void DiffeomorphicDemonsRegistrationFilter::AllocateUpdateBuffer() { // The update buffer looks just like the output. - DisplacementFieldPointer output = this->GetOutput(); - DisplacementFieldPointer upbuf = this->GetUpdateBuffer(); + const DisplacementFieldPointer output = this->GetOutput(); + const DisplacementFieldPointer upbuf = this->GetUpdateBuffer(); upbuf->SetLargestPossibleRegion(output->GetLargestPossibleRegion()); upbuf->SetRequestedRegion(output->GetRequestedRegion()); diff --git a/Modules/Registration/PDEDeformable/include/itkFastSymmetricForcesDemonsRegistrationFilter.hxx b/Modules/Registration/PDEDeformable/include/itkFastSymmetricForcesDemonsRegistrationFilter.hxx index 39e67883406..8b035d0b6eb 100644 --- a/Modules/Registration/PDEDeformable/include/itkFastSymmetricForcesDemonsRegistrationFilter.hxx +++ b/Modules/Registration/PDEDeformable/include/itkFastSymmetricForcesDemonsRegistrationFilter.hxx @@ -165,8 +165,8 @@ void FastSymmetricForcesDemonsRegistrationFilter::AllocateUpdateBuffer() { // The update buffer looks just like the output. - DisplacementFieldPointer output = this->GetOutput(); - DisplacementFieldPointer upbuf = this->GetUpdateBuffer(); + const DisplacementFieldPointer output = this->GetOutput(); + const DisplacementFieldPointer upbuf = this->GetUpdateBuffer(); upbuf->SetLargestPossibleRegion(output->GetLargestPossibleRegion()); upbuf->SetRequestedRegion(output->GetRequestedRegion()); diff --git a/Modules/Registration/PDEDeformable/include/itkMultiResolutionPDEDeformableRegistration.hxx b/Modules/Registration/PDEDeformable/include/itkMultiResolutionPDEDeformableRegistration.hxx index bbde585cbb8..eb417a6bace 100644 --- a/Modules/Registration/PDEDeformable/include/itkMultiResolutionPDEDeformableRegistration.hxx +++ b/Modules/Registration/PDEDeformable/include/itkMultiResolutionPDEDeformableRegistration.hxx @@ -275,8 +275,8 @@ MultiResolutionPDEDeformableRegistration::GenerateData() { // Check for nullptr images and pointers - MovingImageConstPointer movingImage = this->GetMovingImage(); - FixedImageConstPointer fixedImage = this->GetFixedImage(); + const MovingImageConstPointer movingImage = this->GetMovingImage(); + const FixedImageConstPointer fixedImage = this->GetFixedImage(); if (!movingImage || !fixedImage) { @@ -326,7 +326,7 @@ MultiResolutionPDEDeformableRegistration(this->GetInput(0)); + const DisplacementFieldPointer inputPtr = const_cast(this->GetInput(0)); if (this->m_InitialDisplacementField) { @@ -364,7 +364,7 @@ MultiResolutionPDEDeformableRegistrationSetInput(tempField); - typename FloatImageType::Pointer fi = m_FixedImagePyramid->GetOutput(fixedLevel); + const typename FloatImageType::Pointer fi = m_FixedImagePyramid->GetOutput(fixedLevel); m_FieldExpander->SetSize(fi->GetLargestPossibleRegion().GetSize()); m_FieldExpander->SetOutputStartIndex(fi->GetLargestPossibleRegion().GetIndex()); m_FieldExpander->SetOutputOrigin(fi->GetOrigin()); @@ -391,7 +391,7 @@ MultiResolutionPDEDeformableRegistrationSetInput(tempField); - typename FloatImageType::Pointer fi = m_FixedImagePyramid->GetOutput(fixedLevel); + const typename FloatImageType::Pointer fi = m_FixedImagePyramid->GetOutput(fixedLevel); m_FieldExpander->SetSize(fi->GetLargestPossibleRegion().GetSize()); m_FieldExpander->SetOutputStartIndex(fi->GetLargestPossibleRegion().GetIndex()); m_FieldExpander->SetOutputOrigin(fi->GetOrigin()); @@ -595,7 +595,7 @@ MultiResolutionPDEDeformableRegistration(this->GetMovingImage()); + const MovingImagePointer movingPtr = const_cast(this->GetMovingImage()); if (movingPtr) { movingPtr->SetRequestedRegionToLargestPossibleRegion(); @@ -603,9 +603,9 @@ MultiResolutionPDEDeformableRegistration(this->GetInput()); - DisplacementFieldPointer outputPtr = this->GetOutput(); - FixedImagePointer fixedPtr = const_cast(this->GetFixedImage()); + const DisplacementFieldPointer inputPtr = const_cast(this->GetInput()); + const DisplacementFieldPointer outputPtr = this->GetOutput(); + const FixedImagePointer fixedPtr = const_cast(this->GetFixedImage()); if (inputPtr) { diff --git a/Modules/Registration/PDEDeformable/include/itkPDEDeformableRegistrationFilter.hxx b/Modules/Registration/PDEDeformable/include/itkPDEDeformableRegistrationFilter.hxx index 6389c0b762f..5aa3b45b512 100644 --- a/Modules/Registration/PDEDeformable/include/itkPDEDeformableRegistrationFilter.hxx +++ b/Modules/Registration/PDEDeformable/include/itkPDEDeformableRegistrationFilter.hxx @@ -156,8 +156,8 @@ template ::InitializeIteration() { - MovingImageConstPointer movingPtr = this->GetMovingImage(); - FixedImageConstPointer fixedPtr = this->GetFixedImage(); + const MovingImageConstPointer movingPtr = this->GetMovingImage(); + const FixedImageConstPointer fixedPtr = this->GetFixedImage(); if (!movingPtr || !fixedPtr) { @@ -182,7 +182,7 @@ template ::CopyInputToOutput() { - typename Superclass::InputImageType::ConstPointer inputPtr = this->GetInput(); + const typename Superclass::InputImageType::ConstPointer inputPtr = this->GetInput(); if (inputPtr) { @@ -196,7 +196,7 @@ PDEDeformableRegistrationFilter:: zeros[j] = 0; } - typename OutputImageType::Pointer output = this->GetOutput(); + const typename OutputImageType::Pointer output = this->GetOutput(); ImageRegionIterator out(output, output->GetRequestedRegion()); @@ -243,7 +243,7 @@ PDEDeformableRegistrationFilter:: Superclass::GenerateInputRequestedRegion(); // request the largest possible region for the moving image - MovingImagePointer movingPtr = const_cast(this->GetMovingImage()); + const MovingImagePointer movingPtr = const_cast(this->GetMovingImage()); if (movingPtr) { movingPtr->SetRequestedRegionToLargestPossibleRegion(); @@ -251,9 +251,9 @@ PDEDeformableRegistrationFilter:: // just propagate up the output requested region for // the fixed image and initial deformation field. - DisplacementFieldPointer inputPtr = const_cast(this->GetInput()); - DisplacementFieldPointer outputPtr = this->GetOutput(); - FixedImagePointer fixedPtr = const_cast(this->GetFixedImage()); + const DisplacementFieldPointer inputPtr = const_cast(this->GetInput()); + const DisplacementFieldPointer outputPtr = this->GetOutput(); + const FixedImagePointer fixedPtr = const_cast(this->GetFixedImage()); if (inputPtr) { @@ -286,7 +286,7 @@ template ::SmoothDisplacementField() { - DisplacementFieldPointer field = this->GetOutput(); + const DisplacementFieldPointer field = this->GetOutput(); // copy field to TempField m_TempField->SetOrigin(field->GetOrigin()); @@ -315,7 +315,7 @@ PDEDeformableRegistrationFilter:: { // smooth along this dimension oper.SetDirection(j); - double variance = itk::Math::sqr(m_StandardDeviations[j]); + const double variance = itk::Math::sqr(m_StandardDeviations[j]); oper.SetVariance(variance); oper.SetMaximumError(m_MaximumError); oper.SetMaximumKernelWidth(m_MaximumKernelWidth); @@ -346,7 +346,7 @@ void PDEDeformableRegistrationFilter::SmoothUpdateField() { // The update buffer will be overwritten with new data. - DisplacementFieldPointer field = this->GetUpdateBuffer(); + const DisplacementFieldPointer field = this->GetUpdateBuffer(); using VectorType = typename DisplacementFieldType::PixelType; using ScalarType = typename VectorType::ValueType; @@ -360,7 +360,7 @@ PDEDeformableRegistrationFilter:: { // smooth along this dimension opers[j].SetDirection(j); - double variance = itk::Math::sqr(this->GetUpdateFieldStandardDeviations()[j]); + const double variance = itk::Math::sqr(this->GetUpdateFieldStandardDeviations()[j]); // double variance = itk::Math::sqr( 1.0 ); opers[j].SetVariance(variance); opers[j].SetMaximumError(this->GetMaximumError()); diff --git a/Modules/Registration/PDEDeformable/include/itkSymmetricForcesDemonsRegistrationFunction.hxx b/Modules/Registration/PDEDeformable/include/itkSymmetricForcesDemonsRegistrationFunction.hxx index 43cd538c5c3..74cb6715c83 100644 --- a/Modules/Registration/PDEDeformable/include/itkSymmetricForcesDemonsRegistrationFunction.hxx +++ b/Modules/Registration/PDEDeformable/include/itkSymmetricForcesDemonsRegistrationFunction.hxx @@ -28,7 +28,7 @@ template :: SymmetricForcesDemonsRegistrationFunction() { - RadiusType r{}; + const RadiusType r{}; this->SetRadius(r); m_TimeStep = 1.0; diff --git a/Modules/Registration/PDEDeformable/test/itkDemonsRegistrationFilterTest.cxx b/Modules/Registration/PDEDeformable/test/itkDemonsRegistrationFilterTest.cxx index 7bb1b05d8a5..eaf3e1427e4 100644 --- a/Modules/Registration/PDEDeformable/test/itkDemonsRegistrationFilterTest.cxx +++ b/Modules/Registration/PDEDeformable/test/itkDemonsRegistrationFilterTest.cxx @@ -66,7 +66,7 @@ FillWithCircle(TImage * image, it.GoToBegin(); typename TImage::IndexType index; - double r2 = itk::Math::sqr(radius); + const double r2 = itk::Math::sqr(radius); while (!it.IsAtEnd()) { @@ -124,9 +124,9 @@ itkDemonsRegistrationFilterTest(int, char *[]) SizeType size; size.SetSize(sizeArray); - IndexType index{}; + const IndexType index{}; - RegionType region{ index, size }; + const RegionType region{ index, size }; auto moving = ImageType::New(); auto fixed = ImageType::New(); @@ -144,10 +144,10 @@ itkDemonsRegistrationFilterTest(int, char *[]) initField->SetBufferedRegion(region); initField->Allocate(); - double center[ImageDimension]; - double radius; - PixelType fgnd = 250; - PixelType bgnd = 15; + double center[ImageDimension]; + double radius; + const PixelType fgnd = 250; + const PixelType bgnd = 15; // fill moving with circle center[0] = 64; @@ -162,7 +162,7 @@ itkDemonsRegistrationFilterTest(int, char *[]) FillWithCircle(fixed, center, radius, fgnd, bgnd); // fill initial deformation with zero vectors - VectorType zeroVec{}; + const VectorType zeroVec{}; initField->FillBuffer(zeroVec); using CasterType = itk::CastImageFilter; @@ -191,8 +191,8 @@ itkDemonsRegistrationFilterTest(int, char *[]) registrator->SetNumberOfIterations(numberOfIterations); ITK_TEST_SET_GET_VALUE(numberOfIterations, registrator->GetNumberOfIterations()); - double standardDeviationsVal = 1.0; - RegistrationType::StandardDeviationsType standardDeviations{ standardDeviationsVal }; + const double standardDeviationsVal = 1.0; + const RegistrationType::StandardDeviationsType standardDeviations{ standardDeviationsVal }; registrator->SetStandardDeviations(standardDeviationsVal); ITK_TEST_SET_GET_VALUE(standardDeviations, registrator->GetStandardDeviations()); @@ -203,7 +203,7 @@ itkDemonsRegistrationFilterTest(int, char *[]) registrator->SetMaximumError(maximumError); ITK_TEST_SET_GET_VALUE(maximumError, registrator->GetMaximumError()); - unsigned int maximumKernelWidth = 10; + const unsigned int maximumKernelWidth = 10; registrator->SetMaximumKernelWidth(maximumKernelWidth); ITK_TEST_SET_GET_VALUE(maximumKernelWidth, registrator->GetMaximumKernelWidth()); @@ -217,8 +217,8 @@ itkDemonsRegistrationFilterTest(int, char *[]) auto smoothUpdateField = false; ITK_TEST_SET_GET_BOOLEAN(registrator, SmoothUpdateField, smoothUpdateField); - double updateFieldStandardDeviationsVal = 1.0; - RegistrationType::StandardDeviationsType updateFieldStandardDeviations{ updateFieldStandardDeviationsVal }; + const double updateFieldStandardDeviationsVal = 1.0; + const RegistrationType::StandardDeviationsType updateFieldStandardDeviations{ updateFieldStandardDeviationsVal }; registrator->SetUpdateFieldStandardDeviations(updateFieldStandardDeviationsVal); ITK_TEST_SET_GET_VALUE(updateFieldStandardDeviations, registrator->GetUpdateFieldStandardDeviations()); diff --git a/Modules/Registration/PDEDeformable/test/itkDiffeomorphicDemonsRegistrationFilterTest.cxx b/Modules/Registration/PDEDeformable/test/itkDiffeomorphicDemonsRegistrationFilterTest.cxx index 684aa5ee5a3..0f71c656ed6 100644 --- a/Modules/Registration/PDEDeformable/test/itkDiffeomorphicDemonsRegistrationFilterTest.cxx +++ b/Modules/Registration/PDEDeformable/test/itkDiffeomorphicDemonsRegistrationFilterTest.cxx @@ -59,7 +59,7 @@ FillWithCircle(TImage * image, it.GoToBegin(); typename TImage::IndexType index; - double r2 = itk::Math::sqr(radius); + const double r2 = itk::Math::sqr(radius); for (; !it.IsAtEnd(); ++it) { @@ -136,9 +136,9 @@ itkDiffeomorphicDemonsRegistrationFilterTest(int argc, char * argv[]) SizeType size; size.SetSize(sizeArray); - IndexType index{}; + const IndexType index{}; - RegionType region{ index, size }; + const RegionType region{ index, size }; DirectionType direction; direction.SetIdentity(); @@ -163,10 +163,10 @@ itkDiffeomorphicDemonsRegistrationFilterTest(int argc, char * argv[]) initField->Allocate(); initField->SetDirection(direction); - double center[ImageDimension]; - double radius; - PixelType fgnd = 250; - PixelType bgnd = 15; + double center[ImageDimension]; + double radius; + const PixelType fgnd = 250; + const PixelType bgnd = 15; // fill moving with circle center[0] = 64; @@ -181,7 +181,7 @@ itkDiffeomorphicDemonsRegistrationFilterTest(int argc, char * argv[]) FillWithCircle(fixed, center, radius, fgnd, bgnd); // fill initial deformation with zero vectors - VectorType zeroVec{}; + const VectorType zeroVec{}; initField->FillBuffer(zeroVec); using CasterType = itk::CastImageFilter; diff --git a/Modules/Registration/PDEDeformable/test/itkFastSymmetricForcesDemonsRegistrationFilterTest.cxx b/Modules/Registration/PDEDeformable/test/itkFastSymmetricForcesDemonsRegistrationFilterTest.cxx index 81a714826bc..37747d1fc9a 100644 --- a/Modules/Registration/PDEDeformable/test/itkFastSymmetricForcesDemonsRegistrationFilterTest.cxx +++ b/Modules/Registration/PDEDeformable/test/itkFastSymmetricForcesDemonsRegistrationFilterTest.cxx @@ -65,7 +65,7 @@ FillWithCircle(TImage * image, it.GoToBegin(); typename TImage::IndexType index; - double r2 = itk::Math::sqr(radius); + const double r2 = itk::Math::sqr(radius); for (; !it.IsAtEnd(); ++it) { @@ -123,9 +123,9 @@ itkFastSymmetricForcesDemonsRegistrationFilterTest(int, char *[]) SizeType size; size.SetSize(sizeArray); - IndexType index{}; + const IndexType index{}; - RegionType region{ index, size }; + const RegionType region{ index, size }; auto moving = ImageType::New(); auto fixed = ImageType::New(); @@ -143,10 +143,10 @@ itkFastSymmetricForcesDemonsRegistrationFilterTest(int, char *[]) initField->SetBufferedRegion(region); initField->Allocate(); - double center[ImageDimension]; - double radius; - PixelType fgnd = 250; - PixelType bgnd = 15; + double center[ImageDimension]; + double radius; + const PixelType fgnd = 250; + const PixelType bgnd = 15; // fill moving with circle center[0] = 64; @@ -161,7 +161,7 @@ itkFastSymmetricForcesDemonsRegistrationFilterTest(int, char *[]) FillWithCircle(fixed, center, radius, fgnd, bgnd); // fill initial deformation with zero vectors - VectorType zeroVec{}; + const VectorType zeroVec{}; initField->FillBuffer(zeroVec); using CasterType = itk::CastImageFilter; @@ -191,8 +191,8 @@ itkFastSymmetricForcesDemonsRegistrationFilterTest(int, char *[]) registrator->SetNumberOfIterations(numberOfIterations); ITK_TEST_SET_GET_VALUE(numberOfIterations, registrator->GetNumberOfIterations()); - double standardDeviationsVal = 1.0; - RegistrationType::StandardDeviationsType standardDeviations{ standardDeviationsVal }; + const double standardDeviationsVal = 1.0; + const RegistrationType::StandardDeviationsType standardDeviations{ standardDeviationsVal }; registrator->SetStandardDeviations(standardDeviationsVal); ITK_TEST_SET_GET_VALUE(standardDeviations, registrator->GetStandardDeviations()); @@ -203,7 +203,7 @@ itkFastSymmetricForcesDemonsRegistrationFilterTest(int, char *[]) registrator->SetMaximumError(maximumError); ITK_TEST_SET_GET_VALUE(maximumError, registrator->GetMaximumError()); - unsigned int maximumKernelWidth = 10; + const unsigned int maximumKernelWidth = 10; registrator->SetMaximumKernelWidth(maximumKernelWidth); ITK_TEST_SET_GET_VALUE(maximumKernelWidth, registrator->GetMaximumKernelWidth()); @@ -217,8 +217,8 @@ itkFastSymmetricForcesDemonsRegistrationFilterTest(int, char *[]) auto smoothUpdateField = false; ITK_TEST_SET_GET_BOOLEAN(registrator, SmoothUpdateField, smoothUpdateField); - double updateFieldStandardDeviationsVal = 1.0; - RegistrationType::StandardDeviationsType updateFieldStandardDeviations{ updateFieldStandardDeviationsVal }; + const double updateFieldStandardDeviationsVal = 1.0; + const RegistrationType::StandardDeviationsType updateFieldStandardDeviations{ updateFieldStandardDeviationsVal }; registrator->SetUpdateFieldStandardDeviations(updateFieldStandardDeviationsVal); ITK_TEST_SET_GET_VALUE(updateFieldStandardDeviations, registrator->GetUpdateFieldStandardDeviations()); diff --git a/Modules/Registration/PDEDeformable/test/itkLevelSetMotionRegistrationFilterTest.cxx b/Modules/Registration/PDEDeformable/test/itkLevelSetMotionRegistrationFilterTest.cxx index b7ad6d83d24..482a10adcc4 100644 --- a/Modules/Registration/PDEDeformable/test/itkLevelSetMotionRegistrationFilterTest.cxx +++ b/Modules/Registration/PDEDeformable/test/itkLevelSetMotionRegistrationFilterTest.cxx @@ -71,7 +71,7 @@ FillWithCircle(typename TImage::Pointer & image, it.GoToBegin(); typename TImage::IndexType index; - double r2 = itk::Math::sqr(radius); + const double r2 = itk::Math::sqr(radius); while (!it.IsAtEnd()) { @@ -139,9 +139,9 @@ itkLevelSetMotionRegistrationFilterTest(int argc, char * argv[]) SizeType size; size.SetSize(sizeArray); - IndexType index{}; + const IndexType index{}; - RegionType region{ index, size }; + const RegionType region{ index, size }; auto moving = ImageType::New(); auto fixed = ImageType::New(); @@ -159,10 +159,10 @@ itkLevelSetMotionRegistrationFilterTest(int argc, char * argv[]) initField->SetBufferedRegion(region); initField->Allocate(); - double center[ImageDimension]; - double radius; - PixelType fgnd = 250; - PixelType bgnd = 15; + double center[ImageDimension]; + double radius; + const PixelType fgnd = 250; + const PixelType bgnd = 15; // fill moving with circle center[0] = 64; @@ -177,7 +177,7 @@ itkLevelSetMotionRegistrationFilterTest(int argc, char * argv[]) FillWithCircle(fixed, center, radius, fgnd, bgnd); // fill initial deformation with zero vectors - VectorType zeroVec{}; + const VectorType zeroVec{}; initField->FillBuffer(zeroVec); using CasterType = itk::CastImageFilter; @@ -202,15 +202,15 @@ itkLevelSetMotionRegistrationFilterTest(int argc, char * argv[]) registrator->SetMaximumError(0.08); registrator->SetMaximumKernelWidth(10); - double intensityDifferenceThreshold = 0.001; + const double intensityDifferenceThreshold = 0.001; registrator->SetIntensityDifferenceThreshold(intensityDifferenceThreshold); ITK_TEST_SET_GET_VALUE(intensityDifferenceThreshold, registrator->GetIntensityDifferenceThreshold()); - double gradientMagnitudeThreshold = 1e-9; + const double gradientMagnitudeThreshold = 1e-9; registrator->SetGradientMagnitudeThreshold(gradientMagnitudeThreshold); ITK_TEST_SET_GET_VALUE(gradientMagnitudeThreshold, registrator->GetGradientMagnitudeThreshold()); - double alpha = 0.1; + const double alpha = 0.1; registrator->SetAlpha(alpha); ITK_TEST_SET_GET_VALUE(alpha, registrator->GetAlpha()); diff --git a/Modules/Registration/PDEDeformable/test/itkMultiResolutionPDEDeformableRegistrationTest.cxx b/Modules/Registration/PDEDeformable/test/itkMultiResolutionPDEDeformableRegistrationTest.cxx index aea7d6538f9..f2b9d560044 100644 --- a/Modules/Registration/PDEDeformable/test/itkMultiResolutionPDEDeformableRegistrationTest.cxx +++ b/Modules/Registration/PDEDeformable/test/itkMultiResolutionPDEDeformableRegistrationTest.cxx @@ -104,7 +104,7 @@ FillWithCircle(TImage * image, it.GoToBegin(); typename TImage::IndexType index; - double r2 = itk::Math::sqr(radius); + const double r2 = itk::Math::sqr(radius); while (!it.IsAtEnd()) { @@ -171,7 +171,7 @@ itkMultiResolutionPDEDeformableRegistrationTest(int argc, char * argv[]) IndexType index{}; index[0] = 3; - RegionType region{ index, size }; + const RegionType region{ index, size }; ImageType::PointType origin{}; origin[0] = 0.8; @@ -201,10 +201,10 @@ itkMultiResolutionPDEDeformableRegistrationTest(int argc, char * argv[]) initField->SetOrigin(origin); initField->SetSpacing(spacing); - double center[ImageDimension]; - double radius; - PixelType fgnd = 250; - PixelType bgnd = 15; + double center[ImageDimension]; + double radius; + const PixelType fgnd = 250; + const PixelType bgnd = 15; // fill moving with circle center[0] = 128; @@ -219,7 +219,7 @@ itkMultiResolutionPDEDeformableRegistrationTest(int argc, char * argv[]) FillWithCircle(fixed, center, radius, fgnd, bgnd); // fill initial deformation with zero vectors - VectorType zeroVec{}; + const VectorType zeroVec{}; FillImage(initField, zeroVec); //---------------------------------------------------------------- @@ -365,7 +365,7 @@ itkMultiResolutionPDEDeformableRegistrationTest(int argc, char * argv[]) bool passed; using InternalRegistrationType = RegistrationType::RegistrationType; - InternalRegistrationType::Pointer demons = registrator->GetModifiableRegistrationFilter(); + const InternalRegistrationType::Pointer demons = registrator->GetModifiableRegistrationFilter(); try { @@ -389,7 +389,7 @@ itkMultiResolutionPDEDeformableRegistrationTest(int argc, char * argv[]) } using FixedImagePyramidType = RegistrationType::FixedImagePyramidType; - FixedImagePyramidType::Pointer fixedPyramid = registrator->GetModifiableFixedImagePyramid(); + const FixedImagePyramidType::Pointer fixedPyramid = registrator->GetModifiableFixedImagePyramid(); try { @@ -414,7 +414,7 @@ itkMultiResolutionPDEDeformableRegistrationTest(int argc, char * argv[]) } using MovingImagePyramidType = RegistrationType::MovingImagePyramidType; - MovingImagePyramidType::Pointer movingPyramid = registrator->GetModifiableMovingImagePyramid(); + const MovingImagePyramidType::Pointer movingPyramid = registrator->GetModifiableMovingImagePyramid(); try { diff --git a/Modules/Registration/PDEDeformable/test/itkSymmetricForcesDemonsRegistrationFilterTest.cxx b/Modules/Registration/PDEDeformable/test/itkSymmetricForcesDemonsRegistrationFilterTest.cxx index 2ded6885610..47771dbcf3b 100644 --- a/Modules/Registration/PDEDeformable/test/itkSymmetricForcesDemonsRegistrationFilterTest.cxx +++ b/Modules/Registration/PDEDeformable/test/itkSymmetricForcesDemonsRegistrationFilterTest.cxx @@ -56,7 +56,7 @@ FillWithCircle(TImage * image, it.GoToBegin(); typename TImage::IndexType index; - double r2 = itk::Math::sqr(radius); + const double r2 = itk::Math::sqr(radius); while (!it.IsAtEnd()) { @@ -116,9 +116,9 @@ itkSymmetricForcesDemonsRegistrationFilterTest(int, char *[]) SizeType size; size.SetSize(sizeArray); - IndexType index{}; + const IndexType index{}; - RegionType region{ index, size }; + const RegionType region{ index, size }; auto moving = ImageType::New(); auto fixed = ImageType::New(); @@ -136,10 +136,10 @@ itkSymmetricForcesDemonsRegistrationFilterTest(int, char *[]) initField->SetBufferedRegion(region); initField->Allocate(); - double center[ImageDimension]; - double radius; - PixelType fgnd = 250; - PixelType bgnd = 15; + double center[ImageDimension]; + double radius; + const PixelType fgnd = 250; + const PixelType bgnd = 15; // fill moving with circle center[0] = 64; @@ -154,7 +154,7 @@ itkSymmetricForcesDemonsRegistrationFilterTest(int, char *[]) FillWithCircle(fixed, center, radius, fgnd, bgnd); // fill initial deformation with zero vectors - VectorType zeroVec{}; + const VectorType zeroVec{}; initField->FillBuffer(zeroVec); std::cout << "Run registration and warp moving" << std::endl; @@ -172,7 +172,7 @@ itkSymmetricForcesDemonsRegistrationFilterTest(int, char *[]) registrator->SetStandardDeviations(2.0); registrator->SetStandardDeviations(1.0); - double intensityDifferenceThreshold = 0.001; + const double intensityDifferenceThreshold = 0.001; registrator->SetIntensityDifferenceThreshold(intensityDifferenceThreshold); ITK_TEST_SET_GET_VALUE(intensityDifferenceThreshold, registrator->GetIntensityDifferenceThreshold()); diff --git a/Modules/Registration/RegistrationMethodsv4/include/itkBSplineSyNImageRegistrationMethod.hxx b/Modules/Registration/RegistrationMethodsv4/include/itkBSplineSyNImageRegistrationMethod.hxx index 6fffd805c3c..0c9aba5a4e7 100644 --- a/Modules/Registration/RegistrationMethodsv4/include/itkBSplineSyNImageRegistrationMethod.hxx +++ b/Modules/Registration/RegistrationMethodsv4/include/itkBSplineSyNImageRegistrationMethod.hxx @@ -81,7 +81,7 @@ void BSplineSyNImageRegistrationMethod:: StartOptimization() { - VirtualImageBaseConstPointer virtualDomainImage = this->GetCurrentLevelVirtualDomainImage(); + const VirtualImageBaseConstPointer virtualDomainImage = this->GetCurrentLevelVirtualDomainImage(); if (virtualDomainImage.IsNull()) { @@ -120,25 +120,26 @@ BSplineSyNImageRegistrationMethodComputeUpdateField(this->m_FixedSmoothImages, - this->m_FixedPointSets, - fixedComposite, - this->m_MovingSmoothImages, - this->m_MovingPointSets, - movingComposite, - this->m_FixedImageMasks, - this->m_MovingImageMasks, - movingMetricValue); - - DisplacementFieldPointer movingToMiddleSmoothUpdateField = this->ComputeUpdateField(this->m_MovingSmoothImages, - this->m_MovingPointSets, - movingComposite, - this->m_FixedSmoothImages, - this->m_FixedPointSets, - fixedComposite, - this->m_MovingImageMasks, - this->m_FixedImageMasks, - fixedMetricValue); + const DisplacementFieldPointer fixedToMiddleSmoothUpdateField = this->ComputeUpdateField(this->m_FixedSmoothImages, + this->m_FixedPointSets, + fixedComposite, + this->m_MovingSmoothImages, + this->m_MovingPointSets, + movingComposite, + this->m_FixedImageMasks, + this->m_MovingImageMasks, + movingMetricValue); + + const DisplacementFieldPointer movingToMiddleSmoothUpdateField = + this->ComputeUpdateField(this->m_MovingSmoothImages, + this->m_MovingPointSets, + movingComposite, + this->m_FixedSmoothImages, + this->m_FixedPointSets, + fixedComposite, + this->m_MovingImageMasks, + this->m_FixedImageMasks, + fixedMetricValue); if (this->m_AverageMidPointGradients) { @@ -160,7 +161,7 @@ BSplineSyNImageRegistrationMethodSetWarpingField(this->m_FixedToMiddleTransform->GetDisplacementField()); fixedComposer->Update(); - DisplacementFieldPointer fixedToMiddleSmoothTotalFieldTmp = + const DisplacementFieldPointer fixedToMiddleSmoothTotalFieldTmp = this->BSplineSmoothDisplacementField(fixedComposer->GetOutput(), this->m_FixedToMiddleTransform->GetNumberOfControlPointsForTheTotalField(), nullptr, @@ -171,7 +172,7 @@ BSplineSyNImageRegistrationMethodSetWarpingField(this->m_MovingToMiddleTransform->GetDisplacementField()); movingComposer->Update(); - DisplacementFieldPointer movingToMiddleSmoothTotalFieldTmp = + const DisplacementFieldPointer movingToMiddleSmoothTotalFieldTmp = this->BSplineSmoothDisplacementField(movingComposer->GetOutput(), this->m_MovingToMiddleTransform->GetNumberOfControlPointsForTheTotalField(), nullptr, @@ -179,14 +180,14 @@ BSplineSyNImageRegistrationMethodInvertDisplacementField( + const DisplacementFieldPointer fixedToMiddleSmoothTotalFieldInverse = this->InvertDisplacementField( fixedToMiddleSmoothTotalFieldTmp, this->m_FixedToMiddleTransform->GetInverseDisplacementField()); - DisplacementFieldPointer fixedToMiddleSmoothTotalField = + const DisplacementFieldPointer fixedToMiddleSmoothTotalField = this->InvertDisplacementField(fixedToMiddleSmoothTotalFieldInverse, fixedToMiddleSmoothTotalFieldTmp); - DisplacementFieldPointer movingToMiddleSmoothTotalFieldInverse = this->InvertDisplacementField( + const DisplacementFieldPointer movingToMiddleSmoothTotalFieldInverse = this->InvertDisplacementField( movingToMiddleSmoothTotalFieldTmp, this->m_MovingToMiddleTransform->GetInverseDisplacementField()); - DisplacementFieldPointer movingToMiddleSmoothTotalField = + const DisplacementFieldPointer movingToMiddleSmoothTotalField = this->InvertDisplacementField(movingToMiddleSmoothTotalFieldInverse, movingToMiddleSmoothTotalFieldTmp); // Assign the displacement fields and their inverses to the proper transforms. @@ -243,7 +244,7 @@ typename BSplineSyNImageRegistrationMethodm_Metric->GetMetricCategory() == ObjectToObjectMetricBaseTemplateEnums::MetricCategory::POINT_SET_METRIC) { - VirtualImageBaseConstPointer virtualDomainImage = this->GetCurrentLevelVirtualDomainImage(); + const VirtualImageBaseConstPointer virtualDomainImage = this->GetCurrentLevelVirtualDomainImage(); metricGradientField = DisplacementFieldType::New(); metricGradientField->CopyInformation(virtualDomainImage); @@ -282,7 +283,7 @@ typename BSplineSyNImageRegistrationMethodGetNumberOfPoints() > 0) { - typename PointSetType::Pointer transformedPointSet = + const typename PointSetType::Pointer transformedPointSet = dynamic_cast(this->m_Metric.GetPointer())->GetModifiableFixedTransformedPointSet(); typename PointSetType::PointsContainerConstIterator It = transformedPointSet->GetPoints()->Begin(); @@ -325,7 +326,7 @@ typename BSplineSyNImageRegistrationMethodGetCurrentLevelVirtualDomainImage(); + const VirtualImageBaseConstPointer virtualDomainImage = this->GetCurrentLevelVirtualDomainImage(); using MaskResamplerType = ResampleImageFilter; diff --git a/Modules/Registration/RegistrationMethodsv4/include/itkImageRegistrationMethodv4.hxx b/Modules/Registration/RegistrationMethodsv4/include/itkImageRegistrationMethodv4.hxx index 886a94ebf7b..ff4d74a536b 100644 --- a/Modules/Registration/RegistrationMethodsv4/include/itkImageRegistrationMethodv4.hxx +++ b/Modules/Registration/RegistrationMethodsv4/include/itkImageRegistrationMethodv4.hxx @@ -93,7 +93,7 @@ ImageRegistrationMethodv4m_OptimizerWeights.SetSize(0); this->m_OptimizerWeightsAreIdentity = true; - DecoratedOutputTransformPointer transformDecorator = + const DecoratedOutputTransformPointer transformDecorator = itkDynamicCastInDebugMode(this->MakeOutput(0).GetPointer()); this->ProcessObject::SetNthOutput(0, transformDecorator); this->m_OutputTransform = transformDecorator->GetModifiable(); @@ -261,7 +261,7 @@ ImageRegistrationMethodv4m_OptimizerWeights.Size(); ++i) { - OptimizerWeightsValueType difference = + const OptimizerWeightsValueType difference = itk::Math::abs(NumericTraits::OneValue() - this->m_OptimizerWeights[i]); if (difference > tolerance) { @@ -282,13 +282,13 @@ ImageRegistrationMethodv4(this->m_Metric.GetPointer()); + const typename MultiMetricType::Pointer multiMetric = dynamic_cast(this->m_Metric.GetPointer()); // Sanity checks and find the virtual domain image if (level == 0) { - SizeValueType numberOfObjectPairs = static_cast(0.5 * this->GetNumberOfIndexedInputs()); + const SizeValueType numberOfObjectPairs = static_cast(0.5 * this->GetNumberOfIndexedInputs()); if (numberOfObjectPairs == 0) { itkExceptionMacro("There are no input objects."); @@ -527,7 +527,7 @@ ImageRegistrationMethodv4m_Metric->GetMetricCategory() == ObjectToObjectMetricBaseTemplateEnums::MetricCategory::IMAGE_METRIC) { - typename ImageMetricType::Pointer imageMetric = dynamic_cast(this->m_Metric.GetPointer()); + const typename ImageMetricType::Pointer imageMetric = dynamic_cast(this->m_Metric.GetPointer()); if (fixedInitialTransform) { imageMetric->SetFixedTransform(fixedInitialTransform); @@ -547,7 +547,7 @@ ImageRegistrationMethodv4m_Metric->GetMetricCategory() == ObjectToObjectMetricBaseTemplateEnums::MetricCategory::POINT_SET_METRIC) { - typename PointSetMetricType::Pointer pointSetMetric = + const typename PointSetMetricType::Pointer pointSetMetric = dynamic_cast(this->m_Metric.GetPointer()); if (fixedInitialTransform) { @@ -895,7 +895,7 @@ ImageRegistrationMethodv4(this->m_Metric.GetPointer()); + const typename MultiMetricType::Pointer multiMetric = dynamic_cast(this->m_Metric.GetPointer()); if (multiMetric) { numberOfLocalMetrics = multiMetric->GetNumberOfMetrics(); @@ -905,7 +905,7 @@ ImageRegistrationMethodv4(multiMetric->GetMetricQueue()[0].GetPointer()); if (firstMetric.IsNotNull()) { @@ -920,7 +920,7 @@ ImageRegistrationMethodv4(this->m_Metric.GetPointer()); + const typename ImageMetricType::Pointer singleMetric = dynamic_cast(this->m_Metric.GetPointer()); if (singleMetric.IsNotNull()) { virtualImage = singleMetric->GetVirtualImage(); @@ -1058,7 +1058,7 @@ ImageRegistrationMethodv4m_CompositeTransform->GetNumberOfTransforms(); + const SizeValueType numberOfTransforms = this->m_CompositeTransform->GetNumberOfTransforms(); if (numberOfTransforms == 0) { @@ -1110,7 +1110,7 @@ typename ImageRegistrationMethodv4(this->m_Metric.GetPointer()); + const typename MultiMetricType::Pointer multiMetric = dynamic_cast(this->m_Metric.GetPointer()); if (multiMetric->GetMetricQueue()[0]->GetMetricCategory() == ObjectToObjectMetricBaseTemplateEnums::MetricCategory::POINT_SET_METRIC) { @@ -1253,7 +1253,7 @@ ImageRegistrationMethodv4Set(ptr); return transformDecorator.GetPointer(); } diff --git a/Modules/Registration/RegistrationMethodsv4/include/itkSyNImageRegistrationMethod.hxx b/Modules/Registration/RegistrationMethodsv4/include/itkSyNImageRegistrationMethod.hxx index 3086e839410..81f337daab6 100644 --- a/Modules/Registration/RegistrationMethodsv4/include/itkSyNImageRegistrationMethod.hxx +++ b/Modules/Registration/RegistrationMethodsv4/include/itkSyNImageRegistrationMethod.hxx @@ -70,7 +70,7 @@ SyNImageRegistrationMethodm_FixedToMiddleTransform = OutputTransformType::New(); this->m_MovingToMiddleTransform = OutputTransformType::New(); - VirtualImageBaseConstPointer virtualDomainImage = this->GetCurrentLevelVirtualDomainImage(); + const VirtualImageBaseConstPointer virtualDomainImage = this->GetCurrentLevelVirtualDomainImage(); auto fixedDisplacementField = DisplacementFieldType::New(); fixedDisplacementField->CopyInformation(virtualDomainImage); @@ -132,7 +132,7 @@ template ::StartOptimization() { - VirtualImageBaseConstPointer virtualDomainImage = this->GetCurrentLevelVirtualDomainImage(); + const VirtualImageBaseConstPointer virtualDomainImage = this->GetCurrentLevelVirtualDomainImage(); if (virtualDomainImage.IsNull()) { @@ -170,25 +170,26 @@ SyNImageRegistrationMethodComputeUpdateField(this->m_FixedSmoothImages, - this->m_FixedPointSets, - fixedComposite, - this->m_MovingSmoothImages, - this->m_MovingPointSets, - movingComposite, - this->m_FixedImageMasks, - this->m_MovingImageMasks, - movingMetricValue); - - DisplacementFieldPointer movingToMiddleSmoothUpdateField = this->ComputeUpdateField(this->m_MovingSmoothImages, - this->m_MovingPointSets, - movingComposite, - this->m_FixedSmoothImages, - this->m_FixedPointSets, - fixedComposite, - this->m_MovingImageMasks, - this->m_FixedImageMasks, - fixedMetricValue); + const DisplacementFieldPointer fixedToMiddleSmoothUpdateField = this->ComputeUpdateField(this->m_FixedSmoothImages, + this->m_FixedPointSets, + fixedComposite, + this->m_MovingSmoothImages, + this->m_MovingPointSets, + movingComposite, + this->m_FixedImageMasks, + this->m_MovingImageMasks, + movingMetricValue); + + const DisplacementFieldPointer movingToMiddleSmoothUpdateField = + this->ComputeUpdateField(this->m_MovingSmoothImages, + this->m_MovingPointSets, + movingComposite, + this->m_FixedSmoothImages, + this->m_FixedPointSets, + fixedComposite, + this->m_MovingImageMasks, + this->m_FixedImageMasks, + fixedMetricValue); if (this->m_AverageMidPointGradients) { @@ -210,7 +211,7 @@ SyNImageRegistrationMethodSetWarpingField(this->m_FixedToMiddleTransform->GetDisplacementField()); fixedComposer->Update(); - DisplacementFieldPointer fixedToMiddleSmoothTotalFieldTmp = this->GaussianSmoothDisplacementField( + const DisplacementFieldPointer fixedToMiddleSmoothTotalFieldTmp = this->GaussianSmoothDisplacementField( fixedComposer->GetOutput(), this->m_GaussianSmoothingVarianceForTheTotalField); auto movingComposer = ComposerType::New(); @@ -218,19 +219,19 @@ SyNImageRegistrationMethodSetWarpingField(this->m_MovingToMiddleTransform->GetDisplacementField()); movingComposer->Update(); - DisplacementFieldPointer movingToMiddleSmoothTotalFieldTmp = this->GaussianSmoothDisplacementField( + const DisplacementFieldPointer movingToMiddleSmoothTotalFieldTmp = this->GaussianSmoothDisplacementField( movingComposer->GetOutput(), this->m_GaussianSmoothingVarianceForTheTotalField); // Iteratively estimate the inverse fields. - DisplacementFieldPointer fixedToMiddleSmoothTotalFieldInverse = this->InvertDisplacementField( + const DisplacementFieldPointer fixedToMiddleSmoothTotalFieldInverse = this->InvertDisplacementField( fixedToMiddleSmoothTotalFieldTmp, this->m_FixedToMiddleTransform->GetInverseDisplacementField()); - DisplacementFieldPointer fixedToMiddleSmoothTotalField = + const DisplacementFieldPointer fixedToMiddleSmoothTotalField = this->InvertDisplacementField(fixedToMiddleSmoothTotalFieldInverse, fixedToMiddleSmoothTotalFieldTmp); - DisplacementFieldPointer movingToMiddleSmoothTotalFieldInverse = this->InvertDisplacementField( + const DisplacementFieldPointer movingToMiddleSmoothTotalFieldInverse = this->InvertDisplacementField( movingToMiddleSmoothTotalFieldTmp, this->m_MovingToMiddleTransform->GetInverseDisplacementField()); - DisplacementFieldPointer movingToMiddleSmoothTotalField = + const DisplacementFieldPointer movingToMiddleSmoothTotalField = this->InvertDisplacementField(movingToMiddleSmoothTotalFieldInverse, movingToMiddleSmoothTotalFieldTmp); // Assign the displacement fields and their inverses to the proper transforms. @@ -271,17 +272,17 @@ typename SyNImageRegistrationMethodComputeMetricGradientField(fixedImages, - fixedPointSets, - fixedTransform, - movingImages, - movingPointSets, - movingTransform, - fixedImageMasks, - movingImageMasks, - value); - - DisplacementFieldPointer updateField = + const DisplacementFieldPointer metricGradientField = this->ComputeMetricGradientField(fixedImages, + fixedPointSets, + fixedTransform, + movingImages, + movingPointSets, + movingTransform, + fixedImageMasks, + movingImageMasks, + value); + + const DisplacementFieldPointer updateField = this->GaussianSmoothDisplacementField(metricGradientField, this->m_GaussianSmoothingVarianceForTheUpdateField); DisplacementFieldPointer scaledUpdateField = this->ScaleUpdateField(updateField); @@ -307,9 +308,9 @@ typename SyNImageRegistrationMethod(this->m_Metric.GetPointer()); + const typename MultiMetricType::Pointer multiMetric = dynamic_cast(this->m_Metric.GetPointer()); - VirtualImageBaseConstPointer virtualDomainImage = this->GetCurrentLevelVirtualDomainImage(); + const VirtualImageBaseConstPointer virtualDomainImage = this->GetCurrentLevelVirtualDomainImage(); if (multiMetric) { @@ -567,7 +568,7 @@ typename SyNImageRegistrationMethodSetRegions(virtualDomainImage->GetLargestPossibleRegion()); identityField->AllocateInitialized(); - DisplacementFieldTransformPointer identityDisplacementFieldTransform = DisplacementFieldTransformType::New(); + const DisplacementFieldTransformPointer identityDisplacementFieldTransform = DisplacementFieldTransformType::New(); identityDisplacementFieldTransform->SetDisplacementField(identityField); identityDisplacementFieldTransform->SetInverseDisplacementField(identityField); @@ -776,7 +777,7 @@ typename SyNImageRegistrationMethodGetLargestPossibleRegion(); const typename DisplacementFieldType::SizeType size = region.GetSize(); diff --git a/Modules/Registration/RegistrationMethodsv4/include/itkTimeVaryingBSplineVelocityFieldImageRegistrationMethod.hxx b/Modules/Registration/RegistrationMethodsv4/include/itkTimeVaryingBSplineVelocityFieldImageRegistrationMethod.hxx index 2e8e86cedfe..6efe78419b7 100644 --- a/Modules/Registration/RegistrationMethodsv4/include/itkTimeVaryingBSplineVelocityFieldImageRegistrationMethod.hxx +++ b/Modules/Registration/RegistrationMethodsv4/include/itkTimeVaryingBSplineVelocityFieldImageRegistrationMethod.hxx @@ -65,17 +65,17 @@ TimeVaryingBSplineVelocityFieldImageRegistrationMethodSetIdentity(); - TimeVaryingVelocityFieldControlPointLatticePointer velocityFieldLattice = + const TimeVaryingVelocityFieldControlPointLatticePointer velocityFieldLattice = this->m_OutputTransform->GetModifiableVelocityField(); - SizeValueType numberOfIntegrationSteps = this->m_NumberOfTimePointSamples + 2; + const SizeValueType numberOfIntegrationSteps = this->m_NumberOfTimePointSamples + 2; const typename TimeVaryingVelocityFieldControlPointLatticeType::RegionType & latticeRegion = velocityFieldLattice->GetLargestPossibleRegion(); const typename TimeVaryingVelocityFieldControlPointLatticeType::SizeType latticeSize = latticeRegion.GetSize(); - SizeValueType numberOfTimeControlPoints = latticeSize[ImageDimension]; - auto numberOfControlPointsPerTimePoint = + const SizeValueType numberOfTimeControlPoints = latticeSize[ImageDimension]; + auto numberOfControlPointsPerTimePoint = static_cast(latticeRegion.GetNumberOfPixels() / numberOfTimeControlPoints); // Warp the moving image based on the composite transform (not including the current @@ -91,7 +91,7 @@ TimeVaryingBSplineVelocityFieldImageRegistrationMethodm_NumberOfTimePointSamples); sampledVelocityFieldDirection.SetIdentity(); - VirtualImageBaseConstPointer virtualDomainImage = this->GetCurrentLevelVirtualDomainImage(); + const VirtualImageBaseConstPointer virtualDomainImage = this->GetCurrentLevelVirtualDomainImage(); typename FixedImageMaskType::ConstPointer fixedImageMask = nullptr; if (virtualDomainImage.IsNull()) @@ -99,10 +99,10 @@ TimeVaryingBSplineVelocityFieldImageRegistrationMethod(this->m_Metric.GetPointer()); + const typename MultiMetricType::Pointer multiMetric = dynamic_cast(this->m_Metric.GetPointer()); if (multiMetric) { - typename ImageMetricType::Pointer metricQueue = + const typename ImageMetricType::Pointer metricQueue = dynamic_cast(multiMetric->GetMetricQueue()[0].GetPointer()); if (metricQueue.IsNotNull()) { @@ -115,7 +115,7 @@ TimeVaryingBSplineVelocityFieldImageRegistrationMethod(this->m_Metric.GetPointer()); + const typename ImageMetricType::Pointer metric = dynamic_cast(this->m_Metric.GetPointer()); if (metric.IsNotNull()) { fixedImageMask = metric->GetFixedImageMask(); @@ -149,9 +149,9 @@ TimeVaryingBSplineVelocityFieldImageRegistrationMethodm_OutputTransform->IntegrateVelocityField(); // Keep track of velocityFieldPointSet from the previous iteration - VelocityFieldPointSetPointer velocityFieldPointSetFromPreviousIteration = VelocityFieldPointSetType::New(); + const VelocityFieldPointSetPointer velocityFieldPointSetFromPreviousIteration = VelocityFieldPointSetType::New(); - VelocityFieldPointSetPointer velocityFieldPointSet = VelocityFieldPointSetType::New(); + const VelocityFieldPointSetPointer velocityFieldPointSet = VelocityFieldPointSetType::New(); auto velocityFieldWeights = WeightsContainerType::New(); @@ -181,8 +181,8 @@ TimeVaryingBSplineVelocityFieldImageRegistrationMethodGetPointData()->End()) { - DisplacementVectorType v = ItV.Value(); - DisplacementVectorType vp = ItVp.Value(); + const DisplacementVectorType v = ItV.Value(); + const DisplacementVectorType vp = ItVp.Value(); velocityFieldPointSet->SetPointData(ItV.Index(), (v + vp) * 0.5); velocityFieldPointSetFromPreviousIteration->SetPointData(ItV.Index(), v); @@ -251,7 +251,7 @@ TimeVaryingBSplineVelocityFieldImageRegistrationMethodUpdate(); - TimeVaryingVelocityFieldControlPointLatticePointer updateControlPointLattice = bspliner->GetPhiLattice(); + const TimeVaryingVelocityFieldControlPointLatticePointer updateControlPointLattice = bspliner->GetPhiLattice(); TimeVaryingVelocityFieldPointer velocityField = nullptr; if (this->GetDebug()) @@ -263,7 +263,7 @@ TimeVaryingBSplineVelocityFieldImageRegistrationMethod(updateControlPointLattice->GetBufferPointer()); - DerivativeType updateControlPointDerivative( + const DerivativeType updateControlPointDerivative( valuePointer, numberOfControlPointsPerTimePoint * numberOfTimeControlPoints * ImageDimension); this->m_OutputTransform->UpdateTransformParameters(updateControlPointDerivative, this->m_LearningRate); @@ -313,8 +313,8 @@ TimeVaryingBSplineVelocityFieldImageRegistrationMethodm_CurrentMetricValue = MeasureType{}; - SizeValueType numberOfIntegrationSteps = this->m_NumberOfTimePointSamples + 2; + const SizeValueType numberOfIntegrationSteps = this->m_NumberOfTimePointSamples + 2; - typename DisplacementFieldType::PixelType zeroVector{}; + const typename DisplacementFieldType::PixelType zeroVector{}; velocityFieldPointSet->Initialize(); velocityFieldWeights->Initialize(); @@ -437,7 +437,7 @@ TimeVaryingBSplineVelocityFieldImageRegistrationMethod< // variant in TimeVaryingVelocityFieldImageRegistration. See the function in the // PointSetToPointSetMetric::SetStoreDerivativeAsSparseFieldForLocalSupportTransforms. - SizeValueType initialNumberOfVelocityFieldPointsAtTimePoint = velocityFieldPointSet->GetNumberOfPoints(); + const SizeValueType initialNumberOfVelocityFieldPointsAtTimePoint = velocityFieldPointSet->GetNumberOfPoints(); if (this->m_Metric->GetMetricCategory() == ObjectToObjectMetricBaseTemplateEnums::MetricCategory::POINT_SET_METRIC) { @@ -472,7 +472,7 @@ TimeVaryingBSplineVelocityFieldImageRegistrationMethod< } } - InputPointSetPointer transformedPointSet = + const InputPointSetPointer transformedPointSet = dynamic_cast(this->m_Metric.GetPointer())->GetModifiableFixedTransformedPointSet(); typename InputPointSetType::PointsContainerConstIterator It = transformedPointSet->GetPoints()->Begin(); @@ -535,7 +535,7 @@ TimeVaryingBSplineVelocityFieldImageRegistrationMethod< spatioTemporalPoint[d] = imagePoint[d]; } spatioTemporalPoint[ImageDimension] = t; - typename VelocityFieldPointSetType::PixelType displacement(0.0); + const typename VelocityFieldPointSetType::PixelType displacement(0.0); velocityFieldPointSet->SetPoint(numberOfVelocityFieldPoints, spatioTemporalPoint); velocityFieldPointSet->SetPointData(numberOfVelocityFieldPoints, displacement); @@ -568,7 +568,7 @@ TimeVaryingBSplineVelocityFieldImageRegistrationMethod< { if (ItD.Index() >= initialNumberOfVelocityFieldPointsAtTimePoint) { - RealType squaredNorm = (ItD.Value()).GetSquaredNorm(); + const RealType squaredNorm = (ItD.Value()).GetSquaredNorm(); if (squaredNorm > maxSquaredNorm) { maxSquaredNorm = squaredNorm; @@ -579,7 +579,7 @@ TimeVaryingBSplineVelocityFieldImageRegistrationMethod< if (maxSquaredNorm > 0.0) { - RealType normalizationFactor = 1.0 / std::sqrt(maxSquaredNorm); + const RealType normalizationFactor = 1.0 / std::sqrt(maxSquaredNorm); ItD = velocityFieldPointSet->GetPointData()->Begin(); while (ItD != velocityFieldPointSet->GetPointData()->End()) @@ -613,7 +613,7 @@ TimeVaryingBSplineVelocityFieldImageRegistrationMethod< const TransformBaseType * movingTransform, const FixedImageMasksContainerType fixedImageMasks) { - VirtualImageBaseConstPointer virtualDomainImage = this->GetCurrentLevelVirtualDomainImage(); + const VirtualImageBaseConstPointer virtualDomainImage = this->GetCurrentLevelVirtualDomainImage(); typename DisplacementFieldType::DirectionType identity; identity.SetIdentity(); @@ -624,7 +624,7 @@ TimeVaryingBSplineVelocityFieldImageRegistrationMethod< bsplineParametricDomainField->SetDirection(identity); // bsplineParametricDomainField->Allocate(); - typename MultiMetricType::Pointer multiMetric = dynamic_cast(this->m_Metric.GetPointer()); + const typename MultiMetricType::Pointer multiMetric = dynamic_cast(this->m_Metric.GetPointer()); if (multiMetric) { diff --git a/Modules/Registration/RegistrationMethodsv4/include/itkTimeVaryingVelocityFieldImageRegistrationMethodv4.hxx b/Modules/Registration/RegistrationMethodsv4/include/itkTimeVaryingVelocityFieldImageRegistrationMethodv4.hxx index 78741a0ca6b..f6c483d1561 100644 --- a/Modules/Registration/RegistrationMethodsv4/include/itkTimeVaryingVelocityFieldImageRegistrationMethodv4.hxx +++ b/Modules/Registration/RegistrationMethodsv4/include/itkTimeVaryingVelocityFieldImageRegistrationMethodv4.hxx @@ -66,7 +66,7 @@ TimeVaryingVelocityFieldImageRegistrationMethodv4; using DisplacementFieldTransformType = DisplacementFieldTransform; - typename DisplacementFieldType::PixelType zeroVector{}; + const typename DisplacementFieldType::PixelType zeroVector{}; // This transform is used for the fixed image using IdentityTransformType = itk::IdentityTransform; @@ -78,10 +78,10 @@ TimeVaryingVelocityFieldImageRegistrationMethodv4m_OutputTransform->GetModifiableVelocityField(); - IndexValueType numberOfTimePoints = velocityField->GetLargestPossibleRegion().GetSize()[ImageDimension]; + const TimeVaryingVelocityFieldPointer velocityField = this->m_OutputTransform->GetModifiableVelocityField(); + const IndexValueType numberOfTimePoints = velocityField->GetLargestPossibleRegion().GetSize()[ImageDimension]; - SizeValueType numberOfIntegrationSteps = numberOfTimePoints + 2; + const SizeValueType numberOfIntegrationSteps = numberOfTimePoints + 2; const typename TimeVaryingVelocityFieldType::RegionType & largestRegion = velocityField->GetLargestPossibleRegion(); const SizeValueType numberOfPixelsPerTimePoint = largestRegion.GetNumberOfPixels() / numberOfTimePoints; @@ -89,10 +89,10 @@ TimeVaryingVelocityFieldImageRegistrationMethodv4GetSpacing(); typename VirtualImageType::ConstPointer virtualDomainImage; - typename MultiMetricType::Pointer multiMetric = dynamic_cast(this->m_Metric.GetPointer()); + const typename MultiMetricType::Pointer multiMetric = dynamic_cast(this->m_Metric.GetPointer()); if (multiMetric) { - typename ImageMetricType::Pointer metricQueue = + const typename ImageMetricType::Pointer metricQueue = dynamic_cast(multiMetric->GetMetricQueue()[0].GetPointer()); if (metricQueue.IsNotNull()) { @@ -105,7 +105,7 @@ TimeVaryingVelocityFieldImageRegistrationMethodv4(this->m_Metric.GetPointer()); + const typename ImageMetricType::Pointer metric = dynamic_cast(this->m_Metric.GetPointer()); if (metric.IsNotNull()) { virtualDomainImage = metric->GetVirtualImage(); @@ -228,7 +228,7 @@ TimeVaryingVelocityFieldImageRegistrationMethodv4(multiMetric->GetMetricQueue()[n].GetPointer()); if (metricQueue.IsNotNull()) { @@ -321,7 +321,7 @@ TimeVaryingVelocityFieldImageRegistrationMethodv4GetCurrentLevel(); - typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = + const unsigned int currentLevel = filter->GetCurrentLevel(); + const typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = filter->GetShrinkFactorsPerDimension(currentLevel); typename TFilter::SmoothingSigmasArrayType smoothingSigmas = filter->GetSmoothingSigmasPerLevel(); typename TFilter::TransformParametersAdaptorsContainerType adaptors = @@ -67,7 +67,7 @@ class CommandIterationUpdate : public itk::Command const itk::ObjectToObjectOptimizerBase * optimizerBase = filter->GetOptimizer(); using GradientDescentOptimizerv4Type = itk::GradientDescentOptimizerv4; - typename GradientDescentOptimizerv4Type::ConstPointer optimizer = + const typename GradientDescentOptimizerv4Type::ConstPointer optimizer = dynamic_cast(optimizerBase); if (!optimizer) { @@ -130,14 +130,14 @@ PerformBSplineExpImageRegistration(int argc, char * argv[]) auto fixedImageReader = ImageReaderType::New(); fixedImageReader->SetFileName(argv[2]); fixedImageReader->Update(); - typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); fixedImage->Update(); fixedImage->DisconnectPipeline(); auto movingImageReader = ImageReaderType::New(); movingImageReader->SetFileName(argv[3]); movingImageReader->Update(); - typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); + const typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); movingImage->Update(); movingImage->DisconnectPipeline(); @@ -160,7 +160,7 @@ PerformBSplineExpImageRegistration(int argc, char * argv[]) } using GradientDescentOptimizerv4Type = itk::GradientDescentOptimizerv4; - typename GradientDescentOptimizerv4Type::Pointer affineOptimizer = + const typename GradientDescentOptimizerv4Type::Pointer affineOptimizer = dynamic_cast(affineSimple->GetModifiableOptimizer()); if (!affineOptimizer) { @@ -181,7 +181,7 @@ PerformBSplineExpImageRegistration(int argc, char * argv[]) { using ImageMetricType = itk::ImageToImageMetricv4; - typename ImageMetricType::Pointer imageMetric = + const typename ImageMetricType::Pointer imageMetric = dynamic_cast(affineSimple->GetModifiableMetric()); if (imageMetric.IsNull()) { @@ -196,7 +196,7 @@ PerformBSplineExpImageRegistration(int argc, char * argv[]) { using ImageMetricType = itk::ImageToImageMetricv4; - typename ImageMetricType::Pointer imageMetric = + const typename ImageMetricType::Pointer imageMetric = dynamic_cast(affineOptimizer->GetModifiableMetric()); std::cout << "Affine parameters after registration: " << std::endl << affineOptimizer->GetCurrentPosition() << std::endl @@ -230,7 +230,7 @@ PerformBSplineExpImageRegistration(int argc, char * argv[]) using DisplacementFieldRegistrationType = itk::ImageRegistrationMethodv4; - typename DisplacementFieldRegistrationType::Pointer displacementFieldSimple = + const typename DisplacementFieldRegistrationType::Pointer displacementFieldSimple = DisplacementFieldRegistrationType::New(); auto fieldTransform = DisplacementFieldTransformType::New(); @@ -316,7 +316,7 @@ PerformBSplineExpImageRegistration(int argc, char * argv[]) shrinkFilter->SetInput(displacementField); shrinkFilter->Update(); - typename DisplacementFieldTransformAdaptorType::Pointer fieldTransformAdaptor = + const typename DisplacementFieldTransformAdaptorType::Pointer fieldTransformAdaptor = DisplacementFieldTransformAdaptorType::New(); fieldTransformAdaptor->SetRequiredSpacing(shrinkFilter->GetOutput()->GetSpacing()); fieldTransformAdaptor->SetRequiredSize(shrinkFilter->GetOutput()->GetBufferedRegion().GetSize()); @@ -328,7 +328,7 @@ PerformBSplineExpImageRegistration(int argc, char * argv[]) displacementFieldSimple->SetTransformParametersAdaptorsPerLevel(adaptors); using DisplacementFieldRegistrationCommandType = CommandIterationUpdate; - typename DisplacementFieldRegistrationCommandType::Pointer displacementFieldObserver = + const typename DisplacementFieldRegistrationCommandType::Pointer displacementFieldObserver = DisplacementFieldRegistrationCommandType::New(); displacementFieldSimple->AddObserver(itk::IterationEvent(), displacementFieldObserver); diff --git a/Modules/Registration/RegistrationMethodsv4/test/itkBSplineImageRegistrationTest.cxx b/Modules/Registration/RegistrationMethodsv4/test/itkBSplineImageRegistrationTest.cxx index 6a2d6881fda..a7cfd9440e2 100644 --- a/Modules/Registration/RegistrationMethodsv4/test/itkBSplineImageRegistrationTest.cxx +++ b/Modules/Registration/RegistrationMethodsv4/test/itkBSplineImageRegistrationTest.cxx @@ -55,8 +55,8 @@ class CommandIterationUpdate : public itk::Command return; } - unsigned int currentLevel = filter->GetCurrentLevel(); - typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = + const unsigned int currentLevel = filter->GetCurrentLevel(); + const typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = filter->GetShrinkFactorsPerDimension(currentLevel); typename TFilter::SmoothingSigmasArrayType smoothingSigmas = filter->GetSmoothingSigmasPerLevel(); typename TFilter::TransformParametersAdaptorsContainerType adaptors = @@ -64,7 +64,7 @@ class CommandIterationUpdate : public itk::Command const itk::ObjectToObjectOptimizerBase * optimizerBase = filter->GetOptimizer(); using GradientDescentOptimizerv4Type = itk::GradientDescentOptimizerv4; - typename GradientDescentOptimizerv4Type::ConstPointer optimizer = + const typename GradientDescentOptimizerv4Type::ConstPointer optimizer = dynamic_cast(optimizerBase); if (!optimizer) { @@ -119,14 +119,14 @@ PerformBSplineImageRegistration(int argc, char * argv[]) auto fixedImageReader = ImageReaderType::New(); fixedImageReader->SetFileName(argv[2]); fixedImageReader->Update(); - typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); fixedImage->Update(); fixedImage->DisconnectPipeline(); auto movingImageReader = ImageReaderType::New(); movingImageReader->SetFileName(argv[3]); movingImageReader->Update(); - typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); + const typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); movingImage->Update(); movingImage->DisconnectPipeline(); @@ -150,7 +150,7 @@ PerformBSplineImageRegistration(int argc, char * argv[]) } using GradientDescentOptimizerv4Type = itk::GradientDescentOptimizerv4; - typename GradientDescentOptimizerv4Type::Pointer affineOptimizer = + const typename GradientDescentOptimizerv4Type::Pointer affineOptimizer = dynamic_cast(affineSimple->GetModifiableOptimizer()); if (!affineOptimizer) { @@ -166,7 +166,7 @@ PerformBSplineImageRegistration(int argc, char * argv[]) { using ImageMetricType = itk::ImageToImageMetricv4; - typename ImageMetricType::Pointer imageMetric = + const typename ImageMetricType::Pointer imageMetric = dynamic_cast(affineSimple->GetModifiableMetric()); if (imageMetric.IsNull()) { @@ -181,7 +181,7 @@ PerformBSplineImageRegistration(int argc, char * argv[]) { using ImageMetricType = itk::ImageToImageMetricv4; - typename ImageMetricType::Pointer imageMetric = + const typename ImageMetricType::Pointer imageMetric = dynamic_cast(affineOptimizer->GetModifiableMetric()); std::cout << "Affine parameters after registration: " << std::endl << affineOptimizer->GetCurrentPosition() << std::endl diff --git a/Modules/Registration/RegistrationMethodsv4/test/itkBSplineSyNImageRegistrationTest.cxx b/Modules/Registration/RegistrationMethodsv4/test/itkBSplineSyNImageRegistrationTest.cxx index df70890377f..71a308dee99 100644 --- a/Modules/Registration/RegistrationMethodsv4/test/itkBSplineSyNImageRegistrationTest.cxx +++ b/Modules/Registration/RegistrationMethodsv4/test/itkBSplineSyNImageRegistrationTest.cxx @@ -58,8 +58,8 @@ class CommandIterationUpdate : public itk::Command return; } - unsigned int currentLevel = filter->GetCurrentLevel(); - typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = + const unsigned int currentLevel = filter->GetCurrentLevel(); + const typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = filter->GetShrinkFactorsPerDimension(currentLevel); typename TFilter::SmoothingSigmasArrayType smoothingSigmas = filter->GetSmoothingSigmasPerLevel(); typename TFilter::TransformParametersAdaptorsContainerType adaptors = @@ -89,14 +89,14 @@ PerformBSplineSyNImageRegistration(int argc, char * argv[]) auto fixedImageReader = ImageReaderType::New(); fixedImageReader->SetFileName(argv[2]); fixedImageReader->Update(); - typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); fixedImage->Update(); fixedImage->DisconnectPipeline(); auto movingImageReader = ImageReaderType::New(); movingImageReader->SetFileName(argv[3]); movingImageReader->Update(); - typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); + const typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); movingImage->Update(); movingImage->DisconnectPipeline(); @@ -153,7 +153,8 @@ PerformBSplineSyNImageRegistration(int argc, char * argv[]) affineResampler->SetDefaultPixelValue(0); affineResampler->Update(); - std::string affineMovingImageFileName = std::string(argv[4]) + std::string("MovingImageAfterAffineTransform.nii.gz"); + const std::string affineMovingImageFileName = + std::string(argv[4]) + std::string("MovingImageAfterAffineTransform.nii.gz"); using AffineWriterType = itk::ImageFileWriter; auto affineWriter = AffineWriterType::New(); @@ -180,7 +181,7 @@ PerformBSplineSyNImageRegistration(int argc, char * argv[]) inverseDisplacementField->FillBuffer(zeroVector); using DisplacementFieldRegistrationType = itk::BSplineSyNImageRegistrationMethod; - typename DisplacementFieldRegistrationType::Pointer displacementFieldRegistration = + const typename DisplacementFieldRegistrationType::Pointer displacementFieldRegistration = DisplacementFieldRegistrationType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS( @@ -210,7 +211,7 @@ PerformBSplineSyNImageRegistration(int argc, char * argv[]) // if the user wishes to add that option, they can use the class // GaussianSmoothingOnUpdateDisplacementFieldTransformAdaptor - unsigned int numberOfLevels = 3; + const unsigned int numberOfLevels = 3; typename DisplacementFieldRegistrationType::NumberOfIterationsArrayType numberOfIterationsPerLevel; numberOfIterationsPerLevel.SetSize(3); @@ -255,7 +256,7 @@ PerformBSplineSyNImageRegistration(int argc, char * argv[]) shrinkFilter->SetInput(displacementField); shrinkFilter->Update(); - typename DisplacementFieldTransformAdaptorType::Pointer fieldTransformAdaptor = + const typename DisplacementFieldTransformAdaptorType::Pointer fieldTransformAdaptor = DisplacementFieldTransformAdaptorType::New(); fieldTransformAdaptor->SetRequiredSpacing(shrinkFilter->GetOutput()->GetSpacing()); fieldTransformAdaptor->SetRequiredSize(shrinkFilter->GetOutput()->GetBufferedRegion().GetSize()); @@ -318,7 +319,7 @@ PerformBSplineSyNImageRegistration(int argc, char * argv[]) resampler->SetDefaultPixelValue(0); resampler->Update(); - std::string warpedMovingImageFileName = std::string(argv[4]) + std::string("MovingImageAfterSyN.nii.gz"); + const std::string warpedMovingImageFileName = std::string(argv[4]) + std::string("MovingImageAfterSyN.nii.gz"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); @@ -327,7 +328,7 @@ PerformBSplineSyNImageRegistration(int argc, char * argv[]) writer->Update(); using InverseResampleFilterType = itk::ResampleImageFilter; - typename InverseResampleFilterType::Pointer inverseResampler = ResampleFilterType::New(); + const typename InverseResampleFilterType::Pointer inverseResampler = ResampleFilterType::New(); inverseResampler->SetTransform(compositeTransform->GetInverseTransform()); inverseResampler->SetInput(fixedImage); inverseResampler->SetSize(movingImage->GetBufferedRegion().GetSize()); @@ -337,7 +338,8 @@ PerformBSplineSyNImageRegistration(int argc, char * argv[]) inverseResampler->SetDefaultPixelValue(0); inverseResampler->Update(); - std::string inverseWarpedFixedImageFileName = std::string(argv[4]) + std::string("InverseWarpedFixedImage.nii.gz"); + const std::string inverseWarpedFixedImageFileName = + std::string(argv[4]) + std::string("InverseWarpedFixedImage.nii.gz"); using InverseWriterType = itk::ImageFileWriter; auto inverseWriter = InverseWriterType::New(); @@ -345,7 +347,7 @@ PerformBSplineSyNImageRegistration(int argc, char * argv[]) inverseWriter->SetInput(inverseResampler->GetOutput()); inverseWriter->Update(); - std::string displacementFieldFileName = std::string(argv[4]) + std::string("DisplacementField.nii.gz"); + const std::string displacementFieldFileName = std::string(argv[4]) + std::string("DisplacementField.nii.gz"); using DisplacementFieldWriterType = itk::ImageFileWriter; auto displacementFieldWriter = DisplacementFieldWriterType::New(); diff --git a/Modules/Registration/RegistrationMethodsv4/test/itkBSplineSyNPointSetRegistrationTest.cxx b/Modules/Registration/RegistrationMethodsv4/test/itkBSplineSyNPointSetRegistrationTest.cxx index c216b6646c4..43d38c22c54 100644 --- a/Modules/Registration/RegistrationMethodsv4/test/itkBSplineSyNPointSetRegistrationTest.cxx +++ b/Modules/Registration/RegistrationMethodsv4/test/itkBSplineSyNPointSetRegistrationTest.cxx @@ -54,8 +54,8 @@ itkBSplineSyNPointSetRegistrationTest(int itkNotUsed(argc), char * itkNotUsed(ar { auto label = static_cast(1.5 + count / 100); - PointType fixedPoint; - float radius = 100.0; + PointType fixedPoint; + const float radius = 100.0; fixedPoint[0] = radius * std::cos(theta); fixedPoint[1] = radius * std::sin(theta); if (PointSetType::PointDimension > 2) @@ -154,7 +154,7 @@ itkBSplineSyNPointSetRegistrationTest(int itkNotUsed(argc), char * itkNotUsed(ar // if the user wishes to add that option, they can use the class // GaussianSmoothingOnUpdateDisplacementFieldTransformAdaptor - unsigned int numberOfLevels = 3; + const unsigned int numberOfLevels = 3; DisplacementFieldRegistrationType::NumberOfIterationsArrayType numberOfIterationsPerLevel; numberOfIterationsPerLevel.SetSize(3); @@ -232,7 +232,7 @@ itkBSplineSyNPointSetRegistrationTest(int itkNotUsed(argc), char * itkNotUsed(ar // applying the resultant transform to moving points and verify result std::cout << "Fixed\tMoving\tMovingTransformed\tFixedTransformed\tDiff" << std::endl; - PointType::ValueType tolerance = 0.01; + const PointType::ValueType tolerance = 0.01; float averageError = 0.0; for (unsigned int n = 0; n < movingPoints->GetNumberOfPoints(); ++n) @@ -241,8 +241,8 @@ itkBSplineSyNPointSetRegistrationTest(int itkNotUsed(argc), char * itkNotUsed(ar PointType transformedMovingPoint = displacementFieldRegistration->GetModifiableTransform()->GetInverseTransform()->TransformPoint( movingPoints->GetPoint(n)); - PointType fixedPoint = fixedPoints->GetPoint(n); - PointType transformedFixedPoint = + PointType fixedPoint = fixedPoints->GetPoint(n); + const PointType transformedFixedPoint = displacementFieldRegistration->GetModifiableTransform()->TransformPoint(fixedPoints->GetPoint(n)); PointType difference; difference[0] = transformedMovingPoint[0] - fixedPoint[0]; @@ -253,7 +253,7 @@ itkBSplineSyNPointSetRegistrationTest(int itkNotUsed(argc), char * itkNotUsed(ar averageError += ((difference.GetVectorFromOrigin()).GetSquaredNorm()); } - unsigned int numberOfPoints = movingPoints->GetNumberOfPoints(); + const unsigned int numberOfPoints = movingPoints->GetNumberOfPoints(); if (numberOfPoints > 0) { averageError /= static_cast(numberOfPoints); diff --git a/Modules/Registration/RegistrationMethodsv4/test/itkExponentialImageRegistrationTest.cxx b/Modules/Registration/RegistrationMethodsv4/test/itkExponentialImageRegistrationTest.cxx index 463ac81c686..1e4929edb95 100644 --- a/Modules/Registration/RegistrationMethodsv4/test/itkExponentialImageRegistrationTest.cxx +++ b/Modules/Registration/RegistrationMethodsv4/test/itkExponentialImageRegistrationTest.cxx @@ -61,8 +61,8 @@ class CommandIterationUpdate : public itk::Command return; } - unsigned int currentLevel = filter->GetCurrentLevel(); - typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = + const unsigned int currentLevel = filter->GetCurrentLevel(); + const typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = filter->GetShrinkFactorsPerDimension(currentLevel); typename TFilter::SmoothingSigmasArrayType smoothingSigmas = filter->GetSmoothingSigmasPerLevel(); typename TFilter::TransformParametersAdaptorsContainerType adaptors = @@ -70,7 +70,7 @@ class CommandIterationUpdate : public itk::Command const itk::ObjectToObjectOptimizerBase * optimizerBase = filter->GetOptimizer(); using GradientDescentOptimizerv4Type = itk::GradientDescentOptimizerv4; - typename GradientDescentOptimizerv4Type::ConstPointer optimizer = + const typename GradientDescentOptimizerv4Type::ConstPointer optimizer = dynamic_cast(optimizerBase); if (!optimizer) { @@ -137,7 +137,7 @@ PerformExpImageRegistration(int argc, char * argv[]) timer.Start("0 fixedImageReader"); fixedImageReader->Update(); timer.Stop("0 fixedImageReader"); - typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); timer.Start("1 fixedImage"); fixedImage->Update(); timer.Stop("1 fixedImage"); @@ -148,7 +148,7 @@ PerformExpImageRegistration(int argc, char * argv[]) timer.Start("2 movingImageReader"); movingImageReader->Update(); timer.Stop("2 movingImageReader"); - typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); + const typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); timer.Start("3 movingImage"); movingImage->Update(); timer.Stop("3 movingImage"); @@ -173,7 +173,7 @@ PerformExpImageRegistration(int argc, char * argv[]) } using GradientDescentOptimizerv4Type = itk::GradientDescentOptimizerv4; - typename GradientDescentOptimizerv4Type::Pointer affineOptimizer = + const typename GradientDescentOptimizerv4Type::Pointer affineOptimizer = dynamic_cast(affineSimple->GetModifiableOptimizer()); if (affineOptimizer.IsNull()) { @@ -194,7 +194,7 @@ PerformExpImageRegistration(int argc, char * argv[]) { using ImageMetricType = itk::ImageToImageMetricv4; - typename ImageMetricType::Pointer imageMetric = + const typename ImageMetricType::Pointer imageMetric = dynamic_cast(affineSimple->GetModifiableMetric()); if (imageMetric.IsNull()) { @@ -212,7 +212,7 @@ PerformExpImageRegistration(int argc, char * argv[]) { using ImageMetricType = itk::ImageToImageMetricv4; - typename ImageMetricType::Pointer imageMetric = + const typename ImageMetricType::Pointer imageMetric = dynamic_cast(affineOptimizer->GetModifiableMetric()); std::cout << "Affine parameters after registration: " << std::endl << affineOptimizer->GetCurrentPosition() << std::endl @@ -247,7 +247,7 @@ PerformExpImageRegistration(int argc, char * argv[]) using DisplacementFieldRegistrationType = itk::ImageRegistrationMethodv4; - typename DisplacementFieldRegistrationType::Pointer displacementFieldSimple = + const typename DisplacementFieldRegistrationType::Pointer displacementFieldSimple = DisplacementFieldRegistrationType::New(); auto fieldTransform = ConstantVelocityFieldTransformType::New(); @@ -351,7 +351,7 @@ PerformExpImageRegistration(int argc, char * argv[]) shrinkFilter->Update(); timer.Stop("5 shrink"); - typename VelocityFieldTransformAdaptorType::Pointer fieldTransformAdaptor = + const typename VelocityFieldTransformAdaptorType::Pointer fieldTransformAdaptor = VelocityFieldTransformAdaptorType::New(); fieldTransformAdaptor->SetRequiredSpacing(shrinkFilter->GetOutput()->GetSpacing()); fieldTransformAdaptor->SetRequiredSize(shrinkFilter->GetOutput()->GetBufferedRegion().GetSize()); @@ -366,7 +366,7 @@ PerformExpImageRegistration(int argc, char * argv[]) displacementFieldSimple->InPlaceOn(); using DisplacementFieldRegistrationCommandType = CommandIterationUpdate; - typename DisplacementFieldRegistrationCommandType::Pointer displacementFieldObserver = + const typename DisplacementFieldRegistrationCommandType::Pointer displacementFieldObserver = DisplacementFieldRegistrationCommandType::New(); displacementFieldSimple->AddObserver(itk::IterationEvent(), displacementFieldObserver); diff --git a/Modules/Registration/RegistrationMethodsv4/test/itkImageRegistrationSamplingTest.cxx b/Modules/Registration/RegistrationMethodsv4/test/itkImageRegistrationSamplingTest.cxx index cd2f2bf7544..bcac84c220d 100644 --- a/Modules/Registration/RegistrationMethodsv4/test/itkImageRegistrationSamplingTest.cxx +++ b/Modules/Registration/RegistrationMethodsv4/test/itkImageRegistrationSamplingTest.cxx @@ -37,9 +37,9 @@ itkImageRegistrationSamplingTest(int, char *[]) ITK_TRY_EXPECT_NO_EXCEPTION(registrationMethod->SetMetricSamplingPercentage(0.1)); - constexpr unsigned int NUM_ERRORS = 3; - RegistrationType::RealType errorValues[NUM_ERRORS] = { -0.1, 0.0, 1.1 }; - for (double errorValue : errorValues) + constexpr unsigned int NUM_ERRORS = 3; + const RegistrationType::RealType errorValues[NUM_ERRORS] = { -0.1, 0.0, 1.1 }; + for (const double errorValue : errorValues) { ITK_TRY_EXPECT_EXCEPTION(registrationMethod->SetMetricSamplingPercentage(errorValue)); } diff --git a/Modules/Registration/RegistrationMethodsv4/test/itkQuasiNewtonOptimizerv4RegistrationTest.cxx b/Modules/Registration/RegistrationMethodsv4/test/itkQuasiNewtonOptimizerv4RegistrationTest.cxx index 0983946aba3..eb53d2941c1 100644 --- a/Modules/Registration/RegistrationMethodsv4/test/itkQuasiNewtonOptimizerv4RegistrationTest.cxx +++ b/Modules/Registration/RegistrationMethodsv4/test/itkQuasiNewtonOptimizerv4RegistrationTest.cxx @@ -53,9 +53,9 @@ template int itkQuasiNewtonOptimizerv4RegistrationTestMain(int argc, char * argv[]) { - std::string metricString = argv[2]; - unsigned int numberOfIterations = 10; - unsigned int numberOfDisplacementIterations = 10; + const std::string metricString = argv[2]; + unsigned int numberOfIterations = 10; + unsigned int numberOfDisplacementIterations = 10; if (argc >= 7) { @@ -84,9 +84,9 @@ itkQuasiNewtonOptimizerv4RegistrationTestMain(int argc, char * argv[]) // get the images fixedImageReader->Update(); - typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); movingImageReader->Update(); - typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); + const typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); /** define a resample filter that will ultimately be used to deform the image */ using ResampleFilterType = itk::ResampleImageFilter; @@ -118,7 +118,7 @@ itkQuasiNewtonOptimizerv4RegistrationTestMain(int argc, char * argv[]) << "fixedImage->GetBufferedRegion(): " << fixedImage->GetBufferedRegion() << std::endl; field->Allocate(); // Fill it with 0's - typename DisplacementTransformType::OutputVectorType zeroVector{}; + const typename DisplacementTransformType::OutputVectorType zeroVector{}; field->FillBuffer(zeroVector); // Assign to transform displacementTransform->SetDisplacementField(field); @@ -149,7 +149,7 @@ itkQuasiNewtonOptimizerv4RegistrationTestMain(int argc, char * argv[]) miMetric->SetNumberOfHistogramBins(20); using PointType = typename PointSetType::PointType; - typename PointSetType::Pointer pset(PointSetType::New()); + const typename PointSetType::Pointer pset(PointSetType::New()); unsigned long ind = 0; unsigned long ct = 0; itk::ImageRegionIteratorWithIndex It(fixedImage, fixedImage->GetLargestPossibleRegion()); @@ -198,13 +198,13 @@ itkQuasiNewtonOptimizerv4RegistrationTestMain(int argc, char * argv[]) metric->SetMovingImage(movingImage); metric->SetFixedTransform(identityTransform); metric->SetMovingTransform(affineTransform); - bool gaussian = false; + const bool gaussian = false; metric->SetUseMovingImageGradientFilter(gaussian); metric->SetUseFixedImageGradientFilter(gaussian); metric->Initialize(); using RegistrationParameterScalesFromShiftType = itk::RegistrationParameterScalesFromPhysicalShift; - typename RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = + const typename RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = RegistrationParameterScalesFromShiftType::New(); shiftScaleEstimator->SetMetric(metric); @@ -275,11 +275,11 @@ itkQuasiNewtonOptimizerv4RegistrationTestMain(int argc, char * argv[]) resample->Update(); // write out the displacement field using DisplacementWriterType = itk::ImageFileWriter; - auto displacementwriter = DisplacementWriterType::New(); - std::string outfilename(argv[5]); - std::string ext = itksys::SystemTools::GetFilenameExtension(outfilename); - std::string name = itksys::SystemTools::GetFilenameWithoutExtension(outfilename); - std::string defout = name + std::string("_def") + ext; + auto displacementwriter = DisplacementWriterType::New(); + const std::string outfilename(argv[5]); + const std::string ext = itksys::SystemTools::GetFilenameExtension(outfilename); + const std::string name = itksys::SystemTools::GetFilenameWithoutExtension(outfilename); + const std::string defout = name + std::string("_def") + ext; displacementwriter->SetFileName(defout.c_str()); displacementwriter->SetInput(displacementTransform->GetDisplacementField()); displacementwriter->Update(); @@ -322,7 +322,7 @@ itkQuasiNewtonOptimizerv4RegistrationTest(int argc, char * argv[]) return EXIT_FAILURE; } - unsigned int Dimension = std::stoi(argv[1]); + const unsigned int Dimension = std::stoi(argv[1]); if (Dimension == 2) { diff --git a/Modules/Registration/RegistrationMethodsv4/test/itkSimpleImageRegistrationTest.cxx b/Modules/Registration/RegistrationMethodsv4/test/itkSimpleImageRegistrationTest.cxx index dc15a25841e..75fa5281873 100644 --- a/Modules/Registration/RegistrationMethodsv4/test/itkSimpleImageRegistrationTest.cxx +++ b/Modules/Registration/RegistrationMethodsv4/test/itkSimpleImageRegistrationTest.cxx @@ -68,8 +68,8 @@ class CommandIterationUpdate : public itk::Command return; } - unsigned int currentLevel = filter->GetCurrentLevel(); - typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = + const unsigned int currentLevel = filter->GetCurrentLevel(); + const typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = filter->GetShrinkFactorsPerDimension(currentLevel); typename TFilter::SmoothingSigmasArrayType smoothingSigmas = filter->GetSmoothingSigmasPerLevel(); typename TFilter::TransformParametersAdaptorsContainerType adaptors = @@ -77,7 +77,7 @@ class CommandIterationUpdate : public itk::Command const itk::ObjectToObjectOptimizerBase * optimizerBase = filter->GetOptimizer(); using GradientDescentOptimizerv4Type = itk::GradientDescentOptimizerv4; - typename GradientDescentOptimizerv4Type::ConstPointer optimizer = + const typename GradientDescentOptimizerv4Type::ConstPointer optimizer = dynamic_cast(optimizerBase); if (!optimizer) { @@ -135,14 +135,14 @@ PerformSimpleImageRegistration(int argc, char * argv[]) auto fixedImageReader = ImageReaderType::New(); fixedImageReader->SetFileName(argv[3]); fixedImageReader->Update(); - typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); fixedImage->Update(); fixedImage->DisconnectPipeline(); auto movingImageReader = ImageReaderType::New(); movingImageReader->SetFileName(argv[4]); movingImageReader->Update(); - typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); + const typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); movingImage->Update(); movingImage->DisconnectPipeline(); @@ -207,7 +207,7 @@ PerformSimpleImageRegistration(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(smoothingSigmasPerLevel, affineSimple->GetSmoothingSigmasPerLevel()); } - typename AffineRegistrationType::RealType metricSamplingPercentage = 1.0; + const typename AffineRegistrationType::RealType metricSamplingPercentage = 1.0; affineSimple->SetMetricSamplingPercentage(metricSamplingPercentage); typename AffineRegistrationType::MetricSamplingPercentageArrayType metricSamplingPercentagePerLevel; @@ -219,7 +219,7 @@ PerformSimpleImageRegistration(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(metricSamplingPercentagePerLevel, affineSimple->GetMetricSamplingPercentagePerLevel()); using GradientDescentOptimizerv4Type = itk::GradientDescentOptimizerv4; - typename GradientDescentOptimizerv4Type::Pointer affineOptimizer = + const typename GradientDescentOptimizerv4Type::Pointer affineOptimizer = dynamic_cast(affineSimple->GetModifiableOptimizer()); if (!affineOptimizer) { @@ -240,7 +240,7 @@ PerformSimpleImageRegistration(int argc, char * argv[]) { using ImageMetricType = itk::ImageToImageMetricv4; - typename ImageMetricType::Pointer imageMetric = + const typename ImageMetricType::Pointer imageMetric = dynamic_cast(affineSimple->GetModifiableMetric()); // imageMetric->SetUseFloatingPointCorrection(true); imageMetric->SetFloatingPointCorrectionResolution(1e4); @@ -272,7 +272,7 @@ PerformSimpleImageRegistration(int argc, char * argv[]) fieldTransform->SetDisplacementField(displacementField); using DisplacementFieldRegistrationType = itk::ImageRegistrationMethodv4; - typename DisplacementFieldRegistrationType::Pointer displacementFieldSimple = + const typename DisplacementFieldRegistrationType::Pointer displacementFieldSimple = DisplacementFieldRegistrationType::New(); displacementFieldSimple->SetObjectName("displacementFieldSimple"); @@ -363,7 +363,7 @@ PerformSimpleImageRegistration(int argc, char * argv[]) shrinkFilter->SetInput(displacementField); shrinkFilter->Update(); - typename DisplacementFieldTransformAdaptorType::Pointer fieldTransformAdaptor = + const typename DisplacementFieldTransformAdaptorType::Pointer fieldTransformAdaptor = DisplacementFieldTransformAdaptorType::New(); fieldTransformAdaptor->SetRequiredSpacing(shrinkFilter->GetOutput()->GetSpacing()); fieldTransformAdaptor->SetRequiredSize(shrinkFilter->GetOutput()->GetBufferedRegion().GetSize()); @@ -375,7 +375,7 @@ PerformSimpleImageRegistration(int argc, char * argv[]) displacementFieldSimple->SetTransformParametersAdaptorsPerLevel(adaptors); using DisplacementFieldRegistrationCommandType = CommandIterationUpdate; - typename DisplacementFieldRegistrationCommandType::Pointer displacementFieldObserver = + const typename DisplacementFieldRegistrationCommandType::Pointer displacementFieldObserver = DisplacementFieldRegistrationCommandType::New(); displacementFieldSimple->AddObserver(itk::IterationEvent(), displacementFieldObserver); @@ -388,7 +388,8 @@ PerformSimpleImageRegistration(int argc, char * argv[]) std::cout << "IsConverged: " << displacementFieldSimple->GetIsConverged() << std::endl; using ImageMetricType = itk::ImageToImageMetricv4; - typename ImageMetricType::ConstPointer imageMetric = dynamic_cast(affineSimple->GetMetric()); + const typename ImageMetricType::ConstPointer imageMetric = + dynamic_cast(affineSimple->GetMetric()); std::cout << " Affine parameters after registration: " << std::endl << affineOptimizer->GetCurrentPosition() << std::endl << " Last LearningRate: " << affineOptimizer->GetLearningRate() << std::endl diff --git a/Modules/Registration/RegistrationMethodsv4/test/itkSimpleImageRegistrationTest2.cxx b/Modules/Registration/RegistrationMethodsv4/test/itkSimpleImageRegistrationTest2.cxx index 77217f6f7b0..01a08fd5133 100644 --- a/Modules/Registration/RegistrationMethodsv4/test/itkSimpleImageRegistrationTest2.cxx +++ b/Modules/Registration/RegistrationMethodsv4/test/itkSimpleImageRegistrationTest2.cxx @@ -80,8 +80,8 @@ class CommandIterationUpdate : public itk::Command return; } - unsigned int currentLevel = filter->GetCurrentLevel(); - typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = + const unsigned int currentLevel = filter->GetCurrentLevel(); + const typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = filter->GetShrinkFactorsPerDimension(currentLevel); typename TFilter::SmoothingSigmasArrayType smoothingSigmas = filter->GetSmoothingSigmasPerLevel(); typename TFilter::TransformParametersAdaptorsContainerType adaptors = @@ -89,7 +89,7 @@ class CommandIterationUpdate : public itk::Command const itk::ObjectToObjectOptimizerBase * optimizerBase = filter->GetOptimizer(); using GradientDescentOptimizerv4Type = itk::GradientDescentOptimizerv4; - typename GradientDescentOptimizerv4Type::ConstPointer optimizer = + const typename GradientDescentOptimizerv4Type::ConstPointer optimizer = dynamic_cast(optimizerBase); if (!optimizer) { @@ -152,14 +152,14 @@ PerformSimpleImageRegistration2(int argc, char * argv[]) auto fixedImageReader = ImageReaderType::New(); fixedImageReader->SetFileName(argv[2]); fixedImageReader->Update(); - typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); fixedImage->Update(); fixedImage->DisconnectPipeline(); auto movingImageReader = ImageReaderType::New(); movingImageReader->SetFileName(argv[3]); movingImageReader->Update(); - typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); + const typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); movingImage->Update(); movingImage->DisconnectPipeline(); @@ -204,9 +204,9 @@ PerformSimpleImageRegistration2(int argc, char * argv[]) rigidShrinkFactorsPerLevel[2] = 4; rigidRegistration->SetShrinkFactorsPerLevel(rigidShrinkFactorsPerLevel); - typename RegistrationType::MetricSamplingStrategyEnum rigidSamplingStrategy = + const typename RegistrationType::MetricSamplingStrategyEnum rigidSamplingStrategy = RegistrationType::MetricSamplingStrategyEnum::RANDOM; - double rigidSamplingPercentage = 0.20; + const double rigidSamplingPercentage = 0.20; rigidRegistration->SetMetricSamplingStrategy(rigidSamplingStrategy); ITK_TEST_SET_GET_VALUE(rigidSamplingStrategy, rigidRegistration->GetMetricSamplingStrategy()); @@ -293,7 +293,7 @@ PerformSimpleImageRegistration2(int argc, char * argv[]) affineSimple->SetSmoothingSigmasPerLevel(smoothingSigmasPerLevel); } - typename GradientDescentOptimizerv4Type::Pointer affineOptimizer = + const typename GradientDescentOptimizerv4Type::Pointer affineOptimizer = dynamic_cast(affineSimple->GetModifiableOptimizer()); if (!affineOptimizer) { diff --git a/Modules/Registration/RegistrationMethodsv4/test/itkSimpleImageRegistrationTest3.cxx b/Modules/Registration/RegistrationMethodsv4/test/itkSimpleImageRegistrationTest3.cxx index d3d0cf691e2..3cfd6f835aa 100644 --- a/Modules/Registration/RegistrationMethodsv4/test/itkSimpleImageRegistrationTest3.cxx +++ b/Modules/Registration/RegistrationMethodsv4/test/itkSimpleImageRegistrationTest3.cxx @@ -101,8 +101,8 @@ class CommandIterationUpdate : public itk::Command return; } - unsigned int currentLevel = filter->GetCurrentLevel(); - typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = + const unsigned int currentLevel = filter->GetCurrentLevel(); + const typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = filter->GetShrinkFactorsPerDimension(currentLevel); typename TFilter::SmoothingSigmasArrayType smoothingSigmas = filter->GetSmoothingSigmasPerLevel(); typename TFilter::TransformParametersAdaptorsContainerType adaptors = @@ -136,14 +136,14 @@ PerformCompositeImageRegistration(int argc, char * argv[]) auto fixedImageReader = ImageReaderType::New(); fixedImageReader->SetFileName(argv[2]); fixedImageReader->Update(); - typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); fixedImage->Update(); fixedImage->DisconnectPipeline(); auto movingImageReader = ImageReaderType::New(); movingImageReader->SetFileName(argv[3]); movingImageReader->Update(); - typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); + const typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); movingImage->Update(); movingImage->DisconnectPipeline(); @@ -305,7 +305,7 @@ PerformCompositeImageRegistration(int argc, char * argv[]) resampler->SetDefaultPixelValue(0); resampler->Update(); - std::string warpedMovingImageFileName = std::string(argv[4]) + std::string("WarpedMovingImage.nii.gz"); + const std::string warpedMovingImageFileName = std::string(argv[4]) + std::string("WarpedMovingImage.nii.gz"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); @@ -314,7 +314,7 @@ PerformCompositeImageRegistration(int argc, char * argv[]) writer->Update(); using InverseResampleFilterType = itk::ResampleImageFilter; - typename InverseResampleFilterType::Pointer inverseResampler = ResampleFilterType::New(); + const typename InverseResampleFilterType::Pointer inverseResampler = ResampleFilterType::New(); inverseResampler->SetTransform(compositeTransform->GetInverseTransform()); inverseResampler->SetInput(fixedImage); inverseResampler->SetSize(movingImage->GetBufferedRegion().GetSize()); @@ -324,7 +324,8 @@ PerformCompositeImageRegistration(int argc, char * argv[]) inverseResampler->SetDefaultPixelValue(0); inverseResampler->Update(); - std::string inverseWarpedFixedImageFileName = std::string(argv[4]) + std::string("InverseWarpedFixedImage.nii.gz"); + const std::string inverseWarpedFixedImageFileName = + std::string(argv[4]) + std::string("InverseWarpedFixedImage.nii.gz"); using InverseWriterType = itk::ImageFileWriter; auto inverseWriter = InverseWriterType::New(); diff --git a/Modules/Registration/RegistrationMethodsv4/test/itkSimpleImageRegistrationTest4.cxx b/Modules/Registration/RegistrationMethodsv4/test/itkSimpleImageRegistrationTest4.cxx index aa13282189e..66a2a1b78bd 100644 --- a/Modules/Registration/RegistrationMethodsv4/test/itkSimpleImageRegistrationTest4.cxx +++ b/Modules/Registration/RegistrationMethodsv4/test/itkSimpleImageRegistrationTest4.cxx @@ -92,14 +92,14 @@ ImageRegistration(int argc, char * argv[]) auto fixedImageReader = ImageReaderType::New(); fixedImageReader->SetFileName(argv[2]); fixedImageReader->Update(); - typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); fixedImage->Update(); fixedImage->DisconnectPipeline(); auto movingImageReader = ImageReaderType::New(); movingImageReader->SetFileName(argv[3]); movingImageReader->Update(); - typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); + const typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); movingImage->Update(); movingImage->DisconnectPipeline(); @@ -128,8 +128,8 @@ ImageRegistration(int argc, char * argv[]) optimizer->SetMinimumConvergenceValue(1e-5); optimizer->SetConvergenceWindowSize(2); - double scaleData[] = { 200000, 1.0, 1.0 }; - typename Optimizerv4Type::ScalesType::Superclass scales(scaleData, 3); + double scaleData[] = { 200000, 1.0, 1.0 }; + const typename Optimizerv4Type::ScalesType::Superclass scales(scaleData, 3); optimizer->SetScales(scales); registration->SetOptimizer(optimizer); @@ -143,7 +143,7 @@ ImageRegistration(int argc, char * argv[]) registration->GetTransform()->Print(std::cout); std::cout << optimizer->GetStopConditionDescription() << std::endl; - typename TransformType::ParametersType results = registration->GetTransform()->GetParameters(); + const typename TransformType::ParametersType results = registration->GetTransform()->GetParameters(); std::cout << "Expecting close (+/- 0.3) to: ( 0.0, -2.8, 9.5 )" << std::endl; std::cout << "Parameters: " << results << std::endl; diff --git a/Modules/Registration/RegistrationMethodsv4/test/itkSimpleImageRegistrationTestWithMaskAndSampling.cxx b/Modules/Registration/RegistrationMethodsv4/test/itkSimpleImageRegistrationTestWithMaskAndSampling.cxx index 4be35c30cce..0171efb8345 100644 --- a/Modules/Registration/RegistrationMethodsv4/test/itkSimpleImageRegistrationTestWithMaskAndSampling.cxx +++ b/Modules/Registration/RegistrationMethodsv4/test/itkSimpleImageRegistrationTestWithMaskAndSampling.cxx @@ -68,8 +68,8 @@ class CommandIterationUpdate : public itk::Command return; } - unsigned int currentLevel = filter->GetCurrentLevel(); - typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = + const unsigned int currentLevel = filter->GetCurrentLevel(); + const typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = filter->GetShrinkFactorsPerDimension(currentLevel); typename TFilter::SmoothingSigmasArrayType smoothingSigmas = filter->GetSmoothingSigmasPerLevel(); typename TFilter::TransformParametersAdaptorsContainerType adaptors = @@ -77,7 +77,7 @@ class CommandIterationUpdate : public itk::Command const itk::ObjectToObjectOptimizerBase * optimizerBase = filter->GetOptimizer(); using GradientDescentOptimizerv4Type = itk::GradientDescentOptimizerv4; - typename GradientDescentOptimizerv4Type::ConstPointer optimizer = + const typename GradientDescentOptimizerv4Type::ConstPointer optimizer = dynamic_cast(optimizerBase); if (!optimizer) { @@ -135,7 +135,7 @@ PerformSimpleImageRegistrationWithMaskAndSampling(int argc, char * argv[]) auto fixedImageReader = ImageReaderType::New(); fixedImageReader->SetFileName(argv[3]); fixedImageReader->Update(); - typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); fixedImage->Update(); fixedImage->DisconnectPipeline(); @@ -158,7 +158,7 @@ PerformSimpleImageRegistrationWithMaskAndSampling(int argc, char * argv[]) auto movingImageReader = ImageReaderType::New(); movingImageReader->SetFileName(argv[4]); movingImageReader->Update(); - typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); + const typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); movingImage->Update(); movingImage->DisconnectPipeline(); @@ -219,7 +219,7 @@ PerformSimpleImageRegistrationWithMaskAndSampling(int argc, char * argv[]) } using GradientDescentOptimizerv4Type = itk::GradientDescentOptimizerv4; - typename GradientDescentOptimizerv4Type::Pointer affineOptimizer = + const typename GradientDescentOptimizerv4Type::Pointer affineOptimizer = dynamic_cast(affineSimple->GetModifiableOptimizer()); if (!affineOptimizer) { @@ -240,7 +240,7 @@ PerformSimpleImageRegistrationWithMaskAndSampling(int argc, char * argv[]) { using ImageMetricType = itk::ImageToImageMetricv4; - typename ImageMetricType::Pointer imageMetric = + const typename ImageMetricType::Pointer imageMetric = dynamic_cast(affineSimple->GetModifiableMetric()); // imageMetric->SetUseFloatingPointCorrection(true); imageMetric->SetFloatingPointCorrectionResolution(1e4); @@ -271,7 +271,7 @@ PerformSimpleImageRegistrationWithMaskAndSampling(int argc, char * argv[]) fieldTransform->SetDisplacementField(displacementField); using DisplacementFieldRegistrationType = itk::ImageRegistrationMethodv4; - typename DisplacementFieldRegistrationType::Pointer displacementFieldSimple = + const typename DisplacementFieldRegistrationType::Pointer displacementFieldSimple = DisplacementFieldRegistrationType::New(); displacementFieldSimple->SetObjectName("displacementFieldSimple"); @@ -352,7 +352,7 @@ PerformSimpleImageRegistrationWithMaskAndSampling(int argc, char * argv[]) shrinkFilter->SetInput(displacementField); shrinkFilter->Update(); - typename DisplacementFieldTransformAdaptorType::Pointer fieldTransformAdaptor = + const typename DisplacementFieldTransformAdaptorType::Pointer fieldTransformAdaptor = DisplacementFieldTransformAdaptorType::New(); fieldTransformAdaptor->SetRequiredSpacing(shrinkFilter->GetOutput()->GetSpacing()); fieldTransformAdaptor->SetRequiredSize(shrinkFilter->GetOutput()->GetBufferedRegion().GetSize()); @@ -364,7 +364,7 @@ PerformSimpleImageRegistrationWithMaskAndSampling(int argc, char * argv[]) displacementFieldSimple->SetTransformParametersAdaptorsPerLevel(adaptors); using DisplacementFieldRegistrationCommandType = CommandIterationUpdate; - typename DisplacementFieldRegistrationCommandType::Pointer displacementFieldObserver = + const typename DisplacementFieldRegistrationCommandType::Pointer displacementFieldObserver = DisplacementFieldRegistrationCommandType::New(); displacementFieldSimple->AddObserver(itk::IterationEvent(), displacementFieldObserver); @@ -372,7 +372,8 @@ PerformSimpleImageRegistrationWithMaskAndSampling(int argc, char * argv[]) using ImageMetricType = itk::ImageToImageMetricv4; - typename ImageMetricType::ConstPointer imageMetric = dynamic_cast(affineSimple->GetMetric()); + const typename ImageMetricType::ConstPointer imageMetric = + dynamic_cast(affineSimple->GetMetric()); std::cout << " Affine parameters after registration: " << std::endl << affineOptimizer->GetCurrentPosition() << std::endl << " Last LearningRate: " << affineOptimizer->GetLearningRate() << std::endl diff --git a/Modules/Registration/RegistrationMethodsv4/test/itkSimplePointSetRegistrationTest.cxx b/Modules/Registration/RegistrationMethodsv4/test/itkSimplePointSetRegistrationTest.cxx index eba382356d4..6c301b6d0cd 100644 --- a/Modules/Registration/RegistrationMethodsv4/test/itkSimplePointSetRegistrationTest.cxx +++ b/Modules/Registration/RegistrationMethodsv4/test/itkSimplePointSetRegistrationTest.cxx @@ -62,13 +62,13 @@ class CommandIterationUpdate : public itk::Command return; } - unsigned int currentLevel = filter->GetCurrentLevel(); + const unsigned int currentLevel = filter->GetCurrentLevel(); typename TFilter::TransformParametersAdaptorsContainerType adaptors = filter->GetTransformParametersAdaptorsPerLevel(); const itk::ObjectToObjectOptimizerBase * optimizerBase = filter->GetOptimizer(); using GradientDescentOptimizerv4Type = itk::GradientDescentOptimizerv4; - typename GradientDescentOptimizerv4Type::ConstPointer optimizer = + const typename GradientDescentOptimizerv4Type::ConstPointer optimizer = dynamic_cast(optimizerBase); if (!optimizer) { @@ -135,8 +135,8 @@ itkSimplePointSetRegistrationTest(int itkNotUsed(argc), char * itkNotUsed(argv)[ { auto label = static_cast(1.5 + count / 100); - PointType fixedPoint; - float radius = 100.0; + PointType fixedPoint; + const float radius = 100.0; fixedPoint[0] = radius * std::cos(theta); fixedPoint[1] = radius * std::sin(theta); if (PointSetType::PointDimension > 2) @@ -191,7 +191,7 @@ itkSimplePointSetRegistrationTest(int itkNotUsed(argc), char * itkNotUsed(argv)[ // scales estimator using RegistrationParameterScalesFromShiftType = itk::RegistrationParameterScalesFromPhysicalShift; - RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = + const RegistrationParameterScalesFromShiftType::Pointer shiftScaleEstimator = RegistrationParameterScalesFromShiftType::New(); shiftScaleEstimator->SetMetric(metric); shiftScaleEstimator->SetTransformForward(true); @@ -231,16 +231,17 @@ itkSimplePointSetRegistrationTest(int itkNotUsed(argc), char * itkNotUsed(argv)[ // applying the resultant transform to moving points and verify result std::cout << "Fixed\tMoving\tMovingTransformed\tFixedTransformed\tDiff" << std::endl; - bool passed = true; - PointType::ValueType tolerance = 1e-2; - AffineTransformType::InverseTransformBasePointer affineInverseTransform = + bool passed = true; + const PointType::ValueType tolerance = 1e-2; + const AffineTransformType::InverseTransformBasePointer affineInverseTransform = affineSimple->GetModifiableTransform()->GetInverseTransform(); for (unsigned int n = 0; n < movingPoints->GetNumberOfPoints(); ++n) { // compare the points in virtual domain - PointType transformedMovingPoint = affineInverseTransform->TransformPoint(movingPoints->GetPoint(n)); - PointType fixedPoint = fixedPoints->GetPoint(n); - PointType transformedFixedPoint = affineSimple->GetModifiableTransform()->TransformPoint(fixedPoints->GetPoint(n)); + PointType transformedMovingPoint = affineInverseTransform->TransformPoint(movingPoints->GetPoint(n)); + PointType fixedPoint = fixedPoints->GetPoint(n); + const PointType transformedFixedPoint = + affineSimple->GetModifiableTransform()->TransformPoint(fixedPoints->GetPoint(n)); PointType difference; difference[0] = transformedMovingPoint[0] - fixedPoint[0]; difference[1] = transformedMovingPoint[1] - fixedPoint[1]; diff --git a/Modules/Registration/RegistrationMethodsv4/test/itkSyNImageRegistrationTest.cxx b/Modules/Registration/RegistrationMethodsv4/test/itkSyNImageRegistrationTest.cxx index c644d133eae..9d8751c1b2f 100644 --- a/Modules/Registration/RegistrationMethodsv4/test/itkSyNImageRegistrationTest.cxx +++ b/Modules/Registration/RegistrationMethodsv4/test/itkSyNImageRegistrationTest.cxx @@ -65,8 +65,8 @@ class CommandIterationUpdate : public itk::Command return; } - unsigned int currentLevel = filter->GetCurrentLevel(); - typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = + const unsigned int currentLevel = filter->GetCurrentLevel(); + const typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = filter->GetShrinkFactorsPerDimension(currentLevel); typename TFilter::SmoothingSigmasArrayType smoothingSigmas = filter->GetSmoothingSigmasPerLevel(); typename TFilter::TransformParametersAdaptorsContainerType adaptors = @@ -127,14 +127,14 @@ PerformDisplacementFieldImageRegistration(int argc, char * argv[]) auto fixedImageReader = ImageReaderType::New(); fixedImageReader->SetFileName(argv[2]); fixedImageReader->Update(); - typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); fixedImage->Update(); fixedImage->DisconnectPipeline(); auto movingImageReader = ImageReaderType::New(); movingImageReader->SetFileName(argv[3]); movingImageReader->Update(); - typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); + const typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); movingImage->Update(); movingImage->DisconnectPipeline(); @@ -190,7 +190,8 @@ PerformDisplacementFieldImageRegistration(int argc, char * argv[]) affineResampler->SetDefaultPixelValue(0); affineResampler->Update(); - std::string affineMovingImageFileName = std::string(argv[4]) + std::string("MovingImageAfterAffineTransform.nii.gz"); + const std::string affineMovingImageFileName = + std::string(argv[4]) + std::string("MovingImageAfterAffineTransform.nii.gz"); using AffineWriterType = itk::ImageFileWriter; auto affineWriter = AffineWriterType::New(); @@ -217,7 +218,7 @@ PerformDisplacementFieldImageRegistration(int argc, char * argv[]) inverseDisplacementField->FillBuffer(zeroVector); using DisplacementFieldRegistrationType = itk::SyNImageRegistrationMethod; - typename DisplacementFieldRegistrationType::Pointer displacementFieldRegistration = + const typename DisplacementFieldRegistrationType::Pointer displacementFieldRegistration = DisplacementFieldRegistrationType::New(); using OutputTransformType = typename DisplacementFieldRegistrationType::OutputTransformType; @@ -260,7 +261,7 @@ PerformDisplacementFieldImageRegistration(int argc, char * argv[]) // if the user wishes to add that option, they can use the class // GaussianSmoothingOnUpdateDisplacementFieldTransformAdaptor - unsigned int numberOfLevels = 3; + const unsigned int numberOfLevels = 3; typename DisplacementFieldRegistrationType::NumberOfIterationsArrayType numberOfIterationsPerLevel; numberOfIterationsPerLevel.SetSize(3); @@ -273,8 +274,8 @@ PerformDisplacementFieldImageRegistration(int argc, char * argv[]) numberOfIterationsPerLevel[1] = 1; numberOfIterationsPerLevel[2] = 1; #endif - RealType varianceForUpdateField = 1.75; - RealType varianceForTotalField = 0.5; + const RealType varianceForUpdateField = 1.75; + const RealType varianceForTotalField = 0.5; typename DisplacementFieldRegistrationType::ShrinkFactorsArrayType shrinkFactorsPerLevel; shrinkFactorsPerLevel.SetSize(3); @@ -300,7 +301,7 @@ PerformDisplacementFieldImageRegistration(int argc, char * argv[]) shrinkFilter->SetInput(displacementField); shrinkFilter->Update(); - typename DisplacementFieldTransformAdaptorType::Pointer fieldTransformAdaptor = + const typename DisplacementFieldTransformAdaptorType::Pointer fieldTransformAdaptor = DisplacementFieldTransformAdaptorType::New(); fieldTransformAdaptor->SetRequiredSpacing(shrinkFilter->GetOutput()->GetSpacing()); fieldTransformAdaptor->SetRequiredSize(shrinkFilter->GetOutput()->GetBufferedRegion().GetSize()); @@ -326,17 +327,17 @@ PerformDisplacementFieldImageRegistration(int argc, char * argv[]) displacementFieldRegistration->SetSmoothingSigmasPerLevel(smoothingSigmasPerLevel); displacementFieldRegistration->SetMetric(correlationMetric); - typename OutputTransformType::Pointer fixedToMiddleTransform; + const typename OutputTransformType::Pointer fixedToMiddleTransform; displacementFieldRegistration->SetFixedToMiddleTransform(fixedToMiddleTransform); - typename OutputTransformType::Pointer movingToMiddleTransform; + const typename OutputTransformType::Pointer movingToMiddleTransform; displacementFieldRegistration->SetMovingToMiddleTransform(movingToMiddleTransform); const typename DisplacementFieldRegistrationType::RealType epsilon = itk::NumericTraits::epsilon(); const typename DisplacementFieldRegistrationType::RealType learningRate = std::stod(argv[6]); displacementFieldRegistration->SetLearningRate(learningRate); - typename DisplacementFieldRegistrationType::RealType obtainedLearningRate = + const typename DisplacementFieldRegistrationType::RealType obtainedLearningRate = displacementFieldRegistration->GetLearningRate(); if (!itk::Math::FloatAlmostEqual(obtainedLearningRate, learningRate, 10, epsilon)) { @@ -355,7 +356,7 @@ PerformDisplacementFieldImageRegistration(int argc, char * argv[]) displacementFieldRegistration->SetTransformParametersAdaptorsPerLevel(adaptors); displacementFieldRegistration->SetGaussianSmoothingVarianceForTheUpdateField(varianceForUpdateField); - RealType obtainedVarianceForUpdateField = + const RealType obtainedVarianceForUpdateField = displacementFieldRegistration->GetGaussianSmoothingVarianceForTheUpdateField(); if (!itk::Math::FloatAlmostEqual(obtainedVarianceForUpdateField, varianceForUpdateField, 10, epsilon)) { @@ -369,7 +370,7 @@ PerformDisplacementFieldImageRegistration(int argc, char * argv[]) } displacementFieldRegistration->SetGaussianSmoothingVarianceForTheTotalField(varianceForTotalField); - RealType obtainedVarianceForTotalField = + const RealType obtainedVarianceForTotalField = displacementFieldRegistration->GetGaussianSmoothingVarianceForTheTotalField(); if (!itk::Math::FloatAlmostEqual(obtainedVarianceForTotalField, varianceForTotalField, 10, epsilon)) { @@ -384,7 +385,7 @@ PerformDisplacementFieldImageRegistration(int argc, char * argv[]) const typename DisplacementFieldRegistrationType::RealType convergenceThreshold = 1.0e-6; displacementFieldRegistration->SetConvergenceThreshold(convergenceThreshold); - typename DisplacementFieldRegistrationType::RealType obtainedConvergenceThreshold = + const typename DisplacementFieldRegistrationType::RealType obtainedConvergenceThreshold = displacementFieldRegistration->GetConvergenceThreshold(); if (!itk::Math::FloatAlmostEqual(obtainedConvergenceThreshold, convergenceThreshold, 10, epsilon)) { @@ -421,7 +422,7 @@ PerformDisplacementFieldImageRegistration(int argc, char * argv[]) resampler->SetDefaultPixelValue(0); resampler->Update(); - std::string warpedMovingImageFileName = std::string(argv[4]) + std::string("MovingImageAfterSyN.nii.gz"); + const std::string warpedMovingImageFileName = std::string(argv[4]) + std::string("MovingImageAfterSyN.nii.gz"); using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); @@ -430,7 +431,7 @@ PerformDisplacementFieldImageRegistration(int argc, char * argv[]) writer->Update(); using InverseResampleFilterType = itk::ResampleImageFilter; - typename InverseResampleFilterType::Pointer inverseResampler = ResampleFilterType::New(); + const typename InverseResampleFilterType::Pointer inverseResampler = ResampleFilterType::New(); inverseResampler->SetTransform(compositeTransform->GetInverseTransform()); inverseResampler->SetInput(fixedImage); inverseResampler->SetSize(movingImage->GetBufferedRegion().GetSize()); @@ -440,7 +441,8 @@ PerformDisplacementFieldImageRegistration(int argc, char * argv[]) inverseResampler->SetDefaultPixelValue(0); inverseResampler->Update(); - std::string inverseWarpedFixedImageFileName = std::string(argv[4]) + std::string("InverseWarpedFixedImage.nii.gz"); + const std::string inverseWarpedFixedImageFileName = + std::string(argv[4]) + std::string("InverseWarpedFixedImage.nii.gz"); using InverseWriterType = itk::ImageFileWriter; auto inverseWriter = InverseWriterType::New(); @@ -448,7 +450,7 @@ PerformDisplacementFieldImageRegistration(int argc, char * argv[]) inverseWriter->SetInput(inverseResampler->GetOutput()); inverseWriter->Update(); - std::string displacementFieldFileName = std::string(argv[4]) + std::string("DisplacementField.nii.gz"); + const std::string displacementFieldFileName = std::string(argv[4]) + std::string("DisplacementField.nii.gz"); using DisplacementFieldWriterType = itk::ImageFileWriter; auto displacementFieldWriter = DisplacementFieldWriterType::New(); @@ -479,7 +481,7 @@ itkSyNImageRegistrationTest(int argc, char * argv[]) using MovingImageType = itk::Image; using DisplacementFieldRegistrationType = itk::SyNImageRegistrationMethod; - typename DisplacementFieldRegistrationType::Pointer displacementFieldRegistration = + const typename DisplacementFieldRegistrationType::Pointer displacementFieldRegistration = DisplacementFieldRegistrationType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS( diff --git a/Modules/Registration/RegistrationMethodsv4/test/itkSyNPointSetRegistrationTest.cxx b/Modules/Registration/RegistrationMethodsv4/test/itkSyNPointSetRegistrationTest.cxx index 715f2f65f74..34596a8701d 100644 --- a/Modules/Registration/RegistrationMethodsv4/test/itkSyNPointSetRegistrationTest.cxx +++ b/Modules/Registration/RegistrationMethodsv4/test/itkSyNPointSetRegistrationTest.cxx @@ -55,8 +55,8 @@ itkSyNPointSetRegistrationTest(int itkNotUsed(argc), char * itkNotUsed(argv)[]) { auto label = static_cast(1.5 + count / 100); - PointType fixedPoint; - float radius = 100.0; + PointType fixedPoint; + const float radius = 100.0; fixedPoint[0] = radius * std::cos(theta); fixedPoint[1] = radius * std::sin(theta); if (PointSetType::PointDimension > 2) @@ -146,7 +146,7 @@ itkSyNPointSetRegistrationTest(int itkNotUsed(argc), char * itkNotUsed(argv)[]) // if the user wishes to add that option, they can use the class // GaussianSmoothingOnUpdateDisplacementFieldTransformAdaptor - unsigned int numberOfLevels = 3; + const unsigned int numberOfLevels = 3; DisplacementFieldRegistrationType::NumberOfIterationsArrayType numberOfIterationsPerLevel; numberOfIterationsPerLevel.SetSize(3); @@ -154,8 +154,8 @@ itkSyNPointSetRegistrationTest(int itkNotUsed(argc), char * itkNotUsed(argv)[]) numberOfIterationsPerLevel[1] = 1; numberOfIterationsPerLevel[2] = 50; - double varianceForUpdateField = 5; - double varianceForTotalField = 0.0; + const double varianceForUpdateField = 5; + const double varianceForTotalField = 0.0; displacementFieldRegistration->SetGaussianSmoothingVarianceForTheUpdateField(varianceForUpdateField); displacementFieldRegistration->SetGaussianSmoothingVarianceForTheTotalField(varianceForTotalField); @@ -203,7 +203,7 @@ itkSyNPointSetRegistrationTest(int itkNotUsed(argc), char * itkNotUsed(argv)[]) // applying the resultant transform to moving points and verify result std::cout << "Fixed\tMoving\tMovingTransformed\tFixedTransformed\tDiff" << std::endl; - PointType::ValueType tolerance = 0.1; + const PointType::ValueType tolerance = 0.1; float averageError = 0.0; for (unsigned int n = 0; n < movingPoints->GetNumberOfPoints(); ++n) @@ -212,8 +212,8 @@ itkSyNPointSetRegistrationTest(int itkNotUsed(argc), char * itkNotUsed(argv)[]) PointType transformedMovingPoint = displacementFieldRegistration->GetModifiableTransform()->GetInverseTransform()->TransformPoint( movingPoints->GetPoint(n)); - PointType fixedPoint = fixedPoints->GetPoint(n); - PointType transformedFixedPoint = + PointType fixedPoint = fixedPoints->GetPoint(n); + const PointType transformedFixedPoint = displacementFieldRegistration->GetModifiableTransform()->TransformPoint(fixedPoints->GetPoint(n)); PointType difference; difference[0] = transformedMovingPoint[0] - fixedPoint[0]; @@ -224,7 +224,7 @@ itkSyNPointSetRegistrationTest(int itkNotUsed(argc), char * itkNotUsed(argv)[]) averageError += ((difference.GetVectorFromOrigin()).GetSquaredNorm()); } - unsigned int numberOfPoints = movingPoints->GetNumberOfPoints(); + const unsigned int numberOfPoints = movingPoints->GetNumberOfPoints(); if (numberOfPoints > 0) { averageError /= static_cast(numberOfPoints); diff --git a/Modules/Registration/RegistrationMethodsv4/test/itkTimeVaryingBSplineVelocityFieldImageRegistrationTest.cxx b/Modules/Registration/RegistrationMethodsv4/test/itkTimeVaryingBSplineVelocityFieldImageRegistrationTest.cxx index 35f3f043061..c9e56847773 100644 --- a/Modules/Registration/RegistrationMethodsv4/test/itkTimeVaryingBSplineVelocityFieldImageRegistrationTest.cxx +++ b/Modules/Registration/RegistrationMethodsv4/test/itkTimeVaryingBSplineVelocityFieldImageRegistrationTest.cxx @@ -57,8 +57,8 @@ class CommandIterationUpdate : public itk::Command return; } - unsigned int currentLevel = filter->GetCurrentLevel(); - typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = + const unsigned int currentLevel = filter->GetCurrentLevel(); + const typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = filter->GetShrinkFactorsPerDimension(currentLevel); typename TFilter::SmoothingSigmasArrayType smoothingSigmas = filter->GetSmoothingSigmasPerLevel(); typename TFilter::TransformParametersAdaptorsContainerType adaptors = @@ -120,14 +120,14 @@ PerformTimeVaryingBSplineVelocityFieldImageRegistration(int argc, char * argv[]) auto fixedImageReader = ImageReaderType::New(); fixedImageReader->SetFileName(argv[2]); fixedImageReader->Update(); - typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); fixedImage->Update(); fixedImage->DisconnectPipeline(); auto movingImageReader = ImageReaderType::New(); movingImageReader->SetFileName(argv[3]); movingImageReader->Update(); - typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); + const typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); movingImage->Update(); movingImage->DisconnectPipeline(); @@ -182,7 +182,8 @@ PerformTimeVaryingBSplineVelocityFieldImageRegistration(int argc, char * argv[]) affineResampler->SetDefaultPixelValue(0); affineResampler->Update(); - std::string affineMovingImageFileName = std::string(argv[4]) + std::string("MovingImageAfterAffineTransform.nii.gz"); + const std::string affineMovingImageFileName = + std::string(argv[4]) + std::string("MovingImageAfterAffineTransform.nii.gz"); using AffineWriterType = itk::ImageFileWriter; auto affineWriter = AffineWriterType::New(); @@ -260,7 +261,7 @@ PerformTimeVaryingBSplineVelocityFieldImageRegistration(int argc, char * argv[]) using VectorType = itk::Vector; using TimeVaryingVelocityFieldControlPointLatticeType = itk::Image; - typename TimeVaryingVelocityFieldControlPointLatticeType::Pointer velocityFieldLattice = + const typename TimeVaryingVelocityFieldControlPointLatticeType::Pointer velocityFieldLattice = TimeVaryingVelocityFieldControlPointLatticeType::New(); // Determine the parameters (size, spacing, etc) for the time-varying velocity field @@ -298,7 +299,7 @@ PerformTimeVaryingBSplineVelocityFieldImageRegistration(int argc, char * argv[]) using VelocityFieldTransformAdaptorType = itk::TimeVaryingBSplineVelocityFieldTransformParametersAdaptor; - typename VelocityFieldTransformAdaptorType::Pointer initialFieldTransformAdaptor = + const typename VelocityFieldTransformAdaptorType::Pointer initialFieldTransformAdaptor = VelocityFieldTransformAdaptorType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(initialFieldTransformAdaptor, @@ -397,7 +398,7 @@ PerformTimeVaryingBSplineVelocityFieldImageRegistration(int argc, char * argv[]) } } - typename VelocityFieldTransformAdaptorType::Pointer fieldTransformAdaptor = + const typename VelocityFieldTransformAdaptorType::Pointer fieldTransformAdaptor = VelocityFieldTransformAdaptorType::New(); fieldTransformAdaptor->SetSplineOrder(outputTransform->GetSplineOrder()); fieldTransformAdaptor->SetRequiredTransformDomainSpacing(velocityFieldSpacing); @@ -411,7 +412,7 @@ PerformTimeVaryingBSplineVelocityFieldImageRegistration(int argc, char * argv[]) velocityFieldRegistration->SetTransformParametersAdaptorsPerLevel(adaptors); using VelocityFieldRegistrationCommandType = CommandIterationUpdate; - typename VelocityFieldRegistrationCommandType::Pointer displacementFieldObserver = + const typename VelocityFieldRegistrationCommandType::Pointer displacementFieldObserver = VelocityFieldRegistrationCommandType::New(); velocityFieldRegistration->AddObserver(itk::IterationEvent(), displacementFieldObserver); @@ -431,7 +432,7 @@ PerformTimeVaryingBSplineVelocityFieldImageRegistration(int argc, char * argv[]) resampler->SetDefaultPixelValue(0); resampler->Update(); - std::string warpedMovingImageFileName = + const std::string warpedMovingImageFileName = std::string(argv[4]) + std::string("MovingImageAfterVelocityFieldTransform.nii.gz"); using WriterType = itk::ImageFileWriter; @@ -441,7 +442,7 @@ PerformTimeVaryingBSplineVelocityFieldImageRegistration(int argc, char * argv[]) writer->Update(); using InverseResampleFilterType = itk::ResampleImageFilter; - typename InverseResampleFilterType::Pointer inverseResampler = ResampleFilterType::New(); + const typename InverseResampleFilterType::Pointer inverseResampler = ResampleFilterType::New(); inverseResampler->SetTransform(compositeTransform->GetInverseTransform()); inverseResampler->SetInput(fixedImage); inverseResampler->SetSize(movingImage->GetBufferedRegion().GetSize()); @@ -451,7 +452,8 @@ PerformTimeVaryingBSplineVelocityFieldImageRegistration(int argc, char * argv[]) inverseResampler->SetDefaultPixelValue(0); inverseResampler->Update(); - std::string inverseWarpedFixedImageFileName = std::string(argv[4]) + std::string("InverseWarpedFixedImage.nii.gz"); + const std::string inverseWarpedFixedImageFileName = + std::string(argv[4]) + std::string("InverseWarpedFixedImage.nii.gz"); using InverseWriterType = itk::ImageFileWriter; auto inverseWriter = InverseWriterType::New(); @@ -459,7 +461,7 @@ PerformTimeVaryingBSplineVelocityFieldImageRegistration(int argc, char * argv[]) inverseWriter->SetInput(inverseResampler->GetOutput()); inverseWriter->Update(); - std::string velocityFieldLatticeFileName = + const std::string velocityFieldLatticeFileName = std::string(argv[4]) + std::string("VelocityFieldControlPointLattice.nii.gz"); using VelocityFieldWriterType = itk::ImageFileWriter; diff --git a/Modules/Registration/RegistrationMethodsv4/test/itkTimeVaryingBSplineVelocityFieldPointSetRegistrationTest.cxx b/Modules/Registration/RegistrationMethodsv4/test/itkTimeVaryingBSplineVelocityFieldPointSetRegistrationTest.cxx index 87e51d1beb0..5c77946bad3 100644 --- a/Modules/Registration/RegistrationMethodsv4/test/itkTimeVaryingBSplineVelocityFieldPointSetRegistrationTest.cxx +++ b/Modules/Registration/RegistrationMethodsv4/test/itkTimeVaryingBSplineVelocityFieldPointSetRegistrationTest.cxx @@ -54,8 +54,8 @@ itkTimeVaryingBSplineVelocityFieldPointSetRegistrationTest(int itkNotUsed(argc), unsigned long count = 0; for (float theta = 0; theta < 2.0 * itk::Math::pi; theta += 0.1) { - PointType fixedPoint; - float radius = 100.0; + PointType fixedPoint; + const float radius = 100.0; fixedPoint[0] = radius * std::cos(theta); fixedPoint[1] = radius * std::sin(theta); if (PointSetType::PointDimension > 2) @@ -145,7 +145,7 @@ itkTimeVaryingBSplineVelocityFieldPointSetRegistrationTest(int itkNotUsed(argc), using VectorType = itk::Vector; using TimeVaryingVelocityFieldControlPointLatticeType = itk::Image; - TimeVaryingVelocityFieldControlPointLatticeType::Pointer velocityFieldLattice = + const TimeVaryingVelocityFieldControlPointLatticeType::Pointer velocityFieldLattice = TimeVaryingVelocityFieldControlPointLatticeType::New(); // Determine the parameters (size, spacing, etc) for the time-varying velocity field @@ -285,7 +285,7 @@ itkTimeVaryingBSplineVelocityFieldPointSetRegistrationTest(int itkNotUsed(argc), // applying the resultant transform to moving points and verify result std::cout << "Fixed\tMoving\tMovingTransformed\tFixedTransformed\tDiff" << std::endl; - PointType::ValueType tolerance = 0.55; + const PointType::ValueType tolerance = 0.55; float averageError = 0.0; for (unsigned int n = 0; n < movingPoints->GetNumberOfPoints(); ++n) @@ -294,8 +294,8 @@ itkTimeVaryingBSplineVelocityFieldPointSetRegistrationTest(int itkNotUsed(argc), PointType transformedMovingPoint = velocityFieldRegistration->GetModifiableTransform()->GetInverseTransform()->TransformPoint( movingPoints->GetPoint(n)); - PointType fixedPoint = fixedPoints->GetPoint(n); - PointType transformedFixedPoint = + PointType fixedPoint = fixedPoints->GetPoint(n); + const PointType transformedFixedPoint = velocityFieldRegistration->GetModifiableTransform()->TransformPoint(fixedPoints->GetPoint(n)); PointType difference; difference[0] = transformedMovingPoint[0] - fixedPoint[0]; @@ -306,7 +306,7 @@ itkTimeVaryingBSplineVelocityFieldPointSetRegistrationTest(int itkNotUsed(argc), averageError += ((difference.GetVectorFromOrigin()).GetSquaredNorm()); } - unsigned int numberOfPoints = movingPoints->GetNumberOfPoints(); + const unsigned int numberOfPoints = movingPoints->GetNumberOfPoints(); if (numberOfPoints > 0) { averageError /= static_cast(numberOfPoints); diff --git a/Modules/Registration/RegistrationMethodsv4/test/itkTimeVaryingVelocityFieldImageRegistrationTest.cxx b/Modules/Registration/RegistrationMethodsv4/test/itkTimeVaryingVelocityFieldImageRegistrationTest.cxx index 219999ea653..04b0a56d7d4 100644 --- a/Modules/Registration/RegistrationMethodsv4/test/itkTimeVaryingVelocityFieldImageRegistrationTest.cxx +++ b/Modules/Registration/RegistrationMethodsv4/test/itkTimeVaryingVelocityFieldImageRegistrationTest.cxx @@ -57,8 +57,8 @@ class CommandIterationUpdate : public itk::Command return; } - unsigned int currentLevel = filter->GetCurrentLevel(); - typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = + const unsigned int currentLevel = filter->GetCurrentLevel(); + const typename TFilter::ShrinkFactorsPerDimensionContainerType shrinkFactors = filter->GetShrinkFactorsPerDimension(currentLevel); typename TFilter::SmoothingSigmasArrayType smoothingSigmas = filter->GetSmoothingSigmasPerLevel(); typename TFilter::TransformParametersAdaptorsContainerType adaptors = @@ -115,14 +115,14 @@ PerformTimeVaryingVelocityFieldImageRegistration(int argc, char * argv[]) auto fixedImageReader = ImageReaderType::New(); fixedImageReader->SetFileName(argv[2]); fixedImageReader->Update(); - typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); + const typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput(); fixedImage->Update(); fixedImage->DisconnectPipeline(); auto movingImageReader = ImageReaderType::New(); movingImageReader->SetFileName(argv[3]); movingImageReader->Update(); - typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); + const typename MovingImageType::Pointer movingImage = movingImageReader->GetOutput(); movingImage->Update(); movingImage->DisconnectPipeline(); @@ -177,7 +177,8 @@ PerformTimeVaryingVelocityFieldImageRegistration(int argc, char * argv[]) affineResampler->SetDefaultPixelValue(0); affineResampler->Update(); - std::string affineMovingImageFileName = std::string(argv[4]) + std::string("MovingImageAfterAffineTransform.nii.gz"); + const std::string affineMovingImageFileName = + std::string(argv[4]) + std::string("MovingImageAfterAffineTransform.nii.gz"); using AffineWriterType = itk::ImageFileWriter; auto affineWriter = AffineWriterType::New(); @@ -295,11 +296,11 @@ PerformTimeVaryingVelocityFieldImageRegistration(int argc, char * argv[]) smoothingSigmasPerLevel[2] = 0; velocityFieldRegistration->SetSmoothingSigmasPerLevel(smoothingSigmasPerLevel); - typename VelocityFieldRegistrationType::RealType convergenceThreshold = 1.0e-7; + const typename VelocityFieldRegistrationType::RealType convergenceThreshold = 1.0e-7; velocityFieldRegistration->SetConvergenceThreshold(convergenceThreshold); ITK_TEST_SET_GET_VALUE(convergenceThreshold, velocityFieldRegistration->GetConvergenceThreshold()); - unsigned int convergenceWindowSize = 10; + const unsigned int convergenceWindowSize = 10; velocityFieldRegistration->SetConvergenceWindowSize(convergenceWindowSize); ITK_TEST_SET_GET_VALUE(convergenceWindowSize, velocityFieldRegistration->GetConvergenceWindowSize()); @@ -342,7 +343,7 @@ PerformTimeVaryingVelocityFieldImageRegistration(int argc, char * argv[]) } } - typename VelocityFieldTransformAdaptorType::Pointer fieldTransformAdaptor = + const typename VelocityFieldTransformAdaptorType::Pointer fieldTransformAdaptor = VelocityFieldTransformAdaptorType::New(); fieldTransformAdaptor->SetRequiredSpacing(velocityFieldSpacing); fieldTransformAdaptor->SetRequiredSize(velocityFieldSize); @@ -354,7 +355,7 @@ PerformTimeVaryingVelocityFieldImageRegistration(int argc, char * argv[]) velocityFieldRegistration->SetTransformParametersAdaptorsPerLevel(adaptors); using VelocityFieldRegistrationCommandType = CommandIterationUpdate; - typename VelocityFieldRegistrationCommandType::Pointer displacementFieldObserver = + const typename VelocityFieldRegistrationCommandType::Pointer displacementFieldObserver = VelocityFieldRegistrationCommandType::New(); velocityFieldRegistration->AddObserver(itk::IterationEvent(), displacementFieldObserver); @@ -374,7 +375,7 @@ PerformTimeVaryingVelocityFieldImageRegistration(int argc, char * argv[]) resampler->SetDefaultPixelValue(0); resampler->Update(); - std::string warpedMovingImageFileName = + const std::string warpedMovingImageFileName = std::string(argv[4]) + std::string("MovingImageAfterVelocityFieldTransform.nii.gz"); using WriterType = itk::ImageFileWriter; @@ -384,7 +385,7 @@ PerformTimeVaryingVelocityFieldImageRegistration(int argc, char * argv[]) writer->Update(); using InverseResampleFilterType = itk::ResampleImageFilter; - typename InverseResampleFilterType::Pointer inverseResampler = ResampleFilterType::New(); + const typename InverseResampleFilterType::Pointer inverseResampler = ResampleFilterType::New(); inverseResampler->SetTransform(compositeTransform->GetInverseTransform()); inverseResampler->SetInput(fixedImage); inverseResampler->SetSize(movingImage->GetBufferedRegion().GetSize()); @@ -394,7 +395,8 @@ PerformTimeVaryingVelocityFieldImageRegistration(int argc, char * argv[]) inverseResampler->SetDefaultPixelValue(0); inverseResampler->Update(); - std::string inverseWarpedFixedImageFileName = std::string(argv[4]) + std::string("InverseWarpedFixedImage.nii.gz"); + const std::string inverseWarpedFixedImageFileName = + std::string(argv[4]) + std::string("InverseWarpedFixedImage.nii.gz"); using InverseWriterType = itk::ImageFileWriter; auto inverseWriter = InverseWriterType::New(); @@ -402,7 +404,7 @@ PerformTimeVaryingVelocityFieldImageRegistration(int argc, char * argv[]) inverseWriter->SetInput(inverseResampler->GetOutput()); inverseWriter->Update(); - std::string velocityFieldFileName = std::string(argv[4]) + std::string("VelocityField.nii.gz"); + const std::string velocityFieldFileName = std::string(argv[4]) + std::string("VelocityField.nii.gz"); using VelocityFieldWriterType = itk::ImageFileWriter; auto velocityFieldWriter = VelocityFieldWriterType::New(); diff --git a/Modules/Segmentation/Classifiers/include/itkBayesianClassifierImageFilter.hxx b/Modules/Segmentation/Classifiers/include/itkBayesianClassifierImageFilter.hxx index 0da8b8fdf35..c7ffef098d2 100644 --- a/Modules/Segmentation/Classifiers/include/itkBayesianClassifierImageFilter.hxx +++ b/Modules/Segmentation/Classifiers/include/itkBayesianClassifierImageFilter.hxx @@ -43,7 +43,7 @@ BayesianClassifierImageFilterSetNumberOfRequiredOutputs(2); - PosteriorsImagePointer p = static_cast(this->MakeOutput(1).GetPointer()); + const PosteriorsImagePointer p = static_cast(this->MakeOutput(1).GetPointer()); this->SetNthOutput(1, p.GetPointer()); } @@ -139,7 +139,7 @@ BayesianClassifierImageFilterGetInput(); - ImageRegionType imageRegion = membershipImage->GetBufferedRegion(); + const ImageRegionType imageRegion = membershipImage->GetBufferedRegion(); if (m_UserProvidedPriors) { @@ -323,9 +323,9 @@ void BayesianClassifierImageFilter:: ClassifyBasedOnPosteriors() { - OutputImagePointer labels = this->GetOutput(); + const OutputImagePointer labels = this->GetOutput(); - ImageRegionType imageRegion = labels->GetBufferedRegion(); + const ImageRegionType imageRegion = labels->GetBufferedRegion(); PosteriorsImageType * posteriorsImage = this->GetPosteriorImage(); @@ -337,7 +337,7 @@ BayesianClassifierImageFilterGetOutput(); + const typename OutputImageType::Pointer outputPtr = this->GetOutput(); if (!outputPtr) { return; @@ -137,9 +137,9 @@ BayesianClassifierInitializationImageFilterGetInput(); - typename InputImageType::RegionType imageRegion = inputImage->GetLargestPossibleRegion(); - InputImageIteratorType itrInputImage(inputImage, imageRegion); + const InputImageType * inputImage = this->GetInput(); + const typename InputImageType::RegionType imageRegion = inputImage->GetLargestPossibleRegion(); + InputImageIteratorType itrInputImage(inputImage, imageRegion); itrInputImage.GoToBegin(); itrKMeansImage.GoToBegin(); @@ -223,8 +223,8 @@ BayesianClassifierInitializationImageFilterGetInput(); - typename InputImageType::RegionType imageRegion = inputImage->GetLargestPossibleRegion(); - InputImageIteratorType itrInputImage(inputImage, imageRegion); + const typename InputImageType::RegionType imageRegion = inputImage->GetLargestPossibleRegion(); + InputImageIteratorType itrInputImage(inputImage, imageRegion); if (!m_UserSuppliesMembershipFunctions) { diff --git a/Modules/Segmentation/Classifiers/include/itkImageClassifierBase.hxx b/Modules/Segmentation/Classifiers/include/itkImageClassifierBase.hxx index eab3512e0fe..2fa7f4a3086 100644 --- a/Modules/Segmentation/Classifiers/include/itkImageClassifierBase.hxx +++ b/Modules/Segmentation/Classifiers/include/itkImageClassifierBase.hxx @@ -54,8 +54,8 @@ ImageClassifierBase::Classify() } // Set the iterators and the pixel type definition for the input image - InputImageConstPointer inputImage = this->GetInputImage(); - InputImageConstIterator inIt(inputImage, inputImage->GetBufferedRegion()); + const InputImageConstPointer inputImage = this->GetInputImage(); + InputImageConstIterator inIt(inputImage, inputImage->GetBufferedRegion()); // Set the iterators and the pixel type definition for the classified image classifiedImage = this->GetClassifiedImage(); @@ -68,7 +68,7 @@ ImageClassifierBase::Classify() // Set up the storage containers to record the probability // measures for each class. - unsigned int numberOfClasses = this->GetNumberOfMembershipFunctions(); + const unsigned int numberOfClasses = this->GetNumberOfMembershipFunctions(); std::vector discriminantScores; discriminantScores.resize(numberOfClasses); @@ -76,8 +76,8 @@ ImageClassifierBase::Classify() unsigned int classIndex; // support progress methods/callbacks - SizeValueType totalPixels = inputImage->GetBufferedRegion().GetNumberOfPixels(); - SizeValueType updateVisits = totalPixels / 10; + const SizeValueType totalPixels = inputImage->GetBufferedRegion().GetNumberOfPixels(); + SizeValueType updateVisits = totalPixels / 10; if (updateVisits < 1) { updateVisits = 1; @@ -109,11 +109,11 @@ template void ImageClassifierBase::Allocate() { - InputImageConstPointer inputImage = this->GetInputImage(); + const InputImageConstPointer inputImage = this->GetInputImage(); - InputImageSizeType inputImageSize = inputImage->GetBufferedRegion().GetSize(); + const InputImageSizeType inputImageSize = inputImage->GetBufferedRegion().GetSize(); - ClassifiedImagePointer classifiedImage = TClassifiedImage::New(); + const ClassifiedImagePointer classifiedImage = TClassifiedImage::New(); this->SetClassifiedImage(classifiedImage); @@ -128,7 +128,7 @@ template std::vector ImageClassifierBase::GetPixelMembershipValue(const InputImagePixelType inputImagePixel) { - unsigned int numberOfClasses = this->GetNumberOfClasses(); + const unsigned int numberOfClasses = this->GetNumberOfClasses(); std::vector pixelMembershipValue(numberOfClasses); for (unsigned int classIndex = 0; classIndex < numberOfClasses; ++classIndex) diff --git a/Modules/Segmentation/Classifiers/include/itkImageGaussianModelEstimator.hxx b/Modules/Segmentation/Classifiers/include/itkImageGaussianModelEstimator.hxx index 518b223fde9..eeda25ce1ae 100644 --- a/Modules/Segmentation/Classifiers/include/itkImageGaussianModelEstimator.hxx +++ b/Modules/Segmentation/Classifiers/include/itkImageGaussianModelEstimator.hxx @@ -60,7 +60,7 @@ void ImageGaussianModelEstimator::EstimateModels() { // Do some error checking - InputImageConstPointer inputImage = this->GetInputImage(); + const InputImageConstPointer inputImage = this->GetInputImage(); // Check if the training and input image dimensions are the same if (static_cast(TInputImage::ImageDimension) != static_cast(TTrainingImage::ImageDimension)) @@ -70,7 +70,7 @@ ImageGaussianModelEstimator::E InputImageSizeType inputImageSize = inputImage->GetBufferedRegion().GetSize(); - TrainingImageConstPointer trainingImage = this->GetTrainingImage(); + const TrainingImageConstPointer trainingImage = this->GetTrainingImage(); using TrainingImageSizeType = InputImageSizeType; TrainingImageSizeType trainingImageSize = trainingImage->GetBufferedRegion().GetSize(); @@ -86,7 +86,7 @@ ImageGaussianModelEstimator::E } // Set up the gaussian membership calculators - unsigned int numberOfModels = this->GetNumberOfModels(); + const unsigned int numberOfModels = this->GetNumberOfModels(); // Call local function to estimate mean variances of the various // class labels in the training set. @@ -123,15 +123,15 @@ void ImageGaussianModelEstimator::EstimateGaussianModelParameters() { // Set the iterators and the pixel type definition for the input image - InputImageConstPointer inputImage = this->GetInputImage(); - InputImageConstIterator inIt(inputImage, inputImage->GetBufferedRegion()); + const InputImageConstPointer inputImage = this->GetInputImage(); + InputImageConstIterator inIt(inputImage, inputImage->GetBufferedRegion()); // Set the iterators and the pixel type definition for the training image - TrainingImageConstPointer trainingImage = this->GetTrainingImage(); + const TrainingImageConstPointer trainingImage = this->GetTrainingImage(); TrainingImageConstIterator trainingImageIt(trainingImage, trainingImage->GetBufferedRegion()); - unsigned int numberOfModels = (this->GetNumberOfModels()); + const unsigned int numberOfModels = (this->GetNumberOfModels()); // Set up the matrices to hold the means and the covariance for the // training data diff --git a/Modules/Segmentation/Classifiers/include/itkImageKmeansModelEstimator.hxx b/Modules/Segmentation/Classifiers/include/itkImageKmeansModelEstimator.hxx index 88c060f0c19..8875ed892bb 100644 --- a/Modules/Segmentation/Classifiers/include/itkImageKmeansModelEstimator.hxx +++ b/Modules/Segmentation/Classifiers/include/itkImageKmeansModelEstimator.hxx @@ -146,13 +146,13 @@ ImageKmeansModelEstimator::Allocate() // Set the initial and final codebook size - SizeValueType initCodebookSize = (SizeValueType)1; + const SizeValueType initCodebookSize = (SizeValueType)1; m_Codebook.set_size(initCodebookSize, m_VectorDimension); // Initialize m_Codebook to 0 (it now has only one row) m_Codebook.fill(0); } - SizeValueType finalCodebookSize = (SizeValueType)m_NumberOfCodewords; + const SizeValueType finalCodebookSize = (SizeValueType)m_NumberOfCodewords; // Allocate scratch memory for the centroid, codebook histogram // and the codebook distortion @@ -217,7 +217,7 @@ ImageKmeansModelEstimator::EstimateModels() this->EstimateKmeansModelParameters(); // Set up the membership calculators - unsigned int numberOfModels = this->GetNumberOfModels(); + const unsigned int numberOfModels = this->GetNumberOfModels(); // Call local function to estimate mean variances of the various // class labels in the training set @@ -410,8 +410,8 @@ ImageKmeansModelEstimator::NearestNeighborSear *distortion = 0.0; // Declare the iterators for the image and the codebook - InputImageConstPointer inputImage = this->GetInputImage(); - InputImageConstIterator inputImageIt(inputImage, inputImage->GetBufferedRegion()); + const InputImageConstPointer inputImage = this->GetInputImage(); + InputImageConstIterator inputImageIt(inputImage, inputImage->GetBufferedRegion()); inputImageIt.GoToBegin(); // Calculate the number of vectors in the input data set @@ -442,7 +442,7 @@ ImageKmeansModelEstimator::NearestNeighborSear for (unsigned int j = 0; j < m_VectorDimension; ++j) { - double diff = static_cast(inputImagePixelVector[j] - m_Codebook[i][j]); + const double diff = static_cast(inputImagePixelVector[j] - m_Codebook[i][j]); tempdistortion += diff * diff; if (tempdistortion > bestdistortion) diff --git a/Modules/Segmentation/Classifiers/include/itkScalarImageKmeansImageFilter.hxx b/Modules/Segmentation/Classifiers/include/itkScalarImageKmeansImageFilter.hxx index 1f2fa545252..ca068e22357 100644 --- a/Modules/Segmentation/Classifiers/include/itkScalarImageKmeansImageFilter.hxx +++ b/Modules/Segmentation/Classifiers/include/itkScalarImageKmeansImageFilter.hxx @@ -127,8 +127,8 @@ ScalarImageKmeansImageFilter::GenerateData() { classLabels[k] = label; label += labelInterval; - MembershipFunctionPointer membershipFunction = MembershipFunctionType::New(); - MembershipFunctionOriginType origin(adaptor->GetMeasurementVectorSize()); + const MembershipFunctionPointer membershipFunction = MembershipFunctionType::New(); + MembershipFunctionOriginType origin(adaptor->GetMeasurementVectorSize()); origin[0] = this->m_FinalMeans[k]; // A scalar image has a MeasurementVector // of dimension 1 membershipFunction->SetCentroid(origin); @@ -136,7 +136,7 @@ ScalarImageKmeansImageFilter::GenerateData() membershipFunctions.push_back(constMembershipFunction); } - typename ClassifierType::MembershipFunctionVectorObjectPointer membershipFunctionsObject = + const typename ClassifierType::MembershipFunctionVectorObjectPointer membershipFunctionsObject = ClassifierType::MembershipFunctionVectorObjectType::New(); membershipFunctionsObject->Set(membershipFunctions); classifier->SetMembershipFunctions(membershipFunctionsObject); @@ -150,7 +150,7 @@ ScalarImageKmeansImageFilter::GenerateData() classifier->Update(); // Now classify the pixels - typename OutputImageType::Pointer outputPtr = this->GetOutput(); + const typename OutputImageType::Pointer outputPtr = this->GetOutput(); using ImageIterator = ImageRegionIterator; @@ -174,8 +174,8 @@ ScalarImageKmeansImageFilter::GenerateData() using LabelIterator = typename ClassifierOutputType::ConstIterator; - LabelIterator iter = membershipSample->Begin(); - LabelIterator end = membershipSample->End(); + LabelIterator iter = membershipSample->Begin(); + const LabelIterator end = membershipSample->End(); while (iter != end) { @@ -194,7 +194,7 @@ ScalarImageKmeansImageFilter::GenerateData() exIt.GoToBegin(); if (m_UseNonContiguousLabels) { - OutputPixelType outsideLabel = labelInterval * numberOfClasses; + const OutputPixelType outsideLabel = labelInterval * numberOfClasses; while (!exIt.IsAtEnd()) { exIt.Set(outsideLabel); diff --git a/Modules/Segmentation/Classifiers/test/itkBayesianClassifierImageFilterTest.cxx b/Modules/Segmentation/Classifiers/test/itkBayesianClassifierImageFilterTest.cxx index 8ff0154fb57..9daf4cb5ff3 100644 --- a/Modules/Segmentation/Classifiers/test/itkBayesianClassifierImageFilterTest.cxx +++ b/Modules/Segmentation/Classifiers/test/itkBayesianClassifierImageFilterTest.cxx @@ -197,12 +197,12 @@ itkBayesianClassifierImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); - ReaderType::OutputImageType::Pointer inputImage = reader->GetOutput(); + const ReaderType::OutputImageType::Pointer inputImage = reader->GetOutput(); - char * outputFilename = argv[2]; - unsigned int numberOfClasses = std::stoi(argv[3]); - unsigned int numberOfSmoothingIterations = std::stoi(argv[4]); - bool testPriors = std::stoi(argv[5]); + char * outputFilename = argv[2]; + const unsigned int numberOfClasses = std::stoi(argv[3]); + const unsigned int numberOfSmoothingIterations = std::stoi(argv[4]); + const bool testPriors = std::stoi(argv[5]); using LabelType = unsigned char; diff --git a/Modules/Segmentation/Classifiers/test/itkImageClassifierFilterTest.cxx b/Modules/Segmentation/Classifiers/test/itkImageClassifierFilterTest.cxx index 04ca576ed9e..35a861b4ad0 100644 --- a/Modules/Segmentation/Classifiers/test/itkImageClassifierFilterTest.cxx +++ b/Modules/Segmentation/Classifiers/test/itkImageClassifierFilterTest.cxx @@ -63,17 +63,17 @@ itkImageClassifierFilterTest(int argc, char * argv[]) start.Fill(0); size.Fill(512); - InputImageType::RegionType region(start, size); + const InputImageType::RegionType region(start, size); image->SetRegions(region); image->Allocate(); // Fill the first half of the input image with pixel intensities // gnerated from a normal distribution defined by the following parameters - double mean = 10.5; - double standardDeviation = 5.0; + const double mean = 10.5; + const double standardDeviation = 5.0; InputImageType::IndexType index; - unsigned int halfSize = size[1] / 2; + const unsigned int halfSize = size[1] / 2; for (unsigned int y = 0; y < halfSize; ++y) { @@ -89,8 +89,8 @@ itkImageClassifierFilterTest(int argc, char * argv[]) } // Pixel intensities generated from the second normal distribution - double mean2 = 200.5; - double standardDeviation2 = 20.0; + const double mean2 = 200.5; + const double standardDeviation2 = 20.0; for (unsigned int y = halfSize; y < size[1]; ++y) { @@ -141,7 +141,7 @@ itkImageClassifierFilterTest(int argc, char * argv[]) auto estimator = EstimatorType::New(); estimator->SetSample(sample); - int maximumIteration = 200; + const int maximumIteration = 200; estimator->SetMaximumIteration(maximumIteration); itk::Array initialProportions(numberOfClasses); @@ -181,10 +181,10 @@ itkImageClassifierFilterTest(int argc, char * argv[]) using ClassLabelType = ImageClassifierFilterType::ClassLabelType; - ClassLabelType class1 = 0; + const ClassLabelType class1 = 0; classLabelVector.push_back(class1); - ClassLabelType class2 = 255; + const ClassLabelType class2 = 255; classLabelVector.push_back(class2); // Set a decision rule type @@ -211,8 +211,8 @@ itkImageClassifierFilterTest(int argc, char * argv[]) std::cout << "Estimator membership function output " << std::endl; while (functionIter != end) { - ImageClassifierFilterType::MembershipFunctionPointer membershipFunction = *functionIter; - const auto * gaussianMemberShpFunction = + const ImageClassifierFilterType::MembershipFunctionPointer membershipFunction = *functionIter; + const auto * gaussianMemberShpFunction = dynamic_cast(membershipFunction.GetPointer()); std::cout << "\tMembership function:\t " << counter << std::endl; std::cout << "\t\tMean=" << gaussianMemberShpFunction->GetMean() << std::endl; diff --git a/Modules/Segmentation/Classifiers/test/itkKmeansModelEstimatorTest.cxx b/Modules/Segmentation/Classifiers/test/itkKmeansModelEstimatorTest.cxx index de746b63f96..ffd3910573a 100644 --- a/Modules/Segmentation/Classifiers/test/itkKmeansModelEstimatorTest.cxx +++ b/Modules/Segmentation/Classifiers/test/itkKmeansModelEstimatorTest.cxx @@ -64,10 +64,10 @@ itkKmeansModelEstimatorTest(int, char *[]) auto vecImage = VecImageType::New(); - VecImageType::SizeType vecImgSize = { { IMGWIDTH, IMGHEIGHT, NFRAMES } }; + const VecImageType::SizeType vecImgSize = { { IMGWIDTH, IMGHEIGHT, NFRAMES } }; - VecImageType::IndexType index{}; - VecImageType::RegionType region; + const VecImageType::IndexType index{}; + VecImageType::RegionType region; region.SetSize(vecImgSize); region.SetIndex(index); @@ -278,7 +278,7 @@ itkKmeansModelEstimatorTest(int, char *[]) } // Validation with no codebook/initial Kmeans estimate - vnl_matrix kmeansResult = applyKmeansEstimator->GetKmeansResults(); + const vnl_matrix kmeansResult = applyKmeansEstimator->GetKmeansResults(); std::cout << "KMeansResults\n" << kmeansResult << std::endl; applyKmeansEstimator->SetCodebook(inCDBK); @@ -304,7 +304,7 @@ itkKmeansModelEstimatorTest(int, char *[]) double mindist = 99999999; for (unsigned int idx = 0; idx < membershipFunctions.size(); ++idx) { - double classdist = membershipFunctions[idx]->Evaluate(outIt.Get()); + const double classdist = membershipFunctions[idx]->Evaluate(outIt.Get()); std::cout << "Distance of first pixel to class " << idx << " is: " << classdist << std::endl; if (mindist > classdist) { diff --git a/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest1.cxx b/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest1.cxx index 9e12f6f8a18..a091305e144 100644 --- a/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest1.cxx +++ b/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest1.cxx @@ -132,21 +132,21 @@ itkSampleClassifierFilterTest1(int, char *[]) // Add three membership functions and rerun the filter MembershipFunctionVectorType & membershipFunctionsVector = membershipFunctionsObject->Get(); - MembershipFunctionPointer membershipFunction1 = MembershipFunctionType::New(); + const MembershipFunctionPointer membershipFunction1 = MembershipFunctionType::New(); membershipFunction1->SetMeasurementVectorSize(numberOfComponents); MembershipFunctionType::CentroidType centroid1; itk::NumericTraits::SetLength(centroid1, numberOfComponents); membershipFunction1->SetCentroid(centroid1); membershipFunctionsVector.push_back(membershipFunction1); - MembershipFunctionPointer membershipFunction2 = MembershipFunctionType::New(); + const MembershipFunctionPointer membershipFunction2 = MembershipFunctionType::New(); membershipFunction1->SetMeasurementVectorSize(numberOfComponents); MembershipFunctionType::CentroidType centroid2; itk::NumericTraits::SetLength(centroid2, numberOfComponents); membershipFunction2->SetCentroid(centroid2); membershipFunctionsVector.push_back(membershipFunction2); - MembershipFunctionPointer membershipFunction3 = MembershipFunctionType::New(); + const MembershipFunctionPointer membershipFunction3 = MembershipFunctionType::New(); membershipFunction3->SetMeasurementVectorSize(numberOfComponents); MembershipFunctionType::CentroidType centroid3; itk::NumericTraits::SetLength(centroid3, numberOfComponents); @@ -172,13 +172,13 @@ itkSampleClassifierFilterTest1(int, char *[]) using ClassLabelType = FilterType::ClassLabelType; - ClassLabelType class1 = 0; + const ClassLabelType class1 = 0; classLabelVector.push_back(class1); - ClassLabelType class2 = 1; + const ClassLabelType class2 = 1; classLabelVector.push_back(class2); - ClassLabelType class3 = 2; + const ClassLabelType class3 = 2; classLabelVector.push_back(class3); diff --git a/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest2.cxx b/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest2.cxx index 8208a86ba10..d428290f8f3 100644 --- a/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest2.cxx +++ b/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest2.cxx @@ -69,7 +69,7 @@ itkSampleClassifierFilterTest2(int, char *[]) // Add three membership functions and rerun the filter MembershipFunctionVectorType & membershipFunctionsVector = membershipFunctionsObject->Get(); - MembershipFunctionPointer membershipFunction1 = MembershipFunctionType::New(); + const MembershipFunctionPointer membershipFunction1 = MembershipFunctionType::New(); membershipFunction1->SetMeasurementVectorSize(numberOfComponents); MeanVectorType mean1; itk::NumericTraits::SetLength(mean1, numberOfComponents); @@ -83,7 +83,7 @@ itkSampleClassifierFilterTest2(int, char *[]) membershipFunction1->SetCovariance(covariance1); membershipFunctionsVector.push_back(membershipFunction1); - MembershipFunctionPointer membershipFunction2 = MembershipFunctionType::New(); + const MembershipFunctionPointer membershipFunction2 = MembershipFunctionType::New(); membershipFunction1->SetMeasurementVectorSize(numberOfComponents); MeanVectorType mean2; @@ -103,10 +103,10 @@ itkSampleClassifierFilterTest2(int, char *[]) using ClassLabelType = FilterType::ClassLabelType; - ClassLabelType class1 = 0; + const ClassLabelType class1 = 0; classLabelVector.push_back(class1); - ClassLabelType class2 = 1; + const ClassLabelType class2 = 1; classLabelVector.push_back(class2); // Set a decision rule type @@ -127,9 +127,9 @@ itkSampleClassifierFilterTest2(int, char *[]) MeasurementVectorType mv; itk::NumericTraits::SetLength(mv, numberOfComponents); - double mean = mean1[0]; - double standardDeviation = std::sqrt(covariance1[0][0]); - unsigned int numberOfSampleEachClass = 10; + double mean = mean1[0]; + double standardDeviation = std::sqrt(covariance1[0][0]); + const unsigned int numberOfSampleEachClass = 10; for (unsigned int i = 0; i < numberOfSampleEachClass; ++i) { mv[0] = (normalGenerator->GetVariate() * standardDeviation) + mean; diff --git a/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest3.cxx b/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest3.cxx index f1dc3840481..e5bf00f923a 100644 --- a/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest3.cxx +++ b/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest3.cxx @@ -65,9 +65,9 @@ itkSampleClassifierFilterTest3(int, char *[]) MeasurementVectorType mv; itk::NumericTraits::SetLength(mv, numberOfComponents); - double mean = mean1[0]; - double standardDeviation = 0.1; - unsigned int numberOfSampleEachClass = 10; + double mean = mean1[0]; + double standardDeviation = 0.1; + const unsigned int numberOfSampleEachClass = 10; // Add sample from the first gaussian for (unsigned int i = 0; i < numberOfSampleEachClass; ++i) @@ -94,7 +94,7 @@ itkSampleClassifierFilterTest3(int, char *[]) /* Creating k-d tree */ auto generator = GeneratorType::New(); generator->SetSample(sample); - unsigned int bucketSize = 1; + const unsigned int bucketSize = 1; generator->SetBucketSize(bucketSize); generator->GenerateData(); @@ -105,7 +105,7 @@ itkSampleClassifierFilterTest3(int, char *[]) initialMeans[0] = 5; initialMeans[1] = 70; estimator->SetParameters(initialMeans); - unsigned int maximumIteration = 100; + const unsigned int maximumIteration = 100; estimator->SetMaximumIteration(maximumIteration); estimator->SetKdTree(generator->GetOutput()); estimator->SetCentroidPositionChangesThreshold(0.0); @@ -117,10 +117,10 @@ itkSampleClassifierFilterTest3(int, char *[]) using ClassLabelType = FilterType::ClassLabelType; - ClassLabelType class1 = 0; + const ClassLabelType class1 = 0; classLabelVector.push_back(class1); - ClassLabelType class2 = 1; + const ClassLabelType class2 = 1; classLabelVector.push_back(class2); // Set a decision rule type @@ -146,8 +146,8 @@ itkSampleClassifierFilterTest3(int, char *[]) unsigned int counter = 1; while (functionIter != end) { - FilterType::MembershipFunctionPointer membershipFunction = *functionIter; - const auto * distanceMemberShpFunction = + const FilterType::MembershipFunctionPointer membershipFunction = *functionIter; + const auto * distanceMemberShpFunction = dynamic_cast(membershipFunction.GetPointer()); std::cout << "Centroid of the " << counter << " membership function " << distanceMemberShpFunction->GetCentroid() << std::endl; @@ -156,13 +156,13 @@ itkSampleClassifierFilterTest3(int, char *[]) } // Set membership functions weight array - FilterType::MembershipFunctionsWeightsArrayPointer weightArrayObjects = + const FilterType::MembershipFunctionsWeightsArrayPointer weightArrayObjects = FilterType::MembershipFunctionsWeightsArrayObjectType::New(); FilterType::MembershipFunctionsWeightsArrayType weightsArray; // set array size different from the number of classes - unsigned int numberOfClasses2 = 3; + const unsigned int numberOfClasses2 = 3; weightsArray.SetSize(numberOfClasses2); weightArrayObjects->Set(weightsArray); diff --git a/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest4.cxx b/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest4.cxx index 2b456d58da6..12f103dfaf1 100644 --- a/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest4.cxx +++ b/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest4.cxx @@ -64,7 +64,7 @@ itkSampleClassifierFilterTest4(int, char *[]) MeasurementVectorType mv; double mean = mean1[0]; double standardDeviation = 0.1; - unsigned int numberOfSampleEachClass = 10; + const unsigned int numberOfSampleEachClass = 10; // Add sample from the first gaussian for (unsigned int i = 0; i < numberOfSampleEachClass; ++i) @@ -91,7 +91,7 @@ itkSampleClassifierFilterTest4(int, char *[]) /* Creating k-d tree */ auto generator = GeneratorType::New(); generator->SetSample(sample); - unsigned int bucketSize = 1; + const unsigned int bucketSize = 1; generator->SetBucketSize(bucketSize); generator->GenerateData(); @@ -102,7 +102,7 @@ itkSampleClassifierFilterTest4(int, char *[]) initialMeans[0] = 5; initialMeans[1] = 70; estimator->SetParameters(initialMeans); - unsigned int maximumIteration = 100; + const unsigned int maximumIteration = 100; estimator->SetMaximumIteration(maximumIteration); estimator->SetKdTree(generator->GetOutput()); estimator->SetCentroidPositionChangesThreshold(0.0); @@ -114,10 +114,10 @@ itkSampleClassifierFilterTest4(int, char *[]) using ClassLabelType = FilterType::ClassLabelType; - ClassLabelType class1 = 0; + const ClassLabelType class1 = 0; classLabelVector.push_back(class1); - ClassLabelType class2 = 1; + const ClassLabelType class2 = 1; classLabelVector.push_back(class2); // Set a decision rule type @@ -143,8 +143,8 @@ itkSampleClassifierFilterTest4(int, char *[]) unsigned int counter = 1; while (functionIter != end) { - FilterType::MembershipFunctionPointer membershipFunction = *functionIter; - const auto * distanceMemberShpFunction = + const FilterType::MembershipFunctionPointer membershipFunction = *functionIter; + const auto * distanceMemberShpFunction = dynamic_cast(membershipFunction.GetPointer()); std::cout << "Centroid of the " << counter << " membership function " << distanceMemberShpFunction->GetCentroid() << std::endl; diff --git a/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest5.cxx b/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest5.cxx index 0186d53af32..5b0f16fdc3c 100644 --- a/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest5.cxx +++ b/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest5.cxx @@ -65,9 +65,9 @@ itkSampleClassifierFilterTest5(int, char *[]) MeasurementVectorType mv; itk::NumericTraits::SetLength(mv, numberOfComponents); - double mean = mean1[0]; - double standardDeviation = 0.1; - unsigned int numberOfSampleEachClass = 10; + double mean = mean1[0]; + double standardDeviation = 0.1; + const unsigned int numberOfSampleEachClass = 10; // Add sample from the first gaussian for (unsigned int i = 0; i < numberOfSampleEachClass; ++i) @@ -94,7 +94,7 @@ itkSampleClassifierFilterTest5(int, char *[]) /* Creating k-d tree */ auto generator = GeneratorType::New(); generator->SetSample(sample); - unsigned int bucketSize = 1; + const unsigned int bucketSize = 1; generator->SetBucketSize(bucketSize); generator->GenerateData(); @@ -105,7 +105,7 @@ itkSampleClassifierFilterTest5(int, char *[]) initialMeans[0] = 5; initialMeans[1] = 70; estimator->SetParameters(initialMeans); - unsigned int maximumIteration = 100; + const unsigned int maximumIteration = 100; estimator->SetMaximumIteration(maximumIteration); estimator->SetKdTree(generator->GetOutput()); estimator->SetCentroidPositionChangesThreshold(0.0); @@ -117,10 +117,10 @@ itkSampleClassifierFilterTest5(int, char *[]) using ClassLabelType = FilterType::ClassLabelType; - ClassLabelType class1 = 0; + const ClassLabelType class1 = 0; classLabelVector.push_back(class1); - ClassLabelType class2 = 1; + const ClassLabelType class2 = 1; classLabelVector.push_back(class2); // Set a decision rule type @@ -146,8 +146,8 @@ itkSampleClassifierFilterTest5(int, char *[]) unsigned int counter = 1; while (functionIter != end) { - FilterType::MembershipFunctionPointer membershipFunction = *functionIter; - const auto * distanceMemberShpFunction = + const FilterType::MembershipFunctionPointer membershipFunction = *functionIter; + const auto * distanceMemberShpFunction = dynamic_cast(membershipFunction.GetPointer()); std::cout << "Centroid of the " << counter << " membership function " << distanceMemberShpFunction->GetCentroid() << std::endl; diff --git a/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest6.cxx b/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest6.cxx index b56a1a800a1..d97034880ed 100644 --- a/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest6.cxx +++ b/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest6.cxx @@ -64,9 +64,9 @@ itkSampleClassifierFilterTest6(int, char *[]) MeasurementVectorType mv; itk::NumericTraits::SetLength(mv, numberOfComponents); - double mean = mean1[0]; - double standardDeviation = 0.1; - unsigned int numberOfSampleEachClass = 10; + double mean = mean1[0]; + double standardDeviation = 0.1; + const unsigned int numberOfSampleEachClass = 10; // Add sample from the first gaussian for (unsigned int i = 0; i < numberOfSampleEachClass; ++i) @@ -93,7 +93,7 @@ itkSampleClassifierFilterTest6(int, char *[]) /* Creating k-d tree */ auto generator = GeneratorType::New(); generator->SetSample(sample); - unsigned int bucketSize = 1; + const unsigned int bucketSize = 1; generator->SetBucketSize(bucketSize); generator->GenerateData(); @@ -104,7 +104,7 @@ itkSampleClassifierFilterTest6(int, char *[]) initialMeans[0] = 5; initialMeans[1] = 70; estimator->SetParameters(initialMeans); - unsigned int maximumIteration = 100; + const unsigned int maximumIteration = 100; estimator->SetMaximumIteration(maximumIteration); estimator->SetKdTree(generator->GetOutput()); estimator->SetCentroidPositionChangesThreshold(0.0); @@ -116,10 +116,10 @@ itkSampleClassifierFilterTest6(int, char *[]) using ClassLabelType = FilterType::ClassLabelType; - ClassLabelType class1 = 0; + const ClassLabelType class1 = 0; classLabelVector.push_back(class1); - ClassLabelType class2 = 1; + const ClassLabelType class2 = 1; classLabelVector.push_back(class2); // Set a decision rule type @@ -145,8 +145,8 @@ itkSampleClassifierFilterTest6(int, char *[]) unsigned int counter = 1; while (functionIter != end) { - FilterType::MembershipFunctionPointer membershipFunction = *functionIter; - const auto * distanceMemberShpFunction = + const FilterType::MembershipFunctionPointer membershipFunction = *functionIter; + const auto * distanceMemberShpFunction = dynamic_cast(membershipFunction.GetPointer()); std::cout << "Centroid of the " << counter << " membership function " << distanceMemberShpFunction->GetCentroid() << std::endl; diff --git a/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest7.cxx b/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest7.cxx index 9e8f6f7a243..7b81f135d09 100644 --- a/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest7.cxx +++ b/Modules/Segmentation/Classifiers/test/itkSampleClassifierFilterTest7.cxx @@ -92,9 +92,9 @@ itkSampleClassifierFilterTest7(int argc, char * argv[]) initialProportions[1] = 0.5; /* Loading point data */ - auto pointSet = PointSetType::New(); - PointSetType::PointsContainerPointer pointsContainer = PointSetType::PointsContainer::New(); - constexpr int dataSizeBig = 2000; + auto pointSet = PointSetType::New(); + const PointSetType::PointsContainerPointer pointsContainer = PointSetType::PointsContainer::New(); + constexpr int dataSizeBig = 2000; pointsContainer->Reserve(dataSizeBig); pointSet->SetPoints(pointsContainer); @@ -165,7 +165,7 @@ itkSampleClassifierFilterTest7(int argc, char * argv[]) const unsigned int measurementVectorSize = sample->GetMeasurementVectorSize(); for (unsigned int j = 0; j < measurementVectorSize; ++j) { - double temp = (components[i])->GetFullParameters()[j] - trueParameters[i][j]; + const double temp = (components[i])->GetFullParameters()[j] - trueParameters[i][j]; displacement += (temp * temp); } displacement = std::sqrt(displacement); @@ -191,10 +191,10 @@ itkSampleClassifierFilterTest7(int argc, char * argv[]) using ClassLabelType = FilterType::ClassLabelType; - ClassLabelType class1 = 0; + const ClassLabelType class1 = 0; classLabelVector.push_back(class1); - ClassLabelType class2 = 1; + const ClassLabelType class2 = 1; classLabelVector.push_back(class2); // Set a decision rule type @@ -220,8 +220,8 @@ itkSampleClassifierFilterTest7(int argc, char * argv[]) std::cout << "Estimator membership function output " << std::endl; while (functionIter != end) { - FilterType::MembershipFunctionPointer membershipFunction = *functionIter; - const auto * gaussianMemberShpFunction = + const FilterType::MembershipFunctionPointer membershipFunction = *functionIter; + const auto * gaussianMemberShpFunction = dynamic_cast(membershipFunction.GetPointer()); std::cout << "\tMembership function:\t " << counter << std::endl; std::cout << "\t\tMean=" << gaussianMemberShpFunction->GetMean() << std::endl; @@ -249,9 +249,9 @@ itkSampleClassifierFilterTest7(int argc, char * argv[]) return EXIT_FAILURE; } - auto pointSet2 = PointSetType::New(); - PointSetType::PointsContainerPointer pointsContainer2 = PointSetType::PointsContainer::New(); - constexpr int dataSizeSmall = 200; + auto pointSet2 = PointSetType::New(); + const PointSetType::PointsContainerPointer pointsContainer2 = PointSetType::PointsContainer::New(); + constexpr int dataSizeSmall = 200; pointsContainer2->Reserve(dataSizeSmall); pointSet2->SetPoints(pointsContainer2); @@ -291,7 +291,7 @@ itkSampleClassifierFilterTest7(int argc, char * argv[]) unsigned int sampleCounter = 0; - unsigned int numberOfSamplesPerClass = 100; + const unsigned int numberOfSamplesPerClass = 100; if (sampleCounter > numberOfSamplesPerClass) { if (iter.GetClassLabel() != class1) diff --git a/Modules/Segmentation/Classifiers/test/itkScalarImageKmeansImageFilter3DTest.cxx b/Modules/Segmentation/Classifiers/test/itkScalarImageKmeansImageFilter3DTest.cxx index 1dce48d4ed6..6f3aeeb8bfc 100644 --- a/Modules/Segmentation/Classifiers/test/itkScalarImageKmeansImageFilter3DTest.cxx +++ b/Modules/Segmentation/Classifiers/test/itkScalarImageKmeansImageFilter3DTest.cxx @@ -39,13 +39,13 @@ itkScalarImageKmeansImageFilter3DTest(int argc, char * argv[]) return EXIT_FAILURE; } - std::string inputVolume(argv[1]); - std::string input3DSkullStripVolume(argv[2]); - std::string outputLabelMapVolume(argv[3]); - float numberOfStdDeviations = 10.0; + const std::string inputVolume(argv[1]); + const std::string input3DSkullStripVolume(argv[2]); + const std::string outputLabelMapVolume(argv[3]); + const float numberOfStdDeviations = 10.0; - bool debug = true; + const bool debug = true; if (debug) { std::cout << "Input T1 Image: " << inputVolume << std::endl; @@ -274,7 +274,7 @@ itkScalarImageKmeansImageFilter3DTest(int argc, char * argv[]) if (statisticsNonBrainFilter->HasLabel(static_cast(i))) { currentLabel++; - LabelImageType::RegionType labelRegion = statisticsNonBrainFilter->GetRegion(static_cast(i)); + const LabelImageType::RegionType labelRegion = statisticsNonBrainFilter->GetRegion(static_cast(i)); itk::ImageRegionIterator it(kmeansNonBrainFilter->GetOutput(), labelRegion); it.GoToBegin(); @@ -302,7 +302,7 @@ itkScalarImageKmeansImageFilter3DTest(int argc, char * argv[]) if (statisticsBrainFilter->HasLabel(static_cast(i))) { currentLabel++; - LabelImageType::RegionType labelRegion = statisticsBrainFilter->GetRegion(static_cast(i)); + const LabelImageType::RegionType labelRegion = statisticsBrainFilter->GetRegion(static_cast(i)); itk::ImageRegionIterator it(kmeansFilter->GetOutput(), labelRegion); it.GoToBegin(); diff --git a/Modules/Segmentation/Classifiers/test/itkScalarImageKmeansImageFilterTest.cxx b/Modules/Segmentation/Classifiers/test/itkScalarImageKmeansImageFilterTest.cxx index 041a390b7c0..22247716817 100644 --- a/Modules/Segmentation/Classifiers/test/itkScalarImageKmeansImageFilterTest.cxx +++ b/Modules/Segmentation/Classifiers/test/itkScalarImageKmeansImageFilterTest.cxx @@ -60,9 +60,9 @@ itkScalarImageKmeansImageFilterTest(int argc, char * argv[]) auto useNonContiguousLabels = static_cast(std::stoi(argv[3])); ITK_TEST_SET_GET_BOOLEAN(kmeansFilter, UseNonContiguousLabels, useNonContiguousLabels); - typename KMeansFilterType::ImageRegionType region; - typename KMeansFilterType::ImageRegionType::IndexType index = { { 50, 50 } }; - typename KMeansFilterType::ImageRegionType::SizeType size = { { 80, 100 } }; + typename KMeansFilterType::ImageRegionType region; + const typename KMeansFilterType::ImageRegionType::IndexType index = { { 50, 50 } }; + const typename KMeansFilterType::ImageRegionType::SizeType size = { { 80, 100 } }; region.SetIndex(index); region.SetSize(size); kmeansFilter->SetImageRegion(region); diff --git a/Modules/Segmentation/Classifiers/test/itkSupervisedImageClassifierTest.cxx b/Modules/Segmentation/Classifiers/test/itkSupervisedImageClassifierTest.cxx index ed5daaedf0f..58eeef0b0a9 100644 --- a/Modules/Segmentation/Classifiers/test/itkSupervisedImageClassifierTest.cxx +++ b/Modules/Segmentation/Classifiers/test/itkSupervisedImageClassifierTest.cxx @@ -69,10 +69,10 @@ itkSupervisedImageClassifierTest(int, char *[]) auto vecImage = VecImageType::New(); - VecImageType::SizeType vecImgSize = { { IMGWIDTH, IMGHEIGHT, NFRAMES } }; + const VecImageType::SizeType vecImgSize = { { IMGWIDTH, IMGHEIGHT, NFRAMES } }; - VecImageType::IndexType index{}; - VecImageType::RegionType region; + const VecImageType::IndexType index{}; + VecImageType::RegionType region; region.SetSize(vecImgSize); region.SetIndex(index); @@ -173,9 +173,9 @@ itkSupervisedImageClassifierTest(int, char *[]) using ClassImageType = itk::Image; auto classImage = ClassImageType::New(); - ClassImageType::SizeType classImgSize = { { IMGWIDTH, IMGHEIGHT, NFRAMES } }; + const ClassImageType::SizeType classImgSize = { { IMGWIDTH, IMGHEIGHT, NFRAMES } }; - ClassImageType::IndexType classindex{}; + const ClassImageType::IndexType classindex{}; ClassImageType::RegionType classregion; @@ -353,7 +353,7 @@ itkSupervisedImageClassifierTest(int, char *[]) applyClassifier->Update(); // Get the classified image - ClassImageType::Pointer outClassImage = applyClassifier->GetClassifiedImage(); + const ClassImageType::Pointer outClassImage = applyClassifier->GetClassifiedImage(); applyClassifier->Print(std::cout); @@ -364,7 +364,7 @@ itkSupervisedImageClassifierTest(int, char *[]) while (!labeloutIt.IsAtEnd()) { // Print the classified index - int classIndex{ labeloutIt.Get() }; + const int classIndex{ labeloutIt.Get() }; std::cout << " Pixel No " << i << " Value " << classIndex << std::endl; ++i; ++labeloutIt; diff --git a/Modules/Segmentation/ConnectedComponents/include/itkConnectedComponentFunctorImageFilter.hxx b/Modules/Segmentation/ConnectedComponents/include/itkConnectedComponentFunctorImageFilter.hxx index 83d2ad70ca6..7a4dc934d09 100644 --- a/Modules/Segmentation/ConnectedComponents/include/itkConnectedComponentFunctorImageFilter.hxx +++ b/Modules/Segmentation/ConnectedComponents/include/itkConnectedComponentFunctorImageFilter.hxx @@ -33,8 +33,8 @@ ConnectedComponentFunctorImageFilterAllocateOutputs(); - constexpr OutputPixelType maxPossibleLabel = NumericTraits::max(); - typename TOutputImage::Pointer output = this->GetOutput(); + constexpr OutputPixelType maxPossibleLabel = NumericTraits::max(); + const typename TOutputImage::Pointer output = this->GetOutput(); output->FillBuffer(maxPossibleLabel); // Set up the boundary condition to be zero padded (used on output image) @@ -49,9 +49,9 @@ ConnectedComponentFunctorImageFilterGetInput(); - InputNeighborhoodIteratorType init(kernelRadius, input, output->GetRequestedRegion()); - OutputNeighborhoodIteratorType onit(kernelRadius, output, output->GetRequestedRegion()); + const typename TInputImage::ConstPointer input = this->GetInput(); + InputNeighborhoodIteratorType init(kernelRadius, input, output->GetRequestedRegion()); + OutputNeighborhoodIteratorType onit(kernelRadius, output, output->GetRequestedRegion()); onit.OverrideBoundaryCondition(&BC); // assign the boundary condition // only activate the indices that are "previous" to the current @@ -76,7 +76,7 @@ ConnectedComponentFunctorImageFilterGetRequestedRegion().GetNumberOfPixels()); // if the mask is set mark pixels not under the mask as background - if (typename TMaskImage::ConstPointer mask = this->GetMaskImage()) + if (const typename TMaskImage::ConstPointer mask = this->GetMaskImage()) { ImageRegionConstIterator mit(mask, output->GetRequestedRegion()); @@ -129,9 +129,9 @@ ConnectedComponentFunctorImageFilter::GenerateIn Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (!input) { return; } input->SetRequestedRegion(input->GetLargestPossibleRegion()); - MaskImagePointer mask = const_cast(this->GetMaskImage()); + const MaskImagePointer mask = const_cast(this->GetMaskImage()); if (mask) { mask->SetRequestedRegion(input->GetLargestPossibleRegion()); @@ -74,8 +74,8 @@ ConnectedComponentImageFilter::GenerateDa { this->AllocateOutputs(); this->SetupLineOffsets(false); - typename TInputImage::ConstPointer input = this->GetInput(); - typename TMaskImage::ConstPointer mask = this->GetMaskImage(); + const typename TInputImage::ConstPointer input = this->GetInput(); + const typename TMaskImage::ConstPointer mask = this->GetMaskImage(); using MaskFilterType = MaskImageFilter; auto maskFilter = MaskFilterType::New(); @@ -111,7 +111,7 @@ ConnectedComponentImageFilter::GenerateDa [this](const RegionType & lambdaRegion) { this->DynamicThreadedGenerateData(lambdaRegion); }, progress1.GetProcessObject()); - SizeValueType nbOfLabels = this->m_NumberOfLabels.load(); + const SizeValueType nbOfLabels = this->m_NumberOfLabels.load(); // insert all the labels into the structure -- an extra loop but // saves complicating the ones that come later @@ -132,7 +132,7 @@ ConnectedComponentImageFilter::GenerateDa progress3.GetProcessObject()); // AfterThreadedGenerateData - SizeValueType numberOfObjects = this->CreateConsecutive(m_BackgroundValue); + const SizeValueType numberOfObjects = this->CreateConsecutive(m_BackgroundValue); itkAssertOrThrowMacro(numberOfObjects <= this->m_NumberOfLabels, "Number of consecutive labels cannot be greater than the initial number of labels!"); // check for overflow exception here @@ -166,8 +166,8 @@ void ConnectedComponentImageFilter::DynamicThreadedGenerateData( const RegionType & outputRegionForThread) { - WorkUnitData workUnitData = this->CreateWorkUnitData(outputRegionForThread); - SizeValueType lineId = workUnitData.firstLine; + const WorkUnitData workUnitData = this->CreateWorkUnitData(outputRegionForThread); + SizeValueType lineId = workUnitData.firstLine; SizeValueType nbOfLabels = 0; for (ImageScanlineConstIterator inLineIt(m_Input, outputRegionForThread); !inLineIt.IsAtEnd(); inLineIt.NextLine()) @@ -190,7 +190,7 @@ ConnectedComponentImageFilter::DynamicThr ++inLineIt; } // create the run length object to go in the vector - RunLength thisRun = { length, thisIndex, 0 }; + const RunLength thisRun = { length, thisIndex, 0 }; thisLine.push_back(thisRun); ++nbOfLabels; } @@ -227,7 +227,7 @@ ConnectedComponentImageFilter::ThreadedWr ImageRegionIterator fend = oit; fend.GoToEnd(); - WorkUnitData workUnitData = this->CreateWorkUnitData(outputRegionForThread); + const WorkUnitData workUnitData = this->CreateWorkUnitData(outputRegionForThread); for (SizeValueType thisIdx = workUnitData.firstLine; thisIdx <= workUnitData.lastLine; ++thisIdx) { diff --git a/Modules/Segmentation/ConnectedComponents/include/itkRelabelComponentImageFilter.hxx b/Modules/Segmentation/ConnectedComponents/include/itkRelabelComponentImageFilter.hxx index 42c7521724f..bc4dd196fac 100644 --- a/Modules/Segmentation/ConnectedComponents/include/itkRelabelComponentImageFilter.hxx +++ b/Modules/Segmentation/ConnectedComponents/include/itkRelabelComponentImageFilter.hxx @@ -44,7 +44,7 @@ RelabelComponentImageFilter::GenerateInputRequestedRe Superclass::GenerateInputRequestedRegion(); // We need all the input. - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(input->GetLargestPossibleRegion()); @@ -282,7 +282,7 @@ RelabelComponentImageFilter::PrintSelf(std::ostream & SizeValueType i; // limit the number of objects to print - SizeValueType numPrint = std::min(m_NumberOfObjectsToPrint, m_SizeOfObjectsInPixels.size()); + const SizeValueType numPrint = std::min(m_NumberOfObjectsToPrint, m_SizeOfObjectsInPixels.size()); for (i = 0, it = m_SizeOfObjectsInPixels.begin(), fit = m_SizeOfObjectsInPhysicalUnits.begin(); i < numPrint; ++it, ++fit, ++i) diff --git a/Modules/Segmentation/ConnectedComponents/include/itkThresholdMaximumConnectedComponentsImageFilter.hxx b/Modules/Segmentation/ConnectedComponents/include/itkThresholdMaximumConnectedComponentsImageFilter.hxx index fae1e14d935..311740b0772 100644 --- a/Modules/Segmentation/ConnectedComponents/include/itkThresholdMaximumConnectedComponentsImageFilter.hxx +++ b/Modules/Segmentation/ConnectedComponents/include/itkThresholdMaximumConnectedComponentsImageFilter.hxx @@ -88,7 +88,7 @@ ThresholdMaximumConnectedComponentsImageFilter::Gener // // Setup pointers to get input image and send info to output image // - typename Superclass::InputImageConstPointer inputPtr = this->GetInput(); + const typename Superclass::InputImageConstPointer inputPtr = this->GetInput(); // Find the min and max of the image. m_MinMaxCalculator->SetImage(this->GetInput()); diff --git a/Modules/Segmentation/ConnectedComponents/test/itkConnectedComponentImageFilterBackgroundTest.cxx b/Modules/Segmentation/ConnectedComponents/test/itkConnectedComponentImageFilterBackgroundTest.cxx index a349a920beb..ab890a7ef8a 100644 --- a/Modules/Segmentation/ConnectedComponents/test/itkConnectedComponentImageFilterBackgroundTest.cxx +++ b/Modules/Segmentation/ConnectedComponents/test/itkConnectedComponentImageFilterBackgroundTest.cxx @@ -61,7 +61,7 @@ itkConnectedComponentImageFilterBackgroundTest(int argc, char * argv[]) auto filter = FilterType::New(); filter->SetBackgroundValue(background); filter->SetInput(image); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); try { @@ -85,8 +85,8 @@ itkConnectedComponentImageFilterBackgroundTest(int argc, char * argv[]) IteratorType iterator(output, output->GetLargestPossibleRegion()); while (!iterator.IsAtEnd()) { - PixelType value = iterator.Get(); - ImageType::IndexType index = iterator.GetIndex(); + const PixelType value = iterator.Get(); + const ImageType::IndexType index = iterator.GetIndex(); if (index == index1 || index == index2) { // Check that objects don't have the background value diff --git a/Modules/Segmentation/ConnectedComponents/test/itkConnectedComponentImageFilterTest.cxx b/Modules/Segmentation/ConnectedComponents/test/itkConnectedComponentImageFilterTest.cxx index 7ec0944cd1c..e89dd7756dd 100644 --- a/Modules/Segmentation/ConnectedComponents/test/itkConnectedComponentImageFilterTest.cxx +++ b/Modules/Segmentation/ConnectedComponents/test/itkConnectedComponentImageFilterTest.cxx @@ -70,8 +70,8 @@ itkConnectedComponentImageFilterTest(int argc, char * argv[]) reader->SetFileName(argv[1]); - InternalPixelType threshold_low = std::stoi(argv[3]); - InternalPixelType threshold_hi = std::stoi(argv[4]); + const InternalPixelType threshold_low = std::stoi(argv[3]); + const InternalPixelType threshold_hi = std::stoi(argv[4]); threshold->SetInput(reader->GetOutput()); threshold->SetInsideValue(itk::NumericTraits::OneValue()); @@ -88,7 +88,7 @@ itkConnectedComponentImageFilterTest(int argc, char * argv[]) } ITK_TEST_SET_GET_BOOLEAN(filter, FullyConnected, fullyConnected); - typename FilterType::OutputPixelType backgroundValue{}; + const typename FilterType::OutputPixelType backgroundValue{}; filter->SetBackgroundValue(backgroundValue); ITK_TEST_SET_GET_VALUE(backgroundValue, filter->GetBackgroundValue()); @@ -99,7 +99,7 @@ itkConnectedComponentImageFilterTest(int argc, char * argv[]) relabel->SetInput(filter->GetOutput()); if (argc > 6) { - int minSize = std::stoi(argv[6]); + const int minSize = std::stoi(argv[6]); relabel->SetMinimumObjectSize(minSize); std::cerr << "minSize: " << minSize << std::endl; } @@ -119,7 +119,7 @@ itkConnectedComponentImageFilterTest(int argc, char * argv[]) colored->SetRegions(filter->GetOutput()->GetBufferedRegion()); colored->Allocate(); - unsigned short numObjects = relabel->GetNumberOfObjects(); + const unsigned short numObjects = relabel->GetNumberOfObjects(); std::vector colormap; colormap.resize(numObjects + 1); diff --git a/Modules/Segmentation/ConnectedComponents/test/itkConnectedComponentImageFilterTestRGB.cxx b/Modules/Segmentation/ConnectedComponents/test/itkConnectedComponentImageFilterTestRGB.cxx index ba6d2122894..de03f536ba6 100644 --- a/Modules/Segmentation/ConnectedComponents/test/itkConnectedComponentImageFilterTestRGB.cxx +++ b/Modules/Segmentation/ConnectedComponents/test/itkConnectedComponentImageFilterTestRGB.cxx @@ -66,8 +66,8 @@ itkConnectedComponentImageFilterTestRGB(int argc, char * argv[]) reader->SetFileName(argv[1]); - InternalPixelType threshold_low = std::stoi(argv[3]); - InternalPixelType threshold_hi = std::stoi(argv[4]); + const InternalPixelType threshold_low = std::stoi(argv[3]); + const InternalPixelType threshold_hi = std::stoi(argv[4]); threshold->SetInput(reader->GetOutput()); threshold->SetInsideValue(itk::NumericTraits::OneValue()); @@ -79,13 +79,13 @@ itkConnectedComponentImageFilterTestRGB(int argc, char * argv[]) filter->SetInput(threshold->GetOutput()); if (argc > 5) { - int fullyConnected = std::stoi(argv[5]); + const int fullyConnected = std::stoi(argv[5]); filter->SetFullyConnected(fullyConnected); } relabel->SetInput(filter->GetOutput()); if (argc > 6) { - int minSize = std::stoi(argv[6]); + const int minSize = std::stoi(argv[6]); relabel->SetMinimumObjectSize(minSize); std::cerr << "minSize: " << minSize << std::endl; } @@ -98,7 +98,7 @@ itkConnectedComponentImageFilterTestRGB(int argc, char * argv[]) colored->SetRegions(filter->GetOutput()->GetBufferedRegion()); colored->Allocate(); - unsigned short numObjects = relabel->GetNumberOfObjects(); + const unsigned short numObjects = relabel->GetNumberOfObjects(); std::vector colormap; RGBPixelType px; diff --git a/Modules/Segmentation/ConnectedComponents/test/itkConnectedComponentImageFilterTooManyObjectsTest.cxx b/Modules/Segmentation/ConnectedComponents/test/itkConnectedComponentImageFilterTooManyObjectsTest.cxx index e67bf1bc391..ba50cfde6a5 100644 --- a/Modules/Segmentation/ConnectedComponents/test/itkConnectedComponentImageFilterTooManyObjectsTest.cxx +++ b/Modules/Segmentation/ConnectedComponents/test/itkConnectedComponentImageFilterTooManyObjectsTest.cxx @@ -48,7 +48,7 @@ itkConnectedComponentImageFilterTooManyObjectsTest(int itkNotUsed(argc), char *[ using FilterType = itk::ConnectedComponentImageFilter; auto filter = FilterType::New(); filter->SetInput(img); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); try { diff --git a/Modules/Segmentation/ConnectedComponents/test/itkHardConnectedComponentImageFilterTest.cxx b/Modules/Segmentation/ConnectedComponents/test/itkHardConnectedComponentImageFilterTest.cxx index b2ba3b1e600..709665c7696 100644 --- a/Modules/Segmentation/ConnectedComponents/test/itkHardConnectedComponentImageFilterTest.cxx +++ b/Modules/Segmentation/ConnectedComponents/test/itkHardConnectedComponentImageFilterTest.cxx @@ -43,7 +43,7 @@ DoIt(int argc, char * argv[], const std::string pixelType) using IndexType = typename InputImageType::IndexType; auto inputimg = InputImageType::New(); - IndexType index{}; + const IndexType index{}; typename InputImageType::SizeType size; size[0] = width; size[1] = height; @@ -97,7 +97,7 @@ DoIt(int argc, char * argv[], const std::string pixelType) using FilterType = itk::HardConnectedComponentImageFilter; auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + const itk::SimpleFilterWatcher watcher(filter); filter->SetInput(inputimg); // filter->SetObjectSeed(Seed); diff --git a/Modules/Segmentation/ConnectedComponents/test/itkMaskConnectedComponentImageFilterTest.cxx b/Modules/Segmentation/ConnectedComponents/test/itkMaskConnectedComponentImageFilterTest.cxx index 8a2c5c1dc08..51e337688fe 100644 --- a/Modules/Segmentation/ConnectedComponents/test/itkMaskConnectedComponentImageFilterTest.cxx +++ b/Modules/Segmentation/ConnectedComponents/test/itkMaskConnectedComponentImageFilterTest.cxx @@ -68,8 +68,8 @@ itkMaskConnectedComponentImageFilterTest(int argc, char * argv[]) reader->SetFileName(argv[1]); - InternalPixelType threshold_low = std::stoi(argv[3]); - InternalPixelType threshold_hi = std::stoi(argv[4]); + const InternalPixelType threshold_low = std::stoi(argv[3]); + const InternalPixelType threshold_hi = std::stoi(argv[4]); threshold->SetInput(reader->GetOutput()); threshold->SetInsideValue(itk::NumericTraits::OneValue()); @@ -86,8 +86,8 @@ itkMaskConnectedComponentImageFilterTest(int argc, char * argv[]) mask->Allocate(); mask->FillBuffer(MaskPixelType{}); - MaskImageType::RegionType maskRegion = mask->GetLargestPossibleRegion(); - MaskImageType::SizeType maskSize = maskRegion.GetSize(); + const MaskImageType::RegionType maskRegion = mask->GetLargestPossibleRegion(); + MaskImageType::SizeType maskSize = maskRegion.GetSize(); // use upper left corner MaskImageType::SizeType size; @@ -129,13 +129,13 @@ itkMaskConnectedComponentImageFilterTest(int argc, char * argv[]) if (argc > 5) { - int fullyConnected = std::stoi(argv[5]); + const int fullyConnected = std::stoi(argv[5]); filter->SetFullyConnected(fullyConnected); } relabel->SetInput(filter->GetOutput()); if (argc > 6) { - int minSize = std::stoi(argv[6]); + const int minSize = std::stoi(argv[6]); relabel->SetMinimumObjectSize(minSize); std::cerr << "minSize: " << minSize << std::endl; } @@ -155,11 +155,11 @@ itkMaskConnectedComponentImageFilterTest(int argc, char * argv[]) colored->SetRegions(filter->GetOutput()->GetBufferedRegion()); colored->Allocate(); - unsigned short numObjects = relabel->GetNumberOfObjects(); + const unsigned short numObjects = relabel->GetNumberOfObjects(); std::vector colormap; colormap.resize(numObjects + 1); - itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer rvgen = + const itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer rvgen = itk::Statistics::MersenneTwisterRandomVariateGenerator::GetInstance(); rvgen->SetSeed(1031571); RGBPixelType px; diff --git a/Modules/Segmentation/ConnectedComponents/test/itkRelabelComponentImageFilterGTest.cxx b/Modules/Segmentation/ConnectedComponents/test/itkRelabelComponentImageFilterGTest.cxx index 802e9703011..390e05970b3 100644 --- a/Modules/Segmentation/ConnectedComponents/test/itkRelabelComponentImageFilterGTest.cxx +++ b/Modules/Segmentation/ConnectedComponents/test/itkRelabelComponentImageFilterGTest.cxx @@ -70,7 +70,7 @@ TEST(RelabelComponentImageFilter, nosort_nosize) filter->Update(); EXPECT_EQ(filter->GetNumberOfObjects(), 3); - std::vector expected({ 1u, 2u, 3u }); + const std::vector expected({ 1u, 2u, 3u }); ITK_EXPECT_VECTOR_NEAR(filter->GetSizeOfObjectsInPixels(), expected, 0); EXPECT_EQ(filter->GetOutput()->GetPixel({ { 2, 2 } }), 3u); } @@ -88,7 +88,7 @@ TEST(RelabelComponentImageFilter, nosort_size) filter->Update(); EXPECT_EQ(filter->GetNumberOfObjects(), 2); - std::vector expected({ 2u, 3u }); + const std::vector expected({ 2u, 3u }); ITK_EXPECT_VECTOR_NEAR(filter->GetSizeOfObjectsInPixels(), expected, 0); EXPECT_EQ(filter->GetOutput()->GetPixel({ { 2, 2 } }), 2u); } @@ -105,7 +105,7 @@ TEST(RelabelComponentImageFilter, sort_size) filter->Update(); EXPECT_EQ(filter->GetNumberOfObjects(), 2u); - std::vector expected({ 3u, 2u }); + const std::vector expected({ 3u, 2u }); ITK_EXPECT_VECTOR_NEAR(filter->GetSizeOfObjectsInPixels(), expected, 0); EXPECT_EQ(filter->GetOutput()->GetPixel({ { 2, 2 } }), 1u); } @@ -123,7 +123,7 @@ TEST(RelabelComponentImageFilter, sort_nosize) filter->Update(); EXPECT_EQ(filter->GetNumberOfObjects(), 3u); - std::vector expected({ 3u, 2u, 1u }); + const std::vector expected({ 3u, 2u, 1u }); ITK_EXPECT_VECTOR_NEAR(filter->GetSizeOfObjectsInPixels(), expected, 0); EXPECT_EQ(filter->GetOutput()->GetPixel({ { 2, 2 } }), 1u); } @@ -146,7 +146,7 @@ TEST(RelabelComponentImageFilter, big_zero) auto filter = itk::RelabelComponentImageFilter::New(); filter->SetInput(image); - itk::SimpleFilterWatcher watcher1(filter, "relabeler"); + const itk::SimpleFilterWatcher watcher1(filter, "relabeler"); filter->Update(); } @@ -169,7 +169,7 @@ TEST(RelabelComponentImageFilter, big_random) auto filter = itk::RelabelComponentImageFilter::New(); filter->SetInput(randomSource->GetOutput()); - itk::SimpleFilterWatcher watcher1(filter, "relabeler"); + const itk::SimpleFilterWatcher watcher1(filter, "relabeler"); filter->Update(); } diff --git a/Modules/Segmentation/ConnectedComponents/test/itkRelabelComponentImageFilterTest.cxx b/Modules/Segmentation/ConnectedComponents/test/itkRelabelComponentImageFilterTest.cxx index 0cf72149f61..afa31ea1231 100644 --- a/Modules/Segmentation/ConnectedComponents/test/itkRelabelComponentImageFilterTest.cxx +++ b/Modules/Segmentation/ConnectedComponents/test/itkRelabelComponentImageFilterTest.cxx @@ -69,9 +69,9 @@ itkRelabelComponentImageFilterTest(int argc, char * argv[]) using HistogramType = itk::Statistics::Histogram; - int NumBins = 13; - RealType LowerBound = 51.0; - RealType UpperBound = 252.0; + const int NumBins = 13; + const RealType LowerBound = 51.0; + const RealType UpperBound = 252.0; auto reader = ReaderType::New(); auto writer = WriterType::New(); @@ -86,8 +86,8 @@ itkRelabelComponentImageFilterTest(int argc, char * argv[]) auto finalThreshold = FinalThresholdFilterType::New(); auto statistics = StatisticsFilterType::New(); - itk::SimpleFilterWatcher watcher(relabel); - itk::SimpleFilterWatcher statswatcher(statistics); + const itk::SimpleFilterWatcher watcher(relabel); + const itk::SimpleFilterWatcher statswatcher(statistics); reader->SetFileName(argv[1]); @@ -101,8 +101,8 @@ itkRelabelComponentImageFilterTest(int argc, char * argv[]) change->ChangeSpacingOn(); // Create a binary input image to label - InternalPixelType threshold_low = std::stoi(argv[3]); - InternalPixelType threshold_hi = std::stoi(argv[4]); + const InternalPixelType threshold_low = std::stoi(argv[3]); + const InternalPixelType threshold_hi = std::stoi(argv[4]); threshold->SetInput(change->GetOutput()); threshold->SetInsideValue(itk::NumericTraits::OneValue()); @@ -116,15 +116,15 @@ itkRelabelComponentImageFilterTest(int argc, char * argv[]) connected->SetInput(threshold->GetOutput()); relabel->SetInput(connected->GetOutput()); - itk::SizeValueType numberOfObjectsToPrint = 5; + const itk::SizeValueType numberOfObjectsToPrint = 5; relabel->SetNumberOfObjectsToPrint(numberOfObjectsToPrint); ITK_TEST_SET_GET_VALUE(numberOfObjectsToPrint, relabel->GetNumberOfObjectsToPrint()); - typename RelabelComponentType::ObjectSizeType minimumObjectSize = 0; + const typename RelabelComponentType::ObjectSizeType minimumObjectSize = 0; relabel->SetMinimumObjectSize(minimumObjectSize); ITK_TEST_SET_GET_VALUE(minimumObjectSize, relabel->GetMinimumObjectSize()); - bool sortByObjectSize = true; + const bool sortByObjectSize = true; ITK_TEST_SET_GET_BOOLEAN(relabel, SortByObjectSize, sortByObjectSize); std::cout << "Modified time of relabel's output = " << relabel->GetOutput()->GetMTime() << std::endl; @@ -244,7 +244,7 @@ itkRelabelComponentImageFilterTest(int argc, char * argv[]) } // Check for the sizes of the 7 first labels which should be sorted by default - unsigned long ref1[7] = { 7656, 2009, 1586, 1491, 1454, 921, 906 }; + const unsigned long ref1[7] = { 7656, 2009, 1586, 1491, 1454, 921, 906 }; for (int i = 0; i < 6; ++i) { if (relabel->GetSizeOfObjectsInPixels()[i] != ref1[i]) @@ -260,7 +260,7 @@ itkRelabelComponentImageFilterTest(int argc, char * argv[]) relabel->Update(); // Check for the sizes of the 7 first labels which are no more sorted - unsigned long ref2[7] = { 1491, 2, 1, 906, 3, 40, 1 }; + const unsigned long ref2[7] = { 1491, 2, 1, 906, 3, 40, 1 }; for (int i = 0; i < 7; ++i) { if (relabel->GetSizeOfObjectsInPixels()[i] != ref2[i]) diff --git a/Modules/Segmentation/ConnectedComponents/test/itkScalarConnectedComponentImageFilterTest.cxx b/Modules/Segmentation/ConnectedComponents/test/itkScalarConnectedComponentImageFilterTest.cxx index debf7143c13..ec8ac711883 100644 --- a/Modules/Segmentation/ConnectedComponents/test/itkScalarConnectedComponentImageFilterTest.cxx +++ b/Modules/Segmentation/ConnectedComponents/test/itkScalarConnectedComponentImageFilterTest.cxx @@ -73,8 +73,8 @@ itkScalarConnectedComponentImageFilterTest(int argc, char * argv[]) mask->Allocate(); mask->FillBuffer(MaskPixelType{}); - MaskImageType::RegionType maskRegion = mask->GetLargestPossibleRegion(); - MaskImageType::SizeType maskSize = maskRegion.GetSize(); + const MaskImageType::RegionType maskRegion = mask->GetLargestPossibleRegion(); + MaskImageType::SizeType maskSize = maskRegion.GetSize(); MaskImageType::RegionType region; MaskImageType::SizeType size; @@ -123,13 +123,13 @@ itkScalarConnectedComponentImageFilterTest(int argc, char * argv[]) if (argc > 4) { - int fullyConnected = std::stoi(argv[4]); + const int fullyConnected = std::stoi(argv[4]); filter->SetFullyConnected(fullyConnected); } relabel->SetInput(filter->GetOutput()); if (argc > 5) { - int minSize = std::stoi(argv[5]); + const int minSize = std::stoi(argv[5]); relabel->SetMinimumObjectSize(minSize); std::cerr << "minSize: " << minSize << std::endl; } @@ -149,12 +149,12 @@ itkScalarConnectedComponentImageFilterTest(int argc, char * argv[]) colored->SetRegions(filter->GetOutput()->GetBufferedRegion()); colored->Allocate(); - unsigned short numObjects = relabel->GetNumberOfObjects(); + const unsigned short numObjects = relabel->GetNumberOfObjects(); std::vector colormap; RGBPixelType px; colormap.resize(numObjects + 1); - itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer rvgen = + const itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer rvgen = itk::Statistics::MersenneTwisterRandomVariateGenerator::GetInstance(); rvgen->SetSeed(1031571); for (auto & i : colormap) diff --git a/Modules/Segmentation/ConnectedComponents/test/itkThresholdMaximumConnectedComponentsImageFilterTest.cxx b/Modules/Segmentation/ConnectedComponents/test/itkThresholdMaximumConnectedComponentsImageFilterTest.cxx index f4c5835f14e..9f29f5c2ca0 100644 --- a/Modules/Segmentation/ConnectedComponents/test/itkThresholdMaximumConnectedComponentsImageFilterTest.cxx +++ b/Modules/Segmentation/ConnectedComponents/test/itkThresholdMaximumConnectedComponentsImageFilterTest.cxx @@ -54,8 +54,8 @@ itkThresholdMaximumConnectedComponentsImageFilterTest(int argc, char * argv[]) using InputImageType = itk::Image; using OutputImageType = itk::Image; - InputPixelType maxLabel = itk::NumericTraits::max(); - InputPixelType minLabel = itk::NumericTraits::NonpositiveMin(); + const InputPixelType maxLabel = itk::NumericTraits::max(); + const InputPixelType minLabel = itk::NumericTraits::NonpositiveMin(); const unsigned int minimumPixelArea = std::stoi(argv[3]); @@ -96,7 +96,7 @@ itkThresholdMaximumConnectedComponentsImageFilterTest(int argc, char * argv[]) automaticThreshold->SetOutsideValue(maxLabel); ITK_TEST_SET_GET_VALUE(maxLabel, automaticThreshold->GetOutsideValue()); - typename ThresholdType::PixelType upperBoundary = itk::NumericTraits::max(); + const typename ThresholdType::PixelType upperBoundary = itk::NumericTraits::max(); automaticThreshold->SetUpperBoundary(upperBoundary); ITK_TEST_SET_GET_VALUE(upperBoundary, automaticThreshold->GetUpperBoundary()); diff --git a/Modules/Segmentation/ConnectedComponents/test/itkVectorConnectedComponentImageFilterTest.cxx b/Modules/Segmentation/ConnectedComponents/test/itkVectorConnectedComponentImageFilterTest.cxx index d0eaa34de78..e393143b34a 100644 --- a/Modules/Segmentation/ConnectedComponents/test/itkVectorConnectedComponentImageFilterTest.cxx +++ b/Modules/Segmentation/ConnectedComponents/test/itkVectorConnectedComponentImageFilterTest.cxx @@ -60,7 +60,7 @@ itkVectorConnectedComponentImageFilterTest(int argc, char * argv[]) size = region.GetSize(); index = region.GetIndex(); - unsigned int width = size[0]; + const unsigned int width = size[0]; size[0] = width / 2; size[1] = width / 2; @@ -169,7 +169,7 @@ itkVectorConnectedComponentImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, VectorConnectedComponentImageFilter, ConnectedComponentFunctorImageFilter); - typename VectorFilterType::InputValueType distanceThreshold = 0.01; + const typename VectorFilterType::InputValueType distanceThreshold = 0.01; filter->SetDistanceThreshold(distanceThreshold); ITK_TEST_SET_GET_VALUE(distanceThreshold, filter->GetDistanceThreshold()); diff --git a/Modules/Segmentation/DeformableMesh/include/itkDeformableSimplexMesh3DBalloonForceFilter.hxx b/Modules/Segmentation/DeformableMesh/include/itkDeformableSimplexMesh3DBalloonForceFilter.hxx index 9ab28086d1c..d4a9b169830 100644 --- a/Modules/Segmentation/DeformableMesh/include/itkDeformableSimplexMesh3DBalloonForceFilter.hxx +++ b/Modules/Segmentation/DeformableMesh/include/itkDeformableSimplexMesh3DBalloonForceFilter.hxx @@ -116,7 +116,7 @@ DeformableSimplexMesh3DBalloonForceFilter::ComputeExter vec_for.Fill(0); } - double mag = dot_product(data->normal.GetVnlVector(), vec_for.GetVnlVector()); + const double mag = dot_product(data->normal.GetVnlVector(), vec_for.GetVnlVector()); vec_for[0] = this->GetBeta() * mag * (data->normal)[0]; /*num_for*/ vec_for[1] = this->GetBeta() * mag * (data->normal)[1]; /*num_for*/ diff --git a/Modules/Segmentation/DeformableMesh/include/itkDeformableSimplexMesh3DFilter.hxx b/Modules/Segmentation/DeformableMesh/include/itkDeformableSimplexMesh3DFilter.hxx index 3e1e0d9a031..8925deabec8 100644 --- a/Modules/Segmentation/DeformableMesh/include/itkDeformableSimplexMesh3DFilter.hxx +++ b/Modules/Segmentation/DeformableMesh/include/itkDeformableSimplexMesh3DFilter.hxx @@ -56,7 +56,7 @@ DeformableSimplexMesh3DFilter::DeformableSimplexMesh3DF this->ProcessObject::SetNumberOfRequiredInputs(1); - OutputMeshPointer output = OutputMeshType::New(); + const OutputMeshPointer output = OutputMeshType::New(); this->ProcessObject::SetNumberOfRequiredOutputs(1); this->ProcessObject::SetNthOutput(0, output.GetPointer()); @@ -115,7 +115,7 @@ DeformableSimplexMesh3DFilter::GenerateData() while (pointItr != points->End()) { SimplexMeshGeometry * data; - IdentifierType idx = pointItr.Index(); + const IdentifierType idx = pointItr.Index(); data = this->m_Data->GetElement(idx); delete data->neighborSet; data->neighborSet = nullptr; @@ -166,7 +166,7 @@ DeformableSimplexMesh3DFilter::Initialize() while (pointItr != points->End()) { SimplexMeshGeometry * data; - IdentifierType idx = pointItr.Index(); + const IdentifierType idx = pointItr.Index(); data = this->m_Data->GetElement(idx); data->pos = pointItr.Value(); @@ -245,12 +245,12 @@ DeformableSimplexMesh3DFilter::ComputeGeometry() VectorType tmp = data->neighbors[0] - data->pos; - double D = 1.0 / (2 * data->sphereRadius); /* */ + const double D = 1.0 / (2 * data->sphereRadius); /* */ - double tmpNormalProd = dot_product(tmp.GetVnlVector(), data->normal.GetVnlVector()); + const double tmpNormalProd = dot_product(tmp.GetVnlVector(), data->normal.GetVnlVector()); - double sinphi = 2 * data->circleRadius * D * itk::Math::sgn(tmpNormalProd); - double phi = std::asin(sinphi); + const double sinphi = 2 * data->circleRadius * D * itk::Math::sgn(tmpNormalProd); + const double phi = std::asin(sinphi); data->phi = phi; data->meanCurvature = itk::Math::abs(sinphi / data->circleRadius); @@ -258,7 +258,7 @@ DeformableSimplexMesh3DFilter::ComputeGeometry() // compute the foot of p projection of p onto the triangle spanned by its // neighbors - double distance = -tmpNormalProd; + const double distance = -tmpNormalProd; tmp.SetVnlVector((data->pos).GetVnlVector() - distance * normal.GetVnlVector()); const PointType Foot(tmp.data()); @@ -469,12 +469,12 @@ DeformableSimplexMesh3DFilter::UpdateReferenceMetrics() { SimplexMeshGeometry * data = dataIt->Value(); - double H_N1 = ((SimplexMeshGeometry *)(this->m_Data->GetElement(data->neighborIndices[0])))->meanCurvature; - double H_N2 = ((SimplexMeshGeometry *)(this->m_Data->GetElement(data->neighborIndices[1])))->meanCurvature; - double H_N3 = ((SimplexMeshGeometry *)(this->m_Data->GetElement(data->neighborIndices[2])))->meanCurvature; - double H = data->meanCurvature; + const double H_N1 = ((SimplexMeshGeometry *)(this->m_Data->GetElement(data->neighborIndices[0])))->meanCurvature; + const double H_N2 = ((SimplexMeshGeometry *)(this->m_Data->GetElement(data->neighborIndices[1])))->meanCurvature; + const double H_N3 = ((SimplexMeshGeometry *)(this->m_Data->GetElement(data->neighborIndices[2])))->meanCurvature; + const double H = data->meanCurvature; - double H_Mean = (H_N1 + H_N2 + H_N3) / 3.0; + const double H_Mean = (H_N1 + H_N2 + H_N3) / 3.0; PointType deltaH; deltaH[0] = (H_N1 - H_Mean) / H_Mean; @@ -524,7 +524,7 @@ DeformableSimplexMesh3DFilter::L_Func(const double r, { eps = -1.0; } - double tmpSqr = r2 + r2Minusd2 * tanPhi * tanPhi; + const double tmpSqr = r2 + r2Minusd2 * tanPhi * tanPhi; if (tmpSqr > 0) { const double denom = eps * (std::sqrt(tmpSqr) + r); diff --git a/Modules/Segmentation/DeformableMesh/include/itkDeformableSimplexMesh3DGradientConstraintForceFilter.hxx b/Modules/Segmentation/DeformableMesh/include/itkDeformableSimplexMesh3DGradientConstraintForceFilter.hxx index 630383900dc..992fde99e48 100644 --- a/Modules/Segmentation/DeformableMesh/include/itkDeformableSimplexMesh3DGradientConstraintForceFilter.hxx +++ b/Modules/Segmentation/DeformableMesh/include/itkDeformableSimplexMesh3DGradientConstraintForceFilter.hxx @@ -114,7 +114,7 @@ DeformableSimplexMesh3DGradientConstraintForceFilter::N double * y, double * z) { - double dp[3]{ pp[0], pp[1], pp[2] }; + const double dp[3]{ pp[0], pp[1], pp[2] }; double dlx; if (dp[0] >= 0.0) @@ -228,8 +228,8 @@ DeformableSimplexMesh3DGradientConstraintForceFilter::C ic[2] < this->m_ImageDepth) { - SIDEEnum side = SIDEEnum::BOTH; // make sure you can set half segment as well but for now - // we just set it to full segment + const SIDEEnum side = SIDEEnum::BOTH; // make sure you can set half segment as well but for now + // we just set it to full segment int vpos[3] = { ic[0], ic[1], ic[2] }; @@ -282,7 +282,7 @@ DeformableSimplexMesh3DGradientConstraintForceFilter::C while (!stop) { - double a = NextVoxel(dp, ic, &x, &y, &z); + const double a = NextVoxel(dp, ic, &x, &y, &z); pos[0] += a * dp[0]; pos[1] += a * dp[1]; @@ -339,7 +339,7 @@ DeformableSimplexMesh3DGradientConstraintForceFilter::C while (!stop) { - double a = NextVoxel(dp, ic, &x, &y, &z); + const double a = NextVoxel(dp, ic, &x, &y, &z); pos[0] += a * dp[0]; pos[1] += a * dp[1]; @@ -397,7 +397,7 @@ DeformableSimplexMesh3DGradientConstraintForceFilter::C vec_for[2] = gradient3[2]; // check magnitude - double mag = std::sqrt(dot_product(vec_for.GetVnlVector(), vec_for.GetVnlVector())); + const double mag = std::sqrt(dot_product(vec_for.GetVnlVector(), vec_for.GetVnlVector())); if (mag > max) { max = mag; @@ -414,7 +414,7 @@ DeformableSimplexMesh3DGradientConstraintForceFilter::C vec_for[2] = gradient2[2]; // now check highest gradient magnitude direction - double mag = dot_product(vec_for.GetVnlVector(), data->normal.GetVnlVector()); + const double mag = dot_product(vec_for.GetVnlVector(), data->normal.GetVnlVector()); if (mag > 0) { vec_for[0] -= gradient0[0]; diff --git a/Modules/Segmentation/DeformableMesh/test/itkDeformableSimplexMesh3DBalloonForceFilterTest.cxx b/Modules/Segmentation/DeformableMesh/test/itkDeformableSimplexMesh3DBalloonForceFilterTest.cxx index 4424ab242b1..d0aa383d415 100644 --- a/Modules/Segmentation/DeformableMesh/test/itkDeformableSimplexMesh3DBalloonForceFilterTest.cxx +++ b/Modules/Segmentation/DeformableMesh/test/itkDeformableSimplexMesh3DBalloonForceFilterTest.cxx @@ -55,7 +55,7 @@ itkDeformableSimplexMesh3DBalloonForceFilterTest(int argc, char * argv[]) auto mySphereMeshSource = SphereMeshSourceType::New(); auto center = itk::MakeFilled(10); PointType::ValueType scaleInit[3] = { 3, 3, 3 }; - VectorType scale = scaleInit; + const VectorType scale = scaleInit; mySphereMeshSource->SetCenter(center); mySphereMeshSource->SetResolution(2); @@ -140,7 +140,7 @@ itkDeformableSimplexMesh3DBalloonForceFilterTest(int argc, char * argv[]) deformFilter->SetRigidity(0); deformFilter->Update(); - SimplexMeshType::Pointer deformResult = deformFilter->GetOutput(); + const SimplexMeshType::Pointer deformResult = deformFilter->GetOutput(); std::cout << "Deformation Result: " << deformResult << std::endl; diff --git a/Modules/Segmentation/DeformableMesh/test/itkDeformableSimplexMesh3DFilterTest.cxx b/Modules/Segmentation/DeformableMesh/test/itkDeformableSimplexMesh3DFilterTest.cxx index d0562013394..caee04cc109 100644 --- a/Modules/Segmentation/DeformableMesh/test/itkDeformableSimplexMesh3DFilterTest.cxx +++ b/Modules/Segmentation/DeformableMesh/test/itkDeformableSimplexMesh3DFilterTest.cxx @@ -73,7 +73,7 @@ itkDeformableSimplexMesh3DFilterTest(int, char *[]) auto mySphereMeshSource = SphereMeshSourceType::New(); auto center = itk::MakeFilled(10); PointType::ValueType scaleInit[3] = { 3, 3, 3 }; - VectorType scale = scaleInit; + const VectorType scale = scaleInit; mySphereMeshSource->SetCenter(center); mySphereMeshSource->SetResolution(2); @@ -87,7 +87,7 @@ itkDeformableSimplexMesh3DFilterTest(int, char *[]) simplexFilter->SetInput(mySphereMeshSource->GetOutput()); simplexFilter->Update(); - SimplexMeshType::Pointer simplexMesh = simplexFilter->GetOutput(); + const SimplexMeshType::Pointer simplexMesh = simplexFilter->GetOutput(); simplexMesh->DisconnectPipeline(); std::cout << "Simplex Mesh: " << simplexMesh << std::endl; @@ -160,12 +160,12 @@ itkDeformableSimplexMesh3DFilterTest(int, char *[]) constexpr unsigned int numberOfCycles = 100; - double alpha = 0.1; - double beta = -0.1; - double gamma = 0.05; - double damping = 0.65; - int iterations = 5; - unsigned int rigidity = 1; + const double alpha = 0.1; + const double beta = -0.1; + const double gamma = 0.05; + const double damping = 0.65; + const int iterations = 5; + const unsigned int rigidity = 1; for (unsigned int i = 0; i < numberOfCycles; ++i) { @@ -201,7 +201,7 @@ itkDeformableSimplexMesh3DFilterTest(int, char *[]) std::cout << "ImageDepth: " << deformFilter->GetImageDepth() << std::endl; std::cout << "Deform filter Step: " << deformFilter->GetStep() << std::endl; - SimplexMeshType::Pointer deformResult = deformFilter->GetOutput(); + const SimplexMeshType::Pointer deformResult = deformFilter->GetOutput(); // calculate the volume of the mesh auto volumecalculator = SimplexVolumeType::New(); diff --git a/Modules/Segmentation/DeformableMesh/test/itkDeformableSimplexMesh3DGradientConstraintForceFilterTest.cxx b/Modules/Segmentation/DeformableMesh/test/itkDeformableSimplexMesh3DGradientConstraintForceFilterTest.cxx index 05fc67ea3bd..630697e8f93 100644 --- a/Modules/Segmentation/DeformableMesh/test/itkDeformableSimplexMesh3DGradientConstraintForceFilterTest.cxx +++ b/Modules/Segmentation/DeformableMesh/test/itkDeformableSimplexMesh3DGradientConstraintForceFilterTest.cxx @@ -52,7 +52,7 @@ itkDeformableSimplexMesh3DGradientConstraintForceFilterTest(int, char *[]) auto mySphereMeshSource = SphereMeshSourceType::New(); auto center = itk::MakeFilled(10); PointType::ValueType scaleInit[PointDimension] = { 5, 5, 5 }; - VectorType scale = scaleInit; + const VectorType scale = scaleInit; mySphereMeshSource->SetCenter(center); mySphereMeshSource->SetResolution(2); @@ -130,7 +130,7 @@ itkDeformableSimplexMesh3DGradientConstraintForceFilterTest(int, char *[]) deformFilter->SetAlpha(0.2); deformFilter->SetBeta(0.1); - int range = 1; + const int range = 1; deformFilter->SetRange(range); ITK_TEST_SET_GET_VALUE(range, deformFilter->GetRange()); @@ -138,7 +138,7 @@ itkDeformableSimplexMesh3DGradientConstraintForceFilterTest(int, char *[]) deformFilter->SetRigidity(0); deformFilter->Update(); - SimplexMeshType::Pointer deformResult = deformFilter->GetOutput(); + const SimplexMeshType::Pointer deformResult = deformFilter->GetOutput(); std::cout << "Deformation Result: " << deformResult << std::endl; diff --git a/Modules/Segmentation/KLMRegionGrowing/include/itkKLMRegionGrowImageFilter.hxx b/Modules/Segmentation/KLMRegionGrowing/include/itkKLMRegionGrowImageFilter.hxx index 2fb260ccfdf..907aff006c9 100644 --- a/Modules/Segmentation/KLMRegionGrowing/include/itkKLMRegionGrowImageFilter.hxx +++ b/Modules/Segmentation/KLMRegionGrowing/include/itkKLMRegionGrowImageFilter.hxx @@ -48,7 +48,7 @@ void KLMRegionGrowImageFilter::GenerateInputRequestedRegion() { // This filter requires all of the input image to be in the buffer - InputImagePointer inputPtr = const_cast(this->GetInput()); + const InputImagePointer inputPtr = const_cast(this->GetInput()); if (inputPtr) { @@ -73,7 +73,7 @@ KLMRegionGrowImageFilter::GenerateData() this->ApplyRegionGrowImageFilter(); // Set the output labelled and allocate the memory - OutputImagePointer outputPtr = this->GetOutput(); + const OutputImagePointer outputPtr = this->GetOutput(); // Allocate the output buffer memory outputPtr->SetBufferedRegion(outputPtr->GetRequestedRegion()); @@ -86,8 +86,8 @@ template void KLMRegionGrowImageFilter::GenerateOutputImage() { - InputImageConstPointer inputImage = this->GetInput(); - InputImageSizeType inputImageSize = inputImage->GetBufferedRegion().GetSize(); + const InputImageConstPointer inputImage = this->GetInput(); + InputImageSizeType inputImageSize = inputImage->GetBufferedRegion().GetSize(); GridSizeType gridSize = this->GetGridSize(); @@ -105,7 +105,7 @@ KLMRegionGrowImageFilter::GenerateOutputImage() // region intensity. After the updated region intensity is found, // each pixel is updated with the mean approximation value. - OutputImagePointer outputImage = this->GetOutput(); + const OutputImagePointer outputImage = this->GetOutput(); using OutputRegionType = typename TOutputImage::RegionType; OutputRegionType region; region.SetSize(gridSize); // Constant grid size @@ -178,8 +178,8 @@ auto KLMRegionGrowImageFilter::GenerateLabelledImage(LabelImageType * labelImagePtr) -> LabelImagePointer { - InputImageConstPointer inputImage = this->GetInput(); - InputImageSizeType inputImageSize = inputImage->GetBufferedRegion().GetSize(); + const InputImageConstPointer inputImage = this->GetInput(); + InputImageSizeType inputImageSize = inputImage->GetBufferedRegion().GetSize(); GridSizeType gridSize = this->GetGridSize(); @@ -206,7 +206,7 @@ KLMRegionGrowImageFilter::GenerateLabelledImage(Label // Fill the region with the label - RegionLabelType newRegionLabel = m_RegionsPointer[iregion]->GetRegionLabel(); + const RegionLabelType newRegionLabel = m_RegionsPointer[iregion]->GetRegionLabel(); LabelImageIterator labelIt(labelImagePtr, region); while (!labelIt.IsAtEnd()) @@ -274,7 +274,7 @@ KLMRegionGrowImageFilter::InitializeKLM() // This implementation requires the image dimensions to be // multiples of the user specified grid sizes. - InputImageConstPointer inputImage = this->GetInput(); + const InputImageConstPointer inputImage = this->GetInput(); InputImageSizeType inputImageSize = inputImage->GetBufferedRegion().GetSize(); GridSizeType gridSize = this->GetGridSize(); typename TInputImage::SpacingType spacing = inputImage->GetSpacing(); @@ -421,7 +421,7 @@ KLMRegionGrowImageFilter::InitializeKLM() } // Load the border of interest - KLMSegmentationBorderPtr pcurrentBorder = m_BordersPointer[borderCounter]; + const KLMSegmentationBorderPtr pcurrentBorder = m_BordersPointer[borderCounter]; // Set the length of the border pcurrentBorder->SetBorderLength(borderLengthTmp); @@ -441,8 +441,8 @@ KLMRegionGrowImageFilter::InitializeKLM() tmpVal *= numRegionsAlongDim[jdim]; } - KLMSegmentationRegionPtr pRegion1 = m_RegionsPointer[intRegion1Index]; - KLMSegmentationRegionPtr pRegion2 = m_RegionsPointer[intRegion2Index]; + const KLMSegmentationRegionPtr pRegion1 = m_RegionsPointer[intRegion1Index]; + const KLMSegmentationRegionPtr pRegion2 = m_RegionsPointer[intRegion2Index]; // Attach the region border off lesser label value to region1 // Attach the region border of the greater label value to region2 @@ -542,7 +542,7 @@ void KLMRegionGrowImageFilter::InitializeRegionParameters(InputRegionType region) { // Get a pointer to the image - InputImageConstPointer inputImage = this->GetInput(); + const InputImageConstPointer inputImage = this->GetInput(); // Set the iterators and the pixel type definition for the input image InputImageConstIterator inputIt(inputImage, region); @@ -683,7 +683,7 @@ template void KLMRegionGrowImageFilter::ResolveRegions() { - InputImageConstPointer inputImage = this->GetInput(); + const InputImageConstPointer inputImage = this->GetInput(); // Scan through the region labels to establish the correspondence // between the final region (and label) and the initial regions. @@ -754,11 +754,11 @@ KLMRegionGrowImageFilter::ResolveRegions() // Assign new consecutive labels for (iregion = 0; iregion < m_InitialNumberOfRegions; ++iregion) { - RegionLabelType labelValue = m_RegionsPointer[iregion]->GetRegionLabel(); + const RegionLabelType labelValue = m_RegionsPointer[iregion]->GetRegionLabel(); newLabelValue = remapLabelsVec[labelValue - 1]; - double newAreaValue = m_RegionsPointer[labelValue - 1]->GetRegionArea(); - MeanRegionIntensityType newMeanValue = m_RegionsPointer[labelValue - 1]->GetMeanRegionIntensity(); + const double newAreaValue = m_RegionsPointer[labelValue - 1]->GetRegionArea(); + const MeanRegionIntensityType newMeanValue = m_RegionsPointer[labelValue - 1]->GetMeanRegionIntensity(); m_RegionsPointer[iregion]->SetRegionParameters(newMeanValue, newAreaValue, newLabelValue); } diff --git a/Modules/Segmentation/KLMRegionGrowing/include/itkKLMSegmentationBorder.h b/Modules/Segmentation/KLMRegionGrowing/include/itkKLMSegmentationBorder.h index 21a33237631..ea9253f039d 100644 --- a/Modules/Segmentation/KLMRegionGrowing/include/itkKLMSegmentationBorder.h +++ b/Modules/Segmentation/KLMRegionGrowing/include/itkKLMSegmentationBorder.h @@ -67,11 +67,11 @@ class KLMDynamicBorderArray // constant C, allowing a single region to be repeatedly // merged so that it gains many borders will result in // pathologically slow behavior. - double v1 = std::max(static_cast(m_Pointer->GetRegion1()->GetRegionBorderSize()), - static_cast(m_Pointer->GetRegion2()->GetRegionBorderSize())); + const double v1 = std::max(static_cast(m_Pointer->GetRegion1()->GetRegionBorderSize()), + static_cast(m_Pointer->GetRegion2()->GetRegionBorderSize())); - double v2 = std::max(static_cast(rhs.m_Pointer->GetRegion1()->GetRegionBorderSize()), - static_cast(rhs.m_Pointer->GetRegion2()->GetRegionBorderSize())); + const double v2 = std::max(static_cast(rhs.m_Pointer->GetRegion1()->GetRegionBorderSize()), + static_cast(rhs.m_Pointer->GetRegion2()->GetRegionBorderSize())); return (v1 > v2); } diff --git a/Modules/Segmentation/KLMRegionGrowing/src/itkKLMSegmentationRegion.cxx b/Modules/Segmentation/KLMRegionGrowing/src/itkKLMSegmentationRegion.cxx index 63281415caa..0135de8c409 100644 --- a/Modules/Segmentation/KLMRegionGrowing/src/itkKLMSegmentationRegion.cxx +++ b/Modules/Segmentation/KLMRegionGrowing/src/itkKLMSegmentationRegion.cxx @@ -47,13 +47,13 @@ KLMSegmentationRegion::CombineRegionParameters(const Self * region) { // Reset the area and mean associated with the merged region - MeanRegionIntensityType region1Mean = this->GetMeanRegionIntensity(); - MeanRegionIntensityType region2Mean = region->GetMeanRegionIntensity(); + const MeanRegionIntensityType region1Mean = this->GetMeanRegionIntensity(); + const MeanRegionIntensityType region2Mean = region->GetMeanRegionIntensity(); - double region1Area = this->GetRegionArea(); - double region2Area = region->GetRegionArea(); + const double region1Area = this->GetRegionArea(); + const double region2Area = region->GetRegionArea(); - double mergedRegionArea = region1Area + region2Area; + const double mergedRegionArea = region1Area + region2Area; MeanRegionIntensityType mergedRegionMean = region1Mean * region1Area + region2Mean * region2Area; if (mergedRegionArea <= 0) @@ -68,16 +68,16 @@ KLMSegmentationRegion::CombineRegionParameters(const Self * region) double KLMSegmentationRegion::EnergyFunctional(const Self * region) { - MeanRegionIntensityType region1_2MeanDiff = this->m_MeanRegionIntensity - region->m_MeanRegionIntensity; + const MeanRegionIntensityType region1_2MeanDiff = this->m_MeanRegionIntensity - region->m_MeanRegionIntensity; // Assuming equal weights to all the channels // FIXME: For different channel weights modify this part of the code. - double cost = region1_2MeanDiff.squared_magnitude(); + const double cost = region1_2MeanDiff.squared_magnitude(); - double region1Area = this->GetRegionArea(); - double region2Area = region->GetRegionArea(); + const double region1Area = this->GetRegionArea(); + const double region2Area = region->GetRegionArea(); - double scaleArea = (region1Area * region2Area) / (region1Area + region2Area); + const double scaleArea = (region1Area * region2Area) / (region1Area + region2Area); return scaleArea * cost; } @@ -286,8 +286,8 @@ KLMSegmentationRegion::SpliceRegionBorders(Self * region) // Initialize the region iterators - RegionBorderVectorConstIterator thisRegionBordersIt = thisRegionBorder.begin(); - RegionBorderVectorConstIterator endOfThisRegionBorders = thisRegionBorder.end(); + RegionBorderVectorConstIterator thisRegionBordersIt = thisRegionBorder.begin(); + const RegionBorderVectorConstIterator endOfThisRegionBorders = thisRegionBorder.end(); auto thatRegionBordersIt = region->GetRegionBorderConstItBegin(); auto endOfThatRegionBorders = region->GetRegionBorderConstItEnd(); @@ -312,7 +312,7 @@ KLMSegmentationRegion::SpliceRegionBorders(Self * region) ((*thisRegionBordersIt)->GetRegion2() == (*thatRegionBordersIt)->GetRegion2())) { // Add the lengths of the borders - double newLength = (*thatRegionBordersIt)->GetBorderLength() + (*thisRegionBordersIt)->GetBorderLength(); + const double newLength = (*thatRegionBordersIt)->GetBorderLength() + (*thisRegionBordersIt)->GetBorderLength(); (*thisRegionBordersIt)->SetBorderLength(newLength); diff --git a/Modules/Segmentation/KLMRegionGrowing/test/itkRegionGrow2DTest.cxx b/Modules/Segmentation/KLMRegionGrowing/test/itkRegionGrow2DTest.cxx index 7bf5f6287c4..919f3f1f7d6 100644 --- a/Modules/Segmentation/KLMRegionGrowing/test/itkRegionGrow2DTest.cxx +++ b/Modules/Segmentation/KLMRegionGrowing/test/itkRegionGrow2DTest.cxx @@ -114,14 +114,14 @@ test_RegionGrowKLMExceptionHandling() // Generate the image data - int sizeLen = 3; + const int sizeLen = 3; using ImageType5D = itk::Image, NUMDIM5D>; auto image5D = ImageType5D::New(); auto imageSize5D = ImageType5D::SizeType::Filled(sizeLen); - ImageType5D::IndexType index5D{}; + const ImageType5D::IndexType index5D{}; ImageType5D::RegionType region5D; @@ -131,7 +131,7 @@ test_RegionGrowKLMExceptionHandling() image5D->SetLargestPossibleRegion(region5D); image5D->SetBufferedRegion(region5D); image5D->Allocate(); - itk::Vector pixel{}; + const itk::Vector pixel{}; image5D->FillBuffer(pixel); // Set the filter with valid inputs @@ -149,7 +149,7 @@ test_RegionGrowKLMExceptionHandling() exceptionTestingFilter5D->SetGridSize(gridSize5D); exceptionTestingFilter5D->SetMaximumNumberOfRegions(2); - double maximumLambda = 1000.0; + const double maximumLambda = 1000.0; exceptionTestingFilter5D->SetMaximumLambda(maximumLambda); ITK_TEST_SET_GET_VALUE(maximumLambda, exceptionTestingFilter5D->GetMaximumLambda()); @@ -233,13 +233,13 @@ test_regiongrowKLM1D() auto image = ImageType::New(); - unsigned int numPixels = 100; - unsigned int numPixelsHalf = 50; - auto imageSize = ImageType::SizeType::Filled(numPixels); + const unsigned int numPixels = 100; + const unsigned int numPixelsHalf = 50; + auto imageSize = ImageType::SizeType::Filled(numPixels); - ImageType::IndexType index{}; + const ImageType::IndexType index{}; - ImageType::RegionType region{ index, imageSize }; + const ImageType::RegionType region{ index, imageSize }; image->SetLargestPossibleRegion(region); image->SetBufferedRegion(region); @@ -306,7 +306,7 @@ test_regiongrowKLM1D() KLMFilter->SetMaximumLambda(maximumLambda); ITK_TEST_SET_GET_VALUE(maximumLambda, KLMFilter->GetMaximumLambda()); - unsigned int numberOfRegions = 0; + const unsigned int numberOfRegions = 0; KLMFilter->SetNumberOfRegions(numberOfRegions); ITK_TEST_SET_GET_VALUE(numberOfRegions, KLMFilter->GetNumberOfRegions()); @@ -337,13 +337,13 @@ test_regiongrowKLM1D() // This should return unique integer labels of the segmented regions. // The region labels should be consecutive integers beginning with 1. - OutputImageType::Pointer outImage = KLMFilter->GetOutput(); + const OutputImageType::Pointer outImage = KLMFilter->GetOutput(); using OutputImageIterator = itk::ImageRegionIterator; OutputImageIterator outIt(outImage, outImage->GetBufferedRegion()); using LabelType = KLMRegionGrowImageFilterType::RegionLabelType; using LabelledImageType = itk::Image; - LabelledImageType::Pointer labelledImage = KLMFilter->GetLabelledImage(); + const LabelledImageType::Pointer labelledImage = KLMFilter->GetLabelledImage(); using OutputImageData = OutputImageType::PixelType::VectorType; ImageData pixelIn; @@ -429,13 +429,13 @@ test_regiongrowKLM1D() std::cout << "Extracting and checking approximation image" << std::endl; std::cout << "Extracting and checking label image" << std::endl; - OutputImageType::Pointer outImage2 = KLMFilter->GetOutput(); - OutputImageIterator outIt2(outImage2, outImage2->GetBufferedRegion()); - OutputImageData pixelOut2a; - OutputImageData pixelOut2b; + const OutputImageType::Pointer outImage2 = KLMFilter->GetOutput(); + OutputImageIterator outIt2(outImage2, outImage2->GetBufferedRegion()); + OutputImageData pixelOut2a; + OutputImageData pixelOut2b; - LabelledImageType::Pointer labelledImage2 = KLMFilter->GetLabelledImage(); - LabelImageIterator labelIt2(labelledImage2, labelledImage2->GetBufferedRegion()); + const LabelledImageType::Pointer labelledImage2 = KLMFilter->GetLabelledImage(); + LabelImageIterator labelIt2(labelledImage2, labelledImage2->GetBufferedRegion()); pixelOut2a[0] = (numPixelsHalf - 1) * numPixelsHalf / 2; pixelOut2a[1] = (numPixels - 1) * numPixels / 2 - pixelOut2a[0]; @@ -447,8 +447,8 @@ test_regiongrowKLM1D() pixelOut2b[1] = pixelOut2a[0]; pixelOut2b[2] = 247; - LabelType ma = 1; - LabelType mb = 2; + const LabelType ma = 1; + const LabelType mb = 2; k = 0; while (!outIt2.IsAtEnd()) @@ -508,7 +508,7 @@ test_regiongrowKLM1D() nregions = 4; std::cout << std::endl << "Third test, merge to " << nregions << " regions" << std::endl; - unsigned int numPixelsQtr = numPixelsHalf / 2; + const unsigned int numPixelsQtr = numPixelsHalf / 2; k = 0; inIt.GoToBegin(); while (!inIt.IsAtEnd()) @@ -556,15 +556,15 @@ test_regiongrowKLM1D() std::cout << "Extracting and checking approximation image" << std::endl; std::cout << "Extracting and checking label image" << std::endl; - OutputImageType::Pointer outImage3 = KLMFilter->GetOutput(); - OutputImageIterator outIt3(outImage3, outImage3->GetBufferedRegion()); - OutputImageData pixelOut3a; - OutputImageData pixelOut3b; - OutputImageData pixelOut3c; - OutputImageData pixelOut3d; + const OutputImageType::Pointer outImage3 = KLMFilter->GetOutput(); + OutputImageIterator outIt3(outImage3, outImage3->GetBufferedRegion()); + OutputImageData pixelOut3a; + OutputImageData pixelOut3b; + OutputImageData pixelOut3c; + OutputImageData pixelOut3d; - LabelledImageType::Pointer labelledImage3 = KLMFilter->GetLabelledImage(); - LabelImageIterator labelIt3(labelledImage3, labelledImage3->GetBufferedRegion()); + const LabelledImageType::Pointer labelledImage3 = KLMFilter->GetLabelledImage(); + LabelImageIterator labelIt3(labelledImage3, labelledImage3->GetBufferedRegion()); pixelOut3a[0] = (numPixelsQtr - 1) * numPixelsQtr / 2; pixelOut3a[1] = (numPixels - 1) * numPixels / 2 - (3 * numPixelsQtr - 1) * (3 * numPixelsQtr) / 2; @@ -586,8 +586,8 @@ test_regiongrowKLM1D() pixelOut3d[1] = pixelOut3a[0]; pixelOut3d[2] = 227; - LabelType mc = 3; - LabelType md = 4; + const LabelType mc = 3; + const LabelType md = 4; k = 0; while (!outIt3.IsAtEnd()) @@ -710,7 +710,7 @@ test_regiongrowKLM1D() // FIFTH TEST: // large gridsize no merging - int gridWidth = 5; + const int gridWidth = 5; gridSize.Fill(gridWidth); std::cout << std::endl << "Fifth test, gridSize = " << gridWidth << " no merging" << std::endl; @@ -737,11 +737,11 @@ test_regiongrowKLM1D() std::cout << "Extracting and checking approximation image" << std::endl; std::cout << "Extracting and checking label image" << std::endl; - OutputImageType::Pointer outImage5 = KLMFilter->GetOutput(); - OutputImageIterator outIt5(outImage5, outImage5->GetBufferedRegion()); + const OutputImageType::Pointer outImage5 = KLMFilter->GetOutput(); + OutputImageIterator outIt5(outImage5, outImage5->GetBufferedRegion()); - LabelledImageType::Pointer labelledImage5 = KLMFilter->GetLabelledImage(); - LabelImageIterator labelIt5(labelledImage5, labelledImage5->GetBufferedRegion()); + const LabelledImageType::Pointer labelledImage5 = KLMFilter->GetLabelledImage(); + LabelImageIterator labelIt5(labelledImage5, labelledImage5->GetBufferedRegion()); OutputImageData pixelOut5in; OutputImageData pixelOut5out; @@ -817,11 +817,11 @@ test_regiongrowKLM2D() ImageType::SizeType imageSize; imageSize[0] = 10; imageSize[1] = 20; - unsigned int numPixels = 200; + const unsigned int numPixels = 200; - ImageType::IndexType index{}; + const ImageType::IndexType index{}; - ImageType::RegionType region{ index, imageSize }; + const ImageType::RegionType region{ index, imageSize }; image->SetLargestPossibleRegion(region); image->SetBufferedRegion(region); @@ -851,13 +851,13 @@ test_regiongrowKLM2D() 4 each with value z */ - int inImageVals[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 1, 1, 9, 7, 7, 7, 6, 6, 6, 9, - 1, 1, 9, 7, 7, 7, 6, 6, 6, 9, 1, 1, 9, 7, 7, 3, 3, 6, 6, 9, 1, 1, 9, 7, 7, 7, 6, 6, 6, - 9, 1, 1, 9, 7, 7, 3, 3, 6, 6, 9, 1, 1, 9, 7, 7, 7, 6, 6, 6, 9, 1, 1, 9, 9, 9, 9, 9, 9, - 9, 9, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 1, 1, 9, 9, 9, 9, 9, - 9, 9, 9, 1, 1, 9, 7, 7, 7, 6, 6, 6, 9, 1, 1, 9, 7, 7, 3, 3, 6, 6, 9, 1, 1, 9, 7, 7, 7, - 6, 6, 6, 9, 1, 1, 9, 7, 7, 7, 6, 6, 6, 9, 1, 1, 9, 7, 7, 3, 3, 6, 6, 9, 1, 1, 9, 7, 7, - 7, 6, 6, 6, 9, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; + const int inImageVals[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 1, 1, 9, 7, 7, 7, 6, 6, 6, 9, + 1, 1, 9, 7, 7, 7, 6, 6, 6, 9, 1, 1, 9, 7, 7, 3, 3, 6, 6, 9, 1, 1, 9, 7, 7, 7, 6, 6, 6, + 9, 1, 1, 9, 7, 7, 3, 3, 6, 6, 9, 1, 1, 9, 7, 7, 7, 6, 6, 6, 9, 1, 1, 9, 9, 9, 9, 9, 9, + 9, 9, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 1, 1, 9, 9, 9, 9, 9, + 9, 9, 9, 1, 1, 9, 7, 7, 7, 6, 6, 6, 9, 1, 1, 9, 7, 7, 3, 3, 6, 6, 9, 1, 1, 9, 7, 7, 7, + 6, 6, 6, 9, 1, 1, 9, 7, 7, 7, 6, 6, 6, 9, 1, 1, 9, 7, 7, 3, 3, 6, 6, 9, 1, 1, 9, 7, 7, + 7, 6, 6, 6, 9, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; // Set up the filter @@ -873,15 +873,15 @@ test_regiongrowKLM2D() using LabelType = KLMRegionGrowImageFilterType::RegionLabelType; - LabelType labelVals[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 3, 3, 3, 3, 3, 3, 2, - 1, 1, 2, 3, 3, 3, 3, 3, 3, 2, 1, 1, 2, 3, 3, 4, 4, 3, 3, 2, 1, 1, 2, 3, 3, 3, 3, 3, 3, - 2, 1, 1, 2, 3, 3, 5, 5, 3, 3, 2, 1, 1, 2, 3, 3, 3, 3, 3, 3, 2, 1, 1, 2, 2, 2, 2, 2, 2, - 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, - 2, 2, 2, 1, 1, 2, 6, 6, 6, 6, 6, 6, 2, 1, 1, 2, 6, 6, 7, 7, 6, 6, 2, 1, 1, 2, 6, 6, 6, - 6, 6, 6, 2, 1, 1, 2, 6, 6, 6, 6, 6, 6, 2, 1, 1, 2, 6, 6, 8, 8, 6, 6, 2, 1, 1, 2, 6, 6, - 6, 6, 6, 6, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; + const LabelType labelVals[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 3, 3, 3, 3, 3, 3, 2, + 1, 1, 2, 3, 3, 3, 3, 3, 3, 2, 1, 1, 2, 3, 3, 4, 4, 3, 3, 2, 1, 1, 2, 3, 3, 3, 3, 3, 3, + 2, 1, 1, 2, 3, 3, 5, 5, 3, 3, 2, 1, 1, 2, 3, 3, 3, 3, 3, 3, 2, 1, 1, 2, 2, 2, 2, 2, 2, + 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 1, 1, 2, 6, 6, 6, 6, 6, 6, 2, 1, 1, 2, 6, 6, 7, 7, 6, 6, 2, 1, 1, 2, 6, 6, 6, + 6, 6, 6, 2, 1, 1, 2, 6, 6, 6, 6, 6, 6, 2, 1, 1, 2, 6, 6, 8, 8, 6, 6, 2, 1, 1, 2, 6, 6, + 6, 6, 6, 6, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; - double outImageVals[] = { + const double outImageVals[] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 1.0, 1.0, 9.0, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 9.0, 1.0, 1.0, 9.0, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 9.0, 1.0, 1.0, 9.0, 6.5, 6.5, 3.0, 3.0, 6.5, 6.5, 9.0, 1.0, 1.0, 9.0, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 9.0, 1.0, 1.0, 9.0, 6.5, 6.5, 3.0, 3.0, 6.5, 6.5, 9.0, @@ -937,7 +937,7 @@ test_regiongrowKLM2D() std::cout << "Extracting and checking approximation image" << std::endl; - OutputImageType::Pointer outImage = KLMFilter->GetOutput(); + const OutputImageType::Pointer outImage = KLMFilter->GetOutput(); using OutputImageIterator = itk::ImageRegionIterator; @@ -945,9 +945,9 @@ test_regiongrowKLM2D() OutputImageIterator outIt(outImage, outImage->GetBufferedRegion()); using OutputImageData = OutputImageType::PixelType::VectorType; - ImageData pixelIn; - OutputImageData pixelOut; - itk::NumericTraits::ValueType pixelOutZero{}; + ImageData pixelIn; + OutputImageData pixelOut; + const itk::NumericTraits::ValueType pixelOutZero{}; while (!inIt.IsAtEnd()) { @@ -981,7 +981,7 @@ test_regiongrowKLM2D() std::cout << "Extracting and checking label image" << std::endl; using LabelledImageType = itk::Image; - LabelledImageType::Pointer labelledImage = KLMFilter->GetLabelledImage(); + const LabelledImageType::Pointer labelledImage = KLMFilter->GetLabelledImage(); // Loop through the approximation image and check if they match the // input image @@ -1021,7 +1021,7 @@ test_regiongrowKLM2D() std::cout << std::endl << "Second test, key merging test containing duplicate borders" << std::endl; KLMFilter->SetMaximumLambda(1e45); - unsigned int nregions = 8; + const unsigned int nregions = 8; KLMFilter->SetMaximumNumberOfRegions(nregions); // Kick off the Region grow function @@ -1047,7 +1047,7 @@ test_regiongrowKLM2D() std::cout << "Extracting and checking approximation image" << std::endl; - OutputImageType::Pointer outImage2 = KLMFilter->GetOutput(); + const OutputImageType::Pointer outImage2 = KLMFilter->GetOutput(); OutputImageIterator outIt2(outImage2, outImage2->GetBufferedRegion()); @@ -1081,7 +1081,7 @@ test_regiongrowKLM2D() std::cout << "Extracting and checking label image" << std::endl; - LabelledImageType::Pointer labelledImage2 = KLMFilter->GetLabelledImage(); + const LabelledImageType::Pointer labelledImage2 = KLMFilter->GetLabelledImage(); LabelImageIterator labelIt2(labelledImage2, labelledImage2->GetBufferedRegion()); @@ -1129,11 +1129,11 @@ test_regiongrowKLM2D() KLMFilter->SetMaximumNumberOfRegions(25); KLMFilter->SetGridSize(gridSize); - double maximumLambda = 1e45; + const double maximumLambda = 1e45; KLMFilter->SetMaximumLambda(maximumLambda); ITK_TEST_SET_GET_VALUE(maximumLambda, KLMFilter->GetMaximumLambda()); - unsigned int numberOfRegions = 0; + const unsigned int numberOfRegions = 0; KLMFilter->SetNumberOfRegions(numberOfRegions); ITK_TEST_SET_GET_VALUE(numberOfRegions, KLMFilter->GetNumberOfRegions()); @@ -1158,7 +1158,7 @@ test_regiongrowKLM2D() std::cout << "Extracting and checking approximation image" << std::endl; - OutputImageType::Pointer outImage3 = KLMFilter->GetOutput(); + const OutputImageType::Pointer outImage3 = KLMFilter->GetOutput(); OutputImageIterator outIt3(outImage3, outImage3->GetBufferedRegion()); @@ -1205,16 +1205,16 @@ test_regiongrowKLM2D() return EXIT_FAILURE; } - HistogramType::ConstIterator histIt = histogram->Begin(); - HistogramType::ConstIterator histItEnd = histogram->End(); + HistogramType::ConstIterator histIt = histogram->Begin(); + const HistogramType::ConstIterator histItEnd = histogram->End(); - double Sum = histogram->GetTotalFrequency(); - double labelEntropy = 0.0; + const double Sum = histogram->GetTotalFrequency(); + double labelEntropy = 0.0; while (histIt != histItEnd) { - double probability = histIt.GetFrequency() / Sum; + const double probability = histIt.GetFrequency() / Sum; if (itk::Math::AlmostEquals(probability, 0.0)) { @@ -1228,7 +1228,7 @@ test_regiongrowKLM2D() } labelEntropy /= std::log(2.0); - double idealEntropy = -std::log(8.0 / numPixels) / std::log(2.0); + const double idealEntropy = -std::log(8.0 / numPixels) / std::log(2.0); std::cout << "Label entropy = " << labelEntropy << " bits " << std::endl; std::cout << "Ideal entropy = " << idealEntropy << " bits " << std::endl; @@ -1266,11 +1266,11 @@ test_regiongrowKLM3D() imageSize[0] = 10; imageSize[1] = 20; imageSize[2] = 3; - unsigned int numPixels = 10 * 20 * 3; + const unsigned int numPixels = 10 * 20 * 3; - ImageType::IndexType index{}; + const ImageType::IndexType index{}; - ImageType::RegionType region{ index, imageSize }; + const ImageType::RegionType region{ index, imageSize }; image->SetLargestPossibleRegion(region); image->SetBufferedRegion(region); @@ -1300,7 +1300,7 @@ test_regiongrowKLM3D() 4 each with value z */ - int inImageVals[] = { + const int inImageVals[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -1337,7 +1337,7 @@ test_regiongrowKLM3D() using LabelType = KLMRegionGrowImageFilterType::RegionLabelType; - LabelType labelVals[] = { + const LabelType labelVals[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -1360,7 +1360,7 @@ test_regiongrowKLM3D() 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; - float outImageVals[] = { + const float outImageVals[] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, @@ -1417,7 +1417,7 @@ test_regiongrowKLM3D() KLMFilter->SetMaximumLambda(-1); - unsigned int numberOfRegions = 0; + const unsigned int numberOfRegions = 0; KLMFilter->SetNumberOfRegions(numberOfRegions); ITK_TEST_SET_GET_VALUE(numberOfRegions, KLMFilter->GetNumberOfRegions()); @@ -1444,7 +1444,7 @@ test_regiongrowKLM3D() std::cout << "Extracting and checking approximation image" << std::endl; - OutputImageType::Pointer outImage = KLMFilter->GetOutput(); + const OutputImageType::Pointer outImage = KLMFilter->GetOutput(); using OutputImageIterator = itk::ImageRegionIterator; @@ -1452,9 +1452,9 @@ test_regiongrowKLM3D() OutputImageIterator outIt(outImage, outImage->GetBufferedRegion()); using OutputImageData = OutputImageType::PixelType::VectorType; - ImageData pixelIn; - OutputImageData pixelOut; - itk::NumericTraits::ValueType pixelOutZero{}; + ImageData pixelIn; + OutputImageData pixelOut; + const itk::NumericTraits::ValueType pixelOutZero{}; while (!inIt.IsAtEnd()) { @@ -1488,7 +1488,7 @@ test_regiongrowKLM3D() std::cout << "Extracting and checking label image" << std::endl; using LabelledImageType = itk::Image; - LabelledImageType::Pointer labelledImage = KLMFilter->GetLabelledImage(); + const LabelledImageType::Pointer labelledImage = KLMFilter->GetLabelledImage(); // Loop through the approximation image and check if they match the // input image @@ -1528,7 +1528,7 @@ test_regiongrowKLM3D() std::cout << std::endl << "Second test, key merging test containing duplicate borders" << std::endl; KLMFilter->SetMaximumLambda(1e45); - unsigned int nregions = 8; + const unsigned int nregions = 8; KLMFilter->SetMaximumNumberOfRegions(nregions); // Kick off the Region grow function @@ -1554,7 +1554,7 @@ test_regiongrowKLM3D() std::cout << "Extracting and checking approximation image" << std::endl; - OutputImageType::Pointer outImage2 = KLMFilter->GetOutput(); + const OutputImageType::Pointer outImage2 = KLMFilter->GetOutput(); OutputImageIterator outIt2(outImage2, outImage2->GetBufferedRegion()); @@ -1587,7 +1587,7 @@ test_regiongrowKLM3D() std::cout << "Extracting and checking label image" << std::endl; - LabelledImageType::Pointer labelledImage2 = KLMFilter->GetLabelledImage(); + const LabelledImageType::Pointer labelledImage2 = KLMFilter->GetLabelledImage(); LabelImageIterator labelIt2(labelledImage2, labelledImage2->GetBufferedRegion()); @@ -1657,7 +1657,7 @@ test_regiongrowKLM3D() std::cout << "Extracting and checking approximation image" << std::endl; - OutputImageType::Pointer outImage3 = KLMFilter->GetOutput(); + const OutputImageType::Pointer outImage3 = KLMFilter->GetOutput(); OutputImageIterator outIt3(outImage3, outImage3->GetBufferedRegion()); @@ -1704,16 +1704,16 @@ test_regiongrowKLM3D() return EXIT_FAILURE; } - HistogramType::ConstIterator histIt = histogram->Begin(); - HistogramType::ConstIterator histItEnd = histogram->End(); + HistogramType::ConstIterator histIt = histogram->Begin(); + const HistogramType::ConstIterator histItEnd = histogram->End(); - double Sum = histogram->GetTotalFrequency(); - double labelEntropy = 0.0; + const double Sum = histogram->GetTotalFrequency(); + double labelEntropy = 0.0; while (histIt != histItEnd) { - double probability = histIt.GetFrequency() / Sum; + const double probability = histIt.GetFrequency() / Sum; if (itk::Math::AlmostEquals(probability, 0.0)) { @@ -1727,7 +1727,7 @@ test_regiongrowKLM3D() } labelEntropy /= std::log(2.0); - double idealEntropy = -std::log(8.0 / numPixels) / std::log(2.0); + const double idealEntropy = -std::log(8.0 / numPixels) / std::log(2.0); std::cout << "Label entropy = " << labelEntropy << " bits " << std::endl; std::cout << "Ideal entropy = " << idealEntropy << " bits " << std::endl; @@ -1762,16 +1762,16 @@ test_regiongrowKLM4D() auto image = ImageType::New(); ImageType::SizeType imageSize; - int multVal = 2; + const int multVal = 2; imageSize[0] = 2 * multVal; imageSize[1] = 3 * multVal; imageSize[2] = 5 * multVal; imageSize[3] = 7 * multVal; - unsigned int numPixels = imageSize[0] * imageSize[1] * imageSize[2] * imageSize[3]; + const unsigned int numPixels = imageSize[0] * imageSize[1] * imageSize[2] * imageSize[3]; - ImageType::IndexType index{}; + const ImageType::IndexType index{}; - ImageType::RegionType region{ index, imageSize }; + const ImageType::RegionType region{ index, imageSize }; image->SetLargestPossibleRegion(region); image->SetBufferedRegion(region); @@ -1852,7 +1852,7 @@ test_regiongrowKLM4D() std::cout << "Extracting and checking approximation image" << std::endl; - OutputImageType::Pointer outImage = KLMFilter->GetOutput(); + const OutputImageType::Pointer outImage = KLMFilter->GetOutput(); using OutputImageIterator = itk::ImageRegionIterator; @@ -1860,9 +1860,9 @@ test_regiongrowKLM4D() OutputImageIterator outIt(outImage, outImage->GetBufferedRegion()); using OutputImageData = OutputImageType::PixelType::VectorType; - ImageData pixelIn; - OutputImageData pixelOut; - itk::NumericTraits::ValueType pixelOutZero{}; + ImageData pixelIn; + OutputImageData pixelOut; + const itk::NumericTraits::ValueType pixelOutZero{}; while (!inIt.IsAtEnd()) { @@ -1888,7 +1888,7 @@ test_regiongrowKLM4D() std::cout << "Extracting and checking label image" << std::endl; using LabelledImageType = itk::Image; - LabelledImageType::Pointer labelledImage = KLMFilter->GetLabelledImage(); + const LabelledImageType::Pointer labelledImage = KLMFilter->GetLabelledImage(); // Loop through the approximation image and check if they match the // input image @@ -1952,7 +1952,7 @@ test_regiongrowKLM4D() std::cout << "Extracting and checking approximation image" << std::endl; - OutputImageType::Pointer outImage2 = KLMFilter->GetOutput(); + const OutputImageType::Pointer outImage2 = KLMFilter->GetOutput(); OutputImageIterator outIt2(outImage2, outImage2->GetBufferedRegion()); @@ -1977,7 +1977,7 @@ test_regiongrowKLM4D() std::cout << "Extracting and checking label image" << std::endl; - LabelledImageType::Pointer labelledImage2 = KLMFilter->GetLabelledImage(); + const LabelledImageType::Pointer labelledImage2 = KLMFilter->GetLabelledImage(); LabelImageIterator labelIt2(labelledImage2, labelledImage2->GetBufferedRegion()); @@ -2051,7 +2051,7 @@ test_regiongrowKLM4D() std::cout << "Extracting and checking approximation image" << std::endl; - OutputImageType::Pointer outImage3 = KLMFilter->GetOutput(); + const OutputImageType::Pointer outImage3 = KLMFilter->GetOutput(); OutputImageIterator outIt3(outImage3, outImage3->GetBufferedRegion()); @@ -2091,16 +2091,16 @@ test_regiongrowKLM4D() return EXIT_FAILURE; } - HistogramType::ConstIterator histIt = histogram->Begin(); - HistogramType::ConstIterator histItEnd = histogram->End(); + HistogramType::ConstIterator histIt = histogram->Begin(); + const HistogramType::ConstIterator histItEnd = histogram->End(); - double Sum = histogram->GetTotalFrequency(); - double labelEntropy = 0.0; + const double Sum = histogram->GetTotalFrequency(); + double labelEntropy = 0.0; while (histIt != histItEnd) { - double probability = histIt.GetFrequency() / Sum; + const double probability = histIt.GetFrequency() / Sum; if (itk::Math::AlmostEquals(probability, 0.0)) { @@ -2114,7 +2114,7 @@ test_regiongrowKLM4D() } labelEntropy /= std::log(2.0); - double idealEntropy = -std::log(1.0 / KLMFilter->GetNumberOfRegions()) / std::log(2.0); + const double idealEntropy = -std::log(1.0 / KLMFilter->GetNumberOfRegions()) / std::log(2.0); std::cout << "Label entropy = " << labelEntropy << " bits " << std::endl; std::cout << "Ideal entropy = " << idealEntropy << " bits " << std::endl; diff --git a/Modules/Segmentation/LabelVoting/include/itkBinaryMedianImageFilter.hxx b/Modules/Segmentation/LabelVoting/include/itkBinaryMedianImageFilter.hxx index b541438144d..00f37f8f189 100644 --- a/Modules/Segmentation/LabelVoting/include/itkBinaryMedianImageFilter.hxx +++ b/Modules/Segmentation/LabelVoting/include/itkBinaryMedianImageFilter.hxx @@ -48,8 +48,8 @@ BinaryMedianImageFilter::GenerateInputRequestedRegion Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); - typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); + const typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); + const typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -97,12 +97,12 @@ BinaryMedianImageFilter::DynamicThreadedGenerateData( ImageRegionIterator it; // Allocate output - typename OutputImageType::Pointer output = this->GetOutput(); - typename InputImageType::ConstPointer input = this->GetInput(); + const typename OutputImageType::Pointer output = this->GetOutput(); + const typename InputImageType::ConstPointer input = this->GetInput(); // Find the data-set boundary "faces" - NeighborhoodAlgorithm::ImageBoundaryFacesCalculator bC; - typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = + NeighborhoodAlgorithm::ImageBoundaryFacesCalculator bC; + const typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = bC(input, outputRegionForThread, m_Radius); TotalProgressReporter progress(this, output->GetRequestedRegion().GetNumberOfPixels()); @@ -116,12 +116,12 @@ BinaryMedianImageFilter::DynamicThreadedGenerateData( bit.OverrideBoundaryCondition(&nbc); bit.GoToBegin(); - unsigned int neighborhoodSize = bit.Size(); + const unsigned int neighborhoodSize = bit.Size(); // All of our neighborhoods have an odd number of pixels, so there is // always a median index (if there where an even number of pixels // in the neighborhood we have to average the middle two values). - unsigned int medianPosition = neighborhoodSize / 2; + const unsigned int medianPosition = neighborhoodSize / 2; while (!bit.IsAtEnd()) { @@ -129,7 +129,7 @@ BinaryMedianImageFilter::DynamicThreadedGenerateData( unsigned int count = 0; for (unsigned int i = 0; i < neighborhoodSize; ++i) { - InputPixelType value = bit.GetPixel(i); + const InputPixelType value = bit.GetPixel(i); if (Math::ExactlyEquals(value, m_ForegroundValue)) { ++count; diff --git a/Modules/Segmentation/LabelVoting/include/itkLabelVotingImageFilter.hxx b/Modules/Segmentation/LabelVoting/include/itkLabelVotingImageFilter.hxx index ab3e775c3c3..c35ca1d5d1e 100644 --- a/Modules/Segmentation/LabelVoting/include/itkLabelVotingImageFilter.hxx +++ b/Modules/Segmentation/LabelVoting/include/itkLabelVotingImageFilter.hxx @@ -77,7 +77,7 @@ LabelVotingImageFilter::BeforeThreadedGenerateData() } // Allocate the output image - typename TOutputImage::Pointer output = this->GetOutput(); + const typename TOutputImage::Pointer output = this->GetOutput(); output->SetBufferedRegion(output->GetRequestedRegion()); output->Allocate(); } @@ -90,7 +90,7 @@ LabelVotingImageFilter::DynamicThreadedGenerateData( using IteratorType = ImageRegionConstIterator; using OutIteratorType = ImageRegionIterator; - typename TOutputImage::Pointer output = this->GetOutput(); + const typename TOutputImage::Pointer output = this->GetOutput(); TotalProgressReporter progress(this, output->GetRequestedRegion().GetNumberOfPixels()); diff --git a/Modules/Segmentation/LabelVoting/include/itkMultiLabelSTAPLEImageFilter.hxx b/Modules/Segmentation/LabelVoting/include/itkMultiLabelSTAPLEImageFilter.hxx index 53421936157..e1b33bd0cf0 100644 --- a/Modules/Segmentation/LabelVoting/include/itkMultiLabelSTAPLEImageFilter.hxx +++ b/Modules/Segmentation/LabelVoting/include/itkMultiLabelSTAPLEImageFilter.hxx @@ -52,7 +52,7 @@ MultiLabelSTAPLEImageFilter::GenerateInputR for (unsigned int k = 0; k < this->GetNumberOfInputs(); ++k) { - InputImagePointer input = const_cast(this->GetInput(k)); + const InputImagePointer input = const_cast(this->GetInput(k)); input->SetRequestedRegionToLargestPossibleRegion(); } } @@ -123,7 +123,7 @@ MultiLabelSTAPLEImageFilter::InitializeConf typename OutputImageType::Pointer votingOutput; { // begin scope for local filter allocation - LabelVotingFilterPointer votingFilter = LabelVotingFilterType::New(); + const LabelVotingFilterPointer votingFilter = LabelVotingFilterType::New(); for (unsigned int k = 0; k < numberOfInputs; ++k) { @@ -233,7 +233,7 @@ MultiLabelSTAPLEImageFilter::GenerateData() this->InitializePriorProbabilities(); // Allocate the output image. - typename TOutputImage::Pointer output = this->GetOutput(); + const typename TOutputImage::Pointer output = this->GetOutput(); output->SetBufferedRegion(output->GetRequestedRegion()); output->Allocate(); diff --git a/Modules/Segmentation/LabelVoting/include/itkVotingBinaryHoleFillingImageFilter.hxx b/Modules/Segmentation/LabelVoting/include/itkVotingBinaryHoleFillingImageFilter.hxx index 247f38abd5e..e4074a6a7fe 100644 --- a/Modules/Segmentation/LabelVoting/include/itkVotingBinaryHoleFillingImageFilter.hxx +++ b/Modules/Segmentation/LabelVoting/include/itkVotingBinaryHoleFillingImageFilter.hxx @@ -62,7 +62,7 @@ VotingBinaryHoleFillingImageFilter::BeforeThreadedGen this->m_NumberOfPixelsChanged = 0; - unsigned int numberOfWorkUnits = this->GetNumberOfWorkUnits(); + const unsigned int numberOfWorkUnits = this->GetNumberOfWorkUnits(); this->m_Count.SetSize(numberOfWorkUnits); for (unsigned int i = 0; i < numberOfWorkUnits; ++i) { @@ -82,12 +82,12 @@ VotingBinaryHoleFillingImageFilter::ThreadedGenerateD ImageRegionIterator it; // Allocate output - typename OutputImageType::Pointer output = this->GetOutput(); - typename InputImageType::ConstPointer input = this->GetInput(); + const typename OutputImageType::Pointer output = this->GetOutput(); + const typename InputImageType::ConstPointer input = this->GetInput(); // Find the data-set boundary "faces" - NeighborhoodAlgorithm::ImageBoundaryFacesCalculator bC; - typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = + NeighborhoodAlgorithm::ImageBoundaryFacesCalculator bC; + const typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = bC(input, outputRegionForThread, this->GetRadius()); ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels()); @@ -107,7 +107,7 @@ VotingBinaryHoleFillingImageFilter::ThreadedGenerateD bit.OverrideBoundaryCondition(&nbc); bit.GoToBegin(); - unsigned int neighborhoodSize = bit.Size(); + const unsigned int neighborhoodSize = bit.Size(); while (!bit.IsAtEnd()) { @@ -119,7 +119,7 @@ VotingBinaryHoleFillingImageFilter::ThreadedGenerateD unsigned int count = 0; for (unsigned int i = 0; i < neighborhoodSize; ++i) { - InputPixelType value = bit.GetPixel(i); + const InputPixelType value = bit.GetPixel(i); if (value == foregroundValue) { ++count; @@ -154,7 +154,7 @@ VotingBinaryHoleFillingImageFilter::AfterThreadedGene { this->m_NumberOfPixelsChanged = SizeValueType{}; - unsigned int numberOfWorkUnits = this->GetNumberOfWorkUnits(); + const unsigned int numberOfWorkUnits = this->GetNumberOfWorkUnits(); this->m_Count.SetSize(numberOfWorkUnits); for (unsigned int t = 0; t < numberOfWorkUnits; ++t) { diff --git a/Modules/Segmentation/LabelVoting/include/itkVotingBinaryImageFilter.hxx b/Modules/Segmentation/LabelVoting/include/itkVotingBinaryImageFilter.hxx index 6704082e11e..be9f89adffd 100644 --- a/Modules/Segmentation/LabelVoting/include/itkVotingBinaryImageFilter.hxx +++ b/Modules/Segmentation/LabelVoting/include/itkVotingBinaryImageFilter.hxx @@ -48,8 +48,8 @@ VotingBinaryImageFilter::GenerateInputRequestedRegion Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); - typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); + const typename Superclass::InputImagePointer inputPtr = const_cast(this->GetInput()); + const typename Superclass::OutputImagePointer outputPtr = this->GetOutput(); if (!inputPtr || !outputPtr) { @@ -96,12 +96,12 @@ VotingBinaryImageFilter::DynamicThreadedGenerateData( ConstNeighborhoodIterator bit; ImageRegionIterator it; - typename OutputImageType::Pointer output = this->GetOutput(); - typename InputImageType::ConstPointer input = this->GetInput(); + const typename OutputImageType::Pointer output = this->GetOutput(); + const typename InputImageType::ConstPointer input = this->GetInput(); // Find the data-set boundary "faces" - NeighborhoodAlgorithm::ImageBoundaryFacesCalculator bC; - typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = + NeighborhoodAlgorithm::ImageBoundaryFacesCalculator bC; + const typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator::FaceListType faceList = bC(input, outputRegionForThread, m_Radius); TotalProgressReporter progress(this, output->GetRequestedRegion().GetNumberOfPixels()); @@ -114,7 +114,7 @@ VotingBinaryImageFilter::DynamicThreadedGenerateData( bit.OverrideBoundaryCondition(&nbc); bit.GoToBegin(); - unsigned int neighborhoodSize = bit.Size(); + const unsigned int neighborhoodSize = bit.Size(); while (!bit.IsAtEnd()) { @@ -124,7 +124,7 @@ VotingBinaryImageFilter::DynamicThreadedGenerateData( unsigned int count = 0; for (unsigned int i = 0; i < neighborhoodSize; ++i) { - InputPixelType value = bit.GetPixel(i); + const InputPixelType value = bit.GetPixel(i); if (value == m_ForegroundValue) { ++count; diff --git a/Modules/Segmentation/LabelVoting/test/itkBinaryMedianImageFilterTest.cxx b/Modules/Segmentation/LabelVoting/test/itkBinaryMedianImageFilterTest.cxx index 44c1ea21135..2cd4160dba2 100644 --- a/Modules/Segmentation/LabelVoting/test/itkBinaryMedianImageFilterTest.cxx +++ b/Modules/Segmentation/LabelVoting/test/itkBinaryMedianImageFilterTest.cxx @@ -46,8 +46,8 @@ itkBinaryMedianImageFilterTest(int, char *[]) ImageType::PointValueType origin[2] = { 15, 400 }; random->SetOrigin(origin); - ImageType::PixelType foreground = 97; // prime numbers are good testers - ImageType::PixelType background = 29; + const ImageType::PixelType foreground = 97; // prime numbers are good testers + const ImageType::PixelType background = 29; itk::BinaryThresholdImageFilter::Pointer thresholder; thresholder = itk::BinaryThresholdImageFilter::New(); diff --git a/Modules/Segmentation/LabelVoting/test/itkMultiLabelSTAPLEImageFilterTest.cxx b/Modules/Segmentation/LabelVoting/test/itkMultiLabelSTAPLEImageFilterTest.cxx index baac3dc29d3..bb2bc86029c 100644 --- a/Modules/Segmentation/LabelVoting/test/itkMultiLabelSTAPLEImageFilterTest.cxx +++ b/Modules/Segmentation/LabelVoting/test/itkMultiLabelSTAPLEImageFilterTest.cxx @@ -60,9 +60,9 @@ itkMultiLabelSTAPLEImageFilterTest(int, char *[]) using ImageTypePointer = ImageType::Pointer; // Create two images - ImageTypePointer inputImageA = ImageType::New(); - ImageTypePointer inputImageB = ImageType::New(); - ImageTypePointer inputImageC = ImageType::New(); + const ImageTypePointer inputImageA = ImageType::New(); + const ImageTypePointer inputImageB = ImageType::New(); + const ImageTypePointer inputImageC = ImageType::New(); RegionType region; { @@ -113,12 +113,12 @@ itkMultiLabelSTAPLEImageFilterTest(int, char *[]) } // Create an LabelVoting Filter - FilterTypePointer filter = FilterType::New(); + const FilterTypePointer filter = FilterType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, MultiLabelSTAPLEImageFilter, ImageToImageFilter); // Get the Smart Pointer to the Filter Output - ImageTypePointer outputImage = filter->GetOutput(); + const ImageTypePointer outputImage = filter->GetOutput(); // Test first two input images with undecided label set to 255 @@ -128,7 +128,7 @@ itkMultiLabelSTAPLEImageFilterTest(int, char *[]) ITK_TEST_EXPECT_TRUE(!filter->GetHasMaximumNumberOfIterations()); - unsigned int maximumNumberOfIterations = 100; + const unsigned int maximumNumberOfIterations = 100; filter->SetMaximumNumberOfIterations(maximumNumberOfIterations); ITK_TEST_SET_GET_VALUE(maximumNumberOfIterations, filter->GetMaximumNumberOfIterations()); @@ -138,12 +138,12 @@ itkMultiLabelSTAPLEImageFilterTest(int, char *[]) filter->UnsetMaximumNumberOfIterations(); - typename FilterType::WeightsType terminationUpdateThreshold = 1e-5; + const typename FilterType::WeightsType terminationUpdateThreshold = 1e-5; filter->SetTerminationUpdateThreshold(terminationUpdateThreshold); ITK_TEST_SET_GET_VALUE(terminationUpdateThreshold, filter->GetTerminationUpdateThreshold()); // Set label for undecided pixels - typename FilterType::OutputPixelType labelForUndecidedPixels = 255; + const typename FilterType::OutputPixelType labelForUndecidedPixels = 255; filter->SetLabelForUndecidedPixels(labelForUndecidedPixels); ITK_TEST_SET_GET_VALUE(labelForUndecidedPixels, filter->GetLabelForUndecidedPixels()); @@ -151,8 +151,8 @@ itkMultiLabelSTAPLEImageFilterTest(int, char *[]) ITK_TEST_EXPECT_TRUE(!filter->GetHasPriorProbabilities()); - typename FilterType::PriorProbabilitiesType::ValueType priorProbabilitiesVal(0.0); - typename FilterType::PriorProbabilitiesType priorProbabilities(1); + const typename FilterType::PriorProbabilitiesType::ValueType priorProbabilitiesVal(0.0); + typename FilterType::PriorProbabilitiesType priorProbabilities(1); priorProbabilities.Fill(priorProbabilitiesVal); filter->SetPriorProbabilities(priorProbabilities); ITK_TEST_SET_GET_VALUE(priorProbabilities, filter->GetPriorProbabilities()); diff --git a/Modules/Segmentation/LabelVoting/test/itkVotingBinaryHoleFillingImageFilterTest.cxx b/Modules/Segmentation/LabelVoting/test/itkVotingBinaryHoleFillingImageFilterTest.cxx index 8cf2c026f98..ef8b891c75e 100644 --- a/Modules/Segmentation/LabelVoting/test/itkVotingBinaryHoleFillingImageFilterTest.cxx +++ b/Modules/Segmentation/LabelVoting/test/itkVotingBinaryHoleFillingImageFilterTest.cxx @@ -52,10 +52,10 @@ itkVotingBinaryHoleFillingImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); - InputImageType::PixelType foreground = 97; // Prime numbers are good testers - InputImageType::PixelType background = 29; + const InputImageType::PixelType foreground = 97; // Prime numbers are good testers + const InputImageType::PixelType background = 29; - itk::BinaryThresholdImageFilter::Pointer thresholder = + const itk::BinaryThresholdImageFilter::Pointer thresholder = itk::BinaryThresholdImageFilter::New(); thresholder->SetInput(reader->GetOutput()); @@ -80,7 +80,7 @@ itkVotingBinaryHoleFillingImageFilterTest(int argc, char * argv[]) // Set the number of pixels over 50% that will tip the decision about // switching a pixel - unsigned int majorityThreshold = 1; + const unsigned int majorityThreshold = 1; voting->SetMajorityThreshold(majorityThreshold); ITK_TEST_SET_GET_VALUE(majorityThreshold, voting->GetMajorityThreshold()); diff --git a/Modules/Segmentation/LabelVoting/test/itkVotingBinaryImageFilterTest.cxx b/Modules/Segmentation/LabelVoting/test/itkVotingBinaryImageFilterTest.cxx index 6859b5bf222..03288e14e43 100644 --- a/Modules/Segmentation/LabelVoting/test/itkVotingBinaryImageFilterTest.cxx +++ b/Modules/Segmentation/LabelVoting/test/itkVotingBinaryImageFilterTest.cxx @@ -99,7 +99,7 @@ itkVotingBinaryImageFilterTest(int argc, char * argv[]) const long backgroundValue = atol(argv[5]); - itk::ImageIOBase::Pointer iobase = + const itk::ImageIOBase::Pointer iobase = itk::ImageIOFactory::CreateImageIO(infname.c_str(), itk::ImageIOFactory::IOFileModeEnum::ReadMode); if (iobase.IsNull()) diff --git a/Modules/Segmentation/LabelVoting/test/itkVotingBinaryIterativeHoleFillingImageFilterTest.cxx b/Modules/Segmentation/LabelVoting/test/itkVotingBinaryIterativeHoleFillingImageFilterTest.cxx index 264f2d433c8..db13bc4c0dc 100644 --- a/Modules/Segmentation/LabelVoting/test/itkVotingBinaryIterativeHoleFillingImageFilterTest.cxx +++ b/Modules/Segmentation/LabelVoting/test/itkVotingBinaryIterativeHoleFillingImageFilterTest.cxx @@ -47,8 +47,8 @@ itkVotingBinaryIterativeHoleFillingImageFilterTest(int, char *[]) ImageType::PointValueType origin[2] = { 15, 400 }; random->SetOrigin(origin); - ImageType::PixelType foreground = 97; // prime numbers are good testers - ImageType::PixelType background = 29; + const ImageType::PixelType foreground = 97; // prime numbers are good testers + const ImageType::PixelType background = 29; itk::BinaryThresholdImageFilter::Pointer thresholder; thresholder = itk::BinaryThresholdImageFilter::New(); @@ -80,17 +80,17 @@ itkVotingBinaryIterativeHoleFillingImageFilterTest(int, char *[]) // Set the maximum number of times the filter should perform passes filling // the border of holes and cavities. - unsigned int maximumNumberOfIterations = 10; + const unsigned int maximumNumberOfIterations = 10; voting->SetMaximumNumberOfIterations(maximumNumberOfIterations); ITK_TEST_SET_GET_VALUE(maximumNumberOfIterations, voting->GetMaximumNumberOfIterations()); - unsigned int currentNumberOfIterations = 0; + const unsigned int currentNumberOfIterations = 0; voting->SetCurrentNumberOfIterations(currentNumberOfIterations); ITK_TEST_SET_GET_VALUE(currentNumberOfIterations, voting->GetCurrentNumberOfIterations()); // Set the number of pixels over 50% that will tip the decision about // switching a pixel. - unsigned int majorityThreshold = 1; + const unsigned int majorityThreshold = 1; voting->SetMajorityThreshold(majorityThreshold); ITK_TEST_SET_GET_VALUE(majorityThreshold, voting->GetMajorityThreshold()); diff --git a/Modules/Segmentation/LevelSets/include/itkBinaryMaskToNarrowBandPointSetFilter.hxx b/Modules/Segmentation/LevelSets/include/itkBinaryMaskToNarrowBandPointSetFilter.hxx index d2575be90a2..9f639e28cf8 100644 --- a/Modules/Segmentation/LevelSets/include/itkBinaryMaskToNarrowBandPointSetFilter.hxx +++ b/Modules/Segmentation/LevelSets/include/itkBinaryMaskToNarrowBandPointSetFilter.hxx @@ -44,9 +44,9 @@ BinaryMaskToNarrowBandPointSetFilter::BinaryMaskToNarr m_DistanceFilter->NarrowBandingOn(); m_DistanceFilter->SetNarrowBandwidth(m_BandWidth); - PointDataContainerPointer pointData = PointDataContainer::New(); + const PointDataContainerPointer pointData = PointDataContainer::New(); - OutputMeshPointer mesh = this->GetOutput(); + const OutputMeshPointer mesh = this->GetOutput(); mesh->SetPointData(pointData); } @@ -95,19 +95,19 @@ BinaryMaskToNarrowBandPointSetFilter::GenerateData() m_DistanceFilter->Update(); - OutputMeshPointer mesh = this->GetOutput(); - InputImageConstPointer image = this->GetInput(0); + const OutputMeshPointer mesh = this->GetOutput(); + const InputImageConstPointer image = this->GetInput(0); - PointsContainerPointer points = PointsContainer::New(); - PointDataContainerPointer pointData = PointDataContainer::New(); + const PointsContainerPointer points = PointsContainer::New(); + const PointDataContainerPointer pointData = PointDataContainer::New(); - NodeContainerPointer nodes = m_DistanceFilter->GetOutputNarrowBand(); + const NodeContainerPointer nodes = m_DistanceFilter->GetOutputNarrowBand(); - typename std::vector::size_type numberOfPixels = nodes->Size(); - ProgressReporter progress(this, 0, static_cast(numberOfPixels)); + const typename std::vector::size_type numberOfPixels = nodes->Size(); + ProgressReporter progress(this, 0, static_cast(numberOfPixels)); - typename NodeContainer::ConstIterator nodeItr = nodes->Begin(); - typename NodeContainer::ConstIterator lastNode = nodes->End(); + typename NodeContainer::ConstIterator nodeItr = nodes->Begin(); + const typename NodeContainer::ConstIterator lastNode = nodes->End(); PointType point; diff --git a/Modules/Segmentation/LevelSets/include/itkCollidingFrontsImageFilter.hxx b/Modules/Segmentation/LevelSets/include/itkCollidingFrontsImageFilter.hxx index 75d4a978b4f..b1d1d4495e3 100644 --- a/Modules/Segmentation/LevelSets/include/itkCollidingFrontsImageFilter.hxx +++ b/Modules/Segmentation/LevelSets/include/itkCollidingFrontsImageFilter.hxx @@ -83,16 +83,16 @@ CollidingFrontsImageFilter::GenerateData() multiplyFilter->SetInput2(fastMarchingFilter2->GetGradientImage()); multiplyFilter->Update(); - OutputImagePointer multipliedImage = multiplyFilter->GetOutput(); - typename NodeContainer::ConstIterator pointsIter1 = m_SeedPoints1->Begin(); - typename NodeContainer::ConstIterator pointsEnd1 = m_SeedPoints1->End(); + const OutputImagePointer multipliedImage = multiplyFilter->GetOutput(); + typename NodeContainer::ConstIterator pointsIter1 = m_SeedPoints1->Begin(); + const typename NodeContainer::ConstIterator pointsEnd1 = m_SeedPoints1->End(); for (; pointsIter1 != pointsEnd1; ++pointsIter1) { multipliedImage->SetPixel(pointsIter1.Value().GetIndex(), m_NegativeEpsilon); } - typename NodeContainer::ConstIterator pointsIter2 = m_SeedPoints2->Begin(); - typename NodeContainer::ConstIterator pointsEnd2 = m_SeedPoints2->End(); + typename NodeContainer::ConstIterator pointsIter2 = m_SeedPoints2->Begin(); + const typename NodeContainer::ConstIterator pointsEnd2 = m_SeedPoints2->End(); for (; pointsIter2 != pointsEnd2; ++pointsIter2) { multipliedImage->SetPixel(pointsIter2.Value().GetIndex(), m_NegativeEpsilon); @@ -100,9 +100,9 @@ CollidingFrontsImageFilter::GenerateData() if (m_ApplyConnectivity) { - OutputImagePointer outputImage = this->GetOutput(); + const OutputImagePointer outputImage = this->GetOutput(); - OutputImageRegionType region = outputImage->GetRequestedRegion(); + const OutputImageRegionType region = outputImage->GetRequestedRegion(); outputImage->SetBufferedRegion(region); outputImage->AllocateInitialized(); diff --git a/Modules/Segmentation/LevelSets/include/itkExtensionVelocitiesImageFilter.hxx b/Modules/Segmentation/LevelSets/include/itkExtensionVelocitiesImageFilter.hxx index a96ace5d9a2..b9867a875a1 100644 --- a/Modules/Segmentation/LevelSets/include/itkExtensionVelocitiesImageFilter.hxx +++ b/Modules/Segmentation/LevelSets/include/itkExtensionVelocitiesImageFilter.hxx @@ -37,7 +37,7 @@ ExtensionVelocitiesImageFilter::ExtensionVe for (unsigned int k = 0; k < VAuxDimension; ++k) { - AuxImagePointer ptr = AuxImageType::New(); + const AuxImagePointer ptr = AuxImageType::New(); this->ProcessObject::SetNthOutput(k + 1, ptr.GetPointer()); } } @@ -120,13 +120,13 @@ ExtensionVelocitiesImageFilter::AllocateOut // allocate memory for the output images for (unsigned int k = 0; k < VAuxDimension; ++k) { - AuxImagePointer output = this->GetOutputVelocityImage(k); + const AuxImagePointer output = this->GetOutputVelocityImage(k); output->SetBufferedRegion(output->GetRequestedRegion()); output->Allocate(); } // set the marcher output size - LevelSetPointer outputPtr = this->GetOutput(); + const LevelSetPointer outputPtr = this->GetOutput(); m_Marcher->SetOutputSize(outputPtr->GetRequestedRegion().GetSize()); } @@ -137,11 +137,11 @@ template void ExtensionVelocitiesImageFilter::GenerateDataFull() { - LevelSetConstPointer inputPtr = this->GetInput(); - LevelSetPointer outputPtr = this->GetOutput(); - LevelSetPointer tempLevelSet = m_Marcher->GetOutput(); + const LevelSetConstPointer inputPtr = this->GetInput(); + const LevelSetPointer outputPtr = this->GetOutput(); + const LevelSetPointer tempLevelSet = m_Marcher->GetOutput(); - double levelSetValue = this->GetLevelSetValue(); + const double levelSetValue = this->GetLevelSetValue(); // define iterators using LocalLevelSetImageType = typename LevelSetType::LevelSetImageType; @@ -160,7 +160,7 @@ ExtensionVelocitiesImageFilter::GenerateDat for (unsigned int k = 0; k < VAuxDimension; ++k) { - AuxImagePointer ptr = this->GetOutputVelocityImage(k); + const AuxImagePointer ptr = this->GetOutputVelocityImage(k); auxOutputIt[k] = AuxIteratorType(ptr, ptr->GetBufferedRegion()); } @@ -186,7 +186,7 @@ ExtensionVelocitiesImageFilter::GenerateDat for (unsigned int k = 0; k < VAuxDimension; ++k) { - AuxImagePointer ptr = m_Marcher->GetAuxiliaryImage(k); + const AuxImagePointer ptr = m_Marcher->GetAuxiliaryImage(k); auxTempIt[k] = AuxIteratorType(ptr, ptr->GetBufferedRegion()); } @@ -272,13 +272,13 @@ template void ExtensionVelocitiesImageFilter::GenerateDataNarrowBand() { - LevelSetConstPointer inputPtr = this->GetInput(); - LevelSetPointer outputPtr = this->GetOutput(); - LevelSetPointer tempLevelSet = m_Marcher->GetOutput(); + const LevelSetConstPointer inputPtr = this->GetInput(); + const LevelSetPointer outputPtr = this->GetOutput(); + const LevelSetPointer tempLevelSet = m_Marcher->GetOutput(); - double levelSetValue = this->GetLevelSetValue(); - double outputBandwidth = this->GetOutputNarrowBandwidth(); - double inputBandwidth = this->GetInputNarrowBandwidth(); + const double levelSetValue = this->GetLevelSetValue(); + const double outputBandwidth = this->GetOutputNarrowBandwidth(); + const double inputBandwidth = this->GetInputNarrowBandwidth(); // define iterators using LocalLevelSetImageType = typename LevelSetType::LevelSetImageType; @@ -327,7 +327,7 @@ ExtensionVelocitiesImageFilter::GenerateDat for (unsigned int k = 0; k < VAuxDimension; ++k) { - AuxImagePointer ptr = this->GetOutputVelocityImage(k); + const AuxImagePointer ptr = this->GetOutputVelocityImage(k); auxOutputIt[k] = AuxIteratorType(ptr, ptr->GetBufferedRegion()); auxOutputIt[k].GoToBegin(); } @@ -349,7 +349,7 @@ ExtensionVelocitiesImageFilter::GenerateDat } // create a new output narrowband container - NodeContainerPointer outputNB = NodeContainer::New(); + const NodeContainerPointer outputNB = NodeContainer::New(); this->SetOutputNarrowBand(outputNB); this->UpdateProgress(0.0); @@ -378,7 +378,7 @@ ExtensionVelocitiesImageFilter::GenerateDat this->UpdateProgress(0.33); // march outward - double stoppingValue = (outputBandwidth / 2.0) + 2.0; + const double stoppingValue = (outputBandwidth / 2.0) + 2.0; m_Marcher->SetStoppingValue(stoppingValue); m_Marcher->CollectPointsOn(); m_Marcher->SetTrialPoints(m_Locator->GetOutsidePoints()); diff --git a/Modules/Segmentation/LevelSets/include/itkImplicitManifoldNormalVectorFilter.hxx b/Modules/Segmentation/LevelSets/include/itkImplicitManifoldNormalVectorFilter.hxx index 075a7ccb4db..7ccadcacb01 100644 --- a/Modules/Segmentation/LevelSets/include/itkImplicitManifoldNormalVectorFilter.hxx +++ b/Modules/Segmentation/LevelSets/include/itkImplicitManifoldNormalVectorFilter.hxx @@ -87,8 +87,8 @@ template void ImplicitManifoldNormalVectorFilter::SetNormalBand() { - typename InputImageType::ConstPointer ManifoldImage = this->GetInput(); - typename SparseOutputImageType::Pointer output = this->GetOutput(); + const typename InputImageType::ConstPointer ManifoldImage = this->GetInput(); + const typename SparseOutputImageType::Pointer output = this->GetOutput(); InputImageIteratorType it(m_ManifoldRadius, ManifoldImage, ManifoldImage->GetRequestedRegion()); @@ -222,10 +222,10 @@ ImplicitManifoldNormalVectorFilter::PostProcess { if (m_UnsharpMaskingFlag) { - typename NodeListType::Pointer nodelist = this->GetOutput()->GetNodeList(); - typename NodeListType::Iterator it = nodelist->Begin(); - typename NodeListType::ConstIterator last = nodelist->End(); - NormalVectorType nv; + const typename NodeListType::Pointer nodelist = this->GetOutput()->GetNodeList(); + typename NodeListType::Iterator it = nodelist->Begin(); + const typename NodeListType::ConstIterator last = nodelist->End(); + NormalVectorType nv; while (it != last) { diff --git a/Modules/Segmentation/LevelSets/include/itkLevelSetFunction.hxx b/Modules/Segmentation/LevelSets/include/itkLevelSetFunction.hxx index efe43820a28..7fc8b3ae11b 100644 --- a/Modules/Segmentation/LevelSets/include/itkLevelSetFunction.hxx +++ b/Modules/Segmentation/LevelSets/include/itkLevelSetFunction.hxx @@ -97,7 +97,7 @@ LevelSetFunction::ComputeMinimalCurvature(const NeighborhoodType & i } // Eigensystem - vnl_symmetric_eigensystem eig{ Curve.as_matrix() }; + const vnl_symmetric_eigensystem eig{ Curve.as_matrix() }; constexpr ScalarValueType MIN_EIG = NumericTraits::min(); ScalarValueType mincurve = itk::Math::abs(eig.get_eigenvalue(ImageDimension - 1)); @@ -118,12 +118,12 @@ LevelSetFunction::Compute3DMinimalCurvature(const NeighborhoodType & const FloatOffsetType & offset, GlobalDataStruct * gd) -> ScalarValueType { - ScalarValueType mean_curve = this->ComputeMeanCurvature(neighborhood, offset, gd); + const ScalarValueType mean_curve = this->ComputeMeanCurvature(neighborhood, offset, gd); - int i0 = 0; - int i1 = 1; - int i2 = 2; - ScalarValueType gauss_curve = + int i0 = 0; + int i1 = 1; + int i2 = 2; + const ScalarValueType gauss_curve = (2 * (gd->m_dx[i0] * gd->m_dx[i1] * (gd->m_dxy[i2][i0] * gd->m_dxy[i1][i2] - gd->m_dxy[i0][i1] * gd->m_dxy[i2][i2]) + gd->m_dx[i1] * gd->m_dx[i2] * (gd->m_dxy[i2][i0] * gd->m_dxy[i0][i1] - gd->m_dxy[i1][i2] * gd->m_dxy[i0][i0]) + @@ -333,7 +333,7 @@ LevelSetFunction::ComputeUpdate(const NeighborhoodType & it, for (unsigned int i = 0; i < ImageDimension; ++i) { - ScalarValueType x_energy = m_AdvectionWeight * advection_field[i]; + const ScalarValueType x_energy = m_AdvectionWeight * advection_field[i]; if (x_energy > ZERO) { advection_term += advection_field[i] * gd->m_dx_backward[i]; diff --git a/Modules/Segmentation/LevelSets/include/itkLevelSetFunctionWithRefitTerm.hxx b/Modules/Segmentation/LevelSets/include/itkLevelSetFunctionWithRefitTerm.hxx index 7248b3149c8..1c82ac274cb 100644 --- a/Modules/Segmentation/LevelSets/include/itkLevelSetFunctionWithRefitTerm.hxx +++ b/Modules/Segmentation/LevelSets/include/itkLevelSetFunctionWithRefitTerm.hxx @@ -59,7 +59,7 @@ auto LevelSetFunctionWithRefitTerm::ComputeGlobalTimeStep(void * GlobalData) const -> TimeStepType { - TimeStepType dt = std::min(Superclass::ComputeGlobalTimeStep(GlobalData), this->m_WaveDT); + const TimeStepType dt = std::min(Superclass::ComputeGlobalTimeStep(GlobalData), this->m_WaveDT); return dt; } @@ -145,7 +145,7 @@ LevelSetFunctionWithRefitTerm::PropagationSpeed(co GlobalDataStruct * globaldata) const -> ScalarValueType { - IndexType idx = neighborhood.GetIndex(); + const IndexType idx = neighborhood.GetIndex(); NodeType * targetnode = m_SparseTargetImage->GetPixel(idx); ScalarValueType refitterm; @@ -162,8 +162,8 @@ LevelSetFunctionWithRefitTerm::PropagationSpeed(co } else { - ScalarValueType cv = this->ComputeCurvature(neighborhood); - ScalarValueType tcv = targetnode->m_Curvature; + const ScalarValueType cv = this->ComputeCurvature(neighborhood); + const ScalarValueType tcv = targetnode->m_Curvature; refitterm = static_cast(tcv - cv); } diff --git a/Modules/Segmentation/LevelSets/include/itkLevelSetNeighborhoodExtractor.hxx b/Modules/Segmentation/LevelSets/include/itkLevelSetNeighborhoodExtractor.hxx index 56f64085ce1..215c76cd4d6 100644 --- a/Modules/Segmentation/LevelSets/include/itkLevelSetNeighborhoodExtractor.hxx +++ b/Modules/Segmentation/LevelSets/include/itkLevelSetNeighborhoodExtractor.hxx @@ -124,8 +124,8 @@ LevelSetNeighborhoodExtractor::GenerateDataFull() IndexType inputIndex; - SizeValueType totalPixels = m_InputLevelSet->GetBufferedRegion().GetNumberOfPixels(); - SizeValueType updateVisits = totalPixels / 10; + const SizeValueType totalPixels = m_InputLevelSet->GetBufferedRegion().GetNumberOfPixels(); + SizeValueType updateVisits = totalPixels / 10; if (updateVisits < 1) { updateVisits = 1; @@ -158,11 +158,11 @@ LevelSetNeighborhoodExtractor::GenerateDataNarrowBand() pointsIter = m_InputNarrowBand->Begin(); pointsEnd = m_InputNarrowBand->End(); - NodeType node; - double maxValue = m_NarrowBandwidth / 2.0; + NodeType node; + const double maxValue = m_NarrowBandwidth / 2.0; - SizeValueType totalPixels = m_InputNarrowBand->Size(); - SizeValueType updateVisits = totalPixels / 10; + const SizeValueType totalPixels = m_InputNarrowBand->Size(); + SizeValueType updateVisits = totalPixels / 10; if (updateVisits < 1) { updateVisits = 1; @@ -206,7 +206,7 @@ LevelSetNeighborhoodExtractor::CalculateDistance(IndexType & index) return 0.0; } - bool inside = (centerValue <= 0.0); + const bool inside = (centerValue <= 0.0); IndexType neighIndex = index; typename LevelSetImageType::PixelType neighValue; diff --git a/Modules/Segmentation/LevelSets/include/itkLevelSetVelocityNeighborhoodExtractor.hxx b/Modules/Segmentation/LevelSets/include/itkLevelSetVelocityNeighborhoodExtractor.hxx index 2d90e35bca5..4a0145200fd 100644 --- a/Modules/Segmentation/LevelSets/include/itkLevelSetVelocityNeighborhoodExtractor.hxx +++ b/Modules/Segmentation/LevelSets/include/itkLevelSetVelocityNeighborhoodExtractor.hxx @@ -77,7 +77,7 @@ template double LevelSetVelocityNeighborhoodExtractor::CalculateDistance(Index & index) { - double distance = this->Superclass::CalculateDistance(index); + const double distance = this->Superclass::CalculateDistance(index); if (distance >= this->GetLargeValue()) { diff --git a/Modules/Segmentation/LevelSets/include/itkNarrowBandLevelSetImageFilter.hxx b/Modules/Segmentation/LevelSets/include/itkNarrowBandLevelSetImageFilter.hxx index 0714414a4f6..5b2c7596343 100644 --- a/Modules/Segmentation/LevelSets/include/itkNarrowBandLevelSetImageFilter.hxx +++ b/Modules/Segmentation/LevelSets/include/itkNarrowBandLevelSetImageFilter.hxx @@ -118,7 +118,7 @@ template ::CreateNarrowBand() { - typename OutputImageType::Pointer levelset = this->GetOutput(); + const typename OutputImageType::Pointer levelset = this->GetOutput(); if (!this->m_NarrowBand->Empty()) { diff --git a/Modules/Segmentation/LevelSets/include/itkParallelSparseFieldLevelSetImageFilter.hxx b/Modules/Segmentation/LevelSets/include/itkParallelSparseFieldLevelSetImageFilter.hxx index 81fff6aaafa..40bfd9f0e03 100644 --- a/Modules/Segmentation/LevelSets/include/itkParallelSparseFieldLevelSetImageFilter.hxx +++ b/Modules/Segmentation/LevelSets/include/itkParallelSparseFieldLevelSetImageFilter.hxx @@ -40,8 +40,8 @@ ParallelSparseFieldCityBlockNeighborList::ParallelSparseField auto zero_offset = MakeFilled(0); m_Radius.Fill(1); - NeighborhoodType it(m_Radius, dummy_image, dummy_image->GetRequestedRegion()); - const unsigned int nCenter = it.Size() / 2; + const NeighborhoodType it(m_Radius, dummy_image, dummy_image->GetRequestedRegion()); + const unsigned int nCenter = it.Size() / 2; m_ArrayIndex.reserve(m_Size); m_NeighborhoodOffset.reserve(m_Size); @@ -464,7 +464,7 @@ ParallelSparseFieldLevelSetImageFilter::InitializeAct ConstNeighborhoodIterator shiftedIt( m_NeighborList.GetRadius(), m_ShiftedImage, m_OutputImage->GetRequestedRegion()); - unsigned int center = shiftedIt.Size() / 2; + const unsigned int center = shiftedIt.Size() / 2; const NeighborhoodScalesType neighborhoodScales = this->GetDifferenceFunction()->ComputeNeighborhoodScales(); @@ -480,8 +480,9 @@ ParallelSparseFieldLevelSetImageFilter::InitializeAct { const auto stride = shiftedIt.GetStride(i); - ValueType dx_forward = (shiftedIt.GetPixel(center + stride) - shiftedIt.GetCenterPixel()) * neighborhoodScales[i]; - ValueType dx_backward = + const ValueType dx_forward = + (shiftedIt.GetPixel(center + stride) - shiftedIt.GetCenterPixel()) * neighborhoodScales[i]; + const ValueType dx_backward = (shiftedIt.GetCenterPixel() - shiftedIt.GetPixel(center - stride)) * neighborhoodScales[i]; if (itk::Math::abs(dx_forward) > itk::Math::abs(dx_backward)) @@ -494,7 +495,7 @@ ParallelSparseFieldLevelSetImageFilter::InitializeAct } } length = std::sqrt(length) + MIN_NORM; - ValueType distance = shiftedIt.GetCenterPixel() / length; + const ValueType distance = shiftedIt.GetCenterPixel() / length; m_OutputImage->SetPixel(activeIt->m_Index, std::clamp(distance, -CHANGE_FACTOR, CHANGE_FACTOR)); } @@ -524,7 +525,7 @@ ParallelSparseFieldLevelSetImageFilter::PropagateLaye const StatusType & promote, unsigned int InOrOut) { - StatusType past_end = static_cast(m_Layers.size()) - 1; + const StatusType past_end = static_cast(m_Layers.size()) - 1; // Are we propagating values inward (more negative) or outward (more // positive)? @@ -672,7 +673,7 @@ ParallelSparseFieldLevelSetImageFilter::ComputeInitia { // compute m_Boundary[i] - float cutOff = 1.0 * (i + 1) * m_ZCumulativeFrequency[m_ZSize - 1] / m_NumOfWorkUnits; + const float cutOff = 1.0 * (i + 1) * m_ZCumulativeFrequency[m_ZSize - 1] / m_NumOfWorkUnits; // find the position in the cumulative freq dist where this cutoff is met for (unsigned int j = (i == 0 ? 0 : m_Boundary[i - 1]); j < m_ZSize; ++j) @@ -821,15 +822,15 @@ ParallelSparseFieldLevelSetImageFilter::ThreadedIniti // divide the lists based on the boundaries for (unsigned int i = 0; i < 2 * static_cast(m_NumberOfLayers) + 1; ++i) { - typename LayerType::Iterator layerIt = m_Layers[i]->Begin(); - typename LayerType::Iterator layerEnd = m_Layers[i]->End(); + typename LayerType::Iterator layerIt = m_Layers[i]->Begin(); + const typename LayerType::Iterator layerEnd = m_Layers[i]->End(); while (layerIt != layerEnd) { LayerNodeType * nodePtr = layerIt.GetPointer(); ++layerIt; - unsigned int k = this->GetThreadNumber(nodePtr->m_Index[m_SplitAxis]); + const unsigned int k = this->GetThreadNumber(nodePtr->m_Index[m_SplitAxis]); if (k != ThreadId) { continue; // some other thread's node => ignore @@ -899,8 +900,8 @@ ParallelSparseFieldLevelSetImageFilter::DeallocateDat for (unsigned int i = 0; i < 2 * static_cast(m_NumberOfLayers) + 1; ++i) { // return all the nodes in layer i to the main node pool - LayerNodeType * nodePtr = nullptr; - LayerPointerType layerPtr = m_Layers[i]; + LayerNodeType * nodePtr = nullptr; + const LayerPointerType layerPtr = m_Layers[i]; while (!layerPtr->Empty()) { nodePtr = layerPtr->Front(); @@ -932,8 +933,8 @@ ParallelSparseFieldLevelSetImageFilter::DeallocateDat for (unsigned int i = 0; i < 2 * static_cast(m_NumberOfLayers) + 1; ++i) { // return all the nodes in layer i to thread-i's node pool - LayerNodeType * nodePtr; - LayerPointerType layerPtr = m_Data[ThreadId].m_Layers[i]; + LayerNodeType * nodePtr; + const LayerPointerType layerPtr = m_Data[ThreadId].m_Layers[i]; while (!layerPtr->Empty()) { nodePtr = layerPtr->Front(); @@ -955,8 +956,8 @@ ParallelSparseFieldLevelSetImageFilter::DeallocateDat continue; } - LayerNodeType * nodePtr; - LayerPointerType layerPtr = m_Data[ThreadId].m_LoadTransferBufferLayers[i][tid]; + LayerNodeType * nodePtr; + const LayerPointerType layerPtr = m_Data[ThreadId].m_LoadTransferBufferLayers[i][tid]; while (!layerPtr->Empty()) { @@ -976,7 +977,7 @@ ParallelSparseFieldLevelSetImageFilter::DeallocateDat LayerNodeType * nodePtr; for (unsigned int InOrOut = 0; InOrOut < 2; ++InOrOut) { - LayerPointerType layerPtr = + const LayerPointerType layerPtr = m_Data[ThreadId].m_InterNeighborNodeTransferBufferLayers[InOrOut][m_NumberOfLayers][i]; while (!layerPtr->Empty()) @@ -1032,7 +1033,7 @@ ParallelSparseFieldLevelSetImageFilter::Iterate() m_TimeStepList.resize(m_NumOfWorkUnits); m_ValidTimeStepList.resize(m_NumOfWorkUnits, true); - typename TOutputImage::RegionType reqRegion = m_OutputImage->GetRequestedRegion(); + const typename TOutputImage::RegionType reqRegion = m_OutputImage->GetRequestedRegion(); // Controls how often we check for balance of the load among the threads and // perform load balancing (if needed) by redistributing the load. @@ -1097,7 +1098,7 @@ ParallelSparseFieldLevelSetImageFilter::Iterate() { // Update the RMS difference here this->SetRMSChange(static_cast(this->m_Data[0].m_RMSChange)); - unsigned int count = this->m_Data[0].m_Count; + const unsigned int count = this->m_Data[0].m_Count; if (count != 0) { this->SetRMSChange(static_cast(std::sqrt((static_cast(this->GetRMSChange())) / count))); @@ -1214,9 +1215,9 @@ auto ParallelSparseFieldLevelSetImageFilter::ThreadedCalculateChange(ThreadIdType ThreadId) -> TimeStepType { - typename FiniteDifferenceFunctionType::Pointer df = this->GetDifferenceFunction(); - ValueType centerValue = 0.0; - ValueType MIN_NORM = 1.0e-6; + const typename FiniteDifferenceFunctionType::Pointer df = this->GetDifferenceFunction(); + ValueType centerValue = 0.0; + ValueType MIN_NORM = 1.0e-6; if (this->GetUseImageSpacing()) { const auto & spacing = this->GetInput()->GetSpacing(); @@ -1244,8 +1245,8 @@ ParallelSparseFieldLevelSetImageFilter::ThreadedCalcu // the level set function to the output image (level set image) at each // index. - typename LayerType::Iterator layerIt = m_Data[ThreadId].m_Layers[0]->Begin(); - typename LayerType::Iterator layerEnd = m_Data[ThreadId].m_Layers[0]->End(); + typename LayerType::Iterator layerIt = m_Data[ThreadId].m_Layers[0]->Begin(); + const typename LayerType::Iterator layerEnd = m_Data[ThreadId].m_Layers[0]->End(); for (; layerIt != layerEnd; ++layerIt) { @@ -1265,8 +1266,8 @@ ParallelSparseFieldLevelSetImageFilter::ThreadedCalcu typename FiniteDifferenceFunctionType::FloatOffsetType offset; for (unsigned int i = 0; i < static_cast(ImageDimension); ++i) { - ValueType forwardValue = outputIt.GetPixel(center + m_NeighborList.GetStride(i)); - ValueType backwardValue = outputIt.GetPixel(center - m_NeighborList.GetStride(i)); + const ValueType forwardValue = outputIt.GetPixel(center + m_NeighborList.GetStride(i)); + const ValueType backwardValue = outputIt.GetPixel(center - m_NeighborList.GetStride(i)); if (forwardValue * backwardValue >= 0) { @@ -1316,7 +1317,7 @@ ParallelSparseFieldLevelSetImageFilter::ThreadedCalcu } } - TimeStepType timeStep = df->ComputeGlobalTimeStep((void *)m_Data[ThreadId].globalData); + const TimeStepType timeStep = df->ComputeGlobalTimeStep((void *)m_Data[ThreadId].globalData); return timeStep; } @@ -1403,7 +1404,7 @@ ParallelSparseFieldLevelSetImageFilter::ThreadedApply this->SignalNeighborsAndWait(ThreadId); // Update the rest of the layer values - unsigned int N = (2 * static_cast(m_NumberOfLayers) + 1) - 2; + const unsigned int N = (2 * static_cast(m_NumberOfLayers) + 1) - 2; for (unsigned int i = 1; i < N; i += 2) { @@ -1436,17 +1437,18 @@ ParallelSparseFieldLevelSetImageFilter::ThreadedUpdat float rms_change_accumulator = m_ValueZero; - unsigned int Neighbor_Size = m_NeighborList.GetSize(); + const unsigned int Neighbor_Size = m_NeighborList.GetSize(); - typename LayerType::Iterator layerIt = m_Data[ThreadId].m_Layers[0]->Begin(); - typename LayerType::Iterator layerEnd = m_Data[ThreadId].m_Layers[0]->End(); + typename LayerType::Iterator layerIt = m_Data[ThreadId].m_Layers[0]->Begin(); + const typename LayerType::Iterator layerEnd = m_Data[ThreadId].m_Layers[0]->End(); while (layerIt != layerEnd) { const auto centerIndex = layerIt->m_Index; const auto centerValue = m_OutputImage->GetPixel(centerIndex); - float new_value = this->ThreadedCalculateUpdateValue(ThreadId, centerIndex, dt, centerValue, layerIt->m_Value); + const float new_value = + this->ThreadedCalculateUpdateValue(ThreadId, centerIndex, dt, centerValue, layerIt->m_Value); // If this index needs to be moved to another layer, then search its // neighborhood for indices that need to be pulled up/down into the @@ -1563,8 +1565,8 @@ ParallelSparseFieldLevelSetImageFilter::CopyInsertLis LayerPointerType FromListPtr, LayerPointerType ToListPtr) { - typename LayerType::Iterator layerIt = FromListPtr->Begin(); - typename LayerType::Iterator layerEnd = FromListPtr->End(); + typename LayerType::Iterator layerIt = FromListPtr->Begin(); + const typename LayerType::Iterator layerEnd = FromListPtr->End(); while (layerIt != layerEnd) { @@ -1643,7 +1645,7 @@ ParallelSparseFieldLevelSetImageFilter::ThreadedProce unsigned int BufferLayerNumber, ThreadIdType ThreadId) { - unsigned int neighbor_Size = m_NeighborList.GetSize(); + const unsigned int neighbor_Size = m_NeighborList.GetSize(); // InOrOut == 1, inside, more negative, uplist // InOrOut == 0, outside @@ -1671,8 +1673,8 @@ ParallelSparseFieldLevelSetImageFilter::ThreadedProce // for all neighbors i ... and insert it in one's own InputList CopyInsertInterNeighborNodeTransferBufferLayers(ThreadId, InputList, InOrOut, BufferLayerNumber - 1); - typename LayerType::Iterator layerIt = InputList->Begin(); - typename LayerType::Iterator layerEnd = InputList->End(); + typename LayerType::Iterator layerIt = InputList->Begin(); + const typename LayerType::Iterator layerEnd = InputList->End(); while (layerIt != layerEnd) { auto nodePtr = layerIt.GetPointer(); @@ -1745,7 +1747,7 @@ ParallelSparseFieldLevelSetImageFilter::ThreadedProce // is handled at the next stage m_StatusImage->SetPixel(n_index, m_StatusChanging); - unsigned int tmpId = this->GetThreadNumber(n_index[m_SplitAxis]); + const unsigned int tmpId = this->GetThreadNumber(n_index[m_SplitAxis]); nodePtr = m_Data[ThreadId].m_LayerNodeStore->Borrow(); nodePtr->m_Index = n_index; @@ -1830,11 +1832,11 @@ ParallelSparseFieldLevelSetImageFilter::ThreadedProce CopyInsertInterNeighborNodeTransferBufferLayers(ThreadId, InputList, InOrOut, BufferLayerNumber - 1); } - unsigned int neighbor_size = m_NeighborList.GetSize(); + const unsigned int neighbor_size = m_NeighborList.GetSize(); while (!InputList->Empty()) { LayerNodeType * nodePtr = InputList->Front(); - IndexType center_index = nodePtr->m_Index; + const IndexType center_index = nodePtr->m_Index; InputList->PopFront(); @@ -1859,7 +1861,7 @@ ParallelSparseFieldLevelSetImageFilter::ThreadedProce { IndexType n_index = center_index + m_NeighborList.GetNeighborhoodOffset(i); - StatusType neighbor_status = m_StatusImage->GetPixel(n_index); + const StatusType neighbor_status = m_StatusImage->GetPixel(n_index); // Have we bumped up against the boundary? If so, turn on bounds // checking. @@ -1875,7 +1877,7 @@ ParallelSparseFieldLevelSetImageFilter::ThreadedProce // handled at the next stage) m_StatusImage->SetPixel(n_index, m_StatusChanging); - unsigned int tmpId = this->GetThreadNumber(n_index[m_SplitAxis]); + const unsigned int tmpId = this->GetThreadNumber(n_index[m_SplitAxis]); nodePtr = m_Data[ThreadId].m_LayerNodeStore->Borrow(); nodePtr->m_Index = n_index; @@ -1948,20 +1950,20 @@ ParallelSparseFieldLevelSetImageFilter::ThreadedPropa unsigned int InOrOut, ThreadIdType ThreadId) { - StatusType past_end = static_cast(m_Layers.size()) - 1; + const StatusType past_end = static_cast(m_Layers.size()) - 1; // Are we propagating values inward (more negative) or outward (more positive)? - ValueType delta = (InOrOut == 1) ? -m_ConstantGradientValue : m_ConstantGradientValue; + const ValueType delta = (InOrOut == 1) ? -m_ConstantGradientValue : m_ConstantGradientValue; - unsigned int Neighbor_Size = m_NeighborList.GetSize(); - typename LayerType::Iterator toIt = m_Data[ThreadId].m_Layers[to]->Begin(); - typename LayerType::Iterator toEnd = m_Data[ThreadId].m_Layers[to]->End(); + const unsigned int Neighbor_Size = m_NeighborList.GetSize(); + typename LayerType::Iterator toIt = m_Data[ThreadId].m_Layers[to]->Begin(); + const typename LayerType::Iterator toEnd = m_Data[ThreadId].m_Layers[to]->End(); while (toIt != toEnd) { - IndexType centerIndex = toIt->m_Index; + const IndexType centerIndex = toIt->m_Index; - StatusType centerStatus = m_StatusImage->GetPixel(centerIndex); + const StatusType centerStatus = m_StatusImage->GetPixel(centerIndex); if (centerStatus != to) { @@ -1979,15 +1981,15 @@ ParallelSparseFieldLevelSetImageFilter::ThreadedPropa bool found_neighbor_flag = false; for (unsigned int i = 0; i < Neighbor_Size; ++i) { - IndexType nIndex = centerIndex + m_NeighborList.GetNeighborhoodOffset(i); - StatusType nStatus = m_StatusImage->GetPixel(nIndex); + const IndexType nIndex = centerIndex + m_NeighborList.GetNeighborhoodOffset(i); + const StatusType nStatus = m_StatusImage->GetPixel(nIndex); // If this neighbor is in the "from" list, compare its absolute value // to any previous values found in the "from" list. Keep only the // value with the smallest magnitude. if (nStatus == from) { - ValueType value_temp = m_OutputImage->GetPixel(nIndex); + const ValueType value_temp = m_OutputImage->GetPixel(nIndex); if (found_neighbor_flag == false) { @@ -2053,7 +2055,7 @@ ParallelSparseFieldLevelSetImageFilter::CheckLoadBala for (unsigned int i = 0; i < m_NumOfWorkUnits; ++i) { - NodeCounterType count = m_Data[i].m_Layers[0]->Size(); + const NodeCounterType count = m_Data[i].m_Layers[0]->Size(); total += count; if (min > count) { @@ -2096,7 +2098,7 @@ ParallelSparseFieldLevelSetImageFilter::CheckLoadBala for (unsigned int i = 0; i < m_NumOfWorkUnits - 1; ++i) { // compute m_Boundary[i] - float cutOff = 1.0f * (i + 1) * m_ZCumulativeFrequency[m_ZSize - 1] / m_NumOfWorkUnits; + const float cutOff = 1.0f * (i + 1) * m_ZCumulativeFrequency[m_ZSize - 1] / m_NumOfWorkUnits; // find the position in the cumulative freq dist where this cutoff is met for (unsigned int j = (i == 0 ? 0 : m_Boundary[i - 1]); j < m_ZSize; ++j) @@ -2195,8 +2197,8 @@ ParallelSparseFieldLevelSetImageFilter::ThreadedLoadB // for all layers for (i = 0; i < 2 * static_cast(m_NumberOfLayers) + 1; ++i) { - typename LayerType::Iterator layerIt = m_Data[ThreadId].m_Layers[i]->Begin(); - typename LayerType::Iterator layerEnd = m_Data[ThreadId].m_Layers[i]->End(); + typename LayerType::Iterator layerIt = m_Data[ThreadId].m_Layers[i]->Begin(); + const typename LayerType::Iterator layerEnd = m_Data[ThreadId].m_Layers[i]->End(); while (layerIt != layerEnd) { @@ -2205,7 +2207,7 @@ ParallelSparseFieldLevelSetImageFilter::ThreadedLoadB // use the latest (just updated in CheckLoadBalance) boundaries to // determine to which thread region does the pixel now belong - ThreadIdType tmpId = this->GetThreadNumber(nodePtr->m_Index[m_SplitAxis]); + const ThreadIdType tmpId = this->GetThreadNumber(nodePtr->m_Index[m_SplitAxis]); if (tmpId != ThreadId) // this pixel no longer belongs to this thread { @@ -2359,7 +2361,7 @@ ParallelSparseFieldLevelSetImageFilter::SignalNeighbo } } - ThreadIdType lastThreadId = m_NumOfWorkUnits - 1; + const ThreadIdType lastThreadId = m_NumOfWorkUnits - 1; if (lastThreadId == 0) { return; // only 1 thread => no need to wait diff --git a/Modules/Segmentation/LevelSets/include/itkReinitializeLevelSetImageFilter.hxx b/Modules/Segmentation/LevelSets/include/itkReinitializeLevelSetImageFilter.hxx index 26dcc789095..e811c717d62 100644 --- a/Modules/Segmentation/LevelSets/include/itkReinitializeLevelSetImageFilter.hxx +++ b/Modules/Segmentation/LevelSets/include/itkReinitializeLevelSetImageFilter.hxx @@ -101,7 +101,7 @@ template void ReinitializeLevelSetImageFilter::AllocateOutput() { - LevelSetPointer outputPtr = this->GetOutput(); + const LevelSetPointer outputPtr = this->GetOutput(); // allocate the output buffer memory outputPtr->SetBufferedRegion(outputPtr->GetRequestedRegion()); @@ -134,9 +134,9 @@ template void ReinitializeLevelSetImageFilter::GenerateDataFull() { - LevelSetConstPointer inputPtr = this->GetInput(); - LevelSetPointer outputPtr = this->GetOutput(); - LevelSetPointer tempLevelSet = m_Marcher->GetOutput(); + const LevelSetConstPointer inputPtr = this->GetInput(); + const LevelSetPointer outputPtr = this->GetOutput(); + const LevelSetPointer tempLevelSet = m_Marcher->GetOutput(); // define iterators using IteratorType = ImageRegionIterator; @@ -206,9 +206,9 @@ template void ReinitializeLevelSetImageFilter::GenerateDataNarrowBand() { - LevelSetConstPointer inputPtr = this->GetInput(); - LevelSetPointer outputPtr = this->GetOutput(); - LevelSetPointer tempLevelSet = m_Marcher->GetOutput(); + const LevelSetConstPointer inputPtr = this->GetInput(); + const LevelSetPointer outputPtr = this->GetOutput(); + const LevelSetPointer tempLevelSet = m_Marcher->GetOutput(); // define iterators using IteratorType = ImageRegionIterator; @@ -269,7 +269,7 @@ ReinitializeLevelSetImageFilter::GenerateDataNarrowBand() this->UpdateProgress(0.33); // march outward - double stoppingValue = (m_OutputNarrowBandwidth / 2.0) + 2.0; + const double stoppingValue = (m_OutputNarrowBandwidth / 2.0) + 2.0; m_Marcher->SetStoppingValue(stoppingValue); m_Marcher->CollectPointsOn(); m_Marcher->SetTrialPoints(m_Locator->GetOutsidePoints()); diff --git a/Modules/Segmentation/LevelSets/include/itkShapePriorMAPCostFunction.hxx b/Modules/Segmentation/LevelSets/include/itkShapePriorMAPCostFunction.hxx index 86f69102c1a..f7c84eba4b4 100644 --- a/Modules/Segmentation/LevelSets/include/itkShapePriorMAPCostFunction.hxx +++ b/Modules/Segmentation/LevelSets/include/itkShapePriorMAPCostFunction.hxx @@ -53,8 +53,8 @@ ShapePriorMAPCostFunction::ComputeLogInsideTerm(con { this->m_ShapeFunction->SetParameters(parameters); - typename NodeContainerType::ConstIterator iter = this->GetActiveRegion()->Begin(); - typename NodeContainerType::ConstIterator end = this->GetActiveRegion()->End(); + typename NodeContainerType::ConstIterator iter = this->GetActiveRegion()->Begin(); + const typename NodeContainerType::ConstIterator end = this->GetActiveRegion()->End(); MeasureType counter = 0.0; @@ -69,7 +69,7 @@ ShapePriorMAPCostFunction::ComputeLogInsideTerm(con if (node.GetValue() <= 0.0) { - double value = this->m_ShapeFunction->Evaluate(point); + const double value = this->m_ShapeFunction->Evaluate(point); if (value > 0.0) { counter += 1.0; @@ -83,7 +83,7 @@ ShapePriorMAPCostFunction::ComputeLogInsideTerm(con ++iter; } - MeasureType output = counter * m_Weights[0]; + const MeasureType output = counter * m_Weights[0]; return output; } @@ -110,9 +110,9 @@ ShapePriorMAPCostFunction::ComputeLogGradientTerm(c { this->m_ShapeFunction->SetParameters(parameters); - typename NodeContainerType::ConstIterator iter = this->GetActiveRegion()->Begin(); - typename NodeContainerType::ConstIterator end = this->GetActiveRegion()->End(); - MeasureType sum = 0.0; + typename NodeContainerType::ConstIterator iter = this->GetActiveRegion()->Begin(); + const typename NodeContainerType::ConstIterator end = this->GetActiveRegion()->End(); + MeasureType sum = 0.0; // Assume that ( 1 - FeatureImage ) approximates a Gaussian (zero mean, unit // variance) diff --git a/Modules/Segmentation/LevelSets/include/itkShapePriorSegmentationLevelSetFunction.hxx b/Modules/Segmentation/LevelSets/include/itkShapePriorSegmentationLevelSetFunction.hxx index ef92ea08ded..4e10c25fa34 100644 --- a/Modules/Segmentation/LevelSets/include/itkShapePriorSegmentationLevelSetFunction.hxx +++ b/Modules/Segmentation/LevelSets/include/itkShapePriorSegmentationLevelSetFunction.hxx @@ -65,7 +65,7 @@ ShapePriorSegmentationLevelSetFunction::ComputeUp typename ShapeFunctionType::PointType point; this->GetFeatureImage()->TransformContinuousIndexToPhysicalPoint(cdx, point); - ScalarValueType shape_term = + const ScalarValueType shape_term = m_ShapePriorWeight * (m_ShapeFunction->Evaluate(point) - neighborhood.GetCenterPixel()); value += shape_term; diff --git a/Modules/Segmentation/LevelSets/include/itkShapePriorSegmentationLevelSetImageFilter.hxx b/Modules/Segmentation/LevelSets/include/itkShapePriorSegmentationLevelSetImageFilter.hxx index 7855bc13a8b..473b20e80dd 100644 --- a/Modules/Segmentation/LevelSets/include/itkShapePriorSegmentationLevelSetImageFilter.hxx +++ b/Modules/Segmentation/LevelSets/include/itkShapePriorSegmentationLevelSetImageFilter.hxx @@ -81,7 +81,7 @@ ShapePriorSegmentationLevelSetImageFilterExtractActiveRegion(nodes); // Setup the cost function diff --git a/Modules/Segmentation/LevelSets/include/itkSparseFieldFourthOrderLevelSetImageFilter.h b/Modules/Segmentation/LevelSets/include/itkSparseFieldFourthOrderLevelSetImageFilter.h index ff483ee496b..bed9d090a05 100644 --- a/Modules/Segmentation/LevelSets/include/itkSparseFieldFourthOrderLevelSetImageFilter.h +++ b/Modules/Segmentation/LevelSets/include/itkSparseFieldFourthOrderLevelSetImageFilter.h @@ -238,7 +238,7 @@ class ITK_TEMPLATE_EXPORT SparseFieldFourthOrderLevelSetImageFilter void SetNumberOfLayers(const unsigned int n) override { - unsigned int nm = std::max(this->GetMinimumNumberOfLayers(), n); + const unsigned int nm = std::max(this->GetMinimumNumberOfLayers(), n); if (nm != this->GetNumberOfLayers()) { @@ -253,7 +253,7 @@ class ITK_TEMPLATE_EXPORT SparseFieldFourthOrderLevelSetImageFilter InitializeIteration() override { Superclass::InitializeIteration(); - ValueType rmschange = this->GetRMSChange(); + const ValueType rmschange = this->GetRMSChange(); if ((this->GetElapsedIterations() == 0) || (m_RefitIteration == m_MaxRefitIteration) || (rmschange <= m_RMSChangeNormalProcessTrigger) || (this->ActiveLayerCheckBand())) diff --git a/Modules/Segmentation/LevelSets/include/itkSparseFieldFourthOrderLevelSetImageFilter.hxx b/Modules/Segmentation/LevelSets/include/itkSparseFieldFourthOrderLevelSetImageFilter.hxx index a38a8a9ad33..f01b74dd435 100644 --- a/Modules/Segmentation/LevelSets/include/itkSparseFieldFourthOrderLevelSetImageFilter.hxx +++ b/Modules/Segmentation/LevelSets/include/itkSparseFieldFourthOrderLevelSetImageFilter.hxx @@ -158,8 +158,8 @@ SparseFieldFourthOrderLevelSetImageFilter::ComputeCur distanceImageIterator.GoToBegin(); while (!distanceImageIterator.IsAtEnd()) { - ValueType distance = distanceImageIterator.Value(); - NodeType * node = sparseImageIterator.GetCenterPixel(); + const ValueType distance = distanceImageIterator.Value(); + NodeType * node = sparseImageIterator.GetCenterPixel(); if ((distance >= -m_CurvatureBandWidth) && (distance <= m_CurvatureBandWidth)) { node->m_Curvature = ComputeCurvatureFromSparseImageNeighborhood(sparseImageIterator); @@ -181,8 +181,8 @@ template bool SparseFieldFourthOrderLevelSetImageFilter::ActiveLayerCheckBand() const { - typename SparseImageType::Pointer im = m_LevelSetFunction->GetSparseTargetImage(); - bool flag = false; + const typename SparseImageType::Pointer im = m_LevelSetFunction->GetSparseTargetImage(); + bool flag = false; typename LayerType::Iterator layerIt = this->m_Layers[0]->Begin(); while (layerIt != this->m_Layers[0]->End()) @@ -205,8 +205,8 @@ SparseFieldFourthOrderLevelSetImageFilter::ProcessNor { auto temp = static_cast(ImageDimension); - typename NormalVectorFilterType::Pointer NormalVectorFilter = NormalVectorFilterType::New(); - typename NormalVectorFunctionType::Pointer NormalVectorFunction = NormalVectorFunctionType::New(); + const typename NormalVectorFilterType::Pointer NormalVectorFilter = NormalVectorFilterType::New(); + const typename NormalVectorFunctionType::Pointer NormalVectorFunction = NormalVectorFunctionType::New(); NormalVectorFunction->SetNormalProcessType(m_NormalProcessType); NormalVectorFunction->SetConductanceParameter(m_NormalProcessConductance); NormalVectorFilter->SetNormalFunction(NormalVectorFunction); @@ -219,8 +219,8 @@ SparseFieldFourthOrderLevelSetImageFilter::ProcessNor // Move the pixel container and image information of the image we are working // on into a temporary image to use as the input to the mini-pipeline. This // avoids a complete copy of the image. - typename OutputImageType::Pointer phi = this->GetOutput(); - auto tmp = OutputImageType::New(); + const typename OutputImageType::Pointer phi = this->GetOutput(); + auto tmp = OutputImageType::New(); tmp->SetRequestedRegion(phi->GetRequestedRegion()); tmp->SetBufferedRegion(phi->GetBufferedRegion()); tmp->SetLargestPossibleRegion(phi->GetLargestPossibleRegion()); @@ -230,7 +230,7 @@ SparseFieldFourthOrderLevelSetImageFilter::ProcessNor NormalVectorFilter->SetInput(tmp); NormalVectorFilter->Update(); - typename SparseImageType::Pointer SparseNormalImage = NormalVectorFilter->GetOutput(); + const typename SparseImageType::Pointer SparseNormalImage = NormalVectorFilter->GetOutput(); this->ComputeCurvatureTarget(tmp, SparseNormalImage); m_LevelSetFunction->SetSparseTargetImage(SparseNormalImage); diff --git a/Modules/Segmentation/LevelSets/include/itkSparseFieldLevelSetImageFilter.hxx b/Modules/Segmentation/LevelSets/include/itkSparseFieldLevelSetImageFilter.hxx index 45c1639afe4..03580acacb7 100644 --- a/Modules/Segmentation/LevelSets/include/itkSparseFieldLevelSetImageFilter.hxx +++ b/Modules/Segmentation/LevelSets/include/itkSparseFieldLevelSetImageFilter.hxx @@ -36,8 +36,8 @@ SparseFieldCityBlockNeighborList::SparseFieldCityBlockNeighbo auto zero_offset = MakeFilled(0); m_Radius.Fill(1); - NeighborhoodType it(m_Radius, dummy_image, dummy_image->GetRequestedRegion()); - const unsigned int nCenter = it.Size() / 2; + const NeighborhoodType it(m_Radius, dummy_image, dummy_image->GetRequestedRegion()); + const unsigned int nCenter = it.Size() / 2; m_Size = 2 * Dimension; m_ArrayIndex.reserve(m_Size); @@ -248,7 +248,7 @@ SparseFieldLevelSetImageFilter::ProcessStatusList(Lay for (unsigned int i = 0; i < m_NeighborList.GetSize(); ++i) { - StatusType neighbor_status = statusIt.GetPixel(m_NeighborList.GetArrayIndex(i)); + const StatusType neighbor_status = statusIt.GetPixel(m_NeighborList.GetArrayIndex(i)); // Have we bumped up against the boundary? If so, turn on bounds // checking. @@ -758,8 +758,8 @@ SparseFieldLevelSetImageFilter::InitializeActiveLayer ConstNeighborhoodIterator shiftedIt( m_NeighborList.GetRadius(), m_ShiftedImage, this->m_OutputImage->GetRequestedRegion()); - const unsigned int center = shiftedIt.Size() / 2; - typename OutputImageType::Pointer output = this->m_OutputImage; + const unsigned int center = shiftedIt.Size() / 2; + const typename OutputImageType::Pointer output = this->m_OutputImage; const NeighborhoodScalesType neighborhoodScales = this->GetDifferenceFunction()->ComputeNeighborhoodScales(); diff --git a/Modules/Segmentation/LevelSets/include/itkThresholdSegmentationLevelSetFunction.hxx b/Modules/Segmentation/LevelSets/include/itkThresholdSegmentationLevelSetFunction.hxx index 54a79761d04..63c9e802de9 100644 --- a/Modules/Segmentation/LevelSets/include/itkThresholdSegmentationLevelSetFunction.hxx +++ b/Modules/Segmentation/LevelSets/include/itkThresholdSegmentationLevelSetFunction.hxx @@ -54,10 +54,10 @@ ThresholdSegmentationLevelSetFunction::CalculateS this->GetSpeedImage()->CopyInformation(this->GetFeatureImage()); // Calculate the speed image - auto upper_threshold = static_cast(m_UpperThreshold); - auto lower_threshold = static_cast(m_LowerThreshold); - ScalarValueType mid = ((upper_threshold - lower_threshold) / 2.0) + lower_threshold; - ScalarValueType threshold; + auto upper_threshold = static_cast(m_UpperThreshold); + auto lower_threshold = static_cast(m_LowerThreshold); + const ScalarValueType mid = ((upper_threshold - lower_threshold) / 2.0) + lower_threshold; + ScalarValueType threshold; for (fit.GoToBegin(), sit.GoToBegin(); !fit.IsAtEnd(); ++sit, ++fit) { if (static_cast(fit.Get()) < mid) diff --git a/Modules/Segmentation/LevelSets/test/itkAnisotropicFourthOrderLevelSetImageFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkAnisotropicFourthOrderLevelSetImageFilterTest.cxx index 7bc5e3b4e88..e3f8d4f344c 100644 --- a/Modules/Segmentation/LevelSets/test/itkAnisotropicFourthOrderLevelSetImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkAnisotropicFourthOrderLevelSetImageFilterTest.cxx @@ -27,9 +27,9 @@ itkAnisotropicFourthOrderLevelSetImageFilterTest(int, char *[]) auto im_init = ImageType::New(); - ImageType::RegionType r; - ImageType::SizeType sz = { { 128, 128 } }; - ImageType::IndexType idx = { { 0, 0 } }; + ImageType::RegionType r; + const ImageType::SizeType sz = { { 128, 128 } }; + const ImageType::IndexType idx = { { 0, 0 } }; r.SetSize(sz); r.SetIndex(idx); diff --git a/Modules/Segmentation/LevelSets/test/itkBinaryMaskToNarrowBandPointSetFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkBinaryMaskToNarrowBandPointSetFilterTest.cxx index 67bdf9692c1..5c2fb92d8ed 100644 --- a/Modules/Segmentation/LevelSets/test/itkBinaryMaskToNarrowBandPointSetFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkBinaryMaskToNarrowBandPointSetFilterTest.cxx @@ -120,16 +120,16 @@ itkBinaryMaskToNarrowBandPointSetFilterTest(int argc, char * argv[]) using PointDataContainerPointer = PointDataContainer::Pointer; using PointDataIterator = PointDataContainer::ConstIterator; - PointSetType::Pointer pointSet = narrowBandGenerator->GetOutput(); + const PointSetType::Pointer pointSet = narrowBandGenerator->GetOutput(); - PointsContainerPointer points = pointSet->GetPoints(); - PointDataContainerPointer pointData = pointSet->GetPointData(); + const PointsContainerPointer points = pointSet->GetPoints(); + const PointDataContainerPointer pointData = pointSet->GetPointData(); - PointsIterator point = points->Begin(); - PointsIterator lastPoint = points->End(); + PointsIterator point = points->Begin(); + const PointsIterator lastPoint = points->End(); - PointDataIterator data = pointData->Begin(); - PointDataIterator lastData = pointData->End(); + PointDataIterator data = pointData->Begin(); + const PointDataIterator lastData = pointData->End(); while (point != lastPoint && data != lastData) { diff --git a/Modules/Segmentation/LevelSets/test/itkCannySegmentationLevelSetImageFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkCannySegmentationLevelSetImageFilterTest.cxx index 4077b46fd57..a5ae6ece487 100644 --- a/Modules/Segmentation/LevelSets/test/itkCannySegmentationLevelSetImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkCannySegmentationLevelSetImageFilterTest.cxx @@ -32,24 +32,24 @@ constexpr int V_DEPTH = 64; float sphere(float x, float y, float z) { - float dis = (x - static_cast(V_WIDTH) / 2.0) * (x - static_cast(V_WIDTH) / 2.0) / - ((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) + - (y - static_cast(V_HEIGHT) / 2.0) * (y - static_cast(V_HEIGHT) / 2.0) / - ((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) + - (z - static_cast(V_DEPTH) / 2.0) * (z - static_cast(V_DEPTH) / 2.0) / - ((0.2f * V_DEPTH) * (0.2f * V_DEPTH)); + const float dis = (x - static_cast(V_WIDTH) / 2.0) * (x - static_cast(V_WIDTH) / 2.0) / + ((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) + + (y - static_cast(V_HEIGHT) / 2.0) * (y - static_cast(V_HEIGHT) / 2.0) / + ((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) + + (z - static_cast(V_DEPTH) / 2.0) * (z - static_cast(V_DEPTH) / 2.0) / + ((0.2f * V_DEPTH) * (0.2f * V_DEPTH)); return (1.0f - dis); } float sphere2(float x, float y, float z) { - float dis = (x - static_cast(V_WIDTH) / 2.1) * (x - static_cast(V_WIDTH) / 2.1) / - ((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) + - (y - static_cast(V_HEIGHT) / 2.0) * (y - static_cast(V_HEIGHT) / 2.0) / - ((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) + - (z - static_cast(V_DEPTH) / 2.0) * (z - static_cast(V_DEPTH) / 2.0) / - ((0.2f * V_DEPTH) * (0.2f * V_DEPTH)); + const float dis = (x - static_cast(V_WIDTH) / 2.1) * (x - static_cast(V_WIDTH) / 2.1) / + ((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) + + (y - static_cast(V_HEIGHT) / 2.0) * (y - static_cast(V_HEIGHT) / 2.0) / + ((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) + + (z - static_cast(V_DEPTH) / 2.0) * (z - static_cast(V_DEPTH) / 2.0) / + ((0.2f * V_DEPTH) * (0.2f * V_DEPTH)); return (1.0f - dis); } @@ -67,7 +67,7 @@ evaluate_float_function(itk::Image * im, float (*f)(float, float, floa for (int x = 0; x < V_WIDTH; ++x) { idx[0] = x; - float val = f(static_cast(x), static_cast(y), static_cast(z)); + const float val = f(static_cast(x), static_cast(y), static_cast(z)); // im->SetPixel(idx, -1.0 * f(static_cast(x), static_cast(y), static_cast(z))); if (val >= 0.0) { @@ -165,8 +165,8 @@ itkCannySegmentationLevelSetImageFilterTest(int, char *[]) reg.SetSize(sz); reg.SetIndex(idx); - CSIFTN::ImageType::Pointer inputImage = CSIFTN::ImageType::New(); - CSIFTN::SeedImageType::Pointer seedImage = CSIFTN::SeedImageType::New(); + const CSIFTN::ImageType::Pointer inputImage = CSIFTN::ImageType::New(); + const CSIFTN::SeedImageType::Pointer seedImage = CSIFTN::SeedImageType::New(); inputImage->SetRegions(reg); seedImage->SetRegions(reg); inputImage->Allocate(); @@ -178,7 +178,7 @@ itkCannySegmentationLevelSetImageFilterTest(int, char *[]) // Target surface is a sphere VERY NEAR to the starting surface. CSIFTN::evaluate_float_function(inputImage, CSIFTN::sphere2); - itk::CannySegmentationLevelSetImageFilter<::CSIFTN::SeedImageType, ::CSIFTN::ImageType>::Pointer filter = + const itk::CannySegmentationLevelSetImageFilter<::CSIFTN::SeedImageType, ::CSIFTN::ImageType>::Pointer filter = itk::CannySegmentationLevelSetImageFilter<::CSIFTN::SeedImageType, ::CSIFTN::ImageType>::New(); filter->SetInput(seedImage); filter->SetFeatureImage(inputImage); @@ -189,7 +189,7 @@ itkCannySegmentationLevelSetImageFilterTest(int, char *[]) // function so that negative values result in // surface growth. - itk::RMSCommand::Pointer c = itk::RMSCommand::New(); + const itk::RMSCommand::Pointer c = itk::RMSCommand::New(); filter->AddObserver(itk::IterationEvent(), c); filter->SetIsoSurfaceValue(0.5); //<--- IMPORTANT! Default is zero. filter->SetPropagationScaling(0.5); @@ -249,8 +249,8 @@ itkCannySegmentationLevelSetImageFilterTest(int, char *[]) // // simple test to see if itkCannySegmentationLevelSetFunction can // handle a different FeatureImageType - itk::CannySegmentationLevelSetImageFilter<::CSIFTN::SeedImageType, ::CSIFTN::ImageType, double>::Pointer filter2 = - itk::CannySegmentationLevelSetImageFilter<::CSIFTN::SeedImageType, ::CSIFTN::ImageType, double>::New(); + const itk::CannySegmentationLevelSetImageFilter<::CSIFTN::SeedImageType, ::CSIFTN::ImageType, double>::Pointer + filter2 = itk::CannySegmentationLevelSetImageFilter<::CSIFTN::SeedImageType, ::CSIFTN::ImageType, double>::New(); if (filter2.IsNull()) { return EXIT_FAILURE; diff --git a/Modules/Segmentation/LevelSets/test/itkCollidingFrontsImageFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkCollidingFrontsImageFilterTest.cxx index 8ed179e0784..b7d2a926c98 100644 --- a/Modules/Segmentation/LevelSets/test/itkCollidingFrontsImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkCollidingFrontsImageFilterTest.cxx @@ -50,7 +50,7 @@ itkCollidingFrontsImageFilterTest(int argc, char * argv[]) ImageType::RegionType imageRegion; imageRegion.SetSize(imageSize); - PixelType background = 64; + const PixelType background = 64; auto inputImage = ImageType::New(); inputImage->SetRegions(imageRegion); @@ -98,7 +98,7 @@ itkCollidingFrontsImageFilterTest(int argc, char * argv[]) seeds2->InsertElement(0, node2); InternalImageType::OffsetType offset = { { 60, 60 } }; - double radius = seedPosition2[0] - offset[0]; + const double radius = seedPosition2[0] - offset[0]; collidingFronts->SetInput(caster->GetOutput()); collidingFronts->SetSeedPoints1(seeds1); @@ -114,7 +114,7 @@ itkCollidingFrontsImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(collidingFronts->Update()); - InternalImageType::Pointer output = collidingFronts->GetOutput(); + const InternalImageType::Pointer output = collidingFronts->GetOutput(); itk::ImageRegionIterator iterator(output, output->GetBufferedRegion()); @@ -131,7 +131,7 @@ itkCollidingFrontsImageFilterTest(int argc, char * argv[]) distance += tempIndex[j] * tempIndex[j]; } distance = std::sqrt(distance); - InternalImageType::PixelType outputPixel = iterator.Get(); + const InternalImageType::PixelType outputPixel = iterator.Get(); // for test to pass, the circle of radius 10 centered in offset // must be made up only of negative pixels and vice-versa diff --git a/Modules/Segmentation/LevelSets/test/itkCurvesLevelSetImageFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkCurvesLevelSetImageFilterTest.cxx index d79b37a1b5f..5145d760685 100644 --- a/Modules/Segmentation/LevelSets/test/itkCurvesLevelSetImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkCurvesLevelSetImageFilterTest.cxx @@ -54,17 +54,17 @@ itkCurvesLevelSetImageFilterTest(int, char *[]) * Create an input image. * A light square on a dark background. */ - PixelType background = 0; - PixelType foreground = 190; + const PixelType background = 0; + const PixelType foreground = 190; auto inputImage = ImageType::New(); inputImage->SetRegions(imageRegion); inputImage->Allocate(); inputImage->FillBuffer(background); - auto squareStart = ImageType::IndexType::Filled(20); - auto squareSize = ImageType::SizeType::Filled(60); - ImageType::RegionType squareRegion{ squareStart, squareSize }; + auto squareStart = ImageType::IndexType::Filled(20); + auto squareSize = ImageType::SizeType::Filled(60); + const ImageType::RegionType squareRegion{ squareStart, squareSize }; using Iterator = itk::ImageRegionIterator; Iterator it(inputImage, squareRegion); diff --git a/Modules/Segmentation/LevelSets/test/itkCurvesLevelSetImageFilterZeroSigmaTest.cxx b/Modules/Segmentation/LevelSets/test/itkCurvesLevelSetImageFilterZeroSigmaTest.cxx index bfcfe1f045c..503cded652a 100644 --- a/Modules/Segmentation/LevelSets/test/itkCurvesLevelSetImageFilterZeroSigmaTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkCurvesLevelSetImageFilterZeroSigmaTest.cxx @@ -51,17 +51,17 @@ itkCurvesLevelSetImageFilterZeroSigmaTest(int, char *[]) * Create an input image. * A light square on a dark background. */ - PixelType background = 0; - PixelType foreground = 190; + const PixelType background = 0; + const PixelType foreground = 190; auto inputImage = ImageType::New(); inputImage->SetRegions(imageRegion); inputImage->Allocate(); inputImage->FillBuffer(background); - auto squareStart = ImageType::IndexType::Filled(20); - auto squareSize = ImageType::SizeType::Filled(60); - ImageType::RegionType squareRegion{ squareStart, squareSize }; + auto squareStart = ImageType::IndexType::Filled(20); + auto squareSize = ImageType::SizeType::Filled(60); + const ImageType::RegionType squareRegion{ squareStart, squareSize }; using Iterator = itk::ImageRegionIterator; Iterator it(inputImage, squareRegion); diff --git a/Modules/Segmentation/LevelSets/test/itkExtensionVelocitiesImageFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkExtensionVelocitiesImageFilterTest.cxx index 35a431c4b1b..3a389e62b7c 100644 --- a/Modules/Segmentation/LevelSets/test/itkExtensionVelocitiesImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkExtensionVelocitiesImageFilterTest.cxx @@ -47,8 +47,8 @@ template double SimpleSignedDistance(const TPoint & p) { - auto center = itk::MakeFilled(50); - double radius = 19.5; + auto center = itk::MakeFilled(50); + const double radius = 19.5; double accum = 0.0; for (unsigned int j = 0; j < TPoint::PointDimension; ++j) @@ -66,9 +66,9 @@ SimpleVelocity(const TPoint & p) { auto center = itk::MakeFilled(50); - double value; - double x = p[0] - center[0]; - double y = p[1] - center[1]; + double value; + const double x = p[0] - center[0]; + const double y = p[1] - center[1]; if (y == 0.0) { @@ -123,9 +123,9 @@ itkExtensionVelocitiesImageFilterTest(int, char *[]) using PointType = itk::Point; // Fill an input image with simple signed distance function - auto image = ImageType::New(); - auto size = ImageType::SizeType::Filled(128); - ImageType::RegionType region(size); + auto image = ImageType::New(); + auto size = ImageType::SizeType::Filled(128); + const ImageType::RegionType region(size); image->SetRegions(region); image->Allocate(); @@ -213,9 +213,9 @@ itkExtensionVelocitiesImageFilterTest(int, char *[]) difference->Update(); // mask out the peak at near the center point - auto centerIndex = ImageType::IndexType::Filled(50 - 8); - auto centerSize = ImageType::SizeType::Filled(17); - ImageType::RegionType centerRegion{ centerIndex, centerSize }; + auto centerIndex = ImageType::IndexType::Filled(50 - 8); + auto centerSize = ImageType::SizeType::Filled(17); + const ImageType::RegionType centerRegion{ centerIndex, centerSize }; iter = Iterator(difference->GetOutput(), centerRegion); iter.GoToBegin(); @@ -231,8 +231,8 @@ itkExtensionVelocitiesImageFilterTest(int, char *[]) calculator->SetImage(difference->GetOutput()); calculator->Compute(); - double maxAbsDifference = calculator->GetMaximum(); - IndexType maxAbsDifferenceIndex = calculator->GetIndexOfMaximum(); + const double maxAbsDifference = calculator->GetMaximum(); + const IndexType maxAbsDifferenceIndex = calculator->GetIndexOfMaximum(); std::cout << "Max. abs. difference = " << maxAbsDifference; std::cout << " at " << maxAbsDifferenceIndex << std::endl; @@ -263,14 +263,14 @@ itkExtensionVelocitiesImageFilterTest(int, char *[]) using NodeContainerType = ReinitializerType::NodeContainer; using ContainerIterator = NodeContainerType::ConstIterator; - NodeContainerPointer nodes = reinitializer->GetOutputNarrowBand(); - ContainerIterator nodeIter = nodes->Begin(); - ContainerIterator nodeEnd = nodes->End(); + const NodeContainerPointer nodes = reinitializer->GetOutputNarrowBand(); + ContainerIterator nodeIter = nodes->Begin(); + const ContainerIterator nodeEnd = nodes->End(); while (nodeIter != nodeEnd) { - ImageType::IndexType nodeIndex = nodeIter.Value().GetIndex(); - double absDiff = + const ImageType::IndexType nodeIndex = nodeIter.Value().GetIndex(); + const double absDiff = itk::Math::abs(aux2->GetPixel(nodeIndex) - reinitializer->GetOutputVelocityImage(1)->GetPixel(nodeIndex)); if (absDiff > 0.6) { diff --git a/Modules/Segmentation/LevelSets/test/itkGeodesicActiveContourLevelSetImageFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkGeodesicActiveContourLevelSetImageFilterTest.cxx index 46e677b6ecc..0d67dcdf5ee 100644 --- a/Modules/Segmentation/LevelSets/test/itkGeodesicActiveContourLevelSetImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkGeodesicActiveContourLevelSetImageFilterTest.cxx @@ -46,17 +46,17 @@ itkGeodesicActiveContourLevelSetImageFilterTest(int, char *[]) imageRegion.SetSize(imageSize); // Create an input image: a light square on a dark background - PixelType background = 0; - PixelType foreground = 190; + const PixelType background = 0; + const PixelType foreground = 190; auto inputImage = ImageType::New(); inputImage->SetRegions(imageRegion); inputImage->Allocate(); inputImage->FillBuffer(background); - auto squareStart = ImageType::IndexType::Filled(20); - auto squareSize = ImageType::SizeType::Filled(60); - ImageType::RegionType squareRegion{ squareStart, squareSize }; + auto squareStart = ImageType::IndexType::Filled(20); + auto squareSize = ImageType::SizeType::Filled(60); + const ImageType::RegionType squareRegion{ squareStart, squareSize }; using Iterator = itk::ImageRegionIterator; Iterator it(inputImage, squareRegion); diff --git a/Modules/Segmentation/LevelSets/test/itkGeodesicActiveContourLevelSetImageFilterZeroSigmaTest.cxx b/Modules/Segmentation/LevelSets/test/itkGeodesicActiveContourLevelSetImageFilterZeroSigmaTest.cxx index 4e6b7f4ea62..0e674cb36f6 100644 --- a/Modules/Segmentation/LevelSets/test/itkGeodesicActiveContourLevelSetImageFilterZeroSigmaTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkGeodesicActiveContourLevelSetImageFilterZeroSigmaTest.cxx @@ -48,17 +48,17 @@ itkGeodesicActiveContourLevelSetImageFilterZeroSigmaTest(int, char *[]) // // Create an input image: a light square on a dark background. // - PixelType background = 0; - PixelType foreground = 190; + const PixelType background = 0; + const PixelType foreground = 190; auto inputImage = ImageType::New(); inputImage->SetRegions(imageRegion); inputImage->Allocate(); inputImage->FillBuffer(background); - auto squareStart = ImageType::IndexType::Filled(20); - auto squareSize = ImageType::SizeType::Filled(60); - ImageType::RegionType squareRegion{ squareStart, squareSize }; + auto squareStart = ImageType::IndexType::Filled(20); + auto squareSize = ImageType::SizeType::Filled(60); + const ImageType::RegionType squareRegion{ squareStart, squareSize }; using Iterator = itk::ImageRegionIterator; Iterator it(inputImage, squareRegion); diff --git a/Modules/Segmentation/LevelSets/test/itkGeodesicActiveContourShapePriorLevelSetImageFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkGeodesicActiveContourShapePriorLevelSetImageFilterTest.cxx index 3d8013d9a18..24674ac6981 100644 --- a/Modules/Segmentation/LevelSets/test/itkGeodesicActiveContourShapePriorLevelSetImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkGeodesicActiveContourShapePriorLevelSetImageFilterTest.cxx @@ -96,8 +96,8 @@ itkGeodesicActiveContourShapePriorLevelSetImageFilterTest(int, char *[]) // // The true shape is just the circle. // - PixelType background = 0; - PixelType foreground = 190; + const PixelType background = 0; + const PixelType foreground = 190; // Fill in the background auto inputImage = ImageType::New(); @@ -117,7 +117,7 @@ itkGeodesicActiveContourShapePriorLevelSetImageFilterTest(int, char *[]) ImageType::SizeType rectSize; rectSize[0] = 80; rectSize[1] = 10; - ImageType::RegionType rectRegion{ rectStart, rectSize }; + const ImageType::RegionType rectRegion{ rectStart, rectSize }; using Iterator = itk::ImageRegionIterator; Iterator it(inputImage, rectRegion); @@ -144,7 +144,7 @@ itkGeodesicActiveContourShapePriorLevelSetImageFilterTest(int, char *[]) while (!it.IsAtEnd()) { - ImageType::IndexType index = it.GetIndex(); + const ImageType::IndexType index = it.GetIndex(); ShapeFunctionType::PointType point; inputImage->TransformIndexToPhysicalPoint(index, point); if (shape->Evaluate(point) <= 0.0) @@ -264,8 +264,8 @@ itkGeodesicActiveContourShapePriorLevelSetImageFilterTest(int, char *[]) // Connect an observer to the filter // using WatcherType = ShowIterationObject; - WatcherType iterationWatcher(filter); - itk::SimpleMemberCommand::Pointer command = itk::SimpleMemberCommand::New(); + WatcherType iterationWatcher(filter); + const itk::SimpleMemberCommand::Pointer command = itk::SimpleMemberCommand::New(); command->SetCallbackFunction(&iterationWatcher, &WatcherType::ShowIteration); filter->AddObserver(itk::IterationEvent(), command); diff --git a/Modules/Segmentation/LevelSets/test/itkGeodesicActiveContourShapePriorLevelSetImageFilterTest_2.cxx b/Modules/Segmentation/LevelSets/test/itkGeodesicActiveContourShapePriorLevelSetImageFilterTest_2.cxx index 16a48d5c3e0..7f362bf20c2 100644 --- a/Modules/Segmentation/LevelSets/test/itkGeodesicActiveContourShapePriorLevelSetImageFilterTest_2.cxx +++ b/Modules/Segmentation/LevelSets/test/itkGeodesicActiveContourShapePriorLevelSetImageFilterTest_2.cxx @@ -100,8 +100,8 @@ itkGeodesicActiveContourShapePriorLevelSetImageFilterTest_2(int, char *[]) // The true shape is just the circle. // - PixelType background = 0; - PixelType foreground = 190; + const PixelType background = 0; + const PixelType foreground = 190; // Fill in the background auto inputImage = ImageType::New(); @@ -121,7 +121,7 @@ itkGeodesicActiveContourShapePriorLevelSetImageFilterTest_2(int, char *[]) ImageType::SizeType rectSize; rectSize[0] = 80; rectSize[1] = 10; - ImageType::RegionType rectRegion{ rectStart, rectSize }; + const ImageType::RegionType rectRegion{ rectStart, rectSize }; using Iterator = itk::ImageRegionIterator; Iterator it(inputImage, rectRegion); @@ -148,7 +148,7 @@ itkGeodesicActiveContourShapePriorLevelSetImageFilterTest_2(int, char *[]) while (!it.IsAtEnd()) { - ImageType::IndexType index = it.GetIndex(); + const ImageType::IndexType index = it.GetIndex(); SphereFunctionType::PointType point; inputImage->TransformIndexToPhysicalPoint(index, point); if (sphere->Evaluate(point) <= 0.0) @@ -239,8 +239,8 @@ itkGeodesicActiveContourShapePriorLevelSetImageFilterTest_2(int, char *[]) while (!citer.IsAtEnd()) { - ComponentImageType::IndexType index = citer.GetIndex(); - SphereFunctionType::PointType point; + const ComponentImageType::IndexType index = citer.GetIndex(); + SphereFunctionType::PointType point; meanImage->TransformIndexToPhysicalPoint(index, point); citer.Set(sphere->Evaluate(point)); @@ -256,7 +256,7 @@ itkGeodesicActiveContourShapePriorLevelSetImageFilterTest_2(int, char *[]) using ImageVectorType = ShapeFunctionType::ImagePointerVector; ImageVectorType pca; - unsigned int numberOfPCA = 1; + const unsigned int numberOfPCA = 1; pca.resize(numberOfPCA); pca[0] = ComponentImageType::New(); @@ -334,8 +334,8 @@ itkGeodesicActiveContourShapePriorLevelSetImageFilterTest_2(int, char *[]) // Connect an observer to the filter. // using WatcherType = ShowIterationObject; - WatcherType iterationWatcher(filter); - itk::SimpleMemberCommand::Pointer command = itk::SimpleMemberCommand::New(); + WatcherType iterationWatcher(filter); + const itk::SimpleMemberCommand::Pointer command = itk::SimpleMemberCommand::New(); command->SetCallbackFunction(&iterationWatcher, &WatcherType::ShowIteration); filter->AddObserver(itk::IterationEvent(), command); diff --git a/Modules/Segmentation/LevelSets/test/itkImplicitManifoldNormalVectorFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkImplicitManifoldNormalVectorFilterTest.cxx index 3f8d64bede7..08093a07858 100644 --- a/Modules/Segmentation/LevelSets/test/itkImplicitManifoldNormalVectorFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkImplicitManifoldNormalVectorFilterTest.cxx @@ -30,10 +30,10 @@ itkImplicitManifoldNormalVectorFilterTest(int, char *[]) using FilterType = itk::ImplicitManifoldNormalVectorFilter; using FunctionType = itk::NormalVectorDiffusionFunction; - auto im_init = InputImageType::New(); - InputImageType::RegionType r; - InputImageType::SizeType sz = { { 50, 50 } }; - InputImageType::IndexType idx = { { 0, 0 } }; + auto im_init = InputImageType::New(); + InputImageType::RegionType r; + const InputImageType::SizeType sz = { { 50, 50 } }; + const InputImageType::IndexType idx = { { 0, 0 } }; r.SetSize(sz); r.SetIndex(idx); im_init->SetRegions(r); diff --git a/Modules/Segmentation/LevelSets/test/itkIsotropicFourthOrderLevelSetImageFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkIsotropicFourthOrderLevelSetImageFilterTest.cxx index 1ba191433de..bb3727c0bcb 100644 --- a/Modules/Segmentation/LevelSets/test/itkIsotropicFourthOrderLevelSetImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkIsotropicFourthOrderLevelSetImageFilterTest.cxx @@ -27,9 +27,9 @@ itkIsotropicFourthOrderLevelSetImageFilterTest(int, char *[]) auto im_init = ImageType::New(); - ImageType::RegionType r; - ImageType::SizeType sz = { { 128, 128 } }; - ImageType::IndexType idx = { { 0, 0 } }; + ImageType::RegionType r; + const ImageType::SizeType sz = { { 128, 128 } }; + const ImageType::IndexType idx = { { 0, 0 } }; r.SetSize(sz); r.SetIndex(idx); diff --git a/Modules/Segmentation/LevelSets/test/itkLaplacianSegmentationLevelSetImageFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkLaplacianSegmentationLevelSetImageFilterTest.cxx index 930fac1cb22..275138795b3 100644 --- a/Modules/Segmentation/LevelSets/test/itkLaplacianSegmentationLevelSetImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkLaplacianSegmentationLevelSetImageFilterTest.cxx @@ -33,24 +33,24 @@ constexpr int V_DEPTH = 64; float sphere(float x, float y, float z) { - float dis = (x - static_cast(V_WIDTH) / 2.0) * (x - static_cast(V_WIDTH) / 2.0) / - ((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) + - (y - static_cast(V_HEIGHT) / 2.0) * (y - static_cast(V_HEIGHT) / 2.0) / - ((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) + - (z - static_cast(V_DEPTH) / 2.0) * (z - static_cast(V_DEPTH) / 2.0) / - ((0.2f * V_DEPTH) * (0.2f * V_DEPTH)); + const float dis = (x - static_cast(V_WIDTH) / 2.0) * (x - static_cast(V_WIDTH) / 2.0) / + ((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) + + (y - static_cast(V_HEIGHT) / 2.0) * (y - static_cast(V_HEIGHT) / 2.0) / + ((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) + + (z - static_cast(V_DEPTH) / 2.0) * (z - static_cast(V_DEPTH) / 2.0) / + ((0.2f * V_DEPTH) * (0.2f * V_DEPTH)); return (1.0f - dis); } float sphere2(float x, float y, float z) { - float dis = (x - static_cast(V_WIDTH) / 2.1) * (x - static_cast(V_WIDTH) / 2.1) / - ((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) + - (y - static_cast(V_HEIGHT) / 2.0) * (y - static_cast(V_HEIGHT) / 2.0) / - ((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) + - (z - static_cast(V_DEPTH) / 2.0) * (z - static_cast(V_DEPTH) / 2.0) / - ((0.2f * V_DEPTH) * (0.2f * V_DEPTH)); + const float dis = (x - static_cast(V_WIDTH) / 2.1) * (x - static_cast(V_WIDTH) / 2.1) / + ((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) + + (y - static_cast(V_HEIGHT) / 2.0) * (y - static_cast(V_HEIGHT) / 2.0) / + ((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) + + (z - static_cast(V_DEPTH) / 2.0) * (z - static_cast(V_DEPTH) / 2.0) / + ((0.2f * V_DEPTH) * (0.2f * V_DEPTH)); return (1.0f - dis); } @@ -68,7 +68,7 @@ evaluate_float_function(itk::Image * im, float (*f)(float, float, floa for (int x = 0; x < V_WIDTH; ++x) { idx[0] = x; - float val = f(static_cast(x), static_cast(y), static_cast(z)); + const float val = f(static_cast(x), static_cast(y), static_cast(z)); // im->SetPixel(idx, -1.0 * f(static_cast(x), static_cast(y), static_cast(z))); if (val >= 0.0) { @@ -165,8 +165,8 @@ itkLaplacianSegmentationLevelSetImageFilterTest(int, char *[]) reg.SetSize(sz); reg.SetIndex(idx); - LSIFTN::ImageType::Pointer inputImage = LSIFTN::ImageType::New(); - LSIFTN::SeedImageType::Pointer seedImage = LSIFTN::SeedImageType::New(); + const LSIFTN::ImageType::Pointer inputImage = LSIFTN::ImageType::New(); + const LSIFTN::SeedImageType::Pointer seedImage = LSIFTN::SeedImageType::New(); inputImage->SetRegions(reg); seedImage->SetRegions(reg); inputImage->Allocate(); @@ -182,7 +182,7 @@ itkLaplacianSegmentationLevelSetImageFilterTest(int, char *[]) LSIFTN::evaluate_float_function(inputImage, LSIFTN::sphere2); - itk::LaplacianSegmentationLevelSetImageFilter<::LSIFTN::SeedImageType, ::LSIFTN::ImageType>::Pointer filter = + const itk::LaplacianSegmentationLevelSetImageFilter<::LSIFTN::SeedImageType, ::LSIFTN::ImageType>::Pointer filter = itk::LaplacianSegmentationLevelSetImageFilter<::LSIFTN::SeedImageType, ::LSIFTN::ImageType>::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, LaplacianSegmentationLevelSetImageFilter, SegmentationLevelSetImageFilter); @@ -197,7 +197,7 @@ itkLaplacianSegmentationLevelSetImageFilterTest(int, char *[]) // function so that negative values result in // surface growth. - itk::RMSCommand::Pointer c = itk::RMSCommand::New(); + const itk::RMSCommand::Pointer c = itk::RMSCommand::New(); filter->AddObserver(itk::IterationEvent(), c); filter->SetIsoSurfaceValue(0.5); //<--- IMPORTANT! Default is zero. filter->SetFeatureScaling(100.0); diff --git a/Modules/Segmentation/LevelSets/test/itkLevelSetFunctionTest.cxx b/Modules/Segmentation/LevelSets/test/itkLevelSetFunctionTest.cxx index 414fb424886..cdafdfb11bc 100644 --- a/Modules/Segmentation/LevelSets/test/itkLevelSetFunctionTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkLevelSetFunctionTest.cxx @@ -55,9 +55,9 @@ circle(unsigned int x, unsigned int y) float square(unsigned int x, unsigned int y) { - float X = itk::Math::abs(x - static_cast(WIDTH) / 2.0); - float Y = itk::Math::abs(y - static_cast(HEIGHT) / 2.0); - float dis; + const float X = itk::Math::abs(x - static_cast(WIDTH) / 2.0); + const float Y = itk::Math::abs(y - static_cast(HEIGHT) / 2.0); + float dis; if (!((X > RADIUS) && (Y > RADIUS))) { dis = RADIUS - std::max(X, Y); @@ -139,7 +139,7 @@ class MorphFunction : public itk::LevelSetFunction> ScalarValueType PropagationSpeed(const NeighborhoodType & neighborhood, const FloatOffsetType &, GlobalDataStruct *) const override { - itk::Index<2> idx = neighborhood.GetIndex(); + const itk::Index<2> idx = neighborhood.GetIndex(); return m_DistanceTransform->GetPixel(idx); } }; @@ -222,9 +222,9 @@ itkLevelSetFunctionTest(int, char *[]) auto im_init = ImageType::New(); auto im_target = ImageType::New(); - ImageType::RegionType r; - ImageType::SizeType sz = { { LSFT::HEIGHT, LSFT::WIDTH } }; - ImageType::IndexType idx = { { 0, 0 } }; + ImageType::RegionType r; + const ImageType::SizeType sz = { { LSFT::HEIGHT, LSFT::WIDTH } }; + const ImageType::IndexType idx = { { 0, 0 } }; r.SetSize(sz); r.SetIndex(idx); @@ -246,7 +246,7 @@ itkLevelSetFunctionTest(int, char *[]) itr.Value() = itr.Value() / std::sqrt((5.0f + itk::Math::sqr(itr.Value()))); } - LSFT::MorphFilter::Pointer mf = LSFT::MorphFilter::New(); + const LSFT::MorphFilter::Pointer mf = LSFT::MorphFilter::New(); mf->SetDistanceTransform(im_target); mf->SetIterations(n); mf->SetInput(im_init); diff --git a/Modules/Segmentation/LevelSets/test/itkNarrowBandCurvesLevelSetImageFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkNarrowBandCurvesLevelSetImageFilterTest.cxx index 1d299835071..64661e9ec62 100644 --- a/Modules/Segmentation/LevelSets/test/itkNarrowBandCurvesLevelSetImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkNarrowBandCurvesLevelSetImageFilterTest.cxx @@ -56,17 +56,17 @@ itkNarrowBandCurvesLevelSetImageFilterTest(int argc, char * argv[]) // Create an input image. // A light square on a dark background. - PixelType background = 0; - PixelType foreground = 190; + const PixelType background = 0; + const PixelType foreground = 190; auto inputImage = ImageType::New(); inputImage->SetRegions(imageRegion); inputImage->Allocate(); inputImage->FillBuffer(background); - auto squareStart = ImageType::IndexType::Filled(10); - auto squareSize = ImageType::SizeType::Filled(30); - ImageType::RegionType squareRegion{ squareStart, squareSize }; + auto squareStart = ImageType::IndexType::Filled(10); + auto squareSize = ImageType::SizeType::Filled(30); + const ImageType::RegionType squareRegion{ squareStart, squareSize }; using Iterator = itk::ImageRegionIterator; Iterator it(inputImage, squareRegion); @@ -133,7 +133,7 @@ itkNarrowBandCurvesLevelSetImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(curvesFilter, NarrowBandCurvesLevelSetImageFilter, NarrowBandLevelSetImageFilter); - bool reverseExpansionDirection = false; + const bool reverseExpansionDirection = false; ITK_TEST_SET_GET_BOOLEAN(curvesFilter, ReverseExpansionDirection, reverseExpansionDirection); // Set the initial level set diff --git a/Modules/Segmentation/LevelSets/test/itkNarrowBandThresholdSegmentationLevelSetImageFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkNarrowBandThresholdSegmentationLevelSetImageFilterTest.cxx index 2c14ea78fde..70c3c7d2a03 100644 --- a/Modules/Segmentation/LevelSets/test/itkNarrowBandThresholdSegmentationLevelSetImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkNarrowBandThresholdSegmentationLevelSetImageFilterTest.cxx @@ -32,12 +32,12 @@ constexpr int V_DEPTH = 64; float sphere(float x, float y, float z) { - float dis = (x - static_cast(V_WIDTH) / 2.0) * (x - static_cast(V_WIDTH) / 2.0) / - ((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) + - (y - static_cast(V_HEIGHT) / 2.0) * (y - static_cast(V_HEIGHT) / 2.0) / - ((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) + - (z - static_cast(V_DEPTH) / 2.0) * (z - static_cast(V_DEPTH) / 2.0) / - ((0.2f * V_DEPTH) * (0.2f * V_DEPTH)); + const float dis = (x - static_cast(V_WIDTH) / 2.0) * (x - static_cast(V_WIDTH) / 2.0) / + ((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) + + (y - static_cast(V_HEIGHT) / 2.0) * (y - static_cast(V_HEIGHT) / 2.0) / + ((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) + + (z - static_cast(V_DEPTH) / 2.0) * (z - static_cast(V_DEPTH) / 2.0) / + ((0.2f * V_DEPTH) * (0.2f * V_DEPTH)); return (1.0f - dis); } @@ -119,8 +119,8 @@ itkNarrowBandThresholdSegmentationLevelSetImageFilterTest(int, char *[]) reg.SetSize(sz); reg.SetIndex(idx); - NBTS::ImageType::Pointer inputImage = NBTS::ImageType::New(); - NBTS::SeedImageType::Pointer seedImage = NBTS::SeedImageType::New(); + const NBTS::ImageType::Pointer inputImage = NBTS::ImageType::New(); + const NBTS::SeedImageType::Pointer seedImage = NBTS::SeedImageType::New(); inputImage->SetRegions(reg); seedImage->SetRegions(reg); inputImage->Allocate(); @@ -165,27 +165,27 @@ itkNarrowBandThresholdSegmentationLevelSetImageFilterTest(int, char *[]) filter->SetNumberOfWorkUnits(2); - typename FilterType::ValueType upperThreshold = 63; + const typename FilterType::ValueType upperThreshold = 63; filter->SetUpperThreshold(upperThreshold); ITK_TEST_SET_GET_VALUE(upperThreshold, filter->GetUpperThreshold()); - typename FilterType::ValueType lowerThredhold = 50; + const typename FilterType::ValueType lowerThredhold = 50; filter->SetLowerThreshold(lowerThredhold); ITK_TEST_SET_GET_VALUE(lowerThredhold, filter->GetLowerThreshold()); - typename FilterType::ValueType edgeWeight = 0.0; + const typename FilterType::ValueType edgeWeight = 0.0; filter->SetEdgeWeight(edgeWeight); ITK_TEST_SET_GET_VALUE(edgeWeight, filter->GetEdgeWeight()); - int smoothingIterations = 5; + const int smoothingIterations = 5; filter->SetSmoothingIterations(smoothingIterations); ITK_TEST_SET_GET_VALUE(smoothingIterations, filter->GetSmoothingIterations()); - typename FilterType::ValueType smoothingTimeStep = 0.1; + const typename FilterType::ValueType smoothingTimeStep = 0.1; filter->SetSmoothingTimeStep(smoothingTimeStep); ITK_TEST_SET_GET_VALUE(smoothingTimeStep, filter->GetSmoothingTimeStep()); - typename FilterType::ValueType smoothingConductance = 0.8; + const typename FilterType::ValueType smoothingConductance = 0.8; filter->SetSmoothingConductance(smoothingConductance); ITK_TEST_SET_GET_VALUE(smoothingConductance, filter->GetSmoothingConductance()); @@ -195,7 +195,7 @@ itkNarrowBandThresholdSegmentationLevelSetImageFilterTest(int, char *[]) // function so that negative values result in // surface growth. - itk::NBRMSCommand::Pointer c = itk::NBRMSCommand::New(); + const itk::NBRMSCommand::Pointer c = itk::NBRMSCommand::New(); filter->AddObserver(itk::IterationEvent(), c); filter->SetIsoSurfaceValue(0.5); //<--- IMPORTANT! Default is zero. diff --git a/Modules/Segmentation/LevelSets/test/itkParallelSparseFieldLevelSetImageFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkParallelSparseFieldLevelSetImageFilterTest.cxx index 87c85936560..c16301c7153 100644 --- a/Modules/Segmentation/LevelSets/test/itkParallelSparseFieldLevelSetImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkParallelSparseFieldLevelSetImageFilterTest.cxx @@ -59,10 +59,10 @@ sphere(unsigned int x, unsigned int y, unsigned int z) float cube(unsigned int x, unsigned int y, unsigned int z) { - float X = itk::Math::abs(x - static_cast(WIDTH) / 2.0); - float Y = itk::Math::abs(y - static_cast(HEIGHT) / 2.0); - float Z = itk::Math::abs(z - static_cast(DEPTH) / 2.0); - float dis; + const float X = itk::Math::abs(x - static_cast(WIDTH) / 2.0); + const float Y = itk::Math::abs(y - static_cast(HEIGHT) / 2.0); + const float Z = itk::Math::abs(z - static_cast(DEPTH) / 2.0); + float dis; if (!((X > RADIUS) && (Y > RADIUS) && (Z > RADIUS))) { dis = RADIUS - (std::max(std::max(X, Y), Z)); @@ -146,7 +146,7 @@ class MorphFunction : public itk::LevelSetFunction> ScalarValueType PropagationSpeed(const NeighborhoodType & neighborhood, const FloatOffsetType &, GlobalDataStruct *) const override { - itk::Index<3> idx = neighborhood.GetIndex(); + const itk::Index<3> idx = neighborhood.GetIndex(); return m_DistanceTransform->GetPixel(idx); } }; @@ -239,9 +239,9 @@ itkParallelSparseFieldLevelSetImageFilterTest(int argc, char * argv[]) auto im_init = ImageType::New(); auto im_target = ImageType::New(); - ImageType::RegionType r; - ImageType::SizeType sz = { { PSFLSIFT::HEIGHT, PSFLSIFT::WIDTH, PSFLSIFT::DEPTH } }; - ImageType::IndexType idx = { { 0, 0, 0 } }; + ImageType::RegionType r; + const ImageType::SizeType sz = { { PSFLSIFT::HEIGHT, PSFLSIFT::WIDTH, PSFLSIFT::DEPTH } }; + const ImageType::IndexType idx = { { 0, 0, 0 } }; r.SetSize(sz); r.SetIndex(idx); @@ -297,17 +297,17 @@ itkParallelSparseFieldLevelSetImageFilterTest(int argc, char * argv[]) itr.Value() = itr.Value() / std::sqrt((5.0f + itk::Math::sqr(itr.Value()))); } - PSFLSIFT::MorphFilter::Pointer mf = PSFLSIFT::MorphFilter::New(); + const PSFLSIFT::MorphFilter::Pointer mf = PSFLSIFT::MorphFilter::New(); mf->SetDistanceTransform(im_target); mf->SetIterations(n); mf->SetInput(im_init); mf->SetNumberOfWorkUnits(numberOfWorkUnits); - typename PSFLSIFT::MorphFilter::StatusType numberOfLayers = 3; + const typename PSFLSIFT::MorphFilter::StatusType numberOfLayers = 3; mf->SetNumberOfLayers(numberOfLayers); ITK_TEST_SET_GET_VALUE(numberOfLayers, mf->GetNumberOfLayers()); - typename PSFLSIFT::MorphFilter::ValueType isoSurfaceValue = 0.0; + const typename PSFLSIFT::MorphFilter::ValueType isoSurfaceValue = 0.0; mf->SetIsoSurfaceValue(isoSurfaceValue); ITK_TEST_SET_GET_VALUE(isoSurfaceValue, mf->GetIsoSurfaceValue()); diff --git a/Modules/Segmentation/LevelSets/test/itkReinitializeLevelSetImageFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkReinitializeLevelSetImageFilterTest.cxx index eb75d8efeed..7b613347b33 100644 --- a/Modules/Segmentation/LevelSets/test/itkReinitializeLevelSetImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkReinitializeLevelSetImageFilterTest.cxx @@ -48,8 +48,8 @@ template double SimpleSignedDistance(const TPoint & p) { - auto center = itk::MakeFilled(50); - double radius = 19.5; + auto center = itk::MakeFilled(50); + const double radius = 19.5; double accum = 0.0; for (unsigned int j = 0; j < TPoint::PointDimension; ++j) @@ -75,9 +75,9 @@ itkReinitializeLevelSetImageFilterTest(int, char *[]) using PointType = itk::Point; // Fill an input image with simple signed distance function - auto image = ImageType::New(); - auto size = ImageType::SizeType::Filled(128); - ImageType::RegionType region(size); + auto image = ImageType::New(); + auto size = ImageType::SizeType::Filled(128); + const ImageType::RegionType region(size); image->SetRegions(region); image->Allocate(); @@ -142,8 +142,8 @@ itkReinitializeLevelSetImageFilterTest(int, char *[]) calculator->SetImage(difference->GetOutput()); calculator->Compute(); - double maxAbsDifference = calculator->GetMaximum(); - IndexType maxAbsDifferenceIndex = calculator->GetIndexOfMaximum(); + const double maxAbsDifference = calculator->GetMaximum(); + const IndexType maxAbsDifferenceIndex = calculator->GetIndexOfMaximum(); std::cout << "Max. abs. difference = " << maxAbsDifference; std::cout << " at " << maxAbsDifferenceIndex << std::endl; @@ -164,8 +164,8 @@ itkReinitializeLevelSetImageFilterTest(int, char *[]) calculator->SetImage(checker->GetOutput()); calculator->Compute(); - double minValue = calculator->GetMinimum(); - double maxValue = calculator->GetMaximum(); + const double minValue = calculator->GetMinimum(); + const double maxValue = calculator->GetMaximum(); std::cout << "Min. product = " << minValue << std::endl; std::cout << "Max. product = " << maxValue << std::endl; @@ -189,7 +189,7 @@ itkReinitializeLevelSetImageFilterTest(int, char *[]) reinitializer->Update(); using NodeContainerPointer = ReinitializerType::NodeContainerPointer; - NodeContainerPointer nodes = reinitializer->GetOutputNarrowBand(); + const NodeContainerPointer nodes = reinitializer->GetOutputNarrowBand(); std::cout << "Level set value = " << reinitializer->GetLevelSetValue() << std::endl; std::cout << "Narrow banding = " << reinitializer->GetNarrowBanding() << std::endl; @@ -205,14 +205,14 @@ itkReinitializeLevelSetImageFilterTest(int, char *[]) using NodeContainerType = ReinitializerType::NodeContainer; using ContainerIterator = NodeContainerType::ConstIterator; - NodeContainerPointer nodes2 = reinitializer->GetOutputNarrowBand(); - ContainerIterator nodeIter = nodes2->Begin(); - ContainerIterator nodeEnd = nodes2->End(); + const NodeContainerPointer nodes2 = reinitializer->GetOutputNarrowBand(); + ContainerIterator nodeIter = nodes2->Begin(); + const ContainerIterator nodeEnd = nodes2->End(); while (nodeIter != nodeEnd) { - ImageType::IndexType nodeIndex = nodeIter.Value().GetIndex(); - double product = image->GetPixel(nodeIndex) * reinitializer->GetOutput()->GetPixel(nodeIndex); + const ImageType::IndexType nodeIndex = nodeIter.Value().GetIndex(); + const double product = image->GetPixel(nodeIndex) * reinitializer->GetOutput()->GetPixel(nodeIndex); if (product < 0.0) { std::cout << "Product: " << product; diff --git a/Modules/Segmentation/LevelSets/test/itkShapeDetectionLevelSetImageFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkShapeDetectionLevelSetImageFilterTest.cxx index 9fd56713ac1..4abd389c77d 100644 --- a/Modules/Segmentation/LevelSets/test/itkShapeDetectionLevelSetImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkShapeDetectionLevelSetImageFilterTest.cxx @@ -52,17 +52,17 @@ itkShapeDetectionLevelSetImageFilterTest(int, char *[]) * Create an input image. * A light square on a dark background. */ - PixelType background = 0; - PixelType foreground = 190; + const PixelType background = 0; + const PixelType foreground = 190; auto inputImage = ImageType::New(); inputImage->SetRegions(imageRegion); inputImage->Allocate(); inputImage->FillBuffer(background); - auto squareStart = ImageType::IndexType::Filled(20); - auto squareSize = ImageType::SizeType::Filled(60); - ImageType::RegionType squareRegion{ squareStart, squareSize }; + auto squareStart = ImageType::IndexType::Filled(20); + auto squareSize = ImageType::SizeType::Filled(60); + const ImageType::RegionType squareRegion{ squareStart, squareSize }; using Iterator = itk::ImageRegionIterator; Iterator it(inputImage, squareRegion); diff --git a/Modules/Segmentation/LevelSets/test/itkShapePriorMAPCostFunctionTest.cxx b/Modules/Segmentation/LevelSets/test/itkShapePriorMAPCostFunctionTest.cxx index 99ab1e89843..9b37f264852 100644 --- a/Modules/Segmentation/LevelSets/test/itkShapePriorMAPCostFunctionTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkShapePriorMAPCostFunctionTest.cxx @@ -96,8 +96,8 @@ itkShapePriorMAPCostFunctionTest(int, char *[]) Iterator iter(input, region); iter.GoToBegin(); - unsigned int counter = 0; - PixelType activeRegionThreshold = 3.0; + unsigned int counter = 0; + const PixelType activeRegionThreshold = 3.0; while (!iter.IsAtEnd()) { @@ -106,7 +106,7 @@ itkShapePriorMAPCostFunctionTest(int, char *[]) index = iter.GetIndex(); input->TransformIndexToPhysicalPoint(index, point); - float value = shape->Evaluate(point); + const float value = shape->Evaluate(point); iter.Set(value); if (itk::Math::abs(value) < activeRegionThreshold) diff --git a/Modules/Segmentation/LevelSets/test/itkSparseFieldFourthOrderLevelSetImageFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkSparseFieldFourthOrderLevelSetImageFilterTest.cxx index 7e5a866336c..cbdaec00a21 100644 --- a/Modules/Segmentation/LevelSets/test/itkSparseFieldFourthOrderLevelSetImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkSparseFieldFourthOrderLevelSetImageFilterTest.cxx @@ -50,9 +50,9 @@ const unsigned int WIDTH = (128); float square(unsigned int x, unsigned int y) { - float X = itk::Math::abs(x - static_cast(WIDTH) / 2.0); - float Y = itk::Math::abs(y - static_cast(HEIGHT) / 2.0); - float dis; + const float X = itk::Math::abs(x - static_cast(WIDTH) / 2.0); + const float Y = itk::Math::abs(y - static_cast(HEIGHT) / 2.0); + float dis; if (!((X > RADIUS) && (Y > RADIUS))) { dis = RADIUS - std::max(X, Y); @@ -146,9 +146,9 @@ itkSparseFieldFourthOrderLevelSetImageFilterTest(int, char *[]) auto image = ImageType::New(); - ImageType::RegionType r; - ImageType::SizeType sz = { { SFFOLSIFT::HEIGHT, SFFOLSIFT::WIDTH } }; - ImageType::IndexType idx = { { 0, 0 } }; + ImageType::RegionType r; + const ImageType::SizeType sz = { { SFFOLSIFT::HEIGHT, SFFOLSIFT::WIDTH } }; + const ImageType::IndexType idx = { { 0, 0 } }; r.SetSize(sz); r.SetIndex(idx); @@ -163,35 +163,35 @@ itkSparseFieldFourthOrderLevelSetImageFilterTest(int, char *[]) filter, IsotropicDiffusionLevelSetFilter, SparseFieldFourthOrderLevelSetImageFilter); - unsigned int maxRefitIteration = 0; + const unsigned int maxRefitIteration = 0; filter->SetMaxRefitIteration(maxRefitIteration); ITK_TEST_SET_GET_VALUE(maxRefitIteration, filter->GetMaxRefitIteration()); - unsigned int maxNormalIteration = 100; + const unsigned int maxNormalIteration = 100; filter->SetMaxNormalIteration(maxNormalIteration); ITK_TEST_SET_GET_VALUE(maxNormalIteration, filter->GetMaxNormalIteration()); - typename FilterType::ValueType curvatureBandWidth = 4; + const typename FilterType::ValueType curvatureBandWidth = 4; filter->SetCurvatureBandWidth(curvatureBandWidth); ITK_TEST_SET_GET_VALUE(curvatureBandWidth, filter->GetCurvatureBandWidth()); - typename FilterType::ValueType rmsChangeNormalProcessTrigger = 0.001; + const typename FilterType::ValueType rmsChangeNormalProcessTrigger = 0.001; filter->SetRMSChangeNormalProcessTrigger(rmsChangeNormalProcessTrigger); ITK_TEST_SET_GET_VALUE(rmsChangeNormalProcessTrigger, filter->GetRMSChangeNormalProcessTrigger()); - int normalProcessType = 0; + const int normalProcessType = 0; filter->SetNormalProcessType(normalProcessType); ITK_TEST_SET_GET_VALUE(normalProcessType, filter->GetNormalProcessType()); - typename FilterType::ValueType normalProcessConductance{}; + const typename FilterType::ValueType normalProcessConductance{}; filter->SetNormalProcessConductance(normalProcessConductance); ITK_TEST_SET_GET_VALUE(normalProcessConductance, filter->GetNormalProcessConductance()); - bool normalProcessUnsharpFlag = false; + const bool normalProcessUnsharpFlag = false; filter->SetNormalProcessUnsharpFlag(normalProcessUnsharpFlag); ITK_TEST_SET_GET_BOOLEAN(filter, NormalProcessUnsharpFlag, normalProcessUnsharpFlag); - typename FilterType::ValueType normalProcessUnsharpWeight{}; + const typename FilterType::ValueType normalProcessUnsharpWeight{}; filter->SetNormalProcessUnsharpWeight(normalProcessUnsharpWeight); ITK_TEST_SET_GET_VALUE(normalProcessUnsharpWeight, filter->GetNormalProcessUnsharpWeight()); diff --git a/Modules/Segmentation/LevelSets/test/itkThresholdSegmentationLevelSetImageFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkThresholdSegmentationLevelSetImageFilterTest.cxx index 8640a3c79ca..6739eb44b12 100644 --- a/Modules/Segmentation/LevelSets/test/itkThresholdSegmentationLevelSetImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkThresholdSegmentationLevelSetImageFilterTest.cxx @@ -32,12 +32,12 @@ constexpr int V_DEPTH = 64; float sphere(float x, float y, float z) { - float dis = (x - static_cast(V_WIDTH) / 2.0) * (x - static_cast(V_WIDTH) / 2.0) / - ((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) + - (y - static_cast(V_HEIGHT) / 2.0) * (y - static_cast(V_HEIGHT) / 2.0) / - ((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) + - (z - static_cast(V_DEPTH) / 2.0) * (z - static_cast(V_DEPTH) / 2.0) / - ((0.2f * V_DEPTH) * (0.2f * V_DEPTH)); + const float dis = (x - static_cast(V_WIDTH) / 2.0) * (x - static_cast(V_WIDTH) / 2.0) / + ((0.2f * V_WIDTH) * (0.2f * V_WIDTH)) + + (y - static_cast(V_HEIGHT) / 2.0) * (y - static_cast(V_HEIGHT) / 2.0) / + ((0.2f * V_HEIGHT) * (0.2f * V_HEIGHT)) + + (z - static_cast(V_DEPTH) / 2.0) * (z - static_cast(V_DEPTH) / 2.0) / + ((0.2f * V_DEPTH) * (0.2f * V_DEPTH)); return (1.0f - dis); } @@ -154,8 +154,8 @@ itkThresholdSegmentationLevelSetImageFilterTest(int, char *[]) reg.SetSize(sz); reg.SetIndex(idx); - TSIFTN::ImageType::Pointer inputImage = TSIFTN::ImageType::New(); - TSIFTN::SeedImageType::Pointer seedImage = TSIFTN::SeedImageType::New(); + const TSIFTN::ImageType::Pointer inputImage = TSIFTN::ImageType::New(); + const TSIFTN::SeedImageType::Pointer seedImage = TSIFTN::SeedImageType::New(); inputImage->SetRegions(reg); seedImage->SetRegions(reg); inputImage->Allocate(); @@ -206,27 +206,27 @@ itkThresholdSegmentationLevelSetImageFilterTest(int, char *[]) filter->SetAdvectionImage(advectionImage); ITK_TEST_SET_GET_VALUE(advectionImage, filter->GetAdvectionImage()); - typename FilterType::ValueType upperThreshold = 63; + const typename FilterType::ValueType upperThreshold = 63; filter->SetUpperThreshold(upperThreshold); ITK_TEST_SET_GET_VALUE(upperThreshold, filter->GetUpperThreshold()); - typename FilterType::ValueType lowerThreshold = 50; + const typename FilterType::ValueType lowerThreshold = 50; filter->SetLowerThreshold(lowerThreshold); ITK_TEST_SET_GET_VALUE(lowerThreshold, filter->GetLowerThreshold()); - typename FilterType::ValueType edgeWeight = 0.0; + const typename FilterType::ValueType edgeWeight = 0.0; filter->SetEdgeWeight(edgeWeight); ITK_TEST_SET_GET_VALUE(edgeWeight, filter->GetEdgeWeight()); - int smoothingIterations = 5; + const int smoothingIterations = 5; filter->SetSmoothingIterations(smoothingIterations); ITK_TEST_SET_GET_VALUE(smoothingIterations, filter->GetSmoothingIterations()); - typename FilterType::ValueType smoothingTimeStep = 0.1; + const typename FilterType::ValueType smoothingTimeStep = 0.1; filter->SetSmoothingTimeStep(smoothingTimeStep); ITK_TEST_SET_GET_VALUE(smoothingTimeStep, filter->GetSmoothingTimeStep()); - typename FilterType::ValueType smoothingConductance = 0.8; + const typename FilterType::ValueType smoothingConductance = 0.8; filter->SetSmoothingConductance(smoothingConductance); ITK_TEST_SET_GET_VALUE(smoothingConductance, filter->GetSmoothingConductance()); @@ -247,10 +247,10 @@ itkThresholdSegmentationLevelSetImageFilterTest(int, char *[]) auto autoGenerateSpeedAdvection = true; ITK_TEST_SET_GET_BOOLEAN(filter, AutoGenerateSpeedAdvection, autoGenerateSpeedAdvection); - itk::RMSCommand::Pointer c = itk::RMSCommand::New(); + const itk::RMSCommand::Pointer c = itk::RMSCommand::New(); filter->AddObserver(itk::IterationEvent(), c); - itk::TSIFTNProgressCommand::Pointer progress = itk::TSIFTNProgressCommand::New(); + const itk::TSIFTNProgressCommand::Pointer progress = itk::TSIFTNProgressCommand::New(); filter->AddObserver(itk::ProgressEvent(), progress); filter->SetIsoSurfaceValue(0.5); //<--- IMPORTANT! Default is zero. diff --git a/Modules/Segmentation/LevelSets/test/itkUnsharpMaskLevelSetImageFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkUnsharpMaskLevelSetImageFilterTest.cxx index 10680f49c1d..16c90d82dd2 100644 --- a/Modules/Segmentation/LevelSets/test/itkUnsharpMaskLevelSetImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkUnsharpMaskLevelSetImageFilterTest.cxx @@ -28,9 +28,9 @@ const unsigned int WIDTH = (128); float square(unsigned int x, unsigned int y) { - float X = itk::Math::abs(x - static_cast(WIDTH) / 2.0); - float Y = itk::Math::abs(y - static_cast(HEIGHT) / 2.0); - float dis; + const float X = itk::Math::abs(x - static_cast(WIDTH) / 2.0); + const float Y = itk::Math::abs(y - static_cast(HEIGHT) / 2.0); + float dis; if (!((X > RADIUS) && (Y > RADIUS))) { dis = RADIUS - std::max(X, Y); @@ -66,9 +66,9 @@ itkUnsharpMaskLevelSetImageFilterTest(int, char *[]) auto im_init = ImageType::New(); - ImageType::RegionType r; - ImageType::SizeType sz = { { HEIGHT, WIDTH } }; - ImageType::IndexType idx = { { 0, 0 } }; + ImageType::RegionType r; + const ImageType::SizeType sz = { { HEIGHT, WIDTH } }; + const ImageType::IndexType idx = { { 0, 0 } }; r.SetSize(sz); r.SetIndex(idx); diff --git a/Modules/Segmentation/LevelSetsv4/include/itkBinaryImageToLevelSetImageAdaptor.hxx b/Modules/Segmentation/LevelSetsv4/include/itkBinaryImageToLevelSetImageAdaptor.hxx index e45d099e7fb..f7134b632b0 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkBinaryImageToLevelSetImageAdaptor.hxx +++ b/Modules/Segmentation/LevelSetsv4/include/itkBinaryImageToLevelSetImageAdaptor.hxx @@ -85,7 +85,7 @@ BinaryImageToLevelSetImageAdaptorm_InternalImage->Allocate(); this->m_InternalImage->FillBuffer(LevelSetType::PlusThreeLayer()); - LevelSetLabelObjectPointer innerPart = LevelSetLabelObjectType::New(); + const LevelSetLabelObjectPointer innerPart = LevelSetLabelObjectType::New(); innerPart->SetLabel(LevelSetType::MinusThreeLayer()); // Precondition labelmap and phi @@ -149,7 +149,7 @@ BinaryImageToLevelSetImageAdaptorfirst; + const LevelSetInputType idx = nodeIt->first; neighIt.SetLocation(idx); for (typename NeighborhoodIteratorType::Iterator it = neighIt.Begin(); !it.IsAtEnd(); ++it) @@ -157,7 +157,7 @@ BinaryImageToLevelSetImageAdaptorSetLabel(static_cast(outputLayer)); nodeIt = layerPlus2.begin(); @@ -191,7 +191,7 @@ void BinaryImageToLevelSetImageAdaptor>::FindActiveLayer() { - LevelSetLabelObjectPointer labelObject = this->m_LabelMap->GetLabelObject(LevelSetType::MinusThreeLayer()); + const LevelSetLabelObjectPointer labelObject = this->m_LabelMap->GetLabelObject(LevelSetType::MinusThreeLayer()); const LevelSetOutputType zero{}; @@ -229,11 +229,11 @@ BinaryImageToLevelSetImageAdaptorSetLabel(LevelSetType::ZeroLayer()); - LevelSetLayerConstIterator nodeIt = layer0.begin(); - LevelSetLayerConstIterator nodeEnd = layer0.end(); + LevelSetLayerConstIterator nodeIt = layer0.begin(); + const LevelSetLayerConstIterator nodeEnd = layer0.end(); while (nodeIt != nodeEnd) { @@ -274,20 +274,20 @@ BinaryImageToLevelSetImageAdaptorfirst; + const LevelSetInputType idx = nodeIt->first; neighIt.SetLocation(idx); for (typename NeighborhoodIteratorType::Iterator it = neighIt.Begin(); !it.IsAtEnd(); ++it) { if (it.Get() == LevelSetType::PlusThreeLayer()) { - LevelSetInputType tempIndex = neighIt.GetIndex(it.GetNeighborhoodOffset()); + const LevelSetInputType tempIndex = neighIt.GetIndex(it.GetNeighborhoodOffset()); layerPlus1.insert(LayerPairType(tempIndex, plus1)); } if (it.Get() == LevelSetType::MinusThreeLayer()) { - LevelSetInputType tempIndex = neighIt.GetIndex(it.GetNeighborhoodOffset()); + const LevelSetInputType tempIndex = neighIt.GetIndex(it.GetNeighborhoodOffset()); layerMinus1.insert(LayerPairType(tempIndex, minus1)); } @@ -295,7 +295,7 @@ BinaryImageToLevelSetImageAdaptorSetLabel(LevelSetType::MinusOneLayer()); nodeIt = layerMinus1.begin(); @@ -312,7 +312,7 @@ BinaryImageToLevelSetImageAdaptorOptimize(); this->m_LabelMap->AddLabelObject(ObjectMinus1); - LevelSetLabelObjectPointer ObjectPlus1 = LevelSetLabelObjectType::New(); + const LevelSetLabelObjectPointer ObjectPlus1 = LevelSetLabelObjectType::New(); ObjectPlus1->SetLabel(LevelSetType::PlusOneLayer()); nodeIt = layerPlus1.begin(); @@ -359,7 +359,7 @@ BinaryImageToLevelSetImageAdaptorm_InternalImage->Allocate(); this->m_InternalImage->FillBuffer(LevelSetType::PlusThreeLayer()); - LevelSetLabelObjectPointer innerPart = LevelSetLabelObjectType::New(); + const LevelSetLabelObjectPointer innerPart = LevelSetLabelObjectType::New(); innerPart->SetLabel(LevelSetType::MinusThreeLayer()); // Precondition labelmap and phi @@ -394,7 +394,7 @@ template void BinaryImageToLevelSetImageAdaptor>::FindActiveLayer() { - LevelSetLabelObjectPointer labelObject = this->m_LabelMap->GetLabelObject(LevelSetType::MinusThreeLayer()); + const LevelSetLabelObjectPointer labelObject = this->m_LabelMap->GetLabelObject(LevelSetType::MinusThreeLayer()); LevelSetLayerType & layerMinus1 = this->m_LevelSet->GetLayer(LevelSetType::MinusOneLayer()); LevelSetLayerType & layerPlus1 = this->m_LevelSet->GetLayer(LevelSetType::PlusOneLayer()); @@ -423,7 +423,7 @@ BinaryImageToLevelSetImageAdaptorSetLabel(LevelSetType::MinusOneLayer()); LevelSetLayerConstIterator nodeIt = layerMinus1.begin(); @@ -454,7 +454,7 @@ BinaryImageToLevelSetImageAdaptorOptimize(); this->m_LabelMap->AddLabelObject(ObjectMinus1); - LevelSetLabelObjectPointer ObjectPlus1 = LevelSetLabelObjectType::New(); + const LevelSetLabelObjectPointer ObjectPlus1 = LevelSetLabelObjectType::New(); ObjectPlus1->SetLabel(LevelSetType::PlusOneLayer()); nodeIt = layerPlus1.begin(); @@ -501,7 +501,7 @@ BinaryImageToLevelSetImageAdaptorm_InternalImage->Allocate(); this->m_InternalImage->FillBuffer(LevelSetType::PlusOneLayer()); - LevelSetLabelObjectPointer innerPart = LevelSetLabelObjectType::New(); + const LevelSetLabelObjectPointer innerPart = LevelSetLabelObjectType::New(); innerPart->SetLabel(LevelSetType::MinusOneLayer()); // Precondition labelmap and phi @@ -537,7 +537,7 @@ template void BinaryImageToLevelSetImageAdaptor>::FindActiveLayer() { - LevelSetLabelObjectPointer labelObject = this->m_LabelMap->GetLabelObject(LevelSetType::MinusOneLayer()); + const LevelSetLabelObjectPointer labelObject = this->m_LabelMap->GetLabelObject(LevelSetType::MinusOneLayer()); LevelSetLayerType & layer = this->m_LevelSet->GetLayer(LevelSetType::ZeroLayer()); @@ -578,7 +578,7 @@ BinaryImageToLevelSetImageAdaptorSetLabel(LevelSetType::ZeroLayer()); auto nodeIt = layer.begin(); @@ -615,7 +615,7 @@ BinaryImageToLevelSetImageAdaptorfirst; + const LevelSetInputType currentIdx = nodeIt->first; neighIt.SetLocation(currentIdx); @@ -624,7 +624,7 @@ BinaryImageToLevelSetImageAdaptor::EvaluateHessian(const InputType & in InputType inputIndexCa; InputType inputIndexDa; - bool backward = data.BackwardGradient.m_Computed; - bool forward = data.ForwardGradient.m_Computed; + const bool backward = data.BackwardGradient.m_Computed; + const bool forward = data.ForwardGradient.m_Computed; for (unsigned int dim1 = 0; dim1 < Dimension; ++dim1) { @@ -457,7 +457,7 @@ DiscreteLevelSetImage::EvaluateMeanCurvature(const InputTyp } } - OutputRealType gradNorm = grad.GetNorm(); + const OutputRealType gradNorm = grad.GetNorm(); if (gradNorm > itk::Math::eps) { @@ -560,7 +560,7 @@ DiscreteLevelSetImage::EvaluateMeanCurvature(const InputTyp } } - OutputRealType temp = data.GradientNorm.m_Value; + const OutputRealType temp = data.GradientNorm.m_Value; if (temp > itk::Math::eps) { diff --git a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetBase.hxx b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetBase.hxx index d5357dfc17d..4902794625f 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetBase.hxx +++ b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetBase.hxx @@ -70,7 +70,7 @@ template ::EvaluateGradientNorm(const InputType & iP) const -> OutputRealType { - GradientType grad = this->EvaluateGradient(iP); + const GradientType grad = this->EvaluateGradient(iP); return grad.GetNorm(); } @@ -150,7 +150,7 @@ LevelSetBase::EvaluateMeanCurvature(const } } - OutputRealType temp = ioData.GradientNorm.m_Value; + const OutputRealType temp = ioData.GradientNorm.m_Value; if (temp > itk::Math::eps) { @@ -247,7 +247,7 @@ template ::VerifyRequestedRegion() { - bool retval = true; + const bool retval = true; // Are we asking for more regions than we can get? if (m_RequestedNumberOfRegions > m_MaximumNumberOfRegions) diff --git a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetContainer.h b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetContainer.h index ccd6fccef7a..75838acb68d 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetContainer.h +++ b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetContainer.h @@ -152,10 +152,10 @@ class LevelSetContainer> { if (iAllocate) { - LevelSetPointer temp_ls = LevelSetType::New(); + const LevelSetPointer temp_ls = LevelSetType::New(); - LevelSetImagePointer image = LevelSetImageType::New(); - const LevelSetImageType * otherImage = (it->second)->GetImage(); + const LevelSetImagePointer image = LevelSetImageType::New(); + const LevelSetImageType * otherImage = (it->second)->GetImage(); image->CopyInformation(otherImage); image->SetBufferedRegion(otherImage->GetBufferedRegion()); @@ -169,7 +169,7 @@ class LevelSetContainer> } else { - LevelSetPointer temp_ls; + const LevelSetPointer temp_ls; newContainer[it->first] = temp_ls; } ++it; diff --git a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetDenseImage.hxx b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetDenseImage.hxx index 2dd8e288d21..28c23972aa9 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetDenseImage.hxx +++ b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetDenseImage.hxx @@ -42,7 +42,7 @@ template auto LevelSetDenseImage::Evaluate(const InputType & inputIndex) const -> OutputType { - InputType mapIndex = inputIndex - this->m_DomainOffset; + const InputType mapIndex = inputIndex - this->m_DomainOffset; return this->m_Image->GetPixel(mapIndex); } @@ -101,7 +101,7 @@ bool LevelSetDenseImage::IsInsideDomain(const InputType & inputIndex) const { const RegionType largestRegion = this->m_Image->GetLargestPossibleRegion(); - InputType mapIndex = inputIndex - this->m_DomainOffset; + const InputType mapIndex = inputIndex - this->m_DomainOffset; return largestRegion.IsInside(mapIndex); } diff --git a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetDomainPartitionImage.hxx b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetDomainPartitionImage.hxx index 3242435a9fa..c0dcb178617 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetDomainPartitionImage.hxx +++ b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetDomainPartitionImage.hxx @@ -45,9 +45,9 @@ LevelSetDomainPartitionImage::PopulateListDomain() for (ListIteratorType lIt(this->m_ListDomain, region); !lIt.IsAtEnd(); ++lIt) { - ListIndexType listIndex = lIt.GetIndex(); - IdentifierListType identifierList; - IdentifierType i{}; + const ListIndexType listIndex = lIt.GetIndex(); + IdentifierListType identifierList; + IdentifierType i{}; while (i < this->m_NumberOfLevelSetFunctions) { if (this->m_LevelSetDomainRegionVector[i].IsInside(listIndex)) diff --git a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetDomainPartitionImageWithKdTree.hxx b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetDomainPartitionImageWithKdTree.hxx index acd3fcaf1fa..f0824c48bd2 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetDomainPartitionImageWithKdTree.hxx +++ b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetDomainPartitionImageWithKdTree.hxx @@ -55,7 +55,7 @@ LevelSetDomainPartitionImageWithKdTree::PopulateDomainWithKdTree() this->m_ListDomain->TransformIndexToPhysicalPoint(index, pt); - CentroidVectorType queryPoint = pt.GetVectorFromOrigin(); + const CentroidVectorType queryPoint = pt.GetVectorFromOrigin(); typename TreeType::InstanceIdentifierVectorType neighbors; this->m_KdTree->Search(queryPoint, this->m_NumberOfNeighbors, neighbors); @@ -63,7 +63,7 @@ LevelSetDomainPartitionImageWithKdTree::PopulateDomainWithKdTree() IdentifierListType identifierList; for (NeighborsIdType i = 0; i < this->m_NumberOfNeighbors; ++i) { - IdentifierType levelSetID = neighbors[i]; + const IdentifierType levelSetID = neighbors[i]; if (this->m_LevelSetDomainRegionVector[levelSetID].IsInside(index)) { identifierList.push_back(neighbors[i]); diff --git a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEquationAdvectionTerm.hxx b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEquationAdvectionTerm.hxx index ee52ffb7f15..ba76c23b646 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEquationAdvectionTerm.hxx +++ b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEquationAdvectionTerm.hxx @@ -157,7 +157,7 @@ LevelSetEquationAdvectionTerm::Value(const LevelSetI for (unsigned int dim = 0; dim < ImageDimension; ++dim) { - LevelSetOutputRealType component = advectionField[dim]; + const LevelSetOutputRealType component = advectionField[dim]; if (component > LevelSetOutputRealType{}) { @@ -183,7 +183,7 @@ LevelSetEquationAdvectionTerm::Value(const LevelSetI for (unsigned int dim = 0; dim < ImageDimension; ++dim) { - LevelSetOutputRealType component = advectionField[dim]; + const LevelSetOutputRealType component = advectionField[dim]; if (component > LevelSetOutputRealType{}) { diff --git a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEquationChanAndVeseExternalTerm.hxx b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEquationChanAndVeseExternalTerm.hxx index e4a7c4c1610..a29c744ef08 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEquationChanAndVeseExternalTerm.hxx +++ b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEquationChanAndVeseExternalTerm.hxx @@ -37,8 +37,8 @@ LevelSetEquationChanAndVeseExternalTerm::ComputeProd LevelSetOutputRealType & prod) { this->ComputeProductTerm(iP, prod); - LevelSetPointer levelSet = this->m_LevelSetContainer->GetLevelSet(this->m_CurrentLevelSetId); - LevelSetOutputRealType value = levelSet->Evaluate(iP); + const LevelSetPointer levelSet = this->m_LevelSetContainer->GetLevelSet(this->m_CurrentLevelSetId); + const LevelSetOutputRealType value = levelSet->Evaluate(iP); prod *= -(1 - this->m_Heaviside->Evaluate(-value)); } @@ -121,7 +121,7 @@ LevelSetEquationChanAndVeseExternalTerm::UpdatePixel this->ComputeProductTerm(iP, prod); // For each affected h val: h val = new hval (this will dirty some cvals) - InputPixelType input = this->m_Input->GetPixel(iP); + const InputPixelType input = this->m_Input->GetPixel(iP); const LevelSetOutputRealType oldH = this->m_Heaviside->Evaluate(-oldValue); const LevelSetOutputRealType newH = this->m_Heaviside->Evaluate(-newValue); diff --git a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEquationChanAndVeseInternalTerm.hxx b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEquationChanAndVeseInternalTerm.hxx index 73ddfa90124..90e338eb4f3 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEquationChanAndVeseInternalTerm.hxx +++ b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEquationChanAndVeseInternalTerm.hxx @@ -68,7 +68,7 @@ LevelSetEquationChanAndVeseInternalTerm::Initialize( { if (this->m_Heaviside.IsNotNull()) { - InputPixelType pixel = this->m_Input->GetPixel(inputIndex); + const InputPixelType pixel = this->m_Input->GetPixel(inputIndex); LevelSetOutputRealType prod; this->ComputeProduct(inputIndex, prod); @@ -87,7 +87,7 @@ LevelSetEquationChanAndVeseInternalTerm::ComputeProd const LevelSetInputIndexType & inputIndex, LevelSetOutputRealType & prod) { - LevelSetOutputRealType value = this->m_CurrentLevelSetPointer->Evaluate(inputIndex); + const LevelSetOutputRealType value = this->m_CurrentLevelSetPointer->Evaluate(inputIndex); prod = this->m_Heaviside->Evaluate(-value); } @@ -100,7 +100,7 @@ LevelSetEquationChanAndVeseInternalTerm::UpdatePixel const LevelSetOutputRealType & newValue) { // For each affected h val: h val = new hval (this will dirty some cvals) - InputPixelType input = this->m_Input->GetPixel(inputIndex); + const InputPixelType input = this->m_Input->GetPixel(inputIndex); const LevelSetOutputRealType oldH = this->m_Heaviside->Evaluate(-oldValue); const LevelSetOutputRealType newH = this->m_Heaviside->Evaluate(-newValue); diff --git a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEquationTermContainer.hxx b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEquationTermContainer.hxx index 926d8a33061..bbe495ad75d 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEquationTermContainer.hxx +++ b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEquationTermContainer.hxx @@ -101,8 +101,8 @@ LevelSetEquationTermContainer::AddTerm(const Te RequiredDataType termRequiredData = iTerm->GetRequiredData(); - typename RequiredDataType::const_iterator dIt = termRequiredData.begin(); - typename RequiredDataType::const_iterator dEnd = termRequiredData.end(); + typename RequiredDataType::const_iterator dIt = termRequiredData.begin(); + const typename RequiredDataType::const_iterator dEnd = termRequiredData.end(); while (dIt != dEnd) { @@ -269,9 +269,9 @@ LevelSetEquationTermContainer::Evaluate(const L while (term_it != term_end) { - LevelSetOutputRealType temp_val = (term_it->second)->Evaluate(iP); + const LevelSetOutputRealType temp_val = (term_it->second)->Evaluate(iP); - LevelSetOutputRealType abs_temp_value = itk::Math::abs(temp_val); + const LevelSetOutputRealType abs_temp_value = itk::Math::abs(temp_val); // This is a thread-safe equivalent of: // cfl_it->second = std::max(abs_temp_value, cfl_it->second); @@ -304,9 +304,9 @@ LevelSetEquationTermContainer::Evaluate(const L while (term_it != term_end) { - LevelSetOutputRealType temp_val = (term_it->second)->Evaluate(iP, iData); + const LevelSetOutputRealType temp_val = (term_it->second)->Evaluate(iP, iData); - LevelSetOutputRealType abs_temp_value = itk::Math::abs(temp_val); + const LevelSetOutputRealType abs_temp_value = itk::Math::abs(temp_val); // This is a thread-safe equivalent of: // cfl_it->second = std::max(abs_temp_value, cfl_it->second); @@ -377,12 +377,12 @@ void LevelSetEquationTermContainer::ComputeRequiredData(const LevelSetInputIndexType & iP, LevelSetDataType & ioData) { - typename RequiredDataType::const_iterator dIt = m_RequiredData.begin(); - typename RequiredDataType::const_iterator dEnd = m_RequiredData.end(); + typename RequiredDataType::const_iterator dIt = m_RequiredData.begin(); + const typename RequiredDataType::const_iterator dEnd = m_RequiredData.end(); auto tIt = m_Container.begin(); - LevelSetPointer levelset = (tIt->second)->GetModifiableCurrentLevelSetPointer(); + const LevelSetPointer levelset = (tIt->second)->GetModifiableCurrentLevelSetPointer(); while (dIt != dEnd) { diff --git a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEvolution.hxx b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEvolution.hxx index e5a580cf48f..e3b05200c23 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEvolution.hxx +++ b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEvolution.hxx @@ -62,11 +62,12 @@ template void LevelSetEvolution>::ComputeIteration() { - InputImageConstPointer inputImage = this->m_EquationContainer->GetInput(); + const InputImageConstPointer inputImage = this->m_EquationContainer->GetInput(); if (this->m_LevelSetContainer->HasDomainMap()) { - typename DomainMapImageFilterType::ConstPointer domainMapFilter = this->m_LevelSetContainer->GetDomainMapFilter(); + const typename DomainMapImageFilterType::ConstPointer domainMapFilter = + this->m_LevelSetContainer->GetDomainMapFilter(); using DomainMapType = typename DomainMapImageFilterType::DomainMapType; const DomainMapType domainMap = domainMapFilter->GetDomainMap(); auto mapIt = domainMap.begin(); @@ -76,7 +77,7 @@ LevelSetEvolution>::ComputeIterat this->m_SplitDomainMapComputeIterationThreader->GetMaximumNumberOfThreads(); using DomainMapDomainType = typename SplitDomainMapComputeIterationThreaderType::DomainType; DomainMapDomainType subdomain; - DomainMapDomainType completeDomain(mapIt, mapEnd); + const DomainMapDomainType completeDomain(mapIt, mapEnd); const typename SplitDomainMapComputeIterationThreaderType::DomainPartitionerType * domainParitioner = this->m_SplitDomainMapComputeIterationThreader->GetDomainPartitioner(); const ThreadIdType numberOfThreadsThatWillBeUsed = @@ -152,8 +153,9 @@ LevelSetEvolution>::UpdateLevelSe while (this->m_LevelSetContainerIteratorToProcessWhenThreading != this->m_LevelSetContainer->End()) { - typename LevelSetType::Pointer levelSet = this->m_LevelSetContainerIteratorToProcessWhenThreading->GetLevelSet(); - typename LevelSetImageType::ConstPointer levelSetImage = levelSet->GetImage(); + const typename LevelSetType::Pointer levelSet = + this->m_LevelSetContainerIteratorToProcessWhenThreading->GetLevelSet(); + const typename LevelSetImageType::ConstPointer levelSetImage = levelSet->GetImage(); this->m_SplitLevelSetUpdateLevelSetsThreader->Execute(this, levelSetImage->GetRequestedRegion()); ++(this->m_LevelSetContainerIteratorToProcessWhenThreading); @@ -178,9 +180,9 @@ LevelSetEvolution>::ReinitializeT while (it != this->m_LevelSetContainer->End()) { - typename LevelSetImageType::Pointer image = it->GetLevelSet()->GetModifiableImage(); + const typename LevelSetImageType::Pointer image = it->GetLevelSet()->GetModifiableImage(); - ThresholdFilterPointer thresh = ThresholdFilterType::New(); + const ThresholdFilterPointer thresh = ThresholdFilterType::New(); thresh->SetLowerThreshold(NumericTraits::NonpositiveMin()); thresh->SetUpperThreshold(LevelSetOutputType{}); thresh->SetInsideValue(NumericTraits::OneValue()); @@ -188,7 +190,7 @@ LevelSetEvolution>::ReinitializeT thresh->SetInput(image); thresh->Update(); - MaurerPointer maurer = MaurerType::New(); + const MaurerPointer maurer = MaurerType::New(); maurer->SetInput(thresh->GetOutput()); maurer->SetSquaredDistance(false); maurer->SetUseImageSpacing(true); @@ -272,12 +274,12 @@ LevelSetEvolutionm_LevelSetContainerIteratorToProcessWhenThreading != this->m_LevelSetContainer->End()) { - typename LevelSetType::ConstPointer levelSet = + const typename LevelSetType::ConstPointer levelSet = this->m_LevelSetContainerIteratorToProcessWhenThreading->GetLevelSet(); - const LevelSetLayerType zeroLayer = levelSet->GetLayer(0); - auto layerBegin = zeroLayer.begin(); - auto layerEnd = zeroLayer.end(); - typename SplitLevelSetPartitionerType::DomainType completeDomain(layerBegin, layerEnd); + const LevelSetLayerType zeroLayer = levelSet->GetLayer(0); + auto layerBegin = zeroLayer.begin(); + auto layerEnd = zeroLayer.end(); + const typename SplitLevelSetPartitionerType::DomainType completeDomain(layerBegin, layerEnd); this->m_SplitLevelSetComputeIterationThreader->Execute(this, completeDomain); ++(this->m_LevelSetContainerIteratorToProcessWhenThreading); @@ -294,7 +296,7 @@ LevelSetEvolutionm_Alpha > LevelSetOutputRealType{}) && (this->m_Alpha < NumericTraits::OneValue())) { - LevelSetOutputRealType contribution = this->m_EquationContainer->ComputeCFLContribution(); + const LevelSetOutputRealType contribution = this->m_EquationContainer->ComputeCFLContribution(); if (contribution > NumericTraits::epsilon()) { @@ -326,9 +328,9 @@ LevelSetEvolutionm_LevelSetContainer->Begin(); while (it != this->m_LevelSetContainer->End()) { - typename LevelSetType::Pointer levelSet = it->GetLevelSet(); + const typename LevelSetType::Pointer levelSet = it->GetLevelSet(); - UpdateLevelSetFilterPointer updateLevelSet = UpdateLevelSetFilterType::New(); + const UpdateLevelSetFilterPointer updateLevelSet = UpdateLevelSetFilterType::New(); updateLevelSet->SetInputLevelSet(levelSet); updateLevelSet->SetUpdate(*this->m_UpdateBuffer[it->GetIdentifier()]); updateLevelSet->SetEquationContainer(this->m_EquationContainer); @@ -362,9 +364,9 @@ LevelSetEvolution>::Updat while (it != this->m_LevelSetContainer->End()) { - typename LevelSetType::Pointer levelSet = it->GetLevelSet(); + const typename LevelSetType::Pointer levelSet = it->GetLevelSet(); - UpdateLevelSetFilterPointer updateLevelSet = UpdateLevelSetFilterType::New(); + const UpdateLevelSetFilterPointer updateLevelSet = UpdateLevelSetFilterType::New(); updateLevelSet->SetInputLevelSet(levelSet); updateLevelSet->SetCurrentLevelSetId(it->GetIdentifier()); updateLevelSet->SetEquationContainer(this->m_EquationContainer); @@ -395,10 +397,10 @@ LevelSetEvolution>::U while (it != this->m_LevelSetContainer->End()) { - typename LevelSetType::Pointer levelSet = it->GetLevelSet(); - LevelSetIdentifierType levelSetId = it->GetIdentifier(); + const typename LevelSetType::Pointer levelSet = it->GetLevelSet(); + const LevelSetIdentifierType levelSetId = it->GetIdentifier(); - UpdateLevelSetFilterPointer updateLevelSet = UpdateLevelSetFilterType::New(); + const UpdateLevelSetFilterPointer updateLevelSet = UpdateLevelSetFilterType::New(); updateLevelSet->SetInputLevelSet(levelSet); updateLevelSet->SetCurrentLevelSetId(levelSetId); updateLevelSet->SetEquationContainer(this->m_EquationContainer); diff --git a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEvolutionBase.hxx b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEvolutionBase.hxx index 2b4720238db..35ccd633cc2 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEvolutionBase.hxx +++ b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEvolutionBase.hxx @@ -94,7 +94,7 @@ LevelSetEvolutionBase::CheckSetUp() } // Get the image to be segmented - InputImageConstPointer inputImage = this->m_EquationContainer->GetInput(); + const InputImageConstPointer inputImage = this->m_EquationContainer->GetInput(); if (inputImage.IsNull()) { @@ -102,7 +102,7 @@ LevelSetEvolutionBase::CheckSetUp() } // Get the LevelSetContainer from the EquationContainer - TermContainerPointer termContainer = eqIt->GetEquation(); + const TermContainerPointer termContainer = eqIt->GetEquation(); typename TermContainerType::Iterator termIt = termContainer->Begin(); if (termIt == termContainer->End()) @@ -115,7 +115,7 @@ LevelSetEvolutionBase::CheckSetUp() itkGenericExceptionMacro("this->m_LevelSetContainer != termContainer->GetLevelSetContainer()"); } - TermPointer term = termIt->GetTerm(); + const TermPointer term = termIt->GetTerm(); if (this->m_LevelSetContainer != term->GetLevelSetContainer()) { @@ -135,14 +135,15 @@ void LevelSetEvolutionBase::InitializeIteration() { // Get the image to be segmented - InputImageConstPointer inputImage = this->m_EquationContainer->GetInput(); + const InputImageConstPointer inputImage = this->m_EquationContainer->GetInput(); // Initialize parameters here this->m_EquationContainer->InitializeParameters(); if (this->m_LevelSetContainer->HasDomainMap()) { - typename DomainMapImageFilterType::ConstPointer domainMapFilter = this->m_LevelSetContainer->GetDomainMapFilter(); + const typename DomainMapImageFilterType::ConstPointer domainMapFilter = + this->m_LevelSetContainer->GetDomainMapFilter(); using DomainMapType = typename DomainMapImageFilterType::DomainMapType; const DomainMapType domainMap = domainMapFilter->GetDomainMap(); auto mapIt = domainMap.begin(); @@ -169,7 +170,7 @@ LevelSetEvolutionBase::InitializeIteration() while (idListIt != idList->end()) { //! \todo Fix me for string identifiers - TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(*idListIt - 1); + const TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(*idListIt - 1); termContainer->Initialize(it.GetIndex()); ++idListIt; } @@ -180,7 +181,7 @@ LevelSetEvolutionBase::InitializeIteration() } else // assume there is one level set that covers the RequestedRegion of the InputImage { - TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(0); + const TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(0); ImageRegionConstIteratorWithIndex it(inputImage, inputImage->GetRequestedRegion()); it.GoToBegin(); while (!it.IsAtEnd()) diff --git a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEvolutionComputeIterationThreader.hxx b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEvolutionComputeIterationThreader.hxx index cbed5fee80a..c34f366f92b 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEvolutionComputeIterationThreader.hxx +++ b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEvolutionComputeIterationThreader.hxx @@ -32,13 +32,13 @@ LevelSetEvolutionComputeIterationThreader, const ThreadIdType itkNotUsed( threadId)) { - typename LevelSetContainerType::Iterator levelSetContainerIt = this->m_Associate->m_LevelSetContainer->Begin(); - typename LevelSetType::Pointer levelSet = levelSetContainerIt->GetLevelSet(); - typename LevelSetImageType::ConstPointer levelSetImage = levelSet->GetImage(); + typename LevelSetContainerType::Iterator levelSetContainerIt = this->m_Associate->m_LevelSetContainer->Begin(); + const typename LevelSetType::Pointer levelSet = levelSetContainerIt->GetLevelSet(); + const typename LevelSetImageType::ConstPointer levelSetImage = levelSet->GetImage(); // Identify the level-set region - OffsetType offset = levelSet->GetDomainOffset(); - IndexType index = imageSubRegion.GetIndex() - offset; + const OffsetType offset = levelSet->GetDomainOffset(); + const IndexType index = imageSubRegion.GetIndex() - offset; const RegionType subRegion(index, imageSubRegion.GetSize()); ImageRegionConstIteratorWithIndex imageIt(levelSetImage, subRegion); @@ -72,7 +72,7 @@ LevelSetEvolutionComputeIterationThreader, { LevelSetDataType characteristics; termContainers[idListIdx]->ComputeRequiredData(inputIndex, characteristics); - LevelSetOutputRealType temp_update = termContainers[idListIdx]->Evaluate(inputIndex, characteristics); + const LevelSetOutputRealType temp_update = termContainers[idListIdx]->Evaluate(inputIndex, characteristics); levelSetUpdateImages[idListIdx]->SetPixel(levelSetIndex, temp_update); } ++imageIt; @@ -84,11 +84,11 @@ LevelSetEvolutionComputeIterationThreader, // set. typename LevelSetContainerType::ConstIterator levelSetUpdateContainerIt = this->m_Associate->m_UpdateBuffer->Begin(); - typename LevelSetType::Pointer levelSetUpdate = levelSetUpdateContainerIt->GetLevelSet(); - typename LevelSetImageType::Pointer levelSetUpdateImage = levelSetUpdate->GetModifiableImage(); + const typename LevelSetType::Pointer levelSetUpdate = levelSetUpdateContainerIt->GetLevelSet(); + const typename LevelSetImageType::Pointer levelSetUpdateImage = levelSetUpdate->GetModifiableImage(); - typename EquationContainerType::Iterator equationContainerIt = this->m_Associate->m_EquationContainer->Begin(); - typename TermContainerType::Pointer termContainer = equationContainerIt->GetEquation(); + typename EquationContainerType::Iterator equationContainerIt = this->m_Associate->m_EquationContainer->Begin(); + const typename TermContainerType::Pointer termContainer = equationContainerIt->GetEquation(); imageIt.GoToBegin(); while (!imageIt.IsAtEnd()) @@ -97,7 +97,7 @@ LevelSetEvolutionComputeIterationThreader, const IndexType inputIndex = imageIt.GetIndex() + offset; LevelSetDataType characteristics; termContainer->ComputeRequiredData(inputIndex, characteristics); - LevelSetOutputRealType temp_update = termContainer->Evaluate(inputIndex, characteristics); + const LevelSetOutputRealType temp_update = termContainer->Evaluate(inputIndex, characteristics); levelSetUpdateImage->SetPixel(levelSetIndex, temp_update); ++imageIt; } @@ -112,7 +112,7 @@ LevelSetEvolutionComputeIterationThreader< typename TLevelSetEvolution::DomainMapImageFilterType::DomainMapType::const_iterator>, TLevelSetEvolution>::ThreadedExecution(const DomainType & imageSubDomain, const ThreadIdType itkNotUsed(threadId)) { - typename InputImageType::ConstPointer inputImage = this->m_Associate->m_EquationContainer->GetInput(); + const typename InputImageType::ConstPointer inputImage = this->m_Associate->m_EquationContainer->GetInput(); typename DomainType::IteratorType mapIt = imageSubDomain.Begin(); while (mapIt != imageSubDomain.End()) @@ -128,16 +128,17 @@ LevelSetEvolutionComputeIterationThreader< for (auto idListIt = idList.begin(); idListIt != idList.end(); ++idListIt) { - typename LevelSetType::Pointer levelSetUpdate = this->m_Associate->m_UpdateBuffer->GetLevelSet(*idListIt - 1); + const typename LevelSetType::Pointer levelSetUpdate = + this->m_Associate->m_UpdateBuffer->GetLevelSet(*idListIt - 1); - OffsetType offset = levelSetUpdate->GetDomainOffset(); - IndexType levelSetIndex = it.GetIndex() - offset; + const OffsetType offset = levelSetUpdate->GetDomainOffset(); + const IndexType levelSetIndex = it.GetIndex() - offset; - LevelSetDataType characteristics; - typename TermContainerType::Pointer termContainer = + LevelSetDataType characteristics; + const typename TermContainerType::Pointer termContainer = this->m_Associate->m_EquationContainer->GetEquation(*idListIt - 1); termContainer->ComputeRequiredData(it.GetIndex(), characteristics); - LevelSetOutputRealType tempUpdate = termContainer->Evaluate(it.GetIndex(), characteristics); + const LevelSetOutputRealType tempUpdate = termContainer->Evaluate(it.GetIndex(), characteristics); LevelSetImageType * levelSetImage = levelSetUpdate->GetModifiableImage(); levelSetImage->SetPixel(levelSetIndex, tempUpdate); @@ -171,20 +172,21 @@ LevelSetEvolutionComputeIterationThreader< ThreadedIteratorRangePartitioner::LayerConstIterator>, TLevelSetEvolution>::ThreadedExecution(const DomainType & iteratorSubRange, const ThreadIdType threadId) { - typename LevelSetContainerType::Iterator it = this->m_Associate->m_LevelSetContainerIteratorToProcessWhenThreading; - typename LevelSetType::ConstPointer levelSet = it->GetLevelSet(); + typename LevelSetContainerType::Iterator it = this->m_Associate->m_LevelSetContainerIteratorToProcessWhenThreading; + const typename LevelSetType::ConstPointer levelSet = it->GetLevelSet(); - LevelSetIdentifierType levelSetId = it->GetIdentifier(); - OffsetType offset = levelSet->GetDomainOffset(); + const LevelSetIdentifierType levelSetId = it->GetIdentifier(); + const OffsetType offset = levelSet->GetDomainOffset(); - typename TermContainerType::Pointer termContainer = this->m_Associate->m_EquationContainer->GetEquation(levelSetId); + const typename TermContainerType::Pointer termContainer = + this->m_Associate->m_EquationContainer->GetEquation(levelSetId); typename LevelSetType::LayerConstIterator listIt = iteratorSubRange.Begin(); while (listIt != iteratorSubRange.End()) { const LevelSetInputType levelsetIndex = listIt->first; - LevelSetInputType inputIndex = listIt->first + offset; + const LevelSetInputType inputIndex = listIt->first + offset; LevelSetDataType characteristics; @@ -206,7 +208,7 @@ LevelSetEvolutionComputeIterationThreader< TLevelSetEvolution>::AfterThreadedExecution() { typename LevelSetContainerType::Iterator it = this->m_Associate->m_LevelSetContainerIteratorToProcessWhenThreading; - LevelSetIdentifierType levelSetId = it->GetIdentifier(); + const LevelSetIdentifierType levelSetId = it->GetIdentifier(); typename LevelSetEvolutionType::LevelSetLayerType * levelSetLayerUpdateBuffer = this->m_Associate->m_UpdateBuffer[levelSetId]; diff --git a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEvolutionUpdateLevelSetsThreader.hxx b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEvolutionUpdateLevelSetsThreader.hxx index 805233bfdd6..cceec747bb9 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEvolutionUpdateLevelSetsThreader.hxx +++ b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEvolutionUpdateLevelSetsThreader.hxx @@ -52,11 +52,11 @@ LevelSetEvolutionUpdateLevelSetsThreader, // This is for single level set analysis, so we only process the first level // set. - typename LevelSetType::Pointer levelSet = levelSetContainerIt->GetLevelSet(); - typename LevelSetType::Pointer levelSetUpdate = levelSetUpdateContainerIt->GetLevelSet(); + const typename LevelSetType::Pointer levelSet = levelSetContainerIt->GetLevelSet(); + const typename LevelSetType::Pointer levelSetUpdate = levelSetUpdateContainerIt->GetLevelSet(); - typename LevelSetImageType::Pointer levelSetImage = levelSet->GetModifiableImage(); - typename LevelSetImageType::ConstPointer levelSetUpdateImage = levelSetUpdate->GetImage(); + const typename LevelSetImageType::Pointer levelSetImage = levelSet->GetModifiableImage(); + const typename LevelSetImageType::ConstPointer levelSetUpdateImage = levelSetUpdate->GetImage(); ImageRegionIterator levelSetImageIt(levelSetImage, imageSubRegion); ImageRegionConstIterator levelSetUpdateImageIt(levelSetUpdateImage, imageSubRegion); diff --git a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetSparseImage.hxx b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetSparseImage.hxx index 86367894cc1..42ed74055da 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetSparseImage.hxx +++ b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetSparseImage.hxx @@ -27,7 +27,7 @@ template auto LevelSetSparseImage::Status(const InputType & inputIndex) const -> LayerIdType { - InputType mapIndex = inputIndex - this->m_DomainOffset; + const InputType mapIndex = inputIndex - this->m_DomainOffset; return this->m_LabelMap->GetPixel(mapIndex); } @@ -57,7 +57,7 @@ LevelSetSparseImage::IsInsideDomain(const InputType & input { const RegionType largestRegion = this->m_LabelMap->GetLargestPossibleRegion(); - InputType mapIndex = inputIndex - this->m_DomainOffset; + const InputType mapIndex = inputIndex - this->m_DomainOffset; return largestRegion.IsInside(mapIndex); } @@ -176,9 +176,9 @@ LevelSetSparseImage::GetAsLabelObject() while (lIt != lEnd) { - LayerIdType id = *lIt; - LabelObjectPointer labelObject = this->m_LabelMap->GetLabelObject(id); - SizeValueType numberOfLines = labelObject->GetNumberOfLines(); + const LayerIdType id = *lIt; + const LabelObjectPointer labelObject = this->m_LabelMap->GetLabelObject(id); + const SizeValueType numberOfLines = labelObject->GetNumberOfLines(); for (SizeValueType i = 0; i < numberOfLines; ++i) { diff --git a/Modules/Segmentation/LevelSetsv4/include/itkMalcolmSparseLevelSetImage.hxx b/Modules/Segmentation/LevelSetsv4/include/itkMalcolmSparseLevelSetImage.hxx index 557bc5552c2..bdd70505749 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkMalcolmSparseLevelSetImage.hxx +++ b/Modules/Segmentation/LevelSetsv4/include/itkMalcolmSparseLevelSetImage.hxx @@ -35,8 +35,8 @@ template auto MalcolmSparseLevelSetImage::Evaluate(const InputType & inputPixel) const -> OutputType { - InputType mapIndex = inputPixel - this->m_DomainOffset; - auto layerIt = this->m_Layers.begin(); + const InputType mapIndex = inputPixel - this->m_DomainOffset; + auto layerIt = this->m_Layers.begin(); while (layerIt != this->m_Layers.end()) { @@ -55,7 +55,7 @@ MalcolmSparseLevelSetImage::Evaluate(const InputType & inputPixel) c } else { - char status = this->m_LabelMap->GetPixel(mapIndex); + const char status = this->m_LabelMap->GetPixel(mapIndex); if (status == PlusOneLayer()) { return PlusOneLayer(); diff --git a/Modules/Segmentation/LevelSetsv4/include/itkShiSparseLevelSetImage.hxx b/Modules/Segmentation/LevelSetsv4/include/itkShiSparseLevelSetImage.hxx index 2d1c9570b24..82b6c344c1a 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkShiSparseLevelSetImage.hxx +++ b/Modules/Segmentation/LevelSetsv4/include/itkShiSparseLevelSetImage.hxx @@ -34,8 +34,8 @@ template auto ShiSparseLevelSetImage::Evaluate(const InputType & inputIndex) const -> OutputType { - InputType mapIndex = inputIndex - this->m_DomainOffset; - auto layerIt = this->m_Layers.begin(); + const InputType mapIndex = inputIndex - this->m_DomainOffset; + auto layerIt = this->m_Layers.begin(); while (layerIt != this->m_Layers.end()) { diff --git a/Modules/Segmentation/LevelSetsv4/include/itkUpdateMalcolmSparseLevelSet.hxx b/Modules/Segmentation/LevelSetsv4/include/itkUpdateMalcolmSparseLevelSet.hxx index 6fd81793c8e..29dc70c3bc5 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkUpdateMalcolmSparseLevelSet.hxx +++ b/Modules/Segmentation/LevelSetsv4/include/itkUpdateMalcolmSparseLevelSet.hxx @@ -118,7 +118,7 @@ UpdateMalcolmSparseLevelSet::Update() labelImageToLabelMapFilter->SetBackgroundValue(LevelSetType::PlusOneLayer()); labelImageToLabelMapFilter->Update(); - LevelSetLabelMapPointer outputLabelMap = this->m_OutputLevelSet->GetModifiableLabelMap(); + const LevelSetLabelMapPointer outputLabelMap = this->m_OutputLevelSet->GetModifiableLabelMap(); outputLabelMap->Graft(labelImageToLabelMapFilter->GetOutput()); } @@ -131,7 +131,7 @@ UpdateMalcolmSparseLevelSet::FillUpdateContainer auto nodeIt = levelZero.begin(); auto nodeEnd = levelZero.end(); - TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); + const TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); LevelSetInputType inputIndex; while (nodeIt != nodeEnd) @@ -176,7 +176,7 @@ UpdateMalcolmSparseLevelSet::EvolveWithUnPhasedP neighIt.OverrideBoundaryCondition(&sp_nbc); neighIt.ActivateOffsets(GenerateConnectedImageNeighborhoodShapeOffsets()); - TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); + const TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); LevelSetLayerType insertList; @@ -220,10 +220,10 @@ UpdateMalcolmSparseLevelSet::EvolveWithUnPhasedP for (typename NeighborhoodIteratorType::Iterator i = neighIt.Begin(); !i.IsAtEnd(); ++i) { - LevelSetOutputType tempValue = i.Get(); + const LevelSetOutputType tempValue = i.Get(); if (tempValue * newValue == -1) { - LevelSetInputType tempIndex = neighIt.GetIndex(i.GetNeighborhoodOffset()); + const LevelSetInputType tempIndex = neighIt.GetIndex(i.GetNeighborhoodOffset()); insertList.insert(NodePairType(tempIndex, tempValue)); } @@ -265,7 +265,7 @@ UpdateMalcolmSparseLevelSet::EvolveWithPhasedPro neighIt.OverrideBoundaryCondition(&sp_nbc); neighIt.ActivateOffsets(GenerateConnectedImageNeighborhoodShapeOffsets()); - TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); + const TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); LevelSetLayerType insertList; @@ -280,12 +280,12 @@ UpdateMalcolmSparseLevelSet::EvolveWithPhasedPro { itkAssertInDebugAndIgnoreInReleaseMacro(nodeIt->first == upIt->first); - LevelSetOutputType oldValue = LevelSetType::ZeroLayer(); - LevelSetOutputType newValue; + const LevelSetOutputType oldValue = LevelSetType::ZeroLayer(); + LevelSetOutputType newValue; - LevelSetOutputType update = upIt->second; - LevelSetInputType currentIdx = nodeIt->first; - LevelSetInputType inputIndex = currentIdx + this->m_Offset; + const LevelSetOutputType update = upIt->second; + const LevelSetInputType currentIdx = nodeIt->first; + const LevelSetInputType inputIndex = currentIdx + this->m_Offset; if (Math::NotAlmostEquals(update, LevelSetOutputRealType{})) { @@ -313,11 +313,11 @@ UpdateMalcolmSparseLevelSet::EvolveWithPhasedPro for (typename NeighborhoodIteratorType::Iterator i = neighIt.Begin(); !i.IsAtEnd(); ++i) { - LevelSetOutputType tempValue = i.Get(); + const LevelSetOutputType tempValue = i.Get(); if (tempValue * newValue == -1) { - LevelSetInputType tempIdx = neighIt.GetIndex(i.GetNeighborhoodOffset()); + const LevelSetInputType tempIdx = neighIt.GetIndex(i.GetNeighborhoodOffset()); insertList.insert(NodePairType(tempIdx, tempValue)); } @@ -362,12 +362,12 @@ UpdateMalcolmSparseLevelSet::CompactLayersToSing auto nodeIt = listZero.begin(); auto nodeEnd = listZero.end(); - TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); + const TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); LevelSetInputType inputIndex; while (nodeIt != nodeEnd) { - LevelSetInputType currentIdx = nodeIt->first; + const LevelSetInputType currentIdx = nodeIt->first; inputIndex = currentIdx + this->m_Offset; neighIt.SetLocation(currentIdx); @@ -375,10 +375,10 @@ UpdateMalcolmSparseLevelSet::CompactLayersToSing bool positiveUpdate = false; bool negativeUpdate = false; - LevelSetOutputRealType oldValue = LevelSetType::ZeroLayer(); + const LevelSetOutputRealType oldValue = LevelSetType::ZeroLayer(); for (typename NeighborhoodIteratorType::Iterator i = neighIt.Begin(); !i.IsAtEnd(); ++i) { - LevelSetOutputType tempValue = i.Get(); + const LevelSetOutputType tempValue = i.Get(); if (tempValue == LevelSetType::MinusOneLayer()) { negativeUpdate = true; diff --git a/Modules/Segmentation/LevelSetsv4/include/itkUpdateShiSparseLevelSet.hxx b/Modules/Segmentation/LevelSetsv4/include/itkUpdateShiSparseLevelSet.hxx index 2e150f1f6f7..32f097e40bb 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkUpdateShiSparseLevelSet.hxx +++ b/Modules/Segmentation/LevelSetsv4/include/itkUpdateShiSparseLevelSet.hxx @@ -44,7 +44,7 @@ UpdateShiSparseLevelSet::Update() this->m_Offset = this->m_InputLevelSet->GetDomainOffset(); - TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); + const TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); this->m_OutputLevelSet->SetLayer(LevelSetType::MinusOneLayer(), this->m_InputLevelSet->GetLayer(LevelSetType::MinusOneLayer())); @@ -93,7 +93,7 @@ UpdateShiSparseLevelSet::Update() for (typename NeighborhoodIteratorType::Iterator i = neighIt.Begin(); !i.IsAtEnd(); ++i) { - LevelSetOutputType tempValue = i.Get(); + const LevelSetOutputType tempValue = i.Get(); if (tempValue > LevelSetOutputType{}) { toBeDeleted = false; @@ -138,7 +138,7 @@ UpdateShiSparseLevelSet::Update() for (typename NeighborhoodIteratorType::Iterator i = neighIt.Begin(); !i.IsAtEnd(); ++i) { - LevelSetOutputType tempValue = i.Get(); + const LevelSetOutputType tempValue = i.Get(); if (tempValue < LevelSetOutputType{}) { toBeDeleted = false; @@ -169,7 +169,7 @@ UpdateShiSparseLevelSet::Update() labelImageToLabelMapFilter->SetBackgroundValue(LevelSetType::PlusThreeLayer()); labelImageToLabelMapFilter->Update(); - LevelSetLabelMapPointer outputLabelMap = this->m_OutputLevelSet->GetModifiableLabelMap(); + const LevelSetLabelMapPointer outputLabelMap = this->m_OutputLevelSet->GetModifiableLabelMap(); outputLabelMap->Graft(labelImageToLabelMapFilter->GetOutput()); } @@ -177,7 +177,7 @@ template void UpdateShiSparseLevelSet::UpdateLayerPlusOne() { - TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); + const TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); LevelSetLayerType & listOut = this->m_OutputLevelSet->GetLayer(LevelSetType::PlusOneLayer()); LevelSetLayerType & listIn = this->m_OutputLevelSet->GetLayer(LevelSetType::MinusOneLayer()); @@ -208,7 +208,7 @@ UpdateShiSparseLevelSet::UpdateLayerPlusOne() inputIndex = currentIndex + this->m_Offset; // update the level set - LevelSetOutputRealType update = termContainer->Evaluate(inputIndex); + const LevelSetOutputRealType update = termContainer->Evaluate(inputIndex); if (update < LevelSetOutputRealType{}) { @@ -226,11 +226,11 @@ UpdateShiSparseLevelSet::UpdateLayerPlusOne() for (typename NeighborhoodIteratorType::Iterator i = neighIt.Begin(); !i.IsAtEnd(); ++i) { - LevelSetOutputType tempValue = i.Get(); + const LevelSetOutputType tempValue = i.Get(); if (tempValue == LevelSetType::PlusThreeLayer()) { - LevelSetInputType tempIndex = neighIt.GetIndex(i.GetNeighborhoodOffset()); + const LevelSetInputType tempIndex = neighIt.GetIndex(i.GetNeighborhoodOffset()); insertListOut.insert(NodePairType(tempIndex, LevelSetType::PlusOneLayer())); } @@ -276,7 +276,7 @@ template void UpdateShiSparseLevelSet::UpdateLayerMinusOne() { - TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); + const TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); LevelSetLayerType & listOut = this->m_OutputLevelSet->GetLayer(LevelSetType::PlusOneLayer()); LevelSetLayerType & listIn = this->m_OutputLevelSet->GetLayer(LevelSetType::MinusOneLayer()); @@ -305,7 +305,7 @@ UpdateShiSparseLevelSet::UpdateLayerMinusOne() const LevelSetInputType inputIndex = currentIndex + this->m_Offset; // update for the current level set - LevelSetOutputRealType update = termContainer->Evaluate(inputIndex); + const LevelSetOutputRealType update = termContainer->Evaluate(inputIndex); if (update > LevelSetOutputRealType{}) { @@ -324,11 +324,11 @@ UpdateShiSparseLevelSet::UpdateLayerMinusOne() for (typename NeighborhoodIteratorType::Iterator i = neighIt.Begin(); !i.IsAtEnd(); ++i) { - LevelSetOutputType tempValue = i.Get(); + const LevelSetOutputType tempValue = i.Get(); if (tempValue == LevelSetType::MinusThreeLayer()) { - LevelSetInputType tempIndex = neighIt.GetIndex(i.GetNeighborhoodOffset()); + const LevelSetInputType tempIndex = neighIt.GetIndex(i.GetNeighborhoodOffset()); insertListIn.insert(NodePairType(tempIndex, LevelSetType::MinusOneLayer())); } @@ -375,7 +375,7 @@ UpdateShiSparseLevelSet::Con(const LevelSetInput const LevelSetOutputType & currentStatus, const LevelSetOutputRealType & currentUpdate) const { - TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); + const TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); ZeroFluxNeumannBoundaryCondition spNBC; @@ -392,13 +392,13 @@ UpdateShiSparseLevelSet::Con(const LevelSetInput for (typename NeighborhoodIteratorType::Iterator i = neighIt.Begin(); !i.IsAtEnd(); ++i) { - LevelSetOutputType tempValue = i.Get(); + const LevelSetOutputType tempValue = i.Get(); if (tempValue == oppositeStatus) { - LevelSetInputType tempIdx = neighIt.GetIndex(i.GetNeighborhoodOffset()); + const LevelSetInputType tempIdx = neighIt.GetIndex(i.GetNeighborhoodOffset()); - LevelSetOutputRealType neighborUpdate = termContainer->Evaluate(tempIdx + this->m_Offset); + const LevelSetOutputRealType neighborUpdate = termContainer->Evaluate(tempIdx + this->m_Offset); if (neighborUpdate * currentUpdate > LevelSetOutputType{}) { diff --git a/Modules/Segmentation/LevelSetsv4/include/itkUpdateWhitakerSparseLevelSet.hxx b/Modules/Segmentation/LevelSetsv4/include/itkUpdateWhitakerSparseLevelSet.hxx index 473d17b3937..fc4d533e83f 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkUpdateWhitakerSparseLevelSet.hxx +++ b/Modules/Segmentation/LevelSetsv4/include/itkUpdateWhitakerSparseLevelSet.hxx @@ -137,7 +137,7 @@ UpdateWhitakerSparseLevelSet it = layerPlus2.begin(); while (it != layerPlus2.end()) { - LevelSetInputType currentIndex = it->first; + const LevelSetInputType currentIndex = it->first; this->m_TempPhi[currentIndex] = LevelSetType::PlusTwoLayer(); neighIt.SetLocation(currentIndex); @@ -145,7 +145,7 @@ UpdateWhitakerSparseLevelSet { if (nIt.Get() == LevelSetType::PlusThreeLayer()) { - LevelSetInputType neighborIndex = neighIt.GetIndex(nIt.GetNeighborhoodOffset()); + const LevelSetInputType neighborIndex = neighIt.GetIndex(nIt.GetNeighborhoodOffset()); this->m_TempPhi[neighborIndex] = LevelSetType::PlusThreeLayer(); } } @@ -178,7 +178,7 @@ template ::UpdateLayerZero() { - TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); + const TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); LevelSetLayerType & outputLayer0 = this->m_OutputLevelSet->GetLayer(LevelSetType::ZeroLayer()); @@ -206,11 +206,11 @@ UpdateWhitakerSparseLevelSet { itkAssertInDebugAndIgnoreInReleaseMacro(nodeIt->first == upIt->first); - LevelSetInputType currentIndex = nodeIt->first; + const LevelSetInputType currentIndex = nodeIt->first; inputIndex = currentIndex + this->m_Offset; - LevelSetOutputType currentValue = nodeIt->second; - LevelSetOutputType tempUpdate = this->m_TimeStep * static_cast(upIt->second); + const LevelSetOutputType currentValue = nodeIt->second; + LevelSetOutputType tempUpdate = this->m_TimeStep * static_cast(upIt->second); if (tempUpdate > 0.5) { @@ -223,7 +223,7 @@ UpdateWhitakerSparseLevelSet tempUpdate = -0.499; } - LevelSetOutputType tempValue = currentValue + tempUpdate; + const LevelSetOutputType tempValue = currentValue + tempUpdate; this->m_RMSChangeAccumulator += tempUpdate * tempUpdate; if (tempValue > 0.5) @@ -237,7 +237,7 @@ UpdateWhitakerSparseLevelSet { if (it.Get() == LevelSetType::ZeroLayer()) { - LevelSetInputType tempIndex = neighIt.GetIndex(it.GetNeighborhoodOffset()); + const LevelSetInputType tempIndex = neighIt.GetIndex(it.GetNeighborhoodOffset()); auto tit = this->m_TempPhi.find(tempIndex); @@ -291,7 +291,7 @@ UpdateWhitakerSparseLevelSet { if (it.Get() == LevelSetType::ZeroLayer()) { - LevelSetInputType tempIndex = neighIt.GetIndex(it.GetNeighborhoodOffset()); + const LevelSetInputType tempIndex = neighIt.GetIndex(it.GetNeighborhoodOffset()); auto tit = this->m_TempPhi.find(tempIndex); if (tit != this->m_TempPhi.end()) @@ -351,7 +351,7 @@ template ::UpdateLayerMinus1() { - TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); + const TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); ZeroFluxNeumannBoundaryCondition spNBC; @@ -374,7 +374,7 @@ UpdateWhitakerSparseLevelSet while (nodeIt != nodeEnd) { - LevelSetInputType currentIndex = nodeIt->first; + const LevelSetInputType currentIndex = nodeIt->first; inputIndex = currentIndex + this->m_Offset; neighIt.SetLocation(currentIndex); @@ -386,9 +386,9 @@ UpdateWhitakerSparseLevelSet // compute M and check if point with label 0 exists in the neighborhood for (typename NeighborhoodIteratorType::Iterator it = neighIt.Begin(); !it.IsAtEnd(); ++it) { - LevelSetInputType tempIndex = neighIt.GetIndex(it.GetNeighborhoodOffset()); + const LevelSetInputType tempIndex = neighIt.GetIndex(it.GetNeighborhoodOffset()); - LevelSetLayerIdType label = it.Get(); + const LevelSetLayerIdType label = it.Get(); if (label >= LevelSetType::ZeroLayer()) { @@ -444,8 +444,8 @@ UpdateWhitakerSparseLevelSet } else // !thereIsAPointWithLabelEqualTo0 { // change layers only - auto tempIt = nodeIt; - LevelSetOutputType t = tempIt->second; + auto tempIt = nodeIt; + const LevelSetOutputType t = tempIt->second; ++nodeIt; outputlayerMinus1.erase(tempIt); @@ -467,7 +467,7 @@ UpdateWhitakerSparseLevelSet neighIt.OverrideBoundaryCondition(&spNBC); neighIt.ActivateOffsets(GenerateConnectedImageNeighborhoodShapeOffsets()); - TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); + const TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); LevelSetLayerType & layerPlus2 = this->m_TempLevelSet->GetLayer(LevelSetType::PlusTwoLayer()); LevelSetLayerType & layerZero = this->m_TempLevelSet->GetLayer(LevelSetType::ZeroLayer()); @@ -490,7 +490,7 @@ UpdateWhitakerSparseLevelSet for (typename NeighborhoodIteratorType::Iterator it = neighIt.Begin(); !it.IsAtEnd(); ++it) { - LevelSetLayerIdType label = it.Get(); + const LevelSetLayerIdType label = it.Get(); if (label <= LevelSetType::ZeroLayer()) { @@ -550,8 +550,8 @@ UpdateWhitakerSparseLevelSet } else { // change layers only - auto tempIt = nodeIt; - LevelSetOutputType t = tempIt->second; + auto tempIt = nodeIt; + const LevelSetOutputType t = tempIt->second; ++nodeIt; outputLayerPlus1.erase(tempIt); layerPlus2.insert(NodePairType(currentIndex, t)); @@ -572,7 +572,7 @@ UpdateWhitakerSparseLevelSet neighIt.OverrideBoundaryCondition(&spNBC); neighIt.ActivateOffsets(GenerateConnectedImageNeighborhoodShapeOffsets()); - TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); + const TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); LevelSetLayerType & outputLayerMinus2 = this->m_OutputLevelSet->GetLayer(LevelSetType::MinusTwoLayer()); LevelSetLayerType & layerMinus1 = this->m_TempLevelSet->GetLayer(LevelSetType::MinusOneLayer()); @@ -676,7 +676,7 @@ UpdateWhitakerSparseLevelSet neighIt.OverrideBoundaryCondition(&spNBC); neighIt.ActivateOffsets(GenerateConnectedImageNeighborhoodShapeOffsets()); - TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); + const TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); LevelSetLayerType & outputLayerPlus2 = this->m_OutputLevelSet->GetLayer(LevelSetType::PlusTwoLayer()); LevelSetLayerType & layerPlusOne = this->m_TempLevelSet->GetLayer(LevelSetType::PlusOneLayer()); @@ -696,7 +696,7 @@ UpdateWhitakerSparseLevelSet for (typename NeighborhoodIteratorType::Iterator it = neighIt.Begin(); !it.IsAtEnd(); ++it) { - LevelSetLayerIdType label = it.Get(); + const LevelSetLayerIdType label = it.Get(); if (label <= LevelSetType::PlusOneLayer()) { if (label == LevelSetType::PlusOneLayer()) @@ -803,7 +803,7 @@ UpdateWhitakerSparseLevelSet neighIt.OverrideBoundaryCondition(&spNBC); neighIt.ActivateOffsets(GenerateConnectedImageNeighborhoodShapeOffsets()); - TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); + const TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); LevelSetLayerType & layerMinus1 = this->m_TempLevelSet->GetLayer(LevelSetType::MinusOneLayer()); LevelSetLayerType & layerMinus2 = this->m_TempLevelSet->GetLayer(LevelSetType::MinusTwoLayer()); @@ -815,8 +815,8 @@ UpdateWhitakerSparseLevelSet while (nodeIt != nodeEnd) { - LevelSetInputType currentIndex = nodeIt->first; - LevelSetOutputType currentValue = nodeIt->second; + const LevelSetInputType currentIndex = nodeIt->first; + const LevelSetOutputType currentValue = nodeIt->second; outputlayerMinus1.insert(NodePairType(currentIndex, currentValue)); @@ -830,7 +830,7 @@ UpdateWhitakerSparseLevelSet for (typename NeighborhoodIteratorType::Iterator it = neighIt.Begin(); !it.IsAtEnd(); ++it) { - LevelSetInputType tempIndex = neighIt.GetIndex(it.GetNeighborhoodOffset()); + const LevelSetInputType tempIndex = neighIt.GetIndex(it.GetNeighborhoodOffset()); auto phiIt = this->m_TempPhi.find(tempIndex); if (phiIt != this->m_TempPhi.end()) @@ -860,7 +860,7 @@ UpdateWhitakerSparseLevelSet neighIt.OverrideBoundaryCondition(&spNBC); neighIt.ActivateOffsets(GenerateConnectedImageNeighborhoodShapeOffsets()); - TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); + const TermContainerPointer termContainer = this->m_EquationContainer->GetEquation(this->m_CurrentLevelSetId); LevelSetLayerType & layerPlus1 = this->m_TempLevelSet->GetLayer(LevelSetType::PlusOneLayer()); LevelSetLayerType & layerPlus2 = this->m_TempLevelSet->GetLayer(LevelSetType::PlusTwoLayer()); @@ -872,8 +872,8 @@ UpdateWhitakerSparseLevelSet while (nodeIt != nodeEnd) { - LevelSetInputType currentIndex = nodeIt->first; - LevelSetOutputType currentValue = nodeIt->second; + const LevelSetInputType currentIndex = nodeIt->first; + const LevelSetOutputType currentValue = nodeIt->second; outputLayerPlus1.insert(NodePairType(currentIndex, currentValue)); this->m_InternalImage->SetPixel(currentIndex, LevelSetType::PlusOneLayer()); @@ -886,7 +886,7 @@ UpdateWhitakerSparseLevelSet for (typename NeighborhoodIteratorType::Iterator it = neighIt.Begin(); !it.IsAtEnd(); ++it) { - LevelSetInputType tempIndex = neighIt.GetIndex(it.GetNeighborhoodOffset()); + const LevelSetInputType tempIndex = neighIt.GetIndex(it.GetNeighborhoodOffset()); auto phiIt = this->m_TempPhi.find(tempIndex); if (phiIt != this->m_TempPhi.end()) diff --git a/Modules/Segmentation/LevelSetsv4/include/itkWhitakerSparseLevelSetImage.h b/Modules/Segmentation/LevelSetsv4/include/itkWhitakerSparseLevelSetImage.h index bac241d9698..55d795283c4 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkWhitakerSparseLevelSetImage.h +++ b/Modules/Segmentation/LevelSetsv4/include/itkWhitakerSparseLevelSetImage.h @@ -141,7 +141,7 @@ class ITK_TEMPLATE_EXPORT WhitakerSparseLevelSetImage : public LevelSetSparseIma for (LayerIdType status = this->MinusThreeLayer(); status < this->PlusOneLayer(); ++status) { - LabelObjectPointer labelObject = this->m_LabelMap->GetLabelObject(status); + const LabelObjectPointer labelObject = this->m_LabelMap->GetLabelObject(status); for (SizeValueType i = 0; i < labelObject->GetNumberOfLines(); ++i) { diff --git a/Modules/Segmentation/LevelSetsv4/include/itkWhitakerSparseLevelSetImage.hxx b/Modules/Segmentation/LevelSetsv4/include/itkWhitakerSparseLevelSetImage.hxx index c886beaefe4..8df295589aa 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkWhitakerSparseLevelSetImage.hxx +++ b/Modules/Segmentation/LevelSetsv4/include/itkWhitakerSparseLevelSetImage.hxx @@ -34,8 +34,8 @@ template auto WhitakerSparseLevelSetImage::Evaluate(const InputType & inputIndex) const -> OutputType { - InputType mapIndex = inputIndex - this->m_DomainOffset; - auto layerIt = this->m_Layers.begin(); + const InputType mapIndex = inputIndex - this->m_DomainOffset; + auto layerIt = this->m_Layers.begin(); auto rval = static_cast(ZeroLayer()); @@ -61,7 +61,7 @@ WhitakerSparseLevelSetImage::Evaluate(const InputType & inp } else { - char status = this->m_LabelMap->GetPixel(mapIndex); + const char status = this->m_LabelMap->GetPixel(mapIndex); if (status == this->PlusThreeLayer()) { rval = static_cast(this->PlusThreeLayer()); diff --git a/Modules/Segmentation/LevelSetsv4/test/itkBinaryImageToMalcolmSparseLevelSetAdaptorTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkBinaryImageToMalcolmSparseLevelSetAdaptorTest.cxx index e075f033490..573450825b2 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkBinaryImageToMalcolmSparseLevelSetAdaptorTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkBinaryImageToMalcolmSparseLevelSetAdaptorTest.cxx @@ -55,7 +55,7 @@ itkBinaryImageToMalcolmSparseLevelSetAdaptorTest(int argc, char * argv[]) std::cout << err << std::endl; return EXIT_FAILURE; } - InputImageType::Pointer input = reader->GetOutput(); + const InputImageType::Pointer input = reader->GetOutput(); std::cout << "Input image read" << std::endl; using LevelSetType = itk::MalcolmSparseLevelSetImage; @@ -66,7 +66,7 @@ itkBinaryImageToMalcolmSparseLevelSetAdaptorTest(int argc, char * argv[]) adaptor->Initialize(); std::cout << "Finished converting to sparse format" << std::endl; - LevelSetType::Pointer sparseLevelSet = adaptor->GetModifiableLevelSet(); + const LevelSetType::Pointer sparseLevelSet = adaptor->GetModifiableLevelSet(); using StatusImageType = itk::Image; auto statusImage = StatusImageType::New(); @@ -119,8 +119,8 @@ itkBinaryImageToMalcolmSparseLevelSetAdaptorTest(int argc, char * argv[]) using LabelObjectType = itk::LabelObject; using LabelObjectPointer = LabelObjectType::Pointer; - LabelObjectPointer labelObject = LabelObjectType::New(); - LabelObjectPointer labelObjectSrc = sparseLevelSet->GetAsLabelObject(); + const LabelObjectPointer labelObject = LabelObjectType::New(); + const LabelObjectPointer labelObjectSrc = sparseLevelSet->GetAsLabelObject(); labelObject->CopyAllFrom(labelObjectSrc); labelObject->SetLabel(sparseLevelSet->PlusOneLayer()); diff --git a/Modules/Segmentation/LevelSetsv4/test/itkBinaryImageToShiSparseLevelSetAdaptorTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkBinaryImageToShiSparseLevelSetAdaptorTest.cxx index 4b6e41b3a8f..2de051989c0 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkBinaryImageToShiSparseLevelSetAdaptorTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkBinaryImageToShiSparseLevelSetAdaptorTest.cxx @@ -50,7 +50,7 @@ itkBinaryImageToShiSparseLevelSetAdaptorTest(int argc, char * argv[]) std::cout << err << std::endl; return EXIT_FAILURE; } - InputImageType::Pointer input = reader->GetOutput(); + const InputImageType::Pointer input = reader->GetOutput(); std::cout << "Input image read" << std::endl; using LevelSetType = itk::ShiSparseLevelSetImage; @@ -64,7 +64,7 @@ itkBinaryImageToShiSparseLevelSetAdaptorTest(int argc, char * argv[]) using LayerIdType = LevelSetType::LayerIdType; - LevelSetType::Pointer sparseLevelSet = adaptor->GetModifiableLevelSet(); + const LevelSetType::Pointer sparseLevelSet = adaptor->GetModifiableLevelSet(); using StatusImageType = itk::Image; auto statusImage = StatusImageType::New(); @@ -119,8 +119,8 @@ itkBinaryImageToShiSparseLevelSetAdaptorTest(int argc, char * argv[]) using LabelObjectType = itk::LabelObject; using LabelObjectPointer = LabelObjectType::Pointer; - LabelObjectPointer labelObject = LabelObjectType::New(); - LabelObjectPointer labelObjectSrc = sparseLevelSet->GetAsLabelObject(); + const LabelObjectPointer labelObject = LabelObjectType::New(); + const LabelObjectPointer labelObjectSrc = sparseLevelSet->GetAsLabelObject(); labelObject->CopyAllFrom(labelObjectSrc); labelObject->SetLabel(sparseLevelSet->PlusOneLayer()); diff --git a/Modules/Segmentation/LevelSetsv4/test/itkBinaryImageToWhitakerSparseLevelSetAdaptorTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkBinaryImageToWhitakerSparseLevelSetAdaptorTest.cxx index 6f0f306f7f8..fa89c0196f8 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkBinaryImageToWhitakerSparseLevelSetAdaptorTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkBinaryImageToWhitakerSparseLevelSetAdaptorTest.cxx @@ -53,7 +53,7 @@ itkBinaryImageToWhitakerSparseLevelSetAdaptorTest(int argc, char * argv[]) return EXIT_FAILURE; } - InputImageType::Pointer input = reader->GetOutput(); + const InputImageType::Pointer input = reader->GetOutput(); std::cout << "Input image read" << std::endl; using LevelSetType = itk::WhitakerSparseLevelSetImage; @@ -67,7 +67,7 @@ itkBinaryImageToWhitakerSparseLevelSetAdaptorTest(int argc, char * argv[]) std::cout << "Finished converting to sparse format" << std::endl; using LayerIdType = LevelSetType::LayerIdType; - LevelSetType::Pointer sparseLevelSet = adaptor->GetModifiableLevelSet(); + const LevelSetType::Pointer sparseLevelSet = adaptor->GetModifiableLevelSet(); using OutputImageType = itk::Image; auto output = OutputImageType::New(); @@ -149,8 +149,8 @@ itkBinaryImageToWhitakerSparseLevelSetAdaptorTest(int argc, char * argv[]) using LabelObjectType = itk::LabelObject; using LabelObjectPointer = LabelObjectType::Pointer; - LabelObjectPointer labelObject = LabelObjectType::New(); - LabelObjectPointer labelObjectSrc = sparseLevelSet->GetAsLabelObject(); + const LabelObjectPointer labelObject = LabelObjectType::New(); + const LabelObjectPointer labelObjectSrc = sparseLevelSet->GetAsLabelObject(); labelObject->CopyAllFrom(labelObjectSrc); labelObject->SetLabel(sparseLevelSet->PlusOneLayer()); diff --git a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDenseImageTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDenseImageTest.cxx index 530647096ef..a73bb0a9f57 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDenseImageTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDenseImageTest.cxx @@ -87,9 +87,9 @@ itkLevelSetDenseImageTest(int, char *[]) size[0] = 10; size[1] = 20; - ImageType::RegionType region{ index, size }; + const ImageType::RegionType region{ index, size }; - PixelType zeroValue = 0.; + const PixelType zeroValue = 0.; ImageType::SpacingType spacing; spacing[0] = 0.02 / size[0]; @@ -121,7 +121,7 @@ itkLevelSetDenseImageTest(int, char *[]) idx = it.GetIndex(); input->TransformIndexToPhysicalPoint(idx, pt); - PixelType tempValue = testFunction->Evaluate(pt); + const PixelType tempValue = testFunction->Evaluate(pt); it.Set(tempValue); @@ -210,10 +210,10 @@ itkLevelSetDenseImageTest(int, char *[]) return EXIT_FAILURE; } - LevelSetType::OutputRealType laplacian = levelSet->EvaluateLaplacian(idx); + const LevelSetType::OutputRealType laplacian = levelSet->EvaluateLaplacian(idx); std::cout << "laplacian = " << laplacian << std::endl; - LevelSetType::OutputRealType gradientnorm = levelSet->EvaluateGradientNorm(idx); + const LevelSetType::OutputRealType gradientnorm = levelSet->EvaluateGradientNorm(idx); std::cout << "gradient norm = " << gradientnorm << std::endl; if (itk::Math::abs(1 - gradientnorm) > 5e-2) @@ -222,7 +222,7 @@ itkLevelSetDenseImageTest(int, char *[]) return EXIT_FAILURE; } - LevelSetType::OutputRealType meancurvature = levelSet->EvaluateMeanCurvature(idx); + const LevelSetType::OutputRealType meancurvature = levelSet->EvaluateMeanCurvature(idx); std::cout << "mean curvature = " << meancurvature << std::endl; return EXIT_SUCCESS; diff --git a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDomainMapImageFilterTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDomainMapImageFilterTest.cxx index 0d17ddccb43..cfa0b9b35d7 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDomainMapImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDomainMapImageFilterTest.cxx @@ -40,9 +40,9 @@ itkLevelSetDomainMapImageFilterTest(int, char *[]) size[0] = 10; size[1] = 10; - InputImageType::RegionType region{ index, size }; + const InputImageType::RegionType region{ index, size }; - ListPixelType l; + const ListPixelType l; auto input = InputImageType::New(); input->SetRegions(region); @@ -67,7 +67,7 @@ itkLevelSetDomainMapImageFilterTest(int, char *[]) filter->SetInput(input); filter->Update(); - OutputImageType::Pointer output = filter->GetOutput(); + const OutputImageType::Pointer output = filter->GetOutput(); using OutputImageIteratorType = itk::ImageRegionConstIteratorWithIndex; OutputImageIteratorType it(output, output->GetLargestPossibleRegion()); diff --git a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDomainPartitionBaseTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDomainPartitionBaseTest.cxx index f2e59eaf9fe..6e5c0bbce25 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDomainPartitionBaseTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDomainPartitionBaseTest.cxx @@ -58,7 +58,7 @@ itkLevelSetDomainPartitionBaseTest(int, char *[]) using DomainPartitionBaseHelperType = itk::LevelSetDomainPartitionBaseHelper; - itk::IdentifierType count = 2; + const itk::IdentifierType count = 2; auto function = DomainPartitionBaseHelperType::New(); function->SetNumberOfLevelSetFunctions(count); diff --git a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDomainPartitionImageTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDomainPartitionImageTest.cxx index 5737edf62c6..2a1df299f14 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDomainPartitionImageTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDomainPartitionImageTest.cxx @@ -47,9 +47,9 @@ itkLevelSetDomainPartitionImageTest(int, char *[]) spacing[0] = 1.0; spacing[1] = 1.0; - InputImageType::IndexType index{}; + const InputImageType::IndexType index{}; - InputImageType::RegionType region{ index, size }; + const InputImageType::RegionType region{ index, size }; // Binary initialization auto binary = InputImageType::New(); @@ -59,7 +59,7 @@ itkLevelSetDomainPartitionImageTest(int, char *[]) binary->Allocate(); binary->FillBuffer(InputPixelType{}); - IdentifierType numberOfLevelSetFunctions = 2; + const IdentifierType numberOfLevelSetFunctions = 2; LevelSetDomainRegionVectorType regionVector; regionVector.resize(numberOfLevelSetFunctions); @@ -94,9 +94,9 @@ itkLevelSetDomainPartitionImageTest(int, char *[]) bool flag = true; - ListType ll; - ListImageType::ConstPointer listImage = partitionSource->GetListDomain(); - ListImageIteratorType It(listImage, listImage->GetLargestPossibleRegion()); + ListType ll; + const ListImageType::ConstPointer listImage = partitionSource->GetListDomain(); + ListImageIteratorType It(listImage, listImage->GetLargestPossibleRegion()); It.GoToBegin(); while (!It.IsAtEnd()) { diff --git a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDomainPartitionImageWithKdTreeTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDomainPartitionImageWithKdTreeTest.cxx index 106c1ce0258..a5d129cf5aa 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDomainPartitionImageWithKdTreeTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetDomainPartitionImageWithKdTreeTest.cxx @@ -55,7 +55,7 @@ itkLevelSetDomainPartitionImageWithKdTreeTest(int, char *[]) InputImageType::IndexType index{}; - InputImageType::RegionType region{ index, size }; + const InputImageType::RegionType region{ index, size }; // Binary initialization auto binary = InputImageType::New(); @@ -65,7 +65,7 @@ itkLevelSetDomainPartitionImageWithKdTreeTest(int, char *[]) binary->Allocate(); binary->FillBuffer(InputPixelType{}); - IdentifierType numberOfLevelSetFunctions = 10; + const IdentifierType numberOfLevelSetFunctions = 10; LevelSetDomainRegionVectorType regionVector; regionVector.resize(numberOfLevelSetFunctions); @@ -80,7 +80,7 @@ itkLevelSetDomainPartitionImageWithKdTreeTest(int, char *[]) index[1] = 0; size.Fill(10); - InputImageType::RegionType region1{ index, size }; + const InputImageType::RegionType region1{ index, size }; regionVector[i] = region1; @@ -93,7 +93,7 @@ itkLevelSetDomainPartitionImageWithKdTreeTest(int, char *[]) treeGenerator->SetSample(sample); treeGenerator->SetBucketSize(2); treeGenerator->Update(); - TreeType::Pointer kdtree = treeGenerator->GetOutput(); + const TreeType::Pointer kdtree = treeGenerator->GetOutput(); auto partitionSource = DomainPartitionSourceType::New(); @@ -105,7 +105,7 @@ itkLevelSetDomainPartitionImageWithKdTreeTest(int, char *[]) partitionSource->SetImage(binary); partitionSource->SetLevelSetDomainRegionVector(regionVector); - typename DomainPartitionSourceType::NeighborsIdType numberOfNeighbors = 3; + const typename DomainPartitionSourceType::NeighborsIdType numberOfNeighbors = 3; partitionSource->SetNumberOfNeighbors(numberOfNeighbors); ITK_TEST_SET_GET_VALUE(numberOfNeighbors, partitionSource->GetNumberOfNeighbors()); @@ -115,9 +115,9 @@ itkLevelSetDomainPartitionImageWithKdTreeTest(int, char *[]) bool flag = true; - ListType ll; - ListImageType::ConstPointer listImage = partitionSource->GetListDomain(); - ListImageIteratorType It(listImage, listImage->GetLargestPossibleRegion()); + ListType ll; + const ListImageType::ConstPointer listImage = partitionSource->GetListDomain(); + ListImageIteratorType It(listImage, listImage->GetLargestPossibleRegion()); It.GoToBegin(); while (!It.IsAtEnd()) { @@ -134,7 +134,7 @@ itkLevelSetDomainPartitionImageWithKdTreeTest(int, char *[]) while (it != ll.end()) { - IdentifierType id = index[0] / 10; + const IdentifierType id = index[0] / 10; if (*it != id) { flag = false; diff --git a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationBinaryMaskTermTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationBinaryMaskTermTest.cxx index 6aac1425271..01fe41e6bcf 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationBinaryMaskTermTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationBinaryMaskTermTest.cxx @@ -96,7 +96,7 @@ itkLevelSetEquationBinaryMaskTermTest(int, char *[]) adaptor1->Initialize(); std::cout << "Finished converting levelset1 to sparse format" << std::endl; - SparseLevelSetType::Pointer level_set1 = adaptor1->GetModifiableLevelSet(); + const SparseLevelSetType::Pointer level_set1 = adaptor1->GetModifiableLevelSet(); IdListType list_ids; list_ids.push_back(1); @@ -120,7 +120,7 @@ itkLevelSetEquationBinaryMaskTermTest(int, char *[]) lscontainer->SetHeaviside(heaviside); lscontainer->SetDomainMapFilter(domainMapFilter); - bool LevelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set1, false); + const bool LevelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set1, false); if (!LevelSetNotYetAdded) { return EXIT_FAILURE; diff --git a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationChanAndVeseExternalTermTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationChanAndVeseExternalTermTest.cxx index b90a7781ab5..5bc263e04b3 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationChanAndVeseExternalTermTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationChanAndVeseExternalTermTest.cxx @@ -105,7 +105,7 @@ itkLevelSetEquationChanAndVeseExternalTermTest(int argc, char * argv[]) adaptor->Initialize(); std::cout << "Finished converting to sparse format" << std::endl; - SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); + const SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); IdListType list_ids; list_ids.push_back(1); diff --git a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationChanAndVeseInternalTermTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationChanAndVeseInternalTermTest.cxx index b4949b4fb02..eda48595c5c 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationChanAndVeseInternalTermTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationChanAndVeseInternalTermTest.cxx @@ -108,7 +108,7 @@ itkLevelSetEquationChanAndVeseInternalTermTest(int argc, char * argv[]) adaptor->Initialize(); std::cout << "Finished converting to sparse format" << std::endl; - SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); + const SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); IdListType list_ids; list_ids.push_back(1); @@ -132,7 +132,7 @@ itkLevelSetEquationChanAndVeseInternalTermTest(int argc, char * argv[]) lscontainer->SetHeaviside(heaviside); lscontainer->SetDomainMapFilter(domainMapFilter); - bool LevelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); + const bool LevelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); if (!LevelSetNotYetAdded) { return EXIT_FAILURE; diff --git a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationCurvatureTermTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationCurvatureTermTest.cxx index e12aa2596cb..5ad047fb8a5 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationCurvatureTermTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationCurvatureTermTest.cxx @@ -103,7 +103,7 @@ itkLevelSetEquationCurvatureTermTest(int argc, char * argv[]) adaptor->Initialize(); std::cout << "Finished converting to sparse format" << std::endl; - SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); + const SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); IdListType list_ids; list_ids.push_back(1); @@ -127,7 +127,7 @@ itkLevelSetEquationCurvatureTermTest(int argc, char * argv[]) lscontainer->SetHeaviside(heaviside); lscontainer->SetDomainMapFilter(domainMapFilter); - bool LevelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); + const bool LevelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); if (!LevelSetNotYetAdded) { return EXIT_FAILURE; @@ -161,7 +161,7 @@ itkLevelSetEquationCurvatureTermTest(int argc, char * argv[]) index[0] = 10; index[1] = 20; - CurvatureTermType::LevelSetOutputRealType value = term->Evaluate(index); + const CurvatureTermType::LevelSetOutputRealType value = term->Evaluate(index); if (itk::Math::abs(value) > 5e-2) { std::cerr << "( itk::Math::abs( " << value << " ) > 5e-2 )" << std::endl; @@ -188,7 +188,7 @@ itkLevelSetEquationCurvatureTermTest(int argc, char * argv[]) return EXIT_FAILURE; } - bool useCurvatureImage = false; + const bool useCurvatureImage = false; ITK_TEST_SET_GET_BOOLEAN(term, UseCurvatureImage, useCurvatureImage); if (itk::Math::NotAlmostEquals(term->Evaluate(index), value)) diff --git a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationLaplacianTermTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationLaplacianTermTest.cxx index 6c711a1f746..c83885482c7 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationLaplacianTermTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationLaplacianTermTest.cxx @@ -102,7 +102,7 @@ itkLevelSetEquationLaplacianTermTest(int argc, char * argv[]) adaptor->Initialize(); std::cout << "Finished converting to sparse format" << std::endl; - SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); + const SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); IdListType list_ids; list_ids.push_back(1); @@ -126,7 +126,7 @@ itkLevelSetEquationLaplacianTermTest(int argc, char * argv[]) lscontainer->SetHeaviside(heaviside); lscontainer->SetDomainMapFilter(domainMapFilter); - bool LevelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); + const bool LevelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); if (!LevelSetNotYetAdded) { return EXIT_FAILURE; @@ -141,18 +141,18 @@ itkLevelSetEquationLaplacianTermTest(int argc, char * argv[]) term->SetInput(binary); ITK_TEST_SET_GET_VALUE(binary, term->GetInput()); - typename LaplacianTermType::LevelSetOutputRealType coefficient = 1.0; + const typename LaplacianTermType::LevelSetOutputRealType coefficient = 1.0; term->SetCoefficient(coefficient); ITK_TEST_SET_GET_VALUE(coefficient, term->GetCoefficient()); - typename LaplacianTermType::LevelSetIdentifierType currentLevelSetId = 0; + const typename LaplacianTermType::LevelSetIdentifierType currentLevelSetId = 0; term->SetCurrentLevelSetId(currentLevelSetId); ITK_TEST_SET_GET_VALUE(currentLevelSetId, term->GetCurrentLevelSetId()); term->SetLevelSetContainer(lscontainer); ITK_TEST_SET_GET_VALUE(lscontainer, term->GetLevelSetContainer()); - std::string termName = "Laplacia term"; + const std::string termName = "Laplacia term"; term->SetTermName(termName); ITK_TEST_SET_GET_VALUE(termName, term->GetTermName()); diff --git a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationOverlapPenaltyTermTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationOverlapPenaltyTermTest.cxx index 407721e0bcf..13462702ed0 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationOverlapPenaltyTermTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationOverlapPenaltyTermTest.cxx @@ -102,8 +102,8 @@ itkLevelSetEquationOverlapPenaltyTermTest(int, char *[]) adaptor2->Initialize(); std::cout << "Finished converting levelset2 to sparse format" << std::endl; - SparseLevelSetType::Pointer level_set1 = adaptor1->GetModifiableLevelSet(); - SparseLevelSetType::Pointer level_set2 = adaptor2->GetModifiableLevelSet(); + const SparseLevelSetType::Pointer level_set1 = adaptor1->GetModifiableLevelSet(); + const SparseLevelSetType::Pointer level_set2 = adaptor2->GetModifiableLevelSet(); IdListType list_ids; list_ids.push_back(1); @@ -156,18 +156,18 @@ itkLevelSetEquationOverlapPenaltyTermTest(int, char *[]) penaltyTerm1->SetInput(binary); ITK_TEST_SET_GET_VALUE(binary, penaltyTerm1->GetInput()); - typename OverlapPenaltyTermType::LevelSetOutputRealType coefficient = 1000.0; + const typename OverlapPenaltyTermType::LevelSetOutputRealType coefficient = 1000.0; penaltyTerm1->SetCoefficient(coefficient); ITK_TEST_SET_GET_VALUE(coefficient, penaltyTerm1->GetCoefficient()); - typename OverlapPenaltyTermType::LevelSetIdentifierType currentLevelSetId = 1; + const typename OverlapPenaltyTermType::LevelSetIdentifierType currentLevelSetId = 1; penaltyTerm1->SetCurrentLevelSetId(currentLevelSetId); ITK_TEST_SET_GET_VALUE(currentLevelSetId, penaltyTerm1->GetCurrentLevelSetId()); penaltyTerm1->SetLevelSetContainer(lscontainer); ITK_TEST_SET_GET_VALUE(lscontainer, penaltyTerm1->GetLevelSetContainer()); - std::string termName = "Overlap term"; + const std::string termName = "Overlap term"; penaltyTerm1->SetTermName(termName); ITK_TEST_SET_GET_VALUE(termName, penaltyTerm1->GetTermName()); diff --git a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationPropagationTermTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationPropagationTermTest.cxx index ea754b212a8..9b20c9d3fe1 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationPropagationTermTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationPropagationTermTest.cxx @@ -102,7 +102,7 @@ itkLevelSetEquationPropagationTermTest(int argc, char * argv[]) adaptor->Initialize(); std::cout << "Finished converting to sparse format" << std::endl; - SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); + const SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); IdListType list_ids; list_ids.push_back(1); @@ -126,7 +126,7 @@ itkLevelSetEquationPropagationTermTest(int argc, char * argv[]) lscontainer->SetHeaviside(heaviside); lscontainer->SetDomainMapFilter(domainMapFilter); - bool LevelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); + const bool LevelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); if (!LevelSetNotYetAdded) { return EXIT_FAILURE; diff --git a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationTermContainerTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationTermContainerTest.cxx index e6f8331d687..08584846178 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationTermContainerTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEquationTermContainerTest.cxx @@ -110,7 +110,7 @@ itkLevelSetEquationTermContainerTest(int argc, char * argv[]) adaptor->Initialize(); std::cout << "Finished converting to sparse format" << std::endl; - SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); + const SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); IdListType list_ids; list_ids.push_back(1); @@ -134,7 +134,7 @@ itkLevelSetEquationTermContainerTest(int argc, char * argv[]) lscontainer->SetHeaviside(heaviside); lscontainer->SetDomainMapFilter(domainMapFilter); - bool LevelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); + const bool LevelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); if (!LevelSetNotYetAdded) { return EXIT_FAILURE; @@ -159,7 +159,7 @@ itkLevelSetEquationTermContainerTest(int argc, char * argv[]) termContainer0->SetInput(binary); ITK_TEST_SET_GET_VALUE(binary, termContainer0->GetInput()); - typename TermContainerType::LevelSetIdentifierType currentLevelSetId = 0; + const typename TermContainerType::LevelSetIdentifierType currentLevelSetId = 0; termContainer0->SetCurrentLevelSetId(currentLevelSetId); ITK_TEST_SET_GET_VALUE(currentLevelSetId, termContainer0->GetCurrentLevelSetId()); diff --git a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEvolutionNumberOfIterationsStoppingCriterionTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEvolutionNumberOfIterationsStoppingCriterionTest.cxx index 12c5be96b71..89106befa38 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEvolutionNumberOfIterationsStoppingCriterionTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkLevelSetEvolutionNumberOfIterationsStoppingCriterionTest.cxx @@ -38,11 +38,11 @@ itkLevelSetEvolutionNumberOfIterationsStoppingCriterionTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS( criterion, LevelSetEvolutionNumberOfIterationsStoppingCriterion, LevelSetEvolutionStoppingCriterion); - typename StoppingCriterionType::IterationIdType numberOfIterations = 5; + const typename StoppingCriterionType::IterationIdType numberOfIterations = 5; criterion->SetNumberOfIterations(numberOfIterations); ITK_TEST_SET_GET_VALUE(numberOfIterations, criterion->GetNumberOfIterations()); - typename StoppingCriterionType::OutputRealType rmsChangeAccumulator = 0.1; + const typename StoppingCriterionType::OutputRealType rmsChangeAccumulator = 0.1; criterion->SetRMSChangeAccumulator(rmsChangeAccumulator); ITK_TEST_SET_GET_VALUE(rmsChangeAccumulator, criterion->GetRMSChangeAccumulator()); diff --git a/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetChanAndVeseInternalTermTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetChanAndVeseInternalTermTest.cxx index d518d175bcd..a1228d1a805 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetChanAndVeseInternalTermTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetChanAndVeseInternalTermTest.cxx @@ -57,9 +57,9 @@ itkMultiLevelSetChanAndVeseInternalTermTest(int, char *[]) size[0] = 10; size[1] = 10; - ImageType::RegionType region{ index, size }; + const ImageType::RegionType region{ index, size }; - PixelType value = 0.; + const PixelType value = 0.; auto input = InputImageType::New(); input->SetRegions(region); @@ -99,7 +99,7 @@ itkMultiLevelSetChanAndVeseInternalTermTest(int, char *[]) auto domainMapFilter = DomainMapImageFilterType::New(); domainMapFilter->SetInput(id_image); domainMapFilter->Update(); - CacheImageType::Pointer output = domainMapFilter->GetOutput(); + const CacheImageType::Pointer output = domainMapFilter->GetOutput(); std::cout << "Domain partition computed" << std::endl; IteratorType it1(input1, input1->GetLargestPossibleRegion()); diff --git a/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetDenseImageSubset2DTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetDenseImageSubset2DTest.cxx index 346e9c190cd..a0fee021b72 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetDenseImageSubset2DTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetDenseImageSubset2DTest.cxx @@ -134,17 +134,17 @@ itkMultiLevelSetDenseImageSubset2DTest(int, char *[]) auto adaptor1 = BinaryImageToLevelSetType::New(); adaptor1->SetInputImage(binary); adaptor1->Initialize(); - LevelSetType::Pointer levelSet1 = adaptor1->GetModifiableLevelSet(); + const LevelSetType::Pointer levelSet1 = adaptor1->GetModifiableLevelSet(); auto adaptor2 = BinaryImageToLevelSetType::New(); adaptor2->SetInputImage(binary); adaptor2->Initialize(); - LevelSetType::Pointer levelSet2 = adaptor2->GetModifiableLevelSet(); + const LevelSetType::Pointer levelSet2 = adaptor2->GetModifiableLevelSet(); auto adaptor3 = BinaryImageToLevelSetType::New(); adaptor3->SetInputImage(binary); adaptor3->Initialize(); - LevelSetType::Pointer levelSet3 = adaptor3->GetModifiableLevelSet(); + const LevelSetType::Pointer levelSet3 = adaptor3->GetModifiableLevelSet(); index = input->TransformPhysicalPointToIndex(binary->GetOrigin()); InputImageType::OffsetType offset; diff --git a/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetDenseImageTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetDenseImageTest.cxx index 78a6fca34ea..a8a4754b747 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetDenseImageTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetDenseImageTest.cxx @@ -40,9 +40,9 @@ itkMultiLevelSetDenseImageTest(int, char *[]) size[0] = 10; size[1] = 10; - ImageType::RegionType region{ index, size }; + const ImageType::RegionType region{ index, size }; - PixelType value = 0.; + const PixelType value = 0.; auto input1 = ImageType::New(); input1->SetRegions(region); @@ -101,7 +101,7 @@ itkMultiLevelSetDenseImageTest(int, char *[]) auto filter = DomainMapImageFilterType::New(); filter->SetInput(id_image); filter->Update(); - CacheImageType::Pointer output = filter->GetOutput(); + const CacheImageType::Pointer output = filter->GetOutput(); itk::ImageRegionConstIteratorWithIndex it(output, output->GetLargestPossibleRegion()); diff --git a/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetEvolutionTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetEvolutionTest.cxx index 2be0a7cc296..5bb165010c4 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetEvolutionTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetEvolutionTest.cxx @@ -66,9 +66,9 @@ itkMultiLevelSetEvolutionTest(int, char *[]) size[0] = 10; size[1] = 10; - ImageType::RegionType region{ index, size }; + const ImageType::RegionType region{ index, size }; - PixelType value = 0.; + const PixelType value = 0.; auto input = InputImageType::New(); input->SetRegions(region); diff --git a/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetMalcolmImageSubset2DTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetMalcolmImageSubset2DTest.cxx index eec709a3f51..889891df19e 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetMalcolmImageSubset2DTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetMalcolmImageSubset2DTest.cxx @@ -135,7 +135,7 @@ itkMultiLevelSetMalcolmImageSubset2DTest(int, char *[]) auto adaptor1 = BinaryImageToLevelSetType::New(); adaptor1->SetInputImage(binary); adaptor1->Initialize(); - LevelSetType::Pointer levelSet1 = adaptor1->GetModifiableLevelSet(); + const LevelSetType::Pointer levelSet1 = adaptor1->GetModifiableLevelSet(); index = input->TransformPhysicalPointToIndex(binary->GetOrigin()); InputImageType::OffsetType offset; @@ -181,7 +181,7 @@ itkMultiLevelSetMalcolmImageSubset2DTest(int, char *[]) lscontainer->SetHeaviside(heaviside); lscontainer->SetDomainMapFilter(domainMapFilter); - bool levelSetNotYetAdded = lscontainer->AddLevelSet(0, levelSet1, false); + const bool levelSetNotYetAdded = lscontainer->AddLevelSet(0, levelSet1, false); if (!levelSetNotYetAdded) { return EXIT_FAILURE; diff --git a/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetShiImageSubset2DTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetShiImageSubset2DTest.cxx index 866217b6dee..c843c830883 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetShiImageSubset2DTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetShiImageSubset2DTest.cxx @@ -135,7 +135,7 @@ itkMultiLevelSetShiImageSubset2DTest(int, char *[]) auto adaptor1 = BinaryImageToLevelSetType::New(); adaptor1->SetInputImage(binary); adaptor1->Initialize(); - LevelSetType::Pointer levelSet1 = adaptor1->GetModifiableLevelSet(); + const LevelSetType::Pointer levelSet1 = adaptor1->GetModifiableLevelSet(); index = input->TransformPhysicalPointToIndex(binary->GetOrigin()); InputImageType::OffsetType offset; @@ -181,7 +181,7 @@ itkMultiLevelSetShiImageSubset2DTest(int, char *[]) lscontainer->SetHeaviside(heaviside); lscontainer->SetDomainMapFilter(domainMapFilter); - bool levelSetNotYetAdded = lscontainer->AddLevelSet(0, levelSet1, false); + const bool levelSetNotYetAdded = lscontainer->AddLevelSet(0, levelSet1, false); if (!levelSetNotYetAdded) { return EXIT_FAILURE; diff --git a/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetWhitakerImageSubset2DTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetWhitakerImageSubset2DTest.cxx index f7c55614328..078fca8c8a3 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetWhitakerImageSubset2DTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetWhitakerImageSubset2DTest.cxx @@ -135,7 +135,7 @@ itkMultiLevelSetWhitakerImageSubset2DTest(int, char *[]) auto adaptor1 = BinaryImageToLevelSetType::New(); adaptor1->SetInputImage(binary); adaptor1->Initialize(); - LevelSetType::Pointer levelSet1 = adaptor1->GetModifiableLevelSet(); + const LevelSetType::Pointer levelSet1 = adaptor1->GetModifiableLevelSet(); index = input->TransformPhysicalPointToIndex(binary->GetOrigin()); InputImageType::OffsetType offset; @@ -181,7 +181,7 @@ itkMultiLevelSetWhitakerImageSubset2DTest(int, char *[]) lscontainer->SetHeaviside(heaviside); lscontainer->SetDomainMapFilter(domainMapFilter); - bool levelSetNotYetAdded = lscontainer->AddLevelSet(0, levelSet1, false); + const bool levelSetNotYetAdded = lscontainer->AddLevelSet(0, levelSet1, false); if (!levelSetNotYetAdded) { return EXIT_FAILURE; diff --git a/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetDenseAdvectionImage2DTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetDenseAdvectionImage2DTest.cxx index 9a20547788b..98d5a0d87a3 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetDenseAdvectionImage2DTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetDenseAdvectionImage2DTest.cxx @@ -74,7 +74,7 @@ itkSingleLevelSetDenseAdvectionImage2DTest(int argc, char * argv[]) auto reader = ReaderType::New(); reader->SetFileName(argv[1]); reader->Update(); - InputImageType::Pointer input = reader->GetOutput(); + const InputImageType::Pointer input = reader->GetOutput(); auto fastMarching = FastMarchingFilterType::New(); @@ -132,7 +132,7 @@ itkSingleLevelSetDenseAdvectionImage2DTest(int argc, char * argv[]) auto lscontainer = LevelSetContainerType::New(); lscontainer->SetHeaviside(heaviside); - bool levelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); + const bool levelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); if (!levelSetNotYetAdded) { return EXIT_FAILURE; diff --git a/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetDenseImage2DTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetDenseImage2DTest.cxx index 1b7a1662264..2ad8f0dc29b 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetDenseImage2DTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetDenseImage2DTest.cxx @@ -75,7 +75,7 @@ itkSingleLevelSetDenseImage2DTest(int argc, char * argv[]) auto reader = ReaderType::New(); reader->SetFileName(argv[1]); reader->Update(); - InputImageType::Pointer input = reader->GetOutput(); + const InputImageType::Pointer input = reader->GetOutput(); auto fastMarching = FastMarchingFilterType::New(); @@ -133,7 +133,7 @@ itkSingleLevelSetDenseImage2DTest(int argc, char * argv[]) auto lscontainer = LevelSetContainerType::New(); lscontainer->SetHeaviside(heaviside); - bool levelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); + const bool levelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); if (!levelSetNotYetAdded) { return EXIT_FAILURE; diff --git a/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetMalcolmImage2DTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetMalcolmImage2DTest.cxx index db1a9393c71..36bc2acef17 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetMalcolmImage2DTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetMalcolmImage2DTest.cxx @@ -72,7 +72,7 @@ itkSingleLevelSetMalcolmImage2DTest(int argc, char * argv[]) auto reader = ReaderType::New(); reader->SetFileName(argv[1]); reader->Update(); - InputImageType::Pointer input = reader->GetOutput(); + const InputImageType::Pointer input = reader->GetOutput(); // Binary initialization auto binary = InputImageType::New(); @@ -105,7 +105,7 @@ itkSingleLevelSetMalcolmImage2DTest(int argc, char * argv[]) adaptor->Initialize(); std::cout << "Finished converting to sparse format" << std::endl; - SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); + const SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); // Define the Heaviside function auto heaviside = HeavisideFunctionBaseType::New(); @@ -115,7 +115,7 @@ itkSingleLevelSetMalcolmImage2DTest(int argc, char * argv[]) auto lscontainer = LevelSetContainerType::New(); lscontainer->SetHeaviside(heaviside); - bool levelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); + const bool levelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); if (!levelSetNotYetAdded) { return EXIT_FAILURE; diff --git a/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetShiImage2DTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetShiImage2DTest.cxx index ae0283b1a53..f9863906362 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetShiImage2DTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetShiImage2DTest.cxx @@ -72,7 +72,7 @@ itkSingleLevelSetShiImage2DTest(int argc, char * argv[]) auto reader = ReaderType::New(); reader->SetFileName(argv[1]); reader->Update(); - InputImageType::Pointer input = reader->GetOutput(); + const InputImageType::Pointer input = reader->GetOutput(); // Binary initialization auto binary = InputImageType::New(); @@ -105,7 +105,7 @@ itkSingleLevelSetShiImage2DTest(int argc, char * argv[]) adaptor->Initialize(); std::cout << "Finished converting to sparse format" << std::endl; - SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); + const SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); // Define the Heaviside function auto heaviside = HeavisideFunctionBaseType::New(); @@ -115,7 +115,7 @@ itkSingleLevelSetShiImage2DTest(int argc, char * argv[]) auto lscontainer = LevelSetContainerType::New(); lscontainer->SetHeaviside(heaviside); - bool levelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); + const bool levelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); if (!levelSetNotYetAdded) { return EXIT_FAILURE; diff --git a/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetWhitakerImage2DTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetWhitakerImage2DTest.cxx index 0de2f4f0aa1..33ac475947a 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetWhitakerImage2DTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetWhitakerImage2DTest.cxx @@ -74,7 +74,7 @@ itkSingleLevelSetWhitakerImage2DTest(int argc, char * argv[]) auto reader = ReaderType::New(); reader->SetFileName(argv[1]); reader->Update(); - InputImageType::Pointer input = reader->GetOutput(); + const InputImageType::Pointer input = reader->GetOutput(); // Binary initialization auto binary = InputImageType::New(); @@ -107,7 +107,7 @@ itkSingleLevelSetWhitakerImage2DTest(int argc, char * argv[]) adaptor->Initialize(); std::cout << "Finished converting to sparse format" << std::endl; - SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); + const SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); // Define the Heaviside function auto heaviside = HeavisideFunctionBaseType::New(); @@ -117,7 +117,7 @@ itkSingleLevelSetWhitakerImage2DTest(int argc, char * argv[]) auto lscontainer = LevelSetContainerType::New(); lscontainer->SetHeaviside(heaviside); - bool LevelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); + const bool LevelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); if (!LevelSetNotYetAdded) { return EXIT_FAILURE; @@ -174,7 +174,7 @@ itkSingleLevelSetWhitakerImage2DTest(int argc, char * argv[]) evolution->SetLevelSetContainer(lscontainer); - itk::ThreadIdType numberOfWorkUnits = 1; + const itk::ThreadIdType numberOfWorkUnits = 1; evolution->SetNumberOfWorkUnits(numberOfWorkUnits); ITK_TEST_SET_GET_VALUE(numberOfWorkUnits, evolution->GetNumberOfWorkUnits()); diff --git a/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetWhitakerImage2DWithCurvatureTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetWhitakerImage2DWithCurvatureTest.cxx index 81fd4239905..50fa90a1224 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetWhitakerImage2DWithCurvatureTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetWhitakerImage2DWithCurvatureTest.cxx @@ -74,7 +74,7 @@ itkSingleLevelSetWhitakerImage2DWithCurvatureTest(int argc, char * argv[]) auto reader = ReaderType::New(); reader->SetFileName(argv[1]); reader->Update(); - InputImageType::Pointer input = reader->GetOutput(); + const InputImageType::Pointer input = reader->GetOutput(); // Binary initialization auto binary = InputImageType::New(); @@ -107,7 +107,7 @@ itkSingleLevelSetWhitakerImage2DWithCurvatureTest(int argc, char * argv[]) adaptor->Initialize(); std::cout << "Finished converting to sparse format" << std::endl; - SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); + const SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); index = input->TransformPhysicalPointToIndex(binary->GetOrigin()); @@ -126,7 +126,7 @@ itkSingleLevelSetWhitakerImage2DWithCurvatureTest(int argc, char * argv[]) auto lscontainer = LevelSetContainerType::New(); lscontainer->SetHeaviside(heaviside); - bool LevelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); + const bool LevelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); if (!LevelSetNotYetAdded) { return EXIT_FAILURE; @@ -176,7 +176,7 @@ itkSingleLevelSetWhitakerImage2DWithCurvatureTest(int argc, char * argv[]) using StoppingCriterionType = itk::LevelSetEvolutionNumberOfIterationsStoppingCriterion; auto criterion = StoppingCriterionType::New(); - typename StoppingCriterionType::IterationIdType numberOfIterations = 5; + const typename StoppingCriterionType::IterationIdType numberOfIterations = 5; criterion->SetNumberOfIterations(numberOfIterations); ITK_TEST_SET_GET_VALUE(numberOfIterations, criterion->GetNumberOfIterations()); @@ -191,7 +191,7 @@ itkSingleLevelSetWhitakerImage2DWithCurvatureTest(int argc, char * argv[]) evolution->SetLevelSetContainer(lscontainer); ITK_TEST_SET_GET_VALUE(lscontainer, evolution->GetLevelSetContainer()); - typename LevelSetEvolutionType::LevelSetOutputRealType alpha = 0.9; + const typename LevelSetEvolutionType::LevelSetOutputRealType alpha = 0.9; evolution->SetAlpha(alpha); ITK_TEST_SET_GET_VALUE(alpha, evolution->GetAlpha()); diff --git a/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetWhitakerImage2DWithLaplacianTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetWhitakerImage2DWithLaplacianTest.cxx index b9bf62d4e5f..0ae90bb7a9f 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetWhitakerImage2DWithLaplacianTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetWhitakerImage2DWithLaplacianTest.cxx @@ -76,7 +76,7 @@ itkSingleLevelSetWhitakerImage2DWithLaplacianTest(int argc, char * argv[]) auto reader = ReaderType::New(); reader->SetFileName(argv[1]); reader->Update(); - InputImageType::Pointer input = reader->GetOutput(); + const InputImageType::Pointer input = reader->GetOutput(); // Binary initialization auto binary = InputImageType::New(); @@ -109,7 +109,7 @@ itkSingleLevelSetWhitakerImage2DWithLaplacianTest(int argc, char * argv[]) adaptor->Initialize(); std::cout << "Finished converting to sparse format" << std::endl; - SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); + const SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); // Define the Heaviside function auto heaviside = HeavisideFunctionBaseType::New(); @@ -119,7 +119,7 @@ itkSingleLevelSetWhitakerImage2DWithLaplacianTest(int argc, char * argv[]) auto lscontainer = LevelSetContainerType::New(); lscontainer->SetHeaviside(heaviside); - bool LevelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); + const bool LevelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); if (!LevelSetNotYetAdded) { return EXIT_FAILURE; diff --git a/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetWhitakerImage2DWithPropagationTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetWhitakerImage2DWithPropagationTest.cxx index 422bfde4868..c66d1a4dbb5 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetWhitakerImage2DWithPropagationTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkSingleLevelSetWhitakerImage2DWithPropagationTest.cxx @@ -74,7 +74,7 @@ itkSingleLevelSetWhitakerImage2DWithPropagationTest(int argc, char * argv[]) auto reader = ReaderType::New(); reader->SetFileName(argv[1]); reader->Update(); - InputImageType::Pointer input = reader->GetOutput(); + const InputImageType::Pointer input = reader->GetOutput(); // Binary initialization auto binary = InputImageType::New(); @@ -107,7 +107,7 @@ itkSingleLevelSetWhitakerImage2DWithPropagationTest(int argc, char * argv[]) adaptor->Initialize(); std::cout << "Finished converting to sparse format" << std::endl; - SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); + const SparseLevelSetType::Pointer level_set = adaptor->GetModifiableLevelSet(); // Define the Heaviside function auto heaviside = HeavisideFunctionBaseType::New(); @@ -117,7 +117,7 @@ itkSingleLevelSetWhitakerImage2DWithPropagationTest(int argc, char * argv[]) auto lscontainer = LevelSetContainerType::New(); lscontainer->SetHeaviside(heaviside); - bool LevelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); + const bool LevelSetNotYetAdded = lscontainer->AddLevelSet(0, level_set, false); if (!LevelSetNotYetAdded) { return EXIT_FAILURE; diff --git a/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetDenseImage2DTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetDenseImage2DTest.cxx index 8e595454027..0a77183c1f5 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetDenseImage2DTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetDenseImage2DTest.cxx @@ -78,7 +78,7 @@ itkTwoLevelSetDenseImage2DTest(int argc, char * argv[]) auto reader = ReaderType::New(); reader->SetFileName(argv[1]); reader->Update(); - InputImageType::Pointer input = reader->GetOutput(); + const InputImageType::Pointer input = reader->GetOutput(); auto fastMarching = FastMarchingFilterType::New(); @@ -121,8 +121,8 @@ itkTwoLevelSetDenseImage2DTest(int argc, char * argv[]) // only after the \code{Update()} methods of this filter has been called // directly or indirectly. // - InputImageType::RegionType inputBufferedRegion = input->GetBufferedRegion(); - InputImageType::SizeType inputBufferedRegionSize = inputBufferedRegion.GetSize(); + const InputImageType::RegionType inputBufferedRegion = input->GetBufferedRegion(); + const InputImageType::SizeType inputBufferedRegionSize = inputBufferedRegion.GetSize(); fastMarching->SetOutputSize(inputBufferedRegionSize); fastMarching->Update(); diff --git a/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetMalcolmImage2DTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetMalcolmImage2DTest.cxx index 6f13f40701b..1376d9a5189 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetMalcolmImage2DTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetMalcolmImage2DTest.cxx @@ -77,7 +77,7 @@ itkTwoLevelSetMalcolmImage2DTest(int argc, char * argv[]) auto reader = ReaderType::New(); reader->SetFileName(argv[1]); reader->Update(); - InputImageType::Pointer input = reader->GetOutput(); + const InputImageType::Pointer input = reader->GetOutput(); // Binary initialization auto binary = InputImageType::New(); @@ -110,14 +110,14 @@ itkTwoLevelSetMalcolmImage2DTest(int argc, char * argv[]) adaptor0->Initialize(); std::cout << "Finished converting to sparse format" << std::endl; - SparseLevelSetType::Pointer level_set0 = adaptor0->GetModifiableLevelSet(); + const SparseLevelSetType::Pointer level_set0 = adaptor0->GetModifiableLevelSet(); auto adaptor1 = BinaryToSparseAdaptorType::New(); adaptor1->SetInputImage(binary); adaptor1->Initialize(); std::cout << "Finished converting to sparse format" << std::endl; - SparseLevelSetType::Pointer level_set1 = adaptor1->GetModifiableLevelSet(); + const SparseLevelSetType::Pointer level_set1 = adaptor1->GetModifiableLevelSet(); // Create a list image specifying both level set ids IdListType list_ids; diff --git a/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetShiImage2DTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetShiImage2DTest.cxx index 9deb0069101..7a32aaeb4f4 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetShiImage2DTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetShiImage2DTest.cxx @@ -77,7 +77,7 @@ itkTwoLevelSetShiImage2DTest(int argc, char * argv[]) auto reader = ReaderType::New(); reader->SetFileName(argv[1]); reader->Update(); - InputImageType::Pointer input = reader->GetOutput(); + const InputImageType::Pointer input = reader->GetOutput(); // Create a binary initialization auto binary = InputImageType::New(); @@ -110,14 +110,14 @@ itkTwoLevelSetShiImage2DTest(int argc, char * argv[]) adaptor0->Initialize(); std::cout << "Finished converting to sparse format" << std::endl; - SparseLevelSetType::Pointer level_set0 = adaptor0->GetModifiableLevelSet(); + const SparseLevelSetType::Pointer level_set0 = adaptor0->GetModifiableLevelSet(); auto adaptor1 = BinaryToSparseAdaptorType::New(); adaptor1->SetInputImage(binary); adaptor1->Initialize(); std::cout << "Finished converting to sparse format" << std::endl; - SparseLevelSetType::Pointer level_set1 = adaptor1->GetModifiableLevelSet(); + const SparseLevelSetType::Pointer level_set1 = adaptor1->GetModifiableLevelSet(); // Create a list image specifying both level set ids IdListType list_ids; diff --git a/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetWhitakerImage2DTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetWhitakerImage2DTest.cxx index 3b21a88c15b..d58a4f3ea2e 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetWhitakerImage2DTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetWhitakerImage2DTest.cxx @@ -79,7 +79,7 @@ itkTwoLevelSetWhitakerImage2DTest(int argc, char * argv[]) auto reader = ReaderType::New(); reader->SetFileName(argv[1]); reader->Update(); - InputImageType::Pointer input = reader->GetOutput(); + const InputImageType::Pointer input = reader->GetOutput(); // Create a binary initialization auto binary = InputImageType::New(); @@ -112,14 +112,14 @@ itkTwoLevelSetWhitakerImage2DTest(int argc, char * argv[]) adaptor0->Initialize(); std::cout << "Finished converting to sparse format" << std::endl; - SparseLevelSetType::Pointer level_set0 = adaptor0->GetModifiableLevelSet(); + const SparseLevelSetType::Pointer level_set0 = adaptor0->GetModifiableLevelSet(); auto adaptor1 = BinaryToSparseAdaptorType::New(); adaptor1->SetInputImage(binary); adaptor1->Initialize(); std::cout << "Finished converting to sparse format" << std::endl; - SparseLevelSetType::Pointer level_set1 = adaptor1->GetModifiableLevelSet(); + const SparseLevelSetType::Pointer level_set1 = adaptor1->GetModifiableLevelSet(); // Create a list image specifying both level set ids IdListType list_ids; diff --git a/Modules/Segmentation/MarkovRandomFieldsClassifiers/include/itkMRFImageFilter.hxx b/Modules/Segmentation/MarkovRandomFieldsClassifiers/include/itkMRFImageFilter.hxx index b494731b170..1446ed1a973 100644 --- a/Modules/Segmentation/MarkovRandomFieldsClassifiers/include/itkMRFImageFilter.hxx +++ b/Modules/Segmentation/MarkovRandomFieldsClassifiers/include/itkMRFImageFilter.hxx @@ -92,8 +92,8 @@ MRFImageFilter::GenerateInputRequestedRegion() { // this filter requires that all of the input images // are the size of the output requested region - InputImagePointer inputPtr = const_cast(this->GetInput()); - OutputImagePointer outputPtr = this->GetOutput(); + const InputImagePointer inputPtr = const_cast(this->GetInput()); + const OutputImagePointer outputPtr = this->GetOutput(); if (inputPtr && outputPtr) { @@ -115,8 +115,8 @@ template void MRFImageFilter::GenerateOutputInformation() { - typename TInputImage::ConstPointer input = this->GetInput(); - typename TClassifiedImage::Pointer output = this->GetOutput(); + const typename TInputImage::ConstPointer input = this->GetInput(); + const typename TClassifiedImage::Pointer output = this->GetOutput(); output->SetLargestPossibleRegion(input->GetLargestPossibleRegion()); } @@ -128,7 +128,7 @@ MRFImageFilter::GenerateData() // generate the Gaussian model for the different classes // and then generate the initial labelled dataset. - InputImageConstPointer inputImage = this->GetInput(); + const InputImageConstPointer inputImage = this->GetInput(); // Give the input image and training image set to the // classifier @@ -142,7 +142,7 @@ MRFImageFilter::GenerateData() this->ApplyMRFImageFilter(); // Set the output labelled and allocate the memory - LabelledImagePointer outputPtr = this->GetOutput(); + const LabelledImagePointer outputPtr = this->GetOutput(); // Allocate the output buffer memory outputPtr->SetBufferedRegion(outputPtr->GetRequestedRegion()); @@ -231,7 +231,7 @@ MRFImageFilter::SetDefaultMRFNeighborhoodWeight() // Determine the default neighborhood size m_NeighborhoodSize = 1; - int neighborhoodRadius = 1; // Default assumes a radius of 1 + const int neighborhoodRadius = 1; // Default assumes a radius of 1 for (unsigned int i = 0; i < InputImageDimension; ++i) { m_NeighborhoodSize *= (2 * neighborhoodRadius + 1); @@ -442,11 +442,11 @@ MRFImageFilter::ApplyICMLabeller() LabelStatusImageFaceListType labelStatusImageFaceList; // Compute the faces for the neighborhoods in the input/labelled image - InputImageConstPointer inputImage = this->GetInput(); + const InputImageConstPointer inputImage = this->GetInput(); inputImageFaceList = inputImageFacesCalculator(inputImage, inputImage->GetBufferedRegion(), m_InputImageNeighborhoodRadius); - LabelledImagePointer labelledImage = m_ClassifierPtr->GetClassifiedImage(); + const LabelledImagePointer labelledImage = m_ClassifierPtr->GetClassifiedImage(); labelledImageFaceList = labelledImageFacesCalculator(labelledImage, labelledImage->GetBufferedRegion(), m_LabelledImageNeighborhoodRadius); diff --git a/Modules/Segmentation/MarkovRandomFieldsClassifiers/include/itkRGBGibbsPriorFilter.hxx b/Modules/Segmentation/MarkovRandomFieldsClassifiers/include/itkRGBGibbsPriorFilter.hxx index af22b957594..940f3a85c2b 100644 --- a/Modules/Segmentation/MarkovRandomFieldsClassifiers/include/itkRGBGibbsPriorFilter.hxx +++ b/Modules/Segmentation/MarkovRandomFieldsClassifiers/include/itkRGBGibbsPriorFilter.hxx @@ -55,7 +55,7 @@ template void RGBGibbsPriorFilter::GenerateMediumImage() { - InputImageConstPointer input = this->GetInput(); + const InputImageConstPointer input = this->GetInput(); m_MediumImage = TInputImage::New(); m_MediumImage->SetLargestPossibleRegion(input->GetLargestPossibleRegion()); @@ -245,7 +245,7 @@ RGBGibbsPriorFilter::GibbsTotalEnergy(int i) } } - bool changeflag = (k > 3); + const bool changeflag = (k > 3); for (unsigned int jj = 0; jj < 2; ++jj) { @@ -289,8 +289,8 @@ RGBGibbsPriorFilter::GibbsTotalEnergy(int i) if (changeflag) { difenergy = energy[label] - energy[1 - label]; - double rand_num{ rand() / 32768.0 }; - double energy_num{ std::exp(static_cast(difenergy * 0.5 * size / (2 * size - m_Temp))) }; + const double rand_num{ rand() / 32768.0 }; + double energy_num{ std::exp(static_cast(difenergy * 0.5 * size / (2 * size - m_Temp))) }; if (rand_num < energy_num) { m_LabelledImage->SetPixel(offsetIndex3D, 1 - label); @@ -443,7 +443,7 @@ RGBGibbsPriorFilter::GenerateData() this->ApplyGPImageFilter(); // Set the output labelled image and allocate the memory. - LabelledImageType outputPtr = this->GetOutput(); + const LabelledImageType outputPtr = this->GetOutput(); if (m_RecursiveNumber == 0) { diff --git a/Modules/Segmentation/MarkovRandomFieldsClassifiers/test/itkMRFImageFilterTest.cxx b/Modules/Segmentation/MarkovRandomFieldsClassifiers/test/itkMRFImageFilterTest.cxx index 6c1d0863ed5..e7bbe617a5c 100644 --- a/Modules/Segmentation/MarkovRandomFieldsClassifiers/test/itkMRFImageFilterTest.cxx +++ b/Modules/Segmentation/MarkovRandomFieldsClassifiers/test/itkMRFImageFilterTest.cxx @@ -52,7 +52,7 @@ itkMRFImageFilterTest(int, char *[]) VecImageType::SizeType vecImgSize = { { IMGWIDTH, IMGHEIGHT, NFRAMES } }; - VecImageType::IndexType index{}; + const VecImageType::IndexType index{}; VecImageType::RegionType region; @@ -74,8 +74,8 @@ itkMRFImageFilterTest(int, char *[]) // Set up the vector to store the image data using DataVector = VecImageType::PixelType; - int halfWidth = static_cast(vecImgSize[0]) / 2; - int halfHeight = static_cast(vecImgSize[1]) / 2; + const int halfWidth = static_cast(vecImgSize[0]) / 2; + const int halfHeight = static_cast(vecImgSize[1]) / 2; //-------------------------------------------------------------------------- // Manually create and store each vector @@ -215,9 +215,9 @@ itkMRFImageFilterTest(int, char *[]) using ClassImageType = itk::Image; auto classImage = ClassImageType::New(); - ClassImageType::SizeType classImgSize = { { IMGWIDTH, IMGHEIGHT, NFRAMES } }; + const ClassImageType::SizeType classImgSize = { { IMGWIDTH, IMGHEIGHT, NFRAMES } }; - ClassImageType::IndexType classindex{}; + const ClassImageType::IndexType classindex{}; ClassImageType::RegionType classregion; @@ -344,7 +344,7 @@ itkMRFImageFilterTest(int, char *[]) using ClassifierType = itk::ImageClassifierBase; using ClassifierPointer = ClassifierType::Pointer; - ClassifierPointer myClassifier = ClassifierType::New(); + const ClassifierPointer myClassifier = ClassifierType::New(); // Set the Classifier parameters myClassifier->SetNumberOfClasses(NUM_CLASSES); @@ -389,7 +389,7 @@ itkMRFImageFilterTest(int, char *[]) std::cout << "Stop condition: (1) Maximum number of iterations (2) Error tolerance: " << applyMRFImageFilter->GetStopCondition() << std::endl; - ClassImageType::Pointer outClassImage = applyMRFImageFilter->GetOutput(); + const ClassImageType::Pointer outClassImage = applyMRFImageFilter->GetOutput(); // Testing of different parameter access functions in the filter std::cout << "The number of classes labelled was: " << applyMRFImageFilter->GetNumberOfClasses() << std::endl; @@ -400,13 +400,13 @@ itkMRFImageFilterTest(int, char *[]) std::cout << "The MRF neighborhood weights are: " << std::endl; // Test other optional access functions to test coverage - std::vector MRFNeighborhoodWeight = applyMRFImageFilter->GetMRFNeighborhoodWeight(); - std::vector testNewNeighborhoodWeight(MRFNeighborhoodWeight.size(), 1); + const std::vector MRFNeighborhoodWeight = applyMRFImageFilter->GetMRFNeighborhoodWeight(); + const std::vector testNewNeighborhoodWeight(MRFNeighborhoodWeight.size(), 1); applyMRFImageFilter->SetMRFNeighborhoodWeight(testNewNeighborhoodWeight); // Print the mrf labelled image - ClassImageIterator labeloutIt(outClassImage, outClassImage->GetBufferedRegion()); + const ClassImageIterator labeloutIt(outClassImage, outClassImage->GetBufferedRegion()); //--------------------------------------------------------------------- // Set up the neighborhood iterators and the valid neighborhoods diff --git a/Modules/Segmentation/MarkovRandomFieldsClassifiers/test/itkRGBGibbsPriorFilterTest.cxx b/Modules/Segmentation/MarkovRandomFieldsClassifiers/test/itkRGBGibbsPriorFilterTest.cxx index 286ee369a61..846c4b68a6e 100644 --- a/Modules/Segmentation/MarkovRandomFieldsClassifiers/test/itkRGBGibbsPriorFilterTest.cxx +++ b/Modules/Segmentation/MarkovRandomFieldsClassifiers/test/itkRGBGibbsPriorFilterTest.cxx @@ -87,9 +87,9 @@ itkRGBGibbsPriorFilterTest(int, char *[]) using VecImagePixelType = VecImageType::PixelType; - VecImageType::SizeType vecImgSize = { { ImageWidth, ImageHeight, NumFrames } }; + const VecImageType::SizeType vecImgSize = { { ImageWidth, ImageHeight, NumFrames } }; - VecImageType::IndexType index{}; + const VecImageType::IndexType index{}; VecImageType::RegionType region; @@ -135,9 +135,9 @@ itkRGBGibbsPriorFilterTest(int, char *[]) using ClassImageType = itk::Image; auto classImage = ClassImageType::New(); - ClassImageType::SizeType classImgSize = { { ImageWidth, ImageHeight, NumFrames } }; + const ClassImageType::SizeType classImgSize = { { ImageWidth, ImageHeight, NumFrames } }; - ClassImageType::IndexType classindex{}; + const ClassImageType::IndexType classindex{}; ClassImageType::RegionType classregion; @@ -236,7 +236,7 @@ itkRGBGibbsPriorFilterTest(int, char *[]) using ClassifierType = itk::ImageClassifierBase; using ClassifierPointer = ClassifierType::Pointer; - ClassifierPointer myClassifier = ClassifierType::New(); + const ClassifierPointer myClassifier = ClassifierType::New(); // Set the Classifier parameters myClassifier->SetNumberOfClasses(NumClasses); @@ -268,45 +268,45 @@ itkRGBGibbsPriorFilterTest(int, char *[]) // applyGibbsImageFilter->SetErrorTolerance(0.00); - unsigned int clusterSize = 10; + const unsigned int clusterSize = 10; applyGibbsImageFilter->SetClusterSize(clusterSize); ITK_TEST_SET_GET_VALUE(clusterSize, applyGibbsImageFilter->GetClusterSize()); - unsigned int boundaryGradient = 6; + const unsigned int boundaryGradient = 6; applyGibbsImageFilter->SetBoundaryGradient(boundaryGradient); ITK_TEST_SET_GET_VALUE(boundaryGradient, applyGibbsImageFilter->GetBoundaryGradient()); - unsigned int objectLabel = 1; + const unsigned int objectLabel = 1; applyGibbsImageFilter->SetObjectLabel(objectLabel); ITK_TEST_SET_GET_VALUE(objectLabel, applyGibbsImageFilter->GetObjectLabel()); - GibbsPriorFilterType::IndexType startPoint{}; + const GibbsPriorFilterType::IndexType startPoint{}; applyGibbsImageFilter->SetStartPoint(startPoint); ITK_TEST_SET_GET_VALUE(startPoint, applyGibbsImageFilter->GetStartPoint()); // applyGibbsImageFilter->SetRecursiveNumber(1); - double cliqueWeight1 = 5.0; + const double cliqueWeight1 = 5.0; applyGibbsImageFilter->SetCliqueWeight_1(cliqueWeight1); ITK_TEST_SET_GET_VALUE(cliqueWeight1, applyGibbsImageFilter->GetCliqueWeight_1()); - double cliqueWeight2 = 5.0; + const double cliqueWeight2 = 5.0; applyGibbsImageFilter->SetCliqueWeight_2(cliqueWeight2); ITK_TEST_SET_GET_VALUE(cliqueWeight2, applyGibbsImageFilter->GetCliqueWeight_2()); - double cliqueWeight3 = 5.0; + const double cliqueWeight3 = 5.0; applyGibbsImageFilter->SetCliqueWeight_3(cliqueWeight3); ITK_TEST_SET_GET_VALUE(cliqueWeight3, applyGibbsImageFilter->GetCliqueWeight_3()); - double cliqueWeight4 = 5.0; + const double cliqueWeight4 = 5.0; applyGibbsImageFilter->SetCliqueWeight_4(cliqueWeight4); ITK_TEST_SET_GET_VALUE(cliqueWeight4, applyGibbsImageFilter->GetCliqueWeight_4()); - double cliqueWeight5 = 5.0; + const double cliqueWeight5 = 5.0; applyGibbsImageFilter->SetCliqueWeight_5(cliqueWeight5); ITK_TEST_SET_GET_VALUE(cliqueWeight5, applyGibbsImageFilter->GetCliqueWeight_5()); - double cliqueWeight6 = 0.0; + const double cliqueWeight6 = 0.0; applyGibbsImageFilter->SetCliqueWeight_6(cliqueWeight6); ITK_TEST_SET_GET_VALUE(cliqueWeight6, applyGibbsImageFilter->GetCliqueWeight_6()); @@ -324,7 +324,7 @@ itkRGBGibbsPriorFilterTest(int, char *[]) // Kick off the Gibbs labeller function applyGibbsImageFilter->Update(); - ClassImageType::Pointer outClassImage = applyGibbsImageFilter->GetOutput(); + const ClassImageType::Pointer outClassImage = applyGibbsImageFilter->GetOutput(); // Print the mrf labelled image ClassImageIterator labeloutIt(outClassImage, outClassImage->GetBufferedRegion()); diff --git a/Modules/Segmentation/RegionGrowing/include/itkConfidenceConnectedImageFilter.hxx b/Modules/Segmentation/RegionGrowing/include/itkConfidenceConnectedImageFilter.hxx index 6298fd040c2..d79d02f836b 100644 --- a/Modules/Segmentation/RegionGrowing/include/itkConfidenceConnectedImageFilter.hxx +++ b/Modules/Segmentation/RegionGrowing/include/itkConfidenceConnectedImageFilter.hxx @@ -106,7 +106,7 @@ ConfidenceConnectedImageFilter::GenerateInputRequeste Superclass::GenerateInputRequestedRegion(); if (this->GetInput()) { - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); input->SetRequestedRegionToLargestPossibleRegion(); } } @@ -129,11 +129,11 @@ ConfidenceConnectedImageFilter::GenerateData() using IteratorType = FloodFilledImageFunctionConditionalIterator; using SecondIteratorType = FloodFilledImageFunctionConditionalConstIterator; - typename Superclass::InputImageConstPointer inputImage = this->GetInput(); - typename Superclass::OutputImagePointer outputImage = this->GetOutput(); + const typename Superclass::InputImageConstPointer inputImage = this->GetInput(); + const typename Superclass::OutputImagePointer outputImage = this->GetOutput(); // Zero the output - OutputImageRegionType region = outputImage->GetRequestedRegion(); + const OutputImageRegionType region = outputImage->GetRequestedRegion(); outputImage->SetBufferedRegion(region); outputImage->AllocateInitialized(); @@ -154,9 +154,9 @@ ConfidenceConnectedImageFilter::GenerateData() InputRealType sumOfSquares{}; - typename SeedsContainerType::const_iterator si = m_Seeds.begin(); - typename SeedsContainerType::const_iterator li = m_Seeds.end(); - SizeValueType num = 0; + typename SeedsContainerType::const_iterator si = m_Seeds.begin(); + const typename SeedsContainerType::const_iterator li = m_Seeds.end(); + SizeValueType num = 0; while (si != li) { if (region.IsInside(*si)) @@ -196,9 +196,9 @@ ConfidenceConnectedImageFilter::GenerateData() InputRealType sum{}; InputRealType sumOfSquares{}; - typename SeedsContainerType::const_iterator si = m_Seeds.begin(); - typename SeedsContainerType::const_iterator li = m_Seeds.end(); - SizeValueType num = 0; + typename SeedsContainerType::const_iterator si = m_Seeds.begin(); + const typename SeedsContainerType::const_iterator li = m_Seeds.end(); + SizeValueType num = 0; while (si != li) { if (region.IsInside(*si)) @@ -228,8 +228,8 @@ ConfidenceConnectedImageFilter::GenerateData() // Find the highest and lowest seed intensity. InputRealType lowestSeedIntensity = itk::NumericTraits::max(); InputRealType highestSeedIntensity = itk::NumericTraits::NonpositiveMin(); - typename SeedsContainerType::const_iterator si = m_Seeds.begin(); - typename SeedsContainerType::const_iterator li = m_Seeds.end(); + typename SeedsContainerType::const_iterator si = m_Seeds.begin(); + const typename SeedsContainerType::const_iterator li = m_Seeds.end(); while (si != li) { if (region.IsInside(*si)) diff --git a/Modules/Segmentation/RegionGrowing/include/itkConnectedThresholdImageFilter.hxx b/Modules/Segmentation/RegionGrowing/include/itkConnectedThresholdImageFilter.hxx index ca30a14ee3f..ddeb5a24e66 100644 --- a/Modules/Segmentation/RegionGrowing/include/itkConnectedThresholdImageFilter.hxx +++ b/Modules/Segmentation/RegionGrowing/include/itkConnectedThresholdImageFilter.hxx @@ -201,7 +201,7 @@ template auto ConnectedThresholdImageFilter::GetLower() const -> InputImagePixelType { - typename InputPixelObjectType::Pointer lower = const_cast(this)->GetLowerInput(); + const typename InputPixelObjectType::Pointer lower = const_cast(this)->GetLowerInput(); return lower->Get(); } @@ -210,7 +210,7 @@ template auto ConnectedThresholdImageFilter::GetUpper() const -> InputImagePixelType { - typename InputPixelObjectType::Pointer upper = const_cast(this)->GetUpperInput(); + const typename InputPixelObjectType::Pointer upper = const_cast(this)->GetUpperInput(); return upper->Get(); } @@ -229,7 +229,7 @@ ConnectedThresholdImageFilter::GenerateData() const InputImagePixelType upper = upperThreshold->Get(); // Zero the output - OutputImageRegionType region = outputImage->GetRequestedRegion(); + const OutputImageRegionType region = outputImage->GetRequestedRegion(); outputImage->SetBufferedRegion(region); outputImage->AllocateInitialized(); diff --git a/Modules/Segmentation/RegionGrowing/include/itkIsolatedConnectedImageFilter.hxx b/Modules/Segmentation/RegionGrowing/include/itkIsolatedConnectedImageFilter.hxx index 3b1670e97d1..fbc840f4e75 100644 --- a/Modules/Segmentation/RegionGrowing/include/itkIsolatedConnectedImageFilter.hxx +++ b/Modules/Segmentation/RegionGrowing/include/itkIsolatedConnectedImageFilter.hxx @@ -80,7 +80,7 @@ IsolatedConnectedImageFilter::GenerateInputRequestedR Superclass::GenerateInputRequestedRegion(); if (this->GetInput()) { - InputImagePointer image = const_cast(this->GetInput()); + const InputImagePointer image = const_cast(this->GetInput()); image->SetRequestedRegionToLargestPossibleRegion(); } } @@ -167,8 +167,8 @@ template void IsolatedConnectedImageFilter::GenerateData() { - InputImageConstPointer inputImage = this->GetInput(); - OutputImagePointer outputImage = this->GetOutput(); + const InputImageConstPointer inputImage = this->GetInput(); + const OutputImagePointer outputImage = this->GetOutput(); using AccumulateType = typename NumericTraits::AccumulateType; @@ -183,7 +183,7 @@ IsolatedConnectedImageFilter::GenerateData() } // Zero the output - OutputImageRegionType region = outputImage->GetRequestedRegion(); + const OutputImageRegionType region = outputImage->GetRequestedRegion(); outputImage->SetBufferedRegion(region); outputImage->AllocateInitialized(); @@ -235,9 +235,9 @@ IsolatedConnectedImageFilter::GenerateData() // Find the sum of the intensities in m_Seeds2. If the second // seeds are not included, the sum should be zero. Otherwise, // it will be other than zero. - InputRealType seedIntensitySum{}; - typename SeedsContainerType::const_iterator si = m_Seeds2.begin(); - typename SeedsContainerType::const_iterator li = m_Seeds2.end(); + InputRealType seedIntensitySum{}; + typename SeedsContainerType::const_iterator si = m_Seeds2.begin(); + const typename SeedsContainerType::const_iterator li = m_Seeds2.end(); while (si != li) { const auto value = static_cast(outputImage->GetPixel(*si)); @@ -300,9 +300,9 @@ IsolatedConnectedImageFilter::GenerateData() // Find the sum of the intensities in m_Seeds2. If the second // seeds are not included, the sum should be zero. Otherwise, // it will be other than zero. - InputRealType seedIntensitySum{}; - typename SeedsContainerType::const_iterator si = m_Seeds2.begin(); - typename SeedsContainerType::const_iterator li = m_Seeds2.end(); + InputRealType seedIntensitySum{}; + typename SeedsContainerType::const_iterator si = m_Seeds2.begin(); + const typename SeedsContainerType::const_iterator li = m_Seeds2.end(); while (si != li) { const auto value = static_cast(outputImage->GetPixel(*si)); @@ -358,18 +358,18 @@ IsolatedConnectedImageFilter::GenerateData() // Find the sum of the intensities in m_Seeds2. If the second // seeds are not included, the sum should be zero. Otherwise, // it will be other than zero. - InputRealType seed1IntensitySum{}; - InputRealType seed2IntensitySum{}; - typename SeedsContainerType::const_iterator si1 = m_Seeds1.begin(); - typename SeedsContainerType::const_iterator li1 = m_Seeds1.end(); + InputRealType seed1IntensitySum{}; + InputRealType seed2IntensitySum{}; + typename SeedsContainerType::const_iterator si1 = m_Seeds1.begin(); + const typename SeedsContainerType::const_iterator li1 = m_Seeds1.end(); while (si1 != li1) { const auto value = static_cast(outputImage->GetPixel(*si1)); seed1IntensitySum += value; ++si1; } - typename SeedsContainerType::const_iterator si2 = m_Seeds2.begin(); - typename SeedsContainerType::const_iterator li2 = m_Seeds2.end(); + typename SeedsContainerType::const_iterator si2 = m_Seeds2.begin(); + const typename SeedsContainerType::const_iterator li2 = m_Seeds2.end(); while (si2 != li2) { const auto value = static_cast(outputImage->GetPixel(*si2)); diff --git a/Modules/Segmentation/RegionGrowing/include/itkNeighborhoodConnectedImageFilter.hxx b/Modules/Segmentation/RegionGrowing/include/itkNeighborhoodConnectedImageFilter.hxx index d1f0b8627c7..fa1ed55fdb1 100644 --- a/Modules/Segmentation/RegionGrowing/include/itkNeighborhoodConnectedImageFilter.hxx +++ b/Modules/Segmentation/RegionGrowing/include/itkNeighborhoodConnectedImageFilter.hxx @@ -88,7 +88,7 @@ NeighborhoodConnectedImageFilter::GenerateInputReques Superclass::GenerateInputRequestedRegion(); if (this->GetInput()) { - InputImagePointer image = const_cast(this->GetInput()); + const InputImagePointer image = const_cast(this->GetInput()); image->SetRequestedRegionToLargestPossibleRegion(); } } @@ -105,8 +105,8 @@ template void NeighborhoodConnectedImageFilter::GenerateData() { - typename Superclass::InputImageConstPointer inputImage = this->GetInput(); - typename Superclass::OutputImagePointer outputImage = this->GetOutput(); + const typename Superclass::InputImageConstPointer inputImage = this->GetInput(); + const typename Superclass::OutputImagePointer outputImage = this->GetOutput(); // Zero the output outputImage->SetBufferedRegion(outputImage->GetRequestedRegion()); diff --git a/Modules/Segmentation/RegionGrowing/include/itkVectorConfidenceConnectedImageFilter.hxx b/Modules/Segmentation/RegionGrowing/include/itkVectorConfidenceConnectedImageFilter.hxx index ecfd0d1a6de..ce06fc3b8a0 100644 --- a/Modules/Segmentation/RegionGrowing/include/itkVectorConfidenceConnectedImageFilter.hxx +++ b/Modules/Segmentation/RegionGrowing/include/itkVectorConfidenceConnectedImageFilter.hxx @@ -95,7 +95,7 @@ VectorConfidenceConnectedImageFilter::GenerateInputRe Superclass::GenerateInputRequestedRegion(); if (this->GetInput()) { - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); input->SetRequestedRegionToLargestPossibleRegion(); } } @@ -121,11 +121,11 @@ VectorConfidenceConnectedImageFilter::GenerateData() unsigned int loop; - typename Superclass::InputImageConstPointer inputImage = this->GetInput(); - typename Superclass::OutputImagePointer outputImage = this->GetOutput(); + const typename Superclass::InputImageConstPointer inputImage = this->GetInput(); + const typename Superclass::OutputImagePointer outputImage = this->GetOutput(); // Zero the output - OutputImageRegionType region = outputImage->GetRequestedRegion(); + const OutputImageRegionType region = outputImage->GetRequestedRegion(); outputImage->SetBufferedRegion(region); outputImage->AllocateInitialized(); diff --git a/Modules/Segmentation/RegionGrowing/test/itkConfidenceConnectedImageFilterTest.cxx b/Modules/Segmentation/RegionGrowing/test/itkConfidenceConnectedImageFilterTest.cxx index aef91dbbf7a..ac9f96e4b23 100644 --- a/Modules/Segmentation/RegionGrowing/test/itkConfidenceConnectedImageFilterTest.cxx +++ b/Modules/Segmentation/RegionGrowing/test/itkConfidenceConnectedImageFilterTest.cxx @@ -39,14 +39,14 @@ itkConfidenceConnectedImageFilterTest(int argc, char * argv[]) using PixelType = unsigned char; using myImage = itk::Image; - itk::ImageFileReader::Pointer input = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer input = itk::ImageFileReader::New(); input->SetFileName(argv[1]); // Create a filter using FilterType = itk::ConfidenceConnectedImageFilter; - auto filter = FilterType::New(); - itk::SimpleFilterWatcher filterWatch(filter); + auto filter = FilterType::New(); + const itk::SimpleFilterWatcher filterWatch(filter); filter->SetInput(input->GetOutput()); filter->SetInitialNeighborhoodRadius(3); // measured in pixels @@ -74,13 +74,13 @@ itkConfidenceConnectedImageFilterTest(int argc, char * argv[]) // Test the GetMacros - double doubleMultiplier = filter->GetMultiplier(); + const double doubleMultiplier = filter->GetMultiplier(); std::cout << "filter->GetMultiplier(): " << doubleMultiplier << std::endl; - unsigned int uintNumberOfIterations = filter->GetNumberOfIterations(); + const unsigned int uintNumberOfIterations = filter->GetNumberOfIterations(); std::cout << "filter->GetNumberOfIterations(): " << uintNumberOfIterations << std::endl; - PixelType pixelReplaceValue = filter->GetReplaceValue(); + const PixelType pixelReplaceValue = filter->GetReplaceValue(); std::cout << "filter->GetReplaceValue(): " << static_cast::PrintType>(pixelReplaceValue) << std::endl; diff --git a/Modules/Segmentation/RegionGrowing/test/itkConnectedThresholdImageFilterTest.cxx b/Modules/Segmentation/RegionGrowing/test/itkConnectedThresholdImageFilterTest.cxx index 8491dd4621f..a52c4c26789 100644 --- a/Modules/Segmentation/RegionGrowing/test/itkConnectedThresholdImageFilterTest.cxx +++ b/Modules/Segmentation/RegionGrowing/test/itkConnectedThresholdImageFilterTest.cxx @@ -46,9 +46,9 @@ itkConnectedThresholdImageFilterTest(int argc, char * argv[]) using ImageType = itk::Image; - itk::ImageFileReader::Pointer imageReader = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer imageReader = itk::ImageFileReader::New(); - std::string inputImageFilename = argv[1]; + const std::string inputImageFilename = argv[1]; imageReader->SetFileName(inputImageFilename); ITK_TRY_EXPECT_NO_EXCEPTION(imageReader->Update();); @@ -58,7 +58,7 @@ itkConnectedThresholdImageFilterTest(int argc, char * argv[]) auto connectedThresholdFilter = ConnectedThresholdImageFilterType::New(); - itk::SimpleFilterWatcher watcher(connectedThresholdFilter); + const itk::SimpleFilterWatcher watcher(connectedThresholdFilter); ITK_EXERCISE_BASIC_OBJECT_METHODS(connectedThresholdFilter, ConnectedThresholdImageFilter, ImageToImageFilter); @@ -93,22 +93,22 @@ itkConnectedThresholdImageFilterTest(int argc, char * argv[]) ITK_TEST_SET_GET_VALUE(upperInputPixelObject->Get(), connectedThresholdFilter->GetUpper()); - ConnectedThresholdImageFilterType::InputImagePixelType lowerThreshold = std::stoi(argv[5]); + const ConnectedThresholdImageFilterType::InputImagePixelType lowerThreshold = std::stoi(argv[5]); connectedThresholdFilter->SetLower(lowerThreshold); ITK_TEST_SET_GET_VALUE(lowerThreshold, connectedThresholdFilter->GetLower()); - ConnectedThresholdImageFilterType::InputImagePixelType upperThreshold = std::stoi(argv[6]); + const ConnectedThresholdImageFilterType::InputImagePixelType upperThreshold = std::stoi(argv[6]); connectedThresholdFilter->SetUpper(upperThreshold); ITK_TEST_SET_GET_VALUE(upperThreshold, connectedThresholdFilter->GetUpper()); - ConnectedThresholdImageFilterType::OutputImagePixelType replaceValue = 255; + const ConnectedThresholdImageFilterType::OutputImagePixelType replaceValue = 255; connectedThresholdFilter->SetReplaceValue(replaceValue); ITK_TEST_SET_GET_VALUE(replaceValue, connectedThresholdFilter->GetReplaceValue()); // Test the use of full (8 connectivity in 2D) on this image if (argc > 7) { - ConnectedThresholdImageFilterType::ConnectivityEnum conenctivity = + const ConnectedThresholdImageFilterType::ConnectivityEnum conenctivity = std::stoi(argv[7]) ? ConnectedThresholdImageFilterType::ConnectivityEnum::FullConnectivity : ConnectedThresholdImageFilterType::ConnectivityEnum::FaceConnectivity; connectedThresholdFilter->SetConnectivity(conenctivity); @@ -120,9 +120,9 @@ itkConnectedThresholdImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(connectedThresholdFilter->Update();); // Write the output image - itk::ImageFileWriter::Pointer writer = itk::ImageFileWriter::New(); + const itk::ImageFileWriter::Pointer writer = itk::ImageFileWriter::New(); - std::string outputImageFilename = argv[2]; + const std::string outputImageFilename = argv[2]; writer->SetFileName(outputImageFilename); writer->SetInput(connectedThresholdFilter->GetOutput()); diff --git a/Modules/Segmentation/RegionGrowing/test/itkIsolatedConnectedImageFilterTest.cxx b/Modules/Segmentation/RegionGrowing/test/itkIsolatedConnectedImageFilterTest.cxx index 00c39c9134c..0e5693fcc19 100644 --- a/Modules/Segmentation/RegionGrowing/test/itkIsolatedConnectedImageFilterTest.cxx +++ b/Modules/Segmentation/RegionGrowing/test/itkIsolatedConnectedImageFilterTest.cxx @@ -38,14 +38,14 @@ itkIsolatedConnectedImageFilterTest(int argc, char * argv[]) using PixelType = unsigned char; using myImage = itk::Image; - itk::ImageFileReader::Pointer input = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer input = itk::ImageFileReader::New(); input->SetFileName(argv[1]); // Create a filter using FilterType = itk::IsolatedConnectedImageFilter; - auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + auto filter = FilterType::New(); + const itk::SimpleFilterWatcher watcher(filter); filter->SetInput(input->GetOutput()); @@ -76,24 +76,24 @@ itkIsolatedConnectedImageFilterTest(int argc, char * argv[]) } // The min and max values for a .png image - FilterType::InputImagePixelType lower = 0; + const FilterType::InputImagePixelType lower = 0; filter->SetLower(lower); ITK_TEST_SET_GET_VALUE(lower, filter->GetLower()); #if !defined(ITK_LEGACY_REMOVE) - FilterType::InputImagePixelType upperValueLimit = 255; + FilterType::InputImagePixelType const upperValueLimit = 255; filter->SetUpperValueLimit(upperValueLimit); ITK_TEST_SET_GET_VALUE(upperValueLimit, filter->GetUpperValueLimit()); #endif - FilterType::InputImagePixelType upper = 255; + const FilterType::InputImagePixelType upper = 255; filter->SetUpper(upper); ITK_TEST_SET_GET_VALUE(upper, filter->GetUpper()); - FilterType::OutputImagePixelType replaceValue = 255; + const FilterType::OutputImagePixelType replaceValue = 255; filter->SetReplaceValue(replaceValue); ITK_TEST_SET_GET_VALUE(replaceValue, filter->GetReplaceValue()); - FilterType::InputImagePixelType isolatedValueTolerance = 1; + const FilterType::InputImagePixelType isolatedValueTolerance = 1; filter->SetIsolatedValueTolerance(isolatedValueTolerance); ITK_TEST_SET_GET_VALUE(isolatedValueTolerance, filter->GetIsolatedValueTolerance()); diff --git a/Modules/Segmentation/RegionGrowing/test/itkNeighborhoodConnectedImageFilterTest.cxx b/Modules/Segmentation/RegionGrowing/test/itkNeighborhoodConnectedImageFilterTest.cxx index b3b1d2fcd80..65cf829f36c 100644 --- a/Modules/Segmentation/RegionGrowing/test/itkNeighborhoodConnectedImageFilterTest.cxx +++ b/Modules/Segmentation/RegionGrowing/test/itkNeighborhoodConnectedImageFilterTest.cxx @@ -34,14 +34,14 @@ itkNeighborhoodConnectedImageFilterTest(int argc, char * argv[]) using PixelType = unsigned char; using myImage = itk::Image; - itk::ImageFileReader::Pointer input = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer input = itk::ImageFileReader::New(); input->SetFileName(argv[1]); // Create a filter using FilterType = itk::NeighborhoodConnectedImageFilter; - auto filter = FilterType::New(); - itk::SimpleFilterWatcher watcher(filter); + auto filter = FilterType::New(); + const itk::SimpleFilterWatcher watcher(filter); filter->SetInput(input->GetOutput()); @@ -60,11 +60,11 @@ itkNeighborhoodConnectedImageFilterTest(int argc, char * argv[]) filter->SetReplaceValue(255); // Test GetMacros - PixelType lower = filter->GetLower(); + const PixelType lower = filter->GetLower(); std::cout << "filter->GetLower(): " << itk::NumericTraits::PrintType(lower) << std::endl; - PixelType upper = filter->GetUpper(); + const PixelType upper = filter->GetUpper(); std::cout << "filter->GetUpper(): " << itk::NumericTraits::PrintType(upper) << std::endl; - PixelType replaceValue = filter->GetReplaceValue(); + const PixelType replaceValue = filter->GetReplaceValue(); std::cout << "filter->GetReplaceValue(): " << itk::NumericTraits::PrintType(replaceValue) << std::endl; // Test GetConstReferenceMacro diff --git a/Modules/Segmentation/RegionGrowing/test/itkVectorConfidenceConnectedImageFilterTest.cxx b/Modules/Segmentation/RegionGrowing/test/itkVectorConfidenceConnectedImageFilterTest.cxx index adb27f79331..06ed5b0d974 100644 --- a/Modules/Segmentation/RegionGrowing/test/itkVectorConfidenceConnectedImageFilterTest.cxx +++ b/Modules/Segmentation/RegionGrowing/test/itkVectorConfidenceConnectedImageFilterTest.cxx @@ -55,8 +55,8 @@ itkVectorConfidenceConnectedImageFilterTest(int argc, char * argv[]) // Create a filter using FilterType = itk::VectorConfidenceConnectedImageFilter; - auto filter = FilterType::New(); - itk::SimpleFilterWatcher filterWatch(filter); + auto filter = FilterType::New(); + const itk::SimpleFilterWatcher filterWatch(filter); filter->SetInput(input->GetOutput()); filter->SetInitialNeighborhoodRadius(3); // measured in pixels @@ -83,13 +83,13 @@ itkVectorConfidenceConnectedImageFilterTest(int argc, char * argv[]) // Test the GetMacros - double doubleMultiplier = filter->GetMultiplier(); + const double doubleMultiplier = filter->GetMultiplier(); std::cout << "filter->GetMultiplier(): " << doubleMultiplier << std::endl; - unsigned int uintNumberOfIterations = filter->GetNumberOfIterations(); + const unsigned int uintNumberOfIterations = filter->GetNumberOfIterations(); std::cout << "filter->GetNumberOfIterations(): " << uintNumberOfIterations << std::endl; - OutputPixelType pixelReplaceValue = filter->GetReplaceValue(); + const OutputPixelType pixelReplaceValue = filter->GetReplaceValue(); std::cout << "filter->GetReplaceValue(): " << static_cast::PrintType>(pixelReplaceValue) << std::endl; diff --git a/Modules/Segmentation/SignedDistanceFunction/include/itkPCAShapeSignedDistanceFunction.hxx b/Modules/Segmentation/SignedDistanceFunction/include/itkPCAShapeSignedDistanceFunction.hxx index 0d3de6fd7d9..c4125baf810 100644 --- a/Modules/Segmentation/SignedDistanceFunction/include/itkPCAShapeSignedDistanceFunction.hxx +++ b/Modules/Segmentation/SignedDistanceFunction/include/itkPCAShapeSignedDistanceFunction.hxx @@ -120,7 +120,7 @@ PCAShapeSignedDistanceFunction::Initialize } // verify image buffered region - typename ImageType::RegionType meanImageRegion = m_MeanImage->GetBufferedRegion(); + const typename ImageType::RegionType meanImageRegion = m_MeanImage->GetBufferedRegion(); for (unsigned int i = 0; i < m_NumberOfPrincipalComponents; ++i) { @@ -165,7 +165,7 @@ PCAShapeSignedDistanceFunction::Evaluate(c -> OutputType { // transform the point into the shape model space - PointType mappedPoint = m_Transform->TransformPoint(point); + const PointType mappedPoint = m_Transform->TransformPoint(point); itkDebugMacro("mappedPoint:" << mappedPoint); diff --git a/Modules/Segmentation/SignedDistanceFunction/test/itkPCAShapeSignedDistanceFunctionTest.cxx b/Modules/Segmentation/SignedDistanceFunction/test/itkPCAShapeSignedDistanceFunctionTest.cxx index e8feba52c02..ab0bebed618 100644 --- a/Modules/Segmentation/SignedDistanceFunction/test/itkPCAShapeSignedDistanceFunctionTest.cxx +++ b/Modules/Segmentation/SignedDistanceFunction/test/itkPCAShapeSignedDistanceFunctionTest.cxx @@ -60,11 +60,11 @@ itkPCAShapeSignedDistanceFunctionTest(int, char *[]) // prepare for image creation using ImageType = ShapeFunction::ImageType; - ImageType::SizeType imageSize = { { ImageWidth, ImageHeight } }; + const ImageType::SizeType imageSize = { { ImageWidth, ImageHeight } }; - ImageType::IndexType startIndex{}; + const ImageType::IndexType startIndex{}; - ImageType::RegionType region{ startIndex, imageSize }; + const ImageType::RegionType region{ startIndex, imageSize }; // set up the random number generator @@ -124,9 +124,9 @@ itkPCAShapeSignedDistanceFunctionTest(int, char *[]) // set up the parameters - unsigned int numberOfShapeParameters = shape->GetNumberOfShapeParameters(); - unsigned int numberOfPoseParameters = shape->GetNumberOfPoseParameters(); - unsigned int numberOfParameters = numberOfShapeParameters + numberOfPoseParameters; + const unsigned int numberOfShapeParameters = shape->GetNumberOfShapeParameters(); + const unsigned int numberOfPoseParameters = shape->GetNumberOfPoseParameters(); + const unsigned int numberOfParameters = numberOfShapeParameters + numberOfPoseParameters; ShapeFunction::ParametersType parameters(numberOfParameters); for (i = 0; i < numberOfParameters; ++i) @@ -147,8 +147,8 @@ itkPCAShapeSignedDistanceFunctionTest(int, char *[]) ShapeFunction::OutputType expected; std::cout << "check results:" << std::endl; - unsigned int numberOfRotationParameters = Dimension * (Dimension - 1) / 2; - unsigned int startIndexOfTranslationParameters = numberOfShapeParameters + numberOfRotationParameters; + const unsigned int numberOfRotationParameters = Dimension * (Dimension - 1) / 2; + const unsigned int startIndexOfTranslationParameters = numberOfShapeParameters + numberOfRotationParameters; ShapeFunction::TransformType::InputPointType p; ShapeFunction::TransformType::InputPointType q; @@ -163,7 +163,7 @@ itkPCAShapeSignedDistanceFunctionTest(int, char *[]) p[0] = point[0] - parameters[startIndexOfTranslationParameters]; p[1] = point[1] - parameters[startIndexOfTranslationParameters + 1]; - double angle = parameters[numberOfShapeParameters]; + const double angle = parameters[numberOfShapeParameters]; q[0] = p[0] * std::cos(-angle) - p[1] * std::sin(-angle); q[1] = p[0] * std::sin(-angle) + p[1] * std::cos(-angle); @@ -245,8 +245,8 @@ itkPCAShapeSignedDistanceFunctionTest(int, char *[]) TEST_INITIALIZATION_ERROR(PrincipalComponentImages, badPCImages, pcImages); // A PC image of the wrong size - auto badSize = ImageType::SizeType::Filled(1); - ImageType::RegionType badRegion(badSize); + auto badSize = ImageType::SizeType::Filled(1); + const ImageType::RegionType badRegion(badSize); badPCImages[1] = ImageType::New(); badPCImages[1]->SetRegions(badRegion); badPCImages[1]->Allocate(); diff --git a/Modules/Segmentation/SignedDistanceFunction/test/itkSphereSignedDistanceFunctionTest.cxx b/Modules/Segmentation/SignedDistanceFunction/test/itkSphereSignedDistanceFunctionTest.cxx index c78336de952..bd00b376460 100644 --- a/Modules/Segmentation/SignedDistanceFunction/test/itkSphereSignedDistanceFunctionTest.cxx +++ b/Modules/Segmentation/SignedDistanceFunction/test/itkSphereSignedDistanceFunctionTest.cxx @@ -45,7 +45,7 @@ itkSphereSignedDistanceFunctionTest(int, char *[]) auto sphere = SphereFunctionType::New(); // cast it to a generic function - FunctionType::Pointer function = dynamic_cast(sphere.GetPointer()); + const FunctionType::Pointer function = dynamic_cast(sphere.GetPointer()); sphere = nullptr; // we must initialize the function before use @@ -66,12 +66,12 @@ itkSphereSignedDistanceFunctionTest(int, char *[]) for (double p = 0.0; p < 10.0; p += 1.0) { point.Fill(p); - FunctionType::OutputType output = function->Evaluate(point); + const FunctionType::OutputType output = function->Evaluate(point); std::cout << "f( " << point << ") = " << output << std::endl; // check results - CoordRep expected = p * std::sqrt(2.0) - parameters[0]; + const CoordRep expected = p * std::sqrt(2.0) - parameters[0]; if (itk::Math::abs(output - expected) > 1e-9) { std::cout << "But expected value is: " << expected << std::endl; diff --git a/Modules/Segmentation/SuperPixel/include/itkSLICImageFilter.hxx b/Modules/Segmentation/SuperPixel/include/itkSLICImageFilter.hxx index a7d3d7529d3..88314b8a6a2 100644 --- a/Modules/Segmentation/SuperPixel/include/itkSLICImageFilter.hxx +++ b/Modules/Segmentation/SuperPixel/include/itkSLICImageFilter.hxx @@ -285,8 +285,9 @@ SLICImageFilter::ThreadedUpdateCluste const InputPixelType & v = itIn.Get(); const typename OutputImageType::PixelType l = itOut.Get(); - std::pair r = clusterMap.insert(std::make_pair(l, UpdateCluster())); - vnl_vector & cluster = r.first->second.cluster; + const std::pair r = + clusterMap.insert(std::make_pair(l, UpdateCluster())); + vnl_vector & cluster = r.first->second.cluster; if (r.second) { cluster.set_size(numberOfClusterComponents); @@ -651,7 +652,7 @@ SLICImageFilter::GenerateData() ClusterType cluster(numberOfClusterComponents, &m_Clusters[i * numberOfClusterComponents]); cluster /= clusterCount[i]; - ClusterType oldCluster(numberOfClusterComponents, &m_OldClusters[i * numberOfClusterComponents]); + const ClusterType oldCluster(numberOfClusterComponents, &m_OldClusters[i * numberOfClusterComponents]); l1Residual += Distance(cluster, oldCluster); } diff --git a/Modules/Segmentation/SuperPixel/test/itkSLICImageFilterGTest.cxx b/Modules/Segmentation/SuperPixel/test/itkSLICImageFilterGTest.cxx index bc0e8139eb1..1d1cbcc9421 100644 --- a/Modules/Segmentation/SuperPixel/test/itkSLICImageFilterGTest.cxx +++ b/Modules/Segmentation/SuperPixel/test/itkSLICImageFilterGTest.cxx @@ -92,9 +92,9 @@ TEST_F(SLICFixture, SetGet) auto filter = Utils::FilterType::New(); - typename Utils::FilterType::ConstPointer constfilter = (const Utils::FilterType *)(filter.GetPointer()); + const typename Utils::FilterType::ConstPointer constfilter = (const Utils::FilterType *)(filter.GetPointer()); - Utils::FilterType::SuperGridSizeType gridSize3(3); + const Utils::FilterType::SuperGridSizeType gridSize3(3); EXPECT_NO_THROW(filter->SetSuperGridSize(gridSize3)); ITK_EXPECT_VECTOR_NEAR(gridSize3, filter->GetSuperGridSize(), 0); diff --git a/Modules/Segmentation/SuperPixel/test/itkSLICImageFilterTest.cxx b/Modules/Segmentation/SuperPixel/test/itkSLICImageFilterTest.cxx index c1b018cd9c0..7b255f53b78 100644 --- a/Modules/Segmentation/SuperPixel/test/itkSLICImageFilterTest.cxx +++ b/Modules/Segmentation/SuperPixel/test/itkSLICImageFilterTest.cxx @@ -73,7 +73,7 @@ itkSLICImageFilterTestHelper(const std::string & inFileName, filter->DebugOn(); - itk::CStyleCommand::Pointer command = itk::CStyleCommand::New(); + const itk::CStyleCommand::Pointer command = itk::CStyleCommand::New(); command->SetCallback(iterationEventCallback); filter->AddObserver(itk::IterationEvent(), command); diff --git a/Modules/Segmentation/Voronoi/include/itkVoronoiDiagram2DGenerator.hxx b/Modules/Segmentation/Voronoi/include/itkVoronoiDiagram2DGenerator.hxx index d25869d6f2b..6c8be4b6f04 100644 --- a/Modules/Segmentation/Voronoi/include/itkVoronoiDiagram2DGenerator.hxx +++ b/Modules/Segmentation/Voronoi/include/itkVoronoiDiagram2DGenerator.hxx @@ -45,8 +45,8 @@ VoronoiDiagram2DGenerator::SetRandomSeeds(int num) PointType curr; m_Seeds.clear(); - double ymax{ m_VorBoundary[1] }; - double xmax{ m_VorBoundary[0] }; + const double ymax{ m_VorBoundary[1] }; + const double xmax{ m_VorBoundary[0] }; for (int i = 0; i < num; ++i) { curr[0] = (CoordinateType)(vnl_sample_uniform(0, xmax)); @@ -186,8 +186,8 @@ template bool VoronoiDiagram2DGenerator::almostsame(CoordinateType p1, CoordinateType p2) { - double diff = p1 - p2; - bool save = ((diff < -DIFF_TOLERENCE) || (diff > DIFF_TOLERENCE)); + const double diff = p1 - p2; + const bool save = ((diff < -DIFF_TOLERENCE) || (diff > DIFF_TOLERENCE)); return (!save); } @@ -227,8 +227,8 @@ VoronoiDiagram2DGenerator::ConstructDiagram() m_OutputVD->Reset(); - EdgeInfo currentPtID; - int edges = m_OutputVD->EdgeListSize(); + EdgeInfo currentPtID; + const int edges = m_OutputVD->EdgeListSize(); EdgeInfo LRsites; for (int i = 0; i < edges; ++i) @@ -270,9 +270,9 @@ VoronoiDiagram2DGenerator::ConstructDiagram() EdgeInfo curr1; EdgeInfo curr2; - unsigned char frontbnd; - unsigned char backbnd; - std::vector cellPoints; + unsigned char frontbnd; + unsigned char backbnd; + const std::vector cellPoints; for (unsigned int i = 0; i < m_NumberOfSeeds; ++i) { buildEdges.clear(); @@ -313,8 +313,8 @@ VoronoiDiagram2DGenerator::ConstructDiagram() } else if ((frontbnd != 0) || (backbnd != 0)) { - unsigned char cfrontbnd = Pointonbnd(curr[0]); - unsigned char cbackbnd = Pointonbnd(curr[1]); + const unsigned char cfrontbnd = Pointonbnd(curr[0]); + const unsigned char cbackbnd = Pointonbnd(curr[1]); if ((cfrontbnd == backbnd) && (backbnd)) { @@ -423,7 +423,7 @@ VoronoiDiagram2DGenerator::right_of(FortuneHalfEdge * el, PointType FortuneEdge * e = el->m_Edge; FortuneSite * topsite = e->m_Reg[1]; - bool right_of_site = (((*p)[0]) > (topsite->m_Coord[0])); + const bool right_of_site = (((*p)[0]) > (topsite->m_Coord[0])); if (right_of_site && (!(el->m_RorL))) { @@ -437,8 +437,8 @@ VoronoiDiagram2DGenerator::right_of(FortuneHalfEdge * el, PointType bool fast; if (e->m_A == 1.0) { - double dyp = ((*p)[1]) - (topsite->m_Coord[1]); - double dxp = ((*p)[0]) - (topsite->m_Coord[0]); + const double dyp = ((*p)[1]) - (topsite->m_Coord[1]); + const double dxp = ((*p)[0]) - (topsite->m_Coord[0]); fast = false; if (((!right_of_site) && ((e->m_B) < 0.0)) || (right_of_site && ((e->m_B) >= 0.0))) { @@ -459,7 +459,7 @@ VoronoiDiagram2DGenerator::right_of(FortuneHalfEdge * el, PointType } if (!fast) { - double dxs = topsite->m_Coord[0] - ((e->m_Reg[0])->m_Coord[0]); + const double dxs = topsite->m_Coord[0] - ((e->m_Reg[0])->m_Coord[0]); above = (((e->m_B) * (dxp * dxp - dyp * dyp)) < (dxs * dyp * (1.0 + 2.0 * dxp / dxs + (e->m_B) * (e->m_B)))); if ((e->m_B) < 0.0) { @@ -469,10 +469,10 @@ VoronoiDiagram2DGenerator::right_of(FortuneHalfEdge * el, PointType } else { // e->m_B == 1.0 - double y1 = (e->m_C) - (e->m_A) * ((*p)[0]); - double t1 = ((*p)[1]) - y1; - double t2 = ((*p)[0]) - topsite->m_Coord[0]; - double t3 = y1 - topsite->m_Coord[1]; + const double y1 = (e->m_C) - (e->m_A) * ((*p)[0]); + const double t1 = ((*p)[1]) - y1; + const double t2 = ((*p)[0]) - topsite->m_Coord[0]; + const double t3 = y1 - topsite->m_Coord[1]; above = ((t1 * t1) > (t2 * t2 + t3 * t3)); } return (el->m_RorL ? (!above) : above); @@ -572,8 +572,8 @@ template double VoronoiDiagram2DGenerator::dist(FortuneSite * s1, FortuneSite * s2) { - double dx = (s1->m_Coord[0]) - (s2->m_Coord[0]); - double dy = (s1->m_Coord[1]) - (s2->m_Coord[1]); + const double dx = (s1->m_Coord[0]) - (s2->m_Coord[0]); + const double dy = (s1->m_Coord[1]) - (s2->m_Coord[1]); return (std::sqrt(dx * dx + dy * dy)); } @@ -713,10 +713,10 @@ VoronoiDiagram2DGenerator::bisect(FortuneEdge * answer, FortuneSite answer->m_Ep[0] = nullptr; answer->m_Ep[1] = nullptr; - double dx = (s2->m_Coord[0]) - (s1->m_Coord[0]); - double dy = (s2->m_Coord[1]) - (s1->m_Coord[1]); - double adx = (dx > 0) ? dx : -dx; - double ady = (dy > 0) ? dy : -dy; + const double dx = (s2->m_Coord[0]) - (s1->m_Coord[0]); + const double dy = (s2->m_Coord[1]) - (s1->m_Coord[1]); + const double adx = (dx > 0) ? dx : -dx; + const double ady = (dy > 0) ? dy : -dy; answer->m_C = (s1->m_Coord[0]) * dx + (s1->m_Coord[1]) * dy + (dx * dx + dy * dy) * 0.5; if (adx > ady) @@ -764,7 +764,7 @@ VoronoiDiagram2DGenerator::intersect(FortuneSite * newV, FortuneHal return; } - double d = (e1->m_A) * (e2->m_B) - (e1->m_B) * (e2->m_A); + const double d = (e1->m_A) * (e2->m_B) - (e1->m_B) * (e2->m_A); if ((d > -NUMERIC_TOLERENCE) && (d < NUMERIC_TOLERENCE)) { @@ -772,8 +772,8 @@ VoronoiDiagram2DGenerator::intersect(FortuneSite * newV, FortuneHal return; } - double xmeet = ((e1->m_C) * (e2->m_B) - (e2->m_C) * (e1->m_B)) / d; - double ymeet = ((e2->m_C) * (e1->m_A) - (e1->m_C) * (e2->m_A)) / d; + const double xmeet = ((e1->m_C) * (e2->m_B) - (e2->m_C) * (e1->m_B)) / d; + const double ymeet = ((e2->m_C) * (e1->m_A) - (e1->m_C) * (e2->m_A)) / d; if (comp(e1->m_Reg[1]->m_Coord, e2->m_Reg[1]->m_Coord)) { @@ -786,7 +786,7 @@ VoronoiDiagram2DGenerator::intersect(FortuneSite * newV, FortuneHal saveE = e2; } - bool right_of_site = (xmeet >= (saveE->m_Reg[1]->m_Coord[0])); + const bool right_of_site = (xmeet >= (saveE->m_Reg[1]->m_Coord[0])); if ((right_of_site && (!(saveHE->m_RorL))) || ((!right_of_site) && (saveHE->m_RorL))) { newV->m_Sitenbr = -4; diff --git a/Modules/Segmentation/Voronoi/include/itkVoronoiPartitioningImageFilter.hxx b/Modules/Segmentation/Voronoi/include/itkVoronoiPartitioningImageFilter.hxx index 8470fceccd5..33266a97edf 100644 --- a/Modules/Segmentation/Voronoi/include/itkVoronoiPartitioningImageFilter.hxx +++ b/Modules/Segmentation/Voronoi/include/itkVoronoiPartitioningImageFilter.hxx @@ -90,7 +90,7 @@ template void VoronoiPartitioningImageFilter::MakeSegmentBoundary() { - RegionType region = this->GetInput()->GetRequestedRegion(); + const RegionType region = this->GetInput()->GetRequestedRegion(); itk::ImageRegionIteratorWithIndex oit(this->GetOutput(), region); while (!oit.IsAtEnd()) @@ -118,7 +118,7 @@ template void VoronoiPartitioningImageFilter::MakeSegmentObject() { - RegionType region = this->GetInput()->GetRequestedRegion(); + const RegionType region = this->GetInput()->GetRequestedRegion(); itk::ImageRegionIteratorWithIndex oit(this->GetOutput(), region); while (!oit.IsAtEnd()) diff --git a/Modules/Segmentation/Voronoi/include/itkVoronoiSegmentationImageFilter.hxx b/Modules/Segmentation/Voronoi/include/itkVoronoiSegmentationImageFilter.hxx index 83a49f39fba..48fd114e99d 100644 --- a/Modules/Segmentation/Voronoi/include/itkVoronoiSegmentationImageFilter.hxx +++ b/Modules/Segmentation/Voronoi/include/itkVoronoiSegmentationImageFilter.hxx @@ -93,7 +93,7 @@ void VoronoiSegmentationImageFilter::TakeAPrior( const BinaryObjectImage * aprior) { - RegionType region = this->GetInput()->GetRequestedRegion(); + const RegionType region = this->GetInput()->GetRequestedRegion(); itk::ImageRegionConstIteratorWithIndex ait(aprior, region); itk::ImageRegionConstIteratorWithIndex iit(this->GetInput(), region); @@ -185,7 +185,7 @@ VoronoiSegmentationImageFilter::Ta m_Mean = addp / num; m_STD = std::sqrt((addpp - (addp * addp) / num) / (num - 1)); - float b_Mean = addb / numb; + const float b_Mean = addb / numb; if (this->GetUseBackgroundInAPrior()) { diff --git a/Modules/Segmentation/Voronoi/include/itkVoronoiSegmentationImageFilterBase.hxx b/Modules/Segmentation/Voronoi/include/itkVoronoiSegmentationImageFilterBase.hxx index 9fc974bf572..c879a7c0591 100644 --- a/Modules/Segmentation/Voronoi/include/itkVoronoiSegmentationImageFilterBase.hxx +++ b/Modules/Segmentation/Voronoi/include/itkVoronoiSegmentationImageFilterBase.hxx @@ -162,7 +162,7 @@ VoronoiSegmentationImageFilterBase } else { // normal case some scanlines - double offset = static_cast(intbeginy) - beginy; + const double offset = static_cast(intbeginy) - beginy; endx += offset * rightDx; beginx += offset * leftDx; while (idx[1] <= intendy) @@ -249,7 +249,7 @@ VoronoiSegmentationImageFilterBase } else { // normal case some scanlines - double offset = static_cast(intbeginy) - beginy; + const double offset = static_cast(intbeginy) - beginy; endx += offset * rightDx; beginx += offset * leftDx; while (idx[1] <= intendy) @@ -307,7 +307,7 @@ VoronoiSegmentationImageFilterBase beginx = leftP[0]; endx = rightP[0] + rightDx * (leftP[1] - rightP[1]); } - double offset = static_cast(intbeginy) - beginy; + const double offset = static_cast(intbeginy) - beginy; beginx += offset * leftDx; endx += offset * rightDx; while (idx[1] <= intendy) @@ -518,7 +518,7 @@ template ::MakeSegmentBoundary() { - RegionType region = this->GetInput()->GetRequestedRegion(); + const RegionType region = this->GetInput()->GetRequestedRegion(); itk::ImageRegionIteratorWithIndex oit(this->GetOutput(), region); while (!oit.IsAtEnd()) @@ -531,7 +531,7 @@ VoronoiSegmentationImageFilterBase { if (m_Label[i] == 2) { - NeighborIdIterator nitend = m_WorkingVD->NeighborIdsEnd(i); + const NeighborIdIterator nitend = m_WorkingVD->NeighborIdsEnd(i); for (NeighborIdIterator nit = m_WorkingVD->NeighborIdsBegin(i); nit != nitend; ++nit) { if (((*nit) > i) && (m_Label[*nit] == 2)) @@ -547,7 +547,7 @@ template ::MakeSegmentObject() { - RegionType region = this->GetInput()->GetRequestedRegion(); + const RegionType region = this->GetInput()->GetRequestedRegion(); itk::ImageRegionIteratorWithIndex oit(this->GetOutput(), region); while (!oit.IsAtEnd()) @@ -671,7 +671,7 @@ VoronoiSegmentationImageFilterBase } else { // normal case some scanlines - double offset = static_cast(intbeginy) - beginy; + const double offset = static_cast(intbeginy) - beginy; endx += offset * rightDx; beginx += offset * leftDx; while (idx[1] <= intendy) @@ -758,7 +758,7 @@ VoronoiSegmentationImageFilterBase } else { // normal case some scanlines - double offset = static_cast(intbeginy) - beginy; + const double offset = static_cast(intbeginy) - beginy; endx += offset * rightDx; beginx += offset * leftDx; while (idx[1] <= intendy) @@ -816,7 +816,7 @@ VoronoiSegmentationImageFilterBase beginx = leftP[0]; endx = rightP[0] + rightDx * (leftP[1] - rightP[1]); } - double offset = static_cast(intbeginy) - beginy; + const double offset = static_cast(intbeginy) - beginy; beginx += offset * leftDx; endx += offset * rightDx; while (idx[1] <= intendy) @@ -861,17 +861,17 @@ VoronoiSegmentationImageFilterBase --y2; } - int dx = x1 - x2; - int adx = (dx > 0) ? dx : -dx; - int dy = y1 - y2; - int ady = (dy > 0) ? dy : -dy; + int dx = x1 - x2; + const int adx = (dx > 0) ? dx : -dx; + int dy = y1 - y2; + const int ady = (dy > 0) ? dy : -dy; if (adx > ady) { if (x1 > x2) { - int save = x1; + const int save = x1; x1 = x2; x2 = save; y1 = y2; @@ -881,10 +881,10 @@ VoronoiSegmentationImageFilterBase { dx = 1; } - float offset = static_cast(dy) / dx; + const float offset = static_cast(dy) / dx; for (int i = x1; i <= x2; ++i) { - IndexType idx = { i, y1 }; + const IndexType idx = { i, y1 }; output->SetPixel(idx, 1); curr += offset; y1 = static_cast(curr + 0.5); @@ -895,7 +895,7 @@ VoronoiSegmentationImageFilterBase if (y1 > y2) { x1 = x2; - int save = y1; + const int save = y1; y1 = y2; y2 = save; } @@ -904,10 +904,10 @@ VoronoiSegmentationImageFilterBase { dy = 1; } - float offset = static_cast(dx) / dy; + const float offset = static_cast(dx) / dy; for (int i = y1; i <= y2; ++i) { - IndexType idx = { x1, i }; + const IndexType idx = { x1, i }; output->SetPixel(idx, 1); curr += offset; x1 = static_cast(curr + 0.5); @@ -980,10 +980,10 @@ VoronoiSegmentationImageFilterBase { --y2; } - int dx = x1 - x2; - int adx = (dx > 0) ? dx : -dx; - int dy = y1 - y2; - int ady = (dy > 0) ? dy : -dy; + int dx = x1 - x2; + const int adx = (dx > 0) ? dx : -dx; + int dy = y1 - y2; + const int ady = (dy > 0) ? dy : -dy; if (adx > ady) { @@ -1001,7 +1001,7 @@ VoronoiSegmentationImageFilterBase { dx = 1; } - float offset = static_cast(dy) / dx; + const float offset = static_cast(dy) / dx; for (int i = x1; i <= x2; ++i) { IndexType idx{ i, y1 }; @@ -1026,7 +1026,7 @@ VoronoiSegmentationImageFilterBase { dy = 1; } - float offset = static_cast(dx) / dy; + const float offset = static_cast(dx) / dy; for (int i = y1; i <= y2; ++i) { IndexType idx = { x1, i }; @@ -1046,7 +1046,7 @@ VoronoiSegmentationImageFilterBase // set the input requested region to the LargestPossibleRegion { - InputImagePointer input = const_cast(this->GetInput()); + const InputImagePointer input = const_cast(this->GetInput()); if (input) { input->SetRequestedRegion(this->GetInput()->GetLargestPossibleRegion()); diff --git a/Modules/Segmentation/Voronoi/include/itkVoronoiSegmentationRGBImageFilter.hxx b/Modules/Segmentation/Voronoi/include/itkVoronoiSegmentationRGBImageFilter.hxx index fd7694f495a..6fdf111b0a9 100644 --- a/Modules/Segmentation/Voronoi/include/itkVoronoiSegmentationRGBImageFilter.hxx +++ b/Modules/Segmentation/Voronoi/include/itkVoronoiSegmentationRGBImageFilter.hxx @@ -95,9 +95,9 @@ VoronoiSegmentationRGBImageFilter::SetInput(const Inp RGBHCVPixel wpixel; - double X0 = m_MaxValueOfRGB * 0.982; - double Y0 = m_MaxValueOfRGB; - double Z0 = m_MaxValueOfRGB * 1.183; + const double X0 = m_MaxValueOfRGB * 0.982; + const double Y0 = m_MaxValueOfRGB; + const double Z0 = m_MaxValueOfRGB * 1.183; while (!iit.IsAtEnd()) { @@ -190,7 +190,7 @@ template void VoronoiSegmentationRGBImageFilter::TakeAPrior(const BinaryObjectImage * aprior) { - RegionType region = this->GetInput()->GetRequestedRegion(); + const RegionType region = this->GetInput()->GetRequestedRegion(); itk::ImageRegionConstIteratorWithIndex ait(aprior, region); itk::ImageRegionIteratorWithIndex iit(m_WorkingImage, region); diff --git a/Modules/Segmentation/Voronoi/test/itkVoronoiPartitioningImageFilterTest.cxx b/Modules/Segmentation/Voronoi/test/itkVoronoiPartitioningImageFilterTest.cxx index 84e5fbd8a90..2e471aad9b8 100644 --- a/Modules/Segmentation/Voronoi/test/itkVoronoiPartitioningImageFilterTest.cxx +++ b/Modules/Segmentation/Voronoi/test/itkVoronoiPartitioningImageFilterTest.cxx @@ -40,11 +40,11 @@ itkVoronoiPartitioningImageFilterTest(int argc, char * argv[]) // Load an image - itk::ImageFileReader::Pointer original = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer original = itk::ImageFileReader::New(); original->SetFileName(argv[1]); // Preprocess the image - itk::DiscreteGaussianImageFilter::Pointer gaussian3 = + const itk::DiscreteGaussianImageFilter::Pointer gaussian3 = itk::DiscreteGaussianImageFilter::New(); // itk::SimpleFilterWatcher gaussian3Watcher(gaussian3); gaussian3->SetInput(original->GetOutput()); @@ -65,14 +65,14 @@ itkVoronoiPartitioningImageFilterTest(int argc, char * argv[]) voronoi->SetOutputBoundary(std::stoi(argv[3]) == 1); voronoi->SetSteps(7); - double sigmaThreshold = 4.0; + const double sigmaThreshold = 4.0; voronoi->SetSigmaThreshold(sigmaThreshold); ITK_TEST_SET_GET_VALUE(sigmaThreshold, voronoi->GetSigmaThreshold()); voronoi->SetMinRegion(10); voronoi->InteractiveSegmentationOn(); - itk::SimpleFilterWatcher voronoiWatcher(voronoi); + const itk::SimpleFilterWatcher voronoiWatcher(voronoi); // Write out an image of the voronoi diagram using RGBPixelType = itk::RGBPixel; diff --git a/Modules/Segmentation/Voronoi/test/itkVoronoiSegmentationImageFilterTest.cxx b/Modules/Segmentation/Voronoi/test/itkVoronoiSegmentationImageFilterTest.cxx index cad6d766ef4..24502e670b1 100644 --- a/Modules/Segmentation/Voronoi/test/itkVoronoiSegmentationImageFilterTest.cxx +++ b/Modules/Segmentation/Voronoi/test/itkVoronoiSegmentationImageFilterTest.cxx @@ -44,9 +44,9 @@ itkVoronoiSegmentationImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS( voronoiSegmenter, VoronoiSegmentationImageFilter, VoronoiSegmentationImageFilterBase); - auto inputImage = UShortImage::New(); - UShortImage::SizeType size = { { width, height } }; - UShortImage::IndexType index{}; + auto inputImage = UShortImage::New(); + const UShortImage::SizeType size = { { width, height } }; + UShortImage::IndexType index{}; UShortImage::RegionType region; diff --git a/Modules/Segmentation/Voronoi/test/itkVoronoiSegmentationRGBImageFilterTest.cxx b/Modules/Segmentation/Voronoi/test/itkVoronoiSegmentationRGBImageFilterTest.cxx index daa4bc9850a..abe23b7e1d6 100644 --- a/Modules/Segmentation/Voronoi/test/itkVoronoiSegmentationRGBImageFilterTest.cxx +++ b/Modules/Segmentation/Voronoi/test/itkVoronoiSegmentationRGBImageFilterTest.cxx @@ -60,9 +60,9 @@ ImageType::Pointer SetUpInputImage() { // initialize the test input image - auto inputImage = ImageType::New(); - ImageType::SizeType size = { { width, height } }; - ImageType::RegionType region; + auto inputImage = ImageType::New(); + const ImageType::SizeType size = { { width, height } }; + ImageType::RegionType region; region.SetSize(size); inputImage->SetRegions(region); inputImage->Allocate(); @@ -178,7 +178,8 @@ CheckResults(SegmentationType::Pointer outputImage) std::cout << "Correct Exterior: " << correctExterior << std::endl; std::cout << "False Interior: " << falseInterior << std::endl; std::cout << "False Exterior: " << falseExterior << std::endl; - double percentCorrect = static_cast(correctInterior + correctExterior) / static_cast(width * height); + const double percentCorrect = + static_cast(correctInterior + correctExterior) / static_cast(width * height); std::cout << "Percent Correct = " << percentCorrect * 100 << '%' << std::endl; return percentCorrect; @@ -235,7 +236,7 @@ TestNoPrior(ImageType::Pointer inputImage) // check the results std::cout << "Checking the filter results" << std::endl; - double percentCorrect = CheckResults(filter->GetOutput()); + const double percentCorrect = CheckResults(filter->GetOutput()); if (percentCorrect <= minCorrectRate) { std::cout << "[FAILED] Did not segment over " << minCorrectRate * 100 << "% correctly" << std::endl; @@ -260,9 +261,9 @@ TestWithPrior(ImageType::Pointer inputImage) // set up the prior std::cout << "Setting up the prior image" << std::endl; - auto prior = BinaryObjectImage::New(); - BinaryObjectImage::SizeType size = { { width, height } }; - BinaryObjectImage::RegionType region; + auto prior = BinaryObjectImage::New(); + const BinaryObjectImage::SizeType size = { { width, height } }; + BinaryObjectImage::RegionType region; region.SetSize(size); prior->SetRegions(region); prior->Allocate(); @@ -310,7 +311,7 @@ TestWithPrior(ImageType::Pointer inputImage) // check the results std::cout << "Checking the results of the filter" << std::endl; - double percentCorrect = CheckResults(filter->GetOutput()); + const double percentCorrect = CheckResults(filter->GetOutput()); if (percentCorrect <= minCorrectRate) { std::cout << "[FAILED] Did not segment over " << minCorrectRate * 100 << "% correctly" << std::endl; @@ -331,11 +332,11 @@ int itkVoronoiSegmentationRGBImageFilterTest(int, char *[]) { // set up the input image - ImageType::Pointer inputImage = VoronoiSegRGBTest::SetUpInputImage(); + const ImageType::Pointer inputImage = VoronoiSegRGBTest::SetUpInputImage(); // test without prior std::cout << "[Running test without prior]" << std::endl; - int noPriorTestResult = VoronoiSegRGBTest::TestNoPrior(inputImage); + const int noPriorTestResult = VoronoiSegRGBTest::TestNoPrior(inputImage); if (noPriorTestResult == EXIT_FAILURE) { std::cout << "Failed on test without prior" << std::endl; @@ -345,7 +346,7 @@ itkVoronoiSegmentationRGBImageFilterTest(int, char *[]) // test with prior std::cout << "[Running test with prior]" << std::endl; - int priorTestResult = VoronoiSegRGBTest::TestWithPrior(inputImage); + const int priorTestResult = VoronoiSegRGBTest::TestWithPrior(inputImage); if (priorTestResult == EXIT_FAILURE) { std::cout << "Failed on test with prior" << std::endl; diff --git a/Modules/Segmentation/Watersheds/include/itkIsolatedWatershedImageFilter.hxx b/Modules/Segmentation/Watersheds/include/itkIsolatedWatershedImageFilter.hxx index 2a81ee485bd..1919d75a28f 100644 --- a/Modules/Segmentation/Watersheds/include/itkIsolatedWatershedImageFilter.hxx +++ b/Modules/Segmentation/Watersheds/include/itkIsolatedWatershedImageFilter.hxx @@ -46,7 +46,7 @@ IsolatedWatershedImageFilter::GenerateInputRequestedR Superclass::GenerateInputRequestedRegion(); if (this->GetInput()) { - InputImagePointer image = const_cast(this->GetInput()); + const InputImagePointer image = const_cast(this->GetInput()); image->SetRequestedRegionToLargestPossibleRegion(); } } @@ -85,9 +85,9 @@ template void IsolatedWatershedImageFilter::GenerateData() { - const InputImageType * inputImage = this->GetInput(); - OutputImageType * outputImage = this->GetOutput(); - OutputImageRegionType region = outputImage->GetRequestedRegion(); + const InputImageType * inputImage = this->GetInput(); + OutputImageType * outputImage = this->GetOutput(); + const OutputImageRegionType region = outputImage->GetRequestedRegion(); // Set up the pipeline m_GradientMagnitude->SetInput(inputImage); @@ -117,7 +117,7 @@ IsolatedWatershedImageFilter::GenerateData() // two seeds. while (lower + m_IsolatedValueTolerance < guess) { - ProgressReporter progress(this, 0, region.GetNumberOfPixels(), 100, cumulatedProgress, progressWeight); + const ProgressReporter progress(this, 0, region.GetNumberOfPixels(), 100, cumulatedProgress, progressWeight); cumulatedProgress += progressWeight; m_Watershed->SetLevel(guess); m_Watershed->Update(); @@ -149,9 +149,9 @@ IsolatedWatershedImageFilter::GenerateData() ImageRegionIterator ot(outputImage, region); ImageRegionIterator it(m_Watershed->GetOutput(), region); - IdentifierType seed1Label = m_Watershed->GetOutput()->GetPixel(m_Seed1); - IdentifierType seed2Label = m_Watershed->GetOutput()->GetPixel(m_Seed2); - IdentifierType value; + const IdentifierType seed1Label = m_Watershed->GetOutput()->GetPixel(m_Seed1); + const IdentifierType seed2Label = m_Watershed->GetOutput()->GetPixel(m_Seed2); + IdentifierType value; it.GoToBegin(); ot.GoToBegin(); diff --git a/Modules/Segmentation/Watersheds/include/itkMorphologicalWatershedFromMarkersImageFilter.hxx b/Modules/Segmentation/Watersheds/include/itkMorphologicalWatershedFromMarkersImageFilter.hxx index 0eb0f0405dd..f8fa5cd32f5 100644 --- a/Modules/Segmentation/Watersheds/include/itkMorphologicalWatershedFromMarkersImageFilter.hxx +++ b/Modules/Segmentation/Watersheds/include/itkMorphologicalWatershedFromMarkersImageFilter.hxx @@ -186,13 +186,13 @@ MorphologicalWatershedFromMarkersImageFilter::Generate for (markerIt.GoToBegin(), statusIt.GoToBegin(), outputIt.GoToBegin(), inputIt.GoToBegin(); !markerIt.IsAtEnd(); ++markerIt, ++outputIt) { - LabelImagePixelType markerPixel = markerIt.GetCenterPixel(); + const LabelImagePixelType markerPixel = markerIt.GetCenterPixel(); if (markerPixel != bgLabel) { - IndexType idx = markerIt.GetIndex(); + const IndexType idx = markerIt.GetIndex(); // move the iterators to the right place - OffsetType shift = idx - statusIt.GetIndex(); + const OffsetType shift = idx - statusIt.GetIndex(); statusIt += shift; inputIt += shift; @@ -246,18 +246,18 @@ MorphologicalWatershedFromMarkersImageFilter::Generate while (!fah.empty()) { // store the current vars - InputImagePixelType currentValue = fah.begin()->first; - QueueType currentQueue = fah.begin()->second; + const InputImagePixelType currentValue = fah.begin()->first; + QueueType currentQueue = fah.begin()->second; // and remove them from the fah fah.erase(fah.begin()); while (!currentQueue.empty()) { - IndexType idx = currentQueue.front(); + const IndexType idx = currentQueue.front(); currentQueue.pop(); // move the iterators to the right place - OffsetType shift = idx - outputIt.GetIndex(); + const OffsetType shift = idx - outputIt.GetIndex(); outputIt += shift; statusIt += shift; inputIt += shift; @@ -268,7 +268,7 @@ MorphologicalWatershedFromMarkersImageFilter::Generate bool collision = false; for (noIt = outputIt.Begin(); noIt != outputIt.End(); ++noIt) { - LabelImagePixelType o = noIt.Get(); + const LabelImagePixelType o = noIt.Get(); if (o != wsLabel) { if (marker != wsLabel && o != marker) @@ -292,7 +292,7 @@ MorphologicalWatershedFromMarkersImageFilter::Generate if (!nsIt.Get()) { // the pixel is not yet processed. add it to the fah - InputImagePixelType GrayVal = niIt.Get(); + const InputImagePixelType GrayVal = niIt.Get(); if (GrayVal <= currentValue) { currentQueue.push(inputIt.GetIndex() + niIt.GetNeighborhoodOffset()); @@ -330,11 +330,11 @@ MorphologicalWatershedFromMarkersImageFilter::Generate for (markerIt.GoToBegin(), outputIt.GoToBegin(), inputIt.GoToBegin(); !markerIt.IsAtEnd(); ++markerIt, ++outputIt) { - LabelImagePixelType markerPixel = markerIt.GetCenterPixel(); + const LabelImagePixelType markerPixel = markerIt.GetCenterPixel(); if (markerPixel != bgLabel) { - IndexType idx = markerIt.GetIndex(); - OffsetType shift = idx - inputIt.GetIndex(); + const IndexType idx = markerIt.GetIndex(); + const OffsetType shift = idx - inputIt.GetIndex(); inputIt += shift; // this pixels belongs to a marker @@ -379,22 +379,22 @@ MorphologicalWatershedFromMarkersImageFilter::Generate while (!fah.empty()) { // store the current vars - InputImagePixelType currentValue = fah.begin()->first; - QueueType currentQueue = fah.begin()->second; + const InputImagePixelType currentValue = fah.begin()->first; + QueueType currentQueue = fah.begin()->second; // and remove them from the fah fah.erase(fah.begin()); while (!currentQueue.empty()) { - IndexType idx = currentQueue.front(); + const IndexType idx = currentQueue.front(); currentQueue.pop(); // move the iterators to the right place - OffsetType shift = idx - outputIt.GetIndex(); + const OffsetType shift = idx - outputIt.GetIndex(); outputIt += shift; inputIt += shift; - LabelImagePixelType currentMarker = outputIt.GetCenterPixel(); + const LabelImagePixelType currentMarker = outputIt.GetCenterPixel(); // get the current value of the pixel // iterate over neighbors to propagate the marker for (noIt = outputIt.Begin(), niIt = inputIt.Begin(); noIt != outputIt.End(); noIt++, niIt++) @@ -404,7 +404,7 @@ MorphologicalWatershedFromMarkersImageFilter::Generate // the pixel is not yet processed. It can be labeled with the // current label noIt.Set(currentMarker); - InputImagePixelType GrayVal = niIt.Get(); + const InputImagePixelType GrayVal = niIt.Get(); if (GrayVal <= currentValue) { currentQueue.push(inputIt.GetIndex() + noIt.GetNeighborhoodOffset()); diff --git a/Modules/Segmentation/Watersheds/include/itkTobogganImageFilter.hxx b/Modules/Segmentation/Watersheds/include/itkTobogganImageFilter.hxx index 8a27ee26d71..c6a51c00e43 100644 --- a/Modules/Segmentation/Watersheds/include/itkTobogganImageFilter.hxx +++ b/Modules/Segmentation/Watersheds/include/itkTobogganImageFilter.hxx @@ -30,7 +30,7 @@ TobogganImageFilter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); if (this->GetInput()) { - InputImagePointer image = const_cast(this->GetInput()); + const InputImagePointer image = const_cast(this->GetInput()); image->SetRequestedRegionToLargestPossibleRegion(); } } @@ -54,11 +54,11 @@ template void TobogganImageFilter::GenerateData() { - auto inputImage = static_cast(this->GetInput()); - OutputImagePointer outputImage = this->GetOutput(); + auto inputImage = static_cast(this->GetInput()); + const OutputImagePointer outputImage = this->GetOutput(); - OutputImagePixelType z{}; - OutputImagePixelType CurrentLabel{}; + const OutputImagePixelType z{}; + OutputImagePixelType CurrentLabel{}; CurrentLabel += 2; @@ -116,11 +116,11 @@ TobogganImageFilter::GenerateData() // ignore // If NeighborClass > 1 -> Found a new neighbor, but only if // it's minimum - OutputImagePixelType NeighborClass = outputImage->GetPixel(NeighborIndex); + const OutputImagePixelType NeighborClass = outputImage->GetPixel(NeighborIndex); // See if we've already touched it if (NeighborClass != 1) { - InputImagePixelType NeighborValue = inputImage->GetPixel(NeighborIndex); + const InputImagePixelType NeighborValue = inputImage->GetPixel(NeighborIndex); if (NeighborValue < MinimumNeighborValue) { MinimumNeighborValue = inputImage->GetPixel(NeighborIndex); @@ -171,12 +171,12 @@ TobogganImageFilter::GenerateData() while (!OpenList.empty()) { // Pop the last one off - IndexType SeedIndex = OpenList.back(); + const IndexType SeedIndex = OpenList.back(); OpenList.pop_back(); Visited.push_back(SeedIndex); itkDebugMacro("Flood fill, looking at " << SeedIndex); // Look at the neighbors - InputImagePixelType SeedValue = inputImage->GetPixel(SeedIndex); + const InputImagePixelType SeedValue = inputImage->GetPixel(SeedIndex); for (unsigned int Dimension = 0; Dimension < ImageDimension; ++Dimension) { for (int t = -1; t <= 1; t = t + 2) @@ -188,7 +188,7 @@ TobogganImageFilter::GenerateData() if (inputImage->GetPixel(NeighborIndex) <= SeedValue) { // Found a match, check its class - OutputImagePixelType NeighborClass = outputImage->GetPixel(NeighborIndex); + const OutputImagePixelType NeighborClass = outputImage->GetPixel(NeighborIndex); // We've never seen this pixel before, so add it to the open // list if (NeighborClass == z) diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedBoundary.hxx b/Modules/Segmentation/Watersheds/include/itkWatershedBoundary.hxx index d8d0e882790..365214cdbcb 100644 --- a/Modules/Segmentation/Watersheds/include/itkWatershedBoundary.hxx +++ b/Modules/Segmentation/Watersheds/include/itkWatershedBoundary.hxx @@ -28,9 +28,9 @@ namespace watershed template Boundary::Boundary() { - unsigned int i; - FacePointer p; - flat_hash_t f; + unsigned int i; + FacePointer p; + const flat_hash_t f; std::pair i_pair; std::pair c_pair; diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedBoundaryResolver.h b/Modules/Segmentation/Watersheds/include/itkWatershedBoundaryResolver.h index ef02bfb352d..c2368b3b44e 100644 --- a/Modules/Segmentation/Watersheds/include/itkWatershedBoundaryResolver.h +++ b/Modules/Segmentation/Watersheds/include/itkWatershedBoundaryResolver.h @@ -141,7 +141,7 @@ class ITK_TEMPLATE_EXPORT BoundaryResolver : public ProcessObject protected: BoundaryResolver() { - EquivalencyTable::Pointer eq = static_cast(this->MakeOutput(0).GetPointer()); + const EquivalencyTable::Pointer eq = static_cast(this->MakeOutput(0).GetPointer()); this->SetNumberOfRequiredOutputs(1); this->ProcessObject::SetNthOutput(0, eq.GetPointer()); diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedBoundaryResolver.hxx b/Modules/Segmentation/Watersheds/include/itkWatershedBoundaryResolver.hxx index 5905ff510d6..20451c7b906 100644 --- a/Modules/Segmentation/Watersheds/include/itkWatershedBoundaryResolver.hxx +++ b/Modules/Segmentation/Watersheds/include/itkWatershedBoundaryResolver.hxx @@ -38,10 +38,10 @@ BoundaryResolver::GenerateData() typename BoundaryType::IndexType idxA; typename BoundaryType::IndexType idxB; - EquivalencyTableType::Pointer equivTable = this->GetEquivalencyTable(); + const EquivalencyTableType::Pointer equivTable = this->GetEquivalencyTable(); - typename BoundaryType::Pointer boundaryA = this->GetBoundaryA(); - typename BoundaryType::Pointer boundaryB = this->GetBoundaryB(); + const typename BoundaryType::Pointer boundaryA = this->GetBoundaryA(); + const typename BoundaryType::Pointer boundaryB = this->GetBoundaryB(); idxA.first = this->GetFace(); idxB.first = this->GetFace(); diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedEquivalenceRelabeler.h b/Modules/Segmentation/Watersheds/include/itkWatershedEquivalenceRelabeler.h index 2ae28966dc5..7791797322d 100644 --- a/Modules/Segmentation/Watersheds/include/itkWatershedEquivalenceRelabeler.h +++ b/Modules/Segmentation/Watersheds/include/itkWatershedEquivalenceRelabeler.h @@ -125,7 +125,7 @@ class ITK_TEMPLATE_EXPORT EquivalenceRelabeler : public ProcessObject protected: EquivalenceRelabeler() { - typename ImageType::Pointer img = static_cast(this->MakeOutput(0).GetPointer()); + const typename ImageType::Pointer img = static_cast(this->MakeOutput(0).GetPointer()); this->SetNumberOfRequiredOutputs(1); this->ProcessObject::SetNthOutput(0, img.GetPointer()); } diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedEquivalenceRelabeler.hxx b/Modules/Segmentation/Watersheds/include/itkWatershedEquivalenceRelabeler.hxx index d0897854cc9..d777ad7d8f2 100644 --- a/Modules/Segmentation/Watersheds/include/itkWatershedEquivalenceRelabeler.hxx +++ b/Modules/Segmentation/Watersheds/include/itkWatershedEquivalenceRelabeler.hxx @@ -26,10 +26,10 @@ template void EquivalenceRelabeler::GenerateData() { - typename ImageType::ConstPointer input = this->GetInputImage(); - typename ImageType::Pointer output = this->GetOutputImage(); + const typename ImageType::ConstPointer input = this->GetInputImage(); + const typename ImageType::Pointer output = this->GetOutputImage(); - typename EquivalencyTableType::Pointer eqT = this->GetEquivalencyTable(); + const typename EquivalencyTableType::Pointer eqT = this->GetEquivalencyTable(); output->SetBufferedRegion(output->GetRequestedRegion()); output->Allocate(); diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedImageFilter.hxx b/Modules/Segmentation/Watersheds/include/itkWatershedImageFilter.hxx index 6d655526438..35233415b99 100644 --- a/Modules/Segmentation/Watersheds/include/itkWatershedImageFilter.hxx +++ b/Modules/Segmentation/Watersheds/include/itkWatershedImageFilter.hxx @@ -173,7 +173,7 @@ WatershedImageFilter::GenerateData() m_Segmenter->GetOutputImage()->SetRequestedRegion(this->GetInput()->GetLargestPossibleRegion()); // Setup the progress command - WatershedMiniPipelineProgressCommand::Pointer c = + const WatershedMiniPipelineProgressCommand::Pointer c = dynamic_cast(m_TreeGenerator->GetCommand(m_ObserverTag)); c->SetCount(0.0); c->SetNumberOfFilters(3); diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedRelabeler.hxx b/Modules/Segmentation/Watersheds/include/itkWatershedRelabeler.hxx index 3219c601278..759eafe6214 100644 --- a/Modules/Segmentation/Watersheds/include/itkWatershedRelabeler.hxx +++ b/Modules/Segmentation/Watersheds/include/itkWatershedRelabeler.hxx @@ -27,7 +27,7 @@ namespace watershed template Relabeler::Relabeler() { - typename ImageType::Pointer img = static_cast(this->MakeOutput(0).GetPointer()); + const typename ImageType::Pointer img = static_cast(this->MakeOutput(0).GetPointer()); this->SetNumberOfRequiredOutputs(1); this->ProcessObject::SetNthOutput(0, img.GetPointer()); } @@ -44,12 +44,12 @@ void Relabeler::GenerateData() { this->UpdateProgress(0.0); - typename ImageType::Pointer input = this->GetInputImage(); - typename ImageType::Pointer output = this->GetOutputImage(); + const typename ImageType::Pointer input = this->GetInputImage(); + const typename ImageType::Pointer output = this->GetOutputImage(); - typename SegmentTreeType::Pointer tree = this->GetInputSegmentTree(); - typename SegmentTreeType::Iterator it; - auto eqT = EquivalencyTable::New(); + const typename SegmentTreeType::Pointer tree = this->GetInputSegmentTree(); + typename SegmentTreeType::Iterator it; + auto eqT = EquivalencyTable::New(); output->SetBufferedRegion(output->GetRequestedRegion()); output->Allocate(); @@ -76,8 +76,8 @@ Relabeler::GenerateData() // itkWarningMacro("Empty input. No relabeling was done."); return; } - ScalarType max = tree->Back().saliency; - auto mergeLimit = static_cast(m_FloodLevel * max); + const ScalarType max = tree->Back().saliency; + auto mergeLimit = static_cast(m_FloodLevel * max); this->UpdateProgress(0.5); @@ -100,8 +100,8 @@ Relabeler::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - typename ImageType::Pointer inputPtr = this->GetInputImage(); - typename ImageType::Pointer outputPtr = this->GetOutputImage(); + const typename ImageType::Pointer inputPtr = this->GetInputImage(); + const typename ImageType::Pointer outputPtr = this->GetOutputImage(); if (!inputPtr || !outputPtr) { @@ -158,7 +158,7 @@ Relabeler::GraftNthOutput(unsigned int idx, ImageType if (idx < this->GetNumberOfIndexedOutputs()) { - OutputImagePointer output = this->GetOutputImage(); + const OutputImagePointer output = this->GetOutputImage(); if (output && graft) { diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTable.hxx b/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTable.hxx index f4e1e7e6544..7b36d167b98 100644 --- a/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTable.hxx +++ b/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTable.hxx @@ -60,7 +60,7 @@ template bool SegmentTable::Add(IdentifierType a, const segment_t & t) { - std::pair result = m_HashMap.insert(ValueType(a, t)); + const std::pair result = m_HashMap.insert(ValueType(a, t)); if (result.second == false) { return false; diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTreeGenerator.hxx b/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTreeGenerator.hxx index e6e8e11f00b..53b51e8ba2c 100644 --- a/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTreeGenerator.hxx +++ b/Modules/Segmentation/Watersheds/include/itkWatershedSegmentTreeGenerator.hxx @@ -28,7 +28,7 @@ namespace watershed template SegmentTreeGenerator::SegmentTreeGenerator() { - typename SegmentTreeType::Pointer st = static_cast(this->MakeOutput(0).GetPointer()); + const typename SegmentTreeType::Pointer st = static_cast(this->MakeOutput(0).GetPointer()); this->SetNumberOfRequiredOutputs(1); this->ProcessObject::SetNthOutput(0, st.GetPointer()); m_MergedSegmentsTable = OneWayEquivalencyTableType::New(); @@ -76,9 +76,9 @@ SegmentTreeGenerator::GenerateData() m_MergedSegmentsTable->Clear(); this->GetOutputSegmentTree()->Clear(); - typename SegmentTableType::Pointer input = this->GetInputSegmentTable(); - auto mergeList = SegmentTreeType::New(); - auto seg = SegmentTableType::New(); + const typename SegmentTableType::Pointer input = this->GetInputSegmentTable(); + auto mergeList = SegmentTreeType::New(); + auto seg = SegmentTableType::New(); if (m_ConsumeInput) // do not copy input { input->Modified(); @@ -116,9 +116,9 @@ template void SegmentTreeGenerator::MergeEquivalencies() { - typename SegmentTableType::Pointer segTable = this->GetInputSegmentTable(); - auto threshold = static_cast(m_FloodLevel * segTable->GetMaximumDepth()); - typename EquivalencyTableType::Pointer eqTable = this->GetInputEquivalencyTable(); + const typename SegmentTableType::Pointer segTable = this->GetInputSegmentTable(); + auto threshold = static_cast(m_FloodLevel * segTable->GetMaximumDepth()); + const typename EquivalencyTableType::Pointer eqTable = this->GetInputEquivalencyTable(); eqTable->Flatten(); IdentifierType counter = 0; @@ -155,7 +155,7 @@ SegmentTreeGenerator::CompileMergeList(SegmentTableTypePointer segments for (typename SegmentTableType::Iterator segment_ptr = segments->Begin(); segment_ptr != segments->End(); ++segment_ptr) { - IdentifierType labelFROM = segment_ptr->first; + const IdentifierType labelFROM = segment_ptr->first; // Must take into account any equivalencies that have already been // recorded. @@ -192,7 +192,7 @@ template void SegmentTreeGenerator::ExtractMergeHierarchy(SegmentTableTypePointer segments, SegmentTreeTypePointer heap) { - typename SegmentTreeType::Pointer list = this->GetOutputSegmentTree(); + const typename SegmentTreeType::Pointer list = this->GetOutputSegmentTree(); // Merges segments up to a specified flood level according to the information // in the heap of merges. As two segments are merged, calculates a new @@ -231,12 +231,12 @@ SegmentTreeGenerator::ExtractMergeHierarchy(SegmentTableTypePointer seg std::pop_heap(heap->Begin(), heap->End(), MergeComparison()); heap->PopBack(); // Popping the heap moves the top element to the end - // of the container structure, so we delete that here. + // of the container structure, so we delete that here. // Recursively find the segments we are about to merge // (the labels identified here may have merged already) - IdentifierType fromSegLabel = m_MergedSegmentsTable->RecursiveLookup(topMerge.from); - IdentifierType toSegLabel = m_MergedSegmentsTable->RecursiveLookup(topMerge.to); + const IdentifierType fromSegLabel = m_MergedSegmentsTable->RecursiveLookup(topMerge.from); + const IdentifierType toSegLabel = m_MergedSegmentsTable->RecursiveLookup(topMerge.to); // If the two segments do not resolve to the same segment and the // "TO" segment has never been merged, then then merge them. @@ -459,8 +459,8 @@ SegmentTreeGenerator::MergeSegments(SegmentTableTypePointer s while (edgeTOi != to_seg->edge_list.end() && edgeFROMi != from_seg->edge_list.end()) { // Recursively resolve the labels we are seeing - IdentifierType labelTO = eqT->RecursiveLookup(edgeTOi->label); - IdentifierType labelFROM = eqT->RecursiveLookup(edgeFROMi->label); + const IdentifierType labelTO = eqT->RecursiveLookup(edgeTOi->label); + const IdentifierType labelFROM = eqT->RecursiveLookup(edgeFROMi->label); // Ignore any labels already in this list and // any pointers back to ourself. @@ -507,7 +507,7 @@ SegmentTreeGenerator::MergeSegments(SegmentTableTypePointer s // Process tail of the FROM list. while (edgeFROMi != from_seg->edge_list.end()) { - IdentifierType labelFROM = eqT->RecursiveLookup(edgeFROMi->label); + const IdentifierType labelFROM = eqT->RecursiveLookup(edgeFROMi->label); if (seen_table.find(labelFROM) != seen_table.end() || labelFROM == TO) { ++edgeFROMi; @@ -527,7 +527,7 @@ SegmentTreeGenerator::MergeSegments(SegmentTableTypePointer s // Process tail of the TO list. while (edgeTOi != to_seg->edge_list.end()) { - IdentifierType labelTO = eqT->RecursiveLookup(edgeTOi->label); + const IdentifierType labelTO = eqT->RecursiveLookup(edgeTOi->label); if (seen_table.find(labelTO) != seen_table.end() || labelTO == FROM) { typename SegmentTableType::edge_list_t::iterator edgeTEMPi = edgeTOi; diff --git a/Modules/Segmentation/Watersheds/include/itkWatershedSegmenter.hxx b/Modules/Segmentation/Watersheds/include/itkWatershedSegmenter.hxx index 4de575cf70b..3b83e55c88b 100644 --- a/Modules/Segmentation/Watersheds/include/itkWatershedSegmenter.hxx +++ b/Modules/Segmentation/Watersheds/include/itkWatershedSegmenter.hxx @@ -58,9 +58,9 @@ Segmenter::GenerateData() this->SetCurrentLabel(1); } - typename InputImageType::Pointer input = this->GetInputImage(); - typename OutputImageType::Pointer output = this->GetOutputImage(); - typename BoundaryType::Pointer boundary = this->GetBoundary(); + const typename InputImageType::Pointer input = this->GetInputImage(); + const typename OutputImageType::Pointer output = this->GetOutputImage(); + const typename BoundaryType::Pointer boundary = this->GetBoundary(); // ------------------------------------------------------------------------ // @@ -84,10 +84,10 @@ Segmenter::GenerateData() // out a pixel when we threshold so that we can construct the retaining wall // along those faces. // - ImageRegionType regionToProcess = output->GetRequestedRegion(); - ImageRegionType largestPossibleRegion = this->GetLargestPossibleRegion(); - ImageRegionType thresholdImageRegion = regionToProcess; - ImageRegionType thresholdLargestPossibleRegion = this->GetLargestPossibleRegion(); + ImageRegionType regionToProcess = output->GetRequestedRegion(); + const ImageRegionType largestPossibleRegion = this->GetLargestPossibleRegion(); + ImageRegionType thresholdImageRegion = regionToProcess; + ImageRegionType thresholdLargestPossibleRegion = this->GetLargestPossibleRegion(); // First we have to find the boundaries and adjust the threshold image size typename ImageRegionType::IndexType tidx = thresholdImageRegion.GetIndex(); @@ -326,8 +326,8 @@ template void Segmenter::CollectBoundaryInformation(flat_region_table_t & flatRegions) { - typename OutputImageType::Pointer output = this->GetOutputImage(); - typename BoundaryType::Pointer boundary = this->GetBoundary(); + const typename OutputImageType::Pointer output = this->GetOutputImage(); + const typename BoundaryType::Pointer boundary = this->GetBoundary(); typename BoundaryType::IndexType idx; for (idx.first = 0; idx.first < ImageDimension; (idx.first)++) @@ -339,9 +339,9 @@ Segmenter::CollectBoundaryInformation(flat_region_table_t & flatReg continue; } - typename BoundaryType::face_t::Pointer face = boundary->GetFace(idx); - typename BoundaryType::flat_hash_t * flats = boundary->GetFlatHash(idx); - ImageRegionType region = face->GetRequestedRegion(); + const typename BoundaryType::face_t::Pointer face = boundary->GetFace(idx); + typename BoundaryType::flat_hash_t * flats = boundary->GetFlatHash(idx); + const ImageRegionType region = face->GetRequestedRegion(); // Grab all the labels of the boundary pixels. ImageRegionIterator faceIt = @@ -354,12 +354,12 @@ Segmenter::CollectBoundaryInformation(flat_region_table_t & flatReg faceIt.Value().label = labelIt.Get(); // Is this a flat region that flows out? - typename flat_region_table_t::iterator flrt_it = flatRegions.find(labelIt.Get()); + const typename flat_region_table_t::iterator flrt_it = flatRegions.find(labelIt.Get()); if (faceIt.Get().flow != NULL_FLOW && flrt_it != flatRegions.end()) { // Have we already entered this // flat region into the boundary? - typename BoundaryType::flat_hash_t::iterator flats_it = flats->find(labelIt.Get()); + const typename BoundaryType::flat_hash_t::iterator flats_it = flats->find(labelIt.Get()); if (flats_it == flats->end()) // NO { typename BoundaryType::flat_region_t flr; @@ -401,7 +401,7 @@ Segmenter::InitializeBoundary() continue; } this->GetBoundary()->GetFlatHash(idx)->clear(); - typename BoundaryType::face_t::Pointer face = this->GetBoundary()->GetFace(idx); + const typename BoundaryType::face_t::Pointer face = this->GetBoundary()->GetFace(idx); if (face != nullptr) { face->FillBuffer(fps); @@ -424,8 +424,8 @@ Segmenter::AnalyzeBoundaryFlow(InputImageTypePointer thresholdImage typename BoundaryType::face_pixel_t fps; - typename OutputImageType::Pointer output = this->GetOutputImage(); - typename BoundaryType::Pointer boundary = this->GetBoundary(); + const typename OutputImageType::Pointer output = this->GetOutputImage(); + const typename BoundaryType::Pointer boundary = this->GetBoundary(); typename ConstNeighborhoodIterator::RadiusType rad; for (unsigned int i = 0; i < ImageDimension; ++i) @@ -448,8 +448,8 @@ Segmenter::AnalyzeBoundaryFlow(InputImageTypePointer thresholdImage continue; } - typename BoundaryType::face_t::Pointer face = boundary->GetFace(idx); - ImageRegionType region = face->GetRequestedRegion(); + const typename BoundaryType::face_t::Pointer face = boundary->GetFace(idx); + const ImageRegionType region = face->GetRequestedRegion(); ConstNeighborhoodIterator searchIt = ConstNeighborhoodIterator(rad, thresholdImage, region); @@ -457,7 +457,7 @@ Segmenter::AnalyzeBoundaryFlow(InputImageTypePointer thresholdImage ImageRegionIterator faceIt = ImageRegionIterator(face, region); - unsigned int nCenter = searchIt.Size() / 2; + const unsigned int nCenter = searchIt.Size() / 2; searchIt.GoToBegin(); labelIt.GoToBegin(); @@ -489,7 +489,7 @@ Segmenter::AnalyzeBoundaryFlow(InputImageTypePointer thresholdImage bool _connected = false; for (unsigned int i = 0; i < m_Connectivity.size; ++i) { - unsigned int nPos = m_Connectivity.index[i]; + const unsigned int nPos = m_Connectivity.index[i]; if (Math::AlmostEquals(searchIt.GetPixel(nCenter), searchIt.GetPixel(nPos)) && labelIt.GetPixel(nPos) != Self::NULL_LABEL && labelIt.GetPixel(nPos) != labelIt.GetPixel(nCenter)) { @@ -527,7 +527,7 @@ Segmenter::AnalyzeBoundaryFlow(InputImageTypePointer thresholdImage isSteepest = true; for (unsigned int i = 0; i < m_Connectivity.size; ++i) { - unsigned int nPos = m_Connectivity.index[i]; + const unsigned int nPos = m_Connectivity.index[i]; if (searchIt.GetPixel(nPos) < searchIt.GetPixel(cPos)) { isSteepest = false; @@ -557,7 +557,7 @@ Segmenter::AnalyzeBoundaryFlow(InputImageTypePointer thresholdImage // or we could have problems later on. for (unsigned int i = 0; i < m_Connectivity.size; ++i) { - unsigned int nPos = m_Connectivity.index[i]; + const unsigned int nPos = m_Connectivity.index[i]; if (Math::AlmostEquals(searchIt.GetPixel(nPos), searchIt.GetPixel(nCenter))) { flat_region_t tempFlatRegion; @@ -593,8 +593,8 @@ Segmenter::AnalyzeBoundaryFlow(InputImageTypePointer thresholdImage continue; } - typename BoundaryType::face_t::Pointer face = boundary->GetFace(idx); - ImageRegionType region = face->GetRequestedRegion(); + const typename BoundaryType::face_t::Pointer face = boundary->GetFace(idx); + const ImageRegionType region = face->GetRequestedRegion(); Self::RelabelImage(output, region, eqTable); } @@ -624,9 +624,10 @@ Segmenter::GenerateConnectivity() { rad[i] = 1; } - ConstNeighborhoodIterator it(rad, this->GetInputImage(), this->GetInputImage()->GetRequestedRegion()); - unsigned int nSize = it.Size(); - unsigned int nCenter = nSize >> 1; + const ConstNeighborhoodIterator it( + rad, this->GetInputImage(), this->GetInputImage()->GetRequestedRegion()); + const unsigned int nSize = it.Size(); + const unsigned int nCenter = nSize >> 1; unsigned int i = 0; for (; i < m_Connectivity.size; ++i) // initialize move list @@ -639,14 +640,14 @@ Segmenter::GenerateConnectivity() i = 0; for (int d = ImageDimension - 1; d >= 0; d--) { - unsigned int stride = it.GetStride(d); + const unsigned int stride = it.GetStride(d); m_Connectivity.index[i] = nCenter - stride; m_Connectivity.direction[i][d] = -1; ++i; } for (int d = 0; d < static_cast(ImageDimension); ++d) { - unsigned int stride = it.GetStride(d); + const unsigned int stride = it.GetStride(d); m_Connectivity.index[i] = nCenter + stride; m_Connectivity.direction[i][d] = 1; ++i; @@ -660,12 +661,12 @@ Segmenter::LabelMinima(InputImageTypePointer img, typename Self::flat_region_table_t & flatRegions, InputPixelType Max) { - unsigned int nPos = 0; - InputPixelType maxValue = Max; + unsigned int nPos = 0; + const InputPixelType maxValue = Max; auto equivalentLabels = EquivalencyTable::New(); - typename OutputImageType::Pointer output = this->GetOutputImage(); + const typename OutputImageType::Pointer output = this->GetOutputImage(); // Set up the iterators. typename ConstNeighborhoodIterator::RadiusType rad; @@ -675,8 +676,8 @@ Segmenter::LabelMinima(InputImageTypePointer img, } ConstNeighborhoodIterator searchIt(rad, img, region); NeighborhoodIterator labelIt(rad, output, region); - unsigned int nSize = searchIt.Size(); - unsigned int nCenter = nSize >> 1; + const unsigned int nSize = searchIt.Size(); + const unsigned int nCenter = nSize >> 1; // Sweep through the images. Label all local minima // and record information for all the flat regions. @@ -693,8 +694,8 @@ Segmenter::LabelMinima(InputImageTypePointer img, } // Compare current pixel value with its neighbors. - InputPixelType currentValue = searchIt.GetPixel(nCenter); - unsigned int i = 0; + const InputPixelType currentValue = searchIt.GetPixel(nCenter); + unsigned int i = 0; for (; i < m_Connectivity.size; ++i) { nPos = m_Connectivity.index[i]; @@ -760,7 +761,7 @@ Segmenter::LabelMinima(InputImageTypePointer img, // boundary values for the flat regions. for (searchIt.GoToBegin(), labelIt.GoToBegin(); !searchIt.IsAtEnd(); ++searchIt, ++labelIt) { - typename flat_region_table_t::iterator flatPtr = flatRegions.find(labelIt.GetPixel(nCenter)); + const typename flat_region_table_t::iterator flatPtr = flatRegions.find(labelIt.GetPixel(nCenter)); if (flatPtr != flatRegions.end()) // If we are in a flat region { // Search the connectivity neighborhood // for lesser boundary pixels. @@ -806,7 +807,7 @@ template void Segmenter::GradientDescent(InputImageTypePointer img, ImageRegionType region) { - typename OutputImageType::Pointer output = this->GetOutputImage(); + const typename OutputImageType::Pointer output = this->GetOutputImage(); // // Set up our iterators. @@ -840,7 +841,7 @@ Segmenter::GradientDescent(InputImageTypePointer img, ImageRegionTy typename InputImageType::OffsetType moveIndex = m_Connectivity.direction[0]; for (unsigned int ii = 1; ii < m_Connectivity.size; ++ii) { - unsigned int nPos = m_Connectivity.index[ii]; + const unsigned int nPos = m_Connectivity.index[ii]; if (valueIt.GetPixel(nPos) < minVal) { minVal = valueIt.GetPixel(nPos); @@ -865,7 +866,7 @@ template void Segmenter::DescendFlatRegions(flat_region_table_t & flatRegionTable, ImageRegionType imageRegion) { - typename OutputImageType::Pointer output = this->GetOutputImage(); + const typename OutputImageType::Pointer output = this->GetOutputImage(); // Assumes all pixels are labeled in the image. Steps through the flat // regions and equates each one with the label at its lowest boundary // point. Flat basins are preserved as their own regions. The output image is @@ -890,8 +891,8 @@ void Segmenter::UpdateSegmentTable(InputImageTypePointer input, ImageRegionType region) { // Grab the data we need. - typename OutputImageType::Pointer output = this->GetOutputImage(); - typename SegmentTableType::Pointer segments = this->GetSegmentTable(); + const typename OutputImageType::Pointer output = this->GetOutputImage(); + const typename SegmentTableType::Pointer segments = this->GetSegmentTable(); // Set up some iterators. typename NeighborhoodIterator::RadiusType hoodRadius; @@ -902,19 +903,19 @@ Segmenter::UpdateSegmentTable(InputImageTypePointer input, ImageReg ConstNeighborhoodIterator searchIt(hoodRadius, input, region); NeighborhoodIterator labelIt(hoodRadius, output, region); - IdentifierType hoodCenter = searchIt.Size() >> 1; + const IdentifierType hoodCenter = searchIt.Size() >> 1; edge_table_hash_t edgeHash; for (searchIt.GoToBegin(), labelIt.GoToBegin(); !searchIt.IsAtEnd(); ++searchIt, ++labelIt) { - IdentifierType segment_label = labelIt.GetPixel(hoodCenter); + const IdentifierType segment_label = labelIt.GetPixel(hoodCenter); // Find the segment corresponding to this label // and update its minimum value if necessary. typename SegmentTableType::segment_t * segment_ptr = segments->Lookup(segment_label); typename edge_table_hash_t::iterator edge_table_entry_ptr = edgeHash.find(segment_label); - edge_table_t tempEdgeTable; + const edge_table_t tempEdgeTable; if (segment_ptr == nullptr) // This segment not yet identified. { // So add it to the table. typename SegmentTableType::segment_t temp_segment; @@ -938,8 +939,8 @@ Segmenter::UpdateSegmentTable(InputImageTypePointer input, ImageReg // values. for (unsigned int i = 0; i < m_Connectivity.size; ++i) { - unsigned int nPos = m_Connectivity.index[i]; - InputPixelType lowest_edge; + const unsigned int nPos = m_Connectivity.index[i]; + InputPixelType lowest_edge; if (labelIt.GetPixel(nPos) != segment_label && labelIt.GetPixel(nPos) != NULL_LABEL) { if (searchIt.GetPixel(nPos) < searchIt.GetPixel(hoodCenter)) @@ -952,7 +953,7 @@ Segmenter::UpdateSegmentTable(InputImageTypePointer input, ImageReg } // adjacent pixels - typename edge_table_t::iterator edge_ptr = edge_table_entry_ptr->second.find(labelIt.GetPixel(nPos)); + const typename edge_table_t::iterator edge_ptr = edge_table_entry_ptr->second.find(labelIt.GetPixel(nPos)); if (edge_ptr == edge_table_entry_ptr->second.end()) { // This edge has not been identified yet. using ValueType = typename edge_table_t::value_type; @@ -982,7 +983,7 @@ Segmenter::UpdateSegmentTable(InputImageTypePointer input, ImageReg } // Copy into the segment list - IdentifierType listsz = static_cast(edge_table_entry_ptr->second.size()); + const IdentifierType listsz = static_cast(edge_table_entry_ptr->second.size()); segment_ptr->edge_list.resize(listsz); typename edge_table_t::iterator edge_ptr = edge_table_entry_ptr->second.begin(); typename SegmentTableType::edge_list_t::iterator list_ptr = segment_ptr->edge_list.begin(); @@ -1088,8 +1089,8 @@ Segmenter::MergeFlatRegions(flat_region_table_t & regions, Equivale for (EquivalencyTable::ConstIterator it = eqTable->Begin(); it != eqTable->End(); ++it) { - typename flat_region_table_t::iterator a = regions.find(it->first); - typename flat_region_table_t::iterator b = regions.find(it->second); + const typename flat_region_table_t::iterator a = regions.find(it->first); + const typename flat_region_table_t::iterator b = regions.find(it->second); if ((a == regions.end()) || (b == regions.end())) { itkGenericExceptionMacro("MergeFlatRegions:: An unexpected and fatal error has occurred."); @@ -1117,7 +1118,7 @@ Segmenter::RelabelImage(OutputImageTypePointer img, it.GoToBegin(); while (!it.IsAtEnd()) { - IdentifierType temp = eqTable->Lookup(it.Get()); + const IdentifierType temp = eqTable->Lookup(it.Get()); if (temp != it.Get()) { it.Set(temp); @@ -1151,7 +1152,7 @@ Segmenter::Threshold(InputImageTypePointer destination, // requiring an expensive boundary condition checks. while (!dIt.IsAtEnd()) { - InputPixelType tmp = sIt.Get(); + const InputPixelType tmp = sIt.Get(); ITK_GCC_PRAGMA_PUSH ITK_GCC_SUPPRESS_Wfloat_equal if (tmp < threshold) @@ -1227,8 +1228,8 @@ Segmenter::UpdateOutputInformation() Superclass::UpdateOutputInformation(); // get pointers to the input and output - typename InputImageType::Pointer inputPtr = this->GetInputImage(); - typename OutputImageType::Pointer outputPtr = this->GetOutputImage(); + const typename InputImageType::Pointer inputPtr = this->GetInputImage(); + const typename OutputImageType::Pointer outputPtr = this->GetOutputImage(); if (!inputPtr || !outputPtr) { @@ -1261,8 +1262,8 @@ Segmenter::GenerateInputRequestedRegion() Superclass::GenerateInputRequestedRegion(); // get pointers to the input and output - typename InputImageType::Pointer inputPtr = this->GetInputImage(); - typename OutputImageType::Pointer outputPtr = this->GetOutputImage(); + const typename InputImageType::Pointer inputPtr = this->GetInputImage(); + const typename OutputImageType::Pointer outputPtr = this->GetOutputImage(); if (!inputPtr || !outputPtr) { diff --git a/Modules/Segmentation/Watersheds/test/itkIsolatedWatershedImageFilterTest.cxx b/Modules/Segmentation/Watersheds/test/itkIsolatedWatershedImageFilterTest.cxx index b2d7e8420f3..62b092e4a5f 100644 --- a/Modules/Segmentation/Watersheds/test/itkIsolatedWatershedImageFilterTest.cxx +++ b/Modules/Segmentation/Watersheds/test/itkIsolatedWatershedImageFilterTest.cxx @@ -47,7 +47,7 @@ itkIsolatedWatershedImageFilterTest(int argc, char * argv[]) using PixelType = unsigned char; using ImageType = itk::Image; - itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); reader->SetFileName(argv[1]); @@ -67,10 +67,10 @@ itkIsolatedWatershedImageFilterTest(int argc, char * argv[]) FilterType::IndexType seed2{}; // Test the seeds being outside the input image exception - ImageType::Pointer inputImage = reader->GetOutput(); + const ImageType::Pointer inputImage = reader->GetOutput(); - ImageType::RegionType region = inputImage->GetLargestPossibleRegion(); - auto offset = ImageType::IndexType::Filled(10); + const ImageType::RegionType region = inputImage->GetLargestPossibleRegion(); + auto offset = ImageType::IndexType::Filled(10); seed1[0] = region.GetUpperIndex()[0] + offset[0]; filter->SetSeed1(seed1); @@ -96,30 +96,30 @@ itkIsolatedWatershedImageFilterTest(int argc, char * argv[]) filter->SetSeed2(seed2); ITK_TEST_SET_GET_VALUE(seed2, filter->GetSeed2()); - double threshold = std::stod(argv[7]); + const double threshold = std::stod(argv[7]); filter->SetThreshold(threshold); ITK_TEST_SET_GET_VALUE(threshold, filter->GetThreshold()); - PixelType replaceValue1 = 255; + const PixelType replaceValue1 = 255; filter->SetReplaceValue1(replaceValue1); ITK_TEST_SET_GET_VALUE(replaceValue1, filter->GetReplaceValue1()); - PixelType replaceValue2 = 127; + const PixelType replaceValue2 = 127; filter->SetReplaceValue2(replaceValue2); ITK_TEST_SET_GET_VALUE(replaceValue2, filter->GetReplaceValue2()); - double upperValueLimit = 1.0; + const double upperValueLimit = 1.0; filter->SetUpperValueLimit(upperValueLimit); ITK_TEST_SET_GET_VALUE(upperValueLimit, filter->GetUpperValueLimit()); - double isolatedValueTolerance = std::stod(argv[8]); + const double isolatedValueTolerance = std::stod(argv[8]); filter->SetIsolatedValueTolerance(isolatedValueTolerance); ITK_TEST_SET_GET_VALUE(isolatedValueTolerance, filter->GetIsolatedValueTolerance()); ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); - double isolatedValue = filter->GetIsolatedValue(); + const double isolatedValue = filter->GetIsolatedValue(); std::cout << "IsolatedValue: " << isolatedValue << std::endl; // Write the filter output diff --git a/Modules/Segmentation/Watersheds/test/itkMorphologicalWatershedFromMarkersImageFilterTest.cxx b/Modules/Segmentation/Watersheds/test/itkMorphologicalWatershedFromMarkersImageFilterTest.cxx index f78de0efcb5..2c460a6d043 100644 --- a/Modules/Segmentation/Watersheds/test/itkMorphologicalWatershedFromMarkersImageFilterTest.cxx +++ b/Modules/Segmentation/Watersheds/test/itkMorphologicalWatershedFromMarkersImageFilterTest.cxx @@ -59,10 +59,10 @@ itkMorphologicalWatershedFromMarkersImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, MorphologicalWatershedFromMarkersImageFilter, ImageToImageFilter); - bool markWatershedLine = std::stoi(argv[4]); + const bool markWatershedLine = std::stoi(argv[4]); ITK_TEST_SET_GET_BOOLEAN(filter, MarkWatershedLine, markWatershedLine); - bool fullyConnected = std::stoi(argv[5]); + const bool fullyConnected = std::stoi(argv[5]); ITK_TEST_SET_GET_BOOLEAN(filter, FullyConnected, fullyConnected); @@ -81,12 +81,12 @@ itkMorphologicalWatershedFromMarkersImageFilterTest(int argc, char * argv[]) size[i] = size[i] * 2; } - ImageType::RegionType::IndexType index{}; + const ImageType::RegionType::IndexType index{}; region.SetSize(size); region.SetIndex(index); - FilterType::LabelImageType::Pointer largerMarkerImage = FilterType::LabelImageType::New(); + const FilterType::LabelImageType::Pointer largerMarkerImage = FilterType::LabelImageType::New(); largerMarkerImage->SetBufferedRegion(region); largerMarkerImage->SetLargestPossibleRegion(region); largerMarkerImage->Allocate(); @@ -96,11 +96,11 @@ itkMorphologicalWatershedFromMarkersImageFilterTest(int argc, char * argv[]) ITK_TRY_EXPECT_EXCEPTION(filter->Update()); - FilterType::LabelImageType::Pointer markerImage = reader2->GetOutput(); + const FilterType::LabelImageType::Pointer markerImage = reader2->GetOutput(); filter->SetInput2(markerImage); ITK_TEST_SET_GET_VALUE(markerImage, filter->GetMarkerImage()); - itk::SimpleFilterWatcher watcher(filter, "MorphologicalWatershedFromMarkersImageFilter"); + const itk::SimpleFilterWatcher watcher(filter, "MorphologicalWatershedFromMarkersImageFilter"); ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); diff --git a/Modules/Segmentation/Watersheds/test/itkMorphologicalWatershedImageFilterTest.cxx b/Modules/Segmentation/Watersheds/test/itkMorphologicalWatershedImageFilterTest.cxx index 3d01d3b8b78..94cddf3fc41 100644 --- a/Modules/Segmentation/Watersheds/test/itkMorphologicalWatershedImageFilterTest.cxx +++ b/Modules/Segmentation/Watersheds/test/itkMorphologicalWatershedImageFilterTest.cxx @@ -56,10 +56,10 @@ itkMorphologicalWatershedImageFilterTest(int argc, char * argv[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, MorphologicalWatershedImageFilter, ImageToImageFilter); - bool markWatershedLine = std::stoi(argv[3]); + const bool markWatershedLine = std::stoi(argv[3]); ITK_TEST_SET_GET_BOOLEAN(filter, MarkWatershedLine, markWatershedLine); - bool fullyConnected = std::stoi(argv[4]); + const bool fullyConnected = std::stoi(argv[4]); ITK_TEST_SET_GET_BOOLEAN(filter, FullyConnected, fullyConnected); auto level = static_cast(std::stod(argv[5])); @@ -69,7 +69,7 @@ itkMorphologicalWatershedImageFilterTest(int argc, char * argv[]) filter->SetInput(reader->GetOutput()); - itk::SimpleFilterWatcher watcher(filter, "MorphologicalWatershedImageFilter"); + const itk::SimpleFilterWatcher watcher(filter, "MorphologicalWatershedImageFilter"); ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); diff --git a/Modules/Segmentation/Watersheds/test/itkTobogganImageFilterTest.cxx b/Modules/Segmentation/Watersheds/test/itkTobogganImageFilterTest.cxx index edb4e5e16ac..29cd033d535 100644 --- a/Modules/Segmentation/Watersheds/test/itkTobogganImageFilterTest.cxx +++ b/Modules/Segmentation/Watersheds/test/itkTobogganImageFilterTest.cxx @@ -52,7 +52,7 @@ itkTobogganImageFilterTest(int argc, char * argv[]) using GMGaussianType = itk::GradientMagnitudeRecursiveGaussianImageFilter; - itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); + const itk::ImageFileReader::Pointer reader = itk::ImageFileReader::New(); reader->SetFileName(argv[1]); diff --git a/Modules/Segmentation/Watersheds/test/itkWatershedImageFilterBadValuesTest.cxx b/Modules/Segmentation/Watersheds/test/itkWatershedImageFilterBadValuesTest.cxx index ffd631daf14..caa56368e1d 100644 --- a/Modules/Segmentation/Watersheds/test/itkWatershedImageFilterBadValuesTest.cxx +++ b/Modules/Segmentation/Watersheds/test/itkWatershedImageFilterBadValuesTest.cxx @@ -31,7 +31,7 @@ int itkWatershedImageFilterBadValuesTest(int argc, char * argv[]) { - int result = 0; + const int result = 0; if (argc < 2) { diff --git a/Modules/Segmentation/Watersheds/test/itkWatershedImageFilterTest.cxx b/Modules/Segmentation/Watersheds/test/itkWatershedImageFilterTest.cxx index fc9865c220d..6c341c8a7de 100644 --- a/Modules/Segmentation/Watersheds/test/itkWatershedImageFilterTest.cxx +++ b/Modules/Segmentation/Watersheds/test/itkWatershedImageFilterTest.cxx @@ -67,9 +67,9 @@ itkWatershedImageFilterTest(int, char *[]) // // Test EquivalenceRelabeler - itk::EquivalencyTable::Pointer table = itk::EquivalencyTable::New(); + const itk::EquivalencyTable::Pointer table = itk::EquivalencyTable::New(); - itk::watershed::EquivalenceRelabeler::Pointer eq = + const itk::watershed::EquivalenceRelabeler::Pointer eq = itk::watershed::EquivalenceRelabeler::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(eq, EquivalenceRelabeler, ProcessObject); @@ -85,15 +85,15 @@ itkWatershedImageFilterTest(int, char *[]) // Test WatershedMiniPipelineProgressCommand // Forcing the execution of the const Execute method which is not normally called. - itk::WatershedMiniPipelineProgressCommand::Pointer wmppc = itk::WatershedMiniPipelineProgressCommand::New(); + const itk::WatershedMiniPipelineProgressCommand::Pointer wmppc = itk::WatershedMiniPipelineProgressCommand::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(wmppc, WatershedMiniPipelineProgressCommand, Command); - double count = 2.0; + const double count = 2.0; wmppc->SetCount(count); ITK_TEST_SET_GET_VALUE(count, wmppc->GetCount()); - unsigned int numberOfFilters = 2; + const unsigned int numberOfFilters = 2; wmppc->SetNumberOfFilters(numberOfFilters); ITK_TEST_SET_GET_VALUE(numberOfFilters, wmppc->GetNumberOfFilters()); @@ -105,7 +105,7 @@ itkWatershedImageFilterTest(int, char *[]) wmppc->Execute(eq, itk::ProgressEvent()); // Test watershed::BoundaryResolver - itk::watershed::BoundaryResolver::Pointer br = + const itk::watershed::BoundaryResolver::Pointer br = itk::watershed::BoundaryResolver::New(); if (br.IsNull()) { @@ -116,7 +116,7 @@ itkWatershedImageFilterTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(br, BoundaryResolver, ProcessObject); - itk::watershed::Boundary::Pointer boundaryA = itk::watershed::Boundary::New(); + const itk::watershed::Boundary::Pointer boundaryA = itk::watershed::Boundary::New(); if (boundaryA.IsNull()) { std::cerr << "Test failed!" << std::endl; @@ -126,7 +126,7 @@ itkWatershedImageFilterTest(int, char *[]) ITK_EXERCISE_BASIC_OBJECT_METHODS(boundaryA, Boundary, DataObject); - itk::watershed::Boundary::Pointer boundaryB = itk::watershed::Boundary::New(); + const itk::watershed::Boundary::Pointer boundaryB = itk::watershed::Boundary::New(); if (boundaryB.IsNull()) { std::cerr << "Test failed!" << std::endl; @@ -135,17 +135,17 @@ itkWatershedImageFilterTest(int, char *[]) } - itk::WatershedImageFilter::Pointer watershedFilter = itk::WatershedImageFilter::New(); + const itk::WatershedImageFilter::Pointer watershedFilter = itk::WatershedImageFilter::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(watershedFilter, WatershedImageFilter, ImageToImageFilter); - itk::SimpleFilterWatcher watchIt(watershedFilter, "WatershedImageFilter"); + const itk::SimpleFilterWatcher watchIt(watershedFilter, "WatershedImageFilter"); - double threshold = .05; + const double threshold = .05; watershedFilter->SetThreshold(threshold); ITK_TEST_SET_GET_VALUE(threshold, watershedFilter->GetThreshold()); - double level = 1.0; + const double level = 1.0; watershedFilter->SetLevel(level); ITK_TEST_SET_GET_VALUE(level, watershedFilter->GetLevel()); diff --git a/Modules/Video/Core/include/itkImageToVideoFilter.hxx b/Modules/Video/Core/include/itkImageToVideoFilter.hxx index 5dee3ed595a..b1bb79374f4 100644 --- a/Modules/Video/Core/include/itkImageToVideoFilter.hxx +++ b/Modules/Video/Core/include/itkImageToVideoFilter.hxx @@ -98,7 +98,7 @@ ImageToVideoFilter::GenerateOutputInformation() const InputImageType * input = this->GetInput(); // Get first input frame's largest possible spatial region - InputImageRegionType inputRegion = input->GetLargestPossibleRegion(); + const InputImageRegionType inputRegion = input->GetLargestPossibleRegion(); typename InputImageType::SizeType inputSize = inputRegion.GetSize(); typename InputImageType::IndexType inputIndex = inputRegion.GetIndex(); typename InputImageType::SpacingType inputSpacing = input->GetSpacing(); @@ -116,8 +116,8 @@ ImageToVideoFilter::GenerateOutputInformation() static_cast(inputOrigin[m_FrameAxis]), static_cast(std::fmod(inputOrigin[m_FrameAxis], 1) * 1e6)); - auto realDurationRaw = inputSpacing[m_FrameAxis] * inputSize[m_FrameAxis]; - RealTimeInterval realDuration( + auto realDurationRaw = inputSpacing[m_FrameAxis] * inputSize[m_FrameAxis]; + const RealTimeInterval realDuration( static_cast(realDurationRaw), static_cast(std::fmod(realDurationRaw, 1) * 1e6)); @@ -134,8 +134,8 @@ ImageToVideoFilter::GenerateOutputInformation() { if (inputIdx != m_FrameAxis) { - SizeValueType axisSize = inputSize[inputIdx]; - IndexValueType axisStart = inputIndex[inputIdx]; + const SizeValueType axisSize = inputSize[inputIdx]; + const IndexValueType axisStart = inputIndex[inputIdx]; outputSpatialRegion.SetSize(outputIdx, axisSize); outputSpatialRegion.SetIndex(outputIdx, axisStart); ++outputIdx; @@ -221,12 +221,12 @@ ImageToVideoFilter::GenerateOutputRequestedRegi // Go through the requested temporal region and for any frame that doesn't // have a requested spatial region, set it to the largest possible - SizeValueType outFrameStart = vsOutput->GetRequestedTemporalRegion().GetFrameStart(); - SizeValueType outFrameDuration = vsOutput->GetRequestedTemporalRegion().GetFrameDuration(); + const SizeValueType outFrameStart = vsOutput->GetRequestedTemporalRegion().GetFrameStart(); + const SizeValueType outFrameDuration = vsOutput->GetRequestedTemporalRegion().GetFrameDuration(); for (SizeValueType i = outFrameStart; i < outFrameStart + outFrameDuration; ++i) { // Get the requested spatial region for this frame - OutputFrameSpatialRegionType spatialRegion = vsOutput->GetFrameRequestedSpatialRegion(i); + const OutputFrameSpatialRegionType spatialRegion = vsOutput->GetFrameRequestedSpatialRegion(i); // Check if the region has 0 size for all dimensions bool validRegion = false; @@ -262,13 +262,13 @@ ImageToVideoFilter::GenerateData() this->AllocateOutputs(); // Set each frame in output to an image slice in the input image - InputImageType * input = this->GetInput(); - InputImageRegionType inputRegion = input->GetLargestPossibleRegion(); + InputImageType * input = this->GetInput(); + const InputImageRegionType inputRegion = input->GetLargestPossibleRegion(); // Graft input image slices onto output frames OutputVideoStreamType * output = this->GetOutput(); - SizeValueType outputStartFrame = output->GetRequestedTemporalRegion().GetFrameStart(); - SizeValueType outputDuration = output->GetRequestedTemporalRegion().GetFrameDuration(); + const SizeValueType outputStartFrame = output->GetRequestedTemporalRegion().GetFrameStart(); + const SizeValueType outputDuration = output->GetRequestedTemporalRegion().GetFrameDuration(); for (auto idx = outputStartFrame; idx < outputStartFrame + outputDuration; idx++) { InputImageRegionType inputSliceRegion = inputRegion; diff --git a/Modules/Video/Core/include/itkRingBuffer.hxx b/Modules/Video/Core/include/itkRingBuffer.hxx index 76381d481e9..c0128406d60 100644 --- a/Modules/Video/Core/include/itkRingBuffer.hxx +++ b/Modules/Video/Core/include/itkRingBuffer.hxx @@ -113,14 +113,14 @@ template void RingBuffer::SetNumberOfBuffers(SizeValueType n) { - size_t currentSize = this->m_PointerVector.size(); + const size_t currentSize = this->m_PointerVector.size(); // If larger than current size, insert difference after tail if (n > currentSize) { for (size_t i = 0; i < n - currentSize; ++i) { - ElementPointer newPointer = nullptr; + const ElementPointer newPointer = nullptr; this->m_PointerVector.insert(this->m_PointerVector.begin() + this->m_HeadIndex, newPointer); // Increment head index if this wasn't the first one added @@ -154,8 +154,8 @@ template auto RingBuffer::GetOffsetBufferIndex(OffsetValueType offset) -> OffsetValueType { - OffsetValueType moddedOffset = itk::Math::abs(offset) % this->GetNumberOfBuffers(); - auto signedHeadIndex = static_cast(m_HeadIndex); + const OffsetValueType moddedOffset = itk::Math::abs(offset) % this->GetNumberOfBuffers(); + auto signedHeadIndex = static_cast(m_HeadIndex); if (offset >= 0) { return (signedHeadIndex + moddedOffset) % this->GetNumberOfBuffers(); diff --git a/Modules/Video/Core/include/itkVideoSource.hxx b/Modules/Video/Core/include/itkVideoSource.hxx index 8c516454ca4..b3ab4ae3ec5 100644 --- a/Modules/Video/Core/include/itkVideoSource.hxx +++ b/Modules/Video/Core/include/itkVideoSource.hxx @@ -31,7 +31,7 @@ namespace itk template VideoSource::VideoSource() { - typename OutputVideoStreamType::Pointer output = + const typename OutputVideoStreamType::Pointer output = static_cast(this->MakeOutput(0).GetPointer()); this->ProcessObject::SetNumberOfRequiredOutputs(1); this->ProcessObject::SetNthOutput(0, output.GetPointer()); @@ -138,8 +138,8 @@ void VideoSource::GenerateOutputRequestedTemporalRegion(TemporalDataObject * output) { // Check if requested temporal region unset - bool resetNumFrames = false; - TemporalRegion outputRequest = output->GetRequestedTemporalRegion(); + bool resetNumFrames = false; + const TemporalRegion outputRequest = output->GetRequestedTemporalRegion(); if (!outputRequest.GetFrameDuration()) { @@ -154,7 +154,7 @@ VideoSource::GenerateOutputRequestedTemporalRegion(TemporalD // region. This should only happen for filters at the end of the pipeline // since mid-pipeline filters will have their outputs' requested temporal // regions set automatically. - SizeValueType requestDuration = this->GetOutput()->GetRequestedTemporalRegion().GetFrameDuration(); + const SizeValueType requestDuration = this->GetOutput()->GetRequestedTemporalRegion().GetFrameDuration(); if (resetNumFrames && this->GetOutput()->GetNumberOfBuffers() < requestDuration) { this->GetOutput()->SetNumberOfBuffers(requestDuration); @@ -164,8 +164,8 @@ VideoSource::GenerateOutputRequestedTemporalRegion(TemporalD // spatial regions for every frame to the largest possible as well if (resetNumFrames) { - SizeValueType frameStart = this->GetOutput()->GetRequestedTemporalRegion().GetFrameStart(); - SizeValueType numFrames = this->GetOutput()->GetRequestedTemporalRegion().GetFrameDuration(); + const SizeValueType frameStart = this->GetOutput()->GetRequestedTemporalRegion().GetFrameStart(); + const SizeValueType numFrames = this->GetOutput()->GetRequestedTemporalRegion().GetFrameDuration(); for (SizeValueType i = frameStart; i < frameStart + numFrames; ++i) { // this->GetOutput()->SetFrameRequestedSpatialRegion(i, @@ -187,13 +187,13 @@ VideoSource::AllocateOutputs() OutputVideoStreamType * output = this->GetOutput(); // Get a list of unbuffered requested frames - TemporalRegion unbufferedRegion = output->GetUnbufferedRequestedTemporalRegion(); + const TemporalRegion unbufferedRegion = output->GetUnbufferedRequestedTemporalRegion(); // We don't touch the buffered temporal region here because that is handled // by the default implementation of GenerateData in TemporalProcessObject // If there are no unbuffered frames, return now - SizeValueType numFrames = unbufferedRegion.GetFrameDuration(); + const SizeValueType numFrames = unbufferedRegion.GetFrameDuration(); if (numFrames == 0) { @@ -205,11 +205,11 @@ VideoSource::AllocateOutputs() // Loop through the unbuffered frames and set the buffered spatial region to // match the requested spatial region then allocate the data - SizeValueType startFrame = unbufferedRegion.GetFrameStart(); + const SizeValueType startFrame = unbufferedRegion.GetFrameStart(); for (SizeValueType i = startFrame; i < startFrame + numFrames; ++i) { output->SetFrameBufferedSpatialRegion(i, output->GetFrameRequestedSpatialRegion(i)); - typename OutputFrameType::Pointer frame = output->GetFrame(i); + const typename OutputFrameType::Pointer frame = output->GetFrame(i); frame->SetBufferedRegion(output->GetFrameRequestedSpatialRegion(i)); frame->Allocate(); } @@ -272,7 +272,7 @@ VideoSource::SplitRequestedSpatialRegion( { // Get the output pointer and a pointer to the first output frame OutputVideoStreamType * outputPtr = this->GetOutput(); - SizeValueType currentFrame = outputPtr->GetRequestedTemporalRegion().GetFrameStart(); + const SizeValueType currentFrame = outputPtr->GetRequestedTemporalRegion().GetFrameStart(); OutputFrameType * framePtr = outputPtr->GetFrame(currentFrame); const typename TOutputVideoStream::SizeType & requestedRegionSize = framePtr->GetRequestedRegion().GetSize(); @@ -295,7 +295,7 @@ VideoSource::SplitRequestedSpatialRegion( } // determine the actual number of pieces that will be generated - typename TOutputVideoStream::SizeType::SizeValueType range = requestedRegionSize[splitAxis]; + const typename TOutputVideoStream::SizeType::SizeValueType range = requestedRegionSize[splitAxis]; int valuesPerThread; int maxThreadIdUsed; @@ -339,15 +339,15 @@ template ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION VideoSource::ThreaderCallback(void * arg) { - int workUnitID = ((MultiThreaderBase::WorkUnitInfo *)(arg))->WorkUnitID; - int threadCount = ((MultiThreaderBase::WorkUnitInfo *)(arg))->NumberOfWorkUnits; + const int workUnitID = ((MultiThreaderBase::WorkUnitInfo *)(arg))->WorkUnitID; + const int threadCount = ((MultiThreaderBase::WorkUnitInfo *)(arg))->NumberOfWorkUnits; ThreadStruct * str = (ThreadStruct *)(((MultiThreaderBase::WorkUnitInfo *)(arg))->UserData); // execute the actual method with appropriate output region // first find out how many pieces extent can be split into. typename TOutputVideoStream::SpatialRegionType splitRegion; - int total = str->Filter->SplitRequestedSpatialRegion(workUnitID, threadCount, splitRegion); + const int total = str->Filter->SplitRequestedSpatialRegion(workUnitID, threadCount, splitRegion); if (workUnitID < total) { diff --git a/Modules/Video/Core/include/itkVideoStream.hxx b/Modules/Video/Core/include/itkVideoStream.hxx index ff19de36b7a..e5c6ab410df 100644 --- a/Modules/Video/Core/include/itkVideoStream.hxx +++ b/Modules/Video/Core/include/itkVideoStream.hxx @@ -30,8 +30,8 @@ VideoStream::SetFrameLargestPossibleSpatialRegion(SizeValueType m_LargestPossibleSpatialRegionCache[frameNumber] = region; // If the frame is currently buffered, set the actual frame's region - SizeValueType bufStart = m_BufferedTemporalRegion.GetFrameStart(); - SizeValueType bufDur = m_BufferedTemporalRegion.GetFrameDuration(); + const SizeValueType bufStart = m_BufferedTemporalRegion.GetFrameStart(); + const SizeValueType bufDur = m_BufferedTemporalRegion.GetFrameDuration(); if (frameNumber >= bufStart && frameNumber < bufStart + bufDur) { FrameType * frame = this->GetFrame(frameNumber); @@ -58,8 +58,8 @@ VideoStream::SetFrameRequestedSpatialRegion(SizeValueType m_RequestedSpatialRegionCache[frameNumber] = region; // If the frame is currently buffered, set the actual frame's region - SizeValueType bufStart = m_BufferedTemporalRegion.GetFrameStart(); - SizeValueType bufDur = m_BufferedTemporalRegion.GetFrameDuration(); + const SizeValueType bufStart = m_BufferedTemporalRegion.GetFrameStart(); + const SizeValueType bufDur = m_BufferedTemporalRegion.GetFrameDuration(); if (frameNumber >= bufStart && frameNumber < bufStart + bufDur) { FrameType * frame = this->GetFrame(frameNumber); @@ -86,8 +86,8 @@ VideoStream::SetFrameBufferedSpatialRegion(SizeValueType m_BufferedSpatialRegionCache[frameNumber] = region; // If the frame is currently buffered, set the actual frame's region - SizeValueType bufStart = m_BufferedTemporalRegion.GetFrameStart(); - SizeValueType bufDur = m_BufferedTemporalRegion.GetFrameDuration(); + const SizeValueType bufStart = m_BufferedTemporalRegion.GetFrameStart(); + const SizeValueType bufDur = m_BufferedTemporalRegion.GetFrameDuration(); if (frameNumber >= bufStart && frameNumber < bufStart + bufDur) { FrameType * frame = this->GetFrame(frameNumber); @@ -122,8 +122,8 @@ VideoStream::SetFrameSpacing(SizeValueType frameNumber, typename TFr m_SpacingCache[frameNumber] = spacing; // If the frame is currently buffered, set the actual frame's spacing - SizeValueType bufStart = m_BufferedTemporalRegion.GetFrameStart(); - SizeValueType bufDur = m_BufferedTemporalRegion.GetFrameDuration(); + const SizeValueType bufStart = m_BufferedTemporalRegion.GetFrameStart(); + const SizeValueType bufDur = m_BufferedTemporalRegion.GetFrameDuration(); if (frameNumber >= bufStart && frameNumber < bufStart + bufDur) { FrameType * frame = this->GetFrame(frameNumber); @@ -149,8 +149,8 @@ VideoStream::SetFrameOrigin(SizeValueType frameNumber, typename TFra m_OriginCache[frameNumber] = origin; // If the frame is currently buffered, set the actual frame's spacing - SizeValueType bufStart = m_BufferedTemporalRegion.GetFrameStart(); - SizeValueType bufDur = m_BufferedTemporalRegion.GetFrameDuration(); + const SizeValueType bufStart = m_BufferedTemporalRegion.GetFrameStart(); + const SizeValueType bufDur = m_BufferedTemporalRegion.GetFrameDuration(); if (frameNumber >= bufStart && frameNumber < bufStart + bufDur) { FrameType * frame = this->GetFrame(frameNumber); @@ -182,8 +182,8 @@ VideoStream::SetFrameDirection(SizeValueType frameNumber, typename T m_DirectionCache[frameNumber] = direction; // If the frame is currently buffered, set the actual frame's spacing - SizeValueType bufStart = m_BufferedTemporalRegion.GetFrameStart(); - SizeValueType bufDur = m_BufferedTemporalRegion.GetFrameDuration(); + const SizeValueType bufStart = m_BufferedTemporalRegion.GetFrameStart(); + const SizeValueType bufDur = m_BufferedTemporalRegion.GetFrameDuration(); if (frameNumber >= bufStart && frameNumber < bufStart + bufDur) { FrameType * frame = this->GetFrame(frameNumber); @@ -208,8 +208,8 @@ VideoStream::SetFrameNumberOfComponentsPerPixel(SizeValueType frameN m_NumberOfComponentsPerPixelCache[frameNumber] = n; // If the frame is currently buffered, set the actual frame's region - SizeValueType bufStart = m_BufferedTemporalRegion.GetFrameStart(); - SizeValueType bufDur = m_BufferedTemporalRegion.GetFrameDuration(); + const SizeValueType bufStart = m_BufferedTemporalRegion.GetFrameStart(); + const SizeValueType bufDur = m_BufferedTemporalRegion.GetFrameDuration(); if (frameNumber >= bufStart && frameNumber < bufStart + bufDur) { FrameType * frame = this->GetFrame(frameNumber); @@ -283,7 +283,7 @@ void VideoStream::InitializeEmptyFrames() { // If we don't have any frames requested, just return - SizeValueType numFrames = m_RequestedTemporalRegion.GetFrameDuration(); + const SizeValueType numFrames = m_RequestedTemporalRegion.GetFrameDuration(); if (numFrames == 0) { return; @@ -294,14 +294,14 @@ VideoStream::InitializeEmptyFrames() this->SetMinimumBufferSize(numFrames); // Go through the number of required frames and make sure none are empty - SizeValueType startFrame = m_RequestedTemporalRegion.GetFrameStart(); + const SizeValueType startFrame = m_RequestedTemporalRegion.GetFrameStart(); for (SizeValueType i = startFrame; i < startFrame + numFrames; ++i) { if (!m_DataObjectBuffer->BufferIsFull(i)) { - FramePointer newFrame = FrameType::New(); - FrameType * newFrameRawPointer = newFrame.GetPointer(); - typename BufferType::ElementPointer element = + const FramePointer newFrame = FrameType::New(); + FrameType * newFrameRawPointer = newFrame.GetPointer(); + const typename BufferType::ElementPointer element = dynamic_cast(newFrameRawPointer); m_DataObjectBuffer->SetBufferContents(i, element); } @@ -344,7 +344,7 @@ void VideoStream::SetFrame(SizeValueType frameNumber, FramePointer frame) { auto * dataObjectRawPointer = dynamic_cast(frame.GetPointer()); - typename BufferType::ElementPointer dataObject = dataObjectRawPointer; + const typename BufferType::ElementPointer dataObject = dataObjectRawPointer; m_DataObjectBuffer->SetBufferContents(frameNumber, dataObject); // Cache the meta data @@ -363,8 +363,8 @@ VideoStream::GetFrame(SizeValueType frameNumber) -> FrameType * { // Fetch the frame - typename BufferType::ElementPointer element = m_DataObjectBuffer->GetBufferContents(frameNumber); - FramePointer frame = dynamic_cast(element.GetPointer()); + const typename BufferType::ElementPointer element = m_DataObjectBuffer->GetBufferContents(frameNumber); + const FramePointer frame = dynamic_cast(element.GetPointer()); return frame; } @@ -373,8 +373,8 @@ template auto VideoStream::GetFrame(SizeValueType frameNumber) const -> const FrameType * { - typename BufferType::ElementPointer element = m_DataObjectBuffer->GetBufferContents(frameNumber); - FrameConstPointer frame = dynamic_cast(element.GetPointer()); + const typename BufferType::ElementPointer element = m_DataObjectBuffer->GetBufferContents(frameNumber); + const FrameConstPointer frame = dynamic_cast(element.GetPointer()); return frame; } @@ -414,15 +414,16 @@ template void VideoStream::SetAllLargestPossibleSpatialRegions(typename TFrameType::RegionType region) { - SizeValueType numFrames = m_LargestPossibleTemporalRegion.GetFrameDuration(); - SizeValueType startFrame = m_LargestPossibleTemporalRegion.GetFrameStart(); + SizeValueType numFrames = m_LargestPossibleTemporalRegion.GetFrameDuration(); + const SizeValueType startFrame = m_LargestPossibleTemporalRegion.GetFrameStart(); // If the largest region is infinite, use the largest of the requested or // buffered region if (numFrames == ITK_INFINITE_FRAME_DURATION) { - SizeValueType bufEnd = m_BufferedTemporalRegion.GetFrameStart() + m_BufferedTemporalRegion.GetFrameDuration(); - SizeValueType reqEnd = m_RequestedTemporalRegion.GetFrameStart() + m_RequestedTemporalRegion.GetFrameDuration(); + const SizeValueType bufEnd = m_BufferedTemporalRegion.GetFrameStart() + m_BufferedTemporalRegion.GetFrameDuration(); + const SizeValueType reqEnd = + m_RequestedTemporalRegion.GetFrameStart() + m_RequestedTemporalRegion.GetFrameDuration(); (bufEnd > reqEnd) ? (numFrames = bufEnd) : (numFrames = reqEnd); } @@ -439,15 +440,16 @@ template void VideoStream::SetAllRequestedSpatialRegions(typename TFrameType::RegionType region) { - SizeValueType numFrames = m_LargestPossibleTemporalRegion.GetFrameDuration(); - SizeValueType startFrame = m_LargestPossibleTemporalRegion.GetFrameStart(); + SizeValueType numFrames = m_LargestPossibleTemporalRegion.GetFrameDuration(); + const SizeValueType startFrame = m_LargestPossibleTemporalRegion.GetFrameStart(); // If the largest region is infinite, use the largest of the requested or // buffered region if (numFrames == ITK_INFINITE_FRAME_DURATION) { - SizeValueType bufEnd = m_BufferedTemporalRegion.GetFrameStart() + m_BufferedTemporalRegion.GetFrameDuration(); - SizeValueType reqEnd = m_RequestedTemporalRegion.GetFrameStart() + m_RequestedTemporalRegion.GetFrameDuration(); + const SizeValueType bufEnd = m_BufferedTemporalRegion.GetFrameStart() + m_BufferedTemporalRegion.GetFrameDuration(); + const SizeValueType reqEnd = + m_RequestedTemporalRegion.GetFrameStart() + m_RequestedTemporalRegion.GetFrameDuration(); (bufEnd > reqEnd) ? (numFrames = bufEnd) : (numFrames = reqEnd); } @@ -464,15 +466,16 @@ template void VideoStream::SetAllBufferedSpatialRegions(typename TFrameType::RegionType region) { - SizeValueType numFrames = m_LargestPossibleTemporalRegion.GetFrameDuration(); - SizeValueType startFrame = m_LargestPossibleTemporalRegion.GetFrameStart(); + SizeValueType numFrames = m_LargestPossibleTemporalRegion.GetFrameDuration(); + const SizeValueType startFrame = m_LargestPossibleTemporalRegion.GetFrameStart(); // If the largest region is infinite, use the largest of the requested or // buffered region if (numFrames == ITK_INFINITE_FRAME_DURATION) { - SizeValueType bufEnd = m_BufferedTemporalRegion.GetFrameStart() + m_BufferedTemporalRegion.GetFrameDuration(); - SizeValueType reqEnd = m_RequestedTemporalRegion.GetFrameStart() + m_RequestedTemporalRegion.GetFrameDuration(); + const SizeValueType bufEnd = m_BufferedTemporalRegion.GetFrameStart() + m_BufferedTemporalRegion.GetFrameDuration(); + const SizeValueType reqEnd = + m_RequestedTemporalRegion.GetFrameStart() + m_RequestedTemporalRegion.GetFrameDuration(); (bufEnd > reqEnd) ? (numFrames = bufEnd) : (numFrames = reqEnd); } @@ -489,15 +492,16 @@ template void VideoStream::SetAllFramesSpacing(typename TFrameType::SpacingType spacing) { - SizeValueType numFrames = m_LargestPossibleTemporalRegion.GetFrameDuration(); - SizeValueType startFrame = m_LargestPossibleTemporalRegion.GetFrameStart(); + SizeValueType numFrames = m_LargestPossibleTemporalRegion.GetFrameDuration(); + const SizeValueType startFrame = m_LargestPossibleTemporalRegion.GetFrameStart(); // If the largest region is infinite, use the largest of the requested or // buffered region if (numFrames == ITK_INFINITE_FRAME_DURATION) { - SizeValueType bufEnd = m_BufferedTemporalRegion.GetFrameStart() + m_BufferedTemporalRegion.GetFrameDuration(); - SizeValueType reqEnd = m_RequestedTemporalRegion.GetFrameStart() + m_RequestedTemporalRegion.GetFrameDuration(); + const SizeValueType bufEnd = m_BufferedTemporalRegion.GetFrameStart() + m_BufferedTemporalRegion.GetFrameDuration(); + const SizeValueType reqEnd = + m_RequestedTemporalRegion.GetFrameStart() + m_RequestedTemporalRegion.GetFrameDuration(); (bufEnd > reqEnd) ? (numFrames = bufEnd) : (numFrames = reqEnd); } @@ -514,15 +518,16 @@ template void VideoStream::SetAllFramesOrigin(typename TFrameType::PointType origin) { - SizeValueType numFrames = m_LargestPossibleTemporalRegion.GetFrameDuration(); - SizeValueType startFrame = m_LargestPossibleTemporalRegion.GetFrameStart(); + SizeValueType numFrames = m_LargestPossibleTemporalRegion.GetFrameDuration(); + const SizeValueType startFrame = m_LargestPossibleTemporalRegion.GetFrameStart(); // If the largest region is infinite, use the largest of the requested or // buffered region if (numFrames == ITK_INFINITE_FRAME_DURATION) { - SizeValueType bufEnd = m_BufferedTemporalRegion.GetFrameStart() + m_BufferedTemporalRegion.GetFrameDuration(); - SizeValueType reqEnd = m_RequestedTemporalRegion.GetFrameStart() + m_RequestedTemporalRegion.GetFrameDuration(); + const SizeValueType bufEnd = m_BufferedTemporalRegion.GetFrameStart() + m_BufferedTemporalRegion.GetFrameDuration(); + const SizeValueType reqEnd = + m_RequestedTemporalRegion.GetFrameStart() + m_RequestedTemporalRegion.GetFrameDuration(); (bufEnd > reqEnd) ? (numFrames = bufEnd) : (numFrames = reqEnd); } @@ -539,15 +544,16 @@ template void VideoStream::SetAllFramesDirection(typename TFrameType::DirectionType direction) { - SizeValueType numFrames = m_LargestPossibleTemporalRegion.GetFrameDuration(); - SizeValueType startFrame = m_LargestPossibleTemporalRegion.GetFrameStart(); + SizeValueType numFrames = m_LargestPossibleTemporalRegion.GetFrameDuration(); + const SizeValueType startFrame = m_LargestPossibleTemporalRegion.GetFrameStart(); // If the largest region is infinite, use the largest of the requested or // buffered region if (numFrames == ITK_INFINITE_FRAME_DURATION) { - SizeValueType bufEnd = m_BufferedTemporalRegion.GetFrameStart() + m_BufferedTemporalRegion.GetFrameDuration(); - SizeValueType reqEnd = m_RequestedTemporalRegion.GetFrameStart() + m_RequestedTemporalRegion.GetFrameDuration(); + const SizeValueType bufEnd = m_BufferedTemporalRegion.GetFrameStart() + m_BufferedTemporalRegion.GetFrameDuration(); + const SizeValueType reqEnd = + m_RequestedTemporalRegion.GetFrameStart() + m_RequestedTemporalRegion.GetFrameDuration(); (bufEnd > reqEnd) ? (numFrames = bufEnd) : (numFrames = reqEnd); } @@ -563,15 +569,16 @@ template void VideoStream::SetAllFramesNumberOfComponentsPerPixel(NumberOfComponentsPerPixelType n) { - SizeValueType numFrames = m_LargestPossibleTemporalRegion.GetFrameDuration(); - SizeValueType startFrame = m_LargestPossibleTemporalRegion.GetFrameStart(); + SizeValueType numFrames = m_LargestPossibleTemporalRegion.GetFrameDuration(); + const SizeValueType startFrame = m_LargestPossibleTemporalRegion.GetFrameStart(); // If the largest region is infinite, use the largest of the requested or // buffered region if (numFrames == ITK_INFINITE_FRAME_DURATION) { - SizeValueType bufEnd = m_BufferedTemporalRegion.GetFrameStart() + m_BufferedTemporalRegion.GetFrameDuration(); - SizeValueType reqEnd = m_RequestedTemporalRegion.GetFrameStart() + m_RequestedTemporalRegion.GetFrameDuration(); + const SizeValueType bufEnd = m_BufferedTemporalRegion.GetFrameStart() + m_BufferedTemporalRegion.GetFrameDuration(); + const SizeValueType reqEnd = + m_RequestedTemporalRegion.GetFrameStart() + m_RequestedTemporalRegion.GetFrameDuration(); (bufEnd > reqEnd) ? (numFrames = bufEnd) : (numFrames = reqEnd); } @@ -588,7 +595,7 @@ template void VideoStream::Allocate() { - SizeValueType numFrames = m_BufferedTemporalRegion.GetFrameDuration(); + const SizeValueType numFrames = m_BufferedTemporalRegion.GetFrameDuration(); if (m_DataObjectBuffer->GetNumberOfBuffers() < numFrames) { itkExceptionMacro("itk::VideoStream::SetAllLargestPossibleSpatialRegions " diff --git a/Modules/Video/Core/include/itkVideoToVideoFilter.hxx b/Modules/Video/Core/include/itkVideoToVideoFilter.hxx index 561715a847f..0d05ead8e85 100644 --- a/Modules/Video/Core/include/itkVideoToVideoFilter.hxx +++ b/Modules/Video/Core/include/itkVideoToVideoFilter.hxx @@ -107,8 +107,8 @@ VideoToVideoFilter::UpdateOutputInformati const InputVideoStreamType * input = this->GetInput(); // Get first input frame's largest possible spatial region - SizeValueType firstInputFrameNum = input->GetLargestPossibleTemporalRegion().GetFrameStart(); - InputFrameSpatialRegionType inputRegion = input->GetFrameLargestPossibleSpatialRegion(firstInputFrameNum); + const SizeValueType firstInputFrameNum = input->GetLargestPossibleTemporalRegion().GetFrameStart(); + const InputFrameSpatialRegionType inputRegion = input->GetFrameLargestPossibleSpatialRegion(firstInputFrameNum); // Propagate this spatial region to output frames this->GetOutput()->SetAllLargestPossibleSpatialRegions(inputRegion); @@ -148,12 +148,12 @@ VideoToVideoFilter::GenerateOutputRequest // Go through the requested temporal region and for any frame that doesn't // have a requested spatial region, set it to the largest possible - SizeValueType outFrameStart = this->GetOutput()->GetRequestedTemporalRegion().GetFrameStart(); - SizeValueType outFrameDuration = this->GetOutput()->GetRequestedTemporalRegion().GetFrameDuration(); + const SizeValueType outFrameStart = this->GetOutput()->GetRequestedTemporalRegion().GetFrameStart(); + const SizeValueType outFrameDuration = this->GetOutput()->GetRequestedTemporalRegion().GetFrameDuration(); for (SizeValueType i = outFrameStart; i < outFrameStart + outFrameDuration; ++i) { // Get the requested spatial region for this frame - OutputFrameSpatialRegionType spatialRegion = this->GetOutput()->GetFrameRequestedSpatialRegion(i); + const OutputFrameSpatialRegionType spatialRegion = this->GetOutput()->GetFrameRequestedSpatialRegion(i); // Check if the region has 0 size for all dimensions bool validRegion = false; @@ -185,8 +185,8 @@ VideoToVideoFilter::GenerateInputRequeste Superclass::GenerateInputRequestedRegion(); // Get the spatial region from the output frame - SizeValueType outputStart = this->GetOutput()->GetRequestedTemporalRegion().GetFrameStart(); - OutputFrameSpatialRegionType outputRegion = this->GetOutput()->GetFrameRequestedSpatialRegion(outputStart); + const SizeValueType outputStart = this->GetOutput()->GetRequestedTemporalRegion().GetFrameStart(); + const OutputFrameSpatialRegionType outputRegion = this->GetOutput()->GetFrameRequestedSpatialRegion(outputStart); // Convert to input spatial region (TODO: handle difficult cases) const InputFrameSpatialRegionType inputRegion = outputRegion; @@ -200,11 +200,11 @@ VideoToVideoFilter::GenerateInputRequeste { continue; } - TemporalRegion inRequestedTemporalRegion = input->GetRequestedTemporalRegion(); + const TemporalRegion inRequestedTemporalRegion = input->GetRequestedTemporalRegion(); // Loop over all frames in the temporal region - SizeValueType inputStart = inRequestedTemporalRegion.GetFrameStart(); - SizeValueType numFrames = inRequestedTemporalRegion.GetFrameDuration(); + const SizeValueType inputStart = inRequestedTemporalRegion.GetFrameStart(); + const SizeValueType numFrames = inRequestedTemporalRegion.GetFrameDuration(); for (SizeValueType j = inputStart; j < inputStart + numFrames; ++j) { // Set the requested spatial region on the input diff --git a/Modules/Video/Core/src/itkTemporalDataObject.cxx b/Modules/Video/Core/src/itkTemporalDataObject.cxx index 2e87bd47561..ceb0024d8ea 100644 --- a/Modules/Video/Core/src/itkTemporalDataObject.cxx +++ b/Modules/Video/Core/src/itkTemporalDataObject.cxx @@ -142,11 +142,13 @@ TemporalDataObject::GetUnbufferedRequestedTemporalRegion() } // Get the start and end of the buffered and requested temporal regions - SizeValueType reqStart = m_RequestedTemporalRegion.GetFrameStart(); - SizeValueType reqEnd = m_RequestedTemporalRegion.GetFrameStart() + m_RequestedTemporalRegion.GetFrameDuration() - 1; + const SizeValueType reqStart = m_RequestedTemporalRegion.GetFrameStart(); + const SizeValueType reqEnd = + m_RequestedTemporalRegion.GetFrameStart() + m_RequestedTemporalRegion.GetFrameDuration() - 1; - SizeValueType bufStart = m_BufferedTemporalRegion.GetFrameStart(); - SizeValueType bufEnd = m_BufferedTemporalRegion.GetFrameStart() + m_BufferedTemporalRegion.GetFrameDuration() - 1; + const SizeValueType bufStart = m_BufferedTemporalRegion.GetFrameStart(); + const SizeValueType bufEnd = + m_BufferedTemporalRegion.GetFrameStart() + m_BufferedTemporalRegion.GetFrameDuration() - 1; // If the request starts after the buffered region, return the whole request if (reqStart > bufEnd) diff --git a/Modules/Video/Core/src/itkTemporalProcessObject.cxx b/Modules/Video/Core/src/itkTemporalProcessObject.cxx index 87deb6cc6af..291008988af 100644 --- a/Modules/Video/Core/src/itkTemporalProcessObject.cxx +++ b/Modules/Video/Core/src/itkTemporalProcessObject.cxx @@ -70,13 +70,13 @@ void TemporalProcessObject::EnlargeOutputRequestedTemporalRegion(TemporalDataObject * output) { // Get information on output request and current output buffer - TemporalRegion outReqTempRegion = output->GetRequestedTemporalRegion(); - TemporalRegion outBufTempRegion = output->GetBufferedTemporalRegion(); - SizeValueType outReqStart = outReqTempRegion.GetFrameStart(); - SizeValueType outReqDuration = outReqTempRegion.GetFrameDuration(); - SizeValueType outReqEnd = outReqDuration + outReqStart; - SizeValueType outBufStart = outBufTempRegion.GetFrameStart(); - SizeValueType outBufEnd = outBufTempRegion.GetFrameDuration() + outBufStart; + TemporalRegion outReqTempRegion = output->GetRequestedTemporalRegion(); + const TemporalRegion outBufTempRegion = output->GetBufferedTemporalRegion(); + const SizeValueType outReqStart = outReqTempRegion.GetFrameStart(); + SizeValueType outReqDuration = outReqTempRegion.GetFrameDuration(); + const SizeValueType outReqEnd = outReqDuration + outReqStart; + const SizeValueType outBufStart = outBufTempRegion.GetFrameStart(); + const SizeValueType outBufEnd = outBufTempRegion.GetFrameDuration() + outBufStart; // If the requested output region is contained in the buffered temporal // region, just return @@ -88,7 +88,7 @@ TemporalProcessObject::EnlargeOutputRequestedTemporalRegion(TemporalDataObject * // Make sure the requested output temporal region duration is a multiple of // the unit number of output frames - SizeValueType remainder = outReqDuration % m_UnitOutputNumberOfFrames; + const SizeValueType remainder = outReqDuration % m_UnitOutputNumberOfFrames; if (remainder > 0) { outReqDuration += (m_UnitOutputNumberOfFrames - remainder); @@ -124,7 +124,7 @@ void TemporalProcessObject::GenerateOutputRequestedTemporalRegion(TemporalDataObject * output) { // Get the current output requested region - TemporalRegion outputRequest = output->GetRequestedTemporalRegion(); + const TemporalRegion outputRequest = output->GetRequestedTemporalRegion(); // If the largest possible temporal region has infinite duration, we should @@ -208,7 +208,7 @@ TemporalProcessObject::GenerateInputRequestedTemporalRegion() << typeid(TemporalDataObject *).name()); } - TemporalRegion outReqTempRegion = output->GetRequestedTemporalRegion(); + const TemporalRegion outReqTempRegion = output->GetRequestedTemporalRegion(); // This should always be a whole number because of EnlargeOutputRequestedTemporalRegion // but do it safely in case the subclass overrides it @@ -219,11 +219,11 @@ TemporalProcessObject::GenerateInputRequestedTemporalRegion() // will have to request a temporal region of size m_UnitInputNumberOfFrames. // Each request besides the last will require m_FrameSkipPerOutput new frames // to be loaded. - SizeValueType inputDuration = m_FrameSkipPerOutput * (numInputRequests - 1) + m_UnitInputNumberOfFrames; + const SizeValueType inputDuration = m_FrameSkipPerOutput * (numInputRequests - 1) + m_UnitInputNumberOfFrames; // Compute the start of the input requested temporal region based on // m_InputStencilCurrentFrameIndex and FrameSkipPerOutput - OffsetValueType inputStart = + const OffsetValueType inputStart = outReqTempRegion.GetFrameStart() * m_FrameSkipPerOutput - m_InputStencilCurrentFrameIndex; // Make sure we're not requesting a negative frame (this may be replaced by @@ -284,16 +284,17 @@ TemporalProcessObject::UpdateOutputInformation() { inputLargestRegion = input->GetLargestPossibleTemporalRegion(); } - OffsetValueType scannableDuration = inputLargestRegion.GetFrameDuration() - m_UnitInputNumberOfFrames + 1; - SizeValueType outputDuration = + const OffsetValueType scannableDuration = inputLargestRegion.GetFrameDuration() - m_UnitInputNumberOfFrames + 1; + const SizeValueType outputDuration = m_UnitOutputNumberOfFrames * Math::Round(static_cast(scannableDuration - 1) / static_cast(m_FrameSkipPerOutput) + 1); // Compute the start of the output region - OffsetValueType outputStart = Math::Ceil(static_cast(inputLargestRegion.GetFrameStart()) / - static_cast(m_FrameSkipPerOutput)) + - m_InputStencilCurrentFrameIndex; + const OffsetValueType outputStart = + Math::Ceil(static_cast(inputLargestRegion.GetFrameStart()) / + static_cast(m_FrameSkipPerOutput)) + + m_InputStencilCurrentFrameIndex; // Set up output largest possible region TemporalRegion largestRegion = output->GetLargestPossibleTemporalRegion(); @@ -414,7 +415,7 @@ TemporalProcessObject::GenerateData() SizeValueType outputStartFrame = output->GetUnbufferedRequestedTemporalRegion().GetFrameStart(); // Save the full requested and buffered output regions - TemporalRegion fullOutputRequest = output->GetRequestedTemporalRegion(); + const TemporalRegion fullOutputRequest = output->GetRequestedTemporalRegion(); // Process each of the temporal sub-regions in sequence for (const auto & inputTemporalRegionRequest : this->SplitRequestedTemporalRegion()) @@ -456,7 +457,7 @@ TemporalProcessObject::GenerateData() bufferedStart = outputStartFrame; } - OffsetValueType spareFrames = output->GetNumberOfBuffers() - (OffsetValueType)bufferedDuration; + const OffsetValueType spareFrames = output->GetNumberOfBuffers() - (OffsetValueType)bufferedDuration; if (spareFrames >= (OffsetValueType)m_UnitOutputNumberOfFrames) { bufferedDuration += m_UnitOutputNumberOfFrames; @@ -519,7 +520,7 @@ TemporalProcessObject::SplitRequestedTemporalRegion() // requested temporal region and its buffered temporal region. This // difference is defined as any time that is covered by the requested region // but not by the buffered region - TemporalRegion unbufferedRegion = outputObject->GetUnbufferedRequestedTemporalRegion(); + const TemporalRegion unbufferedRegion = outputObject->GetUnbufferedRequestedTemporalRegion(); // Calculate the number of input requests that will be needed auto numRequests = Math::Ceil( diff --git a/Modules/Video/Core/test/itkImageToVideoFilterTest.cxx b/Modules/Video/Core/test/itkImageToVideoFilterTest.cxx index 7bc90d35cbf..0f70d018686 100644 --- a/Modules/Video/Core/test/itkImageToVideoFilterTest.cxx +++ b/Modules/Video/Core/test/itkImageToVideoFilterTest.cxx @@ -68,7 +68,7 @@ itkImageToVideoFilterTest(int argc, char * argv[]) videoFilter->SetInput(inputImage); // Arbitrarily set 0th axis as temporal dimension to split frames - itk::IndexValueType frameAxis = 0; + const itk::IndexValueType frameAxis = 0; videoFilter->SetFrameAxis(frameAxis); ITK_TEST_SET_GET_VALUE(frameAxis, videoFilter->GetFrameAxis()); diff --git a/Modules/Video/Core/test/itkRingBufferTest.cxx b/Modules/Video/Core/test/itkRingBufferTest.cxx index ea986258a67..35a28fc89c9 100644 --- a/Modules/Video/Core/test/itkRingBufferTest.cxx +++ b/Modules/Video/Core/test/itkRingBufferTest.cxx @@ -99,7 +99,7 @@ itkRingBufferTest(int, char *[]) } // Test looping buffer offset forward - unsigned int oldHeadIndex = ringBuffer->GetHeadIndex(); + const unsigned int oldHeadIndex = ringBuffer->GetHeadIndex(); ringBuffer->MoveHead(2 * ringBuffer->GetNumberOfBuffers()); if (ringBuffer->GetHeadIndex() != oldHeadIndex) { @@ -134,7 +134,7 @@ itkRingBufferTest(int, char *[]) } // Create a new Object, add it at Head and make sure it is reported full - itk::Object::Pointer obj1 = itk::Object::New(); + const itk::Object::Pointer obj1 = itk::Object::New(); ringBuffer->SetBufferContents(0, obj1); if (!ringBuffer->BufferIsFull(0)) { @@ -143,7 +143,7 @@ itkRingBufferTest(int, char *[]) } // Try retreiving the object and compare time stamps - itk::Object::Pointer objOut = ringBuffer->GetBufferContents(0); + const itk::Object::Pointer objOut = ringBuffer->GetBufferContents(0); if (obj1->GetTimeStamp() != objOut->GetTimeStamp()) { std::cerr << "Returned object doesn't match input object" << std::endl; @@ -151,7 +151,7 @@ itkRingBufferTest(int, char *[]) } // Add another object and then check fullness of all buffers - itk::Object::Pointer obj2 = itk::Object::New(); + const itk::Object::Pointer obj2 = itk::Object::New(); ringBuffer->SetBufferContents(-1, obj2); // Everything except Head and Head-1 should be empty diff --git a/Modules/Video/Core/test/itkTemporalDataObjectTest.cxx b/Modules/Video/Core/test/itkTemporalDataObjectTest.cxx index eebe39ca404..ee809dae918 100644 --- a/Modules/Video/Core/test/itkTemporalDataObjectTest.cxx +++ b/Modules/Video/Core/test/itkTemporalDataObjectTest.cxx @@ -60,7 +60,7 @@ itkTemporalDataObjectTest(int, char *[]) itk::TemporalDataObject::Pointer tdo2; itk::TemporalDataObject::Pointer tdo3; itk::TemporalDataObject::Pointer tdo4; - itk::DataObject::Pointer notTemporal; + const itk::DataObject::Pointer notTemporal; // Instantiate a TemporalDataObject tdo = itk::TemporalDataObject::New(); diff --git a/Modules/Video/Core/test/itkTemporalProcessObjectTest.cxx b/Modules/Video/Core/test/itkTemporalProcessObjectTest.cxx index 64287c125ab..85be2e7cec5 100644 --- a/Modules/Video/Core/test/itkTemporalProcessObjectTest.cxx +++ b/Modules/Video/Core/test/itkTemporalProcessObjectTest.cxx @@ -259,7 +259,7 @@ class DummyTemporalDataObject : public TemporalDataObject for (SizeValueType i = 0; i < x; ++i) { // Create a new DataObject - DataObject::Pointer obj = DataObject::New().GetPointer(); + const DataObject::Pointer obj = DataObject::New().GetPointer(); // Append to the end of the buffer m_DataObjectBuffer->MoveHeadForward(); @@ -289,15 +289,15 @@ class DummyTemporalDataObject : public TemporalDataObject } // make sure we have the desired frame buffered - SizeValueType bufStart = m_BufferedTemporalRegion.GetFrameStart(); - SizeValueType bufEnd = bufStart + m_BufferedTemporalRegion.GetFrameDuration() - 1; + const SizeValueType bufStart = m_BufferedTemporalRegion.GetFrameStart(); + const SizeValueType bufEnd = bufStart + m_BufferedTemporalRegion.GetFrameDuration() - 1; if (frameNumber < bufStart || frameNumber > bufEnd) { return nullptr; } // If we can, fetch the desired frame - OffsetValueType frameOffset = frameNumber - bufEnd; // Should be negative + const OffsetValueType frameOffset = frameNumber - bufEnd; // Should be negative return m_DataObjectBuffer->GetBufferContents(frameOffset); } }; @@ -331,13 +331,13 @@ class DummyTemporalProcessObject : public TemporalProcessObject m_IdNumber, CallRecord::RecordTypeEnum::START_CALL, CallRecord::MethodTypeEnum::STREAMING_GENERATE_DATA); // Report - SizeValueType outputStart = this->GetOutput()->GetRequestedTemporalRegion().GetFrameStart(); + const SizeValueType outputStart = this->GetOutput()->GetRequestedTemporalRegion().GetFrameStart(); std::cout << "**(ID = " << m_IdNumber << ") - TemporalStreamingGenerateData" << std::endl; std::cout << " -> output requested from: " << outputStart << " to " << this->GetOutput()->GetRequestedTemporalRegion().GetFrameDuration() + outputStart - 1 << std::endl; - SizeValueType inputStart = this->GetInput()->GetRequestedTemporalRegion().GetFrameStart(); - SizeValueType inputEnd = inputStart + this->GetInput()->GetRequestedTemporalRegion().GetFrameDuration() - 1; + const SizeValueType inputStart = this->GetInput()->GetRequestedTemporalRegion().GetFrameStart(); + const SizeValueType inputEnd = inputStart + this->GetInput()->GetRequestedTemporalRegion().GetFrameDuration() - 1; std::cout << " -> input requested from " << inputStart << " to " << inputEnd << std::endl; std::cout << " -> input buffered from " << this->GetInput()->GetBufferedTemporalRegion().GetFrameStart() << " to " << this->GetInput()->GetBufferedTemporalRegion().GetFrameStart() + @@ -345,12 +345,12 @@ class DummyTemporalProcessObject : public TemporalProcessObject << std::endl; // Get the list of unbuffered frames - TemporalRegion unbufferedRegion = this->GetOutput()->GetUnbufferedRequestedTemporalRegion(); + const TemporalRegion unbufferedRegion = this->GetOutput()->GetUnbufferedRequestedTemporalRegion(); std::cout << unbufferedRegion << std::endl; // Make sure that the requested output duration matches the unit output // duration - SizeValueType numFramesOut = this->GetOutput()->GetRequestedTemporalRegion().GetFrameDuration(); + const SizeValueType numFramesOut = this->GetOutput()->GetRequestedTemporalRegion().GetFrameDuration(); if (numFramesOut != m_UnitOutputNumberOfFrames) { itkExceptionMacro("Requested non-unit number of output frames"); @@ -359,7 +359,7 @@ class DummyTemporalProcessObject : public TemporalProcessObject // Just pass frames from the input through to the output and add debug info for (SizeValueType i = outputStart; i < outputStart + numFramesOut; ++i) { - DataObject::Pointer newObj = DataObject::New().GetPointer(); + const DataObject::Pointer newObj = DataObject::New().GetPointer(); // Set the output this->GetOutput()->SetObjectAtFrame(i, newObj); @@ -603,8 +603,8 @@ itkTemporalProcessObjectTest(int, char *[]) // Test results of requested region propagation // Set up requested region for the end of the pipeline - itk::TemporalRegion endLargestPossibleRegion = tpo3->GetOutput()->GetLargestPossibleTemporalRegion(); - itk::TemporalRegion finalRequest; + const itk::TemporalRegion endLargestPossibleRegion = tpo3->GetOutput()->GetLargestPossibleTemporalRegion(); + itk::TemporalRegion finalRequest; finalRequest.SetFrameStart(endLargestPossibleRegion.GetFrameStart()); finalRequest.SetFrameDuration(1); itk::TemporalProcessObjectTest::DummyTemporalDataObject * finalOutput = tpo3->GetOutput(); @@ -637,9 +637,9 @@ itkTemporalProcessObjectTest(int, char *[]) tpo3->Update(); // Print out duration of buffered output region - itk::TemporalProcessObjectTest::DummyTemporalDataObject::Pointer outputObject = tpo3->GetOutput(); - OffsetValueType outputStart = outputObject->GetBufferedTemporalRegion().GetFrameStart(); - SizeValueType outputDuration = outputObject->GetBufferedTemporalRegion().GetFrameDuration(); + const itk::TemporalProcessObjectTest::DummyTemporalDataObject::Pointer outputObject = tpo3->GetOutput(); + const OffsetValueType outputStart = outputObject->GetBufferedTemporalRegion().GetFrameStart(); + const SizeValueType outputDuration = outputObject->GetBufferedTemporalRegion().GetFrameDuration(); std::cout << "Buffered Output Region: " << outputStart << "->" << outputStart + outputDuration - 1 << std::endl; // Create a list of CallRecord items representing the correct @@ -799,7 +799,7 @@ itkTemporalProcessObjectTest(int, char *[]) // Reset tpo1 and the requested temporal region of tdo tpo1 = TPOType::New(); - itk::TemporalRegion emptyRegion; + const itk::TemporalRegion emptyRegion; tdo->SetRequestedTemporalRegion(emptyRegion); tpo1->SetInput(tdo); tpo1->UpdateOutputInformation(); diff --git a/Modules/Video/Core/test/itkTemporalRegionTest.cxx b/Modules/Video/Core/test/itkTemporalRegionTest.cxx index c5135872882..588132ae6ac 100644 --- a/Modules/Video/Core/test/itkTemporalRegionTest.cxx +++ b/Modules/Video/Core/test/itkTemporalRegionTest.cxx @@ -35,14 +35,14 @@ itkTemporalRegionTest(int, char *[]) ITK_MACROEND_NOOP_STATEMENT // Test arrays for frame durations - itk::SizeValueType testFrameStart = 0; - itk::SizeValueType testFrameDuration = 20; + const itk::SizeValueType testFrameStart = 0; + const itk::SizeValueType testFrameDuration = 20; // Test time stamps and intervals - itk::RealTimeStamp stamp0; - itk::RealTimeStamp stamp1 = stamp0; - itk::RealTimeInterval oneSecond(1, 0); - itk::RealTimeInterval tenSeconds(10, 0); + const itk::RealTimeStamp stamp0; + itk::RealTimeStamp stamp1 = stamp0; + const itk::RealTimeInterval oneSecond(1, 0); + const itk::RealTimeInterval tenSeconds(10, 0); for (unsigned int i = 0; i < 1000000L; ++i) { stamp1 += oneSecond; @@ -53,10 +53,10 @@ itkTemporalRegionTest(int, char *[]) itk::TemporalRegion regionB; // Check value of regions at init - bool shouldBeTrue = regionA == regionB; + const bool shouldBeTrue = regionA == regionB; CHECK_FOR_VALUE(shouldBeTrue, true); - bool shouldBeFalse = regionA != regionB; + const bool shouldBeFalse = regionA != regionB; CHECK_FOR_VALUE(shouldBeFalse, false); // Set new start times diff --git a/Modules/Video/Core/test/itkVectorImageToVideoTest.cxx b/Modules/Video/Core/test/itkVectorImageToVideoTest.cxx index 38c041fb2f2..2c544de54a1 100644 --- a/Modules/Video/Core/test/itkVectorImageToVideoTest.cxx +++ b/Modules/Video/Core/test/itkVectorImageToVideoTest.cxx @@ -54,7 +54,7 @@ itkVectorImageToVideoTest(int argc, char * argv[]) auto videoFilter = VideoFilterType::New(); videoFilter->SetInput(inputImage); // Arbitrarily set last axis as temporal dimension to split frames - itk::IndexValueType frameAxis = Dimension - 1; + const itk::IndexValueType frameAxis = Dimension - 1; videoFilter->SetFrameAxis(frameAxis); ITK_TEST_SET_GET_VALUE(frameAxis, videoFilter->GetFrameAxis()); diff --git a/Modules/Video/Core/test/itkVideoSourceTest.cxx b/Modules/Video/Core/test/itkVideoSourceTest.cxx index de4acaf66cd..1f50dac5e20 100644 --- a/Modules/Video/Core/test/itkVideoSourceTest.cxx +++ b/Modules/Video/Core/test/itkVideoSourceTest.cxx @@ -75,10 +75,11 @@ class DummyVideoSource : public VideoSource std::cout << "Working on thread " << threadId << std::endl; this->m_Mutex.unlock(); - OutputVideoStreamType * video = this->GetOutput(); - typename OutputVideoStreamType::TemporalRegionType requestedTemporalRegion = video->GetRequestedTemporalRegion(); - SizeValueType startFrame = requestedTemporalRegion.GetFrameStart(); - SizeValueType frameDuration = requestedTemporalRegion.GetFrameDuration(); + OutputVideoStreamType * video = this->GetOutput(); + const typename OutputVideoStreamType::TemporalRegionType requestedTemporalRegion = + video->GetRequestedTemporalRegion(); + const SizeValueType startFrame = requestedTemporalRegion.GetFrameStart(); + const SizeValueType frameDuration = requestedTemporalRegion.GetFrameDuration(); // Just as a check, throw an exception if the duration isn't equal to the // unit output size @@ -112,9 +113,9 @@ CreateEmptyFrame() { auto out = FrameType::New(); - FrameType::RegionType largestRegion; - FrameType::SizeType sizeLR; - FrameType::IndexType startLR{}; + FrameType::RegionType largestRegion; + FrameType::SizeType sizeLR; + const FrameType::IndexType startLR{}; sizeLR[0] = 50; sizeLR[1] = 40; largestRegion.SetSize(sizeLR); @@ -182,7 +183,7 @@ itkVideoSourceTest(int, char *[]) videoSource->GraftOutput(video); // Check that graft worked - VideoType::Pointer videoOut = videoSource->GetOutput(); + const VideoType::Pointer videoOut = videoSource->GetOutput(); if (videoOut->GetLargestPossibleTemporalRegion() != video->GetLargestPossibleTemporalRegion() || videoOut->GetRequestedTemporalRegion() != video->GetRequestedTemporalRegion() || videoOut->GetBufferedTemporalRegion() != video->GetBufferedTemporalRegion()) @@ -204,10 +205,10 @@ itkVideoSourceTest(int, char *[]) videoSource = VideoSourceType::New(); // Set the requested regions on videoSource's output - VideoType::Pointer output = videoSource->GetOutput(); + const VideoType::Pointer output = videoSource->GetOutput(); output->SetRequestedTemporalRegion(requestedRegion); output->InitializeEmptyFrames(); - FrameType::RegionType spatialRegion = frame->GetRequestedRegion(); + const FrameType::RegionType spatialRegion = frame->GetRequestedRegion(); output->SetAllRequestedSpatialRegions(spatialRegion); // Call update to set the requested spatial region to 1 for each requested @@ -215,12 +216,12 @@ itkVideoSourceTest(int, char *[]) videoSource->Update(); // Check the pixel values of the output - SizeValueType frameStart = requestedRegion.GetFrameStart(); - SizeValueType numFrames = requestedRegion.GetFrameDuration(); + const SizeValueType frameStart = requestedRegion.GetFrameStart(); + const SizeValueType numFrames = requestedRegion.GetFrameDuration(); for (SizeValueType i = frameStart; i < frameStart + numFrames; ++i) { frame = videoSource->GetOutput()->GetFrame(i); - FrameType::RegionType region = frame->GetRequestedRegion(); + const FrameType::RegionType region = frame->GetRequestedRegion(); itk::ImageRegionIterator iter(frame, region); while (!iter.IsAtEnd()) { @@ -236,7 +237,7 @@ itkVideoSourceTest(int, char *[]) // get set if (region.GetNumberOfPixels() > 0) { - FrameType::IndexType idx{}; + const FrameType::IndexType idx{}; if (frame->GetPixel(idx) == 1) { std::cerr << "Pixel outside requested spatial region set to 1" << std::endl; @@ -255,7 +256,7 @@ itkVideoSourceTest(int, char *[]) videoSource->UpdateOutputInformation(); // Make sure the requested temporal region of videoSource's output is empty - itk::TemporalRegion emptyRegion; + const itk::TemporalRegion emptyRegion; if (videoSource->GetOutput()->GetRequestedTemporalRegion() != emptyRegion) { std::cerr << "videoSource's output's requested temporal region not empty before propagate" << std::endl; @@ -276,7 +277,7 @@ itkVideoSourceTest(int, char *[]) // Artificially set the output's largest possible temporal region duration itk::TemporalRegion largestTempRegion = videoSource->GetOutput()->GetLargestPossibleTemporalRegion(); - unsigned int newNumBuffers = 25; + const unsigned int newNumBuffers = 25; largestTempRegion.SetFrameDuration(newNumBuffers); videoSource->GetOutput()->SetLargestPossibleTemporalRegion(largestTempRegion); videoSource->GetOutput()->SetRequestedTemporalRegion(emptyRegion); diff --git a/Modules/Video/Core/test/itkVideoStreamTest.cxx b/Modules/Video/Core/test/itkVideoStreamTest.cxx index c4259cf0133..db45f1f9e49 100644 --- a/Modules/Video/Core/test/itkVideoStreamTest.cxx +++ b/Modules/Video/Core/test/itkVideoStreamTest.cxx @@ -116,9 +116,9 @@ itkVideoStreamTest(int, char *[]) video2->SetFrame(2, frame3); // Test retreiving frames - FrameType::Pointer outFrame1 = video2->GetFrame(0); - FrameType::Pointer outFrame2 = video2->GetFrame(1); - FrameType::Pointer outFrame3 = video2->GetFrame(2); + const FrameType::Pointer outFrame1 = video2->GetFrame(0); + const FrameType::Pointer outFrame2 = video2->GetFrame(1); + const FrameType::Pointer outFrame3 = video2->GetFrame(2); if (outFrame3 != frame3 || outFrame2 != frame2 || outFrame1 != frame1) { std::cerr << "Frames not retreived correctly" << std::endl; @@ -163,8 +163,8 @@ itkVideoStreamTest(int, char *[]) // Set the buffered temporal region VideoType::TemporalRegionType temporalRegion; - SizeValueType startFrame = 0; - SizeValueType numFrames = 5; + const SizeValueType startFrame = 0; + const SizeValueType numFrames = 5; temporalRegion.SetFrameStart(startFrame); temporalRegion.SetFrameDuration(numFrames); video1->SetLargestPossibleTemporalRegion(temporalRegion); @@ -175,9 +175,9 @@ itkVideoStreamTest(int, char *[]) video1->InitializeEmptyFrames(); // Set the buffered spatial region for each frame - FrameType::RegionType largestSpatialRegion = SetUpSpatialRegion(100, 100); - FrameType::RegionType requestedSpatialRegion = SetUpSpatialRegion(40, 40); - FrameType::RegionType bufferedSpatialRegion = SetUpSpatialRegion(50, 40); + const FrameType::RegionType largestSpatialRegion = SetUpSpatialRegion(100, 100); + const FrameType::RegionType requestedSpatialRegion = SetUpSpatialRegion(40, 40); + const FrameType::RegionType bufferedSpatialRegion = SetUpSpatialRegion(50, 40); video1->SetAllLargestPossibleSpatialRegions(largestSpatialRegion); video1->SetAllRequestedSpatialRegions(requestedSpatialRegion); video1->SetAllBufferedSpatialRegions(bufferedSpatialRegion); diff --git a/Modules/Video/Core/test/itkVideoToVideoFilterTest.cxx b/Modules/Video/Core/test/itkVideoToVideoFilterTest.cxx index fa85244c518..727f24b8530 100644 --- a/Modules/Video/Core/test/itkVideoToVideoFilterTest.cxx +++ b/Modules/Video/Core/test/itkVideoToVideoFilterTest.cxx @@ -43,9 +43,9 @@ CreateInputFrame(InputPixelType val) { auto out = InputFrameType::New(); - InputFrameType::RegionType largestRegion; - InputFrameType::SizeType sizeLR; - InputFrameType::IndexType startLR{}; + InputFrameType::RegionType largestRegion; + InputFrameType::SizeType sizeLR; + const InputFrameType::IndexType startLR{}; sizeLR[0] = 50; sizeLR[1] = 40; largestRegion.SetSize(sizeLR); @@ -108,13 +108,13 @@ class DummyVideoToVideoFilter : public VideoToVideoFilterGetInput(); OutputVideoStreamType * output = this->GetOutput(); - typename OutputVideoStreamType::TemporalRegionType outReqTempRegion = output->GetRequestedTemporalRegion(); - SizeValueType outputStart = outReqTempRegion.GetFrameStart(); - SizeValueType outputDuration = outReqTempRegion.GetFrameDuration(); + const typename OutputVideoStreamType::TemporalRegionType outReqTempRegion = output->GetRequestedTemporalRegion(); + const SizeValueType outputStart = outReqTempRegion.GetFrameStart(); + const SizeValueType outputDuration = outReqTempRegion.GetFrameDuration(); - typename InputVideoStreamType::TemporalRegionType inReqTempRegion = input->GetRequestedTemporalRegion(); - SizeValueType inputStart = inReqTempRegion.GetFrameStart(); - SizeValueType inputDuration = inReqTempRegion.GetFrameDuration(); + const typename InputVideoStreamType::TemporalRegionType inReqTempRegion = input->GetRequestedTemporalRegion(); + const SizeValueType inputStart = inReqTempRegion.GetFrameStart(); + const SizeValueType inputDuration = inReqTempRegion.GetFrameDuration(); // Print out your threadId std::cout << "Working on thread " << threadId << std::endl; @@ -146,7 +146,7 @@ class DummyVideoToVideoFilter : public VideoToVideoFilterSetLargestPossibleTemporalRegion(inputLargestTemporalRegion); @@ -225,8 +225,8 @@ itkVideoToVideoFilterTest(int, char *[]) std::cout << "Number of output buffers: " << filter->GetOutput()->GetNumberOfBuffers() << std::endl; // Make sure results are correct in the requested spatial region - SizeValueType outputStart = filter->GetOutput()->GetRequestedTemporalRegion().GetFrameStart(); - SizeValueType outputDuration = filter->GetOutput()->GetRequestedTemporalRegion().GetFrameDuration(); + const SizeValueType outputStart = filter->GetOutput()->GetRequestedTemporalRegion().GetFrameStart(); + const SizeValueType outputDuration = filter->GetOutput()->GetRequestedTemporalRegion().GetFrameDuration(); for (SizeValueType i = outputStart; i < outputStart + outputDuration; ++i) { std::cout << "Checking frame: " << i << std::endl; @@ -234,8 +234,8 @@ itkVideoToVideoFilterTest(int, char *[]) const OutputFrameType * frame = filter->GetOutput()->GetFrame(i); itk::ImageRegionConstIterator iter(frame, frame->GetRequestedRegion()); - OutputPixelType expectedVal = ((OutputPixelType)(i)-1.0 + (OutputPixelType)(i)) / 2.0; - OutputPixelType epsilon = .00001; + const OutputPixelType expectedVal = ((OutputPixelType)(i)-1.0 + (OutputPixelType)(i)) / 2.0; + const OutputPixelType epsilon = .00001; while (!iter.IsAtEnd()) { if (iter.Get() < expectedVal - epsilon || iter.Get() > expectedVal + epsilon) @@ -248,7 +248,7 @@ itkVideoToVideoFilterTest(int, char *[]) } // Make sure nothing set outside of requested spatial region - OutputFrameType::IndexType idx{}; + const OutputFrameType::IndexType idx{}; if (frame->GetRequestedRegion().IsInside(idx)) { std::cerr << "Filter set pixel outside of requested region" << std::endl; @@ -267,8 +267,8 @@ itkVideoToVideoFilterTest(int, char *[]) filter->UpdateOutputInformation(); // Make sure the requested spatial regions are empty - SizeValueType startFrame = filter->GetOutput()->GetLargestPossibleTemporalRegion().GetFrameStart(); - SizeValueType numFrames = filter->GetOutput()->GetLargestPossibleTemporalRegion().GetFrameDuration(); + const SizeValueType startFrame = filter->GetOutput()->GetLargestPossibleTemporalRegion().GetFrameStart(); + const SizeValueType numFrames = filter->GetOutput()->GetLargestPossibleTemporalRegion().GetFrameDuration(); if (numFrames == 0) { std::cerr << "Output's largest possible temporal region not set correctly" << std::endl; diff --git a/Modules/Video/Filtering/include/itkDecimateFramesVideoFilter.hxx b/Modules/Video/Filtering/include/itkDecimateFramesVideoFilter.hxx index 7a66b3cb7f4..e66fad34b91 100644 --- a/Modules/Video/Filtering/include/itkDecimateFramesVideoFilter.hxx +++ b/Modules/Video/Filtering/include/itkDecimateFramesVideoFilter.hxx @@ -88,11 +88,11 @@ DecimateFramesVideoFilter::ThreadedGenerateData(const FrameSpatial OutputVideoStreamType * output = this->GetOutput(); // Get input and output frame numbers - typename OutputVideoStreamType::TemporalRegionType outReqTempRegion = output->GetRequestedTemporalRegion(); - SizeValueType outFrameNum = outReqTempRegion.GetFrameStart(); + const typename OutputVideoStreamType::TemporalRegionType outReqTempRegion = output->GetRequestedTemporalRegion(); + const SizeValueType outFrameNum = outReqTempRegion.GetFrameStart(); - typename InputVideoStreamType::TemporalRegionType inReqTempRegion = input->GetRequestedTemporalRegion(); - SizeValueType inFrameNum = inReqTempRegion.GetFrameStart(); + const typename InputVideoStreamType::TemporalRegionType inReqTempRegion = input->GetRequestedTemporalRegion(); + const SizeValueType inFrameNum = inReqTempRegion.GetFrameStart(); // Since we want to support only returning a requested spatial region of the // input frame, we do the pass-through the slow way using iterators rather diff --git a/Modules/Video/Filtering/include/itkFrameAverageVideoFilter.hxx b/Modules/Video/Filtering/include/itkFrameAverageVideoFilter.hxx index ec2f8472916..d9103181348 100644 --- a/Modules/Video/Filtering/include/itkFrameAverageVideoFilter.hxx +++ b/Modules/Video/Filtering/include/itkFrameAverageVideoFilter.hxx @@ -93,15 +93,15 @@ FrameAverageVideoFilter::ThreadedGenerate // Get the input and output video streams const InputVideoStreamType * input = this->GetInput(); OutputVideoStreamType * output = this->GetOutput(); - SizeValueType numFrames = this->TemporalProcessObject::m_UnitInputNumberOfFrames; + const SizeValueType numFrames = this->TemporalProcessObject::m_UnitInputNumberOfFrames; // Get output frame number - typename OutputVideoStreamType::TemporalRegionType outReqTempRegion = output->GetRequestedTemporalRegion(); - SizeValueType outputFrameNumber = outReqTempRegion.GetFrameStart(); + const typename OutputVideoStreamType::TemporalRegionType outReqTempRegion = output->GetRequestedTemporalRegion(); + const SizeValueType outputFrameNumber = outReqTempRegion.GetFrameStart(); - typename InputVideoStreamType::TemporalRegionType inReqTempRegion = input->GetRequestedTemporalRegion(); - SizeValueType inputStart = inReqTempRegion.GetFrameStart(); - SizeValueType inputDuration = inReqTempRegion.GetFrameDuration(); + const typename InputVideoStreamType::TemporalRegionType inReqTempRegion = input->GetRequestedTemporalRegion(); + const SizeValueType inputStart = inReqTempRegion.GetFrameStart(); + const SizeValueType inputDuration = inReqTempRegion.GetFrameDuration(); // Make sure we've got the right duration if (inputDuration != numFrames) diff --git a/Modules/Video/Filtering/include/itkFrameDifferenceVideoFilter.hxx b/Modules/Video/Filtering/include/itkFrameDifferenceVideoFilter.hxx index 909c23c1aa4..5571f9b9daa 100644 --- a/Modules/Video/Filtering/include/itkFrameDifferenceVideoFilter.hxx +++ b/Modules/Video/Filtering/include/itkFrameDifferenceVideoFilter.hxx @@ -96,15 +96,15 @@ FrameDifferenceVideoFilter::ThreadedGener // Get the input and output video streams const InputVideoStreamType * input = this->GetInput(); OutputVideoStreamType * output = this->GetOutput(); - SizeValueType numFrames = this->TemporalProcessObject::m_UnitInputNumberOfFrames; + const SizeValueType numFrames = this->TemporalProcessObject::m_UnitInputNumberOfFrames; // Get output frame number - typename OutputVideoStreamType::TemporalRegionType outReqTempRegion = output->GetRequestedTemporalRegion(); - SizeValueType outputFrameNumber = outReqTempRegion.GetFrameStart(); + const typename OutputVideoStreamType::TemporalRegionType outReqTempRegion = output->GetRequestedTemporalRegion(); + const SizeValueType outputFrameNumber = outReqTempRegion.GetFrameStart(); - typename InputVideoStreamType::TemporalRegionType inReqTempRegion = input->GetRequestedTemporalRegion(); - SizeValueType inputStart = inReqTempRegion.GetFrameStart(); - SizeValueType inputDuration = inReqTempRegion.GetFrameDuration(); + const typename InputVideoStreamType::TemporalRegionType inReqTempRegion = input->GetRequestedTemporalRegion(); + const SizeValueType inputStart = inReqTempRegion.GetFrameStart(); + const SizeValueType inputDuration = inReqTempRegion.GetFrameDuration(); // Make sure we've got the right duration if (inputDuration != numFrames) diff --git a/Modules/Video/Filtering/include/itkImageFilterToVideoFilterWrapper.hxx b/Modules/Video/Filtering/include/itkImageFilterToVideoFilterWrapper.hxx index 636a2556f09..d888bfe8eb4 100644 --- a/Modules/Video/Filtering/include/itkImageFilterToVideoFilterWrapper.hxx +++ b/Modules/Video/Filtering/include/itkImageFilterToVideoFilterWrapper.hxx @@ -59,11 +59,11 @@ ImageFilterToVideoFilterWrapper::TemporalStreamingGenerateD OutputVideoStreamType * output = this->GetOutput(); // Get input and output frame numbers - typename OutputVideoStreamType::TemporalRegionType outReqTempRegion = output->GetRequestedTemporalRegion(); - SizeValueType outFrameNum = outReqTempRegion.GetFrameStart(); + const typename OutputVideoStreamType::TemporalRegionType outReqTempRegion = output->GetRequestedTemporalRegion(); + const SizeValueType outFrameNum = outReqTempRegion.GetFrameStart(); - typename InputVideoStreamType::TemporalRegionType inReqTempRegion = input->GetRequestedTemporalRegion(); - SizeValueType inFrameNum = inReqTempRegion.GetFrameStart(); + const typename InputVideoStreamType::TemporalRegionType inReqTempRegion = input->GetRequestedTemporalRegion(); + const SizeValueType inFrameNum = inReqTempRegion.GetFrameStart(); // Set up the internal image pipeline m_ImageFilter->SetInput(input->GetFrame(inFrameNum)); diff --git a/Modules/Video/Filtering/test/itkFrameAverageVideoFilterTest.cxx b/Modules/Video/Filtering/test/itkFrameAverageVideoFilterTest.cxx index 2dd21898e82..2b7016939f8 100644 --- a/Modules/Video/Filtering/test/itkFrameAverageVideoFilterTest.cxx +++ b/Modules/Video/Filtering/test/itkFrameAverageVideoFilterTest.cxx @@ -51,9 +51,9 @@ CreateInputFrame(InputPixelType val) { auto out = InputFrameType::New(); - InputFrameType::RegionType largestRegion; - InputFrameType::SizeType sizeLR; - InputFrameType::IndexType startLR{}; + InputFrameType::RegionType largestRegion; + InputFrameType::SizeType sizeLR; + const InputFrameType::IndexType startLR{}; sizeLR[0] = 50; sizeLR[1] = 40; largestRegion.SetSize(sizeLR); @@ -102,8 +102,8 @@ itkFrameAverageVideoFilterTest(int argc, char * argv[]) // Set up an input VideoStream - auto inputVideo = InputVideoType::New(); - SizeValueType numInputFrames = 50; + auto inputVideo = InputVideoType::New(); + const SizeValueType numInputFrames = 50; inputVideo->SetNumberOfBuffers(numInputFrames); itk::TemporalRegion inputTempRegion; inputTempRegion.SetFrameStart(0); @@ -155,9 +155,9 @@ itkFrameAverageVideoFilterTest(int argc, char * argv[]) filter->Update(); // Check the results - OutputPixelType expectedVal = (OutputPixelType)(i + (i + 1)) / 2.0; - OutputPixelType actualVal = filter->GetOutput()->GetFrame(i)->GetPixel(checkPx); - double eps = 0.00001; + const OutputPixelType expectedVal = (OutputPixelType)(i + (i + 1)) / 2.0; + const OutputPixelType actualVal = filter->GetOutput()->GetFrame(i)->GetPixel(checkPx); + const double eps = 0.00001; if (expectedVal < actualVal - eps || expectedVal > actualVal + eps) { std::cerr << "Filter failed to compute frame " << i << " correctly over 2 frames." << std::endl; @@ -198,9 +198,9 @@ itkFrameAverageVideoFilterTest(int argc, char * argv[]) filter->Update(); for (unsigned int i = outputStart; i < outputStart + outputDuration; ++i) { - OutputPixelType expectedVal = (OutputPixelType)(i + (i + 1) + (i + 2)) / 3.0; - OutputPixelType actualVal = filter->GetOutput()->GetFrame(i)->GetPixel(checkPx); - double eps = 0.00001; + const OutputPixelType expectedVal = (OutputPixelType)(i + (i + 1) + (i + 2)) / 3.0; + const OutputPixelType actualVal = filter->GetOutput()->GetFrame(i)->GetPixel(checkPx); + const double eps = 0.00001; if (expectedVal < actualVal - eps || expectedVal > actualVal + eps) { std::cerr << "Filter failed to compute frame " << i << " correctly over 3 frames." << std::endl; diff --git a/Modules/Video/Filtering/test/itkFrameDifferenceVideoFilterTest.cxx b/Modules/Video/Filtering/test/itkFrameDifferenceVideoFilterTest.cxx index 1a6db226640..14b4139326c 100644 --- a/Modules/Video/Filtering/test/itkFrameDifferenceVideoFilterTest.cxx +++ b/Modules/Video/Filtering/test/itkFrameDifferenceVideoFilterTest.cxx @@ -51,9 +51,9 @@ CreateInputFrame(InputPixelType val) { auto out = InputFrameType::New(); - InputFrameType::RegionType largestRegion; - InputFrameType::SizeType sizeLR; - InputFrameType::IndexType startLR{}; + InputFrameType::RegionType largestRegion; + InputFrameType::SizeType sizeLR; + const InputFrameType::IndexType startLR{}; sizeLR[0] = 50; sizeLR[1] = 40; largestRegion.SetSize(sizeLR); @@ -91,8 +91,8 @@ itkFrameDifferenceVideoFilterTest(int itkNotUsed(argc), char * itkNotUsed(argv)[ // Set up an input VideoStream - auto inputVideo = InputVideoType::New(); - SizeValueType numInputFrames = 50; + auto inputVideo = InputVideoType::New(); + const SizeValueType numInputFrames = 50; inputVideo->SetNumberOfBuffers(numInputFrames); itk::TemporalRegion inputTempRegion; inputTempRegion.SetFrameStart(0); @@ -143,8 +143,8 @@ itkFrameDifferenceVideoFilterTest(int itkNotUsed(argc), char * itkNotUsed(argv)[ filter->Update(); // Check the results - OutputPixelType expectedVal = 1; - OutputPixelType actualVal = filter->GetOutput()->GetFrame(i)->GetPixel(checkPx); + const OutputPixelType expectedVal = 1; + const OutputPixelType actualVal = filter->GetOutput()->GetFrame(i)->GetPixel(checkPx); if (expectedVal != actualVal) { std::cerr << "Filter failed to compute frame " << i << " correctly for adjacent frames." << std::endl; @@ -185,8 +185,8 @@ itkFrameDifferenceVideoFilterTest(int itkNotUsed(argc), char * itkNotUsed(argv)[ filter->Update(); for (unsigned int i = outputStart; i < outputStart + outputDuration; ++i) { - OutputPixelType expectedVal = 4; // Difference of 2 squared - OutputPixelType actualVal = filter->GetOutput()->GetFrame(i)->GetPixel(checkPx); + const OutputPixelType expectedVal = 4; // Difference of 2 squared + const OutputPixelType actualVal = filter->GetOutput()->GetFrame(i)->GetPixel(checkPx); if (expectedVal != actualVal) { std::cerr << "Filter failed to compute frame " << i << " correctly with offset of 2." << std::endl; diff --git a/Modules/Video/IO/include/itkVideoFileReader.hxx b/Modules/Video/IO/include/itkVideoFileReader.hxx index bb018015d65..a57a7859495 100644 --- a/Modules/Video/IO/include/itkVideoFileReader.hxx +++ b/Modules/Video/IO/include/itkVideoFileReader.hxx @@ -100,7 +100,7 @@ VideoFileReader::UpdateOutputInformation() } const RegionType region(size); - VideoStreamPointer output = this->GetOutput(); + const VideoStreamPointer output = this->GetOutput(); output->SetAllLargestPossibleSpatialRegions(region); output->SetAllBufferedSpatialRegions(region); @@ -188,7 +188,7 @@ VideoFileReader::InitializeVideoIO() } // See if a buffer conversion is needed - IOComponentEnum ioType = ImageIOBase::MapPixelType::CType; + const IOComponentEnum ioType = ImageIOBase::MapPixelType::CType; if (m_VideoIO->GetComponentType() != ioType || m_VideoIO->GetNumberOfComponents() != ConvertPixelTraits::GetNumberOfComponents()) { @@ -219,10 +219,10 @@ VideoFileReader::TemporalStreamingGenerateData() typename VideoStreamType::TemporalRegionType requestedTemporalRegion; output = this->GetOutput(); requestedTemporalRegion = output->GetRequestedTemporalRegion(); - FrameOffsetType frameNum = requestedTemporalRegion.GetFrameStart(); + const FrameOffsetType frameNum = requestedTemporalRegion.GetFrameStart(); // Figure out if we need to skip frames - FrameOffsetType currentIOFrame = m_VideoIO->GetCurrentFrame(); + const FrameOffsetType currentIOFrame = m_VideoIO->GetCurrentFrame(); if (frameNum != currentIOFrame) { m_VideoIO->SetNextFrameToRead(frameNum); @@ -232,8 +232,8 @@ VideoFileReader::TemporalStreamingGenerateData() if (this->m_PixelConversionNeeded) { // Set up temporary buffer for reading - size_t bufferSize = m_VideoIO->GetImageSizeInBytes(); - const auto loadBuffer = make_unique_for_overwrite(bufferSize); + const size_t bufferSize = m_VideoIO->GetImageSizeInBytes(); + const auto loadBuffer = make_unique_for_overwrite(bufferSize); // Read into a temporary buffer this->m_VideoIO->Read(static_cast(loadBuffer.get())); @@ -255,9 +255,9 @@ template void VideoFileReader::DoConvertBuffer(const void * inputData, FrameOffsetType frameNumber) { - PixelType * outputData = this->GetOutput()->GetFrame(frameNumber)->GetPixelContainer()->GetBufferPointer(); - unsigned int numberOfPixels = this->GetOutput()->GetFrame(frameNumber)->GetPixelContainer()->Size(); - bool isVectorImage(strcmp(this->GetOutput()->GetFrame(frameNumber)->GetNameOfClass(), "VectorImage") == 0); + PixelType * outputData = this->GetOutput()->GetFrame(frameNumber)->GetPixelContainer()->GetBufferPointer(); + const unsigned int numberOfPixels = this->GetOutput()->GetFrame(frameNumber)->GetPixelContainer()->Size(); + const bool isVectorImage(strcmp(this->GetOutput()->GetFrame(frameNumber)->GetNameOfClass(), "VectorImage") == 0); #define ITK_CONVERT_BUFFER_IF_BLOCK(_CType, type) \ else if (m_VideoIO->GetComponentType() == _CType) \ { \ diff --git a/Modules/Video/IO/include/itkVideoFileWriter.hxx b/Modules/Video/IO/include/itkVideoFileWriter.hxx index eb65aceeeb3..2377477c254 100644 --- a/Modules/Video/IO/include/itkVideoFileWriter.hxx +++ b/Modules/Video/IO/include/itkVideoFileWriter.hxx @@ -142,8 +142,8 @@ VideoFileWriter::Write() // FIXME: For now we will always request the entire spatial region of each // frame as output - SizeValueType frameStart = m_OutputTemporalRegion.GetFrameStart(); - SizeValueType numFrames = m_OutputTemporalRegion.GetFrameDuration(); + const SizeValueType frameStart = m_OutputTemporalRegion.GetFrameStart(); + const SizeValueType numFrames = m_OutputTemporalRegion.GetFrameDuration(); for (SizeValueType i = frameStart; i < frameStart + numFrames; ++i) { nonConstInput->SetFrameRequestedSpatialRegion(i, input->GetFrameLargestPossibleSpatialRegion(i)); @@ -224,8 +224,8 @@ VideoFileWriter::TemporalStreamingGenerateData() } // Get the frame we're going to write - SizeValueType frameNum = output->GetRequestedTemporalRegion().GetFrameStart(); - const FrameType * frame = input->GetFrame(frameNum); + const SizeValueType frameNum = output->GetRequestedTemporalRegion().GetFrameStart(); + const FrameType * frame = input->GetFrame(frameNum); if (!frame) { itkExceptionMacro("Could not get input frame " << frameNum << " for writing"); @@ -246,7 +246,7 @@ VideoFileWriter::InitializeOutputParameters() } // Get the frame number for the current frame - SizeValueType frameNum = this->GetInput()->GetRequestedTemporalRegion().GetFrameStart(); + const SizeValueType frameNum = this->GetInput()->GetRequestedTemporalRegion().GetFrameStart(); // Get a non-const pointer so we can get spatial regions (VideoStream isn't const correct) const VideoStreamType * input = this->GetInput(); diff --git a/Modules/Video/IO/src/itkFileListVideoIO.cxx b/Modules/Video/IO/src/itkFileListVideoIO.cxx index 1b15211ff88..717a5e51627 100644 --- a/Modules/Video/IO/src/itkFileListVideoIO.cxx +++ b/Modules/Video/IO/src/itkFileListVideoIO.cxx @@ -60,7 +60,7 @@ FileListVideoIO::SplitFileNames(const std::string & fileList) while (pos != std::string::npos && len > 0) { // Get the substring - std::string str = fileList.substr(pos, len); + const std::string str = fileList.substr(pos, len); // Update pos pos = str.find(','); @@ -102,7 +102,7 @@ bool FileListVideoIO::CanReadFile(const char * filename) { // Make sure file names have been specified - std::string strFileName = filename; + const std::string strFileName = filename; std::vector fileList = this->SplitFileNames(strFileName); if (fileList.empty()) { @@ -116,7 +116,7 @@ FileListVideoIO::CanReadFile(const char * filename) } // Make sure we can instantiate an ImageIO to read the first file - ImageIOBase::Pointer ioTemp = + const ImageIOBase::Pointer ioTemp = ImageIOFactory::CreateImageIO(fileList[0].c_str(), ImageIOFactory::IOFileModeEnum::ReadMode); if (ioTemp.IsNull()) { @@ -140,7 +140,7 @@ FileListVideoIO::ReadImageInformation() { // Make sure file can be read - std::string filename = m_FileNames[0]; + const std::string filename = m_FileNames[0]; if (!this->CanReadFile(filename.c_str())) { itkExceptionMacro("Cannot Read File: " << filename); @@ -161,7 +161,7 @@ FileListVideoIO::ReadImageInformation() m_LastIFrame = m_FrameTotal - 1; // Fill dimensions and origin - unsigned int numberOfDimensions = m_ImageIO->GetNumberOfDimensions(); + const unsigned int numberOfDimensions = m_ImageIO->GetNumberOfDimensions(); this->SetNumberOfDimensions(numberOfDimensions); for (unsigned int i = 0; i < numberOfDimensions; ++i) @@ -278,7 +278,7 @@ FileListVideoIO::CanWriteFile(const char * filename) } // Make sure we can instantiate an ImageIO to write the first file - ImageIOBase::Pointer ioTemp = + const ImageIOBase::Pointer ioTemp = ImageIOFactory::CreateImageIO(fileList[0].c_str(), ImageIOFactory::IOFileModeEnum::WriteMode); if (ioTemp.IsNull()) { @@ -463,14 +463,14 @@ FileListVideoIO::VerifyExtensions(const std::vector & fileList) con { for (size_t i = 1; i < fileList.size(); ++i) { - size_t prevExtPos = fileList[i - 1].rfind("."); - size_t extPos = fileList[i].rfind("."); + const size_t prevExtPos = fileList[i - 1].rfind("."); + const size_t extPos = fileList[i].rfind("."); if (prevExtPos == std::string::npos || extPos == std::string::npos) { return false; } - std::string prevExt = fileList[i - 1].substr(prevExtPos + 1, fileList[i - 1].length() - prevExtPos - 1); - std::string ext = fileList[i].substr(extPos + 1, fileList[i].length() - extPos - 1); + const std::string prevExt = fileList[i - 1].substr(prevExtPos + 1, fileList[i - 1].length() - prevExtPos - 1); + const std::string ext = fileList[i].substr(extPos + 1, fileList[i].length() - extPos - 1); if (strcmp(prevExt.c_str(), ext.c_str())) { diff --git a/Modules/Video/IO/src/itkVideoIOFactory.cxx b/Modules/Video/IO/src/itkVideoIOFactory.cxx index 6b932a99904..72e39566251 100644 --- a/Modules/Video/IO/src/itkVideoIOFactory.cxx +++ b/Modules/Video/IO/src/itkVideoIOFactory.cxx @@ -57,7 +57,7 @@ VideoIOFactory::CreateVideoIO(IOModeEnum mode, const char * arg) // Check camera readability if reading from camera else if (mode == IOModeEnum::ReadCameraMode) { - int cameraIndex = std::stoi(arg); + const int cameraIndex = std::stoi(arg); if (j->CanReadCamera(cameraIndex)) { return j; diff --git a/Modules/Video/IO/test/itkFileListVideoIOFactoryTest.cxx b/Modules/Video/IO/test/itkFileListVideoIOFactoryTest.cxx index 7e04d9948ed..358923b9f24 100644 --- a/Modules/Video/IO/test/itkFileListVideoIOFactoryTest.cxx +++ b/Modules/Video/IO/test/itkFileListVideoIOFactoryTest.cxx @@ -47,7 +47,7 @@ test_FileListVideoIOFactory(const char * input, char * output, itk::SizeValueTyp // Create the VideoIOBase for reading from a file ////// std::cout << "Trying to create IO for reading from file..." << std::endl; - itk::VideoIOBase::Pointer ioReadFile = + const itk::VideoIOBase::Pointer ioReadFile = itk::VideoIOFactory::CreateVideoIO(itk::VideoIOFactory::IOModeEnum::ReadFileMode, input); if (!ioReadFile) { @@ -59,7 +59,7 @@ test_FileListVideoIOFactory(const char * input, char * output, itk::SizeValueTyp // Create the VideoIOBase for writing to a file ////// std::cout << "Trying to create IO for writing to file..." << std::endl; - itk::VideoIOBase::Pointer ioWrite = + const itk::VideoIOBase::Pointer ioWrite = itk::VideoIOFactory::CreateVideoIO(itk::VideoIOFactory::IOModeEnum::WriteMode, output); if (!ioWrite) { diff --git a/Modules/Video/IO/test/itkFileListVideoIOTest.cxx b/Modules/Video/IO/test/itkFileListVideoIOTest.cxx index df56aacc63b..6894c7e5eb7 100644 --- a/Modules/Video/IO/test/itkFileListVideoIOTest.cxx +++ b/Modules/Video/IO/test/itkFileListVideoIOTest.cxx @@ -48,7 +48,7 @@ test_FileListVideoIO(const char * input, int ret = EXIT_SUCCESS; // Create the VideoIO - itk::FileListVideoIO::Pointer fileListIO = itk::FileListVideoIO::New(); + const itk::FileListVideoIO::Pointer fileListIO = itk::FileListVideoIO::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(fileListIO, FileListVideoIO, VideoIOBase); @@ -65,7 +65,7 @@ test_FileListVideoIO(const char * input, } // Test CanReadFile on non-existant file - std::string nonExistantFile = "Bad/Path/To/Nothing"; + const std::string nonExistantFile = "Bad/Path/To/Nothing"; if (fileListIO->CanReadFile(nonExistantFile.c_str())) { std::cerr << "Should have failed to open \"" << nonExistantFile << '"' << std::endl; @@ -98,7 +98,7 @@ test_FileListVideoIO(const char * input, paramMessage << "Height mismatch: (expected) " << inHeight << " != (got) " << fileListIO->GetDimensions(1) << std::endl; } - double epsilon = 0.0001; + const double epsilon = 0.0001; if (!itk::Math::FloatAlmostEqual(fileListIO->GetFramesPerSecond(), inFpS, 10, epsilon)) { infoSet = false; @@ -138,8 +138,8 @@ test_FileListVideoIO(const char * input, reader->Update(); // Read the image using FileListVideoIO - size_t bufferSize = fileListIO->GetImageSizeInBytes(); - auto * buffer = new PixelType[bufferSize]; + const size_t bufferSize = fileListIO->GetImageSizeInBytes(); + auto * buffer = new PixelType[bufferSize]; fileListIO->Read(static_cast(buffer)); // Compare Spacing, Origin, Direction @@ -177,7 +177,7 @@ test_FileListVideoIO(const char * input, std::cout << "FileListVideoIO::SetNextFrameToRead" << std::endl; // try seeking to the end - SizeValueType seekFrame = fileListIO->GetFrameTotal() - 1; + const SizeValueType seekFrame = fileListIO->GetFrameTotal() - 1; if (!fileListIO->SetNextFrameToRead(seekFrame)) { std::cerr << "Failed to seek to second I-Frame..." << std::endl; @@ -185,11 +185,11 @@ test_FileListVideoIO(const char * input, } // Save the current parameters - double fps = fileListIO->GetFramesPerSecond(); - unsigned int width = fileListIO->GetDimensions(0); - unsigned int height = fileListIO->GetDimensions(1); - const char * fourCC = "MP42"; - unsigned int nChannels = fileListIO->GetNumberOfComponents(); + const double fps = fileListIO->GetFramesPerSecond(); + unsigned int width = fileListIO->GetDimensions(0); + unsigned int height = fileListIO->GetDimensions(1); + const char * fourCC = "MP42"; + const unsigned int nChannels = fileListIO->GetNumberOfComponents(); // Reset the VideoIO fileListIO->FinishReadingOrWriting(); @@ -240,8 +240,8 @@ test_FileListVideoIO(const char * input, fileListIO->SetFileName(output); // Set up a two more VideoIOs to read while we're writing - itk::FileListVideoIO::Pointer fileListIO2 = itk::FileListVideoIO::New(); - itk::FileListVideoIO::Pointer fileListIO3 = itk::FileListVideoIO::New(); + const itk::FileListVideoIO::Pointer fileListIO2 = itk::FileListVideoIO::New(); + const itk::FileListVideoIO::Pointer fileListIO3 = itk::FileListVideoIO::New(); fileListIO2->SetFileName(input); fileListIO2->ReadImageInformation(); fileListIO3->SetFileName(output); @@ -250,8 +250,8 @@ test_FileListVideoIO(const char * input, for (unsigned int i = 0; i < inNumFrames; ++i) { // Set up a buffer to read to - size_t bufferSize = fileListIO2->GetImageSizeInBytes(); - auto * buffer = new PixelType[bufferSize]; + const size_t bufferSize = fileListIO2->GetImageSizeInBytes(); + auto * buffer = new PixelType[bufferSize]; // Read into the buffer fileListIO2->Read(static_cast(buffer)); diff --git a/Wrapping/Generators/Python/PyUtils/itkPyCommand.cxx b/Wrapping/Generators/Python/PyUtils/itkPyCommand.cxx index 431808b0894..8674b066d37 100644 --- a/Wrapping/Generators/Python/PyUtils/itkPyCommand.cxx +++ b/Wrapping/Generators/Python/PyUtils/itkPyCommand.cxx @@ -47,14 +47,14 @@ PyCommand::~PyCommand() { if (this->m_Object) { - PyGILStateEnsure gil; + const PyGILStateEnsure gil; Py_DECREF(this->m_Object); } this->m_Object = nullptr; if (this->m_EmptyArgumentList) { - PyGILStateEnsure gil; + const PyGILStateEnsure gil; Py_DECREF(this->m_EmptyArgumentList); } this->m_EmptyArgumentList = nullptr; @@ -66,7 +66,7 @@ PyCommand::SetCommandCallable(PyObject * o) { if (o != this->m_Object) { - PyGILStateEnsure gil; + const PyGILStateEnsure gil; if (this->m_Object) { // get rid of our reference @@ -120,8 +120,8 @@ PyCommand::PyExecute() } else { - PyGILStateEnsure gil; - PyObject * result = PyObject_Call(this->m_Object, this->m_EmptyArgumentList, (PyObject *)nullptr); + const PyGILStateEnsure gil; + PyObject * result = PyObject_Call(this->m_Object, this->m_EmptyArgumentList, (PyObject *)nullptr); if (result) {