Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <mitkNavigationDataSequentialPlayer.h>
00020 #include <mitkStandardFileLocations.h>
00021 #include "mitkTestingMacros.h"
00022
00023 #include <iostream>
00024 #include <sstream>
00025
00026 const char* XML_STRING =
00027 "<?xml version=\"1.0\" ?><Version Ver=\"1\" /><Data ToolCount=\"2\">"
00028 "<ND Time=\"1375.79\" Tool=\"0\" X=\"-279.14\" Y=\"40.48\" Z=\"-2023.72\" QX=\"0.0085\" QY=\"-0.0576\" QZ=\"-0.0022\" QR=\"0.9982\" C00=\"0.00168921\" C01=\"0\" C02=\"0\" C03=\"0\" C04=\"0\" C05=\"0\" C10=\"0\" C11=\"0.00168921\" C12=\"0\" C13=\"0\" C14=\"0\" C15=\"0\" Valid=\"1\" hO=\"1\" hP=\"1\" />"
00029 "<ND Time=\"1375.79\" Tool=\"1\" X=\"-142.54\" Y=\"43.67\" Z=\"-1913.5\" QX=\"0.4478\" QY=\"-0.092\" QZ=\"-0.8824\" QR=\"0.1102\" C00=\"0.104782\" C01=\"0\" C02=\"0\" C03=\"0\" C04=\"0\" C05=\"0\" C10=\"0\" C11=\"0.104782\" C12=\"0\" C13=\"0\" C14=\"0\" C15=\"0\" Valid=\"1\" hO=\"1\" hP=\"1\" />"
00030 "<ND Time=\"9948.11\" Tool=\"0\" X=\"-336.65\" Y=\"138.5\" Z=\"-2061.07\" QX=\"0.1251\" QY=\"-0.0638\" QZ=\"0.0071\" QR=\"0.99\" C00=\"0.023593\" C01=\"0\" C02=\"0\" C03=\"0\" C04=\"0\" C05=\"0\" C10=\"0\" C11=\"0.023593\" C12=\"0\" C13=\"0\" C14=\"0\" C15=\"0\" Valid=\"1\" hO=\"1\" hP=\"1\" />"
00031 "<ND Time=\"9948.11\" Tool=\"1\" X=\"-202.09\" Y=\"120.33\" Z=\"-1949.81\" QX=\"0.4683\" QY=\"0.0188\" QZ=\"-0.8805\" QR=\"0.0696\" C00=\"0.0913248\" C01=\"0\" C02=\"0\" C03=\"0\" C04=\"0\" C05=\"0\" C10=\"0\" C11=\"0.0913248\" C12=\"0\" C13=\"0\" C14=\"0\" C15=\"0\" Valid=\"1\" hO=\"1\" hP=\"1\" />"
00032 "<ND Time=\"104845\" Tool=\"0\" X=\"-134.86\" Y=\"295.49\" Z=\"-2187.63\" QX=\"0.1846\" QY=\"-0.2565\" QZ=\"-0.0829\" QR=\"0.945\" C00=\"0.022082\" C01=\"0\" C02=\"0\" C03=\"0\" C04=\"0\" C05=\"0\" C10=\"0\" C11=\"0.022082\" C12=\"0\" C13=\"0\" C14=\"0\" C15=\"0\" Valid=\"1\" hO=\"1\" hP=\"1\" />"
00033 "<ND Time=\"104845\" Tool=\"1\" X=\"-56.93\" Y=\"233.79\" Z=\"-2042.6\" QX=\"-0.6264\" QY=\"-0.0197\" QZ=\"0.7772\" QR=\"0.0562\" C00=\"0.0915063\" C01=\"0\" C02=\"0\" C03=\"0\" C04=\"0\" C05=\"0\" C10=\"0\" C11=\"0.0915063\" C12=\"0\" C13=\"0\" C14=\"0\" C15=\"0\" Valid=\"1\" hO=\"1\" hP=\"1\" />"
00034 "</Data>";
00035
00036 vnl_vector<mitk::ScalarType> tTool0Snapshot1(3);
00037 vnl_vector<mitk::ScalarType> tTool1Snapshot2(3);
00038 mitk::Quaternion qTool0Snapshot0;
00039 mitk::Quaternion qTool1Snapshot1;
00040
00041 mitk::NavigationDataSequentialPlayer::Pointer player(
00042 mitk::NavigationDataSequentialPlayer::New());
00043
00044 void runLoop()
00045 {
00046 mitk::NavigationData::Pointer nd0;
00047 mitk::NavigationData::Pointer nd1;
00048 for(unsigned int i=0; i<player->GetNumberOfSnapshots();++i)
00049 {
00050 player->Update();
00051 nd0 = player->GetOutput();
00052 nd1 = player->GetOutput(1);
00053
00054
00055 MITK_TEST_CONDITION_REQUIRED(nd0.IsNotNull(), "nd0.IsNotNull()");
00056 MITK_TEST_CONDITION_REQUIRED(nd1.IsNotNull(), "nd1.IsNotNull()");
00057
00058 if(i==0)
00059 {
00060 MITK_TEST_CONDITION(qTool0Snapshot0.as_vector() == nd0->GetOrientation().as_vector(),
00061 "qTool0Snapshot0.as_vector() == nd0->GetOrientation().as_vector()");
00062 }
00063 else if(i==1)
00064 {
00065 MITK_TEST_CONDITION(tTool0Snapshot1 == nd0->GetPosition().GetVnlVector(),
00066 "tTool0Snapshot1 == nd0->GetPosition().GetVnlVector()");
00067
00068 MITK_TEST_CONDITION(qTool1Snapshot1.as_vector() == nd1->GetOrientation().as_vector(),
00069 "qTool1Snapshot1.as_vector() == nd1->GetOrientation().as_vector()");
00070 }
00071 else if(i==2)
00072 {
00073 MITK_TEST_CONDITION(tTool1Snapshot2 == nd1->GetPosition().GetVnlVector(),
00074 "tTool1Snapshot2 == nd1->GetPosition().GetVnlVector()");
00075 }
00076
00077 }
00078 }
00079
00083 int mitkNavigationDataSequentialPlayerTest(int , char* [])
00084 {
00085 MITK_TEST_BEGIN("NavigationDataSequentialPlayer");
00086
00087
00088 tTool0Snapshot1[0] = -336.65;
00089 tTool0Snapshot1[1] = 138.5;
00090 tTool0Snapshot1[2]= -2061.07;
00091 tTool1Snapshot2[0] = -56.93;
00092 tTool1Snapshot2[1] = 233.79;
00093 tTool1Snapshot2[2]= -2042.6;
00094 vnl_vector_fixed<mitk::ScalarType,4> qVec;
00095 qVec[0] = 0.0085;
00096 qVec[1] = -0.0576;
00097 qVec[2]= -0.0022;
00098 qVec[3]= 0.9982;
00099 qTool0Snapshot0 = mitk::Quaternion(qVec);
00100 qVec[0] = 0.4683;
00101 qVec[1] = 0.0188;
00102 qVec[2]= -0.8805;
00103 qVec[3]= 0.0696;
00104 qTool1Snapshot1 = mitk::Quaternion(qVec);
00105
00106 player
00107 ->SetXMLString(XML_STRING);
00108
00109 MITK_TEST_CONDITION_REQUIRED(player->GetNumberOfSnapshots() == 3,
00110 "player->GetNumberOfSnapshots() == 3");
00111 player
00112 ->SetRepeat(true);
00113
00114 runLoop();
00115
00116 runLoop();
00117
00118
00119 player->GoToSnapshot(3);
00120 mitk::NavigationData::Pointer nd1 = player->GetOutput(1);
00121 MITK_TEST_CONDITION(tTool1Snapshot2 == nd1->GetPosition().GetVnlVector(),
00122 "tTool1Snapshot2 == nd1->GetPosition().GetVnlVector()");
00123
00124 player->GoToSnapshot(1);
00125 mitk::NavigationData::Pointer nd0 = player->GetOutput(0);
00126 MITK_TEST_CONDITION(qTool0Snapshot0.as_vector() == nd0->GetOrientation().as_vector(),
00127 "qTool0Snapshot0.as_vector() == nd0->GetOrientation().as_vector()");
00128
00129 player->GoToSnapshot(3);
00130
00131
00132 runLoop();
00133
00134
00135 MITK_TEST_END();
00136 }