/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    $RCSfile: liFilterConsole3DBase.cxx,v $
  Language:  C++
  Date:      $Date: 2003/09/02 17:46:53 $
  Version:   $Revision: 1.5 $

  Copyright (c) 2002 Insight 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.

=========================================================================*/


#include <liFilterConsole3DBase.h>
#include <itkMetaImageIO.h>


/************************************
 *
 *  Constructor
 *
 ***********************************/
liFilterConsole3DBase 
::liFilterConsole3DBase()
{

  m_ImageFileNameAvailable = false;

  m_Reader     = VolumeReaderType::New();

  m_Flip = FlipType::New();
  m_Flip->SetInput(m_Reader->GetOutput());
  axes[0] = false;
  axes[1] = false;
  axes[2] = false;
  m_Flip->SetFlipAxes(axes);
  
  m_FilterG = GradientAnisotropicDiffusionFilterType::New();
  m_FilterG->SetNumberOfIterations( 10 );
  m_FilterG->SetTimeStep( 0.125 );
  m_FilterG->SetConductanceParameter( 1.0 );
  m_FilterG->SetInput( m_Flip->GetOutput() );

  m_FilterC = CurvatureAnisotropicDiffusionFilterType::New();
  m_FilterC->SetNumberOfIterations( 10 );
  m_FilterC->SetTimeStep( 0.0625 );
  m_FilterC->SetConductanceParameter( 1.0 );
  m_FilterC->SetInput( m_Reader->GetOutput() );

  m_Rescaler  = RescaleIntensityImageFilterType::New();
  m_Rescaler->SetOutputMinimum( 0 );
  m_Rescaler->SetOutputMaximum( 255 );
  m_Rescaler->SetInput(  m_FilterG->GetOutput()  );

  m_Writer   = VolumeWriterType::New();
}




/************************************
 *
 *  Destructor
 *
 ***********************************/
liFilterConsole3DBase 
::~liFilterConsole3DBase()
{

}



 
/************************************
 *
 *  Load
 *
 ***********************************/
void
liFilterConsole3DBase 
::Load( const char * filename )
{
  if( !filename )
  {
    return;
  }

  m_Reader->SetFileName( filename );

  m_ImageFileNameAvailable = true;

}


/************************************
 *
 *  Show Progress
 *
 ***********************************/
void
liFilterConsole3DBase 
::ShowProgress( float )
{

}


/************************************
 *
 *  Show Status
 *
 ***********************************/
void
liFilterConsole3DBase 
::ShowStatus( const char * )
{

}


 
/************************************
 *
 *  Save Gradient Image
 *
 ***********************************/
void
liFilterConsole3DBase 
::SaveGradientImage( const char * filename )
{
  if( !filename )
  {
    return;
  }

  m_Rescaler->SetInput( m_FilterG->GetOutput() );
  m_Rescaler->Update();

  m_Writer->SetFileName( filename );
  m_Writer->SetInput(  m_FilterG->GetOutput()  );
  m_Writer->Update();

}

/************************************
 *
 *  Save Curvature Image
 *
 ***********************************/
void
liFilterConsole3DBase 
::SaveCurvatureImage( const char * filename )
{
  if( !filename )
  {
    return;
  }

  m_Rescaler->SetInput( m_FilterC->GetOutput() );
  m_Rescaler->Update();

  m_Writer->SetFileName( filename );
  m_Writer->SetInput(  m_FilterC->GetOutput()  );
  m_Writer->Update();

}


/************************************
 *
 *  Show Gradient Image
 *
 ***********************************/
void
liFilterConsole3DBase 
::ShowGradientImage()
{

}

/************************************
 *
 *  Show Curvature Image
 *
 ***********************************/
void
liFilterConsole3DBase 
::ShowCurvatureImage()
{

}
 
/************************************
 *
 *  Set Iterations For Gradient
 *
 ***********************************/
void
liFilterConsole3DBase 
::SetIterationsForGradient( double value )
{
  m_FilterG->SetNumberOfIterations( (unsigned int)value );
}

/************************************
 *
 *  Set Conductance Parameter For Gradient
 *
 ***********************************/
void
liFilterConsole3DBase 
::SetConductanceForGradient( double value )
{
  m_FilterG->SetConductanceParameter( value );
}

/************************************
 *
 *  Set Time Step For Gradient
 *
 ***********************************/
void
liFilterConsole3DBase 
::SetTimeStepForGradient( double value )
{
  m_FilterG->SetTimeStep( value );
}

/************************************
 *
 *  Set Iterations For Curvature
 *
 ***********************************/
void
liFilterConsole3DBase 
::SetIterationsForCurvature( double value )
{
  m_FilterC->SetNumberOfIterations( (unsigned int)value );
}

/************************************
 *
 *  Set Conductance Parameter For Curvature
 *
 ***********************************/
void
liFilterConsole3DBase 
::SetConductanceForCurvature( double value )
{
  m_FilterC->SetConductanceParameter( value );
}

/***********************************
 *
 * Flip
 *
 ***********************************/
void liFilterConsole3DBase::Flip(int) {
  
}

/************************************
 *
 *  Set Time Step For Curvature
 *
 ***********************************/
void
liFilterConsole3DBase 
::SetTimeStepForCurvature( double value )
{
  m_FilterC->SetTimeStep( value );
}

