Skip to content

Commit

Permalink
STYLE: Clarify estimation ray position RayCastInterpolateImageFunction
Browse files Browse the repository at this point in the history
`RayCastInterpolateImageFunction::Evaluate` did specify the ray position
by `point - origin`, which appears somewhat unclear, because
`point - origin` yields a `Vector`, not a `Point`.

This commit explicitly declares the ray position as `Point`. It also
declares a `spacing` variable, to avoid redundant repetitive calls to
`TInputImage::GetSpacing()`.
  • Loading branch information
N-Dekker authored and hjmjohnson committed Feb 27, 2022
1 parent dc70e38 commit e4841aa
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1416,10 +1416,17 @@ RayCastInterpolateImageFunction<TInputImage, TCoordRep>::Evaluate(const PointTyp
ray.ZeroState();
ray.Initialise();

PointType origin = this->m_Image->GetOrigin();
for (unsigned int i = 0; i < origin.Length; ++i)
origin[i] -= 0.5 * this->m_Image->GetSpacing()[i];
ray.SetRay(point - origin, direction);
const PointType origin = this->m_Image->GetOrigin();
const auto spacing = this->m_Image->GetSpacing();

PointType rayPosition = point;

for (unsigned int i = 0; i < PointType::Length; ++i)
{
rayPosition[i] -= origin[i] - 0.5 * spacing[i];
}

ray.SetRay(rayPosition, direction);
ray.IntegrateAboveThreshold(integral, m_Threshold);

return (static_cast<OutputType>(integral));
Expand Down

0 comments on commit e4841aa

Please sign in to comment.