Skip to content

Commit

Permalink
ENH: Add missing getter/boolean macro methods
Browse files Browse the repository at this point in the history
Add missing getter/boolean macro methods to boolean ivars across
miscellaneous classes.
  • Loading branch information
jhlegarreta authored and hjmjohnson committed Jan 16, 2022
1 parent 379f5e0 commit 4db7880
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 15 deletions.
2 changes: 2 additions & 0 deletions Modules/Core/Mesh/include/itkImageToParametricSpaceFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ class ITK_TEMPLATE_EXPORT ImageToParametricSpaceFilter : public ImageToMeshFilte
* mesh is capable of accepting an itk::Index through
* an operator=(). Default value = true */
itkSetMacro(ComputeIndices, bool);
itkGetConstMacro(ComputeIndices, bool);
itkBooleanMacro(ComputeIndices);

protected:
ImageToParametricSpaceFilter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ itkImageToParametricSpaceFilterTest(int, char *[])
ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, ImageToParametricSpaceFilter, ImageToMeshFilter);


bool computeIndices = true;
ITK_TEST_SET_GET_BOOLEAN(filter, ComputeIndices, computeIndices);

// Connect the inputs
filter->SetInput(0, imageX);
filter->SetInput(1, imageY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class ITK_TEMPLATE_EXPORT ComparisonImageFilter : public ImageToImageFilter<TInp
* Default = false */
itkSetMacro(IgnoreBoundaryPixels, bool);
itkGetConstMacro(IgnoreBoundaryPixels, bool);
itkBooleanMacro(IgnoreBoundaryPixels);

/** Get statistical attributes for those pixels which exceed the
* tolerance and radius parameters */
Expand Down
2 changes: 1 addition & 1 deletion Modules/Filtering/ImageCompare/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ itk_add_test(NAME itkTestingComparisonImageFilterTest
COMMAND ITKImageCompareTestDriver
--compare DATA{Input/itkTestingComparisonImageFilterTest.png}
${ITK_TEST_OUTPUT_DIR}/itkTestingComparisonImageFilterTest.png
itkTestingComparisonImageFilterTest DATA{${ITK_DATA_ROOT}/Input/cake_easy.png} DATA{${ITK_DATA_ROOT}/Input/cake_hard.png} ${ITK_TEST_OUTPUT_DIR}/itkTestingComparisonImageFilterTest.png 10 1 1647 11 66 16.2999 26846
itkTestingComparisonImageFilterTest DATA{${ITK_DATA_ROOT}/Input/cake_easy.png} DATA{${ITK_DATA_ROOT}/Input/cake_hard.png} ${ITK_TEST_OUTPUT_DIR}/itkTestingComparisonImageFilterTest.png 0 10 1 1647 11 66 16.2999 26846
)
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
int
itkTestingComparisonImageFilterTest(int argc, char * argv[])
{
if (argc < 11)
if (argc < 12)
{
std::cerr << "Usage: " << std::endl;
std::cerr << itkNameOfTestExecutableMacro(argv);
std::cerr << " inputImageFile1 inputImageFile2 outputImage threshold radius numberOfPixelsWithDifferences "
"minimumDifference maximumDifference meanDifference totalDifference"
std::cerr << " inputImageFile1 inputImageFile2 outputImage ignoreBoundaryPixels threshold radius "
"numberOfPixelsWithDifferences minimumDifference maximumDifference meanDifference totalDifference"
<< std::endl;
return EXIT_FAILURE;
}
Expand Down Expand Up @@ -66,11 +66,14 @@ itkTestingComparisonImageFilterTest(int argc, char * argv[])


// setup the filter
auto differenceThreshold = static_cast<typename FilterType::OutputPixelType>(std::stoi(argv[4]));
auto ignoreBoundaryPixels = static_cast<bool>(std::stoi(argv[4]));
ITK_TEST_SET_GET_BOOLEAN(filter, IgnoreBoundaryPixels, ignoreBoundaryPixels);

auto differenceThreshold = static_cast<typename FilterType::OutputPixelType>(std::stoi(argv[5]));
filter->SetDifferenceThreshold(differenceThreshold);
TEST_SET_GET_VALUE(differenceThreshold, filter->GetDifferenceThreshold());

int toleranceRadius = std::stoi(argv[5]);
int toleranceRadius = std::stoi(argv[6]);
filter->SetToleranceRadius(toleranceRadius);
TEST_SET_GET_VALUE(toleranceRadius, filter->GetToleranceRadius());

Expand All @@ -94,15 +97,15 @@ itkTestingComparisonImageFilterTest(int argc, char * argv[])
unsigned long numberOfPixelsWithDifferences = filter->GetNumberOfPixelsWithDifferences();

char * end;
ITK_TEST_EXPECT_EQUAL(numberOfPixelsWithDifferences, std::strtoul(argv[6], &end, 10));
ITK_TEST_EXPECT_EQUAL(numberOfPixelsWithDifferences, std::strtoul(argv[7], &end, 10));

auto minimumDifference = static_cast<typename FilterType::OutputPixelType>(std::stod(argv[7]));
auto minimumDifference = static_cast<typename FilterType::OutputPixelType>(std::stod(argv[8]));
ITK_TEST_EXPECT_EQUAL(minimumDifference, filter->GetMinimumDifference());

auto maximumDifference = static_cast<typename FilterType::OutputPixelType>(std::stod(argv[8]));
auto maximumDifference = static_cast<typename FilterType::OutputPixelType>(std::stod(argv[9]));
ITK_TEST_EXPECT_EQUAL(maximumDifference, filter->GetMaximumDifference());

auto meanDifference = static_cast<typename FilterType::RealType>(std::stod(argv[9]));
auto meanDifference = static_cast<typename FilterType::RealType>(std::stod(argv[10]));

const double epsilon = 1e-4;
std::cout.precision(static_cast<int>(itk::Math::abs(std::log10(epsilon))));
Expand All @@ -117,7 +120,7 @@ itkTestingComparisonImageFilterTest(int argc, char * argv[])
return EXIT_FAILURE;
}

auto totalDifference = static_cast<typename FilterType::AccumulateType>(std::stod(argv[10]));
auto totalDifference = static_cast<typename FilterType::AccumulateType>(std::stod(argv[11]));
ITK_TEST_EXPECT_EQUAL(totalDifference, filter->GetTotalDifference());

// Change test input spacing to test that comparison filter fails if spacings are different
Expand Down
1 change: 1 addition & 0 deletions Modules/Numerics/Optimizers/include/itkFRPROptimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class ITKOptimizers_EXPORT FRPROptimizer : public PowellOptimizer
/** Convert gradient to a unit length vector */
itkSetMacro(UseUnitLengthGradient, bool);
itkGetConstMacro(UseUnitLengthGradient, bool);
itkBooleanMacro(UseUnitLengthGradient);

/** Start optimization. */
void
Expand Down
3 changes: 3 additions & 0 deletions Modules/Numerics/Optimizers/test/itkFRPROptimizerTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ itkFRPROptimizerTest(int, char *[])
itkOptimizer->SetMaximize(false);
itkOptimizer->SetMaximumIteration(50);

bool useUnitLengthGradient = false;
ITK_TEST_SET_GET_BOOLEAN(itkOptimizer, UseUnitLengthGradient, useUnitLengthGradient);

{
// Exercise the methods that set the optimization mode
std::cout << "Testing Fletch Reeves Mode" << std::endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class ITK_TEMPLATE_EXPORT OnePlusOneEvolutionaryOptimizerv4

itkGetConstReferenceMacro(CatchGetValueException, bool);
itkSetMacro(CatchGetValueException, bool);
itkBooleanMacro(CatchGetValueException);

itkGetConstReferenceMacro(MetricWorstPossibleValue, double);
itkSetMacro(MetricWorstPossibleValue, double);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class ITK_TEMPLATE_EXPORT PowellOptimizerv4 : public ObjectToObjectOptimizerBase

itkGetConstReferenceMacro(CatchGetValueException, bool);
itkSetMacro(CatchGetValueException, bool);
itkBooleanMacro(CatchGetValueException);

itkGetConstReferenceMacro(MetricWorstPossibleValue, double);
itkSetMacro(MetricWorstPossibleValue, double);
Expand Down
2 changes: 1 addition & 1 deletion Modules/Numerics/Optimizersv4/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ itk_add_test(NAME itkExhaustiveOptimizerv4Test

itk_add_test(NAME itkPowellOptimizerv4Test
COMMAND ITKOptimizersv4TestDriver
itkPowellOptimizerv4Test 10 0.01 0.1 100 100 0.0)
itkPowellOptimizerv4Test 10 0.01 0.1 100 100 0 0.0)

itk_add_test(NAME itkOnePlusOneEvolutionaryOptimizerv4Test
COMMAND ITKOptimizersv4TestDriver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ itkOnePlusOneEvolutionaryOptimizerv4Test(int, char *[])
auto generator = GeneratorType::New();
itkOptimizer->SetNormalVariateGenerator(generator);

bool catchGetValueException = false;
ITK_TEST_SET_GET_BOOLEAN(itkOptimizer, CatchGetValueException, catchGetValueException);

// Set the initial position by setting the metric
// parameters.
std::cout << "Set metric parameters." << std::endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ class PowellBoundedMetric : public itk::ObjectToObjectMetricBase
int
itkPowellOptimizerv4Test(int argc, char * argv[])
{
if (argc != 7)
if (argc != 8)
{
std::cerr << "Missing parameters." << std::endl;
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv)
<< " stepLength stepTolerance valueTolerance maximumIteration maximumLineIteration "
" metricWorstPossibleValue"
"catchGetValueException metricWorstPossibleValue"
<< std::endl;
return EXIT_FAILURE;
}
Expand Down Expand Up @@ -204,7 +204,10 @@ itkPowellOptimizerv4Test(int argc, char * argv[])
itkOptimizer->SetMaximumLineIteration(maximumLineIteration);
ITK_TEST_SET_GET_VALUE(maximumLineIteration, itkOptimizer->GetMaximumLineIteration());

auto metricWorstPossibleValue = std::stod(argv[6]);
auto catchGetValueException = static_cast<bool>(std::stoi(argv[6]));
ITK_TEST_SET_GET_BOOLEAN(itkOptimizer, CatchGetValueException, catchGetValueException);

auto metricWorstPossibleValue = std::stod(argv[7]);
itkOptimizer->SetMetricWorstPossibleValue(metricWorstPossibleValue);
ITK_TEST_SET_GET_VALUE(metricWorstPossibleValue, itkOptimizer->GetMetricWorstPossibleValue());

Expand Down

0 comments on commit 4db7880

Please sign in to comment.