void TestWriteAndReadSimpleToolStorageWithToolLandmarks()
  {
    //create Tool Storage
    mitk::NavigationToolStorage::Pointer storage = mitk::NavigationToolStorageTestHelper::CreateTestData_StorageWithOneTool();

    //test serialization
    bool success = m_Serializer->Serialize(m_FileName1,storage);
    CPPUNIT_ASSERT_MESSAGE("Testing serialization of tool storage with tool registrations",success);

    //test deserialization of the same file
    mitk::NavigationToolStorage::Pointer readStorage = m_Deserializer->Deserialize(m_FileName1);
    CPPUNIT_ASSERT_MESSAGE("Testing deserialization of tool storage with tool registrations",readStorage.IsNotNull());
    CPPUNIT_ASSERT_MESSAGE(" ..Testing number of tools in storage",readStorage->GetToolCount()==1);

    mitk::PointSet::Pointer readRegLandmarks = readStorage->GetTool(0)->GetToolRegistrationLandmarks();
    mitk::PointSet::Pointer readCalLandmarks = readStorage->GetTool(0)->GetToolCalibrationLandmarks();

    CPPUNIT_ASSERT_MESSAGE("..Testing if tool registration landmarks have been stored and loaded correctly.",((readRegLandmarks->GetPoint(5)[0] == 4)&&(readRegLandmarks->GetPoint(5)[1] == 5)&&(readRegLandmarks->GetPoint(5)[2] == 6)));
    CPPUNIT_ASSERT_MESSAGE("..Testing if tool calibration landmarks have been stored and loaded correctly.",((readCalLandmarks->GetPoint(0)[0] == 1)&&(readCalLandmarks->GetPoint(0)[1] == 2)&&(readCalLandmarks->GetPoint(0)[2] == 3)));

    mitk::Point3D readToolTipPos = readStorage->GetTool(0)->GetToolTipPosition();
    mitk::Quaternion readToolTipRot = readStorage->GetTool(0)->GetToolTipOrientation();

    CPPUNIT_ASSERT_MESSAGE("..Testing if tool tip position has been stored and loaded correctly.",
      ((float(readToolTipPos[0]) == float(1.3423))&&
      (float(readToolTipPos[1]) == float(2.323))&&
      (float(readToolTipPos[2]) == float(4.332))));

    CPPUNIT_ASSERT_MESSAGE("..Testing if tool tip orientation has been stored and loaded correctly.",
      ((float(readToolTipRot.x()) == float(0.1))&&
      (float(readToolTipRot.y()) == float(0.2))&&
      (float(readToolTipRot.z()) == float(0.3))&&
      (float(readToolTipRot.r()) == float(0.4))));
  }
コード例 #2
0
  void TestWriteComplexToolStorage()
  {
    //create navigation tool storage
    mitk::NavigationToolStorage::Pointer myStorage = mitk::NavigationToolStorageTestHelper::CreateTestData_ComplexStorage(GetTestDataFilePath("ClaronTool"),GetTestDataFilePath("IGT-Data/ClaronTool.stl"),GetTestDataFilePath("IGT-Data/EMTool.stl"));

    //test serialization
    bool success = m_Serializer->Serialize(m_FileName1,myStorage);
    CPPUNIT_ASSERT_MESSAGE("Testing serialization of complex tool storage",success);
  }
コード例 #3
0
  void TestWriteSimpleToolStorage()
  {
  //create Tool Storage
    mitk::NavigationToolStorage::Pointer myStorage = mitk::NavigationToolStorageTestHelper::CreateTestData_SimpleStorage();

  //test serialization
  bool success = m_Serializer->Serialize(m_FileName1,myStorage);
  CPPUNIT_ASSERT_MESSAGE("Testing serialization of simple tool storage",success);
  }
コード例 #4
0
  void TestSerializerForExceptions()
  {
    mitk::NavigationToolStorage::Pointer myStorage = mitk::NavigationToolStorage::New();

    //create an invalid filename
    std::string filename = std::string( MITK_TEST_OUTPUT_DIR )+Poco::Path::separator()+"";

    //now try to serialize an check if an exception is thrown
    CPPUNIT_ASSERT_THROW_MESSAGE("Test serialization with empty storage and invalid filename, an exception is expected.",m_Serializer->Serialize(filename,myStorage),mitk::IGTException);
  }
コード例 #5
0
  void TestWriteStorageToInvalidFile()
  {
    //create Tool Storage
    mitk::NavigationToolStorage::Pointer myStorage = mitk::NavigationToolStorageTestHelper::CreateTestData_SimpleStorage();

    //create invalid filename
  #ifdef WIN32
    std::string filename = "C:\342INVALIDFILE<>.storage"; //invalid filename for windows
  #else
    std::string filename = "/dsfdsf:$�$342INVALIDFILE.storage"; //invalid filename for linux
  #endif

    //test serialization (should throw exception)
    CPPUNIT_ASSERT_THROW_MESSAGE("Test serialization with simple storage and invalid filename, an exception is expected.",m_Serializer->Serialize(filename,myStorage),mitk::IGTException);
  }