/**============================================================================
 *
 * \file   distance_filter.hpp
 * \brief  Declarations for the DistanceFilter class.
 *
 * \author Leblanc Christophe.
 * \date   23/11/2012
 * \email cleblancad@gmail.com
 *
 * Code inspired from:
 * 'Getting Started with ITK + VTK'
 * L. Ibanez, W. Schroeder, Insight Software Consortium.
 *
 *
 *===========================================================================*/

#ifndef TOMOPROCESS_FILTER_DISTANCE_FILTER_HPP
#define TOMOPROCESS_FILTER_DISTANCE_FILTER_HPP

#include "filter.hpp"
#include "detail/maurer_distance_map_filter.hpp"
#include "itkNumericTraits.h"

TOMOPROCESS_OPEN_GLOBAL_NAMESPACE
TOMOPROCESS_OPEN_FILTER_NAMESPACE

/** \class DistanceFilter
  * \brief Computes the distance transform of an image.
  */
template<class ImageT>
class DistanceFilter
  : public Filter<
      itk::MaurerDistanceMapFilter<
        typename ImageT::InputImageType,
	typename ImageT::OutputImageType>,
      ImageT>
{
public:
  /// \brief This type.
  typedef DistanceFilter	Self;
  
  /// \brief Parent class.
  typedef Filter<
    itk::MaurerDistanceMapFilter<
      typename ImageT::InputImageType,
      typename ImageT::OutputImageType>,
    ImageT> SuperClass;
  
  /// \brief Image type.
  typedef ImageT 		ImageType;
  
  /// \brief Pixel type.
  typedef typename ImageType::OutputPixelType PixelType;
  
  /// Sets the parameters.
  /// \param[in] useSquaredDistance uses squared distance instead of euclidean distance.
  /// \param[in] useImageSpacing uses the image spacing for computing the distances.
  /// \param[in] background background value which defines the object. Useually this value is = 0.
  virtual void SetParameters(bool useSquaredDistance = false, bool useImageSpacing = true,
			     PixelType background = 0)
  {
    this->m_Filter->SetSquaredDistance(useSquaredDistance);
    this->m_Filter->SetUseImageSpacing(useImageSpacing);
    this->m_Filter->SetInsideIsPositive(false);
    this->m_Filter->SetBackgroundValue(background);
  }
};

TOMOPROCESS_CLOSE_FILTER_NAMESPACE
TOMOPROCESS_CLOSE_GLOBAL_NAMESPACE

#endif // TOMOPROCESS_FILTER_DISTANCE_FILTER_HPP