[Insight-developers] interrupting filter execution

Karthik Krishnan Karthik.Krishnan at kitware.com
Tue Jul 18 14:51:27 EDT 2006


Make the UI Abort button throw an ProcessAborted exception. See class 
ProcessAborted in Common/itkExceptionObject.h .

The ProcessObject updates its output data as follows:

    try
      {
      this->GenerateData();
      }
    catch( ProcessAborted & excp )
      {
      excp = excp;
      this->InvokeEvent( AbortEvent() );
      this->ResetPipeline();
      this->RestoreInputReleaseDataFlags();
      throw ProcessAborted(__FILE__,__LINE__);
      }
    catch( ExceptionObject& excp )
      {
......


So you could write your code as

try { filter->GenerateData(); }
catch (ProcessAborted &) { // Put up some UI dialog to tell the user we 
aborted.. }
catch ...


-karthik

Paul Koshevoy wrote:

>Hi,
>
>I am working on a UI with an ITK 2.4.1 backend. The UI is multi threaded
>-- image processing in the secondary thread, UI in the first thread.
>Some of the ITK operations I have to carry out take a significant amount
>of time -- an itk::ImageFileReader stage on a 411MB file can take a
>while, and itk::DiscreteGaussianImageFilter may take a while as well. In
>the UI I present the user with a dialog where the ITK process can be
>canceled. I call AbortGenerateDataOn() to interrupt the ITK processes.
>I've noticed (by means of itk::SimpleFilterWatcher) that
>AbortGenerateDataOn() has no effect on the itk::ImageFileReader or
>itk::DiscreteGaussianImageFilter.
>
>Am I using the correct API for aborting the filters? What is the correct
>way to stop a filter?
>
>Thank you,
>    Paul.
>
>_______________________________________________
>Insight-developers mailing list
>Insight-developers at itk.org
>http://www.itk.org/mailman/listinfo/insight-developers
>
>  
>


More information about the Insight-developers mailing list