<commit_before>/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    FastMarchingLevelSetBase.cxx
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  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 "FastMarchingLevelSetBase.h"
#include <FL/fl_ask.H>


/************************************
 *
 *  Constructor
 *
 ***********************************/
FastMarchingLevelSetBase 
::FastMarchingLevelSetBase()
{

  m_ImageReader                  = ImageReaderType::New();

  m_CastImageFilter = CastImageFilterType::New();
  m_CastImageFilter->SetInput( m_ImageReader->GetOutput() );

  m_DerivativeFilter   = DerivativeFilterType::New();
  m_DerivativeFilter->SetInput( m_CastImageFilter->GetOutput() );

  m_ExpNegativeFilter  = ExpNegativeFilterType::New();
  m_ExpNegativeFilter->SetInput( m_DerivativeFilter->GetOutput() );

  m_FastMarchingFilter = FastMarchingFilterType::New();
  m_FastMarchingFilter->SetSpeedImage( m_ExpNegativeFilter->GetOutput() );

  m_ThresholdFilter = ThresholdFilterType::New();
  m_ThresholdFilter->SetInput( m_FastMarchingFilter->GetOutput() );
  m_ThresholdFilter->SetInsideValue( 200 );
  m_ThresholdFilter->SetOutsideValue(  0 );

  m_TrialPoints = NodeContainer::New();
  m_FastMarchingFilter->SetTrialPoints( m_TrialPoints );

  m_SeedValue     = 0;
  m_NumberOfSeeds = 0;

  m_InputImageIsLoaded  = false;

}



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

}



 
/************************************
 *
 *  Load Input Image
 *
 ***********************************/
void
FastMarchingLevelSetBase 
::LoadInputImage( const char * filename )
{
  if( !filename )
  {
    return;
  }

  m_ImageReader->SetFileName( filename );
  m_ImageReader->Update();
  
  m_InputImageIsLoaded = true;

  m_FastMarchingFilter->SetOutputSize( m_ImageReader->GetOutput()->GetBufferedRegion().GetSize() );

}



  
/************************************
 *
 *  Clear Seeds
 *
 ***********************************/
void
FastMarchingLevelSetBase 
::ClearSeeds()
{
  m_TrialPoints->Initialize(); 
  m_NumberOfSeeds = 0;
}




/************************************
 *
 *  Add a seed
 *
 ***********************************/
void
FastMarchingLevelSetBase 
::AddSeed( const IndexType & seedPosition  )
{

  // setup trial points
  NodeType node;
  
  node.SetValue( m_SeedValue );
  node.SetIndex( seedPosition );

  m_TrialPoints->InsertElement( m_NumberOfSeeds, node );
  m_NumberOfSeeds++;
  
}

<commit_msg>FIX: Modified() is now called on m_FastMarchingFilter whenever the seed are modified<commit_after>/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    FastMarchingLevelSetBase.cxx
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  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 "FastMarchingLevelSetBase.h"
#include <FL/fl_ask.H>


/************************************
 *
 *  Constructor
 *
 ***********************************/
FastMarchingLevelSetBase 
::FastMarchingLevelSetBase()
{

  m_ImageReader                  = ImageReaderType::New();

  m_CastImageFilter = CastImageFilterType::New();
  m_CastImageFilter->SetInput( m_ImageReader->GetOutput() );

  m_DerivativeFilter   = DerivativeFilterType::New();
  m_DerivativeFilter->SetInput( m_CastImageFilter->GetOutput() );

  m_ExpNegativeFilter  = ExpNegativeFilterType::New();
  m_ExpNegativeFilter->SetInput( m_DerivativeFilter->GetOutput() );

  m_FastMarchingFilter = FastMarchingFilterType::New();
  m_FastMarchingFilter->SetSpeedImage( m_ExpNegativeFilter->GetOutput() );

  m_ThresholdFilter = ThresholdFilterType::New();
  m_ThresholdFilter->SetInput( m_FastMarchingFilter->GetOutput() );
  m_ThresholdFilter->SetInsideValue( 200 );
  m_ThresholdFilter->SetOutsideValue(  0 );

  m_TrialPoints = NodeContainer::New();
  m_FastMarchingFilter->SetTrialPoints( m_TrialPoints );

  m_SeedValue     = 0;
  m_NumberOfSeeds = 0;

  m_InputImageIsLoaded  = false;

}



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

}



 
/************************************
 *
 *  Load Input Image
 *
 ***********************************/
void
FastMarchingLevelSetBase 
::LoadInputImage( const char * filename )
{
  if( !filename )
  {
    return;
  }

  m_ImageReader->SetFileName( filename );
  m_ImageReader->Update();
  
  m_InputImageIsLoaded = true;

  m_FastMarchingFilter->SetOutputSize( m_ImageReader->GetOutput()->GetBufferedRegion().GetSize() );

}



  
/************************************
 *
 *  Clear Seeds
 *
 ***********************************/
void
FastMarchingLevelSetBase 
::ClearSeeds()
{
  m_TrialPoints->Initialize(); 
  m_FastMarchingFilter->Modified();
  m_NumberOfSeeds = 0;
}




/************************************
 *
 *  Add a seed
 *
 ***********************************/
void
FastMarchingLevelSetBase 
::AddSeed( const IndexType & seedPosition  )
{

  // setup trial points
  NodeType node;
  
  node.SetValue( m_SeedValue );
  node.SetIndex( seedPosition );

  m_TrialPoints->InsertElement( m_NumberOfSeeds, node );
  m_FastMarchingFilter->Modified();
  m_NumberOfSeeds++;
  
}


{'fraction_non_alphanumeric': 0.25205877603746163, 'fraction_numerical': 0.003552397868561279, 'mean_word_length': 5.084479371316307, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4257280', 'n_tokens_mistral': 1935, 'n_tokens_neox': 1751, 'n_words': 315}