Skip to content

Commit

Permalink
COMP: Fix building with ITK_USE_FLOAT_SPACE_PRECISION=ON
Browse files Browse the repository at this point in the history
Need to match precision for types used to allow building.
In a few cases double precision was assumed for values
related to spacing precision.
  • Loading branch information
hjmjohnson committed Dec 18, 2024
1 parent cad4297 commit c9b342e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
3 changes: 2 additions & 1 deletion Examples/DataRepresentation/Image/Image4.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,8 @@ main(int, char *[])
image->GetDirection();
const ImageType::PointType & ImageOrigin = image->GetOrigin();

using VectorType = itk::Vector<double, Dimension>;
using VectorType =
itk::Vector<ImageType::PointType::CoordinateType, Dimension>;
VectorType LeftEyeIndexVector;
LeftEyeIndexVector[0] = LeftEyeIndex[0];
LeftEyeIndexVector[1] = LeftEyeIndex[1];
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkImageAlgorithm.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ ImageAlgorithm::EnlargeRegionOverBox(const typename InputImageType::RegionType &
{
numberOfInputCorners *= 2;
}
using ContinuousIndexValueType = double;
using ContinuousIndexValueType = ContinuousIndex<SpacePrecisionType>::ValueType;
using ContinuousInputIndexType = ContinuousIndex<ContinuousIndexValueType, InputImageType::ImageDimension>;
using ContinuousOutputIndexType = ContinuousIndex<ContinuousIndexValueType, OutputImageType::ImageDimension>;

Expand Down Expand Up @@ -241,7 +241,7 @@ ImageAlgorithm::EnlargeRegionOverBox(const typename InputImageType::RegionType &

using InputPointType = Point<SpacePrecisionType, InputImageType::ImageDimension>;
const InputPointType inputPoint =
inputImage->template TransformContinuousIndexToPhysicalPoint<SpacePrecisionType, SpacePrecisionType>(
inputImage->template TransformContinuousIndexToPhysicalPoint<SpacePrecisionType, ContinuousIndexValueType>(
currentInputCornerIndex);
using OutputPointType = Point<SpacePrecisionType, OutputImageType::ImageDimension>;
OutputPointType outputPoint{};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,6 @@ itkPhysicalPointImageSourceTest(int argc, char * argv[])

ITK_EXERCISE_BASIC_OBJECT_METHODS(physicalPointImageSource, PhysicalPointImageSource, GenerateImageSource);


double theta = 0;
if (argc >= 4)
{
theta = std::stod(argv[3]);
}

int testStatus = EXIT_SUCCESS;
auto spacing = itk::MakeFilled<ImageType::SpacingType>(1.0);
ImageType::PointType origin{};
Expand All @@ -129,7 +122,8 @@ itkPhysicalPointImageSourceTest(int argc, char * argv[])
}
else
{
itk::SpacePrecisionType M[] = { std::cos(theta), -std::sin(theta), std::sin(theta), std::cos(theta) };
const itk::SpacePrecisionType theta = (argc >= 4) ? std::stod(argv[3]) : 0;
itk::SpacePrecisionType M[] = { std::cos(theta), -std::sin(theta), std::sin(theta), std::cos(theta) };

direction = vnl_matrix<itk::SpacePrecisionType>(M, 2, 2);
testStatus = itkPhysicalPointImageSourceTest<itk::VectorImage<float, ImageDimension>>(
Expand Down

0 comments on commit c9b342e

Please sign in to comment.