Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 38 additions & 11 deletions Modules/Core/Common/include/itkPeriodicBoundaryCondition.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,19 @@ PeriodicBoundaryCondition< TInputImage, TOutputImage >
::operator()(const OffsetType & point_index, const OffsetType & boundary_offset,
const NeighborhoodType *data) const
{
// This is guaranteed to be called with an object that is using
// PeriodicBoundaryCondition
const auto * iterator = reinterpret_cast< const ConstNeighborhoodIterator< TInputImage, Self > * >( data );
const TInputImage * imagePointer = nullptr;
if (dynamic_cast< const ConstNeighborhoodIterator< TInputImage > * >( data ))
{
imagePointer = dynamic_cast< const ConstNeighborhoodIterator< TInputImage > * >( data )->GetImagePointer();
}
else if (dynamic_cast< const ConstNeighborhoodIterator< TInputImage, Self > * >( data ))
{
imagePointer = dynamic_cast< const ConstNeighborhoodIterator< TInputImage, Self > * >( data )->GetImagePointer();
}
else
{
// What to do for error?
}
typename TInputImage::PixelType * ptr;
int linear_index = 0;
unsigned int i;
Expand All @@ -55,21 +65,21 @@ PeriodicBoundaryCondition< TInputImage, TOutputImage >

// These are the step sizes for increments in each dimension of the image.
const typename TInputImage::OffsetValueType * offset_table =
iterator->GetImagePointer()->GetOffsetTable();
imagePointer->GetOffsetTable();

for ( i = 0; i < ImageDimension; ++i )
{
if ( boundary_offset[i] != 0 )
{ // If the neighborhood overlaps on the low edge, then wrap from the
// high edge of the image.
if ( point_index[i] < static_cast< OffsetValueType >( iterator->GetRadius(i) ) )
if ( point_index[i] < static_cast< OffsetValueType >( data->GetRadius(i) ) )
{
ptr += iterator->GetImagePointer()->GetBufferedRegion().GetSize()[i]
ptr += imagePointer->GetBufferedRegion().GetSize()[i]
* offset_table[i] - boundary_offset[i] * offset_table[i];
}
else // wrap from the low side of the image
{
ptr -= iterator->GetImagePointer()->GetBufferedRegion().GetSize()[i]
ptr -= imagePointer->GetBufferedRegion().GetSize()[i]
* offset_table[i] + boundary_offset[i] * offset_table[i];
}
}
Expand All @@ -85,9 +95,26 @@ PeriodicBoundaryCondition< TInputImage, TOutputImage >
const NeighborhoodType *data,
const NeighborhoodAccessorFunctorType & neighborhoodAccessorFunctor) const
{
<<<<<<< HEAD
// This is guaranteed to be called with an object that is using
// PeriodicBoundaryCondition
const auto * iterator = reinterpret_cast< const ConstNeighborhoodIterator< TInputImage, Self > * >( data );
=======
const TInputImage * imagePointer = nullptr;
if (dynamic_cast< const ConstNeighborhoodIterator< TInputImage > * >( data ))
{
imagePointer = dynamic_cast< const ConstNeighborhoodIterator< TInputImage > * >( data )->GetImagePointer();
}
else if (dynamic_cast< const ConstNeighborhoodIterator< TInputImage > * >( data ))
{
imagePointer = dynamic_cast< const ConstNeighborhoodIterator< TInputImage, Self > * >( data )->GetImagePointer();
}
else
{
// What to do for error?
}

>>>>>>> BUG: fix itkPeriodicBoundaryConditionTest itkGradientImageFilterTest
typename TInputImage::InternalPixelType * ptr;
int linear_index = 0;
unsigned int i;
Expand All @@ -110,21 +137,21 @@ PeriodicBoundaryCondition< TInputImage, TOutputImage >

// These are the step sizes for increments in each dimension of the image.
const typename TInputImage::OffsetValueType * offset_table =
iterator->GetImagePointer()->GetOffsetTable();
imagePointer->GetOffsetTable();

for ( i = 0; i < ImageDimension; ++i )
{
if ( boundary_offset[i] != 0 )
{ // If the neighborhood overlaps on the low edge, then wrap from the
// high edge of the image.
if ( point_index[i] < static_cast< OffsetValueType >( iterator->GetRadius(i) ) )
if ( point_index[i] < static_cast< OffsetValueType >( data->GetRadius(i) ) )
{
ptr += iterator->GetImagePointer()->GetBufferedRegion().GetSize()[i]
ptr += imagePointer->GetBufferedRegion().GetSize()[i]
* offset_table[i] - boundary_offset[i] * offset_table[i];
}
else // wrap from the low side of the image
{
ptr -= iterator->GetImagePointer()->GetBufferedRegion().GetSize()[i]
ptr -= imagePointer->GetBufferedRegion().GetSize()[i]
* offset_table[i] + boundary_offset[i] * offset_table[i];
}
}
Expand Down