[Insight-developers] trouble creating a binary filter

Luis Ibanez luis . ibanez at kitware . com
Tue, 04 Jun 2002 16:56:40 -0400


Hi Aaron,


The const cast seems to be Ok for your filter,
as well as the  SetNumberOfRequiredInputs(2);

Can you look at the call stack on VC++ after
the program crashes ?

It should be on the menu View -> Debug Windows -> call stack

That could help to identify the place where it is crashing.


One first thing to verify is:  when you get prepared for running
the filter at the moment of calling GetInput(), a dynamic_cast
must be used to down-cast the *itkDataObject to the actal type of
your image.

Keep in mind that a dynamic_cast failure will throw an exception.

you could also put the Update() call of your filter inside a
try/catch block and print the description and location of the
eventual exception.




     Luis



============================================================


Aaron Cois wrote:

> Greetings all.  I have been attempting to create a filter which takes in 
> two types of images as inputs (a source image and a 
> BloxBoundaryPointImage), and outputs a third image type.  It is only 
> templated over the type of source image, as both the output type and the 
> second input type are to remain stoic. 
> 
>  
> 
> Following the lead of itkBinaryFunctorImageFilter, i have used that 
> notation:
> 
>  
> 
>     SetNthInput(0,  const_cast<SourceImageType *>( image1 ) );
> 
>  
> 
> in my SetInput1 and SetInput2 functions, and have added
> 
>  
> 
>     this->SetNumberOfRequiredInputs( 2 );
> 
> to my constructor. 
> 
>  
> 
> Everything compiles and builds fine, and i can initialize an instance of 
> the filter, set its inputs, and call GetOutput(), but when i call 
> Update() on the filter, it crashes with an abnormal program 
> termination.  It is not getting far enough to call GenerateData() before 
> it crashes.  I haven't been able to get any useful information out of 
> the debugger (i am using VC), and was wondering if anyone had 
> experienced similar problems or had any thoughts.  Thanks in advance.
> 
>  
> 
>                                                                         
>                 Aaron Cois
>