Skip to content

Commit

Permalink
PERF: Make m_ObjectToWorldTransformInverse->TransformPoint non-virtual
Browse files Browse the repository at this point in the history
Suppressed the virtual call mechanism for
`m_ObjectToWorldTransformInverse->TransformPoint(point)` by explicit
qualification with the `TransformType` scope, in the five `SpatialObject`
"InWorldSpace" member functions.

A performance improvement of more than 13 % was observed, from more than 0.36
sec. (before this commit) to less than 0.31 sec. (after this commit) when
calling IsInsideInWorldSpace(point) 2^25 times, using VS2022 Release.
  • Loading branch information
N-Dekker authored and hjmjohnson committed Feb 1, 2024
1 parent 2ca2351 commit 4ae04b3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Modules/Core/SpatialObjects/include/itkSpatialObject.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ SpatialObject<TDimension>::DerivativeAtInWorldSpace(const PointType &
const std::string & name,
const DerivativeOffsetType & offset)
{
const PointType pnt = m_ObjectToWorldTransformInverse->TransformPoint(point);
const PointType pnt = m_ObjectToWorldTransformInverse->TransformType::TransformPoint(point);
this->DerivativeAtInObjectSpace(pnt, order, value, depth, name, offset);
}

Expand Down Expand Up @@ -180,15 +180,15 @@ SpatialObject<TDimension>::IsInsideInWorldSpace(const PointType & point,
unsigned int depth,
const std::string & name) const
{
const PointType pnt = m_ObjectToWorldTransformInverse->TransformPoint(point);
const PointType pnt = m_ObjectToWorldTransformInverse->TransformType::TransformPoint(point);
return IsInsideInObjectSpace(pnt, depth, name);
}

template <unsigned int TDimension>
bool
SpatialObject<TDimension>::IsInsideInWorldSpace(const PointType & point) const
{
const PointType pnt = m_ObjectToWorldTransformInverse->TransformPoint(point);
const PointType pnt = m_ObjectToWorldTransformInverse->TransformType::TransformPoint(point);
return IsInsideInObjectSpace(pnt);
}

Expand Down Expand Up @@ -239,7 +239,7 @@ SpatialObject<TDimension>::IsEvaluableAtInWorldSpace(const PointType & point,
unsigned int depth,
const std::string & name) const
{
const PointType pnt = m_ObjectToWorldTransformInverse->TransformPoint(point);
const PointType pnt = m_ObjectToWorldTransformInverse->TransformType::TransformPoint(point);
return this->IsEvaluableAtInObjectSpace(pnt, depth, name);
}

Expand Down Expand Up @@ -303,7 +303,7 @@ SpatialObject<TDimension>::ValueAtInWorldSpace(const PointType & point,
unsigned int depth,
const std::string & name) const
{
const PointType pnt = m_ObjectToWorldTransformInverse->TransformPoint(point);
const PointType pnt = m_ObjectToWorldTransformInverse->TransformType::TransformPoint(point);
return this->ValueAtInObjectSpace(pnt, value, depth, name);
}

Expand Down

0 comments on commit 4ae04b3

Please sign in to comment.