コード例 #1
0
bool runLoop()
{


  bool success = true;
  mitk::NavigationData::Pointer nd0;
  mitk::NavigationData::Pointer nd1;
  for(unsigned int i=0; i<player->GetNumberOfSnapshots();++i)
  {
    player->Update();
    nd0 = player->GetOutput();
    nd1 = player->GetOutput(1);

    // test some values
    if(nd0.IsNull() || nd1.IsNull()) return false;

    if(i==0)
    {
      if (!(qTool0Snapshot0.as_vector() == nd0->GetOrientation().as_vector())) {success = false;}
    }
    else if(i==1)
    {
      if (!(tTool0Snapshot1 == nd0->GetPosition().GetVnlVector())) {success = false;}
      else if (!(qTool1Snapshot1.as_vector() == nd1->GetOrientation().as_vector())) {success = false;}
    }
    else if(i==2) // should be repeated
    {
      if (!(tTool1Snapshot2 == nd1->GetPosition().GetVnlVector())) {success = false;}
    }

  }
  return success;
}
コード例 #2
0
void TestStandardWorkflow()
{
  // create test values valid for the xml data above
  tTool0Snapshot1[0] = -336.65;
  tTool0Snapshot1[1] = 138.5;
  tTool0Snapshot1[2]= -2061.07;
  tTool1Snapshot2[0] = -56.93;
  tTool1Snapshot2[1] = 233.79;
  tTool1Snapshot2[2]= -2042.6;
  vnl_vector_fixed<mitk::ScalarType,4> qVec;
  qVec[0] = 0.0085;
  qVec[1] = -0.0576;
  qVec[2]= -0.0022;
  qVec[3]= 0.9982;
  qTool0Snapshot0 = mitk::Quaternion(qVec);
  qVec[0] = 0.4683;
  qVec[1] = 0.0188;
  qVec[2]= -0.8805;
  qVec[3]= 0.0696;
  qTool1Snapshot1 = mitk::Quaternion(qVec);

  //test SetXMLString()
  player->SetXMLString(XML_STRING);
  MITK_TEST_CONDITION_REQUIRED(player->GetNumberOfSnapshots() == 3,"Testing method SetXMLString with 3 navigation datas.");
  MITK_TEST_CONDITION_REQUIRED(player->GetNumberOfIndexedOutputs() == 2,"Testing number of outputs");

  //rest repeat
  player->SetRepeat(true);
  MITK_TEST_CONDITION_REQUIRED(runLoop(),"Testing first run.");
  MITK_TEST_CONDITION_REQUIRED(runLoop(),"Testing second run."); //repeat is on should work a second time

  // now test the go to snapshot function
  player->GoToSnapshot(3);
  mitk::NavigationData::Pointer nd1 = player->GetOutput(1);
  MITK_TEST_CONDITION(tTool1Snapshot2 == nd1->GetPosition().GetVnlVector(),
                      "Testing GoToSnapshot() [1]");

  player->GoToSnapshot(1);
  mitk::NavigationData::Pointer nd0 = player->GetOutput();
  MITK_TEST_CONDITION(qTool0Snapshot0.as_vector() == nd0->GetOrientation().as_vector(),
                      "Testing GoToSnapshot() [2]");

  player->GoToSnapshot(3);

  // and a third time
  MITK_TEST_CONDITION_REQUIRED(runLoop(),"Tested if repeat works again.");

}