From b8685d47094fa0c743bd10a6cc334a6f83bdf464 Mon Sep 17 00:00:00 2001 From: Hans Johnson Date: Sat, 13 Apr 2024 08:38:20 -0500 Subject: [PATCH] COMP: Add coverage IsCongruentImageGeometry IsSameImageGeometryAs --- Modules/Core/Common/include/itkImageBase.hxx | 8 +++----- Modules/Core/Common/test/itkImageTest.cxx | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Modules/Core/Common/include/itkImageBase.hxx b/Modules/Core/Common/include/itkImageBase.hxx index f67fd5f4193..e03b5e05941 100644 --- a/Modules/Core/Common/include/itkImageBase.hxx +++ b/Modules/Core/Common/include/itkImageBase.hxx @@ -347,14 +347,13 @@ template bool ImageBase::RequestedRegionIsOutsideOfTheBufferedRegion() { - unsigned int i; const IndexType & requestedRegionIndex = this->GetRequestedRegion().GetIndex(); const IndexType & bufferedRegionIndex = this->GetBufferedRegion().GetIndex(); const SizeType & requestedRegionSize = this->GetRequestedRegion().GetSize(); const SizeType & bufferedRegionSize = this->GetBufferedRegion().GetSize(); - for (i = 0; i < VImageDimension; ++i) + for (unsigned int i = 0; i < VImageDimension; ++i) { if ((requestedRegionIndex[i] < bufferedRegionIndex[i]) || ((requestedRegionIndex[i] + static_cast(requestedRegionSize[i])) > @@ -372,8 +371,7 @@ template bool ImageBase::VerifyRequestedRegion() { - bool retval = true; - unsigned int i; + bool retval = true; // Is the requested region within the LargestPossibleRegion? // Note that the test is indeed against the largest possible region @@ -384,7 +382,7 @@ ImageBase::VerifyRequestedRegion() const SizeType & requestedRegionSize = this->GetRequestedRegion().GetSize(); const SizeType & largestPossibleRegionSize = this->GetLargestPossibleRegion().GetSize(); - for (i = 0; i < VImageDimension; ++i) + for (unsigned int i = 0; i < VImageDimension; ++i) { if ((requestedRegionIndex[i] < largestPossibleRegionIndex[i]) || ((requestedRegionIndex[i] + static_cast(requestedRegionSize[i])) > diff --git a/Modules/Core/Common/test/itkImageTest.cxx b/Modules/Core/Common/test/itkImageTest.cxx index 11d511668f5..f96dca483f2 100644 --- a/Modules/Core/Common/test/itkImageTest.cxx +++ b/Modules/Core/Common/test/itkImageTest.cxx @@ -49,8 +49,7 @@ itkImageTest(int, char *[]) { using Image = itk::Image; - auto image = Image::New(); - Image::ConstPointer myconstptr = image; + auto image = Image::New(); image->DebugOn(); const char * const knownStringName = "My First Image For Testing."; image->SetObjectName(knownStringName); @@ -234,5 +233,16 @@ itkImageTest(int, char *[]) return EXIT_FAILURE; } + // Test that a const pointer can be instantiated from a non-const pointer + Image::ConstPointer myconstptr = image; + if (!image->IsCongruentImageGeometry(myconstptr, 0.0, 0.0)) + { + std::cerr << "Image compare to self fails IsCongruentImageGeometry" << std::endl; + } + if (!image->IsSameImageGeometryAs(myconstptr, 0.0, 0.0)) + { + std::cerr << "Image compare to self fails IsSameImageGeometryAs" << std::endl; + } + return (EXIT_SUCCESS); }