From 25f7948f36698bd52504d2930e39ae1fea7e8dc4 Mon Sep 17 00:00:00 2001 From: Bradley Lowekamp Date: Thu, 7 Nov 2024 10:11:23 -0500 Subject: [PATCH] COMP: Fix OrientImageFilter tests with options Support ITK_FUTURE_LEGACY_REMOVE for OrientImageFilter tests. Update itkOrientImageFilterTest.cxx to use new AnatomicalOrientation enums, and mark itkOrientImageFilterTest2.cxx to be removed. --- .../Filtering/ImageGrid/test/CMakeLists.txt | 6 ++++- .../test/itkOrientImageFilterTest.cxx | 23 ++++++++----------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Modules/Filtering/ImageGrid/test/CMakeLists.txt b/Modules/Filtering/ImageGrid/test/CMakeLists.txt index 9abaac48944..541f8cc28a3 100644 --- a/Modules/Filtering/ImageGrid/test/CMakeLists.txt +++ b/Modules/Filtering/ImageGrid/test/CMakeLists.txt @@ -31,7 +31,6 @@ set(ITKImageGridTests itkPasteImageFilterTest.cxx itkPermuteAxesImageFilterTest.cxx itkOrientImageFilterTest.cxx - itkOrientImageFilterTest2.cxx itkWarpImageFilterTest.cxx itkWarpImageFilterTest2.cxx itkWarpVectorImageFilterTest.cxx @@ -55,6 +54,11 @@ set(ITKImageGridTests itkSliceBySliceImageFilterTest.cxx itkPadImageFilterTest.cxx) +if( NOT ITK_FUTURE_LEGACY_REMOVE) + list(APPEND ITKImageGridTests itkOrientImageFilterTest2.cxx) +endif() + + createtestdriver(ITKImageGrid "${ITKImageGrid-Test_LIBRARIES}" "${ITKImageGridTests}") itk_add_test( diff --git a/Modules/Filtering/ImageGrid/test/itkOrientImageFilterTest.cxx b/Modules/Filtering/ImageGrid/test/itkOrientImageFilterTest.cxx index 2b8a0a040f2..9443036752c 100644 --- a/Modules/Filtering/ImageGrid/test/itkOrientImageFilterTest.cxx +++ b/Modules/Filtering/ImageGrid/test/itkOrientImageFilterTest.cxx @@ -16,7 +16,6 @@ * *=========================================================================*/ -#define ITK_LEGACY_SILENT #include "itkOrientImageFilter.h" #include "itkImageToImageFilter.h" #include "itkTestingMacros.h" @@ -83,20 +82,18 @@ itkOrientImageFilterTest(int argc, char * argv[]) auto useImageDirection = static_cast(std::stoi(argv[1])); ITK_TEST_SET_GET_BOOLEAN(orienter, UseImageDirection, useImageDirection); - orienter->SetGivenCoordinateOrientation( - itk::SpatialOrientationEnums::ValidCoordinateOrientations::ITK_COORDINATE_ORIENTATION_RIP); + orienter->SetGivenCoordinateOrientation(itk::AnatomicalOrientation::PositiveEnum::LSA); orienter->SetInput(randImage); // Try permuting axes - orienter->SetDesiredCoordinateOrientation( - itk::SpatialOrientationEnums::ValidCoordinateOrientations::ITK_COORDINATE_ORIENTATION_IRP); + orienter->SetDesiredCoordinateOrientation(itk::AnatomicalOrientation::PositiveEnum::SLA); orienter->Update(); - ImageType::Pointer IRP = orienter->GetOutput(); - std::cerr << "IRP" << std::endl; - PrintImg(IRP); + ImageType::Pointer SLA = orienter->GetOutput(); + std::cerr << "SLA" << std::endl; + PrintImg(SLA); ImageType::RegionType::SizeType originalSize = randImage->GetLargestPossibleRegion().GetSize(); - ImageType::RegionType::SizeType transformedSize = IRP->GetLargestPossibleRegion().GetSize(); + ImageType::RegionType::SizeType transformedSize = SLA->GetLargestPossibleRegion().GetSize(); ImageType::IndexType originalIndex, transformedIndex; for (originalIndex[2] = transformedIndex[2] = 0; @@ -112,7 +109,7 @@ itkOrientImageFilterTest(int argc, char * argv[]) originalIndex[0]++, transformedIndex[1]++) { ImageType::PixelType orig = randImage->GetPixel(originalIndex); - ImageType::PixelType xfrm = IRP->GetPixel(transformedIndex); + ImageType::PixelType xfrm = SLA->GetPixel(transformedIndex); if (orig != xfrm) { return EXIT_FAILURE; @@ -124,10 +121,8 @@ itkOrientImageFilterTest(int argc, char * argv[]) // Go to LIP to check flipping an axis orienter = itk::OrientImageFilter::New(); orienter->SetInput(randImage); - orienter->SetGivenCoordinateOrientation( - itk::SpatialOrientationEnums::ValidCoordinateOrientations::ITK_COORDINATE_ORIENTATION_RIP); - orienter->SetDesiredCoordinateOrientation( - itk::SpatialOrientationEnums::ValidCoordinateOrientations::ITK_COORDINATE_ORIENTATION_LIP); + orienter->SetGivenCoordinateOrientation(itk::AnatomicalOrientation::NegativeEnum::RIP); + orienter->SetDesiredCoordinateOrientation(itk::AnatomicalOrientation::NegativeEnum::LIP); orienter->Update(); ImageType::Pointer LIP = orienter->GetOutput(); std::cerr << "LIP" << std::endl;