[IGSTK-Users] dynamic_cast in TrackerController::TrackerInitializeProcess

Andrew Wiles awiles at ndigital.com
Thu Aug 5 11:42:05 EDT 2010


Hi Ziv,

Thanks for getting back to me.  Okay, I thought I was using the CVS Head and I went back deleted everything and rebuilt the IGSTK library.  I can now run Navigator but I can't test the tracking system as I don't have any images or mesh items to test it with.  Are there any samples available?

Now, I did compare my code (and the Navigator code) to the TrackerConfigurationExample since the TrackerConfigurationExample works fine, i.e. the Aurora successfully beeps after the initialization is requested.  I went line by line and it appears that my code is identical except for the fact that I have created a Tracker Class to do all the configuration stuff.  So the configuration object is set up as a member variable of the tracker class, e.g. igstk::TrackerConfiguration *m_TrackerConfiguration and not a local variable in the main function as done in TrackerConfigurationExample.  Now, I searched a bit deeper and noticed that the m_TrackerConfiguration object is not being assigned properly.  The code at this point looks like this:

... code snip ...

else if( rfso->GotSuccess() )
   {
     //get the configuration data from the reader
     trackerConfigReader->AddObserver(igstk::TrackerConfigurationFileReader::TrackerConfigurationDataEvent(), tco );
     trackerConfigReader->RequestGetData();

     // check the configuration.
     if( tco->GotTrackerConfiguration() )
     {
       m_TrackerConfiguration = tco->GetTrackerConfiguration();
       m_StateMachine.PushInput( m_SuccessInput );
     }
     else
     {
       igstkLogMacro2( m_Logger, DEBUG, "Could not get tracker configuration error\n" );
    
       m_tcfeErrorMessage = "Could not get the tracker configuration";
       m_StateMachine.PushInput( m_FailureInput );       
     }

     m_StateMachine.ProcessInputs();
     return; 
   }

... code snip ...

When I step through the code and get to the spot where the m_TrackerConfiguration pointer is assigned to the TrackerConfiguration object, non of the m_TrackerConfiguration member variables are assigned properly.  If I step into the trackerConfigReader->RequestGetData() function (or rather the state machine processing function). The TrackerConfiguration member variables are visible.

Now, the TrackerConfiguration object is not defined using ::Pointer but * instead.  Could this be a scope or smart pointer issue?  Also, even if I declare the TrackerConfiguration Object as a local variable, MSVC can't seem to decipher it in the watch variables list.  This also occurs when I run TrackerConfigurationExample in debug, where I can't use the watch list for the trackerConfguration variable but the system initializes fine.

Let me know if you have any other suggestions.

Cheers.
Andrew


--------------------
Andrew D. Wiles, PhD, PEng
Research Scientist, Medical Division
NDI
103 Randall Drive
Waterloo, ON, Canada, N2V 1C5
Telephone: +1 (519) 884-5142 ext. 314
Toll Free: +1 (877) 634-6340
Global: ++ (800) 634-634-00
Facsimile: +1 (519) 884-5184
Website: www.ndigital.com
--------------------

>>> Ziv Yaniv <zivy at isis.imac.georgetown.edu> 8/4/2010 2:37 PM >>>
Hi Andrew,

I don't really have an answer to your problem as it isn't clear to me 
what is happening. What I suspect is that there is an exception that 
should be caught in the IGSTK code but isn't identified. This happened 
to us on linux but never on windows.

To isolate the problem, please try the TrackerConfigurationExample.cxx 
program. Also please check if you get the same error if you change the 
order of the trackers (lines 89-102) so that the first one matches the 
configuration in your xml file.

In any case please download the cvs version of the toolkit (there were 
some bug fixes since the last release):
cvs -d :pserver:anonymous at public.kitware.com:/cvsroot/IGSTK login
answer by 'igstk'
cvs -d :pserver:anonymous at public.kitware.com:/cvsroot/IGSTK co IGSTK

                    regards
                        Ziv


On 8/4/2010 11:47 AM, Andrew Wiles wrote:
> Hello,
>
> I am having some issues using the TrackerController class.  I am writing an application modelling it after the Navigator application.  I can successfully read the Aurora xml file and when I go to initialize the tracker I get an unhandled exception: Microsoft C++ exception: std::__non_rtti_object at memory location 0x010acc78.  I have tracked it down to occurring in the TrackerController::TrackerInitializeProcess() function where a dynamic cast is performed on the temporary configuration object.  (Line 130 in igstkTrackerController.cxx).
>
> ... code snip ...
>
> if( dynamic_cast<PolarisVicraTrackerConfiguration *>
>        ( this->m_TmpTrackerConfiguration ) )
>        {
>        this->m_TrackerConfiguration = m_TmpTrackerConfiguration;
>        igstkPushInputMacro( PolarisVicraInitialize );
>        }
>      else if( dynamic_cast<PolarisHybridTrackerConfiguration *>
>        ( this->m_TmpTrackerConfiguration ) )
>        {
>        this->m_TrackerConfiguration = m_TmpTrackerConfiguration;
>        igstkPushInputMacro( PolarisHybridInitialize );
>        }
>
> ... code snip ...
>
> The strange thing is that things were working before with both my app and the Navigator application.  Now, only the TrackerConfigurationExample which uses primarily the same code works and both my app and the Navigator app fails.  The only change on my computer that I think has happened was a Microsoft Update (running XP).
>
> System config:
>
> Windows XP
> MSVC 2008 Express
> IGSTK 4.2 (latest version of that branch).
> VTK 5.6
> ITK 3.8
> FLTK provided on the IGSTK wiki
> Qt 4.6.3.
>
> Any thoughts on how I should track down the problem?  I have been struggling with this for several days and I am at a bit of a loss on how to proceed.
>
> Cheers.
> Andrew
>
> --------------------
> Andrew D. Wiles, PhD, PEng
> Research Scientist, Medical Division
> NDI
> 103 Randall Drive
> Waterloo, ON, Canada, N2V 1C5
> Telephone: +1 (519) 884-5142 ext. 314
> Toll Free: +1 (877) 634-6340
> Global: ++ (800) 634-634-00
> Facsimile: +1 (519) 884-5184
> Website: www.ndigital.com 
> --------------------
>
> _______________________________________________
> Powered by www.kitware.com 
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html 
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/cgi-bin/mailman/listinfo/igstk-users 
>
>


-- 
Ziv Yaniv, PhD., Research Assistant Professor
Imaging Science and Information Systems (ISIS) Center
Department of Radiology
Georgetown University Medical Center
2115 Wisconsin Avenue, Suite 603
Washington, DC, 20007,

Phone: +1-202-687-7286
Fax: +1-202-784-3479
email: zivy at isis.georgetown.edu 
web: http://isiswiki.georgetown.edu/zivy/



More information about the IGSTK-Users mailing list