Skip to content

Commit

Permalink
COMP: Add coverage IsCongruentImageGeometry IsSameImageGeometryAs
Browse files Browse the repository at this point in the history
  • Loading branch information
hjmjohnson committed Apr 17, 2024
1 parent 2a1265d commit b8685d4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
8 changes: 3 additions & 5 deletions Modules/Core/Common/include/itkImageBase.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -347,14 +347,13 @@ template <unsigned int VImageDimension>
bool
ImageBase<VImageDimension>::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<OffsetValueType>(requestedRegionSize[i])) >
Expand All @@ -372,8 +371,7 @@ template <unsigned int VImageDimension>
bool
ImageBase<VImageDimension>::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
Expand All @@ -384,7 +382,7 @@ ImageBase<VImageDimension>::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<OffsetValueType>(requestedRegionSize[i])) >
Expand Down
14 changes: 12 additions & 2 deletions Modules/Core/Common/test/itkImageTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ itkImageTest(int, char *[])
{

using Image = itk::Image<float, 2>;
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);
Expand Down Expand Up @@ -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);
}

0 comments on commit b8685d4

Please sign in to comment.