<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hi,<br>
<br>
I am following the examples and tests to display a tracking tool in IGSTK, but I cannot display the tracking tool.<br>
I am able to track the position of the tool, print it, but not able to display it in the 3DView.<br>
<br>
My code is very simple, it has just a main.cpp (see below) as well as a QT pro file (below).<br>
<br>
I already tried a very lot, but can't find the error...<br>
So where is the error ???<br>
<br>
I use a Polaris camera, IGSTK 5.2 along with QT.<br>
<br>
Kind regards,<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>
--------------------------------------------------------------------------<br>
<font color="000000">MAIN</font>.CPP<br>
-------------------------------------------------------------------------<br>
<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 "igstkBoxObject.h"<br>
#include "igstkBoxObjectRepresentation.h"<br>
#include "igstkMeshObject.h"<br>
#include "igstkMeshObjectRepresentation.h"<br>
#include "igstkEvents.h"<br>
#include "igstkTransformObserver.h"<br>
#include "igstkEllipsoidObject.h"<br>
#include "igstkCylinderObject.h"<br>
#include "igstkEllipsoidObjectRepresentation.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>
int main( int argc, char * argv[])<br>
{<br>
igstk::RealTimeClock::Initialize();<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>
<br>
//transformation<br>
const double longestValidityTime = igstk::TimeStamp::GetLongestPossibleTime();<br>
igstk::Transform identityTransform;<br>
identityTransform.SetToIdentity(longestValidityTime);<br>
igstk::Transform boxTransform;<br>
igstk::Transform::VectorType boxTranslation;<br>
igstk::Transform::VersorType boxRotation;<br>
igstk::Transform::ErrorType boxErrorValue = 0.01; // 10 microns<br>
<br>
//objects<br>
igstk::EllipsoidObject::Pointer ellipsoid = igstk::EllipsoidObject::New();<br>
igstk::EllipsoidObjectRepresentation::Pointer ellipsoidRepresentation = igstk::EllipsoidObjectRepresentation::New();<br>
igstk::CylinderObject::Pointer cylinder = igstk::CylinderObject::New();<br>
igstk::CylinderObjectRepresentation::Pointer cylinderRepresentation = igstk::CylinderObjectRepresentation::New();<br>
igstk::BoxObject::Pointer box = igstk::BoxObject::New();<br>
igstk::BoxObjectRepresentation::Pointer boxRepresentation = igstk::BoxObjectRepresentation::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>
// 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>
// OBJECTS<br>
//********************************<br>
<br>
// Create the ellipsoid<br>
ellipsoid->SetRadius(100,100,150);<br>
ellipsoidRepresentation->RequestSetEllipsoidObject( ellipsoid );<br>
ellipsoidRepresentation->SetColor(0.0,1.0,0.0);<br>
ellipsoidRepresentation->SetOpacity(0.2);<br>
<br>
// Create the cylinder<br>
cylinder->SetRadius(20.0);<br>
cylinder->SetHeight(300.0);<br>
cylinderRepresentation->RequestSetCylinderObject( cylinder );<br>
cylinderRepresentation->SetColor(1.0,0.0,0.0);<br>
cylinderRepresentation->SetOpacity(1.0);<br>
<br>
// Create the box<br>
box->SetSize(80,80,80);<br>
boxRepresentation->RequestSetBoxObject( box );<br>
boxRepresentation->SetColor(0.0,0.0,1.0);<br>
boxRepresentation->SetOpacity(1.0);<br>
boxTranslation[0] = 100.0;<br>
boxTranslation[1] = 200.0;<br>
boxTranslation[2] = -1300.0;<br>
boxRotation.Set( 0.0, 0.0, 0.0, 1.0 );<br>
boxTransform.SetTranslationAndRotation(boxTranslation, boxRotation, boxErrorValue, longestValidityTime );<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
// *******************************<br>
// TRACKER<br>
//********************************<br>
<br>
//serial communication<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->SetLogger(m_Logger);<br>
m_Tracker->SetCommunication(m_Communication);<br>
m_Tracker->RequestOpen();<br>
<br>
<br>
// tool<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>
<br>
//start tracking<br>
m_Tracker->RequestStartTracking();<br>
<br>
<br>
<br>
<br>
// *******************************<br>
// TRANSFORM AND PARENTS<br>
//********************************<br>
<br>
View3D->RequestSetTransformAndParent(identityTransform, ellipsoid);<br>
box->RequestSetTransformAndParent( boxTransform, ellipsoid );<br>
m_Tracker->RequestSetTransformAndParent(identityTransform, View3D);<br>
cylinder->RequestSetTransformAndParent(identityTransform, m_TrackerTool);<br>
<br>
<br>
<br>
<br>
<br>
<br>
// *******************************<br>
// 3DView<br>
//********************************<br>
//View3D->SetLogger(m_Logger);<br>
View3D->RequestAddObject(ellipsoidRepresentation->Copy());<br>
View3D->RequestAddObject(cylinderRepresentation);<br>
View3D->RequestAddObject(boxRepresentation->Copy());<br>
View3D->SetRefreshRate( 30 ); // Hz<br>
<br>
View3D->RequestResetCamera();<br>
View3D->RequestStart();<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(250);<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>
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>
}<br>
}<br>
<br>
<br>
}<br>
<br>
<br>
return EXIT_SUCCESS;<br>
<br>
<br>
}<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
--------------------------------------------------------------------------<br>
<font color="000000">.PRO FILE</font><br>
-------------------------------------------------------------------------<br>
<br>
<br>
<br>
QT += core gui network \<br>
widgets printsupport<br>
<br>
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets<br>
<br>
QT += testlib #to be able to use the QtTest library<br>
DESTDIR = $$PWD #to say that we are working from this project directory (to easily set up relative filepath)<br>
<br>
HEADERS += \<br>
<br>
<br>
SOURCES += \<br>
src/main.cpp \<br>
<br>
<br>
<br>
#include the geometry library<br>
INCLUDEPATH += /usr/local/include/Geometry<br>
<br>
<br>
#include IGSTK<br>
INCLUDEPATH += /usr/local/include/IGSTK<br>
INCLUDEPATH += /home/berger/SpineBot/kitware/igstk/IGSTK-5.2/bin/Testing/<br>
<br>
#include ITK<br>
INCLUDEPATH += /usr/local/include/ITK-4.4<br>
INCLUDEPATH += /usr/local/include/ITK-4.4/vnl<br>
<br>
<br>
#include VTK<br>
INCLUDEPATH += /usr/local/include/vtk-5.10<br>
<br>
<br>
#lib geometry<br>
LIBS += /usr/local/lib/libGeometry.a<br>
<br>
#lib igstk<br>
LIBS += -L/usr/local/lib/IGSTK<br>
LIBS += -lIGSTK<br>
LIBS += -lSceneGraphVisualization<br>
<br>
<br>
#lib ITK<br>
LIBS += -L/usr/local/lib/<br>
LIBS += -lITKBiasCorrection-4.4<br>
LIBS += -lITKBioCell-4.4<br>
LIBS += -lITKCommon-4.4<br>
LIBS += -lITKDICOMParser-4.4<br>
LIBS += -litkdouble-conversion-4.4<br>
LIBS += -lITKEXPAT-4.4<br>
LIBS += -lITKFEM-4.4<br>
LIBS += -litkgdcmCommon-4.4<br>
LIBS += -litkgdcmDICT-4.4<br>
LIBS += -litkgdcmDSED-4.4<br>
LIBS += -litkgdcmIOD-4.4<br>
LIBS += -litkgdcmjpeg12-4.4<br>
LIBS += -litkgdcmjpeg16-4.4<br>
LIBS += -litkgdcmjpeg8-4.4<br>
LIBS += -litkgdcmMSFF-4.4<br>
LIBS += -litkgdcmuuid-4.4<br>
LIBS += -lITKgiftiio-4.4<br>
LIBS += -litkhdf5-4.4<br>
LIBS += -litkhdf5_cpp-4.4<br>
LIBS += -lITKIOBioRad-4.4<br>
LIBS += -lITKIOBMP-4.4<br>
LIBS += -lITKIOCSV-4.4<br>
LIBS += -lITKIOGDCM-4.4<br>
LIBS += -lITKIOGE-4.4<br>
LIBS += -lITKIOGIPL-4.4<br>
LIBS += -lITKIOHDF5-4.4<br>
LIBS += -lITKIOImageBase-4.4<br>
LIBS += -lITKIOIPL-4.4<br>
LIBS += -lITKIOJPEG-4.4<br>
LIBS += -lITKIOLSM-4.4<br>
LIBS += -lITKIOMesh-4.4<br>
LIBS += -lITKIOMeta-4.4<br>
LIBS += -lITKIONIFTI-4.4<br>
LIBS += -lITKIONRRD-4.4<br>
LIBS += -lITKIOPNG-4.4<br>
LIBS += -lITKIOSiemens-4.4<br>
LIBS += -lITKIOSpatialObjects-4.4<br>
LIBS += -lITKIOStimulate-4.4<br>
LIBS += -lITKIOTIFF-4.4<br>
LIBS += -lITKIOTransformBase-4.4<br>
LIBS += -lITKIOTransformHDF5-4.4<br>
LIBS += -lITKIOTransformInsightLegacy-4.4<br>
LIBS += -lITKIOTransformMatlab-4.4<br>
LIBS += -lITKIOVTK-4.4<br>
LIBS += -lITKIOXML-4.4<br>
LIBS += -litkjpeg-4.4<br>
LIBS += -lITKKLMRegionGrowing-4.4<br>
LIBS += -lITKLabelMap-4.4<br>
LIBS += -lITKMesh-4.4<br>
LIBS += -lITKMetaIO-4.4<br>
LIBS += -litkNetlibSlatec-4.4<br>
LIBS += -lITKniftiio-4.4<br>
LIBS += -lITKNrrdIO-4.4<br>
LIBS += -litkopenjpeg-4.4<br>
LIBS += -lITKOptimizers-4.4<br>
LIBS += -lITKOptimizersv4-4.4<br>
LIBS += -lITKPath-4.4<br>
LIBS += -litkpng-4.4<br>
LIBS += -lITKPolynomials-4.4<br>
LIBS += -lITKQuadEdgeMesh-4.4<br>
LIBS += -lITKReview-4.4<br>
LIBS += -lITKSpatialObjects-4.4<br>
LIBS += -lITKStatistics-4.4<br>
LIBS += -litksys-4.4<br>
LIBS += -litktiff-4.4<br>
LIBS += -litkv3p_lsqr-4.4<br>
LIBS += -litkv3p_netlib-4.4<br>
LIBS += -litkvcl-4.4<br>
LIBS += -lITKVideoCore-4.4<br>
LIBS += -lITKVideoIO-4.4<br>
LIBS += -litkvnl-4.4<br>
LIBS += -litkvnl_algo-4.4<br>
LIBS += -lITKVNLInstantiation-4.4<br>
LIBS += -lITKVTK-4.4<br>
LIBS += -lITKWatersheds-4.4<br>
LIBS += -litkzlib-4.4<br>
LIBS += -lITKznz-4.4<br>
<br>
<br>
<br>
#lib VTK<br>
LIBS += -L/usr/local/lib/vtk-5.10<br>
LIBS += -lLSDyna<br>
LIBS += -lMapReduceMPI<br>
LIBS += -lmpistubs<br>
LIBS += -lQVTK<br>
LIBS += -lvtkalglib<br>
LIBS += -lvtkCharts<br>
LIBS += -lvtkCommon<br>
LIBS += -lvtkDICOMParser<br>
LIBS += -lvtkexoIIc<br>
LIBS += -lvtkexpat<br>
LIBS += -lvtkFiltering<br>
LIBS += -lvtkfreetype<br>
LIBS += -lvtkftgl<br>
LIBS += -lvtkGenericFiltering<br>
LIBS += -lvtkGeovis<br>
LIBS += -lvtkGraphics<br>
LIBS += -lvtkhdf5<br>
LIBS += -lvtkhdf5_hl<br>
LIBS += -lvtkHybrid<br>
LIBS += -lvtkImaging<br>
LIBS += -lvtkInfovis<br>
LIBS += -lvtkIO<br>
LIBS += -lvtkjpeg<br>
LIBS += -lvtklibxml2<br>
LIBS += -lvtkmetaio<br>
LIBS += -lvtkNetCDF<br>
LIBS += -lvtkNetCDF_cxx<br>
LIBS += -lvtkpng<br>
LIBS += -lvtkproj4<br>
LIBS += -lvtkQtChart<br>
LIBS += -lvtkRendering<br>
LIBS += -lvtksqlite<br>
LIBS += -lvtksys<br>
LIBS += -lvtktiff<br>
LIBS += -lvtkverdict<br>
LIBS += -lvtkViews<br>
LIBS += -lvtkVolumeRendering<br>
LIBS += -lvtkWidgets<br>
LIBS += -lvtkzlib<br>
<br>
<br>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>