<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css"></style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hello,<br>
<br>
Thanks again for your answer!<br>
<br>
As you suggested, I tried to set the transform at each time step, but... it doesn't work...<br>
<br>
The position of the cylinder (which is attached to the tracker) in the View3D is not updated at all. It just stay where it has been initialized (center of the world).
<br>
<br>
So I just don't know how to solve this, despite I'm trying hard. I can't find the error, even when looking in the tests and examples.<br>
<br>
Would you have another idea? I'm sure the solution is very simple.<br>
<br>
I change a bit the code to make it even more simple (see below).<br>
<br>
Thanks a lot for your ideas,<br>
<div><br>
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px"><font color="808080"><b><font face="Tahoma">Steve Berger</font></b><br>
<br>
</font><br>
<br>
MAIN.CPP<br>
-------------------------------------------------------------------------------------<br>
<br>
<font color="000000"><br>
<br>
#include <QApplication><br>
#include <QtTest/QTest><br>
#include <QMainWindow><br>
<br>
#include <iostream><br>
<br>
#include "igstkView2D.h"<br>
#include "igstkView3D.h"<br>
#include "igstkAxesObject.h"<br>
#include "igstkAxesObjectRepresentation.h"<br>
#include "igstkEvents.h"<br>
#include "igstkTransformObserver.h"<br>
#include "igstkCylinderObject.h"<br>
#include "igstkCylinderObjectRepresentation.h"<br>
<br>
#include "igstkLogger.h"<br>
#include "itkStdStreamLogOutput.h"<br>
<br>
#include "igstkPolarisTracker.h"<br>
#include "igstkPolarisTrackerTool.h"<br>
<br>
#include "igstkSerialCommunication.h"<br>
<br>
#include "igstkQTWidget.h"<br>
<br>
#include "PolarisTrackerCommand.h"<br>
<br>
<br>
<br>
<br>
int main( int argc, char * argv[])<br>
{<br>
igstk::RealTimeClock::Initialize();<br>
<br>
<br>
<br>
<br>
<br>
// *******************************<br>
// INSTANCES<br>
//********************************<br>
<br>
// logger<br>
igstk::Object::LoggerType::Pointer m_Logger = igstk::Object::LoggerType::New();<br>
itk::StdStreamLogOutput::Pointer m_LogOutput = itk::StdStreamLogOutput::New();<br>
<br>
// tracker<br>
igstk::PolarisTracker::Pointer m_Tracker = igstk::PolarisTracker::New();<br>
igstk::PolarisTrackerTool::Pointer m_TrackerTool = igstk::PolarisTrackerTool::New();<br>
igstk::SerialCommunication::Pointer m_Communication = igstk::SerialCommunication::New();<br>
<br>
//observer<br>
igstk::TransformObserver::Pointer coordSystemAObserver = igstk::TransformObserver::New();<br>
PolarisTrackerCommand::Pointer command = PolarisTrackerCommand::New();<br>
<br>
//transformation<br>
const double longestValidityTime = igstk::TimeStamp::GetLongestPossibleTime();<br>
igstk::Transform identityTransform;<br>
identityTransform.SetToIdentity(longestValidityTime);<br>
<br>
//objects<br>
igstk::AxesObject::Pointer worldReference = igstk::AxesObject::New();<br>
igstk::AxesObjectRepresentation::Pointer worldReferenceR = igstk::AxesObjectRepresentation::New();<br>
igstk::CylinderObject::Pointer cylinder = igstk::CylinderObject::New();<br>
igstk::CylinderObjectRepresentation::Pointer cylinderR = igstk::CylinderObjectRepresentation::New();<br>
<br>
//views<br>
igstk::View3D::Pointer View3D = igstk::View3D::New();<br>
<br>
//QT<br>
QApplication myApp(argc, argv);<br>
QMainWindow myMainWindow;<br>
igstk::QTWidget* qtWidget3D = new igstk::QTWidget();<br>
<br>
<br>
<br>
<br>
<br>
<br>
// *******************************<br>
// LOGGER<br>
//********************************<br>
m_LogOutput->SetStream(std::cout);<br>
m_Logger->AddLogOutput(m_LogOutput);<br>
//m_Logger->SetPriorityLevel( itk::Logger::DEBUG);<br>
<br>
<br>
<br>
<br>
<br>
<br>
// *******************************<br>
// OBJECTS<br>
//********************************<br>
<br>
//world reference<br>
worldReference -> SetSize(200.0,200.0,200.0);<br>
worldReferenceR -> RequestSetAxesObject(worldReference);<br>
worldReferenceR -> SetOpacity(1.0);<br>
<br>
// Create the cylinder<br>
//cylinder->SetLogger(m_Logger);<br>
cylinder -> SetRadius(20.0);<br>
cylinder -> SetHeight(300.0);<br>
cylinderR -> RequestSetCylinderObject( cylinder );<br>
cylinderR -> SetColor(1.0,0.0,0.0);<br>
cylinderR -> SetOpacity(1.0);<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
// *******************************<br>
// TRACKER<br>
//********************************<br>
<br>
//serial communication<br>
//m_Communication->AddObserver(itk::AnyEvent(),command);<br>
//m_Communication->SetLogger( m_Logger );<br>
m_Communication->SetPortNumber( igstk::SerialCommunication::PortNumber0 );<br>
m_Communication->SetParity( igstk::SerialCommunication::NoParity );<br>
m_Communication->SetBaudRate( igstk::SerialCommunication::BaudRate115200 );<br>
m_Communication->SetDataBits( igstk::SerialCommunication::DataBits8 );<br>
m_Communication->SetStopBits( igstk::SerialCommunication::StopBits1 );<br>
m_Communication->SetHardwareHandshake(igstk::SerialCommunication::HandshakeOff );<br>
m_Communication->SetCapture( true );<br>
<br>
igstk::Communication::ResultType openCommOutput = m_Communication->OpenCommunication();<br>
if( openCommOutput == igstk::Communication::SUCCESS)<br>
std::cout<<"SerialComm: OpenCommunication OK"<<std::endl;<br>
else if(openCommOutput == igstk::Communication::TIMEOUT)<br>
std::cout<<"SerialComm: OpenCommunication TIMEOUT"<<std::endl;<br>
else if(openCommOutput == igstk::Communication::FAILURE)<br>
std::cout<<"SerialComm: OpenCommunication FAILED"<<std::endl;<br>
<br>
<br>
// tracker<br>
//m_Tracker->AddObserver(itk::AnyEvent(),command);<br>
//m_Tracker->SetLogger(m_Logger);<br>
m_Tracker->SetCommunication(m_Communication);<br>
m_Tracker->RequestOpen();<br>
<br>
<br>
// tool<br>
m_TrackerTool->AddObserver(itk::AnyEvent(),command);<br>
m_TrackerTool->SetLogger(m_Logger);<br>
m_TrackerTool->RequestSelectWirelessTrackerTool();<br>
m_TrackerTool->RequestSetSROMFileName("../Resources/TrackerROMfiles/ISTB0050.rom");<br>
m_TrackerTool->RequestConfigure();<br>
m_TrackerTool->RequestAttachToTracker(m_Tracker);<br>
<br>
<br>
//observer<br>
coordSystemAObserver->ObserveTransformEventsFrom(m_TrackerTool);<br>
<br>
<br>
//start tracking<br>
m_Tracker->RequestStartTracking();<br>
<br>
<br>
<br>
<br>
<br>
<br>
// *******************************<br>
// TRANSFORM AND PARENTS<br>
//********************************<br>
<br>
View3D->RequestSetTransformAndParent(identityTransform, worldReference);<br>
cylinder->RequestSetTransformAndParent(identityTransform, worldReference);<br>
<br>
<br>
<br>
<br>
<br>
<br>
// *******************************<br>
// 3DView<br>
//********************************<br>
//View3D->SetLogger(m_Logger);<br>
View3D->RequestAddObject(worldReferenceR->Copy());<br>
View3D->RequestAddObject(cylinderR->Copy());<br>
<br>
View3D->SetRefreshRate( 30 ); // Hz<br>
View3D->RequestResetCamera();<br>
View3D->RequestStart();<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
// *******************************<br>
// QT<br>
//********************************<br>
qtWidget3D->RequestSetView( View3D );<br>
qtWidget3D->RequestEnableInteractions();<br>
myMainWindow.setCentralWidget(qtWidget3D);<br>
myMainWindow.setFixedSize(720,576);<br>
myMainWindow.show();<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
// *******************************<br>
// MAIN LOOP<br>
//********************************<br>
<br>
while(1)<br>
{<br>
std::cout<<"\n\n"<<std::endl;<br>
QTest::qWait(500);<br>
igstk::PulseGenerator::CheckTimeouts();<br>
<br>
//print tracker position<br>
igstk::Transform trackerToolTransform;<br>
::itk::Vector<double, 3> trackerToolTranslation;<br>
coordSystemAObserver->Clear();<br>
m_TrackerTool->RequestGetTransformToParent();<br>
if (coordSystemAObserver->GotTransform())<br>
{<br>
trackerToolTransform = coordSystemAObserver->GetTransform();<br>
if ( trackerToolTransform.IsValidNow() )<br>
{<br>
trackerToolTranslation = trackerToolTransform.GetTranslation();<br>
<br>
std::cout << "Trackertool :"<br>
<< m_TrackerTool->GetTrackerToolIdentifier()<br>
<< "\t\t Position = ("<br>
<< trackerToolTranslation[0]<br>
<< ","<br>
<< trackerToolTranslation[1]<br>
<< ","<br>
<< trackerToolTranslation[2]<br>
<< ")" << std::endl<br>
<< "\tExp Time = " << trackerToolTransform.GetExpirationTime() <<std::endl;<br>
<br>
cylinder->RequestSetTransformAndParent(trackerToolTransform, worldReference);<br>
//cylinder->RequestUpdateTransformToParent(trackerToolTransform);<br>
<br>
}<br>
}<br>
<br>
<br>
}<br>
<br>
<br>
return EXIT_SUCCESS;<br>
<br>
<br>
}<br>
</font><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF75893"><font color="#000000" face="Tahoma" size="2"><b>De :</b> ionut iorgovan [ionutcelgroaznic@yahoo.com]<br>
<b>Envoyé :</b> lundi, 17. mars 2014 20:56<br>
<b>À :</b> Berger, Steve (ISTB)<br>
<b>Objet :</b> Re: [IGSTK-Users] not able to display the tracker tool<br>
</font><br>
</div>
<div></div>
<div>
<div style="">
<div style="font-size:12pt"><span><br>
</span></div>
<div style="font-size:12pt">Hi,</div>
<div style="font-size:12pt"><br>
</div>
<div style="font-size:16px; color:rgb(0,0,0); font-family:'Times New Roman'; background-color:transparent; font-style:normal">
<br>
</div>
<div style="font-size:16px; color:rgb(0,0,0); font-family:'Times New Roman'; background-color:transparent; font-style:normal">
You need to pass the transform after you get it from the aurora <span style="background-color:transparent">like this</span></div>
<div style="font-size:16px; color:rgb(0,0,0); font-family:'Times New Roman'; background-color:transparent; font-style:normal">
<span style="background-color:transparent"><br>
</span></div>
<div style="background-color:transparent"> /** Define a initial world coordinate system */</div>
<div style="background-color:transparent"><span style="background-color:transparent"></span></div>
<div style="background-color:transparent"> igstk::AxesObject::Pointer m_WorldReference = igstk::AxesObject::New();;</div>
<div style="font-size:16px; color:rgb(0,0,0); font-family:'Times New Roman'; background-color:transparent; font-style:normal">
<span style="background-color:transparent">box->RequestSetTransformAndParent( *m_toolTransform, m_WorldReference );</span></div>
<div style="font-size:16px; color:rgb(0,0,0); font-family:'Times New Roman'; background-color:transparent; font-style:normal">
<span style="background-color:transparent"><br>
</span></div>
<div style="font-size:16px; color:rgb(0,0,0); font-family:'Times New Roman'; background-color:transparent; font-style:normal">
<span style="background-color:transparent">I'm not sure what is your world reference in this case or if you can just skip it.But you will need to set the transform each time.</span></div>
<div style="font-size:16px; color:rgb(0,0,0); font-family:'Times New Roman'; background-color:transparent; font-style:normal">
<span style="background-color:transparent"><br>
</span></div>
<div style="font-size:16px; color:rgb(0,0,0); font-family:'Times New Roman'; background-color:transparent; font-style:normal">
Your case:</div>
<div style="font-size:16px; color:rgb(0,0,0); font-family:'Times New Roman'; background-color:transparent; font-style:normal">
<br>
</div>
<div style="font-size:16px; color:rgb(0,0,0); font-family:'Times New Roman'; background-color:transparent; font-style:normal">
<span style="font-family:Tahoma; font-size:13px"> //print tracker position</span><br style="font-family:Tahoma; font-size:13px" clear="none">
<span style="font-family:Tahoma; font-size:13px"> igstk::Transform trackerToolTransform;</span><br style="font-family:Tahoma; font-size:13px" clear="none">
<span style="font-family:Tahoma; font-size:13px"> ::itk::Vector<double, 3> trackerToolTranslation;</span><br style="font-family:Tahoma; font-size:13px" clear="none">
<span style="font-family:Tahoma; font-size:13px"> coordSystemAObserver->Clear();</span><br style="font-family:Tahoma; font-size:13px" clear="none">
<span style="font-family:Tahoma; font-size:13px"> m_TrackerTool->RequestGetTransformToParent();</span><br style="font-family:Tahoma; font-size:13px" clear="none">
<span style="font-family:Tahoma; font-size:13px"> if (coordSystemAObserver->GotTransform())</span><br style="font-family:Tahoma; font-size:13px" clear="none">
<span style="font-family:Tahoma; font-size:13px"> {</span><br style="font-family:Tahoma; font-size:13px" clear="none">
<span style="font-family:Tahoma; font-size:13px"> trackerToolTransform = coordSystemAObserver->GetTransform();</span><br style="font-family:Tahoma; font-size:13px" clear="none">
<span style="font-family:Tahoma; font-size:13px"> if ( trackerToolTransform.IsValidNow() )</span><br style="font-family:Tahoma; font-size:13px" clear="none">
<span style="font-family:Tahoma; font-size:13px"> {</span><br style="font-family:Tahoma; font-size:13px" clear="none">
<span style="font-family:Tahoma; font-size:13px"> trackerToolTranslation = trackerToolTransform.GetTranslation();</span><br style="font-family:Tahoma; font-size:13px" clear="none">
<span style="font-family:Tahoma; font-size:13px"> std::cout << "Trackertool :"</span><br style="font-family:Tahoma; font-size:13px" clear="none">
<span style="font-family:Tahoma; font-size:13px"> << m_TrackerTool->GetTrackerToolIdentifier()</span><br style="font-family:Tahoma; font-size:13px" clear="none">
<span style="font-family:Tahoma; font-size:13px"> << "\t\t Position = ("</span><br style="font-family:Tahoma; font-size:13px" clear="none">
<span style="font-family:Tahoma; font-size:13px"> << trackerToolTranslation[0]</span><br style="font-family:Tahoma; font-size:13px" clear="none">
<span style="font-family:Tahoma; font-size:13px"> << ","</span><br style="font-family:Tahoma; font-size:13px" clear="none">
<span style="font-family:Tahoma; font-size:13px"> << trackerToolTranslation[1]</span><br style="font-family:Tahoma; font-size:13px" clear="none">
<span style="font-family:Tahoma; font-size:13px"> << ","</span><br style="font-family:Tahoma; font-size:13px" clear="none">
<span style="font-family:Tahoma; font-size:13px"> << trackerToolTranslation[2]</span><br style="font-family:Tahoma; font-size:13px" clear="none">
<span style="font-family:Tahoma; font-size:13px"> << ")" << std::endl;</span></div>
<div style="font-size:13px; color:rgb(0,0,0); font-family:Tahoma; background-color:transparent; font-style:normal">
<span class="Apple-tab-span" style="white-space:pre"></span><span style="font-size:16px">box->RequestSetTransformAndParent( </span>trackerToolTransform<span style="font-size:16px; background-color:transparent">, m_WorldReference );</span></div>
<div style="font-size:13px; color:rgb(0,0,0); font-family:Tahoma; background-color:transparent; font-style:normal">
<span style="font-family:Tahoma; font-size:13px"> }</span><br style="font-family:Tahoma; font-size:13px" clear="none">
<span style="font-family:Tahoma; font-size:13px"> }</span><br style="font-family:Tahoma; font-size:13px" clear="none">
</div>
<div style="font-size:16px; color:rgb(0,0,0); font-family:'Times New Roman'; background-color:transparent; font-style:normal">
<span style="background-color:transparent"><br>
</span></div>
<div style="font-size:12pt">
<div style="font-family:'times new roman','new york',times,serif; font-size:12pt">
<div dir="ltr">
<hr size="1">
<font face="Arial" size="2"><b><span style="font-weight:bold">From:</span></b> "steve.berger@istb.unibe.ch" <steve.berger@istb.unibe.ch><br>
<b><span style="font-weight:bold">To:</span></b> ionutcelgroaznic@yahoo.com <br>
<b><span style="font-weight:bold">Sent:</span></b> Monday, March 17, 2014 9:44 AM<br>
<b><span style="font-weight:bold">Subject:</span></b> RE:[IGSTK-Users] not able to display the tracker tool<br>
</font></div>
<div class="y_msg_container"><br>
<div id="yiv4588813794"><style type="text/css">
<!--
-->
</style>
<div>
<div style="direction:ltr; font-family:Tahoma; color:rgb(0,0,0); font-size:10pt">
Hi,<br clear="none">
<br clear="none">
Thank you for your answer!<br clear="none">
Indeed, I was thinking the error was about the connection from the tool to the 3D view, but I can't find the solution.<br clear="none">
<br clear="none">
Could you give me a hand please?<br clear="none">
<br clear="none">
Thanks,<br clear="none">
<br clear="none">
<div><br clear="none">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px"><font color="808080"><b><font face="Tahoma">Steve Berger</font></b><br clear="none">
<br clear="none">
________________________________________<br clear="none">
<br clear="none">
Institute for Surgical Technology & Biomechanics<br clear="none">
Computational Bioengineering Group</font><br clear="none">
<br clear="none">
<font color="808080">Stauffacherstrasse 78<br clear="none">
CH-3014 Bern<br clear="none">
<br clear="none">
<a rel="nofollow" shape="rect" href="http://www.istb.unibe.ch/" target="_blank">http://www.istb.unibe.ch</a></font><br clear="none">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div style="font-family:'Times New Roman'; color:rgb(0,0,0); font-size:16px">
<hr tabindex="-1">
<div id="yiv4588813794divRpF164366" style="direction:ltr"><font color="#000000" face="Tahoma" size="2"><b>De :</b> ionut iorgovan [ionutcelgroaznic@yahoo.com]<br clear="none">
<b>Envoyé :</b> dimanche, 16. mars 2014 05:50<br clear="none">
<b>À :</b> Berger, Steve (ISTB)<br clear="none">
<b>Objet :</b> Re: [IGSTK-Users] not able to display the tracker tool<br clear="none">
</font><br clear="none">
</div>
<div></div>
<div class="yiv4588813794yqt7700947483" id="yiv4588813794yqt20948">
<div>
<div style="color:rgb(0,0,0); background-color:rgb(255,255,255); font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif; font-size:12pt">
<div>You are not connecting correctlly the transformation from tool to the 3D View</div>
<div><br clear="none">
</div>
<div style="font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif; font-size:12pt">
<div style="font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif; font-size:12pt">
<div dir="ltr">
<hr size="1">
<font face="Arial" size="2"><b><span style="font-weight:bold">From:</span></b> "steve.berger@istb.unibe.ch" <steve.berger@istb.unibe.ch><br clear="none">
<b><span style="font-weight:bold">To:</span></b> igstk-users@public.kitware.com <br clear="none">
<b><span style="font-weight:bold">Sent:</span></b> Friday, March 14, 2014 5:17 PM<br clear="none">
<b><span style="font-weight:bold">Subject:</span></b> [IGSTK-Users] not able to display the tracker tool<br clear="none">
</font></div>
<div class="yiv4588813794y_msg_container"><br clear="none">
<div id="yiv4588813794"><style type="text/css">
<!--
#yiv4588813794 #yiv4588813794 -- p
{margin-top:0;
margin-bottom:0}
#yiv4588813794 #yiv4588813794 body
{direction:ltr;
font-family:Tahoma;
color:#000000;
font-size:10pt}
#yiv4588813794 p
{margin-top:0;
margin-bottom:0}
-->
BODY {direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;}P {margin-top:0;margin-bottom:0;}BODY {scrollbar-base-color:undefined;scrollbar-highlight-color:undefined;scrollbar-darkshadow-color:undefined;scrollbar-track-color:undefined;scrollbar-arrow-color:undefined}BODY {scrollbar-base-color:undefined;scrollbar-highlight-color:undefined;scrollbar-darkshadow-color:undefined;scrollbar-track-color:undefined;scrollbar-arrow-color:undefined}</style>
<div>
<div style="direction:ltr; font-family:Tahoma; color:rgb(0,0,0); font-size:10pt">
Hi,<br clear="none">
<br clear="none">
I am following the examples and tests to display a tracking tool in IGSTK, but I cannot display the tracking tool.<br clear="none">
I am able to track the position of the tool, print it, but not able to display it in the 3DView.<br clear="none">
<br clear="none">
My code is very simple, it has just a main.cpp (see below) as well as a QT pro file (below).<br clear="none">
<br clear="none">
I already tried a very lot, but can't find the error...<br clear="none">
So where is the error ???<br clear="none">
<br clear="none">
I use a Polaris camera, IGSTK 5.2 along with QT.<br clear="none">
<br clear="none">
Kind regards,<br clear="none">
<div><br clear="none">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px"><font color="808080"><b><font face="Tahoma">Steve Berger</font></b><br clear="none">
<br clear="none">
</font><br clear="none">
<br clear="none">
--------------------------------------------------------------------------<br clear="none">
<font color="000000">MAIN</font>.CPP<br clear="none">
-------------------------------------------------------------------------<br clear="none">
<br clear="none">
<br clear="none">
#include <QApplication><br clear="none">
#include <QtTest/QTest><br clear="none">
#include <QMainWindow><br clear="none">
<br clear="none">
#include <iostream><br clear="none">
<br clear="none">
#include "igstkView2D.h"<br clear="none">
#include "igstkView3D.h"<br clear="none">
#include "igstkAxesObject.h"<br clear="none">
#include "igstkAxesObjectRepresentation.h"<br clear="none">
#include "igstkBoxObject.h"<br clear="none">
#include "igstkBoxObjectRepresentation.h"<br clear="none">
#include "igstkMeshObject.h"<br clear="none">
#include "igstkMeshObjectRepresentation.h"<br clear="none">
#include "igstkEvents.h"<br clear="none">
#include "igstkTransformObserver.h"<br clear="none">
#include "igstkEllipsoidObject.h"<br clear="none">
#include "igstkCylinderObject.h"<br clear="none">
#include "igstkEllipsoidObjectRepresentation.h"<br clear="none">
#include "igstkCylinderObjectRepresentation.h"<br clear="none">
<br clear="none">
#include "igstkLogger.h"<br clear="none">
#include "itkStdStreamLogOutput.h"<br clear="none">
<br clear="none">
#include "igstkPolarisTracker.h"<br clear="none">
#include "igstkPolarisTrackerTool.h"<br clear="none">
<br clear="none">
#include "igstkSerialCommunication.h"<br clear="none">
<br clear="none">
#include "igstkQTWidget.h"<br clear="none">
<br clear="none">
int main( int argc, char * argv[])<br clear="none">
{<br clear="none">
igstk::RealTimeClock::Initialize();<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
// *******************************<br clear="none">
// INSTANCES<br clear="none">
//********************************<br clear="none">
<br clear="none">
// logger<br clear="none">
igstk::Object::LoggerType::Pointer m_Logger = igstk::Object::LoggerType::New();<br clear="none">
itk::StdStreamLogOutput::Pointer m_LogOutput = itk::StdStreamLogOutput::New();<br clear="none">
<br clear="none">
// tracker<br clear="none">
igstk::PolarisTracker::Pointer m_Tracker = igstk::PolarisTracker::New();<br clear="none">
igstk::PolarisTrackerTool::Pointer m_TrackerTool = igstk::PolarisTrackerTool::New();<br clear="none">
igstk::SerialCommunication::Pointer m_Communication = igstk::SerialCommunication::New();<br clear="none">
<br clear="none">
//observer<br clear="none">
igstk::TransformObserver::Pointer coordSystemAObserver = igstk::TransformObserver::New();<br clear="none">
<br clear="none">
//transformation<br clear="none">
const double longestValidityTime = igstk::TimeStamp::GetLongestPossibleTime();<br clear="none">
igstk::Transform identityTransform;<br clear="none">
identityTransform.SetToIdentity(longestValidityTime);<br clear="none">
igstk::Transform boxTransform;<br clear="none">
igstk::Transform::VectorType boxTranslation;<br clear="none">
igstk::Transform::VersorType boxRotation;<br clear="none">
igstk::Transform::ErrorType boxErrorValue = 0.01; // 10 microns<br clear="none">
<br clear="none">
//objects<br clear="none">
igstk::EllipsoidObject::Pointer ellipsoid = igstk::EllipsoidObject::New();<br clear="none">
igstk::EllipsoidObjectRepresentation::Pointer ellipsoidRepresentation = igstk::EllipsoidObjectRepresentation::New();<br clear="none">
igstk::CylinderObject::Pointer cylinder = igstk::CylinderObject::New();<br clear="none">
igstk::CylinderObjectRepresentation::Pointer cylinderRepresentation = igstk::CylinderObjectRepresentation::New();<br clear="none">
igstk::BoxObject::Pointer box = igstk::BoxObject::New();<br clear="none">
igstk::BoxObjectRepresentation::Pointer boxRepresentation = igstk::BoxObjectRepresentation::New();<br clear="none">
<br clear="none">
//views<br clear="none">
igstk::View3D::Pointer View3D = igstk::View3D::New();<br clear="none">
<br clear="none">
//QT<br clear="none">
QApplication myApp(argc, argv);<br clear="none">
QMainWindow myMainWindow;<br clear="none">
igstk::QTWidget* qtWidget3D = new igstk::QTWidget();<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
// *******************************<br clear="none">
// LOGGER<br clear="none">
//********************************<br clear="none">
m_LogOutput->SetStream(std::cout);<br clear="none">
m_Logger->AddLogOutput(m_LogOutput);<br clear="none">
//m_Logger->SetPriorityLevel( itk::Logger::DEBUG);<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
// *******************************<br clear="none">
// OBJECTS<br clear="none">
//********************************<br clear="none">
<br clear="none">
// Create the ellipsoid<br clear="none">
ellipsoid->SetRadius(100,100,150);<br clear="none">
ellipsoidRepresentation->RequestSetEllipsoidObject( ellipsoid );<br clear="none">
ellipsoidRepresentation->SetColor(0.0,1.0,0.0);<br clear="none">
ellipsoidRepresentation->SetOpacity(0.2);<br clear="none">
<br clear="none">
// Create the cylinder<br clear="none">
cylinder->SetRadius(20.0);<br clear="none">
cylinder->SetHeight(300.0);<br clear="none">
cylinderRepresentation->RequestSetCylinderObject( cylinder );<br clear="none">
cylinderRepresentation->SetColor(1.0,0.0,0.0);<br clear="none">
cylinderRepresentation->SetOpacity(1.0);<br clear="none">
<br clear="none">
// Create the box<br clear="none">
box->SetSize(80,80,80);<br clear="none">
boxRepresentation->RequestSetBoxObject( box );<br clear="none">
boxRepresentation->SetColor(0.0,0.0,1.0);<br clear="none">
boxRepresentation->SetOpacity(1.0);<br clear="none">
boxTranslation[0] = 100.0;<br clear="none">
boxTranslation[1] = 200.0;<br clear="none">
boxTranslation[2] = -1300.0;<br clear="none">
boxRotation.Set( 0.0, 0.0, 0.0, 1.0 );<br clear="none">
boxTransform.SetTranslationAndRotation(boxTranslation, boxRotation, boxErrorValue, longestValidityTime );<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
// *******************************<br clear="none">
// TRACKER<br clear="none">
//********************************<br clear="none">
<br clear="none">
//serial communication<br clear="none">
//m_Communication->SetLogger( m_Logger );<br clear="none">
m_Communication->SetPortNumber( igstk::SerialCommunication::PortNumber0 );<br clear="none">
m_Communication->SetParity( igstk::SerialCommunication::NoParity );<br clear="none">
m_Communication->SetBaudRate( igstk::SerialCommunication::BaudRate115200 );<br clear="none">
m_Communication->SetDataBits( igstk::SerialCommunication::DataBits8 );<br clear="none">
m_Communication->SetStopBits( igstk::SerialCommunication::StopBits1 );<br clear="none">
m_Communication->SetHardwareHandshake(igstk::SerialCommunication::HandshakeOff );<br clear="none">
m_Communication->SetCapture( true );<br clear="none">
<br clear="none">
igstk::Communication::ResultType openCommOutput = m_Communication->OpenCommunication();<br clear="none">
if( openCommOutput == igstk::Communication::SUCCESS)<br clear="none">
std::cout<<"SerialComm: OpenCommunication OK"<<std::endl;<br clear="none">
else if(openCommOutput == igstk::Communication::TIMEOUT)<br clear="none">
std::cout<<"SerialComm: OpenCommunication TIMEOUT"<<std::endl;<br clear="none">
else if(openCommOutput == igstk::Communication::FAILURE)<br clear="none">
std::cout<<"SerialComm: OpenCommunication FAILED"<<std::endl;<br clear="none">
<br clear="none">
<br clear="none">
// tracker<br clear="none">
//m_Tracker->SetLogger(m_Logger);<br clear="none">
m_Tracker->SetCommunication(m_Communication);<br clear="none">
m_Tracker->RequestOpen();<br clear="none">
<br clear="none">
<br clear="none">
// tool<br clear="none">
// m_TrackerTool->SetLogger(m_Logger);<br clear="none">
m_TrackerTool->RequestSelectWirelessTrackerTool();<br clear="none">
m_TrackerTool->RequestSetSROMFileName("../Resources/TrackerROMfiles/ISTB0050.rom");<br clear="none">
m_TrackerTool->RequestConfigure();<br clear="none">
m_TrackerTool->RequestAttachToTracker(m_Tracker);<br clear="none">
<br clear="none">
<br clear="none">
//observer<br clear="none">
coordSystemAObserver->ObserveTransformEventsFrom(m_TrackerTool);<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
//start tracking<br clear="none">
m_Tracker->RequestStartTracking();<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
// *******************************<br clear="none">
// TRANSFORM AND PARENTS<br clear="none">
//********************************<br clear="none">
<br clear="none">
View3D->RequestSetTransformAndParent(identityTransform, ellipsoid);<br clear="none">
box->RequestSetTransformAndParent( boxTransform, ellipsoid );<br clear="none">
m_Tracker->RequestSetTransformAndParent(identityTransform, View3D);<br clear="none">
cylinder->RequestSetTransformAndParent(identityTransform, m_TrackerTool);<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
// *******************************<br clear="none">
// 3DView<br clear="none">
//********************************<br clear="none">
//View3D->SetLogger(m_Logger);<br clear="none">
View3D->RequestAddObject(ellipsoidRepresentation->Copy());<br clear="none">
View3D->RequestAddObject(cylinderRepresentation);<br clear="none">
View3D->RequestAddObject(boxRepresentation->Copy());<br clear="none">
View3D->SetRefreshRate( 30 ); // Hz<br clear="none">
<br clear="none">
View3D->RequestResetCamera();<br clear="none">
View3D->RequestStart();<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
// *******************************<br clear="none">
// QT<br clear="none">
//********************************<br clear="none">
qtWidget3D->RequestSetView( View3D );<br clear="none">
qtWidget3D->RequestEnableInteractions();<br clear="none">
myMainWindow.setCentralWidget(qtWidget3D);<br clear="none">
myMainWindow.setFixedSize(720,576);<br clear="none">
myMainWindow.show();<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
// *******************************<br clear="none">
// MAIN LOOP<br clear="none">
//********************************<br clear="none">
<br clear="none">
while(1)<br clear="none">
{<br clear="none">
std::cout<<"\n\n"<<std::endl;<br clear="none">
QTest::qWait(250);<br clear="none">
igstk::PulseGenerator::CheckTimeouts();<br clear="none">
<br clear="none">
//print tracker position<br clear="none">
igstk::Transform trackerToolTransform;<br clear="none">
::itk::Vector<double, 3> trackerToolTranslation;<br clear="none">
coordSystemAObserver->Clear();<br clear="none">
m_TrackerTool->RequestGetTransformToParent();<br clear="none">
if (coordSystemAObserver->GotTransform())<br clear="none">
{<br clear="none">
trackerToolTransform = coordSystemAObserver->GetTransform();<br clear="none">
if ( trackerToolTransform.IsValidNow() )<br clear="none">
{<br clear="none">
trackerToolTranslation = trackerToolTransform.GetTranslation();<br clear="none">
std::cout << "Trackertool :"<br clear="none">
<< m_TrackerTool->GetTrackerToolIdentifier()<br clear="none">
<< "\t\t Position = ("<br clear="none">
<< trackerToolTranslation[0]<br clear="none">
<< ","<br clear="none">
<< trackerToolTranslation[1]<br clear="none">
<< ","<br clear="none">
<< trackerToolTranslation[2]<br clear="none">
<< ")" << std::endl;<br clear="none">
}<br clear="none">
}<br clear="none">
<br clear="none">
<br clear="none">
}<br clear="none">
<br clear="none">
<br clear="none">
return EXIT_SUCCESS;<br clear="none">
<br clear="none">
<br clear="none">
}<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
--------------------------------------------------------------------------<br clear="none">
<font color="000000">.PRO FILE</font><br clear="none">
-------------------------------------------------------------------------<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
QT += core gui network \<br clear="none">
widgets printsupport<br clear="none">
<br clear="none">
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets<br clear="none">
<br clear="none">
QT += testlib #to be able to use the QtTest library<br clear="none">
DESTDIR = $$PWD #to say that we are working from this project directory (to easily set up relative filepath)<br clear="none">
<br clear="none">
HEADERS += \<br clear="none">
<br clear="none">
<br clear="none">
SOURCES += \<br clear="none">
src/main.cpp \<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
#include the geometry library<br clear="none">
INCLUDEPATH += /usr/local/include/Geometry<br clear="none">
<br clear="none">
<br clear="none">
#include IGSTK<br clear="none">
INCLUDEPATH += /usr/local/include/IGSTK<br clear="none">
INCLUDEPATH += /home/berger/SpineBot/kitware/igstk/IGSTK-5.2/bin/Testing/<br clear="none">
<br clear="none">
#include ITK<br clear="none">
INCLUDEPATH += /usr/local/include/ITK-4.4<br clear="none">
INCLUDEPATH += /usr/local/include/ITK-4.4/vnl<br clear="none">
<br clear="none">
<br clear="none">
#include VTK<br clear="none">
INCLUDEPATH += /usr/local/include/vtk-5.10<br clear="none">
<br clear="none">
<br clear="none">
#lib geometry<br clear="none">
LIBS += /usr/local/lib/libGeometry.a<br clear="none">
<br clear="none">
#lib igstk<br clear="none">
LIBS += -L/usr/local/lib/IGSTK<br clear="none">
LIBS += -lIGSTK<br clear="none">
LIBS += -lSceneGraphVisualization<br clear="none">
<br clear="none">
<br clear="none">
#lib ITK<br clear="none">
LIBS += -L/usr/local/lib/<br clear="none">
LIBS += -lITKBiasCorrection-4.4<br clear="none">
LIBS += -lITKBioCell-4.4<br clear="none">
LIBS += -lITKCommon-4.4<br clear="none">
LIBS += -lITKDICOMParser-4.4<br clear="none">
LIBS += -litkdouble-conversion-4.4<br clear="none">
LIBS += -lITKEXPAT-4.4<br clear="none">
LIBS += -lITKFEM-4.4<br clear="none">
LIBS += -litkgdcmCommon-4.4<br clear="none">
LIBS += -litkgdcmDICT-4.4<br clear="none">
LIBS += -litkgdcmDSED-4.4<br clear="none">
LIBS += -litkgdcmIOD-4.4<br clear="none">
LIBS += -litkgdcmjpeg12-4.4<br clear="none">
LIBS += -litkgdcmjpeg16-4.4<br clear="none">
LIBS += -litkgdcmjpeg8-4.4<br clear="none">
LIBS += -litkgdcmMSFF-4.4<br clear="none">
LIBS += -litkgdcmuuid-4.4<br clear="none">
LIBS += -lITKgiftiio-4.4<br clear="none">
LIBS += -litkhdf5-4.4<br clear="none">
LIBS += -litkhdf5_cpp-4.4<br clear="none">
LIBS += -lITKIOBioRad-4.4<br clear="none">
LIBS += -lITKIOBMP-4.4<br clear="none">
LIBS += -lITKIOCSV-4.4<br clear="none">
LIBS += -lITKIOGDCM-4.4<br clear="none">
LIBS += -lITKIOGE-4.4<br clear="none">
LIBS += -lITKIOGIPL-4.4<br clear="none">
LIBS += -lITKIOHDF5-4.4<br clear="none">
LIBS += -lITKIOImageBase-4.4<br clear="none">
LIBS += -lITKIOIPL-4.4<br clear="none">
LIBS += -lITKIOJPEG-4.4<br clear="none">
LIBS += -lITKIOLSM-4.4<br clear="none">
LIBS += -lITKIOMesh-4.4<br clear="none">
LIBS += -lITKIOMeta-4.4<br clear="none">
LIBS += -lITKIONIFTI-4.4<br clear="none">
LIBS += -lITKIONRRD-4.4<br clear="none">
LIBS += -lITKIOPNG-4.4<br clear="none">
LIBS += -lITKIOSiemens-4.4<br clear="none">
LIBS += -lITKIOSpatialObjects-4.4<br clear="none">
LIBS += -lITKIOStimulate-4.4<br clear="none">
LIBS += -lITKIOTIFF-4.4<br clear="none">
LIBS += -lITKIOTransformBase-4.4<br clear="none">
LIBS += -lITKIOTransformHDF5-4.4<br clear="none">
LIBS += -lITKIOTransformInsightLegacy-4.4<br clear="none">
LIBS += -lITKIOTransformMatlab-4.4<br clear="none">
LIBS += -lITKIOVTK-4.4<br clear="none">
LIBS += -lITKIOXML-4.4<br clear="none">
LIBS += -litkjpeg-4.4<br clear="none">
LIBS += -lITKKLMRegionGrowing-4.4<br clear="none">
LIBS += -lITKLabelMap-4.4<br clear="none">
LIBS += -lITKMesh-4.4<br clear="none">
LIBS += -lITKMetaIO-4.4<br clear="none">
LIBS += -litkNetlibSlatec-4.4<br clear="none">
LIBS += -lITKniftiio-4.4<br clear="none">
LIBS += -lITKNrrdIO-4.4<br clear="none">
LIBS += -litkopenjpeg-4.4<br clear="none">
LIBS += -lITKOptimizers-4.4<br clear="none">
LIBS += -lITKOptimizersv4-4.4<br clear="none">
LIBS += -lITKPath-4.4<br clear="none">
LIBS += -litkpng-4.4<br clear="none">
LIBS += -lITKPolynomials-4.4<br clear="none">
LIBS += -lITKQuadEdgeMesh-4.4<br clear="none">
LIBS += -lITKReview-4.4<br clear="none">
LIBS += -lITKSpatialObjects-4.4<br clear="none">
LIBS += -lITKStatistics-4.4<br clear="none">
LIBS += -litksys-4.4<br clear="none">
LIBS += -litktiff-4.4<br clear="none">
LIBS += -litkv3p_lsqr-4.4<br clear="none">
LIBS += -litkv3p_netlib-4.4<br clear="none">
LIBS += -litkvcl-4.4<br clear="none">
LIBS += -lITKVideoCore-4.4<br clear="none">
LIBS += -lITKVideoIO-4.4<br clear="none">
LIBS += -litkvnl-4.4<br clear="none">
LIBS += -litkvnl_algo-4.4<br clear="none">
LIBS += -lITKVNLInstantiation-4.4<br clear="none">
LIBS += -lITKVTK-4.4<br clear="none">
LIBS += -lITKWatersheds-4.4<br clear="none">
LIBS += -litkzlib-4.4<br clear="none">
LIBS += -lITKznz-4.4<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
#lib VTK<br clear="none">
LIBS += -L/usr/local/lib/vtk-5.10<br clear="none">
LIBS += -lLSDyna<br clear="none">
LIBS += -lMapReduceMPI<br clear="none">
LIBS += -lmpistubs<br clear="none">
LIBS += -lQVTK<br clear="none">
LIBS += -lvtkalglib<br clear="none">
LIBS += -lvtkCharts<br clear="none">
LIBS += -lvtkCommon<br clear="none">
LIBS += -lvtkDICOMParser<br clear="none">
LIBS += -lvtkexoIIc<br clear="none">
LIBS += -lvtkexpat<br clear="none">
LIBS += -lvtkFiltering<br clear="none">
LIBS += -lvtkfreetype<br clear="none">
LIBS += -lvtkftgl<br clear="none">
LIBS += -lvtkGenericFiltering<br clear="none">
LIBS += -lvtkGeovis<br clear="none">
LIBS += -lvtkGraphics<br clear="none">
LIBS += -lvtkhdf5<br clear="none">
LIBS += -lvtkhdf5_hl<br clear="none">
LIBS += -lvtkHybrid<br clear="none">
LIBS += -lvtkImaging<br clear="none">
LIBS += -lvtkInfovis<br clear="none">
LIBS += -lvtkIO<br clear="none">
LIBS += -lvtkjpeg<br clear="none">
LIBS += -lvtklibxml2<br clear="none">
LIBS += -lvtkmetaio<br clear="none">
LIBS += -lvtkNetCDF<br clear="none">
LIBS += -lvtkNetCDF_cxx<br clear="none">
LIBS += -lvtkpng<br clear="none">
LIBS += -lvtkproj4<br clear="none">
LIBS += -lvtkQtChart<br clear="none">
LIBS += -lvtkRendering<br clear="none">
LIBS += -lvtksqlite<br clear="none">
LIBS += -lvtksys<br clear="none">
LIBS += -lvtktiff<br clear="none">
LIBS += -lvtkverdict<br clear="none">
LIBS += -lvtkViews<br clear="none">
LIBS += -lvtkVolumeRendering<br clear="none">
LIBS += -lvtkWidgets<br clear="none">
LIBS += -lvtkzlib<br clear="none">
<br clear="none">
<br clear="none">
<br clear="none">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br clear="none">
_______________________________________________<br clear="none">
Powered by www.kitware.com<br clear="none">
<br clear="none">
Visit other Kitware open-source projects at <a rel="nofollow" shape="rect" href="http://www.kitware.com/opensource/opensource.html" target="_blank">
http://www.kitware.com/opensource/opensource.html</a><br clear="none">
<br clear="none">
Follow this link to subscribe/unsubscribe:<br clear="none">
<a rel="nofollow" shape="rect" href="http://public.kitware.com/cgi-bin/mailman/listinfo/igstk-users" target="_blank">http://public.kitware.com/cgi-bin/mailman/listinfo/igstk-users</a><br clear="none">
<br clear="none">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>