Skip to content

Commit

Permalink
STYLE: SpatialObject use std::transform to fill transformedCorners
Browse files Browse the repository at this point in the history
Modernized the code by using `std::transform`, in both
`GetFamilyBoundingBoxInWorldSpace()` and `GetMyBoundingBoxInWorldSpace()`.
  • Loading branch information
N-Dekker committed Feb 11, 2024
1 parent fa52dba commit c516690
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions Modules/Core/SpatialObjects/include/itkSpatialObject.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -398,15 +398,9 @@ SpatialObject<TDimension>::GetFamilyBoundingBoxInWorldSpace() const -> const Bou
auto transformedCorners = PointsContainer::New();
transformedCorners->Reserve(static_cast<typename PointsContainer::ElementIdentifier>(corners.size()));

auto it = corners.begin();
auto itTrans = transformedCorners->begin();
while (it != corners.end())
{
const PointType pnt = this->m_ObjectToWorldTransform->TransformPoint(*it);
*itTrans = pnt;
++it;
++itTrans;
}
std::transform(corners.cbegin(), corners.cend(), transformedCorners->begin(), [this](const auto & point) {
return m_ObjectToWorldTransform->TransformPoint(point);
});

m_FamilyBoundingBoxInWorldSpace->SetPoints(transformedCorners);
m_FamilyBoundingBoxInWorldSpace->ComputeBoundingBox();
Expand Down Expand Up @@ -628,15 +622,9 @@ SpatialObject<TDimension>::GetMyBoundingBoxInWorldSpace() const -> const Boundin
auto transformedCorners = PointsContainer::New();
transformedCorners->Reserve(static_cast<typename PointsContainer::ElementIdentifier>(corners.size()));

auto it = corners.begin();
auto itTrans = transformedCorners->begin();
while (it != corners.end())
{
const PointType pnt = this->m_ObjectToWorldTransform->TransformPoint(*it);
*itTrans = pnt;
++it;
++itTrans;
}
std::transform(corners.cbegin(), corners.cend(), transformedCorners->begin(), [this](const auto & point) {
return m_ObjectToWorldTransform->TransformPoint(point);
});

m_MyBoundingBoxInWorldSpace->SetPoints(transformedCorners);
m_MyBoundingBoxInWorldSpace->ComputeBoundingBox();
Expand Down

0 comments on commit c516690

Please sign in to comment.