[Insight-developers] interrupting filter execution
Miller, James V (GE, Research)
millerjv at crd.ge.com
Wed Jul 19 09:27:13 EDT 2006
Paul,
The mechanism for hooking the UI in is that the when the user presses your stop
button, you need to set the AbortGenerateData flag. The next time the filter
checks this flag, it will throw a ProcessAborted exception. This exception
will be caught by the pipeline and the pipeline reset itself to a default state
and then rethrow the ProcessAborted exception. (Note that the exception is
ProcessAborted not ProgressAborted.)
So your image processing thread will need to catch this exception (or your thread
will crash and your main application will have problems).
Jim
-----Original Message-----
From: insight-developers-bounces+millerjv=crd.ge.com at itk.org
[mailto:insight-developers-bounces+millerjv=crd.ge.com at itk.org]On Behalf
Of Karthik Krishnan
Sent: Tuesday, July 18, 2006 5:30 PM
To: Paul Koshevoy
Cc: insight-developers at itk.org
Subject: Re: [Insight-developers] interrupting filter execution
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
>
_______________________________________________
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