[Insight-developers] interrupting filter execution

Karthik Krishnan Karthik.Krishnan at kitware.com
Tue Jul 18 17:29:45 EDT 2006


Never mind.. I am stupid. Discard the earlier suggestion. The exception 
must be thrown by the filter, of course.., not you.

That exception is also thrown by the filter or the progress reporter in 
the CompletedPixel method. 
http://www.itk.org/cgi-bin/viewcvs.cgi/Code/Common/itkProgressReporter.cxx?rev=1.8&root=Insight&view=markup

It should likewise be thrown also in the 
ProgressAccumulator.cxx::ReportProgress method as in
if (m_MiniPipelineFilter->GetAbortGenerateData())
  {
   throw ProgressAborted();
  }

That addition should fix it, I suppose. Could you check ?

Thanks
-karthik

Karthik Krishnan wrote:

> 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
>>
>>  
>>
> _______________________________________________
> 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