[Insight-users] Connecting ITK + VTK : Need for enabling RTTI and Exceptions.

Luis Ibanez luis.ibanez@kitware.com
Tue, 11 Feb 2003 18:49:36 -0500


Hi Christof,

Thanks for your detailed report.

I wish all the bug reports in the list were
like yours.

----

The problem is that you are building your project
with RTTI disabled (and probably also Exceptions support
disabled).

If you were using CMake for generating the VisualStudio
workspace you would not have to be concerned with these
details since CMake will generate a consistent project.

You may have to go to Project properties and enable
RTTI support and Exceptions.

ITK uses Exceptions for reporting error conditions.

You can take advantage of this nice property by placing
all your calls to Update() methods in try/catch blocks.

There are multiple examples of this in the
SoftwareGuide.pdf:

    http://www.itk.org/ItkSoftwareGuide.pdf

---

Actually VisualStudio sent you a lot of warnings
regarding the fact that RTTI is disabled in your project:

They look like:

   'dynamic_cast' used on polymorphic type
   'itk::EventObject' with /GR-; unpredictable behavior
   may result


-----

I would encourage you to use CMake for configuring your
project. It will save you a lot of time by protecting
your from errors like this one.

Please let us know if you find further problems.



Thanks



   Luis


----------------------------------------------------------
karmonik wrote:

Luis,

thanks for your email.

I decided to start simple: read a VTK file and experiment with one 
filter. I chose the itk::MRIBiasFieldCorrectionFilter as I do have an 
application for it.
(Also b/c there is an example called MRIBiasCorrection).

My first try, reading a VTK file (ASCII, STRUCTURED POINTS, float 3D) 
and then writing it back to disk worked fine (I think).

But when I add the filter (following the code in the MRIBiasCorrection 
example), I do get a runtime error:

---->Unhandled exception at 0x77e6d756 in ITKApp.exe: Microsoft C++ 
exception: __non_rtti_object @ 0x0012ec44.<----------

Looking at the call stack makes me think that I was not successful to 
initialize the image object after all 
(itk::ImageBase::CopyInformation(...)) actually causes this error).

I have attached the code, the beginning of the VTK file, the error 
message, the call stack and the Output window of the build log.

Any thoughts?

Best regards,

Christof

-----------------------------