Skip to content

Commit

Permalink
STYLE: Remove local crop variable from ImageRegion::Crop
Browse files Browse the repository at this point in the history
It appears unnecessary to use this helper variable to calculate how much to crop.
  • Loading branch information
N-Dekker authored and dzenanz committed Nov 14, 2023
1 parent 6d86d1f commit 8439a2e
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions Modules/Core/Common/include/itkImageRegion.hxx
Expand Up @@ -187,8 +187,6 @@ template <unsigned int VImageDimension>
bool
ImageRegion<VImageDimension>::Crop(const Self & region)
{
OffsetValueType crop;

// Can we crop?
for (unsigned int i = 0; i < VImageDimension; ++i)
{
Expand All @@ -208,23 +206,16 @@ ImageRegion<VImageDimension>::Crop(const Self & region)
// first check the start index
if (m_Index[i] < region.m_Index[i])
{
// how much do we need to adjust
crop = region.m_Index[i] - m_Index[i];

// adjust the start index and the size of the current region
m_Index[i] += crop;
m_Size[i] -= static_cast<SizeValueType>(crop);
// adjust the size and the start index of the current region
m_Size[i] -= static_cast<SizeValueType>(region.m_Index[i] - m_Index[i]);
m_Index[i] = region.m_Index[i];
}
// now check the final size
if (m_Index[i] + static_cast<OffsetValueType>(m_Size[i]) >
region.m_Index[i] + static_cast<OffsetValueType>(region.m_Size[i]))
{
// how much do we need to adjust
crop = m_Index[i] + static_cast<OffsetValueType>(m_Size[i]) - region.m_Index[i] -
static_cast<OffsetValueType>(region.m_Size[i]);

// adjust the size
m_Size[i] -= static_cast<SizeValueType>(crop);
m_Size[i] = region.m_Size[i] - static_cast<SizeValueType>(m_Index[i] - region.m_Index[i]);
}
}

Expand Down

0 comments on commit 8439a2e

Please sign in to comment.