/usr/include/InsightToolkit/Common/itkZeroFluxNeumannBoundaryCondition.txx is in libinsighttoolkit3-dev 3.20.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | /*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: itkZeroFluxNeumannBoundaryCondition.txx
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __itkZeroFluxNeumannBoundaryCondition_txx
#define __itkZeroFluxNeumannBoundaryCondition_txx
#include "itkZeroFluxNeumannBoundaryCondition.h"
namespace itk
{
template<class TImage>
typename ZeroFluxNeumannBoundaryCondition<TImage>::PixelType
ZeroFluxNeumannBoundaryCondition<TImage>
::operator()(const OffsetType& point_index, const OffsetType& boundary_offset,
const NeighborhoodType *data) const
{
int linear_index = 0;
// Return the value of the pixel at the closest boundary point.
for (unsigned int i = 0; i < ImageDimension; ++i)
{
linear_index += (point_index[i] + boundary_offset[i]) * data->GetStride(i);
}
// The reinterpret_cast is necessary, cause we will have a warning if we
// do not do this. (In fact this function exists for legacy
// reasons. The overloaded function below should be (and is) used instead).
// See any of the neighborhood iterators.
//
// (data->operator[](linear_index)) is guaranteed to be a pointer to
// TImage::PixelType except for VectorImage, in which case, it will be a
// pointer to TImage::InternalPixelType.
//
// A typical neighborhood iterator working on an image will use the boundary
// condition in the following manner:
//
// \code
// // Initialize the functor typically in the constructor.
// m_NeighborhoodAccessorFunctor = image->GetNeighborhoodAccessor();
// m_NeighborhoodAccessorFunctor->SetBegin( image->GetBufferPointer() );
//
// m_NeighborhoodAccessorFunctor.BoundaryCondition(
// point_index, boundary_offset, data, m_ChosenBoundaryCondition );
// \endcode
//
return *(reinterpret_cast< PixelType *>( (data->operator[](linear_index)) ));
}
template<class TImage>
typename ZeroFluxNeumannBoundaryCondition<TImage>::PixelType
ZeroFluxNeumannBoundaryCondition<TImage>
::operator()(const OffsetType& point_index, const OffsetType& boundary_offset,
const NeighborhoodType *data,
const NeighborhoodAccessorFunctorType &neighborhoodAccessorFunctor) const
{
int linear_index = 0;
// Return the value of the pixel at the closest boundary point.
for (unsigned int i = 0; i < ImageDimension; ++i)
{
linear_index += (point_index[i] + boundary_offset[i]) * data->GetStride(i);
}
return neighborhoodAccessorFunctor.Get(data->operator[](linear_index));
}
} // end namespace itk
#endif
|