From 97a6b89f150c0ab616f5c0153a324057acdbe31b Mon Sep 17 00:00:00 2001 From: Nick Tustison Date: Tue, 25 Jul 2023 19:00:36 -0700 Subject: [PATCH] BUG: Avoid divide by 0. --- Examples/itkantsRegistrationHelper.hxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Examples/itkantsRegistrationHelper.hxx b/Examples/itkantsRegistrationHelper.hxx index 3ca3dd3ee..f496805d9 100644 --- a/Examples/itkantsRegistrationHelper.hxx +++ b/Examples/itkantsRegistrationHelper.hxx @@ -3712,9 +3712,16 @@ RegistrationHelper::CalculateMeshSizeForSpecified for (unsigned int d = 0; d < ImageDimension; d++) { + if (itk::Math::FloatAlmostEqual(knotSpacing, itk::NumericTraits::ZeroValue())) + { + meshSize.push_back(itk::NumericTraits::ZeroValue()); + } + else + { RealType domain = static_cast(inputImage->GetLargestPossibleRegion().GetSize()[d] - 1) * static_cast(inputImage->GetSpacing()[d]); meshSize.push_back(static_cast(std::ceil(domain / knotSpacing))); + } // unsigned long extraPadding = static_cast( // ( numberOfSpans * splineDistance - domain ) / inputImage->GetSpacing()[d] + 0.5 ); // lowerBound[d] = static_cast( 0.5 * extraPadding );