void TestStandardWorkflow() { // Set NavigationDatas for player player->SetNavigationDataSet(NavigationDataSet); MITK_TEST_CONDITION(player->GetNumberOfSnapshots() == 3,"Testing if player reports correct number of Snapshots"); MITK_TEST_CONDITION(player->GetNumberOfIndexedOutputs() == 2,"Testing number of outputs"); //rest repeat player->SetRepeat(true); MITK_TEST_CONDITION(runLoop(),"Testing first run."); MITK_TEST_CONDITION(runLoop(),"Testing second run."); //repeat is on should work a second time // now test the go to snapshot function player->GoToSnapshot(2); mitk::NavigationData::Pointer nd1 = player->GetOutput(1); mitk::NavigationData::Pointer ref1 = NavigationDataSet->GetNavigationDataForIndex(2,1); MITK_TEST_CONDITION(ref1->GetPosition().GetVnlVector() == nd1->GetPosition().GetVnlVector(), "Testing GoToSnapshot() [1]"); //MITK_TEST_OUTPUT( << "Reference:" << ref1->GetPosition().GetVnlVector() << "\tObserved: " << nd1->GetPosition().GetVnlVector()); player->GoToSnapshot(0); mitk::NavigationData::Pointer nd0 = player->GetOutput(); mitk::NavigationData::Pointer ref0 = NavigationDataSet->GetNavigationDataForIndex(0,0); MITK_TEST_CONDITION(ref0->GetOrientation().as_vector() == nd0->GetOrientation().as_vector(), "Testing GoToSnapshot() [2]"); //MITK_TEST_OUTPUT( << "Reference" << ref0->GetPosition().GetVnlVector() << "\tObserved:" <<nd0->GetOrientation().as_vector() ); }
/* * private hepler method that compares the recorded Dataset against the member variable. * This is a reasonable test only under the assumption that the Data should be equal from coyping - It does not consider * homonymus Quaternions and NO FLOAT ROUNDING ISSUES */ bool compareDataSet(mitk::NavigationDataSet::Pointer recorded) { for (unsigned int tool = 0; tool < recorded->GetNumberOfTools(); tool++){ for (unsigned int i = 0; i < recorded->Size(); i++) { mitk::NavigationData::Pointer ref = m_NavigationDataSet->GetNavigationDataForIndex(i,tool); mitk::NavigationData::Pointer rec = recorded->GetNavigationDataForIndex(i,tool); if (!(ref->GetOrientation().as_vector() == rec->GetOrientation().as_vector())) {return false;} if (!(ref->GetPosition().GetVnlVector() == rec->GetPosition().GetVnlVector())) {return false;} } } return true; }
bool CompareFiles(std::string file) { set = mitk::IOUtil::Load<mitk::NavigationDataSet>(file); double sample[2][30] ={ {5134019.44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5134019.44, 0, 1, 101.2300034, -62.63999939, -203.2400055, -0.3059000075, 0.5752000213, 0, 0.7585999966, 5134019.44, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {5134082.84, 5134073.64, 1, -172.6100006, 12.60999966, -299.4500122, -0.1588999927, 0.4370000064, 0, 0.8852000237, 5134082.84, 5134073.64, 1, 101.2300034, -62.63999939, -203.2400055, -0.3059000075, 0.5752000213, 0, 0.7585999966, 5134082.84, 5134073.64, 0, 0, 0, 0, 0, 0, 0, 0} }; bool returnValue = true; for(int line = 0 ; line < 2; line++) { for (int tool =0; tool < 3; tool ++) { mitk::NavigationData::Pointer testline = set->GetNavigationDataForIndex(line,tool) ; returnValue = returnValue && mitk::Equal( testline->GetIGTTimeStamp() , sample [line] [(tool*10)] ); returnValue = returnValue && mitk::Equal( testline->IsDataValid() , sample [line] [(tool*10)+1] ); mitk::NavigationData::PositionType pos = testline->GetPosition(); returnValue = returnValue && mitk::Equal( pos[0] , sample [line] [(tool*10)+2] ); returnValue = returnValue && mitk::Equal( pos[1] , sample [line] [(tool*10)+3] ); returnValue = returnValue && mitk::Equal( pos[2] , sample [line] [(tool*10)+4] ); mitk::NavigationData::OrientationType ori = testline->GetOrientation(); returnValue = returnValue && mitk::Equal( ori[0] , sample [line] [(tool*10)+5] ); returnValue = returnValue && mitk::Equal( ori[1] , sample [line] [(tool*10)+6] ); returnValue = returnValue && mitk::Equal( ori[2] , sample [line] [(tool*10)+7] ); returnValue = returnValue && mitk::Equal( ori[3] , sample [line] [(tool*10)+8] ); } } return returnValue; }
bool runLoop() { player->Update(); mitk::NavigationData::Pointer nd0; mitk::NavigationData::Pointer nd1; for(unsigned int i=0; i<player->GetNumberOfSnapshots(); ++i) { nd0 = player->GetOutput(0); nd1 = player->GetOutput(1); // test some values if(nd0.IsNull() || nd1.IsNull()) return false; //Compare data mitk::NavigationData::Pointer ref0 = NavigationDataSet->GetNavigationDataForIndex(i,0); mitk::NavigationData::Pointer ref1 = NavigationDataSet->GetNavigationDataForIndex(i,1); if (!(ref0->GetOrientation().as_vector() == nd0->GetOrientation().as_vector())) {return false;} if (!(ref1->GetOrientation().as_vector() == nd1->GetOrientation().as_vector())) {return false;} if (!(ref0->GetPosition().GetVnlVector() == nd0->GetPosition().GetVnlVector())) {return false;} if (!(ref1->GetPosition().GetVnlVector() == nd1->GetPosition().GetVnlVector())) {return false;} // Goto next Snapshot player->GoToNextSnapshot(); } return true; }
void TestRecording() { m_Recorder->StartRecording(); while (!m_Player->IsAtEnd()) { m_Recorder->Update(); m_Player->GoToNextSnapshot(); } mitk::NavigationDataSet::Pointer recordedData = m_Recorder->GetNavigationDataSet(); MITK_TEST_CONDITION_REQUIRED(recordedData->Size() == m_NavigationDataSet->Size(), "Test if recorded Dataset is of equal size as original"); MITK_TEST_CONDITION_REQUIRED(compareDataSet(recordedData), "Test recorded dataset for equality with reference"); }