Functions | Variables

mitkNavigationDataSequentialPlayerTest.cpp File Reference

#include <mitkNavigationDataSequentialPlayer.h>
#include <mitkStandardFileLocations.h>
#include "mitkTestingMacros.h"
#include <iostream>
#include <sstream>

Go to the source code of this file.

Functions

vnl_vector< mitk::ScalarType > tTool0Snapshot1 (3)
vnl_vector< mitk::ScalarType > tTool1Snapshot2 (3)
mitk::NavigationDataSequentialPlayer::Pointer player (mitk::NavigationDataSequentialPlayer::New())
void runLoop ()
int mitkNavigationDataSequentialPlayerTest (int, char *[])

Variables

const char * XML_STRING = "</Data>"
mitk::Quaternion qTool0Snapshot0
mitk::Quaternion qTool1Snapshot1

Function Documentation

int mitkNavigationDataSequentialPlayerTest ( int  ,
char *  [] 
)

Documentation test for the class "NavigationDataRecorder".

Definition at line 83 of file mitkNavigationDataSequentialPlayerTest.cpp.

References MITK_TEST_BEGIN, MITK_TEST_CONDITION, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, player(), qTool0Snapshot0, qTool1Snapshot1, runLoop(), tTool0Snapshot1(), tTool1Snapshot2(), and XML_STRING.

{
  MITK_TEST_BEGIN("NavigationDataSequentialPlayer");

  // 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);

  player
      ->SetXMLString(XML_STRING);

  MITK_TEST_CONDITION_REQUIRED(player->GetNumberOfSnapshots() == 3,
                               "player->GetNumberOfSnapshots() == 3");
  player
      ->SetRepeat(true);

  runLoop();
  // repeat is on should work a second time
  runLoop();

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

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

  player->GoToSnapshot(3);

  // and a third time
  runLoop();

  // always end with this!
  MITK_TEST_END();
}
mitk::NavigationDataSequentialPlayer::Pointer player ( mitk::NavigationDataSequentialPlayer::  New() )
void runLoop (  )

Definition at line 44 of file mitkNavigationDataSequentialPlayerTest.cpp.

References MITK_TEST_CONDITION, MITK_TEST_CONDITION_REQUIRED, player(), qTool0Snapshot0, qTool1Snapshot1, tTool0Snapshot1(), and tTool1Snapshot2().

Referenced by mitkNavigationDataSequentialPlayerTest().

{
  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
    MITK_TEST_CONDITION_REQUIRED(nd0.IsNotNull(), "nd0.IsNotNull()");
    MITK_TEST_CONDITION_REQUIRED(nd1.IsNotNull(), "nd1.IsNotNull()");

    if(i==0)
    {
      MITK_TEST_CONDITION(qTool0Snapshot0.as_vector() == nd0->GetOrientation().as_vector(),
                          "qTool0Snapshot0.as_vector() == nd0->GetOrientation().as_vector()");
    }
    else if(i==1)
    {
      MITK_TEST_CONDITION(tTool0Snapshot1 == nd0->GetPosition().GetVnlVector(),
                          "tTool0Snapshot1 == nd0->GetPosition().GetVnlVector()");

      MITK_TEST_CONDITION(qTool1Snapshot1.as_vector() == nd1->GetOrientation().as_vector(),
                          "qTool1Snapshot1.as_vector() == nd1->GetOrientation().as_vector()");
    }
    else if(i==2) // should be repeated
    {
      MITK_TEST_CONDITION(tTool1Snapshot2 == nd1->GetPosition().GetVnlVector(),
                          "tTool1Snapshot2 == nd1->GetPosition().GetVnlVector()");
    }

  }
}
vnl_vector<mitk::ScalarType> tTool0Snapshot1 (  )
vnl_vector<mitk::ScalarType> tTool1Snapshot2 (  )

Variable Documentation

mitk::Quaternion qTool0Snapshot0
mitk::Quaternion qTool1Snapshot1
const char* XML_STRING = "</Data>"
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines