[IGSTK-Users] Get position tools

sebastian ordas sebastian.ordas at gmail.com
Sun Jul 6 16:42:59 EDT 2008


Hi Eric,

you can retrieve the transform like this:

//  define an observer in your main class

#include "igstkEvents.h"

typedef itk::ReceptorMemberCommand < Self > LoadedObserverType;

LoadedObserverType::Pointer m_TrackerToolUpdateObserver;

// set a callback function to it

m_TrackerToolUpdateObserver = LoadedObserverType::New();

m_TrackerToolUpdateObserver->SetCallbackFunction( this,
&MyClass::TrackingCallback );

// the callback function

void MyClass::TrackingCallback(const itk::EventObject & event )

{

  if ( igstk::TrackerToolTransformUpdateEvent().CheckEvent( &event ) )

 {

     typedef igstk::TransformObserver ObserverType;

     ObserverType::Pointer transformObserver = ObserverType::New();

     transformObserver->ObserveTransformEventsFrom( m_TrackerTool );

     transformObserver->Clear();

     m_TrackerTool->RequestComputeTransformTo( m_WorldReference ); // some
reference e.g.  igstk::AxesObject::Pointer m_WorldReference;

     if ( transformObserver->GotTransform() )

     {

          igstk::Transform::VectorType translation;

         // get the translational component

          translation = transformObserver->GetTransform().GetTranslation();

         // get the rotational component (quaternion)

          igstk::Transform::VersorType rotation;

          rotation= transformObserver->GetTransform().GetRotation();

      }

 }

}

// and don't forget to add the observer to the tracker tool

m_TrackerTool->AddObserver( igstk::TrackerToolTransformUpdateEvent(),
m_TrackerToolUpdateObserver);

Let us know how you do with it

best regards,

sebastian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/igstk-users/attachments/20080706/30b19bac/attachment-0001.html>


More information about the IGSTK-Users mailing list