Classes | Typedefs | Functions | Variables

MitkTestDriver.cpp File Reference

#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "mitkLog.h"

Go to the source code of this file.

Classes

struct  functionMapEntry

Typedefs

typedef int(* MainFuncPointer )(int, char *[])

Functions

int mitkCoreObjectFactoryTest (int, char *[])
int mitkPointSetWriterTest (int, char *[])
int mitkMaterialTest (int, char *[])
int mitkDataNodeTest (int, char *[])
int mitkActionTest (int, char *[])
int mitkDataStorageTest (int, char *[])
int mitkEnumerationPropertyTest (int, char *[])
int mitkEventMapperTest (int, char *[])
int mitkEventTest (int, char *[])
int mitkFocusManagerTest (int, char *[])
int mitkGenericPropertyTest (int, char *[])
int mitkGeometry3DTest (int, char *[])
int mitkGeometryDataToSurfaceFilterTest (int, char *[])
int mitkGlobalInteractionTest (int, char *[])
int mitkImageDataItemTest (int, char *[])
int mitkImageTest (int, char *[])
int mitkBaseDataTest (int, char *[])
int mitkInteractorTest (int, char *[])
int mitkITKThreadingTest (int, char *[])
int mitkLevelWindowTest (int, char *[])
int mitkMessageTest (int, char *[])
int mitkPixelTypeTest (int, char *[])
int mitkPlaneGeometryTest (int, char *[])
int mitkPointSetFileIOTest (int, char *[])
int mitkPointSetTest (int, char *[])
int mitkPointSetInteractorTest (int, char *[])
int mitkPropertyListTest (int, char *[])
int mitkSlicedGeometry3DTest (int, char *[])
int mitkSliceNavigationControllerTest (int, char *[])
int mitkStateMachineTest (int, char *[])
int mitkStateMachineFactoryTest (int, char *[])
int mitkStateTest (int, char *[])
int mitkSurfaceTest (int, char *[])
int mitkSurfaceToSurfaceFilterTest (int, char *[])
int mitkTimeSlicedGeometryTest (int, char *[])
int mitkTransitionTest (int, char *[])
int mitkUndoControllerTest (int, char *[])
int mitkVtkWidgetRenderingTest (int, char *[])
int mitkVerboseLimitedLinearUndoTest (int, char *[])
 Test of the LimitedLinearUndo object.
int mitkWeakPointerTest (int, char *[])
int mitkTransferFunctionTest (int, char *[])
int mitkStepperTest (int, char *[])
int itkTotalVariationDenoisingImageFilterTest (int, char *[])
int mitkDICOMLocaleTest (int, char *[])
int mitkPointSetLocaleTest (int, char *[])
int mitkRenderingManagerTest (int, char *[])
int vtkMitkThickSlicesFilterTest (int, char *[])
int mitkSurfaceVtkWriterTest (int, char *[])
int mitkPicFileWriterTest (int, char *[])
int mitkImageWriterTest (int, char *[])
int mitkImageTimeSelectorTest (int, char *[])
int mitkPicFileReaderTest (int, char *[])
int mitkDataNodeFactoryTest (int, char *[])
char * lowercase (const char *string)
int main (int ac, char *av[])

Variables

functionMapEntry cmakeGeneratedFunctionMapEntries []

Typedef Documentation

typedef int(* MainFuncPointer)(int, char *[])

Definition at line 68 of file MitkTestDriver.cpp.


Function Documentation

int itkTotalVariationDenoisingImageFilterTest ( int  ,
char *  [] 
)

todo

Definition at line 138 of file itkTotalVariationDenoisingImageFilterTest.cpp.

References EXIT_FAILURE, EXIT_SUCCESS, GenerateTestImage(), GenerateVectorTestImage(), PrintImage(), and PrintVectorImage().

{

  ImageType::Pointer image = GenerateTestImage();
  PrintImage(image);

  double precision = 0.01;
  ImageType::IndexType index = {{1,1,0}};
  VectorImageType::IndexType vecIndex = {{1,1,0}};

  try
  {
    typedef itk::LocalVariationImageFilter<ImageType,ImageType> 
      LocalFilterType;
    LocalFilterType::Pointer filter = LocalFilterType::New();
    filter->SetInput(image);
    filter->SetNumberOfThreads(1);
    filter->Update();
    ImageType::Pointer outImage = filter->GetOutput();

    PrintImage(outImage);
    if(fabs(outImage->GetPixel(index) - 4.472) > precision)
    {
      return EXIT_FAILURE;
    }
    
  }
  catch (...)
  {
    return EXIT_FAILURE;
  }

  try
  {
    typedef itk::TotalVariationSingleIterationImageFilter<ImageType,ImageType> 
      SingleFilterType;
    SingleFilterType::Pointer sFilter = SingleFilterType::New();
    sFilter->SetInput( image );
    sFilter->SetOriginalImage(GenerateTestImage());
    sFilter->SetLambda(0.5);
    sFilter->SetNumberOfThreads(1);
    sFilter->Update();  
    ImageType::Pointer outImageS = sFilter->GetOutput();
    
    PrintImage(outImageS);
    if(fabs(outImageS->GetPixel(index) - 4.0) > precision)
    {
      return EXIT_FAILURE;
    }

  }
  catch (...)
  {
    return EXIT_FAILURE;
  }

  try
  {
    typedef itk::TotalVariationDenoisingImageFilter<ImageType,ImageType> 
      TVFilterType;
    TVFilterType::Pointer tvFilter = TVFilterType::New();
    tvFilter->SetInput(image);
    tvFilter->SetNumberIterations(30);
    tvFilter->SetNumberOfThreads(1);
    tvFilter->SetLambda(0.1);
    tvFilter->Update();
    ImageType::Pointer outImageTV = tvFilter->GetOutput();
    
    PrintImage(outImageTV);
    if(fabs(outImageTV->GetPixel(index) - 4.0) > precision)
    {
      return EXIT_FAILURE;
    }

  }
  catch (...)
  {
    return EXIT_FAILURE;
  }

  VectorImageType::Pointer vecImage = GenerateVectorTestImage();
  PrintVectorImage(vecImage);

  try
  {
    typedef itk::LocalVariationImageFilter<VectorImageType,ImageType> 
      LocalVecFilterType;
    LocalVecFilterType::Pointer vecFilter = LocalVecFilterType::New();
    vecFilter->SetInput(vecImage);
    vecFilter->SetNumberOfThreads(1);
    vecFilter->Update();
    ImageType::Pointer outVecImage = vecFilter->GetOutput();
    
    PrintImage(outVecImage);
    if(fabs(outVecImage->GetPixel(index) - 6.324) > precision)
    {
      return EXIT_FAILURE;
    }

  }
  catch (...)
  {
    return EXIT_FAILURE;
  }

  try
  {
    typedef itk::TotalVariationSingleIterationImageFilter
      <VectorImageType,VectorImageType> 
      SingleVecFilterType;
    SingleVecFilterType::Pointer sVecFilter = SingleVecFilterType::New();
    sVecFilter->SetInput( vecImage );
    sVecFilter->SetOriginalImage(vecImage);
    sVecFilter->SetLambda(0.5);
    sVecFilter->SetNumberOfThreads(1);
    sVecFilter->UpdateLargestPossibleRegion();  
    VectorImageType::Pointer outVecImageS = sVecFilter->GetOutput();
    
    PrintVectorImage(outVecImageS);
    if(fabs(outVecImageS->GetPixel(vecIndex)[1] - 4.0) > precision)
    {
      return EXIT_FAILURE;
    }
  }
  catch (...)
  {
    return EXIT_FAILURE;
  }

  try
  {
    typedef itk::TotalVariationDenoisingImageFilter
      <VectorImageType,VectorImageType> TVVectorFilterType;
    TVVectorFilterType::Pointer tvVecFilter = TVVectorFilterType::New();
    tvVecFilter->SetInput(vecImage);
    tvVecFilter->SetNumberIterations(30);
    tvVecFilter->SetNumberOfThreads(1);
    tvVecFilter->SetLambda(0.1);
    tvVecFilter->Update();
    VectorImageType::Pointer outVecImageTV = tvVecFilter->GetOutput();
    
    PrintVectorImage(outVecImageTV);
    if(fabs(outVecImageTV->GetPixel(vecIndex)[1] - 4.0) > precision)
    {
      return EXIT_FAILURE;
    }
  }
  catch (...)
  {
    return EXIT_FAILURE;
  }

  return EXIT_SUCCESS;
}
char* lowercase ( const char *  string )

Definition at line 295 of file MitkTestDriver.cpp.

Referenced by main().

{
  char *new_string, *p;

#ifdef __cplusplus
  new_string = static_cast<char *>(malloc(sizeof(char) *
    static_cast<size_t>(strlen(string) + 1)));
#else
  new_string = (char *)(malloc(sizeof(char) * (size_t)(strlen(string) + 1)));
#endif

  if (!new_string)
    {
    return 0;
    }
  strcpy(new_string, string);
  p = new_string;
  while (*p != 0)
    {
#ifdef __cplusplus
    *p = static_cast<char>(tolower(*p));
#else
    *p = (char)(tolower(*p));
#endif

    ++p;
    }
  return new_string;
}
int main ( int  ac,
char *  av[] 
)

Definition at line 325 of file MitkTestDriver.cpp.

References functionMapEntry::func, lowercase(), functionMapEntry::name, mitk::LoggingBackend::Register(), and mitk::LoggingBackend::Unregister().

{
  int i, NumTests, testNum, partial_match;
  char *arg, *test_name;
  int count;
  int testToRun = -1;

  
    
  for(count =0; cmakeGeneratedFunctionMapEntries[count].name != 0; count++)
    {
    }
  NumTests = count;
  /* If no test name was given */
  /* process command line with user function.  */
  if (ac < 2)
    {
    /* Ask for a test.  */
    printf("Available tests:\n");
    for (i =0; i < NumTests; ++i)
      {
      printf("%3d. %s\n", i, cmakeGeneratedFunctionMapEntries[i].name);
      }
    printf("To run a test, enter the test number: ");
    fflush(stdout);
    testNum = 0;
    if( scanf("%d", &testNum) != 1 )
      {
      printf("Couldn't parse that input as a number\n");
      return -1;
      }
    if (testNum >= NumTests)
      {
      printf("%3d is an invalid test number.\n", testNum);
      return -1;
      }
    testToRun = testNum;
    ac--;
    av++;
    }
  partial_match = 0;
  arg = 0;
  /* If partial match is requested.  */
  if(testToRun == -1 && ac > 1)
    {
    partial_match = (strcmp(av[1], "-R") == 0) ? 1 : 0;
    }
  if (partial_match && ac < 3)
    {
    printf("-R needs an additional parameter.\n");
    return -1;
    }
  if(testToRun == -1)
    {
    arg = lowercase(av[1 + partial_match]);
    }
  for (i =0; i < NumTests && testToRun == -1; ++i)
    {
    test_name = lowercase(cmakeGeneratedFunctionMapEntries[i].name);
    if (partial_match && strstr(test_name, arg) != NULL)
      {
      testToRun = i;
      ac -=2;
      av += 2;
      }
    else if (!partial_match && strcmp(test_name, arg) == 0)
      {
      testToRun = i;
      ac--;
      av++;
      }
    free(test_name);
    }
  if(arg)
    {
    free(arg);
    }
  if(testToRun != -1)
    {
    int result;
mitk::LoggingBackend::Register(); ;
    result = (*cmakeGeneratedFunctionMapEntries[testToRun].func)(ac, av);
mitk::LoggingBackend::Unregister();
    return result;
    }
  
  
  /* Nothing was run, display the test names.  */
  printf("Available tests:\n");
  for (i =0; i < NumTests; ++i)
    {
    printf("%3d. %s\n", i, cmakeGeneratedFunctionMapEntries[i].name);
    }
  printf("Failed: %s is an invalid test name.\n", av[1]);
  
  return -1;
}
int mitkActionTest ( int  ,
char *  [] 
)

Definition at line 23 of file mitkActionTest.cpp.

References EXIT_FAILURE, EXIT_SUCCESS, mitk::FloatProperty::New(), mitk::IntProperty::New(), mitk::BoolProperty::New(), and mitk::Action::New().

{
  int actionId = 10;
  //Create Action
  mitk::Action::Pointer action = mitk::Action::New(actionId);

  //check ActionID
  std::cout << "check ActionId";
  if (action->GetActionId()!=actionId)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  //check properties
  action->AddProperty("boolproperty", mitk::BoolProperty::New(true));
  action->AddProperty("intproperty", mitk::IntProperty::New(10));
  action->AddProperty("floatproperty", mitk::FloatProperty::New(10.05));
  
  std::cout << "try adding property BOOL and read them: ";
  bool boolproperty = false;
  boolproperty = dynamic_cast<mitk::BoolProperty *>(action->GetProperty("boolproperty"))->GetValue();
  if (boolproperty != true)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "try adding property INT and read them: ";
  int intproperty = 0;
  intproperty = dynamic_cast<mitk::IntProperty *>(action->GetProperty("intproperty"))->GetValue();
  if (intproperty != 10)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "try adding property FLOAT and read them: ";
  float floatproperty = 0.0;
  floatproperty = dynamic_cast<mitk::FloatProperty *>(action->GetProperty("floatproperty"))->GetValue();
  if (floatproperty != 10.05f)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  //delete the action
  //action->Delete();
  
  //well done!!! Passed!
  std::cout<<"[EVERYTHING PASSED]"<<std::endl;

  std::cout<<"[TEST DONE]"<<std::endl;
  return EXIT_SUCCESS;
}
int mitkBaseDataTest ( int  ,
char *  [] 
)

Definition at line 24 of file mitkBaseDataTest.cpp.

References MITK_TEST_BEGIN, MITK_TEST_CONDITION, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, mitk::PropertyList::New(), mitk::StringProperty::New(), mitk::Geometry3D::New(), mitk::TimeSlicedGeometry::New(), and mitk::BaseDataTestImplementation::New().

{

  MITK_TEST_BEGIN("BaseData")

  //Create a BaseData implementation
  std::cout << "Creating a base data instance..." << std::endl;
  mitk::BaseDataTestImplementation::Pointer baseDataImpl = mitk::BaseDataTestImplementation::New();

  MITK_TEST_CONDITION_REQUIRED(baseDataImpl.IsNotNull(),"Testing instantiation");
  MITK_TEST_CONDITION(baseDataImpl->IsInitialized(), "BaseDataTestImplementation is initialized");
  MITK_TEST_CONDITION(baseDataImpl->IsEmpty(), "BaseDataTestImplementation is initialized and empty");
  MITK_TEST_CONDITION(baseDataImpl->GetExternalReferenceCount()== baseDataImpl->GetReferenceCount(), "Checks external reference count!");
  


  std::cout << "Testing setter and getter for geometries..." << std::endl;

  //test method GetTimeSlicedGeometry()
  MITK_TEST_CONDITION(baseDataImpl->GetTimeSlicedGeometry(), "Testing creation of TimeSlicedGeometry");

  mitk::TimeSlicedGeometry* geo = NULL;
  baseDataImpl->SetGeometry(geo);

  MITK_TEST_CONDITION(baseDataImpl->GetTimeSlicedGeometry() == NULL, "Reset Geometry");

  mitk::TimeSlicedGeometry::Pointer geo2 = mitk::TimeSlicedGeometry::New();
  baseDataImpl->SetGeometry(geo2);
  baseDataImpl->InitializeTimeSlicedGeometry(2);

  MITK_TEST_CONDITION(baseDataImpl->GetTimeSlicedGeometry() == geo2, "Correct Reinit of TimeslicedGeometry");
  
  //test method GetGeometry(int timeStep)  
  MITK_TEST_CONDITION(baseDataImpl->GetGeometry(1) != NULL, "... and single Geometries");
    
  //test method Expand(unsigned int timeSteps)
  baseDataImpl->Expand(5);
  MITK_TEST_CONDITION(baseDataImpl->GetTimeSteps() == 5, "Expand the geometry to further time slices!");
  
  //test method GetUpdatedGeometry(int timeStep);
  mitk::Geometry3D::Pointer geo3 = mitk::Geometry3D::New();
  baseDataImpl->SetGeometry(geo3, 1);

  MITK_TEST_CONDITION(baseDataImpl->GetUpdatedGeometry(1) == geo3, "Set Geometry for time step 1");
  MITK_TEST_CONDITION(baseDataImpl->GetMTime()!= 0, "Check if modified time is set");  
  baseDataImpl->SetClonedGeometry(geo3, 1);

  float x[3];
  x[0] = 2; 
  x[1] = 4; 
  x[2] = 6;
  mitk::Point3D p3d(x);
  baseDataImpl->SetOrigin(p3d);
  geo3->SetOrigin(p3d);

  MITK_TEST_CONDITION(baseDataImpl->GetGeometry(1)->GetOrigin() == geo3->GetOrigin(), "Testing Origin set");

  MITK_TEST_CONDITION(!baseDataImpl->IsEmpty(1), "Is not empty before clear()!");
  baseDataImpl->Clear();
  MITK_TEST_CONDITION(baseDataImpl->IsEmpty(1), "...but afterwards!");
  //test method Set-/GetProperty()
  baseDataImpl->SetProperty("property38", mitk::StringProperty::New("testproperty"));
  //baseDataImpl->SetProperty("visibility", mitk::BoolProperty::New());
  MITK_TEST_CONDITION(baseDataImpl->GetProperty("property38")->GetValueAsString() == "testproperty","Check if base property is set correctly!");

  //test method Set-/GetPropertyList
  mitk::PropertyList::Pointer propertyList = mitk::PropertyList::New();
  propertyList->SetFloatProperty("floatProperty1", 123.45);
  propertyList->SetBoolProperty("visibility",true);
  propertyList->SetStringProperty("nameXY","propertyName");
  baseDataImpl->SetPropertyList(propertyList);
  bool value = false;
  MITK_TEST_CONDITION(baseDataImpl->GetPropertyList() == propertyList, "Check if base property list is set correctly!");
  MITK_TEST_CONDITION(baseDataImpl->GetPropertyList()->GetBoolProperty("visibility", value) == true, "Check if base property is set correctly in the property list!");
  
  //test method UpdateOutputInformation()
   baseDataImpl->UpdateOutputInformation();
  MITK_TEST_CONDITION(baseDataImpl->GetUpdatedTimeSlicedGeometry() == geo2, "TimeSlicedGeometry update!");
  //Test method CopyInformation()
  mitk::BaseDataTestImplementation::Pointer newBaseData =  mitk::BaseDataTestImplementation::New();
  newBaseData->CopyInformation(baseDataImpl);
  MITK_TEST_CONDITION(  newBaseData->GetTimeSlicedGeometry()->GetTimeSteps() == 5, "Check copying of of Basedata Data Object!");
 
  MITK_TEST_END()
}
int mitkCoreObjectFactoryTest ( int  ,
char *  [] 
)

Definition at line 22 of file mitkCoreObjectFactoryTest.cpp.

References mitk::CoreObjectFactory::GetInstance(), MITK_TEST_BEGIN, MITK_TEST_CONDITION, MITK_TEST_CONDITION_REQUIRED, and MITK_TEST_END.

{

  MITK_TEST_BEGIN("CoreObjectFactory")
  
  mitk::CoreObjectFactory::Pointer instance = mitk::CoreObjectFactory::GetInstance();
  MITK_TEST_CONDITION_REQUIRED(instance.IsNotNull(),"Testing instantiation");
  MITK_TEST_CONDITION(strcmp(instance->GetNameOfClass(),"CoreObjectFactory") == 0,"Is this a CoreObjectFactory?");

  

 
  MITK_TEST_END()
}
int mitkDataNodeFactoryTest ( int  ,
char *  argv[] 
)

Test for the class "DataNodeFactory".

argc and argv are the command line parameters which were passed to the ADD_TEST command in the CMakeLists.txt file. For the automatic tests, argv is either empty for the simple tests or contains the filename of a test image for the image tests (see CMakeLists.txt).

Definition at line 33 of file mitkDataNodeFactoryTest.cpp.

References MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, MITK_TEST_OUTPUT, mitk::DataNodeFactory::New(), and mitk::StringProperty::PATH.

{
  // always start with this!
  MITK_TEST_BEGIN("DataNodeFactory")

    mitk::DataNodeFactory::Pointer factory = mitk::DataNodeFactory::New();
    MITK_TEST_OUTPUT(<< "Loading file: " << argv[1]);

    factory->SetFileName( argv[1] );
    MITK_TEST_CONDITION_REQUIRED(strcmp(factory->GetFileName(),argv[1])==0,"Test for Set/GetFileName()");

    factory->Update();
    MITK_TEST_CONDITION_REQUIRED(factory->GetNumberOfOutputs() > 0, "file loaded");
    
    MITK_TEST_OUTPUT(<< "Test function SetDefaultCommonProperties()");
    mitk::DataNode::Pointer node = factory->GetOutput( 0 );
    factory->SetDefaultCommonProperties(node);
    // get file path and property
    std::string filePath = itksys::SystemTools::GetFilenamePath(factory->GetFileName());
    mitk::StringProperty::Pointer pathProp = dynamic_cast<mitk::StringProperty*>(node->GetProperty(mitk::StringProperty::PATH));

    MITK_TEST_CONDITION_REQUIRED(strcmp(pathProp->GetValue(),filePath.c_str())==0,"Test for file path");

    std::string fileName = factory->GetFileName();
    std::string fileExtension = itksys::SystemTools::GetFilenameExtension(fileName);
    if (fileName.substr(fileName.size()-3) == ".gz")
       fileName = fileName.substr( 0, fileName.length()-3 );
    fileName = fileName.substr(0,fileName.length()-fileExtension.length());
    fileName = fileName.substr(filePath.length()+1, fileName.length());
    mitk::StringProperty::Pointer nameProp = dynamic_cast<mitk::StringProperty*>(node->GetProperty("name"));
    MITK_TEST_CONDITION_REQUIRED(strcmp(nameProp->GetValue(),fileName.c_str())==0,"Test for file name");

    mitk::BoolProperty::Pointer visibleProp = dynamic_cast<mitk::BoolProperty*>(node->GetProperty("visible"));
    MITK_TEST_CONDITION_REQUIRED(visibleProp->GetValue()==true,"Test for visibility");
  // always end with this!
  MITK_TEST_END()
}
int mitkDataNodeTest ( int  ,
char *  [] 
)

Definition at line 270 of file mitkDataNodeTest.cpp.

References mitk::GlobalInteraction::GetInstance(), MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, mitk::DataNode::New(), mitkDataNodeTestClass::TestDataSetting(), mitkDataNodeTestClass::TestGetMTime(), mitkDataNodeTestClass::TestInteractorSetting(), mitkDataNodeTestClass::TestMapperSetting(), mitkDataNodeTestClass::TestPropertyList(), and mitkDataNodeTestClass::TestSelected().

{
  // always start with this!
  MITK_TEST_BEGIN("DataNode")

  // Global interaction must(!) be initialized
  mitk::GlobalInteraction::GetInstance()->Initialize("global");

  // let's create an object of our class  
  mitk::DataNode::Pointer myDataNode = mitk::DataNode::New();

  // first test: did this work?
  // using MITK_TEST_CONDITION_REQUIRED makes the test stop after failure, since
  // it makes no sense to continue without an object.
  MITK_TEST_CONDITION_REQUIRED(myDataNode.IsNotNull(),"Testing instantiation") 

  //test setData() Method
  mitkDataNodeTestClass::TestDataSetting(myDataNode);
  mitkDataNodeTestClass::TestMapperSetting(myDataNode);
  //
  //note, that no data is set to the dataNode
  mitkDataNodeTestClass::TestInteractorSetting(myDataNode);
  mitkDataNodeTestClass::TestPropertyList(myDataNode);
  mitkDataNodeTestClass::TestSelected(myDataNode);
  mitkDataNodeTestClass::TestGetMTime(myDataNode);

  // write your own tests here and use the macros from mitkTestingMacros.h !!!
  // do not write to std::cout and do not return from this function yourself!
  
  // always end with this!
  MITK_TEST_END()
}
int mitkDataStorageTest ( int  ,
char *  [] 
)

Definition at line 132 of file mitkDataStorageTest.cpp.

References MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, MITK_TEST_FAILED_MSG, MITK_TEST_OUTPUT, mitk::StandaloneDataStorage::New(), mitk::DataNode::New(), mitk::TestStandaloneDataStorage::New(), and TestDataStorage().

{
  MITK_TEST_BEGIN("DataStorageTest");

  // muellerm: test observer tag remove
  mitk::TestStandaloneDataStorage::Pointer testDS
      = mitk::TestStandaloneDataStorage::New();
  mitk::DataNode::Pointer n1 = mitk::DataNode::New();
  testDS->Add(n1);
  MITK_TEST_CONDITION_REQUIRED(
      testDS->GetModifiedObserverTags().size()==1, "Testing if modified"
      " observer was added.");
  MITK_TEST_CONDITION_REQUIRED(
      testDS->GetDeletedObserverTags().size()==1, "Testing if delete"
      " observer was added.");
  testDS->Remove(n1);
  MITK_TEST_CONDITION_REQUIRED(
      testDS->GetModifiedObserverTags().size()==0, "Testing if modified"
      " observer was removed.");
  MITK_TEST_CONDITION_REQUIRED(
      testDS->GetDeletedObserverTags().size()==0, "Testing if delete"
      " observer was removed.");

  /* Create StandaloneDataStorage */
  MITK_TEST_OUTPUT( << "Create StandaloneDataStorage : ");
  mitk::StandaloneDataStorage::Pointer sds;
  try
  {
    sds = mitk::StandaloneDataStorage::New();
    MITK_TEST_CONDITION_REQUIRED(sds.IsNotNull(), "Testing Instatiation");
  }
  catch (...)
  {
    MITK_TEST_FAILED_MSG( << "Exception during creation of StandaloneDataStorage");
  }

  MITK_TEST_OUTPUT( << "Testing StandaloneDataStorage: ");
  TestDataStorage(sds);
  // TODO: Add specific StandaloneDataStorage Tests here
  sds = NULL;

  MITK_TEST_END();
}
int mitkDICOMLocaleTest ( int  ,
char *  [] 
)

Definition at line 88 of file mitkDICOMLocaleTest.cpp.

References MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, mitkDICOMLocaleTestChangeLocale(), and mitkDICOMLocaleTestWithReferenceImage().

{
  MITK_TEST_BEGIN("DICOMLocaleTest");

  // load a reference DICOM file with the "C" locale being set
  mitkDICOMLocaleTestChangeLocale("C");
  mitkDICOMLocaleTestWithReferenceImage();
  // load a reference DICOM file with German locales being set
  typedef std::list<std::string> StringList;
  StringList alllocales;
  alllocales.push_back("de_DE");
  alllocales.push_back("de_DE.utf8");
  alllocales.push_back("de_DE.UTF8");
  alllocales.push_back("de_DE@euro");
  alllocales.push_back("German_Germany");

  // QuickFix for MAC OS X
  // See for more the Bug #3894 comments
#if defined (__APPLE__) || defined(MACOSX)
  alllocales.push_back("C");
#endif

  unsigned int numberOfTestedGermanLocales(0);

  for (StringList::iterator iter = alllocales.begin();
       iter != alllocales.end();
       ++iter)
  {
    if ( mitkDICOMLocaleTestChangeLocale(*iter) )
    {
      ++numberOfTestedGermanLocales;
      mitkDICOMLocaleTestWithReferenceImage();
    }
  }

  MITK_TEST_CONDITION_REQUIRED( numberOfTestedGermanLocales > 0, "Verify that at least one German locale has been tested.");
 
  MITK_TEST_END();
}
int mitkEnumerationPropertyTest ( int  ,
char *  [] 
)

Definition at line 24 of file mitkEnumerationPropertyTest.cpp.

References EXIT_FAILURE, EXIT_SUCCESS, mitk::VtkRepresentationProperty::New(), mitk::VtkInterpolationProperty::New(), and mitk::EnumerationProperty::New().

{
  mitk::EnumerationProperty::Pointer enumerationProperty(mitk::EnumerationProperty::New());

  std::cout << "Testing mitk::EnumerationProperty::AddEnum(...): ";
  bool success = true;
  success = success && enumerationProperty->AddEnum( "first", 1 );
  success = success && enumerationProperty->AddEnum( "second", 2 );
  success = success && enumerationProperty->AddEnum( "third", 3 );
  if ( ! success )
  {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  else
  {
    std::cout << "[PASSED]" << std::endl;
  }

  
  
  
  
  std::cout << "Testing mitk::EnumerationProperty::Size(): " ;
  if ( enumerationProperty->Size() != 3 )
  {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  else
  {
    std::cout << "[PASSED]" << std::endl;
  }

  std::cout << "Testing mitk::EnumerationProperty::AddEnum() with invalid entries: ";
  if ( enumerationProperty->AddEnum( "first", 0 ) )
  {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  else
  {
    std::cout << "[PASSED]" << std::endl;
  }

  
  
  
  
  std::cout << "Testing mitk::EnumerationProperty::SetValue(id): ";
  if ( ! enumerationProperty->SetValue( 2 ) )
  {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  if ( enumerationProperty->GetValueAsId() != 2 )
  {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  if ( enumerationProperty->GetValueAsString() != "second" )
  {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  std::cout << "[PASSED]" << std::endl;

  
  
  
  
  std::cout << "Testing mitk::EnumerationProperty::SetValue(name): ";
  if ( ! enumerationProperty->SetValue( "third" ) )
  {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  if ( enumerationProperty->GetValueAsId() != 3 )
  {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  if ( enumerationProperty->GetValueAsString() != "third" )
  {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  std::cout << "[PASSED]" << std::endl;

  
  
  
  
  std::cout << "Testing mitk::EnumerationProperty::SetValue(invalid id): ";
  if ( enumerationProperty->SetValue( 100 ) )
  {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  std::cout << "[PASSED]" << std::endl;

  std::cout << "Testing mitk::EnumerationProperty::SetValue(invalid name): ";
  if ( enumerationProperty->SetValue( "madmax" ) )
  {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  std::cout << "[PASSED]" << std::endl;


  
  
  
  
  std::cout << "Testing mitk::VtkInterpolationType::SetInterpolationToPhong(): ";
  mitk::VtkInterpolationProperty::Pointer vtkInterpolationProperty(mitk::VtkInterpolationProperty::New());;
  vtkInterpolationProperty->SetInterpolationToPhong();
  if ( vtkInterpolationProperty->GetValueAsString() != "Phong" )
  {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  if ( vtkInterpolationProperty->GetValueAsId() != 2 )
  {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  if ( vtkInterpolationProperty->GetVtkInterpolation() != VTK_PHONG )
  {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  std::cout << "[PASSED]" << std::endl;

  
  
  
  
  std::cout << "Testing mitk::VtkRepresentationType::SetRepresentationToWireframe(): ";
  mitk::VtkRepresentationProperty::Pointer vtkRepresentationProperty(mitk::VtkRepresentationProperty::New());
  vtkRepresentationProperty->SetRepresentationToWireframe();
  if ( vtkRepresentationProperty->GetValueAsString() != "Wireframe" )
  {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  if ( vtkRepresentationProperty->GetValueAsId() != 1 )
  {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  if ( vtkRepresentationProperty->GetVtkRepresentation() != VTK_WIREFRAME )
  {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  std::cout << "[PASSED]" << std::endl;

  std::cout << "[TEST DONE]" << std::endl;
  return EXIT_SUCCESS;
}
int mitkEventMapperTest ( int  ,
char *  [] 
)

Definition at line 25 of file mitkEventMapperTest.cpp.

References mitk::BS_LeftButton, mitk::BS_NoButton, mitk::StateEvent::GetId(), mitk::StandardFileLocations::GetInstance(), mitk::EventMapper::GetStyleName(), mitk::Key_N, mitk::Key_none, mitk::Key_R, mitk::EventMapper::LoadBehavior(), mitk::EventMapper::LoadStandardBehavior(), MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, mitk::EventMapper::New(), mitk::EventMapper::RefreshStateEvent(), mitk::StateEvent::Set(), and mitk::Type_MouseButtonPress.

{
  MITK_TEST_BEGIN("EventMapper")

  //construct IDs to be checked
  mitk::Event* mouseButtonPressEvent = new mitk::Event(NULL, mitk::Type_MouseButtonPress, mitk::BS_LeftButton, mitk::BS_NoButton, mitk::Key_none);
  const int mouseButtonPressID = 1;
  //there is no combination Type_MouseButtonPress and Keys, so use this to be sure to have unique events
  mitk::Event* uniqueEventFile1 = new mitk::Event(NULL, mitk::Type_MouseButtonPress, mitk::BS_NoButton, mitk::BS_NoButton, mitk::Key_R); 
  const int uniqueEventIDFile1 = 13000;
  mitk::Event* uniqueEventFile2 = new mitk::Event(NULL, mitk::Type_MouseButtonPress, mitk::BS_NoButton, mitk::BS_NoButton, mitk::Key_N);
  const int uniqueEventIDFile2 = 13001;

    
  //create statemachinefactory
  mitk::EventMapper* eventMapper = mitk::EventMapper::New();
  
  //load standard behavior 
  MITK_TEST_CONDITION_REQUIRED(eventMapper->LoadStandardBehavior(),"Testing LoadStandardBehavior(): ")
  std::cout<<"StyleName: " << eventMapper->GetStyleName()<<"\n";

  mitk::StateEvent stateEvent;
  stateEvent.Set(0, mouseButtonPressEvent);
  eventMapper->RefreshStateEvent(&stateEvent);
  MITK_TEST_CONDITION_REQUIRED(stateEvent.GetId() == mouseButtonPressID,"Testing event mapping of standard xml-file: ") 
  
  std::string xmlFileName1( mitk::StandardFileLocations::GetInstance()->FindFile("TestStateMachine1.xml", "Core/Code/Testing/Data") );
  MITK_TEST_CONDITION_REQUIRED(!xmlFileName1.empty(),"Getting xml file 1: ") 
  MITK_TEST_CONDITION_REQUIRED(eventMapper->LoadBehavior(xmlFileName1),"Parsing xml file 1 should throw warning: ") 
  
  stateEvent.Set(0, uniqueEventFile1);
  eventMapper->RefreshStateEvent(&stateEvent);
  MITK_TEST_CONDITION_REQUIRED(stateEvent.GetId() == uniqueEventIDFile1,"Testing event mapping of first additionally loaded xml-file: ") 

  //global still accessible?
  stateEvent.Set(0, mouseButtonPressEvent);
  eventMapper->RefreshStateEvent(&stateEvent);
  MITK_TEST_CONDITION_REQUIRED(stateEvent.GetId() == mouseButtonPressID,"Testing if standard information still available: ") 

  
  std::string xmlFileName2( mitk::StandardFileLocations::GetInstance()->FindFile("TestStateMachine2.xml", "Core/Code/Testing/Data") );
  MITK_TEST_CONDITION_REQUIRED(!xmlFileName2.empty(),"Getting xml file 2: ") 
  MITK_TEST_CONDITION_REQUIRED(eventMapper->LoadBehavior(xmlFileName2),"Parsing xml file 2. Warning of double entry should be thrown: ") 

  stateEvent.Set(0, uniqueEventFile2);
  eventMapper->RefreshStateEvent(&stateEvent);
  MITK_TEST_CONDITION_REQUIRED(stateEvent.GetId() == uniqueEventIDFile2,"Testing event mapping of second additionally loaded xml-file: ") 

  //global still accessible?
  stateEvent.Set(0, mouseButtonPressEvent);
  eventMapper->RefreshStateEvent(&stateEvent);
  MITK_TEST_CONDITION_REQUIRED(stateEvent.GetId() == mouseButtonPressID,"Testing if standard information still available: ") 

  eventMapper->Delete();

  // always end with this!
  MITK_TEST_END();
}
int mitkEventTest ( int  ,
char *  [] 
)

Definition at line 25 of file mitkEventTest.cpp.

References mitk::RenderingManager::GetInstance(), mitk::GlobalInteraction::GetInstance(), MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, and mitk::VtkPropRenderer::New().

{
  MITK_TEST_BEGIN("Event")

  // Global interaction must(!) be initialized if used
  mitk::GlobalInteraction::GetInstance()->Initialize("global");

  vtkRenderWindow* renWin = vtkRenderWindow::New();
  mitk::VtkPropRenderer::Pointer renderer = mitk::VtkPropRenderer::New( "ContourRenderer",renWin, mitk::RenderingManager::GetInstance() );

  //Create Event
  mitk::Event * event = new mitk::Event(renderer, 0, 1, 2, 3);

  //check Get...
  MITK_TEST_CONDITION_REQUIRED(
    event->GetSender() == renderer ||
    event->GetType() == 0 ||
    event->GetButton() == 1 ||
    event->GetButtonState() == 2 ||
    event->GetKey() == 3
    , "Checking Get methods of mitk::Event");

  renWin->Delete();
  delete event;

  // always end with this!
  MITK_TEST_END()


}
int mitkFocusManagerTest ( int  ,
char *  [] 
)

Definition at line 24 of file mitkFocusManagerTest.cpp.

References mitk::RenderingManager::GetInstance(), mitk::GlobalInteraction::GetInstance(), MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, mitk::FocusManager::New(), and mitk::VtkPropRenderer::New().

{
  MITK_TEST_BEGIN("FocusManager");

  // Global interaction must(!) be initialized if used
  mitk::GlobalInteraction::GetInstance()->Initialize("global");

  mitk::RenderingManager::Pointer rm = mitk::RenderingManager::GetInstance();

  //building up necessary objects
  vtkRenderWindow* renderWindow = vtkRenderWindow::New();
  mitk::VtkPropRenderer::Pointer element1 = mitk::VtkPropRenderer::New( "renderer1", renderWindow, rm );
  mitk::VtkPropRenderer::Pointer element2 = mitk::VtkPropRenderer::New( "renderer2", renderWindow, rm );
  mitk::VtkPropRenderer::Pointer element3 = mitk::VtkPropRenderer::New( "renderer3", renderWindow, rm );

  //the FocusManager itself
  mitk::FocusManager::Pointer focusManager = mitk::FocusManager::New();

  //testing
  MITK_TEST_CONDITION_REQUIRED(focusManager.IsNotNull(), "Testing Instatiation");
  
  MITK_TEST_CONDITION_REQUIRED(element1.IsNotNull(), "Testing Instatiation of an element");

  MITK_TEST_CONDITION_REQUIRED(focusManager->AddElement(element1), "Testing addition of an element");

  MITK_TEST_CONDITION_REQUIRED(focusManager->GetFocused() == element1, "Testing if the added element is focused on");

  MITK_TEST_CONDITION_REQUIRED(focusManager->RemoveElement(element1), "Testing removing of an element");
  
  MITK_TEST_CONDITION_REQUIRED(focusManager->GetFocused() == NULL, "Testing focused on an empty list");
  
  MITK_TEST_CONDITION_REQUIRED(focusManager->AddElement(element1), "Testing addition of an element; Elements in list: 1");
  MITK_TEST_CONDITION_REQUIRED(focusManager->AddElement(element2), "Testing addition of a second element; Elements in list: 1 2");
  MITK_TEST_CONDITION_REQUIRED(focusManager->GetFocused() == element1, "Testing if the added element still is element 1");
  MITK_TEST_CONDITION_REQUIRED(focusManager->AddElement(element3), "Testing addition of a third element; Elements in list: 1 2 3");
  MITK_TEST_CONDITION_REQUIRED(focusManager->GetFocused() == element1, "Testing if the added element still is element 1");

  MITK_TEST_CONDITION_REQUIRED(focusManager->SetFocused(element1), "Testing setting focused to element 1");
  MITK_TEST_CONDITION_REQUIRED(focusManager->GetFocused() == element1, "focus on element 1");
  MITK_TEST_CONDITION_REQUIRED(focusManager->SetFocused(element2), "Testing setting focused to element 2");
  MITK_TEST_CONDITION_REQUIRED(focusManager->GetFocused() == element2, "focus on element 2");
  MITK_TEST_CONDITION_REQUIRED(focusManager->SetFocused(element3), "Testing setting focused to element 3");
  MITK_TEST_CONDITION_REQUIRED(focusManager->GetFocused() == element3, "focus on element 3");

  MITK_TEST_CONDITION_REQUIRED(focusManager->RemoveElement(element1), "Testing removing first element; Elements in list: 2 3");
  MITK_TEST_CONDITION_REQUIRED(focusManager->GetFocused() == element2, "Testing if focused element is the one behind the deleted one: 2");
  MITK_TEST_CONDITION_REQUIRED(focusManager->AddElement(element1), "Testing addition of an element again; Elements in list: 2 3 1");
  MITK_TEST_CONDITION_REQUIRED(focusManager->RemoveElement(element3), "Testing removing element 3; Elements in list: 2 1");
  MITK_TEST_CONDITION_REQUIRED(focusManager->GetFocused() == element1, "Testing if focused element is the one behind the deleted one: 1");

  MITK_TEST_CONDITION_REQUIRED(focusManager->RemoveElement(element1), "Testing removing last element 1; Elements in list: 2 ");
  MITK_TEST_CONDITION_REQUIRED(focusManager->GetFocused() == element2, "Testing if focused element is 2");

  MITK_TEST_CONDITION_REQUIRED(!focusManager->RemoveElement(element1), "Testing removing same element");
  MITK_TEST_CONDITION_REQUIRED(focusManager->RemoveElement(element2), "Testing removing last element in list (2)");

  MITK_TEST_CONDITION_REQUIRED(!focusManager->RemoveElement(element3), "Testing removing from empty list ");
  MITK_TEST_CONDITION_REQUIRED(!focusManager->RemoveElement(element2), "Testing removing from empty list with different object");
  MITK_TEST_CONDITION_REQUIRED(!focusManager->RemoveElement(element1), "Testing removing from empty list with different object again");

  focusManager = NULL;
    
  //TODO: test IsLast() IsFirst() GetFirst() GetLast() GoToNext() GetIter() SetLoop(bool loop)

  //Delete renderWindo correctly
  renderWindow->Delete();

  MITK_TEST_END();
}
int mitkGenericPropertyTest ( int  ,
char *  [] 
)

Definition at line 71 of file mitkGenericPropertyTest.cpp.

References MITK_TEST_BEGIN, and MITK_TEST_END.

{
  MITK_TEST_BEGIN(GenericPropertyTest)

  // testing for some different data types
  TestGenericPropertyForDataType<mitk::IntProperty>(1, 2, "1", "2", "int");
  TestGenericPropertyForDataType<mitk::BoolProperty>(true, false, "1", "0", "bool");
  TestGenericPropertyForDataType<mitk::FloatProperty>(1.0, -1.0, "1", "-1", "float");
  TestGenericPropertyForDataType<mitk::DoubleProperty>(1.0, -1.0, "1", "-1", "double");
  
  TestGenericPropertyForDataType<mitk::StringProperty>(std::string("eins"), std::string("zwei"), std::string("eins"), std::string("zwei"), "std::string");

  {
  mitk::Point3D p1; p1[0] = 2.0; p1[1] = 3.0; p1[2] = 4.0;
  mitk::Point3D p2; p2[0] =-1.0; p2[1] = 2.0; p2[2] = 3.0;
  TestGenericPropertyForDataType<mitk::Point3dProperty>( p1, p2, "[2, 3, 4]", "[-1, 2, 3]", "mitk::Point3D");
  }
 
  {
  mitk::Point4D p1; p1[0] = 2.0; p1[1] = 3.0; p1[2] = 4.0; p1[3] =-2.0;
  mitk::Point4D p2; p2[0] =-1.0; p2[1] = 2.0; p2[2] = 3.0; p2[3] = 5.0;
  TestGenericPropertyForDataType<mitk::Point4dProperty>( p1, p2, "[2, 3, 4, -2]", "[-1, 2, 3, 5]", "mitk::Point4D");
  }
 
  /*  THIS won't compile because of the interface of XMLWriter... that should be reworked perhaps
  {
  mitk::Vector2D p1; p1[0] = 2.0; p1[1] = 3.0;
  mitk::Vector2D p2; p2[0] =-1.0; p2[1] = 2.0;
  TestGenericPropertyForDataType<mitk::Vector2D>( p1, p2, "[2, 3]", "[-1, 2]", "mitk::Vector2D");
  }
  */

  {
  mitk::Vector3D p1; p1[0] = 2.0; p1[1] = 3.0; p1[2] = 4.0;
  mitk::Vector3D p2; p2[0] =-1.0; p2[1] = 2.0; p2[2] = 3.0;
  TestGenericPropertyForDataType<mitk::Vector3DProperty>( p1, p2, "[2, 3, 4]", "[-1, 2, 3]", "mitk::Vector3D");
  }
 
  MITK_TEST_END();
}
int mitkGeometry3DTest ( int  ,
char *  [] 
)

Definition at line 290 of file mitkGeometry3DTest.cpp.

References EXIT_SUCCESS, MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, MITK_TEST_OUTPUT, mitkGeometry3DTest(), testGeometry3D(), and testItkImageIsCenterBased().

Referenced by mitkGeometry3DTest().

{
  MITK_TEST_BEGIN(mitkGeometry3DTest);

  int result;

  MITK_TEST_CONDITION_REQUIRED( (result = testItkImageIsCenterBased()) == EXIT_SUCCESS, "");

  MITK_TEST_OUTPUT(<< "Running main part of test with ImageGeometry = false");
  MITK_TEST_CONDITION_REQUIRED( (result = testGeometry3D(false)) == EXIT_SUCCESS, "");

  MITK_TEST_OUTPUT(<< "Running main part of test with ImageGeometry = true");
  MITK_TEST_CONDITION_REQUIRED( (result = testGeometry3D(true)) == EXIT_SUCCESS, "");

  MITK_TEST_END();

  return EXIT_SUCCESS;
}
int mitkGeometryDataToSurfaceFilterTest ( int  ,
char *  [] 
)

Definition at line 156 of file mitkGeometryDataToSurfaceFilterTest.cpp.

References EXIT_FAILURE, EXIT_SUCCESS, mitk::Geometry2DData::New(), mitk::PlaneGeometry::New(), mitk::Geometry2DDataToSurfaceFilter::New(), and testGeometryDataToSurfaceFilter().

{
  int result;

  std::cout << "Testing mitk::Geometry2DDataToSurfaceFilter: " << std::endl;

  mitk::Geometry2DDataToSurfaceFilter::Pointer geometryToSurfaceFilter;
  std::cout << "Testing Geometry2DDataToSurfaceFilter::New(): ";
  geometryToSurfaceFilter = mitk::Geometry2DDataToSurfaceFilter::New();
  if (geometryToSurfaceFilter.IsNull()) {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  else {
    std::cout<<"[PASSED]"<<std::endl;
  } 

  mitk::Point3D origin;
  mitk::PlaneGeometry::Pointer plane = mitk::PlaneGeometry::New();
  plane->InitializeStandardPlane(50, 100);
  mitk::FillVector3D(origin, 1.0, 2.0, 3.0);
  plane->SetOrigin(origin);

  mitk::Geometry2DData::Pointer geometryData = mitk::Geometry2DData::New();
  geometryData->SetGeometry2D(plane);

  std::cout << "Testing SetInput(): ";
  geometryToSurfaceFilter->SetInput(geometryData);
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing GetInput(): ";
  if (geometryToSurfaceFilter->GetInput() !=  geometryData ) {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  else {
    std::cout<<"[PASSED]"<<std::endl;
  }


  std::cout << "Testing default of Geometry2DDataToSurfaceFilter::m_PlaceByGeometry (expected is false): ";
  if (geometryToSurfaceFilter->GetPlaceByGeometry() !=  false ) {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  else {
    std::cout<<"[PASSED]"<<std::endl;
  }

  // test with m_PlaceByGeometry==false
  mitk::ScalarType expectedBoundsFinal[6] = {1.0, 51.0, 2.0, 102.0, 3.0, 3.0};
  if((result=testGeometryDataToSurfaceFilter(geometryToSurfaceFilter, expectedBoundsFinal, expectedBoundsFinal, true)) != EXIT_SUCCESS) {
    return result;
  }

  std::cout << "Testing Geometry2DDataToSurfaceFilter::SetPlaceByGeometry(true): ";
  geometryToSurfaceFilter->SetPlaceByGeometry(true);
  if (geometryToSurfaceFilter->GetPlaceByGeometry() !=  true ) {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  else {
    std::cout<<"[PASSED]"<<std::endl;
  }

  // test with m_PlaceByGeometry==true
  mitk::ScalarType expectedIndexBounds[6] = {0.0, 50.0, 0.0, 100.0, 0.0, 0.0};
  mitk::ScalarType expectedAxisParallelBounds[6] = {1.0, 51.0, 2.0, 102.0, 3.0, 3.0};
  if((result=testGeometryDataToSurfaceFilter(geometryToSurfaceFilter, expectedIndexBounds, expectedAxisParallelBounds, true)) != EXIT_SUCCESS) {
    return result;
  }



  // test with specified BoundingBox (m_PlaceByGeometry is irrelevant for this test)
  mitk::BoundingBox::Pointer boundingBox = mitk::BoundingBox::New();
  mitk::Point3D bbMin, bbMax;
  mitk::FillVector3D( bbMin, 10.0, 10.0, -6.0 );
  mitk::FillVector3D( bbMax, 40.0, 90.0, 6.0 );

  mitk::BoundingBox::PointsContainer::Pointer pointsContainer = mitk::BoundingBox::PointsContainer::New();
  pointsContainer->InsertElement( 0, bbMin );
  pointsContainer->InsertElement( 1, bbMax );
  boundingBox->SetPoints( pointsContainer );
  boundingBox->ComputeBoundingBox();


  geometryToSurfaceFilter->SetPlaceByGeometry( true );
  geometryToSurfaceFilter->SetBoundingBox( boundingBox );
  mitk::ScalarType expectedIndexBoundsWithBB[6] = {9.0, 39.0, 8.0, 88.0, 0.0, 0.0};
  mitk::ScalarType expectedAxisParallelBoundsWithBB[6] = {10.0, 40.0, 10.0, 90.0, 3.0, 3.0};
  if((result=testGeometryDataToSurfaceFilter(geometryToSurfaceFilter, expectedIndexBoundsWithBB, expectedAxisParallelBoundsWithBB, true)) != EXIT_SUCCESS) {
    return result;
  }


  std::cout<<"[TEST DONE]"<<std::endl;
  return EXIT_SUCCESS;
}
int mitkGlobalInteractionTest ( int  ,
char *  [] 
)

Definition at line 25 of file mitkGlobalInteractionTest.cpp.

References mitk::GlobalInteraction::GetInstance(), MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, mitk::PointSetInteractor::New(), and mitk::GlobalInteraction::New().

{
  MITK_TEST_BEGIN("GlobalInteraction")
 
  //get static instance of globalInteraction
  mitk::GlobalInteraction::Pointer globalInteraction = mitk::GlobalInteraction::GetInstance();
  MITK_TEST_CONDITION_REQUIRED(globalInteraction.IsNotNull(),"testing singleton initialization: ") 
  MITK_TEST_CONDITION_REQUIRED(globalInteraction->IsInitialized() == false ,"testing initial initialization: not initialized") 

  // Initialize with default values
  MITK_TEST_CONDITION_REQUIRED(globalInteraction->Initialize("global"),"testing to initialize: ")

  //testing initialization
  MITK_TEST_CONDITION_REQUIRED(globalInteraction->IsInitialized(),"testing initial initialization: initialized") 
  
  MITK_TEST_CONDITION_REQUIRED(globalInteraction->Initialize("global") == false ,"testing double initialization") 

  MITK_TEST_CONDITION_REQUIRED(globalInteraction->IsInitialized(),"still initialized: ") 

  MITK_TEST_CONDITION_REQUIRED(globalInteraction.IsNotNull() ,"Testing 'instantiation' of 'global' static GlobalInteraction") 

  //testing creating non singleton instance
  mitk::GlobalInteraction::Pointer myGlobalInteraction = mitk::GlobalInteraction::New();
  MITK_TEST_CONDITION_REQUIRED(myGlobalInteraction.IsNotNull(),"testing non singleton initialization: ") 
  MITK_TEST_CONDITION_REQUIRED(myGlobalInteraction->IsInitialized() == false ,"testing initial initialization of non singleton: not initialized") 
  MITK_TEST_CONDITION_REQUIRED(myGlobalInteraction->Initialize("global"),"testing to initialize non singleton: ")
  MITK_TEST_CONDITION_REQUIRED(myGlobalInteraction->IsInitialized() ,"testing initialization of non singleton: initialized") 

  //testing if it really is a different instance than singleton
  MITK_TEST_CONDITION_REQUIRED(myGlobalInteraction != globalInteraction ,"Testing whether new instance equals the global satic one (must not be!)") 
  
  //getting singleton over non singleton instance: bug or feature???
  MITK_TEST_CONDITION_REQUIRED(myGlobalInteraction->GetInstance() == globalInteraction ,"Testing singleton from non singleton instance") 

  //destroy non singleton class
  myGlobalInteraction = NULL;
  
  //now test adding and removing of Interactors and Listeners
  //create Interactors
  mitk::PointSetInteractor::Pointer firstInteractor = mitk::PointSetInteractor::New("pointsetinteractor", NULL, 1);
  mitk::PointSetInteractor::Pointer secondInteractor = mitk::PointSetInteractor::New("pointsetinteractor", NULL, 10);

  globalInteraction->AddInteractor(firstInteractor);
  MITK_TEST_CONDITION_REQUIRED(globalInteraction->InteractorRegistered(firstInteractor),"Add first interactor to globalInteraction and check if is is registered: ") 
  globalInteraction->AddInteractor(secondInteractor);
  MITK_TEST_CONDITION_REQUIRED(globalInteraction->InteractorRegistered(secondInteractor),"Add second interactor to globalInteraction and check if is is registered: ") 

  //remove Interactor
  MITK_TEST_CONDITION_REQUIRED(globalInteraction->RemoveInteractor(firstInteractor),"Remove the first Interactor: ") 
  MITK_TEST_CONDITION_REQUIRED(!globalInteraction->RemoveInteractor(firstInteractor),"Remove the first Interactor a second time: ") 

  //check if really removed
  MITK_TEST_CONDITION_REQUIRED(!globalInteraction->InteractorRegistered(firstInteractor),"Check if the first is not registered: ") 
  //check if second still present
  MITK_TEST_CONDITION_REQUIRED(globalInteraction->InteractorRegistered(secondInteractor),"Check if the second is still registered: ") 
  
  //remove the second too
  MITK_TEST_CONDITION_REQUIRED(globalInteraction->RemoveInteractor(secondInteractor),"Remove the second Interactor: ") 
  MITK_TEST_CONDITION_REQUIRED(!globalInteraction->RemoveInteractor(secondInteractor),"Remove the second Interactor a second time: ") 
  MITK_TEST_CONDITION_REQUIRED(!globalInteraction->InteractorRegistered(secondInteractor),"Check if the second is not registered: ") 
  

  //------------------
  //now check the same with Listener
  std::cout << "Check the addition of a Listener the same way: ";
  std::cout << "Add two interactors as listeners (usually you add statemachines, not interactors). Are they both registered?: ";
  std::cout << "Add listener1 (ITK popup with warning should come up: ";
  globalInteraction->AddListener(firstInteractor);
  MITK_TEST_CONDITION_REQUIRED(globalInteraction->ListenerRegistered(firstInteractor),"registered listener1: ") 
  MITK_TEST_CONDITION_REQUIRED(!globalInteraction->ListenerRegistered(secondInteractor),"not yet registered listener2: ") 
  std::cout << "Add listener2: ";
  globalInteraction->AddListener(secondInteractor);
  MITK_TEST_CONDITION_REQUIRED(globalInteraction->ListenerRegistered(secondInteractor),"registered listener2: ") 
  MITK_TEST_CONDITION_REQUIRED(globalInteraction->ListenerRegistered(firstInteractor),"listener1 still registered: ") 
  
  //remove Listener
  MITK_TEST_CONDITION_REQUIRED(globalInteraction->RemoveListener(secondInteractor),"Remove listener2: ") 
  MITK_TEST_CONDITION_REQUIRED(!globalInteraction->ListenerRegistered(secondInteractor),"listener2 not registered anymore: ") 
  MITK_TEST_CONDITION_REQUIRED(globalInteraction->ListenerRegistered(firstInteractor),"but listener1: ") 
  //remove first too
  MITK_TEST_CONDITION_REQUIRED(globalInteraction->RemoveListener(firstInteractor),"Remove listener1: ") 
  MITK_TEST_CONDITION_REQUIRED(!globalInteraction->ListenerRegistered(firstInteractor),"listener1 not registered anymore: ") 
  MITK_TEST_CONDITION_REQUIRED(!globalInteraction->ListenerRegistered(secondInteractor),"listener2 also not registered: ") 

  
  //now add them as interactors again
  std::cout << "Now add the two interactors as interactors again: ";
  globalInteraction->AddInteractor(firstInteractor);
  globalInteraction->AddInteractor(secondInteractor);
  
  std::cout << "and free the instances!";
  //releasing smartpointer of interactors; should be kept in GlobalInteraction
  firstInteractor = NULL;
  secondInteractor = NULL;
  globalInteraction = NULL;

  // always end with this!
  MITK_TEST_END();
}
int mitkImageDataItemTest ( int  ,
char *  [] 
)

Definition at line 23 of file mitkImageDataItemTest.cpp.

References EXIT_SUCCESS.

{
  unsigned long *pixels = new unsigned long [100];
  void * data = pixels;

  std::cout << "Testing pseudo-type independent deleting: ";
  delete [] (unsigned char*) data;
  std::cout<<"[PASSED]"<<std::endl;

  std::cout<<"[TEST DONE]"<<std::endl;
  return EXIT_SUCCESS;
}
int mitkImageTest ( int  ,
char *  [] 
)

Definition at line 35 of file mitkImageTest.cpp.

References mitk::CastToItkImage(), mitk::Image::CopyMemory, EXIT_FAILURE, EXIT_SUCCESS, mitk::StandardFileLocations::GetInstance(), MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, MITK_TEST_FAILED_MSG, MITK_TEST_OUTPUT, mitkImageTest(), mitkIpPicDescriptor, mitk::DataNodeFactory::New(), mitk::PlaneGeometry::New(), and mitk::Image::New().

Referenced by mitkImageTest().

{
  MITK_TEST_BEGIN(mitkImageTest);

  //Create Image out of nowhere
  mitk::Image::Pointer imgMem;
  mitk::PixelType pt(typeid(int));
  unsigned int dim[]={100,100,20};

  std::cout << "Testing creation of Image: ";
  imgMem=mitk::Image::New();
  if(imgMem.IsNull())
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing Initialize(const mitk::PixelType& type, unsigned int dimension, unsigned int *dimensions): ";
  imgMem->Initialize(mitk::PixelType(typeid(int)), 3, dim);
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing IsInitialized(): ";
  if(imgMem->IsInitialized()==false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing GetData(): ";
  int *p = (int*)imgMem->GetData();
  if(p==NULL)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Filling image: ";
  unsigned int i;
  unsigned int size = dim[0]*dim[1]*dim[2];
  for(i=0; i<size; ++i, ++p)
    *p= (signed int)i;
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Getting it again and compare with filled values: ";
  int *p2 = (int*)imgMem->GetData();
  if(p2==NULL)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  for(i=0; i<size; ++i, ++p2)
  {
    if(*p2!= (signed int)i )
    {
      std::cout<<"[FAILED]"<<std::endl;
      return EXIT_FAILURE;
    }
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing IsInitialized(): ";
  if(imgMem->IsInitialized()==false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;
  
  std::cout << "Testing GetSliceData() and compare with filled values: ";
  p2 = (int*)imgMem->GetSliceData(dim[2]/2)->GetData();
  unsigned int xy_size = dim[0]*dim[1];
  unsigned int start_mid_slice = (dim[2]/2)*xy_size;
  for(i=0; i<xy_size; ++i, ++p2)
  {
    if(*p2!=(signed int)(i+start_mid_slice))
    {
      std::cout<<"[FAILED]"<<std::endl;
      return EXIT_FAILURE;
    }
  }
  std::cout<<"[PASSED]"<<std::endl;

  //----
  mitkIpPicDescriptor *pic_slice=mitkIpPicClone(imgMem->GetSliceData(dim[2]/2)->GetPicDescriptor());
  imgMem=mitk::Image::New();

  std::cout << "Testing reinitializing via Initialize(const mitk::PixelType& type, unsigned int dimension, unsigned int *dimensions): ";
  imgMem->Initialize(mitk::PixelType(typeid(int)), 3, dim);
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing slice-wise filling via SetPicSlice(): ";
  for(i=0;i<dim[2];++i)
  {
    imgMem->SetPicSlice(pic_slice, i, 0, 0);
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Getting it again and compare with filled values: ";
  p2 = (int*)imgMem->GetData();
  if(p2==NULL)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  for(i=0; i<size; ++i, ++p2)
  {
    if(*p2!= (signed int)((i%xy_size)+start_mid_slice))
    {
      std::cout<<"[FAILED]"<<std::endl;
      return EXIT_FAILURE;
    }
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing IsInitialized(): ";
  if(imgMem->IsInitialized()==false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Setting a copy of the volume once again: ";
  imgMem->SetPicVolume(mitkIpPicClone(imgMem->GetVolumeData(0)->GetPicDescriptor()),0);
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Set a slice with different content via SetPicSlice(): ";
  memset(pic_slice->data,0,xy_size*sizeof(int));
  imgMem->SetPicSlice(pic_slice, 1);

  std::cout << "Getting the volume again and compare the check the changed slice: ";
  p2 = (int*)imgMem->GetData();
  if(p2==NULL)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  p2+=xy_size;
  for(i=0; i<xy_size; ++i, ++p2)
  {
    if(*p2!=0)
    {
      std::cout<<"[FAILED]"<<std::endl;
      return EXIT_FAILURE;
    }
  }
  std::cout<<"[PASSED]"<<std::endl;


  std::cout << "Setting volume again: ";
  imgMem->SetVolume(imgMem->GetData());
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Set a slice with different content via SetSlice(): ";
  memset(pic_slice->data,0,xy_size*sizeof(int));
  imgMem->SetSlice(pic_slice->data, 0);

  std::cout << "Getting the volume again and compare the check the changed slice: ";
  p2 = (int*)imgMem->GetData();
  if(p2==NULL)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  for(i=0; i<xy_size; ++i, ++p2)
  {
    if(*p2!=0)
    {
      std::cout<<"[FAILED]"<<std::endl;
      return EXIT_FAILURE;
    }
  }
  std::cout<<"[PASSED]"<<std::endl;



  //std::cout << "Testing SetVolume(): ";
  //imgMem->SetVolume(data);
  //std::cout<<"[PASSED]"<<std::endl;

  mitkIpPicFree(pic_slice);

  //-----------------
  // geometry information for image
  mitk::Point3D origin;
  mitk::Vector3D right, bottom;
  mitk::Vector3D spacing;
  mitk::FillVector3D(origin, 17.0, 19.92, 7.83);
  mitk::FillVector3D(right, 1.0, 2.0, 3.0);
  mitk::FillVector3D(bottom, 0.0, -3.0, 2.0);
  mitk::FillVector3D(spacing, 0.78, 0.91, 2.23);

  std::cout << "Testing InitializeStandardPlane(rightVector, downVector, spacing): " << std::flush;
  mitk::PlaneGeometry::Pointer planegeometry = mitk::PlaneGeometry::New();
  planegeometry->InitializeStandardPlane(100, 100, right, bottom, &spacing);
  planegeometry->SetOrigin(origin);
  std::cout << "done" << std::endl;

  std::cout << "Testing Initialize(const mitk::PixelType& type, const mitk::Geometry3D& geometry, unsigned int slices) with PlaneGeometry and GetData(): ";
  imgMem->Initialize(mitk::PixelType(typeid(int)), *planegeometry);
  p = (int*)imgMem->GetData();
  if(p==NULL)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing Initialize(const mitk::PixelType& type, int sDim, const mitk::PlaneGeometry& geometry) and GetData(): ";
  imgMem->Initialize(mitk::PixelType(typeid(int)), 40, *planegeometry);
  p = (int*)imgMem->GetData();
  if(p==NULL)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  //-----------------
  // testing origin information and methods
  std::cout << "Testing correctness of origin via GetGeometry()->GetOrigin(): ";
  if( mitk::Equal(imgMem->GetGeometry()->GetOrigin(), origin) == false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing correctness of origin via GetTimeSlicedGeometry()->GetOrigin(): ";
  if( mitk::Equal(imgMem->GetTimeSlicedGeometry()->GetOrigin(), origin) == false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  mitk::FillVector3D(origin, 37.0, 17.92, 27.83);
  std::cout << "Setting origin via SetOrigin(origin): ";
  imgMem->SetOrigin(origin);
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing correctness of changed origin via GetGeometry()->GetOrigin(): ";
  if( mitk::Equal(imgMem->GetGeometry()->GetOrigin(), origin) == false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing correctness of changed origin via GetTimeSlicedGeometry()->GetOrigin(): ";
  if( mitk::Equal(imgMem->GetTimeSlicedGeometry()->GetOrigin(), origin) == false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing correctness of changed origin via GetSlicedGeometry()->GetGeometry2D(0)->GetOrigin(): ";
  if( mitk::Equal(imgMem->GetSlicedGeometry()->GetGeometry2D(0)->GetOrigin(), origin) == false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  //-----------------
  // testing spacing information and methods
  std::cout << "Testing correctness of spacing via GetGeometry()->GetSpacing(): ";
  if( mitk::Equal(imgMem->GetGeometry()->GetSpacing(), spacing) == false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing correctness of spacing via GetTimeSlicedGeometry()->GetSpacing(): ";
  if( mitk::Equal(imgMem->GetTimeSlicedGeometry()->GetSpacing(), spacing) == false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  mitk::FillVector3D(spacing, 7.0, 0.92, 1.83);
  std::cout << "Setting spacing via SetSpacing(spacing): ";
  imgMem->SetSpacing(spacing);
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing correctness of changed spacing via GetGeometry()->GetSpacing(): ";
  if( mitk::Equal(imgMem->GetGeometry()->GetSpacing(), spacing) == false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing correctness of changed spacing via GetTimeSlicedGeometry()->GetSpacing(): ";
  if( mitk::Equal(imgMem->GetTimeSlicedGeometry()->GetSpacing(), spacing) == false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing correctness of changed spacing via GetSlicedGeometry()->GetGeometry2D(0)->GetSpacing(): ";
  if( mitk::Equal(imgMem->GetSlicedGeometry()->GetGeometry2D(0)->GetSpacing(), spacing) == false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  //-----------------
  MITK_TEST_OUTPUT(<< "Testing SetImportChannel");
  mitk::Image::Pointer vecImg = mitk::Image::New();
  vecImg->Initialize(*imgMem->GetPixelType().GetTypeId(), *imgMem->GetGeometry(), 2 /* #channels */, 0 /*tDim*/ );
  vecImg->SetImportChannel(imgMem->GetData(), 0, mitk::Image::CopyMemory );
  vecImg->SetImportChannel(imgMem->GetData(), 1, mitk::Image::CopyMemory );
  std::cout<<"[PASSED]"<<std::endl;

  MITK_TEST_OUTPUT(<< " Testing whether IsValidSlice returns valid after SetImportChannel");
  MITK_TEST_CONDITION_REQUIRED( vecImg->IsValidSlice(0,0,1) , "");

  MITK_TEST_OUTPUT(<< " Testing whether CopyMemory worked");
  MITK_TEST_CONDITION_REQUIRED(imgMem->GetData() != vecImg->GetData(), "");

  MITK_TEST_OUTPUT(<< " Testing destruction after SetImportChannel");
  vecImg = NULL; 
  std::cout<<"[PASSED]"<<std::endl;

  //-----------------
  MITK_TEST_OUTPUT(<< "Testing initialization via vtkImageData");
  MITK_TEST_OUTPUT(<< " Setting up vtkImageData");
  vtkImageData* vtkimage = vtkImageData::New();
  vtkimage->Initialize();
  vtkimage->SetDimensions( 2, 3, 4);
  double vtkorigin[] =  {-350,-358.203, -1363.5};
  vtkimage->SetOrigin(vtkorigin);
  mitk::Point3D vtkoriginAsMitkPoint;
  mitk::vtk2itk(vtkorigin, vtkoriginAsMitkPoint);
  double vtkspacing[] =  {1.367, 1.367, 2};
  vtkimage->SetSpacing(vtkspacing);
  vtkimage->SetScalarType( VTK_SHORT );
  vtkimage->AllocateScalars();
  std::cout<<"[PASSED]"<<std::endl;
  
  MITK_TEST_OUTPUT(<< " Testing mitk::Image::Initialize(vtkImageData*, ...)");
  mitk::Image::Pointer mitkByVtkImage = mitk::Image::New();
  mitkByVtkImage ->Initialize(vtkimage);
  MITK_TEST_CONDITION_REQUIRED(mitkByVtkImage->IsInitialized(), "");

  MITK_TEST_OUTPUT(<< " vtkimage->Delete");
  vtkimage->Delete();
  std::cout<<"[PASSED]"<<std::endl;

  MITK_TEST_OUTPUT(<< " Testing whether spacing has been correctly initialized from vtkImageData");
  mitk::Vector3D spacing2 = mitkByVtkImage->GetGeometry()->GetSpacing();
  mitk::Vector3D vtkspacingAsMitkVector;
  mitk::vtk2itk(vtkspacing, vtkspacingAsMitkVector);
  MITK_TEST_CONDITION_REQUIRED(mitk::Equal(spacing2,vtkspacingAsMitkVector), "");

  MITK_TEST_OUTPUT(<< " Testing whether GetSlicedGeometry(0)->GetOrigin() has been correctly initialized from vtkImageData");
  mitk::Point3D origin2 = mitkByVtkImage->GetSlicedGeometry(0)->GetOrigin();
  MITK_TEST_CONDITION_REQUIRED(mitk::Equal(origin2,vtkoriginAsMitkPoint), "");

  MITK_TEST_OUTPUT(<< " Testing whether GetGeometry()->GetOrigin() has been correctly initialized from vtkImageData");
  origin2 = mitkByVtkImage->GetGeometry()->GetOrigin();
  MITK_TEST_CONDITION_REQUIRED(mitk::Equal(origin2,vtkoriginAsMitkPoint), "");

  MITK_TEST_OUTPUT(<< " Testing whether GetTimeSlicedGeometry()->GetOrigin() has been correctly initialized from vtkImageData");
  origin2 = mitkByVtkImage->GetTimeSlicedGeometry()->GetOrigin();
  MITK_TEST_CONDITION_REQUIRED(mitk::Equal(origin2,vtkoriginAsMitkPoint), "");

  // TODO test the following initializers on channel-incorporation
  //  void mitk::Image::Initialize(const mitk::PixelType& type, unsigned int dimension, unsigned int *dimensions, unsigned int channels)
  //  void mitk::Image::Initialize(const mitk::PixelType& type, int sDim, const mitk::Geometry2D& geometry2d, bool flipped, unsigned int channels, int tDim )
  //  void mitk::Image::Initialize(const mitk::Image* image) 
  //  void mitk::Image::Initialize(const mitkIpPicDescriptor* pic, int channels, int tDim, int sDim)

  //mitk::Image::Pointer vecImg = mitk::Image::New();
  //vecImg->Initialize(PixelType(typeid(float), 6, itk::ImageIOBase::SYMMETRICSECONDRANKTENSOR), *imgMem->GetGeometry(), 2 /* #channels */, 0 /*tDim*/, false /*shiftBoundingBoxMinimumToZero*/ );
  //vecImg->Initialize(PixelType(typeid(itk::Vector<float,6>)), *imgMem->GetGeometry(), 2 /* #channels */, 0 /*tDim*/, false /*shiftBoundingBoxMinimumToZero*/ );


  // testing access by index coordinates and by world coordinates
  
  mitk::DataNode::Pointer node;      
  mitk::DataNodeFactory::Pointer nodeReader = mitk::DataNodeFactory::New();
  mitk::StandardFileLocations::Pointer locator = mitk::StandardFileLocations::GetInstance();
  MITK_TEST_CONDITION_REQUIRED(locator.IsNotNull(),"Instantiating StandardFileLocations") 
  try
  {
    const std::string filename = locator->FindFile("brain.mhd", "Core/Code/Testing/Data");   
    nodeReader->SetFileName(filename);
    nodeReader->Update();
    node = nodeReader->GetOutput();      
  }
  catch(...) {
    MITK_TEST_FAILED_MSG(<< "Could not read file for testing: " << "brain.mhd");
    return NULL;
  }  

  mitk::Image::Pointer image = dynamic_cast<mitk::Image*>(node->GetData());
    
  // test by index coordinates
  mitk::Index3D index;
  mitk::FillVector3D(index, 55, 39, 50);
  MITK_TEST_OUTPUT(<< "Testing mitk::Image::GetPixelValueByIndex");
  double val = image->GetPixelValueByIndex(index);
  MITK_TEST_CONDITION_REQUIRED( mitk::Equal(val,112.22475433349609), "");
  
  //test by world coordinates
  MITK_TEST_OUTPUT(<< "Testing mitk::Image::GetPixelValueByWorldCoordinate");
  mitk::Point3D point;
  mitk::FillVector3D(point, -5.93752, 18.7199, 6.74218);
  val = image->GetPixelValueByWorldCoordinate(point);
  MITK_TEST_CONDITION_REQUIRED( mitk::Equal(val,94.456184387207031), "");

  MITK_TEST_OUTPUT(<< "Convert to index and access value by mitk::Image::GetPixelValueByIndex again");
  mitk::Index3D index2;
  image->GetGeometry()->WorldToIndex(point, index2);
  float val2 = image->GetPixelValueByIndex(index2);
  MITK_TEST_CONDITION_REQUIRED( mitk::Equal(val2,94.456184387207031), "");

  //access via itk
  MITK_TEST_OUTPUT(<< "Test conversion to itk::Image");
  typedef itk::Image<float,3> ItkFloatImage3D;
  ItkFloatImage3D::Pointer itkimage;
  mitk::CastToItkImage(image, itkimage);
  std::cout<<"[PASSED]"<<std::endl;
 
  MITK_TEST_OUTPUT(<< "Testing world->itk-physical->world consistency");
  mitk::Point3D itkPhysicalPoint;
  image->GetGeometry()->WorldToItkPhysicalPoint(point, itkPhysicalPoint);

  mitk::Point3D backTransformedPoint;
  image->GetGeometry()->ItkPhysicalPointToWorld(itkPhysicalPoint, backTransformedPoint);
  MITK_TEST_CONDITION_REQUIRED( mitk::Equal(point,backTransformedPoint), "");

  MITK_TEST_OUTPUT(<< "Compare value of pixel returned by mitk in comparison to itk");
  itk::Index<3> idx;  
  itkimage->TransformPhysicalPointToIndex(itkPhysicalPoint, idx);
  float valByItk = itkimage->GetPixel(idx);

  MITK_TEST_CONDITION_REQUIRED( mitk::Equal(valByItk,94.456184387207031), "");

  MITK_TEST_END();

  return EXIT_SUCCESS;
}
int mitkImageTimeSelectorTest ( int  ,
char *  [] 
)

Definition at line 25 of file mitkImageTimeSelectorTest.cpp.

References EXIT_FAILURE, EXIT_SUCCESS, mitk::ImageTimeSelector::New(), and mitk::DataNodeFactory::New().

{

  std::cout << "Loading file: ";
  if(argc==0)
  {
    std::cout<<"no file specified [FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  mitk::Image::Pointer image = NULL;
  mitk::DataNodeFactory::Pointer factory = mitk::DataNodeFactory::New();
  try
  {
    factory->SetFileName( argv[1] );
    factory->Update();

    if(factory->GetNumberOfOutputs()<1)
    {
      std::cout<<"file could not be loaded [FAILED]"<<std::endl;
      return EXIT_FAILURE;
    }
    mitk::DataNode::Pointer node = factory->GetOutput( 0 );
    image = dynamic_cast<mitk::Image*>(node->GetData());
    if(image.IsNull())
    {
      std::cout<<"file not an image - test will not be applied [PASSED]"<<std::endl;
      std::cout<<"[TEST DONE]"<<std::endl;
      return EXIT_SUCCESS;
    }
  }
  catch ( itk::ExceptionObject & ex )
  {
    std::cout << "Exception: " << ex << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }

  //Take a time step
  mitk::ImageTimeSelector::Pointer timeSelector = mitk::ImageTimeSelector::New();
  timeSelector->SetInput(image);
  timeSelector->SetTimeNr( 0 );
  timeSelector->UpdateLargestPossibleRegion();
  mitk::Image::Pointer result = timeSelector->GetOutput();

  std::cout << "Testing IsInitialized(): ";
  if(result->IsInitialized()==false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing if Volume is set ";
  //result->DisconnectPipeline();
  //timeSelector = NULL;

  if( result->IsVolumeSet(0) == false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;



  std::cout<<"[TEST DONE]"<<std::endl;
  return EXIT_SUCCESS;
}
int mitkImageWriterTest ( int  argc,
char *  argv[] 
)

test for "ImageWriter".

argc and argv are the command line parameters which were passed to the ADD_TEST command in the CMakeLists.txt file. For the automatic tests, argv is either empty for the simple tests or contains the filename of a test image for the image tests (see CMakeLists.txt).

Definition at line 33 of file mitkImageWriterTest.cpp.

References EXIT_SUCCESS, MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, MITK_TEST_FAILED_MSG, MITK_TEST_FOR_EXCEPTION_BEGIN, MITK_TEST_FOR_EXCEPTION_END, MITK_TEST_OUTPUT, mitk::DataNodeFactory::New(), and mitk::ImageWriter::New().

{
  // always start with this!
  MITK_TEST_BEGIN("ImageWriter")

    // let's create an object of our class  
    mitk::ImageWriter::Pointer myImageWriter = mitk::ImageWriter::New();

  // first test: did this work?
  // using MITK_TEST_CONDITION_REQUIRED makes the test stop after failure, since
  // it makes no sense to continue without an object.
  MITK_TEST_CONDITION_REQUIRED(myImageWriter.IsNotNull(),"Testing instantiation") 

    // write your own tests here and use the macros from mitkTestingMacros.h !!!
    // do not write to std::cout and do not return from this function yourself!

    // load image
    
  MITK_TEST_CONDITION_REQUIRED(argc != 0, "File to load has been specified");


  mitk::Image::Pointer image = NULL;
  mitk::DataNodeFactory::Pointer factory = mitk::DataNodeFactory::New();

  try
  {
    MITK_TEST_OUTPUT(<< "Loading file: " << argv[1]);
    factory->SetFileName( argv[1] );
    factory->Update();
    MITK_TEST_CONDITION_REQUIRED(factory->GetNumberOfOutputs() > 0, "file loaded");
    
    mitk::DataNode::Pointer node = factory->GetOutput( 0 );
    image = dynamic_cast<mitk::Image*>(node->GetData());
    if(image.IsNull())
    {
      std::cout<<"file "<< argv[1]<< "is not an image - test will not be applied."<<std::endl;
      std::cout<<"[TEST DONE]"<<std::endl;
      return EXIT_SUCCESS;
    }  
  }
  catch (itk::ExceptionObject & ex)
  {
    MITK_TEST_FAILED_MSG(<< "Exception during file loading: " << ex.GetDescription());
  }


  MITK_TEST_CONDITION_REQUIRED(image.IsNotNull(),"loaded image not NULL")

  // test set/get methods
  myImageWriter->SetInput(image);
  MITK_TEST_CONDITION_REQUIRED(myImageWriter->GetInput()==image,"test Set/GetInput()");
  myImageWriter->SetFileName("test");
  MITK_TEST_CONDITION_REQUIRED(!strcmp(myImageWriter->GetFileName(),"test"),"test Set/GetFileName()");
  myImageWriter->SetExtension(".pic");
  MITK_TEST_CONDITION_REQUIRED(!strcmp(myImageWriter->GetExtension(),".pic"),"test Set/GetExtension()");
  myImageWriter->SetFilePrefix("pref");
  MITK_TEST_CONDITION_REQUIRED(!strcmp(myImageWriter->GetFilePrefix(),"pref"),"test Set/GetFilePrefix()");
  myImageWriter->SetFilePattern("pattern");
  MITK_TEST_CONDITION_REQUIRED(!strcmp(myImageWriter->GetFilePattern(),"pattern"),"test Set/GetFilePattern()");

  // write ITK .mhd image (2D and 3D only)
  if( image->GetDimension() <= 3 )
  {
    try
    {
      myImageWriter->SetExtension(".mhd");
      myImageWriter->Update();
      std::fstream fin, fin2;
      fin.open("test.mhd",std::ios::in);
      fin2.open("test.raw",std::ios::in);
      MITK_TEST_CONDITION_REQUIRED(fin.is_open(),"Write .mhd file");
      MITK_TEST_CONDITION_REQUIRED(fin2.is_open(),"Write .raw file");
      fin.close();
      fin2.close();
      remove("test.mhd");
      remove("test.raw");
    }
    catch (...)
    {
      MITK_TEST_FAILED_MSG(<< "Exception during .mhd file writing");
    }
  }

  // write MITK .pic image
  try
  {
    myImageWriter->SetExtension(".pic");
    myImageWriter->Update();
    std::fstream fin;
    fin.open("test.pic",std::ios::in);
    MITK_TEST_CONDITION_REQUIRED(fin.is_open(),"Write .pic file");
    fin.close();
    remove("test.pic");
  }
  catch (...)
  {
    MITK_TEST_FAILED_MSG(<< "Exception during .pic file writing");
  }

  // test for exception handling
  try
  {
    MITK_TEST_FOR_EXCEPTION_BEGIN(itk::ExceptionObject)
    myImageWriter->SetInput(image);
    myImageWriter->SetFileName("/usr/bin");
    myImageWriter->Update(); 
    MITK_TEST_FOR_EXCEPTION_END(itk::ExceptionObject)
  }
  catch(...) {
    //this means that a wrong exception (i.e. no itk:Exception) has been thrown 
    MITK_TEST_FAILED_MSG(<< "Wrong exception (i.e. no itk:Exception) caught during write");
  }

  // always end with this!
  MITK_TEST_END();
}
int mitkInteractorTest ( int  ,
char *  [] 
)

Definition at line 29 of file mitkInteractorTest.cpp.

References mitk::BS_MidButton, mitk::BS_NoButton, mitk::GlobalInteraction::GetInstance(), mitk::Key_none, MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, mitk::Interactor::New(), mitk::StateEvent::Set(), mitk::Interactor::SMDESELECTED, mitk::Interactor::SMSELECTED, mitk::Type_MouseButtonPress, mitk::Type_MouseButtonRelease, and mitk::Type_MouseMove.

{
  MITK_TEST_BEGIN("Interactor")

  // Global interaction must(!) be initialized if used
  mitk::GlobalInteraction::GetInstance()->Initialize("global");

  //create interactor; use pattern InteractorTestPattern
  mitk::Interactor::Pointer interactor = mitk::Interactor::New("InteractorTestPattern", NULL);

  //load interactor
  std::cout << "Testing to initialize the interactor";
  MITK_TEST_CONDITION_REQUIRED(interactor.IsNotNull(),"Testing to initialize the interactor")
  
  std::cout<<"The pattern of the interactor is called: "<<interactor->GetType()<<std::endl;
  
  //creating an event to go from state 0 to state 1:
  //<!-- middle MouseButton -->
  //<event NAME="middle MouseBN" ID="4" TYPE="Type_MouseButtonPress" BUTTON="BS_MidButton" BUTTONSTATE="0x0000" KEY="Key_none" />
  mitk::Event *event = new mitk::Event(NULL, mitk::Type_MouseButtonPress, mitk::BS_MidButton, mitk::BS_NoButton, mitk::Key_none);
  mitk::StateEvent *stateEvent = new mitk::StateEvent(4, event);
  MITK_TEST_CONDITION_REQUIRED(interactor->HandleEvent(stateEvent),"Testing to send an event to go from State 0 to State 1")
  
  MITK_TEST_CONDITION_REQUIRED(interactor->GetMode() == mitk::Interactor::SMSELECTED,"Testing right Mode and thus right action behavior")
  
  //statemachine should have called transition "initmove", executed action with he id 9 and currentState should be 1 = "move"
  delete event;

  //send next event to stay in State1
  //<!-- middle MouseButton and MouseMove -->
  //<event NAME="middleBN+MouseMove" ID="533" TYPE="Type_MouseMove" BUTTON="BS_NoButton" BUTTONSTATE="0x0004" KEY="Key_none" />
  event = new mitk::Event(NULL, mitk::Type_MouseMove, mitk::BS_NoButton, mitk::BS_MidButton, mitk::Key_none);
  stateEvent->Set(533, event);
  MITK_TEST_CONDITION_REQUIRED(interactor->HandleEvent(stateEvent),"Staying in State 1")

  MITK_TEST_CONDITION_REQUIRED(interactor->GetMode() == mitk::Interactor::SMSELECTED,"Testing for the same Mode")
  delete event;

  //create a new event
  //<!-- MiddleMouseButtonRelease -->
  //<event NAME="MiddleMouseRelease" ID="506" TYPE="Type_MouseButtonRelease" BUTTON="BS_MidButton" BUTTONSTATE="0x0004" KEY="Key_none" />
  event = new mitk::Event(NULL, mitk::Type_MouseButtonRelease, mitk::BS_MidButton, mitk::BS_MidButton, mitk::Key_none);
  stateEvent->Set(506, event);
  //because the statemachine is waiting for this event, 0.5 should be returned
  float returnvalue = interactor->CanHandleEvent(stateEvent);
  MITK_TEST_CONDITION_REQUIRED(returnvalue == 0.5,"Testing to call CanHandleEvent with next event")
  std::cout<<"CanHandleEvent returned: "<<returnvalue<<std::endl;

  //The transition "finish" should call no action an lead into state 0 = startState 
  MITK_TEST_CONDITION_REQUIRED(interactor->HandleEvent(stateEvent),"Testing to send next event leading back to startState0")

  MITK_TEST_CONDITION_REQUIRED(interactor->GetMode() == mitk::Interactor::SMDESELECTED,"Testing right Mode and thus right action behavior")
  delete event;


  event = NULL;
  stateEvent->Set(4, event);
  MITK_TEST_CONDITION_REQUIRED(interactor->HandleEvent(stateEvent),"Testing to send event == NULL to interactor")
  delete stateEvent;
  stateEvent = NULL;
  MITK_TEST_CONDITION_REQUIRED( ! interactor->HandleEvent(stateEvent),"Testing to send stateEvent == NULL to interactor")
  
  MITK_TEST_END()
}
int mitkITKThreadingTest ( int  ,
char *  [] 
)

Definition at line 94 of file mitkITKThreadingTest.cpp.

References EXIT_FAILURE, EXIT_SUCCESS, UserData::intPointer, UserData::mayIRun, UserData::mutex, UserData::semaphore, and ThreadedFunction().

{
  itk::MultiThreader::Pointer threader = itk::MultiThreader::New();

  int localInt(0); // this will be modified by both threads
  
  itk::Semaphore::Pointer m_ResultAvailable = itk::Semaphore::New();
  m_ResultAvailable->Initialize(0); // no pieces left (thread has to create one)
  
  itk::Semaphore::Pointer m_RunThreadRun = itk::Semaphore::New();
  m_RunThreadRun->Initialize(0); // no pieces left (thread has to create one)
  
  itk::FastMutexLock::Pointer m_Mutex = itk::FastMutexLock::New();

  UserData userData;
  userData.intPointer = &localInt;
  userData.mutex = m_Mutex.GetPointer();
  userData.semaphore = m_ResultAvailable.GetPointer();
  userData.mayIRun = m_RunThreadRun.GetPointer();
  
  itk::ThreadFunctionType pointer = &ThreadedFunction;
  int thread_id = threader->SpawnThread( pointer, &userData );

  // let thread generate 10 results
  for (int i = 1; i <= 10000; ++i)
    m_ResultAvailable->Down();

  std::cout<<"signaling by semaphore thread->main ";
  if (localInt == 10000)
    std::cout<<"[PASSED]"<<std::endl;
  else
  {
    std::cout<<"[FAILED] localInt == "<< localInt <<std::endl;
    return EXIT_FAILURE;
  }

  // increase int simultaneously with thread (coordinated by mutex)
  localInt = 0;
  m_RunThreadRun->Up(); // let thread work again
  for (int i = 1; i <= 10000; ++i)
  {
    m_Mutex->Lock();
    ++localInt;
    m_Mutex->Unlock();
  }

  std::cout<<"waiting for thread's signal"<<std::endl;;
  m_ResultAvailable->Down(); // wait for thread
  std::cout<<"got thread's signal"<<std::endl;;
  
  std::cout<<"sharing a mutex protected variable among threads";
  if (localInt == 20000)
    std::cout<<"[PASSED]"<<std::endl;
  else
  {
    std::cout<<"[FAILED] localInt == "<< localInt <<std::endl;
    return EXIT_FAILURE;
  }

  // terminating work thread
  std::cout<<"waiting for idling thread ";
  threader->TerminateThread( thread_id );
  std::cout<<"[PASSED]"<<std::endl;
  
  std::cout<<"Whole test [PASSED]"<<std::endl;

  return EXIT_SUCCESS;
}
int mitkLevelWindowTest ( int  ,
char *  [] 
)

Definition at line 21 of file mitkLevelWindowTest.cpp.

References EXIT_FAILURE, EXIT_SUCCESS, mitk::LevelWindow::GetDefaultLevel(), mitk::LevelWindow::GetDefaultLowerBound(), mitk::LevelWindow::GetDefaultUpperBound(), mitk::LevelWindow::GetDefaultWindow(), mitk::LevelWindow::GetLevel(), mitk::LevelWindow::GetLowerWindowBound(), mitk::LevelWindow::GetRange(), mitk::LevelWindow::GetRangeMax(), mitk::LevelWindow::GetRangeMin(), mitk::LevelWindow::GetUpperWindowBound(), mitk::LevelWindow::GetWindow(), int(), mitk::Image::New(), mitk::LevelWindow::ResetDefaultLevelWindow(), mitk::LevelWindow::ResetDefaultRangeMinMax(), mitk::LevelWindow::SetAuto(), mitk::LevelWindow::SetDefaultBoundaries(), mitk::LevelWindow::SetDefaultLevelWindow(), mitk::LevelWindow::SetLevelWindow(), mitk::LevelWindow::SetRangeMinMax(), and mitk::LevelWindow::SetWindowBounds().

{
  std::cout << "Testing mitk::LevelWindow  "<<std::endl;

  std::cout << "Testing mitk::LevelWindow constructor with Level and Window ";
  mitk::LevelWindow* levWin = new mitk::LevelWindow(256, 500);
  std::cout<<"[PASSED]"<<std::endl;
  
  std::cout << "Testing mitk::LevelWindow GetDefaultWindow ";
  mitk::ScalarType defaultWindow = levWin->GetDefaultWindow();
  if (!(defaultWindow == 500))
  {
    std::cout<<(int)(defaultWindow) + "[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow GetDefaultLevel ";
  mitk::ScalarType defaultLevel = levWin->GetDefaultLevel();
  if (!(defaultLevel == 256))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow GetWindow ";
  mitk::ScalarType window = levWin->GetWindow();
  if (!(window == 500))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow GetMin ";
  if (!(levWin->GetLowerWindowBound() == 6))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow GetMax ";
  if (!(levWin->GetUpperWindowBound() == 506))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow GetLevel ";
  mitk::ScalarType level = levWin->GetLevel();
  if (!(level == 256))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;
  
  std::cout << "Testing mitk::LevelWindow GetWindow : GetDefaultWindow ";
  if (!(defaultWindow == window))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow GetLevel : GetDefaultLevel ";
  if (!(defaultLevel == level))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow SetLevelWindow ";
  levWin->SetLevelWindow(20, 100);
  if (!(levWin->GetLevel() == 20))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  if (!(levWin->GetWindow() == 100))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow SetLevelWindow ";
  levWin->SetLevelWindow(levWin->GetDefaultLevel(), levWin->GetDefaultWindow());
  if (!(levWin->GetLevel() == 256) && !(levWin->GetWindow() == 500))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow SetDefaultLevelWindow ";
  levWin->SetDefaultLevelWindow(20, 200);
  if (!(levWin->GetDefaultLevel() == 20) && !(levWin->GetDefaultWindow() == 200))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow ResetDefaultLevelWindow ";
  levWin->SetLevelWindow(100, 50);
  levWin->ResetDefaultLevelWindow();
  //double a = levWin->GetLevel();
  //double d = levWin->GetWindow();

  if (!((levWin->GetLevel() == 20) &&(levWin->GetWindow() == 200)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow SetWindowBounds ";
  levWin->SetWindowBounds(0, 2);
  if (!((levWin->GetLowerWindowBound() == 0) && (levWin->GetUpperWindowBound() == 2) && (levWin->GetLevel() == 1) && (levWin->GetWindow() == 2)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow SetRangeMinMax with rangemin = rangemax";
  levWin->SetRangeMinMax(2000, 2000);
  if (!(levWin->GetRangeMin() == 1999 && levWin->GetRangeMax() == 2000))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow SetRangeMinMax with rangemin > rangemax";
  levWin->SetRangeMinMax(2100, 2000);
  if (!(levWin->GetRangeMin() == 2000 && levWin->GetRangeMax() == 2100))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow SetRangeMinMax ";
  levWin->SetRangeMinMax(-1000, 2000);
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow GetRangeMin ";
  if (!(levWin->GetRangeMin() == -1000))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow GetRangeMax ";
  if (!(levWin->GetRangeMax() == 2000))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow GetRange ";
  if (!((levWin->GetRangeMax() - levWin->GetRangeMin()) == levWin->GetRange()))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow SetDefaultBoundaries with rangemin = rangemax";
  levWin->SetDefaultBoundaries(2000, 2000);
  if (!(levWin->GetDefaultLowerBound() == 1999 && levWin->GetDefaultUpperBound() == 2000))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow SetDefaultBoundaries with rangemin > rangemax";
  levWin->SetDefaultBoundaries(2100, 2000);
  if (!(levWin->GetDefaultLowerBound() == 2000 && levWin->GetDefaultUpperBound() == 2100))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow SetDefaultBoundaries ";
  levWin->SetDefaultBoundaries(-2000, 8000);
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow GetDefaultLowerBound ";
  if (!(levWin->GetDefaultLowerBound() == -2000))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow GetDefaultUpperBound ";
  if (!(levWin->GetDefaultUpperBound() == 8000))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow ResetDefaultRangeMinMax ";
  levWin->ResetDefaultRangeMinMax();
  if (!((levWin->GetRangeMin() == levWin->GetDefaultLowerBound()) && (levWin->GetRangeMax() == levWin->GetDefaultUpperBound())))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow minRange > maxRange ";
  levWin->SetRangeMinMax(2000, 1000);
  if (!((levWin->GetRangeMin() == 1000) && (levWin->GetRangeMax() == 2000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->SetRangeMinMax(2000, -1000);
  if (!((levWin->GetRangeMin() == -1000) && (levWin->GetRangeMax() == 2000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->SetRangeMinMax(-2000, -3000);
  if (!((levWin->GetRangeMin() == -3000) && (levWin->GetRangeMax() == -2000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->SetRangeMinMax(0, -1000);
  if (!((levWin->GetRangeMin() == -1000) && (levWin->GetRangeMax() == 0)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->SetRangeMinMax(2000, 0);
  if (!((levWin->GetRangeMin() == 0) && (levWin->GetRangeMax() == 2000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->SetRangeMinMax(-10000, 10000);
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow defaultMinRange > defaultMaxRange ";
  levWin->SetDefaultBoundaries(2000, 1000);
  if (!((levWin->GetDefaultLowerBound() == 1000) && (levWin->GetDefaultUpperBound() == 2000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->SetDefaultBoundaries(2000, -1000);
  if (!((levWin->GetDefaultLowerBound() == -1000) && (levWin->GetDefaultUpperBound() == 2000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->SetDefaultBoundaries(-2000, -3000);
  if (!((levWin->GetDefaultLowerBound() == -3000) && (levWin->GetDefaultUpperBound() == -2000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->SetDefaultBoundaries(0, -1000);
  if (!((levWin->GetDefaultLowerBound() == -1000) && (levWin->GetDefaultUpperBound() == 0)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->SetDefaultBoundaries(2000, 0);
  if (!((levWin->GetDefaultLowerBound() == 0) && (levWin->GetDefaultUpperBound() == 2000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->SetDefaultBoundaries(-10000, 10000);
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow min > max ";
  levWin->SetWindowBounds(2000, 1000);
  if (!((levWin->GetLowerWindowBound() == 1000) && (levWin->GetUpperWindowBound() == 2000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->SetWindowBounds(2000, -1000);
  if (!((levWin->GetLowerWindowBound() == -1000) && (levWin->GetUpperWindowBound() == 2000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->SetWindowBounds(-2000, -3000);
  if (!((levWin->GetLowerWindowBound() == -3000) && (levWin->GetUpperWindowBound() == -2000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->SetWindowBounds(0, -1000);
  if (!((levWin->GetLowerWindowBound() == -1000) && (levWin->GetUpperWindowBound() == 0)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->SetWindowBounds(2000, 0);
  if (!((levWin->GetLowerWindowBound() == 0) && (levWin->GetUpperWindowBound() == 2000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  //minmax > maxrange, minmax < minrange, min<maxrange & max >maxrange, min < minrange & max > minrange
  // max < minrange & min > minrange, min > maxrange & max < maxrange, min < minrange & max > maxrange
  // min > maxrange & max < minrange 
  std::cout << "Testing mitk::LevelWindow max > min > maxrange ";
  levWin->SetWindowBounds(11000, 12000);
  if (!((levWin->GetLowerWindowBound() == 9999) && (levWin->GetUpperWindowBound() == 10000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow min > max > maxrange ";
  levWin->SetWindowBounds(12000, 11000);
  if (!((levWin->GetLowerWindowBound() == 9999) && (levWin->GetUpperWindowBound() == 10000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow min < max < minrange ";
  levWin->SetWindowBounds(-12000, -11000);
  if (!((levWin->GetLowerWindowBound() == -10000) && (levWin->GetUpperWindowBound() == -9999)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow max < min < minrange ";
  levWin->SetWindowBounds(-11000, -12000);
  if (!((levWin->GetLowerWindowBound() == -10000) && (levWin->GetUpperWindowBound() == -9999)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow min < maxrang & max > maxrange ";
  levWin->SetWindowBounds(9999, 12000);
  if (!((levWin->GetLowerWindowBound() == 9999) && (levWin->GetUpperWindowBound() == 10000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow min < minrange & max > minrange ";
  levWin->SetWindowBounds(-11000, -9999);
  if (!((levWin->GetLowerWindowBound() == -10000) && (levWin->GetUpperWindowBound() == -9999)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow min < minrange & max > maxrange ";
  levWin->SetWindowBounds(-11000, 11000);
  if (!((levWin->GetLowerWindowBound() == -10000) && (levWin->GetUpperWindowBound() == 10000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow maxrange > min = max > minrange ";
  levWin->SetWindowBounds(5000, 5000);
  if (!((levWin->GetLowerWindowBound() == 4999) && (levWin->GetUpperWindowBound() == 5000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow min = max = minrange ";
  levWin->SetWindowBounds(-10000, -10000);
  if (!((levWin->GetLowerWindowBound() == -10000) && (levWin->GetUpperWindowBound() == -9999)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow min = max = maxrange ";
  levWin->SetWindowBounds(10000, 10000);
  if (!((levWin->GetLowerWindowBound() == 9999) && (levWin->GetUpperWindowBound() == 10000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow min = max > maxrange ";
  levWin->SetWindowBounds(11000, 11000);
  if (!((levWin->GetLowerWindowBound() == 9999) && (levWin->GetUpperWindowBound() == 10000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow min = max < minrange ";
  levWin->SetWindowBounds(-11000, -11000);
  if (!((levWin->GetLowerWindowBound() == -10000) && (levWin->GetUpperWindowBound() == -9999)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow maxrange > min > minrange > max ";
  levWin->SetWindowBounds(-9000, -11000);
  if (!((levWin->GetLowerWindowBound() == -10000) && (levWin->GetUpperWindowBound() == -9000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow min > maxrange > minrange > max ";
  levWin->SetWindowBounds(11000, -11000);
  if (!((levWin->GetLowerWindowBound() == -10000) && (levWin->GetUpperWindowBound() == 10000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow SetRangeMinMax with maxrange < min < max ";
  levWin->SetRangeMinMax(-20000, -15000);
  if (!((levWin->GetLowerWindowBound() == -15001) && (levWin->GetUpperWindowBound() == -15000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultRangeMinMax();
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow SetRangeMinMax with minrange > maxrange & maxrange < min < max ";
  levWin->ResetDefaultLevelWindow();
  levWin->SetRangeMinMax(-15000, -20000);
  if (!((levWin->GetLowerWindowBound() == -15001) && (levWin->GetUpperWindowBound() == -15000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultRangeMinMax();
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow SetRangeMinMax with minrange < min < maxrange < max ";
  levWin->SetRangeMinMax(-80, 1000);
  levWin->SetWindowBounds(-1000,110);
  if (!((levWin->GetLowerWindowBound() == -80) && (levWin->GetUpperWindowBound() == 110)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultRangeMinMax();
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow SetRangeMinMax with maxrange < minrange & minrange < min < maxrange < max ";
  levWin->SetRangeMinMax(1000,-80);
  levWin->SetWindowBounds(-1000,110);
  if (!((levWin->GetLowerWindowBound() == -80) && (levWin->GetUpperWindowBound() == 110)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultRangeMinMax();
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow SetRangeMinMax with min < minrange < maxrange <max ";
  levWin->SetRangeMinMax(20, 110);
  if (!((levWin->GetLowerWindowBound() == 20) && (levWin->GetUpperWindowBound() == 110)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultRangeMinMax();
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow SetRangeMinMax with minRange > maxRange & min < maxrange < max ";
  levWin->SetWindowBounds(-90,1000);
  levWin->SetRangeMinMax(100, -80);

  if (!((levWin->GetLowerWindowBound() == -80) && (levWin->GetUpperWindowBound() == 100)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultRangeMinMax();
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow SetRangeMinMax with minRange > maxRange & min < minrange < maxrange <max ";
  levWin->SetRangeMinMax(20, 100);
  if (!((levWin->GetLowerWindowBound() == 20) && (levWin->GetUpperWindowBound() == 100)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultRangeMinMax();
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow SetRangeMinMax with min < max < minrange ";
  levWin->SetRangeMinMax(20000, 15000);
  if (!((levWin->GetLowerWindowBound() == 15000) && (levWin->GetUpperWindowBound() == 15001)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultRangeMinMax();
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow SetRangeMinMax with minrange > maxrange & min < max < minrange ";
  levWin->SetRangeMinMax(20000, 15000);
  if (!((levWin->GetLowerWindowBound() == 15000) && (levWin->GetUpperWindowBound() == 15001)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultRangeMinMax();
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow SetRangeMinMax with min < minrange <max ";
  levWin->SetRangeMinMax(-20000, -15000);
  if (!((levWin->GetLowerWindowBound() == -15001) && (levWin->GetUpperWindowBound() == -15000)))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  levWin->ResetDefaultRangeMinMax();
  levWin->ResetDefaultLevelWindow();
  std::cout<<"[PASSED]"<<std::endl;

  // auch für default levelwindow und default range

  //Create Image out of nowhere
  mitk::Image::Pointer image;
  mitk::PixelType pt(typeid(int));
  unsigned int dim[]={100,100,20};

  std::cout << "Creating image: ";
  image = mitk::Image::New();
  //image->DebugOn();
  image->Initialize(mitk::PixelType(typeid(int)), 3, dim);
  int *p = (int*)image->GetData();

  int size = dim[0]*dim[1]*dim[2];
  int i;
  for(i=0; i<size; ++i, ++p)
    *p=i;
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow SetAuto ";
  mitk::LevelWindow levelwindow;
  levelwindow.SetAuto( image );
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing mitk::LevelWindow constructor with mitkLevelWindow ";
  const mitk::LevelWindow* lw = new mitk::LevelWindow(levelwindow);
  if (!(lw->GetRange() == levelwindow.GetRange()))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;
  
  std::cout << "Testing mitk::LevelWindow destructor ";
  delete levWin;
  delete lw;
  std::cout<<"[PASSED]"<<std::endl;
  std::cout<<"[TEST DONE]"<<std::endl;
  return EXIT_SUCCESS;
}
int mitkMaterialTest ( int  ,
char *  [] 
)

Definition at line 346 of file mitkMaterialTest.cpp.

References MITK_TEST_BEGIN, MITK_TEST_END, MaterialTest::testAssignable(), MaterialTest::testConstructor(), MaterialTest::testConstructorColorColorCoefficientSpecularCoefficientSpecularPowerOpacity(), MaterialTest::testConstructorPropertyRedGreenBlueOpacityAndName(), MaterialTest::testConstructorRedGreenBlueColorCoefficientSpecularCoefficientSpecularPowerOpacity(), MaterialTest::testConstructorWithColorOpacity(), MaterialTest::testConstructorWithRedGreenBlueOpacity(), MaterialTest::testInitialize(), MaterialTest::testOperatorAssign(), MaterialTest::testOperatorequality(), MaterialTest::testSetColor(), MaterialTest::testSetColorCoefficient(), MaterialTest::testSetInterpolation(), MaterialTest::testSetLineWidth(), MaterialTest::testSetOpacity(), MaterialTest::testSetRepresentation(), MaterialTest::testSetSpecularCoefficient(), MaterialTest::testSetSpecularColor(), and MaterialTest::testSetSpecularPower().

{
  // always start with this!
  MITK_TEST_BEGIN("Material")
      
      MaterialTest materialTest;

      materialTest.testConstructor();
      materialTest.testConstructorWithColorOpacity();
      materialTest.testConstructorWithRedGreenBlueOpacity();
      materialTest.testConstructorRedGreenBlueColorCoefficientSpecularCoefficientSpecularPowerOpacity();
      materialTest.testConstructorColorColorCoefficientSpecularCoefficientSpecularPowerOpacity();
      materialTest.testConstructorPropertyRedGreenBlueOpacityAndName();
      materialTest.testAssignable();
      materialTest.testOperatorAssign();
      materialTest.testSetColor();
      materialTest.testSetColorCoefficient();
      materialTest.testSetSpecularColor();
      materialTest.testSetSpecularCoefficient();
      materialTest.testSetSpecularPower();
      materialTest.testSetOpacity();
      materialTest.testSetInterpolation();
      materialTest.testSetRepresentation();
      materialTest.testSetLineWidth();
      materialTest.testInitialize();
      materialTest.testOperatorequality();
   
      // first test: did this work?
      // using MITK_TEST_CONDITION_REQUIRED makes the test stop after failure, since
      // it makes no sense to continue without an object.

      // write your own tests here and use the macros from mitkTestingMacros.h !!!
      // do not write to std::cout and do not return from this function yourself!

      // always end with this!
MITK_TEST_END    ()  
}
int mitkMessageTest ( int  ,
char *  [] 
)

Definition at line 332 of file mitkMessageTest.cpp.

References mitk::mitkMessageTestTestClass::MessageReceiverClass::Age(), mitk::mitkMessageTestTestClass::MessageReceiverClass::Amnesia(), mitk::mitkMessageTestTestClass::MessageSenderClass::DoGivePackage(), mitk::mitkMessageTestTestClass::MessageSenderClass::DoSay(), mitk::mitkMessageTestTestClass::MessageSenderClass::DoShoutAgeAndFootSize(), mitk::mitkMessageTestTestClass::MessageSenderClass::DoShowFinger(), mitk::mitkMessageTestTestClass::MessageSenderClass::DoWalk(), mitk::mitkMessageTestTestClass::MessageSenderClass::DoWaveHand(), mitk::mitkMessageTestTestClass::MessageReceiverClass::FootSize(), mitk::mitkMessageTestTestClass::MessageReceiverClass::HandWaved(), mitk::mitkMessageTestTestClass::Observer::m_Error, mitk::mitkMessageTestTestClass::Observer::m_Law, mitk::mitkMessageTestTestClass::Observer::m_MachineStarted, mitk::mitkMessageTestTestClass::Observer::m_MachineStopped, mitk::mitkMessageTestTestClass::MessageReceiverClass::MetersWalked(), MITK_TEST_BEGIN, MITK_TEST_CONDITION, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, mitk::mitkMessageTestTestClass::MessageReceiverClass::PackageReceived(), mitk::mitkMessageTestTestClass::MessageReceiverClass::RegisterObservers(), mitk::mitkMessageTestTestClass::NewtonMachine::StartAnalysis(), mitk::mitkMessageTestTestClass::NewtonMachine::StopAnalysis(), and mitk::mitkMessageTestTestClass::MessageReceiverClass::WordsSaid().

{
  MITK_TEST_BEGIN("Message")

  mitk::mitkMessageTestTestClass::MessageSenderClass sender;
  mitk::mitkMessageTestTestClass::MessageReceiverClass receiver;

  MITK_TEST_CONDITION_REQUIRED(true, "Testing instantiation");

  receiver.RegisterObservers(sender);

  MITK_TEST_CONDITION_REQUIRED(true, "Testing registration to messages");

  MITK_TEST_CONDITION_REQUIRED(
      (sender.DoWaveHand(),  // This is called "comma operator". Don't ask, read!
       receiver.HandWaved()),
      "Message without parameters");
  receiver.Amnesia();

  MITK_TEST_CONDITION_REQUIRED(
      (sender.DoShowFinger(),
       receiver.HandWaved()),
      "Message without parameters");
  receiver.Amnesia();

  MITK_TEST_CONDITION_REQUIRED(
      (sender.DoSay("Blooodworsch"),
       receiver.WordsSaid() == "Blooodworsch"),
      "Message with std::string parameter");
  receiver.Amnesia();

  MITK_TEST_CONDITION_REQUIRED(
      (sender.DoWalk(2.67),
       (receiver.MetersWalked() - 2.67) < 0.0001 ),
      "Message with double parameter");
  receiver.Amnesia();

  mitk::mitkMessageTestTestClass::Package package(8);
  MITK_TEST_CONDITION_REQUIRED(
      (sender.DoGivePackage(package),
       receiver.PackageReceived() == package),
      "Message with class parameter");
  receiver.Amnesia();

  MITK_TEST_CONDITION_REQUIRED(
      (sender.DoShoutAgeAndFootSize(46, 30.5),
       (receiver.Age() == 46 && (receiver.FootSize() - 30.5 < 0.0001))),
      "Message with int AND float parameter");
  receiver.Amnesia();


  mitk::mitkMessageTestTestClass::NewtonMachine newtonMachine;
  mitk::mitkMessageTestTestClass::Observer observer1(&newtonMachine);
  mitk::mitkMessageTestTestClass::Observer observer2(&newtonMachine);

  // This will send two events to registered observers
  newtonMachine.StartAnalysis();
  MITK_TEST_CONDITION(observer1.m_MachineStarted == true, "Message from Message Macro send to receiver 1");
  MITK_TEST_CONDITION(observer2.m_MachineStarted == true, "Message from Message Macro send to receiver 2");
  
  MITK_TEST_CONDITION(observer1.m_Law.GetDescription() == std::string("Unit tests are mandatory!"), 
    "Message1 from Message Macro send to receiver 1");
  MITK_TEST_CONDITION(observer2.m_Law.GetDescription() == std::string("Unit tests are mandatory!"), 
    "Message1 from Message Macro send to receiver 2");

  
  // This will send one event to registered observers
  newtonMachine.StopAnalysis();
  MITK_TEST_CONDITION(observer1.m_MachineStopped == true, "Message1 from Message Macro send to receiver 1");
  MITK_TEST_CONDITION(observer1.m_Error == true, "Message1 parameter from Message Macro send to receiver 1");

  MITK_TEST_CONDITION(observer2.m_MachineStopped == true, "Message1 from Message Macro send to receiver 2");
  MITK_TEST_CONDITION(observer2.m_Error == true, "Message1 parameter from Message Macro send to receiver 2");

  /* Message with return type tests are work in progess... */
  //bool patentSuccessful = newtonMachine.PatentLaw();   // what with return types from multiple observers?

  //MITK_TEST_CONDITION((observer1.m_PatentReviewed == true) && (patentSuccessful == false), 
  //  "Message with return type from Message Macro send to receiver 1");
  //
  //MITK_TEST_CONDITION((observer2.m_PatentReviewed == true) && (patentSuccessful == false), 
  //  "Message with return type from Message Macro send to receiver 2");
  
  MITK_TEST_END();
}
int mitkPicFileReaderTest ( int  ,
char *  [] 
)

Definition at line 27 of file mitkPicFileReaderTest.cpp.

References QuadProgPP::abs(), QuadProgPP::dist(), EXIT_FAILURE, EXIT_SUCCESS, mitk::Geometry3D::GetExtent(), mitk::SlicedGeometry3D::GetGeometry2D(), mitk::TimeSlicedGeometry::GetGeometry3D(), mitk::Geometry3D::GetIndexToWorldTransform(), mitk::PicHelper::GetSpacing(), mitk::Geometry3D::GetSpacing(), mitk::Geometry3D::GetTimeBounds(), mitk::TimeSlicedGeometry::GetTimeSteps(), QuadProgPP::max(), mitkIpPicDescriptor, and mitk::PicFileReader::New().

{
  //independently read header of pic file
  mitkIpPicDescriptor *picheader=NULL;
  if(argc>=1)
  {
    if(itksys::SystemTools::LowerCase(itksys::SystemTools::GetFilenameExtension(argv[1])).find(".pic")!=std::string::npos)
      picheader = mitkIpPicGetHeader(argv[1], NULL);
  }
  if(picheader==NULL)
  {
    std::cout<<"file not found/not a pic-file - test not applied [PASSED]"<<std::endl;
    std::cout<<"[TEST DONE]"<<std::endl;
    return EXIT_SUCCESS;
  }
  mitkIpPicGetTags(argv[1], picheader);

  //Read pic-Image from file
  mitk::PicFileReader::Pointer reader = mitk::PicFileReader::New();
    reader->SetFileName(argv[1]);
    reader->Update();

  std::cout << "Testing IsInitialized(): ";
  if(reader->GetOutput()->IsInitialized()==false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing IsSliceSet(): ";
  if(reader->GetOutput()->IsSliceSet(0)==false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing availability of geometry: ";
  if(reader->GetOutput()->GetGeometry()==NULL)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing type of geometry (TimeSlicedGeometry expected): ";
  mitk::TimeSlicedGeometry* timegeometry;
  timegeometry = reader->GetOutput()->GetTimeSlicedGeometry();
  if(timegeometry==NULL)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing availability of first geometry contained in the TimeSlicedGeometry: ";
  if(timegeometry->GetGeometry3D(0)==NULL)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing type of first geometry contained in the TimeSlicedGeometry (SlicedGeometry3D expected): ";
  mitk::SlicedGeometry3D* slicedgeometry;
  slicedgeometry = dynamic_cast<mitk::SlicedGeometry3D*>(timegeometry->GetGeometry3D(0));
  if(slicedgeometry==NULL)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing availability of first geometry contained in the SlicedGeometry3D: ";
  mitk::Geometry2D* geometry2d = slicedgeometry->GetGeometry2D(0);
  if(geometry2d==NULL)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing extent in units of first geometry contained in the SlicedGeometry3D: ";
  if((fabs(geometry2d->GetExtent(0)-picheader->n[0])>mitk::eps) || (fabs(geometry2d->GetExtent(1)-picheader->n[1])>mitk::eps))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing extent in units of image of SlicedGeometry3D: ";
  if((fabs(slicedgeometry->GetExtent(0)-picheader->n[0])>mitk::eps) || (fabs(slicedgeometry->GetExtent(1)-picheader->n[1])>mitk::eps)
    || (picheader->dim>2 && (fabs(slicedgeometry->GetExtent(2)-picheader->n[2])>mitk::eps))
    )
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing extent in units of image of TimeSlicedGeometry: ";
  if((fabs(timegeometry->GetExtent(0)-picheader->n[0])>mitk::eps) || (fabs(timegeometry->GetExtent(1)-picheader->n[1])>mitk::eps)
    || (picheader->dim>2 && (fabs(timegeometry->GetExtent(2)-picheader->n[2])>mitk::eps))
    || (picheader->dim>3 && (abs((mitkIpInt4_t) timegeometry->GetTimeSteps()- (mitkIpInt4_t) picheader->n[3])>0))
    )
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing consistency of spacing from matrix and stored spacing in the first SlicedGeometry3D: ";
  mitk::Vector3D spacing;
  spacing[0] = slicedgeometry->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(0).two_norm();
  spacing[1] = slicedgeometry->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(1).two_norm();
  spacing[2] = slicedgeometry->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(2).two_norm();
  mitk::Vector3D readspacing=slicedgeometry->GetSpacing();
  mitk::Vector3D dist = spacing-readspacing;
  if(dist.GetSquaredNorm()>mitk::eps)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  //independently read the overall spacing 
  spacing.Fill(1);
  mitk::PicHelper::GetSpacing(picheader, spacing);

  std::cout << "Testing correct reading of overall spacing stored in the first SlicedGeometry3D: ";
  dist = spacing-readspacing;
  if(dist.GetSquaredNorm()>mitk::eps)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  if(picheader->dim==4)
  {
    std::cout << "4D dataset: Testing that timebounds are not infinite: ";
    if((slicedgeometry->GetTimeBounds()[0] == mitk::ScalarTypeNumericTraits::NonpositiveMin()) && 
       (slicedgeometry->GetTimeBounds()[1] == mitk::ScalarTypeNumericTraits::max())
      )
    {
      std::cout<<"[FAILED]"<<std::endl;
      return EXIT_FAILURE;
    }
    std::cout<<"[PASSED]"<<std::endl;
  }

  mitkIpPicFree(picheader);

  std::cout<<"[TEST DONE]"<<std::endl;
  return EXIT_SUCCESS;
}
int mitkPicFileWriterTest ( int  argc,
char *  argv[] 
)

Simple example for a test for the (non-existent) class "PicFileWriter".

argc and argv are the command line parameters which were passed to the ADD_TEST command in the CMakeLists.txt file. For the automatic tests, argv is either empty for the simple tests or contains the filename of a test image for the image tests (see CMakeLists.txt).

Definition at line 30 of file mitkPicFileWriterTest.cpp.

References EXIT_FAILURE, EXIT_SUCCESS, MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, MITK_TEST_FOR_EXCEPTION_BEGIN, MITK_TEST_FOR_EXCEPTION_END, mitk::DataNodeFactory::New(), and mitk::PicFileWriter::New().

{
  // always start with this!
  MITK_TEST_BEGIN("PicFileWriter")

    // let's create an object of our class  
    mitk::PicFileWriter::Pointer myPicFileWriter = mitk::PicFileWriter::New();

  // first test: did this work?
  // using MITK_TEST_CONDITION_REQUIRED makes the test stop after failure, since
  // it makes no sense to continue without an object.
  MITK_TEST_CONDITION_REQUIRED(myPicFileWriter.IsNotNull(),"Testing instantiation") 

    // load image
    std::cout << "Loading file: " << std::flush;
  if(argc==0)
  {
    std::cout<<"no file specified [FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  mitk::Image::Pointer image = NULL;

  try{  
    // test for exception handling of NULL image
    std::cout << "Testing handling of NULL image " << std::flush;
    MITK_TEST_FOR_EXCEPTION_BEGIN(itk::ExceptionObject)

    myPicFileWriter->SetInput(image);
    myPicFileWriter->SetFileName("/usr/bin");
    myPicFileWriter->Update(); 
    MITK_TEST_FOR_EXCEPTION_END(itk::ExceptionObject)
  }
  catch(...) {
    std::cout << "Success: Writer warns on NULL image." << std::endl;
  }

  mitk::DataNodeFactory::Pointer factory = mitk::DataNodeFactory::New();
  try
  {
    std::cout<<argv[1]<<std::endl;
    factory->SetFileName( argv[1] );
    factory->Update();

    if(factory->GetNumberOfOutputs()<1)
    {
      std::cout<<"file could not be loaded [FAILED]"<<std::endl;
      return EXIT_FAILURE;
    }
    mitk::DataNode::Pointer node = factory->GetOutput( 0 );
    image = dynamic_cast<mitk::Image*>(node->GetData());
    if(image.IsNull())
    {
      std::cout<<"file "<< argv[1]<< "is not an image - test will not be applied [PASSED]"<<std::endl;
      std::cout<<"[TEST DONE]"<<std::endl;
      return EXIT_SUCCESS;
    }
  }
  catch ( itk::ExceptionObject & ex )
  {
    std::cout << "Exception: " << ex << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }

  MITK_TEST_CONDITION_REQUIRED(image.IsNotNull(),"loaded image not NULL")

  try{  
    // test for exception handling
    MITK_TEST_FOR_EXCEPTION_BEGIN(itk::ExceptionObject)

    myPicFileWriter->SetInput(image);
    myPicFileWriter->SetFileName("/usr/bin");
    myPicFileWriter->Update(); 
    MITK_TEST_FOR_EXCEPTION_END(itk::ExceptionObject)
  }
  catch(...) {
    //this means that a wrong exception (i.e. no itk:Exception) has been thrown 
    std::cout << "Wrong exception (i.e. no itk:Exception) caught during write [FAILED]" << std::endl;
    return EXIT_FAILURE;
  }

  // always end with this!
  MITK_TEST_END()
}
int mitkPixelTypeTest ( int  ,
char *  [] 
)

Definition at line 25 of file mitkPixelTypeTest.cpp.

References mitk::PixelType::GetBitsPerComponent(), mitk::PixelType::GetBpe(), mitk::PixelType::GetItkTypeAsString(), mitk::PixelType::GetItkTypeId(), mitk::PixelType::GetNumberOfComponents(), mitk::PixelType::GetTypeId(), int(), MITK_INFO, MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, and MITK_TEST_END.

{
  MITK_TEST_BEGIN("PixelTypeTest");

  mitk::PixelType ptype( typeid(int) ,5);
  MITK_TEST_CONDITION_REQUIRED( *ptype.GetTypeId() == typeid(int), "GetTypeId()");
  //MITK_TEST_CONDITION_REQUIRED( ptype == typeid(int), "operator ==");
  MITK_TEST_CONDITION_REQUIRED( ptype.GetItkTypeId() == NULL, "GetItkTypeId(");
  MITK_INFO << sizeof(int);
  MITK_TEST_CONDITION_REQUIRED( ptype.GetBpe() == 8*sizeof(int)*5, "GetBpe()");
  MITK_TEST_CONDITION_REQUIRED( ptype.GetNumberOfComponents() == 5, "GetNumberOfComponents()");
  MITK_TEST_CONDITION_REQUIRED( ptype.GetBitsPerComponent() == 8*sizeof(int), "GetBitsPerComponent()");

  MITK_TEST_CONDITION_REQUIRED( ptype.GetItkTypeAsString().compare("unknown") == 0, "GetItkTypeAsString()");
  {

    {
      mitk::PixelType ptype2( ptype); 
      MITK_TEST_CONDITION_REQUIRED( *ptype.GetTypeId() == typeid(int), "ptype2( ptype)- GetTypeId()");
      MITK_TEST_CONDITION_REQUIRED( ptype.GetItkTypeId() == NULL, "ptype2( ptype)-GetItkTypeId(");
      MITK_TEST_CONDITION_REQUIRED( ptype.GetBpe() == 8*sizeof(int)*5, "ptype2( ptype)-GetBpe()");
      MITK_TEST_CONDITION_REQUIRED( ptype.GetNumberOfComponents() == 5, "ptype2( ptype)-GetNumberOfComponents()");
      MITK_TEST_CONDITION_REQUIRED( ptype.GetBitsPerComponent() == 8*sizeof(int), "ptype2( ptype)-GetBitsPerComponent()");
      MITK_TEST_CONDITION_REQUIRED( ptype.GetItkTypeAsString().compare("unknown") == 0, "ptype2( ptype)-GetItkTypeAsString()");
    }

    {
      mitk::PixelType ptype2 = ptype; 
      MITK_TEST_CONDITION_REQUIRED( *ptype.GetTypeId() == typeid(int), "ptype2 = ptype- GetTypeId()");
      MITK_TEST_CONDITION_REQUIRED( ptype.GetItkTypeId() == NULL, "ptype2 = ptype- GetItkTypeId(");
      MITK_TEST_CONDITION_REQUIRED( ptype.GetBpe() == 8*sizeof(int)*5, "ptype2 = ptype- GetBpe()");
      MITK_TEST_CONDITION_REQUIRED( ptype.GetNumberOfComponents() == 5, "ptype2 = ptype- GetNumberOfComponents()");
      MITK_TEST_CONDITION_REQUIRED( ptype.GetBitsPerComponent() == 8*sizeof(int), "ptype2 = ptype- GetBitsPerComponent()");
      MITK_TEST_CONDITION_REQUIRED( ptype.GetItkTypeAsString().compare("unknown") == 0, "ptype2 = ptype- GetItkTypeAsString()");
    }

    {
      mitk::PixelType ptype2 = ptype; 
      MITK_TEST_CONDITION_REQUIRED( ptype == ptype2, "operator ==");
      //MITK_TEST_CONDITION_REQUIRED( ptype == typeid(int), "operator ==");
      mitk::PixelType ptype3(typeid(char) ,5); 
      MITK_TEST_CONDITION_REQUIRED( ptype != ptype3, "operator !=");
      //MITK_TEST_CONDITION_REQUIRED( *ptype3 != typeid(int), "operator !="); 
    }  
  }

  MITK_TEST_END();
}
int mitkPlaneGeometryTest ( int  ,
char *  [] 
)

Definition at line 210 of file mitkPlaneGeometryTest.cpp.

References EXIT_FAILURE, EXIT_SUCCESS, mitk::PlaneGeometry::Frontal, mappingTests2D(), matrix(), MITK_TEST_CONDITION_REQUIRED, MITK_TEST_OUTPUT, mitk::PlaneGeometry::New(), mitk::OpROTATE, mitk::PlaneGeometry::Sagittal, TestProjectPointOntoPlane(), and mitk::PlaneGeometry::Transversal.

{
  int result;

  /*
  // the following can be used to reproduce a bug in ITK matrix inversion
  // which was found while investigating bug #1210.
  result = TestCase1210();
  if(result!=EXIT_SUCCESS)
    return result;
  */

  mitk::PlaneGeometry::Pointer planegeometry = mitk::PlaneGeometry::New();
 
  mitk::Point3D origin;
  mitk::Vector3D right, bottom, normal;
  mitk::ScalarType width, height;
  mitk::ScalarType widthInMM, heightInMM, thicknessInMM;

  width  = 100;    widthInMM  = width;
  height = 200;    heightInMM = height;
  thicknessInMM = 1.0;
  mitk::FillVector3D(origin, 4.5,              7.3, 11.2);
  mitk::FillVector3D(right,  widthInMM,          0, 0);
  mitk::FillVector3D(bottom,         0, heightInMM, 0);
  mitk::FillVector3D(normal,         0,          0, thicknessInMM);

  std::cout << "Testing InitializeStandardPlane(rightVector, downVector, spacing = NULL): "<<std::endl;
  planegeometry->InitializeStandardPlane(right.Get_vnl_vector(), bottom.Get_vnl_vector());

  std::cout << "Testing width, height and thickness (in units): ";
  if((mitk::Equal(planegeometry->GetExtent(0),width)==false) || 
     (mitk::Equal(planegeometry->GetExtent(1),height)==false) || 
     (mitk::Equal(planegeometry->GetExtent(2),1)==false)
    )
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing width, height and thickness (in mm): ";
  if((mitk::Equal(planegeometry->GetExtentInMM(0),widthInMM)==false) || 
     (mitk::Equal(planegeometry->GetExtentInMM(1),heightInMM)==false) || 
     (mitk::Equal(planegeometry->GetExtentInMM(2),thicknessInMM)==false)
    )
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing GetAxisVector(): ";
  if((mitk::Equal(planegeometry->GetAxisVector(0), right)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), bottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), normal)==false))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;



  std::cout << "Testing InitializeStandardPlane(rightVector, downVector, spacing = {1.0, 1.0, 1.5}): "<<std::endl;
  mitk::Vector3D spacing;
  thicknessInMM = 1.5;
  normal.Normalize(); normal *= thicknessInMM;
  mitk::FillVector3D(spacing, 1.0, 1.0, thicknessInMM);
  planegeometry->InitializeStandardPlane(right.Get_vnl_vector(), bottom.Get_vnl_vector(), &spacing);

  std::cout << "Testing width, height and thickness (in units): ";
  if((mitk::Equal(planegeometry->GetExtent(0),width)==false) || 
     (mitk::Equal(planegeometry->GetExtent(1),height)==false) || 
     (mitk::Equal(planegeometry->GetExtent(2),1)==false)
    )
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing width, height and thickness (in mm): ";
  if((mitk::Equal(planegeometry->GetExtentInMM(0),widthInMM)==false) || 
     (mitk::Equal(planegeometry->GetExtentInMM(1),heightInMM)==false) || 
     (mitk::Equal(planegeometry->GetExtentInMM(2),thicknessInMM)==false)
    )
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing GetAxisVector(): ";
  if((mitk::Equal(planegeometry->GetAxisVector(0), right)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), bottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), normal)==false))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;



  std::cout << "Testing SetExtentInMM(2, ...), querying by GetExtentInMM(2): ";
  thicknessInMM = 3.5;
  normal.Normalize(); normal *= thicknessInMM;
  planegeometry->SetExtentInMM(2, thicknessInMM);
  if(mitk::Equal(planegeometry->GetExtentInMM(2),thicknessInMM)==false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing SetExtentInMM(2, ...), querying by GetAxisVector(2) and comparing to normal: ";
  if(mitk::Equal(planegeometry->GetAxisVector(2), normal)==false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing SetOrigin: ";
  planegeometry->SetOrigin(origin);
  if(mitk::Equal(planegeometry->GetOrigin(), origin)==false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing GetAxisVector() after SetOrigin: ";
  if((mitk::Equal(planegeometry->GetAxisVector(0), right)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), bottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), normal)==false))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  result = mappingTests2D(planegeometry, width, height, widthInMM, heightInMM, origin, right, bottom);
  if(result!=EXIT_SUCCESS)
    return result;



  std::cout << "Changing the IndexToWorldTransform to a rotated version by SetIndexToWorldTransform() (keep origin): "<<std::endl;
  mitk::AffineTransform3D::Pointer transform = mitk::AffineTransform3D::New();
  mitk::AffineTransform3D::MatrixType::InternalMatrixType vnlmatrix;
  vnlmatrix = planegeometry->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix();
  mitk::VnlVector axis(3);
  mitk::FillVector3D(axis, 1.0, 1.0, 1.0); axis.normalize();
  vnl_quaternion<mitk::ScalarType> rotation(axis, 0.223);
  vnlmatrix = rotation.rotation_matrix_transpose()*vnlmatrix;
  mitk::Matrix3D matrix;
  matrix = vnlmatrix;
  transform->SetMatrix(matrix);
  transform->SetOffset(planegeometry->GetIndexToWorldTransform()->GetOffset());
  
  right.Set_vnl_vector( rotation.rotation_matrix_transpose()*right.Get_vnl_vector() );
  bottom.Set_vnl_vector(rotation.rotation_matrix_transpose()*bottom.Get_vnl_vector());
  normal.Set_vnl_vector(rotation.rotation_matrix_transpose()*normal.Get_vnl_vector());
  planegeometry->SetIndexToWorldTransform(transform);

  //The origin changed,because m_Origin=m_IndexToWorldTransform->GetOffset()+GetAxisVector(2)*0.5
  //and the AxisVector changes due to the rotation. In other words: the rotation was done around 
  //the corner of the box, not around the planes origin. Now change it to a rotation around
  //the origin, simply by re-setting the origin to the original one:
  planegeometry->SetOrigin(origin);
  mitk::Point3D cornerpoint0 = planegeometry->GetCornerPoint(0);

  std::cout << "Testing whether SetIndexToWorldTransform kept origin: ";
  if(mitk::Equal(planegeometry->GetOrigin(), origin)==false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }

  MITK_TEST_OUTPUT( << "Testing consistancy of index and world coordinates. ");
  mitk::Point2D point; point[0] = 4; point[1] = 3;
  mitk::Point2D dummy;
  planegeometry->WorldToIndex(point, dummy);
  planegeometry->IndexToWorld(dummy, dummy);
  MITK_TEST_CONDITION_REQUIRED(dummy == point, "");

  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing width, height and thickness (in mm) of rotated version: ";
  if((mitk::Equal(planegeometry->GetExtentInMM(0),widthInMM)==false) || 
     (mitk::Equal(planegeometry->GetExtentInMM(1),heightInMM)==false) || 
     (mitk::Equal(planegeometry->GetExtentInMM(2),thicknessInMM)==false)
    )
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing GetAxisVector() of rotated version: ";
  if((mitk::Equal(planegeometry->GetAxisVector(0), right)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), bottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), normal)==false))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing GetAxisVector(direction).GetNorm() != planegeometry->GetExtentInMM(direction) of rotated version: ";
  if((mitk::Equal(planegeometry->GetAxisVector(0).GetNorm(),planegeometry->GetExtentInMM(0))==false) || 
     (mitk::Equal(planegeometry->GetAxisVector(1).GetNorm(),planegeometry->GetExtentInMM(1))==false) || 
     (mitk::Equal(planegeometry->GetAxisVector(2).GetNorm(),planegeometry->GetExtentInMM(2))==false)
    )
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  result = mappingTests2D(planegeometry, width, height, widthInMM, heightInMM, origin, right, bottom);
  if(result!=EXIT_SUCCESS)
    return result;

  std::cout << "Testing SetSizeInUnits() of rotated version: "<<std::endl;
  width  *= 2;
  height *= 3;
  planegeometry->SetSizeInUnits(width, height);

  std::cout << "Testing width, height and thickness (in units): ";
  if((mitk::Equal(planegeometry->GetExtent(0),width)==false) || 
     (mitk::Equal(planegeometry->GetExtent(1),height)==false) || 
     (mitk::Equal(planegeometry->GetExtent(2),1)==false)
    )
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing width, height and thickness (in mm) of version with changed size in units: ";
  if(!mitk::Equal(planegeometry->GetExtentInMM(0), widthInMM) || !mitk::Equal(planegeometry->GetExtentInMM(1), heightInMM) || !mitk::Equal(planegeometry->GetExtentInMM(2), thicknessInMM))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing GetAxisVector() of version with changed size in units: ";
  if((mitk::Equal(planegeometry->GetAxisVector(0), right)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), bottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), normal)==false))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing GetAxisVector(direction).GetNorm() != planegeometry->GetExtentInMM(direction) of rotated version: ";
  if((mitk::Equal(planegeometry->GetAxisVector(0).GetNorm(),planegeometry->GetExtentInMM(0))==false) || 
     (mitk::Equal(planegeometry->GetAxisVector(1).GetNorm(),planegeometry->GetExtentInMM(1))==false) || 
     (mitk::Equal(planegeometry->GetAxisVector(2).GetNorm(),planegeometry->GetExtentInMM(2))==false)
    )
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  result = mappingTests2D(planegeometry, width, height, widthInMM, heightInMM, origin, right, bottom);
  if(result!=EXIT_SUCCESS)
    return result;



  std::cout << "Testing Clone(): ";
  mitk::PlaneGeometry::Pointer clonedplanegeometry = dynamic_cast<mitk::PlaneGeometry*>(planegeometry->Clone().GetPointer());
  if((clonedplanegeometry.IsNull()) || (clonedplanegeometry->GetReferenceCount()!=1))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing origin of cloned version: ";
  if(mitk::Equal(clonedplanegeometry->GetOrigin(), origin)==false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;
  
  std::cout << "Testing width, height and thickness (in units) of cloned version: ";
  if((mitk::Equal(clonedplanegeometry->GetExtent(0),width)==false) || 
     (mitk::Equal(clonedplanegeometry->GetExtent(1),height)==false) || 
     (mitk::Equal(clonedplanegeometry->GetExtent(2),1)==false)
    )
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing width, height and thickness (in mm) of cloned version: ";
  if(!mitk::Equal(clonedplanegeometry->GetExtentInMM(0), widthInMM) || !mitk::Equal(clonedplanegeometry->GetExtentInMM(1), heightInMM) || !mitk::Equal(clonedplanegeometry->GetExtentInMM(2), thicknessInMM))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing GetAxisVector() of cloned version: ";
  if((mitk::Equal(clonedplanegeometry->GetAxisVector(0), right)==false) || (mitk::Equal(clonedplanegeometry->GetAxisVector(1), bottom)==false) || (mitk::Equal(clonedplanegeometry->GetAxisVector(2), normal)==false))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  result = mappingTests2D(clonedplanegeometry, width, height, widthInMM, heightInMM, origin, right, bottom);
  if(result!=EXIT_SUCCESS)
    return result;
    
  
  // Clone, move, rotate and test for 'IsParallel' and 'IsOnPlane'
  std::cout << "Testing Clone(): ";
  mitk::PlaneGeometry::Pointer clonedplanegeometry2 = dynamic_cast<mitk::PlaneGeometry*>(planegeometry->Clone().GetPointer());
  if((clonedplanegeometry2.IsNull()) || (clonedplanegeometry2->GetReferenceCount()!=1))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout << "Testing if cloned and original version are at the same place: ";
  if(mitk::Equal(clonedplanegeometry2->IsOnPlane(planegeometry), true) ==false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;
  
  std::cout << "Testing if the origin is on the plane: ";
  if(mitk::Equal(clonedplanegeometry2->IsOnPlane(origin), true)==false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;
  
  mitk::VnlVector newaxis(3);
  mitk::FillVector3D(newaxis, 1.0, 1.0, 1.0); newaxis.normalize();
  vnl_quaternion<mitk::ScalarType> rotation2(newaxis, 0.0);
  
  mitk::Vector3D clonednormal = clonedplanegeometry2->GetNormal();
  mitk::Point3D clonedorigin = clonedplanegeometry2->GetOrigin();
  
  mitk::RotationOperation* planerot = new mitk::RotationOperation( mitk::OpROTATE, origin, clonedplanegeometry2->GetAxisVector( 0 ), 180.0 );
  
  clonedplanegeometry2->ExecuteOperation( planerot ); 
  
  std::cout << "Testing whether the flipped plane is still the original plane: ";
  if( mitk::Equal( clonedplanegeometry2->IsOnPlane(planegeometry), true )==false )
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;
  
  clonedorigin += clonednormal;
  clonedplanegeometry2->SetOrigin( clonedorigin );
 
  std::cout << "Testing if the translated (cloned, flipped) plane is parallel to its origin plane: ";
  if( mitk::Equal( clonedplanegeometry2->IsParallel(planegeometry), true )==false )
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;
  

  delete planerot;
  
  planerot = new mitk::RotationOperation( mitk::OpROTATE, origin, clonedplanegeometry2->GetAxisVector( 0 ), 0.5 );
  clonedplanegeometry2->ExecuteOperation( planerot ); 
  
  std::cout << "Testing if a non-paralell plane gets recognized as not paralell  [rotation +0.5 degree] : ";
  if( mitk::Equal( clonedplanegeometry2->IsParallel(planegeometry), false )==false )
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;
  
  delete planerot;
  
  planerot = new mitk::RotationOperation( mitk::OpROTATE, origin, clonedplanegeometry2->GetAxisVector( 0 ), -1.0 );
  clonedplanegeometry2->ExecuteOperation( planerot ); 
  
  std::cout << "Testing if a non-paralell plane gets recognized as not paralell  [rotation -0.5 degree] : ";
  if( mitk::Equal( clonedplanegeometry2->IsParallel(planegeometry), false )==false )
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  delete planerot;

  planerot = new mitk::RotationOperation( mitk::OpROTATE, origin, clonedplanegeometry2->GetAxisVector( 0 ), 360.5 );
  clonedplanegeometry2->ExecuteOperation( planerot ); 
  
  std::cout << "Testing if a non-paralell plane gets recognized as not paralell  [rotation 360 degree] : ";
  if( mitk::Equal( clonedplanegeometry2->IsParallel(planegeometry), true )==false )
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;


  std::cout << "Testing InitializeStandardPlane(clonedplanegeometry, planeorientation = Transversal, zPosition = 0, frontside=true): " <<std::endl;
  planegeometry->InitializeStandardPlane(clonedplanegeometry);

  std::cout << "Testing origin of transversally initialized version: ";
  if(mitk::Equal(planegeometry->GetOrigin(), origin)==false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing GetCornerPoint(0) of transversally initialized version: ";
  if(mitk::Equal(planegeometry->GetCornerPoint(0), cornerpoint0)==false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing width, height and thickness (in units) of transversally initialized version (should be same as in mm due to unit spacing, except for thickness, which is always 1): ";
  if(!mitk::Equal(planegeometry->GetExtent(0), width) || !mitk::Equal(planegeometry->GetExtent(1), height) || !mitk::Equal(planegeometry->GetExtent(2), 1))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing width, height and thickness (in mm) of transversally initialized version: ";
  if(!mitk::Equal(planegeometry->GetExtentInMM(0), widthInMM) || !mitk::Equal(planegeometry->GetExtentInMM(1), heightInMM) || !mitk::Equal(planegeometry->GetExtentInMM(2), thicknessInMM))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing GetAxisVector() of transversally initialized version: ";
  if((mitk::Equal(planegeometry->GetAxisVector(0), right)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), bottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), normal)==false))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  result = mappingTests2D(planegeometry, width, height, widthInMM, heightInMM, origin, right, bottom);
  if(result!=EXIT_SUCCESS)
    return result;



  mitk::Vector3D newright, newbottom, newnormal;
  mitk::ScalarType newthicknessInMM;
  std::cout << "Testing InitializeStandardPlane(clonedplanegeometry, planeorientation = Frontal, zPosition = 0, frontside=true): " <<std::endl;
  planegeometry->InitializeStandardPlane(clonedplanegeometry, mitk::PlaneGeometry::Frontal);
  newright = right; 
  newbottom = normal; newbottom.Normalize();  newbottom *= thicknessInMM;
  newthicknessInMM = heightInMM/height*1.0/*extent in normal direction is 1*/;
  newnormal = -bottom; newnormal.Normalize(); newnormal *= newthicknessInMM;

  std::cout << "Testing GetCornerPoint(0) of frontally initialized version: ";
  if(mitk::Equal(planegeometry->GetCornerPoint(0), cornerpoint0)==false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;
  //ok, corner was fine, so we can dare to believe the origin is ok.
  origin = planegeometry->GetOrigin();

  std::cout << "Testing width, height and thickness (in units) of frontally initialized version: ";
  if(!mitk::Equal(planegeometry->GetExtent(0), width) || !mitk::Equal(planegeometry->GetExtent(1), 1) || !mitk::Equal(planegeometry->GetExtent(2), 1))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing width, height and thickness (in mm) of frontally initialized version: ";
  if(!mitk::Equal(planegeometry->GetExtentInMM(0), widthInMM) || !mitk::Equal(planegeometry->GetExtentInMM(1), thicknessInMM) || !mitk::Equal(planegeometry->GetExtentInMM(2), newthicknessInMM))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing GetAxisVector() of frontally initialized version: ";
  if((mitk::Equal(planegeometry->GetAxisVector(0), newright)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), newbottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), newnormal)==false))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  result = mappingTests2D(planegeometry, width, 1, widthInMM, thicknessInMM, origin, newright, newbottom);
  if(result!=EXIT_SUCCESS)
    return result;



  std::cout << "Changing plane to in-plane unit spacing using SetSizeInUnits: " <<std::endl;
  planegeometry->SetSizeInUnits(planegeometry->GetExtentInMM(0), planegeometry->GetExtentInMM(1));

  std::cout << "Testing origin of unit spaced, frontally initialized version: ";
  if(mitk::Equal(planegeometry->GetOrigin(), origin)==false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing width, height and thickness (in units) of unit spaced, frontally initialized version: ";
  if(!mitk::Equal(planegeometry->GetExtent(0), widthInMM) || !mitk::Equal(planegeometry->GetExtent(1), thicknessInMM) || !mitk::Equal(planegeometry->GetExtent(2), 1))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing width, height and thickness (in mm) of unit spaced, frontally initialized version: ";
  if(!mitk::Equal(planegeometry->GetExtentInMM(0), widthInMM) || !mitk::Equal(planegeometry->GetExtentInMM(1), thicknessInMM) || !mitk::Equal(planegeometry->GetExtentInMM(2), newthicknessInMM))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing GetAxisVector() of unit spaced, frontally initialized version: ";
  if((mitk::Equal(planegeometry->GetAxisVector(0), newright)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), newbottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), newnormal)==false))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  result = mappingTests2D(planegeometry, widthInMM, thicknessInMM, widthInMM, thicknessInMM, origin, newright, newbottom);
  if(result!=EXIT_SUCCESS)
    return result;



  std::cout << "Changing plane to unit spacing also in normal direction using SetExtentInMM(2, 1.0): " <<std::endl;
  planegeometry->SetExtentInMM(2, 1.0);
  newnormal.Normalize();

  std::cout << "Testing origin of unit spaced, frontally initialized version: ";
  if(mitk::Equal(planegeometry->GetOrigin(), origin)==false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing width, height and thickness (in units) of unit spaced, frontally initialized version: ";
  if(!mitk::Equal(planegeometry->GetExtent(0), widthInMM) || !mitk::Equal(planegeometry->GetExtent(1), thicknessInMM) || !mitk::Equal(planegeometry->GetExtent(2), 1))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing width, height and thickness (in mm) of unit spaced, frontally initialized version: ";
  if(!mitk::Equal(planegeometry->GetExtentInMM(0), widthInMM) || !mitk::Equal(planegeometry->GetExtentInMM(1), thicknessInMM) || !mitk::Equal(planegeometry->GetExtentInMM(2), 1.0))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing GetAxisVector() of unit spaced, frontally initialized version: ";
  if((mitk::Equal(planegeometry->GetAxisVector(0), newright)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), newbottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), newnormal)==false))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  result = mappingTests2D(planegeometry, widthInMM, thicknessInMM, widthInMM, thicknessInMM, origin, newright, newbottom);
  if(result!=EXIT_SUCCESS)
    return result;



  std::cout << "Testing InitializeStandardPlane(clonedplanegeometry, planeorientation = Sagittal, zPosition = 0, frontside=true): " <<std::endl;
  planegeometry->InitializeStandardPlane(clonedplanegeometry, mitk::PlaneGeometry::Sagittal);
  newright = bottom;
  newthicknessInMM = widthInMM/width*1.0/*extent in normal direction is 1*/;
  newnormal = right; newnormal.Normalize(); newnormal *= newthicknessInMM;

  std::cout << "Testing GetCornerPoint(0) of sagitally initialized version: ";
  if(mitk::Equal(planegeometry->GetCornerPoint(0), cornerpoint0)==false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;
  //ok, corner was fine, so we can dare to believe the origin is ok.
  origin = planegeometry->GetOrigin();

  std::cout << "Testing width, height and thickness (in units) of sagitally initialized version: ";
  if(!mitk::Equal(planegeometry->GetExtent(0), height) || !mitk::Equal(planegeometry->GetExtent(1), 1) || !mitk::Equal(planegeometry->GetExtent(2), 1))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing width, height and thickness (in mm) of sagitally initialized version: ";
  if(!mitk::Equal(planegeometry->GetExtentInMM(0), heightInMM) || !mitk::Equal(planegeometry->GetExtentInMM(1), thicknessInMM) || !mitk::Equal(planegeometry->GetExtentInMM(2), newthicknessInMM))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing GetAxisVector() of sagitally initialized version: ";
  if((mitk::Equal(planegeometry->GetAxisVector(0), newright)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), newbottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), newnormal)==false))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  result = mappingTests2D(planegeometry, height, 1, heightInMM, thicknessInMM, origin, newright, newbottom);
  if(result!=EXIT_SUCCESS)
    return result;



  //set origin back to the one of the transversal slice:
  origin = clonedplanegeometry->GetOrigin();
  std::cout << "Testing backside initialization: InitializeStandardPlane(clonedplanegeometry, planeorientation = Transversal, zPosition = 0, frontside=false, rotated=true): " <<std::endl;
  planegeometry->InitializeStandardPlane(clonedplanegeometry, mitk::PlaneGeometry::Transversal, 0, false, true);
  mitk::Point3D backsideorigin;
  backsideorigin=origin+clonedplanegeometry->GetAxisVector(1);//+clonedplanegeometry->GetAxisVector(2);

  std::cout << "Testing origin of backsidedly, transversally initialized version: ";
  if(mitk::Equal(planegeometry->GetOrigin(), backsideorigin)==false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing GetCornerPoint(0) of sagitally initialized version: ";
  mitk::Point3D backsidecornerpoint0;
  backsidecornerpoint0 = cornerpoint0+clonedplanegeometry->GetAxisVector(1);//+clonedplanegeometry->GetAxisVector(2);
  if(mitk::Equal(planegeometry->GetCornerPoint(0), backsidecornerpoint0)==false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing width, height and thickness (in units) of backsidedly, transversally initialized version (should be same as in mm due to unit spacing, except for thickness, which is always 1): ";
  if(!mitk::Equal(planegeometry->GetExtent(0), width) || !mitk::Equal(planegeometry->GetExtent(1), height) || !mitk::Equal(planegeometry->GetExtent(2), 1))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing width, height and thickness (in mm) of backsidedly, transversally initialized version: ";
  if(!mitk::Equal(planegeometry->GetExtentInMM(0), widthInMM) || !mitk::Equal(planegeometry->GetExtentInMM(1), heightInMM) || !mitk::Equal(planegeometry->GetExtentInMM(2), thicknessInMM))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing GetAxisVector() of backsidedly, transversally initialized version: ";
  if((mitk::Equal(planegeometry->GetAxisVector(0), right)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), -bottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), -normal)==false))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  result = mappingTests2D(planegeometry, width, height, widthInMM, heightInMM, backsideorigin, right, -bottom);
  if(result!=EXIT_SUCCESS)
    return result;


  // test method mitk::PlaneGeometry::ProjectPointOntoPlane()
  // (see also bug #3409)
  result = TestProjectPointOntoPlane();
  if(result!=EXIT_SUCCESS)
    return result;


  std::cout<<"[TEST DONE]"<<std::endl;
  return EXIT_SUCCESS;
}
int mitkPointSetFileIOTest ( int  ,
char *  [] 
)

Definition at line 145 of file mitkPointSetFileIOTest.cpp.

References MITK_TEST_BEGIN, MITK_TEST_CONDITION, MITK_TEST_END, mitkPointSetFileIOTestClass::PointSetLoadAndCompareTest(), and mitkPointSetFileIOTestClass::PointSetWrite().

{
  MITK_TEST_BEGIN("PointSet");
  unsigned int numberOfPointSets(5);

  mitkPointSetFileIOTestClass* test = new mitkPointSetFileIOTestClass();

  // write
  MITK_TEST_CONDITION(test->PointSetWrite(numberOfPointSets), "Testing if the PointSetWriter writes Data" );

  // load - compare
  test->PointSetLoadAndCompareTest(numberOfPointSets);
  
  //Delete correctly
  delete test;

  MITK_TEST_END();
}
int mitkPointSetInteractorTest ( int  ,
char *  [] 
)

Definition at line 507 of file mitkPointSetInteractorTest.cpp.

References mitk::GlobalInteraction::GetInstance(), MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, MITK_TEST_OUTPUT, mitk::VtkPropRenderer::New(), mitk::RenderingManager::New(), mitk::DataNode::New(), mitk::PointSet::New(), ONLYMOVEPOINTSETINTERACTORNAME, POINTSETINTERACTORNAME, SEEDPOINTSETINTERACTORNAME, and SINGLEPOINTWITHOUTSHIFTCLICKNAME.

{
  MITK_TEST_BEGIN("PointSetInteractor")

  // Global interaction must(!) be initialized if used
  mitk::GlobalInteraction::GetInstance()->Initialize("global");

  //create the corresponding data
  mitk::PointSet::Pointer pointSet = mitk::PointSet::New();
  mitk::DataNode::Pointer node = mitk::DataNode::New();

  //we need a baserenderer (VtkPropRenderer) to be able to let PointSetInteractor::CanHandleEvent() proccess
  //and for this we need a RenderWindow and a RenderingManager
  
  mitk::RenderingManager::Pointer myRenderingManager = mitk::RenderingManager::New();
  myRenderingManager->SetGlobalInteraction(mitk::GlobalInteraction::GetInstance());
  vtkRenderWindow* vtkRenWin = vtkRenderWindow::New();
  mitk::VtkPropRenderer::Pointer sender = mitk::VtkPropRenderer::New("testingBR", vtkRenWin, myRenderingManager);
  vtkRenWin->Delete();

  //hook everything up into a dataNode. (node doesn't here have to be in DataStorage)
  node->SetData(pointSet);

  //pointset should be empty  
  MITK_TEST_CONDITION_REQUIRED(pointSet->GetPointSet()->GetNumberOfPoints()==0,"Checking if pointset is empty.");

  //instance of testclass
  mitkPointSetInteractorTestClass* test = new mitkPointSetInteractorTestClass();
  
  //test setup regular pointsetinteractor
  MITK_TEST_OUTPUT(<<"--------Testing "<<POINTSETINTERACTORNAME<<" with max 3 points--------");
  test->TestPointSetInteractor(POINTSETINTERACTORNAME, node, sender, 3);
  
  pointSet = mitk::PointSet::New();
  node = mitk::DataNode::New();
  node->SetData(pointSet);

  //test setup with unlimited numbers of points supported
  MITK_TEST_OUTPUT(<<"--------Testing "<<POINTSETINTERACTORNAME<<" with unlimited points --------");
  test->TestPointSetInteractor(POINTSETINTERACTORNAME, node, sender, -1);

  pointSet = mitk::PointSet::New();
  node = mitk::DataNode::New();
  node->SetData(pointSet);

  //test setup only move pointsetinteractor
  MITK_TEST_OUTPUT(<<"--------Testing "<<ONLYMOVEPOINTSETINTERACTORNAME<<" with unlimited points --------");
  test->TestOnlyMovePointSetInteractor(ONLYMOVEPOINTSETINTERACTORNAME, node, sender, -1);

  pointSet = mitk::PointSet::New();
  node = mitk::DataNode::New();
  node->SetData(pointSet);

  MITK_TEST_OUTPUT(<<"--------Testing "<<SEEDPOINTSETINTERACTORNAME<<" with one point --------");
  test->TestSeedPointSetInteractor(SEEDPOINTSETINTERACTORNAME, node, sender);

  pointSet = mitk::PointSet::New();
  node = mitk::DataNode::New();
  node->SetData(pointSet);
  
  MITK_TEST_OUTPUT(<<"--------Testing "<<SINGLEPOINTWITHOUTSHIFTCLICKNAME<<" with one point --------");
  test->TestSinglePointSetInteractorWithoutShiftClick(SINGLEPOINTWITHOUTSHIFTCLICKNAME, node, sender);

  MITK_TEST_END()
}
int mitkPointSetLocaleTest ( int  ,
char *  [] 
)

Definition at line 124 of file mitkPointSetLocaleTest.cpp.

References ChangeLocale(), MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, mitk::PointSet::New(), ReaderLocaleTest(), and WriterLocaleTest().

{
  MITK_TEST_BEGIN("PointSetLocaleTest");

  //create reference point set
  mitk::PointSet::Pointer refPointSet = mitk::PointSet::New();
  mitk::Point3D refPoint;
  refPoint[0] = 32.2946;
  refPoint[1] = -17.7359;
  refPoint[2] = 29.6502;
  refPointSet->SetPoint(0, refPoint);

  //create locale list
  std::ofstream stream;
  std::locale previousLocale(stream.getloc());

  typedef std::list<std::string> StringList;
  StringList alllocales;
  alllocales.push_back("de_DE");
  alllocales.push_back("de_DE.utf8");
  alllocales.push_back("de_DE.UTF-8");
  alllocales.push_back("de_DE@euro");
  alllocales.push_back("German_Germany");

  // QuickFix for MAC OS X
  // See for more the Bug #3894 comments
#if defined (__APPLE__) || defined(MACOSX)
  alllocales.push_back("C");
#endif

  unsigned int numberOfTestedGermanLocales(0);
  for (StringList::iterator iter = alllocales.begin();
       iter != alllocales.end();
       ++iter)
  {
    if ( ChangeLocale(*iter) )
    {
      ++numberOfTestedGermanLocales;
     WriterLocaleTest(refPoint);
     ReaderLocaleTest(refPoint);
    }
  }
  MITK_TEST_CONDITION_REQUIRED( numberOfTestedGermanLocales > 0, "Verify that at least one German locale has been tested.");
  MITK_TEST_END();
}
int mitkPointSetTest ( int  ,
char *  [] 
)

Definition at line 526 of file mitkPointSetTest.cpp.

References MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, MITK_TEST_OUTPUT, mitk::PointSet::New(), mitk::OpINSERT, mitk::OpMOVE, mitk::OpREMOVE, mitkPointSetTestClass::TestAddSecondPoint(), mitkPointSetTestClass::TestCreateHoleInThePointIDs(), mitkPointSetTestClass::TestCreateOperationAndAddPoint(), mitkPointSetTestClass::TestGetITKPointSet(), mitkPointSetTestClass::TestGetNumberOfSelected(), mitkPointSetTestClass::TestGetPointIfExists(), mitkPointSetTestClass::TestGetSizeIsZero(), mitkPointSetTestClass::TestInsertPointWithPointSpecification(), mitkPointSetTestClass::TestIsEmpty(), mitkPointSetTestClass::TestIsNotEmpty(), mitkPointSetTestClass::TestOpDeselectPoint(), mitkPointSetTestClass::TestOpMovePointDown(), mitkPointSetTestClass::TestOpMovePointUp(), mitkPointSetTestClass::TestOpMovePointUpOnFirstPoint(), mitkPointSetTestClass::TestPointContainerPointDataContainer(), mitkPointSetTestClass::TestPointOperationOpMove(), mitkPointSetTestClass::TestPointOperationOpRemove(), mitkPointSetTestClass::TestPointOperationOpSelectPoint(), mitkPointSetTestClass::TestSearchSelectedPoint(), mitkPointSetTestClass::TestSetSelectInfo(), mitkPointSetTestClass::TestSwapPointPositionDownwards(), mitkPointSetTestClass::TestSwapPointPositionDownwardsNotPossible(), mitkPointSetTestClass::TestSwapPointPositionUpwards(), and mitkPointSetTestClass::TestSwapPointPositionUpwardsNotPossible().

{

  MITK_TEST_BEGIN("PointSet")

    //Create PointSet
    mitk::PointSet::Pointer pointSet = mitk::PointSet::New();

  MITK_TEST_CONDITION_REQUIRED(pointSet.IsNotNull(),"Testing instantiation") 

  mitkPointSetTestClass::TestGetITKPointSet(pointSet); 
  mitkPointSetTestClass::TestGetSizeIsZero(pointSet);
  mitkPointSetTestClass::TestIsEmpty(pointSet);
  mitkPointSetTestClass::TestCreateOperationAndAddPoint(pointSet);

  mitk::Point3D point2, point3, point4;
  point2.Fill(3);
  point3.Fill(4);
  point4.Fill(5);
  pointSet->InsertPoint(2,point2);
  pointSet->InsertPoint(3,point3);
  pointSet->InsertPoint(4,point4);

  mitkPointSetTestClass::TestAddSecondPoint(pointSet);
  mitkPointSetTestClass::TestIsNotEmpty(pointSet);
  mitkPointSetTestClass::TestSwapPointPositionUpwards(pointSet);
  mitkPointSetTestClass::TestSwapPointPositionUpwardsNotPossible(pointSet);
  mitkPointSetTestClass::TestSwapPointPositionDownwards(pointSet);
  mitkPointSetTestClass::TestSwapPointPositionDownwardsNotPossible(pointSet);
  mitkPointSetTestClass::TestPointOperationOpMove(pointSet);
  mitkPointSetTestClass::TestPointOperationOpRemove(pointSet);
  mitkPointSetTestClass::TestPointOperationOpSelectPoint(pointSet);
  mitkPointSetTestClass::TestGetNumberOfSelected(pointSet);
  mitkPointSetTestClass::TestSearchSelectedPoint(pointSet);
  mitkPointSetTestClass::TestOpDeselectPoint(pointSet);
  mitkPointSetTestClass::TestOpMovePointUp(pointSet);
  mitkPointSetTestClass::TestOpMovePointDown(pointSet);
  mitkPointSetTestClass::TestSetSelectInfo(pointSet);
  mitkPointSetTestClass::TestInsertPointWithPointSpecification(pointSet);
  mitkPointSetTestClass::TestGetPointIfExists(pointSet);
  mitkPointSetTestClass::TestCreateHoleInThePointIDs(pointSet);
  mitkPointSetTestClass::TestOpMovePointUpOnFirstPoint(pointSet);

  MITK_TEST_OUTPUT(<< "Test InsertPoint(), SetPoint() and SwapPointPosition()");
  mitk::PointSet::PointType point;
  mitk::FillVector3D(point, 2.2, 3.3, -4.4);
  /* call everything that might modify PointContainer and PointDataContainer */
  pointSet->InsertPoint(17, point);
  pointSet->SetPoint(4, point);
  pointSet->SetPoint(7, point);
  pointSet->SetPoint(2, point);
  pointSet->SwapPointPosition(7, true);
  pointSet->SwapPointPosition(3, true);
  pointSet->SwapPointPosition(2, false);
  mitkPointSetTestClass::TestPointContainerPointDataContainer(pointSet);
  
  MITK_TEST_OUTPUT(<< "Test OpREMOVE");
  mitk::PointOperation op1(mitk::OpREMOVE, mitk::Point3D(), 2); // existing index
  pointSet->ExecuteOperation(&op1);
  mitk::PointOperation op1b(mitk::OpREMOVE, mitk::Point3D(), 112); // non existing index
  pointSet->ExecuteOperation(&op1b);
  mitkPointSetTestClass::TestPointContainerPointDataContainer(pointSet);

  MITK_TEST_OUTPUT(<< "Test OpMove");
  mitk::PointOperation op2(mitk::OpMOVE, mitk::Point3D(), 4);  // existing index
  pointSet->ExecuteOperation(&op2);
  mitk::PointOperation op3(mitk::OpMOVE, mitk::Point3D(), 34);  // non existing index
  pointSet->ExecuteOperation(&op3);
  mitkPointSetTestClass::TestPointContainerPointDataContainer(pointSet);

  MITK_TEST_OUTPUT(<< "Test OpINSERT");
  mitk::PointOperation op4(mitk::OpINSERT, mitk::Point3D(), 38);  // non existing index
  pointSet->ExecuteOperation(&op4);
  mitk::PointOperation op5(mitk::OpINSERT, mitk::Point3D(), 17);  // existing index
  pointSet->ExecuteOperation(&op5);  
  mitkPointSetTestClass::TestPointContainerPointDataContainer(pointSet);

  MITK_TEST_END();
}
int mitkPointSetWriterTest ( int  ,
char *  [] 
)

Test for the class "mitkPointSetFileWriter".

argc and argv are the command line parameters which were passed to the ADD_TEST command in the CMakeLists.txt file. For the automatic tests, argv is either empty for the simple tests or contains the filename of a test image for the image tests (see CMakeLists.txt).

Definition at line 34 of file mitkPointSetWriterTest.cpp.

References EXIT_FAILURE, MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, MITK_TEST_FOR_EXCEPTION_BEGIN, MITK_TEST_FOR_EXCEPTION_END, MITK_TEST_OUTPUT, mitk::PointSet::New(), and mitk::PointSetWriter::New().

{
  // always start with this!
  MITK_TEST_BEGIN("PointSetWriter")

  // let's create an object of our class  
  mitk::PointSetWriter::Pointer myPointSetWriter = mitk::PointSetWriter::New();
  
  // first test: did this work?
  // using MITK_TEST_CONDITION_REQUIRED makes the test stop after failure, since
  // it makes no sense to continue without an object.
  MITK_TEST_CONDITION_REQUIRED(myPointSetWriter.IsNotNull(),"Testing instantiation") 

  // write your own tests here and use the macros from mitkTestingMacros.h !!!
  // do not write to std::cout and do not return from this function yourself!

  // create pointSet
  srand(time(NULL));
  mitk::PointSet::Pointer pointSet = mitk::PointSet::New();
  int numberOfPoints = rand()%100;
  for (int i=0; i<=numberOfPoints+1;i++)
  {
    mitk::Point3D point;
    point[0] = rand()%1000;
    point[1] = rand()%1000;
    point[2] = rand()%1000;
    pointSet->SetPoint(i,point);
  }

  MITK_TEST_CONDITION_REQUIRED(pointSet.IsNotNull(),"PointSet creation")

    try{  
      // test for exception handling
      MITK_TEST_FOR_EXCEPTION_BEGIN(itk::ExceptionObject)
      myPointSetWriter->SetInput(pointSet);
      myPointSetWriter->SetFileName("/usr/bin");
      myPointSetWriter->Update(); 
      MITK_TEST_FOR_EXCEPTION_END(itk::ExceptionObject)
  }
  catch(...) {
    //this means that a wrong exception (i.e. no itk:Exception) has been thrown 
    std::cout << "Wrong exception (i.e. no itk:Exception) caught during write [FAILED]" << std::endl;
    return EXIT_FAILURE;
  }

  /*
  MITK_TEST_OUTPUT( << "Check if filename can be set correctly: ");
  myPointSetWriter->SetFileName("filename");
  const char * filename = myPointSetWriter->GetFileName();
  MITK_TEST_CONDITION_REQUIRED(std::string("filename") == "filename", "Filename set correctly?");

  MITK_TEST_OUTPUT( << "Check if prefix can be set correctly: ");
  myPointSetWriter->SetFilePrefix("pre");
  const char * prefix = myPointSetWriter->GetFilePrefix();
  MITK_TEST_CONDITION_REQUIRED(std::string("pre") == prefix, "Prefix set correctly?");

  MITK_TEST_OUTPUT( << "Check if pattern can be set correctly: ");
  myPointSetWriter->SetFilePattern("pattern");
  const char * pattern = myPointSetWriter->GetFilePattern();
  MITK_TEST_CONDITION_REQUIRED(std::string("pattern") == prefix, "Pattern set correctly?");
  */
  
  MITK_TEST_OUTPUT( << "Check if input can be set correctly: ");
  myPointSetWriter->SetInput(pointSet);
  mitk::PointSet::Pointer pointSet2 = mitk::PointSet::New();
  pointSet2 = myPointSetWriter->GetInput();

  MITK_TEST_CONDITION_REQUIRED( pointSet->GetSize() == pointSet2->GetSize(), "Pointsets have unequal size" ); 
  
  for(int i=0; i<pointSet->GetSize(); i++)
  {
    mitk::Point3D p1 = pointSet->GetPoint(i);
    mitk::Point3D p2 = pointSet2->GetPoint(i);
    MITK_TEST_CONDITION_REQUIRED( p1[0] == p2[0] && p1[0] == p2[0] && p1[0] == p2[0], "Pointsets aren't equal" );
  }

  std::vector< std::string > extensions = myPointSetWriter->GetPossibleFileExtensions();

  // always end with this!
  MITK_TEST_END()
}
int mitkPropertyListTest ( int  ,
char *  [] 
)

Definition at line 24 of file mitkPropertyListTest.cpp.

References EXIT_FAILURE, EXIT_SUCCESS, mitk::GenericLookupTable< T >::GetTableValue(), mitk::StringProperty::New(), mitk::IntProperty::New(), mitk::BoolLookupTableProperty::New(), mitk::FloatProperty::New(), mitk::BoolProperty::New(), mitk::PropertyList::New(), and mitk::GenericLookupTable< T >::SetTableValue().

{
  mitk::PropertyList::Pointer propList;
  std::cout << "Testing mitk::PropertyList::New(): ";
  propList = mitk::PropertyList::New();
  if (propList.IsNull()) {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  else {
  std::cout << "[PASSED]" << std::endl;
  } 
  mitk::BoolProperty::Pointer boolProp = mitk::BoolProperty::New(false);
  mitk::BoolProperty::Pointer boolProp2 = mitk::BoolProperty::New(false);
  std::cout << "Testing BoolProperty ==: ";
  if (! (*boolProp2 == *boolProp) ) {
    
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
    } 
  std::cout << "[PASSED]" << std::endl;
  unsigned long tBefore,tAfter; 
  
  std::cout << "Testing SetProperty() with new key value: ";
  tBefore = propList->GetMTime();
  propList->SetProperty("test",boolProp); 
  tAfter = propList->GetMTime();
  if (! ( tAfter > tBefore) ) {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  std::cout << "[PASSED]" << std::endl;
  
  std::cout << "Testing SetProperty() with changed property value: ";
  tBefore = propList->GetMTime();
  propList->SetProperty("test",mitk::BoolProperty::New(true)); 
  tAfter = propList->GetMTime();
  if (!  (tAfter > tBefore) ) {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  std::cout << "[PASSED]" << std::endl;
  
  std::cout << "Testing SetProperty() with unchanged property value: ";
  tBefore = propList->GetMTime();
  propList->SetProperty("test",mitk::BoolProperty::New(true)); 
  tAfter = propList->GetMTime();
  if ( tBefore != tAfter ) {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  std::cout << "[PASSED]" << std::endl;
  
  std::cout << "Testing MTime correctness when changing property value: ";
  boolProp = mitk::BoolProperty::New(true);
  propList->ReplaceProperty("test",boolProp); 
  tBefore = propList->GetMTime();
  boolProp->SetValue(true);
  tAfter = propList->GetMTime();
  boolProp->SetValue(false);
  unsigned long tAfterAll = propList->GetMTime();
  
  if (tBefore != tAfter || tAfterAll <= tAfter) {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  std::cout << "[PASSED]" << std::endl;
 
  std::cout << "Testing MTime correctness when calling SetProperty twice: ";
  boolProp = mitk::BoolProperty::New(true);
  propList->SetProperty("test",boolProp); 
  tBefore = propList->GetMTime();
  propList->SetProperty("test",boolProp); 
  tAfter = propList->GetMTime();
  
  if (tBefore != tAfter) {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  std::cout << "[PASSED]" << std::endl;
 

  std::cout << "Testing if existing properties survive SetProperty: ";
  propList->SetProperty("test",boolProp);
  mitk::BaseProperty* bpBefore = propList->GetProperty("test");
  propList->SetProperty("test",boolProp2);
  mitk::BaseProperty* bpAfter = propList->GetProperty("test");

  if (bpBefore != bpAfter || bpAfter == NULL) {
    std::cout << std::endl;
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  std::cout << "[PASSED]" << std::endl;

  std::cout << "Testing if existing properties survive ReplaceProperty: ";
  propList->SetProperty("test",boolProp);
  bpBefore = propList->GetProperty("test");
  propList->ReplaceProperty("test",boolProp2);
  bpAfter = propList->GetProperty("test");

  if (bpBefore == bpAfter || bpAfter == NULL) {
    std::cout << std::endl;
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  std::cout << "[PASSED]" << std::endl;
  
  //std::cout << "Testing output of PropertyList to file: ";
  //if ( TestXMLWriter() )
  //  std::cout << "[PASSED]" << std::endl;
  //else
  //  return EXIT_FAILURE;
  
  std::cout << "Testing GetPropertyValue(bool): ";
  mitk::BoolProperty::Pointer gpvTest = mitk::BoolProperty::New(true);
  propList->SetProperty("gpvBool", gpvTest);
  bool b = false;
  bool getPropertyValueReturnValue = propList->GetPropertyValue<bool>("gpvBool", b);
  if ((getPropertyValueReturnValue == true) && (b == gpvTest->GetValue()))
    std::cout << "[PASSED]" << std::endl;
  else
  {
    std::cout << "Oh, not goot:" 
                 "\nWe called propList->GetPropertyValue<bool>('gpvBool', b) and it returned " << getPropertyValueReturnValue <<
                 "\nThen we compared b [" << b << "] and gpvTest->GetValue() [" << gpvTest->GetValue() << "]" << std::endl;
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }
  
  std::cout << "Testing GetPropertyValue(float): ";
  mitk::FloatProperty::Pointer gpvTest2 = mitk::FloatProperty::New(3.1337);
  propList->SetProperty("gpvfloat", gpvTest2);
  float v = -1.23;
  if ((propList->GetPropertyValue<float>("gpvfloat", v) == true) && (v == gpvTest2->GetValue()))
    std::cout << "[PASSED]" << std::endl;
  else
  {
    std::cout << "[FAILED]" << std::endl;
    return EXIT_FAILURE;
  }

  std::cout << "Testing GetPropertyValue(BoolLookupTable): ";
  mitk::BoolLookupTable blt;
  blt.SetTableValue(17, true);
  propList->SetProperty("blutprop", mitk::BoolLookupTableProperty::New(blt));
  try
  {
    mitk::BoolLookupTable blut;
    if ((propList->GetPropertyValue<mitk::BoolLookupTable>("blutprop", blut) == true) && (blut.GetTableValue(17) == true))
      std::cout << "[PASSED]" << std::endl;
    else
    {
      std::cout << "[FAILED]" << std::endl;
      return EXIT_FAILURE;
    }
  }
  catch(...)
  {
    std::cout << "Exception thrown! [FAILED]" << std::endl;
    return EXIT_FAILURE;
  }

  {  
    std::cout << "Testing GetBoolProperty(): ";
    mitk::BoolProperty::Pointer prop = mitk::BoolProperty::New(true);
    propList->ReplaceProperty("test", prop);
    bool v = false;
    if ((propList->GetBoolProperty("test", v) == true) && (v == prop->GetValue()))
      std::cout << "[PASSED]" << std::endl;
    else
    {
      std::cout << "[FAILED]" << std::endl;
      return EXIT_FAILURE;
    }
  }
  {  
    std::cout << "Testing GetIntProperty(): ";
    mitk::IntProperty::Pointer prop = mitk::IntProperty::New(31337);
    propList->ReplaceProperty("test", prop);
    int v = 1;
    if ((propList->GetIntProperty("test", v) == true) && (v == prop->GetValue()))
      std::cout << "[PASSED]" << std::endl;
    else
    {
      std::cout << "[FAILED]" << std::endl;
      return EXIT_FAILURE;
    }
  }
  {  
    std::cout << "Testing GetFloatProperty(): ";
    mitk::FloatProperty::Pointer prop = mitk::FloatProperty::New(31.337);
    propList->ReplaceProperty("test", prop);
    float v = 1.2;
    if ((propList->GetFloatProperty("test", v) == true) && (v == prop->GetValue()))
      std::cout << "[PASSED]" << std::endl;
    else
    {
      std::cout << "[FAILED]" << std::endl;
      return EXIT_FAILURE;
    }
  } 
  {  
    std::cout << "Testing GetStringProperty(): ";
    mitk::StringProperty::Pointer prop = mitk::StringProperty::New("MITK");
    propList->ReplaceProperty("test", prop);
    std::string v = "";
    if ((propList->GetStringProperty("test", v) == true) && (v == prop->GetValue()))
      std::cout << "[PASSED]" << std::endl;
    else
    {
      std::cout << "[FAILED]" << std::endl;
      return EXIT_FAILURE;
    }
  } 
  
  std::cout << "[TEST DONE]" << std::endl;
  return EXIT_SUCCESS;
}
int mitkRenderingManagerTest ( int  ,
char *  [] 
)

Definition at line 62 of file mitkRenderingManagerTest.cpp.

References mitk::BaseRenderer::AddInstance(), mitk::RenderingManager::GetInstance(), MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, mitk::VtkPropRenderer::New(), mitk::GlobalInteraction::New(), mitk::StandaloneDataStorage::New(), mitk::RenderingManager::New(), and mitkRenderingManagerTestClass::TestPropertyList().

{
  // always start with this!
  MITK_TEST_BEGIN("RenderingManager")

  mitk::RenderingManager::Pointer globalRenderingManager = mitk::RenderingManager::GetInstance();

  MITK_TEST_CONDITION_REQUIRED(globalRenderingManager.IsNotNull(),"Testing instantiation of global static instance")


  mitk::RenderingManager::Pointer myRenderingManager = mitk::RenderingManager::New();

  MITK_TEST_CONDITION_REQUIRED(myRenderingManager.IsNotNull(),"Testing instantiation of second 'local' instance") 

  MITK_TEST_CONDITION_REQUIRED(myRenderingManager != globalRenderingManager ,"Testing whether global instance equals new local instance (must not be!)") 


  mitk::StandaloneDataStorage::Pointer ds = mitk::StandaloneDataStorage::New();
  mitk::StandaloneDataStorage::Pointer ds2 = mitk::StandaloneDataStorage::New();
  mitk::GlobalInteraction::Pointer gi = mitk::GlobalInteraction::New();
  gi->Initialize("global");
  
  myRenderingManager->SetDataStorage(ds);
  myRenderingManager->SetGlobalInteraction(gi);

  vtkRenderWindow* vtkRenWin = vtkRenderWindow::New();
  mitk::VtkPropRenderer::Pointer br = mitk::VtkPropRenderer::New("testingBR", vtkRenWin, myRenderingManager);

  mitk::BaseRenderer::AddInstance(vtkRenWin,br);
  myRenderingManager->AddRenderWindow(vtkRenWin);

  MITK_TEST_CONDITION_REQUIRED(myRenderingManager->GetDataStorage() == ds, "Testing the setter and getter for internal DataStorage") 
  MITK_TEST_CONDITION_REQUIRED(myRenderingManager->GetGlobalInteraction() ==gi, "Testing the setter and getter for internal GlobalInteraction") 

  MITK_TEST_CONDITION_REQUIRED(br->GetDataStorage() == ds,"Testing if internal DataStorage has been set correctly for registered BaseRenderer") 
  myRenderingManager->SetDataStorage(ds2);
  MITK_TEST_CONDITION_REQUIRED(br->GetDataStorage() == ds2,"Testing if change of internal DataStorage has been forwarded correctly to registered BaseRenderer") 

  mitkRenderingManagerTestClass::TestPropertyList(myRenderingManager);

  // write your own tests here and use the macros from mitkTestingMacros.h !!!
  // do not write to std::cout and do not return from this function yourself!

  //Remove Render Window
  myRenderingManager->RemoveRenderWindow(vtkRenWin);

  //Delete vtk variable correctly
  vtkRenWin->Delete();
    
  // always end with this!
  MITK_TEST_END()
}
int mitkSlicedGeometry3DTest ( int  ,
char *  [] 
)

Definition at line 29 of file mitkSlicedGeometry3DTest.cpp.

References EXIT_FAILURE, EXIT_SUCCESS, mitk::Geometry3D::GetAxisVector(), mitk::Geometry3D::GetIndexToWorldTransform(), mitk::Geometry3D::GetOrigin(), matrix(), mitk::SlicedGeometry3D::New(), mitk::PlaneGeometry::New(), and mitk::PlaneGeometry::Transversal.

{
  mitk::PlaneGeometry::Pointer planegeometry1 = mitk::PlaneGeometry::New();
 
  mitk::Point3D origin;
  mitk::Vector3D right, bottom, normal;
  mitk::ScalarType width, height;
  mitk::ScalarType widthInMM, heightInMM, thicknessInMM;

  width  = 100;    widthInMM  = width;
  height = 200;    heightInMM = height;
  thicknessInMM = 3.5;
  mitk::FillVector3D(origin, 4.5,              7.3, 11.2);
  mitk::FillVector3D(right,  widthInMM,          0, 0);
  mitk::FillVector3D(bottom,         0, heightInMM, 0);
  mitk::FillVector3D(normal,         0,          0, thicknessInMM);

  std::cout << "Initializing planegeometry1 by InitializeStandardPlane(rightVector, downVector, spacing = NULL): "<<std::endl;
  planegeometry1->InitializeStandardPlane(right.Get_vnl_vector(), bottom.Get_vnl_vector());

  std::cout << "Setting planegeometry2 to a cloned version of planegeometry1: "<<std::endl;
  mitk::PlaneGeometry::Pointer planegeometry2;
  planegeometry2 = dynamic_cast<mitk::PlaneGeometry*>(planegeometry1->Clone().GetPointer());;

  std::cout << "Changing the IndexToWorldTransform of planegeometry2 to a rotated version by SetIndexToWorldTransform() (keep origin): "<<std::endl;
  mitk::AffineTransform3D::Pointer transform = mitk::AffineTransform3D::New();
  mitk::AffineTransform3D::MatrixType::InternalMatrixType vnlmatrix;
  vnlmatrix = planegeometry2->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix();
  mitk::VnlVector axis(3);
  mitk::FillVector3D(axis, 1.0, 1.0, 1.0); axis.normalize();
  vnl_quaternion<mitk::ScalarType> rotation(axis, 0.123);
  vnlmatrix = rotation.rotation_matrix_transpose()*vnlmatrix;
  mitk::Matrix3D matrix;
  matrix = vnlmatrix;
  transform->SetMatrix(matrix);
  transform->SetOffset(planegeometry2->GetIndexToWorldTransform()->GetOffset());
  
  right.Set_vnl_vector( rotation.rotation_matrix_transpose()*right.Get_vnl_vector() );
  bottom.Set_vnl_vector(rotation.rotation_matrix_transpose()*bottom.Get_vnl_vector());
  normal.Set_vnl_vector(rotation.rotation_matrix_transpose()*normal.Get_vnl_vector());
  planegeometry2->SetIndexToWorldTransform(transform);


  std::cout << "Setting planegeometry3 to the backside of planegeometry2: " <<std::endl;
  mitk::PlaneGeometry::Pointer planegeometry3 = mitk::PlaneGeometry::New();
  planegeometry3->InitializeStandardPlane(planegeometry2, mitk::PlaneGeometry::Transversal, 0, false);


  std::cout << "Testing SlicedGeometry3D::InitializeEvenlySpaced(planegeometry3, zSpacing = 1, slices = 5, flipped = false): " <<std::endl;
  mitk::SlicedGeometry3D::Pointer slicedWorldGeometry=mitk::SlicedGeometry3D::New();
  unsigned int numSlices = 5;
  slicedWorldGeometry->InitializeEvenlySpaced(planegeometry3, 1, numSlices, false);

  std::cout << "Testing availability and type (PlaneGeometry) of first geometry in the SlicedGeometry3D: ";
  mitk::PlaneGeometry* accessedplanegeometry3 = dynamic_cast<mitk::PlaneGeometry*>(slicedWorldGeometry->GetGeometry2D(0));
  if(accessedplanegeometry3==NULL)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing whether the first geometry in the SlicedGeometry3D is identical to planegeometry3 by axis comparison and origin: "<<std::endl;
  if((mitk::Equal(accessedplanegeometry3->GetAxisVector(0), planegeometry3->GetAxisVector(0))==false) || 
     (mitk::Equal(accessedplanegeometry3->GetAxisVector(1), planegeometry3->GetAxisVector(1))==false) || 
     (mitk::Equal(accessedplanegeometry3->GetAxisVector(2), planegeometry3->GetAxisVector(2))==false) ||
     (mitk::Equal(accessedplanegeometry3->GetOrigin(), planegeometry3->GetOrigin())==false))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing availability and type (PlaneGeometry) of the last geometry in the SlicedGeometry3D: ";
  mitk::PlaneGeometry* accessedplanegeometry3last = dynamic_cast<mitk::PlaneGeometry*>(slicedWorldGeometry->GetGeometry2D(numSlices-1));
  mitk::Point3D origin3last; origin3last = planegeometry3->GetOrigin()+slicedWorldGeometry->GetDirectionVector()*(numSlices-1);
  if(accessedplanegeometry3last==NULL)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing whether the last geometry in the SlicedGeometry3D is identical to planegeometry3 by axis comparison: "<<std::endl;
  if((mitk::Equal(accessedplanegeometry3last->GetAxisVector(0), planegeometry3->GetAxisVector(0))==false) || 
     (mitk::Equal(accessedplanegeometry3last->GetAxisVector(1), planegeometry3->GetAxisVector(1))==false) || 
     (mitk::Equal(accessedplanegeometry3last->GetAxisVector(2), planegeometry3->GetAxisVector(2))==false) ||
     (mitk::Equal(accessedplanegeometry3last->GetOrigin(), origin3last)==false) ||
     (mitk::Equal(accessedplanegeometry3last->GetIndexToWorldTransform()->GetOffset(), origin3last.GetVectorFromOrigin())==false))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Again for first slice - Testing availability and type (PlaneGeometry) of first geometry in the SlicedGeometry3D: ";
  accessedplanegeometry3 = dynamic_cast<mitk::PlaneGeometry*>(slicedWorldGeometry->GetGeometry2D(0));
  if(accessedplanegeometry3==NULL)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Again for first slice - Testing whether the first geometry in the SlicedGeometry3D is identical to planegeometry3 by axis comparison and origin: "<<std::endl;
  if((mitk::Equal(accessedplanegeometry3->GetAxisVector(0), planegeometry3->GetAxisVector(0))==false) || 
     (mitk::Equal(accessedplanegeometry3->GetAxisVector(1), planegeometry3->GetAxisVector(1))==false) || 
     (mitk::Equal(accessedplanegeometry3->GetAxisVector(2), planegeometry3->GetAxisVector(2))==false) ||
     (mitk::Equal(accessedplanegeometry3->GetOrigin(), planegeometry3->GetOrigin())==false) ||
     (mitk::Equal(accessedplanegeometry3->GetIndexToWorldTransform()->GetOffset(), planegeometry3->GetOrigin().GetVectorFromOrigin())==false))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;


  std::cout<<"[TEST DONE]"<<std::endl;
  return EXIT_SUCCESS;
}
int mitkSliceNavigationControllerTest ( int  ,
char *  [] 
)

Definition at line 206 of file mitkSliceNavigationControllerTest.cpp.

References EXIT_FAILURE, EXIT_SUCCESS, matrix(), mitk::Geometry3D::New(), mitk::SlicedGeometry3D::New(), mitk::PlaneGeometry::New(), and testGeometry().

{
  int result=EXIT_FAILURE;

  std::cout << "Creating and initializing a PlaneGeometry: ";
  mitk::PlaneGeometry::Pointer planegeometry = mitk::PlaneGeometry::New();
 
  mitk::Point3D origin;
  mitk::Vector3D right, bottom, normal;
  mitk::ScalarType width, height;
  mitk::ScalarType widthInMM, heightInMM, thicknessInMM;

  width  = 100;    widthInMM  = width;
  height = 200;    heightInMM = height;
  thicknessInMM = 1.5;
//  mitk::FillVector3D(origin,         0,          0, thicknessInMM*0.5);
  mitk::FillVector3D(origin, 4.5,              7.3, 11.2);
  mitk::FillVector3D(right,  widthInMM,          0, 0);
  mitk::FillVector3D(bottom,         0, heightInMM, 0);
  mitk::FillVector3D(normal,         0,          0, thicknessInMM);

  mitk::Vector3D spacing;
  normal.Normalize(); normal *= thicknessInMM;
  mitk::FillVector3D(spacing, 1.0, 1.0, thicknessInMM);
  planegeometry->InitializeStandardPlane(right.Get_vnl_vector(), bottom.Get_vnl_vector(), &spacing);
  planegeometry->SetOrigin(origin);
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Creating and initializing a SlicedGeometry3D with the PlaneGeometry: ";
  mitk::SlicedGeometry3D::Pointer slicedgeometry = mitk::SlicedGeometry3D::New();
  unsigned int numSlices = 5;
  slicedgeometry->InitializeEvenlySpaced(planegeometry, thicknessInMM, numSlices, false);
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Creating a Geometry3D with the same extent as the SlicedGeometry3D: ";
  mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New();
  geometry->SetBounds(slicedgeometry->GetBounds());
  geometry->SetIndexToWorldTransform(slicedgeometry->GetIndexToWorldTransform());
  std::cout<<"[PASSED]"<<std::endl;

  mitk::Point3D cornerpoint0;
  cornerpoint0 = geometry->GetCornerPoint(0);


  result=testGeometry(geometry, width, height, numSlices, widthInMM, heightInMM, thicknessInMM, cornerpoint0, right, bottom, normal);
  if(result!=EXIT_SUCCESS)
    return result;



  mitk::BoundingBox::BoundsArrayType bounds =  geometry->GetBounds();
  mitk::AffineTransform3D::Pointer transform = mitk::AffineTransform3D::New();
  transform->SetMatrix(geometry->GetIndexToWorldTransform()->GetMatrix());
  mitk::BoundingBox::Pointer boundingbox = geometry->CalculateBoundingBoxRelativeToTransform(transform);
  geometry->SetBounds(boundingbox->GetBounds());
  cornerpoint0 = geometry->GetCornerPoint(0);

  result=testGeometry(geometry, width, height, numSlices, widthInMM, heightInMM, thicknessInMM, cornerpoint0, right, bottom, normal);
  if(result!=EXIT_SUCCESS)
    return result;



  std::cout << "Changing the IndexToWorldTransform of the geometry to a rotated version by SetIndexToWorldTransform() (keep cornerpoint0): ";
  transform = mitk::AffineTransform3D::New();
  mitk::AffineTransform3D::MatrixType::InternalMatrixType vnlmatrix;
  vnlmatrix = planegeometry->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix();
  mitk::VnlVector axis(3);
  mitk::FillVector3D(axis, 1.0, 1.0, 1.0); axis.normalize();
  vnl_quaternion<mitk::ScalarType> rotation(axis, 0.223);
  vnlmatrix = rotation.rotation_matrix_transpose()*vnlmatrix;
  mitk::Matrix3D matrix;
  matrix = vnlmatrix;
  transform->SetMatrix(matrix);
  transform->SetOffset(cornerpoint0.GetVectorFromOrigin());
  
  right.Set_vnl_vector( rotation.rotation_matrix_transpose()*right.Get_vnl_vector() );
  bottom.Set_vnl_vector(rotation.rotation_matrix_transpose()*bottom.Get_vnl_vector());
  normal.Set_vnl_vector(rotation.rotation_matrix_transpose()*normal.Get_vnl_vector());
  geometry->SetIndexToWorldTransform(transform);
  std::cout<<"[PASSED]"<<std::endl;

  cornerpoint0 = geometry->GetCornerPoint(0);

  result = testGeometry(geometry, width, height, numSlices, widthInMM, heightInMM, thicknessInMM, cornerpoint0, right, bottom, normal);
  if(result!=EXIT_SUCCESS)
    return result;





  std::cout<<"[TEST DONE]"<<std::endl;
  return EXIT_SUCCESS;
}
int mitkStateMachineFactoryTest ( int  ,
char *  [] 
)

Definition at line 24 of file mitkStateMachineFactoryTest.cpp.

References mitk::AcDONOTHING, mitk::Transition::AddAction(), mitk::StateMachineFactory::AddStateMachinePattern(), mitk::EIDNULLEVENT, mitk::StandardFileLocations::GetInstance(), mitk::StateMachineFactory::GetStartState(), mitk::StateMachineFactory::LoadBehavior(), mitk::StateMachineFactory::LoadStandardBehavior(), MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, mitk::Action::New(), mitk::State::New(), mitk::StateMachineFactory::New(), and mitk::Transition::SetNextState().

{
  MITK_TEST_BEGIN("StateMachineFactory")
  //create statemachinefactory
  mitk::StateMachineFactory* statemachineFactory = mitk::StateMachineFactory::New();
  
  //load standard behavior 
  MITK_TEST_CONDITION_REQUIRED(statemachineFactory->LoadStandardBehavior(),"Testing LoadStandardBehavior(): ") 
  
  //get the first state of the statemachine "global" (mitkGlobalInteraction)
  mitk::State::Pointer state = statemachineFactory->GetStartState("global");
  MITK_TEST_CONDITION_REQUIRED(state.IsNotNull(),"Testing GetStartState() of GlobalInteraction state machine pattern: ") 

  std::string xmlFileName1( mitk::StandardFileLocations::GetInstance()->FindFile("TestStateMachine1.xml", "Core/Code/Testing/Data") );
  MITK_TEST_CONDITION_REQUIRED(!xmlFileName1.empty(),"Getting xml file 1: ") 
  MITK_TEST_CONDITION_REQUIRED(statemachineFactory->LoadBehavior(xmlFileName1),"Parsing xml file 1: ") 
  state = statemachineFactory->GetStartState("test1");
  MITK_TEST_CONDITION_REQUIRED(state.IsNotNull(),"Testing GetStartState() of test1 state machine pattern: ") 

  //global still accessible?
  state = statemachineFactory->GetStartState("global");
  MITK_TEST_CONDITION_REQUIRED(state.IsNotNull(),"Testing if previous loaded state machine patterns are still accessible: ") 
  
  std::string xmlFileName2( mitk::StandardFileLocations::GetInstance()->FindFile("TestStateMachine2.xml", "Core/Code/Testing/Data") );
  MITK_TEST_CONDITION_REQUIRED(!xmlFileName2.empty(),"Getting xml file 2: ") 
  MITK_TEST_CONDITION_REQUIRED(statemachineFactory->LoadBehavior(xmlFileName2),"Parsing xml file 2. Schould throw a fatal error due to already existing pattern name: ") 
  state = statemachineFactory->GetStartState("test4");
  MITK_TEST_CONDITION_REQUIRED(state.IsNotNull(),"Testing GetStartState() of test4 state machine pattern: ")
  
  state = statemachineFactory->GetStartState("global");
  MITK_TEST_CONDITION_REQUIRED(state.IsNotNull(),"Testing if previous loaded state machine pattern (global) is still accessible: ") 
  state = statemachineFactory->GetStartState("test1");
  MITK_TEST_CONDITION_REQUIRED(state.IsNotNull(),"Testing if previous loaded state machine pattern (test1) is still accessible: ") 


  //manually create a state machine pattern and add it to factory
  std::string patternName("manuallyCreatedStateMachine");
  mitk::StateMachineFactory::StateMachineMapType* allStatesMap = new mitk::StateMachineFactory::StateMachineMapType();

  mitk::State::Pointer state1 = mitk::State::New("firstState", 1);
  mitk::Transition* transition1 = new mitk::Transition("goto2", 2, mitk::EIDNULLEVENT); 
  mitk::Action::Pointer action1 = mitk::Action::New(mitk::AcDONOTHING);
  transition1->AddAction(action1);
  state1->AddTransition(transition1);
  allStatesMap->insert(mitk::StateMachineFactory::StateMachineMapType::value_type(state1->GetId(), state1));

  mitk::State::Pointer state2 = mitk::State::New("secondState", 2);
  transition1->SetNextState(state2);
  mitk::Transition* transition2 = new mitk::Transition("goto1", 1, mitk::EIDNULLEVENT); 
  mitk::Action::Pointer action2 = mitk::Action::New(mitk::AcDONOTHING);
  transition2->AddAction(action2);
  transition2->SetNextState(state1);
  state2->AddTransition(transition2);
  allStatesMap->insert(mitk::StateMachineFactory::StateMachineMapType::value_type(state2->GetId(), state2));

  //now add to factory
  statemachineFactory->AddStateMachinePattern(patternName.c_str(), state1, allStatesMap);
  
  //check if it is accessable
  state = statemachineFactory->GetStartState("global");
  MITK_TEST_CONDITION_REQUIRED(state.IsNotNull(),"Testing if previous loaded state machine pattern (global) is still accessible: ") 
  state = statemachineFactory->GetStartState("test1");
  MITK_TEST_CONDITION_REQUIRED(state.IsNotNull(),"Testing if previous loaded state machine pattern (test1) is still accessible: ") 
  state = statemachineFactory->GetStartState(patternName.c_str());
  MITK_TEST_CONDITION_REQUIRED(state.IsNotNull(),"Testing if manually created and added state machine pattern is accessible: ") 

  statemachineFactory->Delete();
  //states, transitions and actions are freed in StateMachineFactory

  // always end with this!
  MITK_TEST_END();
}
int mitkStateMachineTest ( int  ,
char *  [] 
)

Simple example for a test for the (non-existent) class "StateMachine".

argc and argv are the command line parameters which were passed to the ADD_TEST command in the CMakeLists.txt file. For the automatic tests, argv is either empty f25or the simple tests or contains the filename of a test image for the image tests (see CMakeLists.txt).

Definition at line 35 of file mitkStateMachineTest.cpp.

References mitk::BS_NoButton, mitk::GlobalInteraction::GetInstance(), mitk::Key_none, MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, mitk::StateMachine::New(), and mitk::Type_None.

{
  // always start with this!
  MITK_TEST_BEGIN("StateMachine")

  std::string name("global"); 

  //test Statemachine without given pattern name
  std::cout<<"should throw fatal error:\n";
  mitk::StateMachine::Pointer noMachine1 = mitk::StateMachine::New("");

  std::cout<<"should throw fatal error:\n";
  //test Statemachine without initialization of GlobalInteraction
  mitk::StateMachine::Pointer noMachine2 = mitk::StateMachine::New(name.c_str());
  
  std::cout<<"should throw fatal error:\n";
  // test Statemachine with GlobalInteraction being initialized with no string
  MITK_TEST_CONDITION_REQUIRED(mitk::GlobalInteraction::GetInstance()->Initialize("")==false,"Testing wrong initialization")

  MITK_TEST_CONDITION_REQUIRED(mitk::GlobalInteraction::GetInstance()->Initialize("raraolala")==false,"Testing initialization with wrong pattern name")

  std::cout<<"should throw fatal error:\n";
  mitk::StateMachine::Pointer noMachine3 = mitk::StateMachine::New(name.c_str());

  //now get serious

  std::cout<<"no errors / warnings anymore!\n";
  // now initialize GlobalInteraction 
  MITK_TEST_CONDITION_REQUIRED(mitk::GlobalInteraction::GetInstance()->Initialize(name.c_str())==true,"Testing wright initialization")

  // let's create an object of our class  
  mitk::StateMachine::Pointer myStateMachine = mitk::StateMachine::New(name.c_str());
  
  // first test: did this work?
  // using MITK_TEST_CONDITION_REQUIRED makes the test stop after failure, since
  // it makes no sense to continue without an object.
  MITK_TEST_CONDITION_REQUIRED(myStateMachine.IsNotNull(),"Testing instantiation")
  
  MITK_TEST_CONDITION_REQUIRED(myStateMachine->GetType() == name ,"Testing GetType") 

  //severe HandleEvent testing
  //creating an event to go from state 1 to state 2; don't execute an action
  mitk::Event *event = new mitk::Event(NULL, mitk::Type_None, mitk::Type_None, mitk::BS_NoButton, mitk::Key_none);
  mitk::StateEvent *stateEvent = new mitk::StateEvent(1013, event);
  MITK_TEST_CONDITION_REQUIRED(myStateMachine->HandleEvent(stateEvent) ,"Testing HandleEvent by statechange") 

  //go from state 2 to state 1; don't execute an action
  mitk::StateEvent *nextStateEvent = new mitk::StateEvent(1002, event);
  MITK_TEST_CONDITION_REQUIRED(myStateMachine->HandleEvent(nextStateEvent) ,"Testing HandleEvent returning to startstate") 

  myStateMachine = NULL;
  MITK_TEST_CONDITION_REQUIRED(myStateMachine.IsNull(),"Testing setting pointer to NULL")

  // Clean up...
  delete event;
  delete stateEvent;
  delete nextStateEvent;

  // always end with this!
  MITK_TEST_END()
}
int mitkStateTest ( int  ,
char *  [] 
)

http://msdn.microsoft.com/en-us/library/e5ewb1h3.aspx VS9 memory leakage detection

Definition at line 38 of file mitkStateTest.cpp.

References EXIT_SUCCESS, MITK_TEST_CONDITION_REQUIRED, mitk::State::New(), and mitk::Transition::SetNextState().

{
  int stateId = 10;
  
  //Create State
  mitk::State::Pointer state = mitk::State::New("state", stateId);
  
  //check reference count
  MITK_TEST_CONDITION_REQUIRED(state->GetReferenceCount() == 1,"Testing ReferenceCount of State");

  //check Id
  MITK_TEST_CONDITION_REQUIRED(state->GetId()==stateId,"Testing GetID ");

  int count = 0;
  //Create Transition
  std::string firstTName = "firstTransition";
  std::string secondTName = "secondTransition";
  mitk::Transition* firstTransition = new mitk::Transition(firstTName, count, count+1);
  MITK_TEST_CONDITION_REQUIRED(state->AddTransition( firstTransition ),"Adding first transition");
  MITK_TEST_CONDITION_REQUIRED(state->IsValidEvent(count+1),"Check if the first EventId is valid");
  MITK_TEST_CONDITION_REQUIRED(state->GetTransition(count+1) == firstTransition ,"Getting first transition");
  MITK_TEST_CONDITION_REQUIRED(state->GetReferenceCount() == 1,"Testing ReferenceCount still one");
  ++count;
  
  mitk::Transition* secondTransition = new mitk::Transition(secondTName, count, count+1);
  MITK_TEST_CONDITION_REQUIRED(state->AddTransition( secondTransition ),"Adding second transition");
  MITK_TEST_CONDITION_REQUIRED(state->IsValidEvent(count+1),"Check if the second EventId is valid");
  MITK_TEST_CONDITION_REQUIRED(state->GetTransition(count+1) == secondTransition ,"Getting second transition");
  MITK_TEST_CONDITION_REQUIRED(state->GetReferenceCount() == 1,"Testing ReferenceCount still one");

  ++count;
  MITK_TEST_CONDITION_REQUIRED( ! state->IsValidEvent(count+1),"Check if a non existent EventId is valid");
  
  //deleting state and checking if transitions are deleted
  state = NULL;
  MITK_TEST_CONDITION_REQUIRED(state.IsNull(),"Testing setting state to null and deleting it with it"); 

    
  std::cout << "Check state with cyclic definition: StateA->TransitionA->StateA: \n";
  stateId = 20;
  const char* name = "StateA";
  state = mitk::State::New(name, stateId);
  MITK_TEST_CONDITION_REQUIRED(state->GetId()==stateId,"Testing GetID ");
  MITK_TEST_CONDITION_REQUIRED(state->GetName()==name,"Testing GetID "); 
  MITK_TEST_CONDITION_REQUIRED(state->GetReferenceCount() == 1,"Testing ReferenceCount of State"); 
  std::cout << "Add next state to transition: ";
  count = 0;
  //creating first transition
  firstTransition = new mitk::Transition(firstTName, stateId, count+1);
  firstTransition->SetNextState(state);
  state->AddTransition(firstTransition);
  MITK_TEST_CONDITION_REQUIRED(state->GetReferenceCount() == 1,"Testing ReferenceCount still one");
  //creating second transition
  secondTransition = new mitk::Transition(secondTName, stateId, count+2);
  secondTransition ->SetNextState(state);
  state->AddTransition(secondTransition); 
  MITK_TEST_CONDITION_REQUIRED(state->GetReferenceCount() == 1,"Testing ReferenceCount still one");
  
  //destroying it again.
  state = NULL;
  MITK_TEST_CONDITION_REQUIRED(state.IsNull(),"Testing setting state to null and deleting it with it"); 

  //doesn't have to be done because the memory is freed in ~State destructor
  //delete firstTransition;
  //delete secondTransition;


  //#ifdef WIN32
  //#ifdef _DEBUG
  //_CrtDumpMemoryLeaks();
  //#endif
  //#endif

  std::cout<<"[TEST DONE]"<<std::endl;
  return EXIT_SUCCESS;
}
int mitkStepperTest ( int  ,
char *  [] 
)

Definition at line 22 of file mitkStepperTest.cpp.

References MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, and mitk::Stepper::New().

{
  MITK_TEST_BEGIN(StepperTest)

  mitk::Stepper::Pointer stepperA;
  stepperA = mitk::Stepper::New();
  MITK_TEST_CONDITION_REQUIRED(stepperA.IsNotNull(),"Stepper instantiation.")

  // number of steps defaults to zero, SetPos should have no effect, GetPos should return zero
  stepperA->SetPos(10);
  MITK_TEST_CONDITION_REQUIRED(stepperA->GetPos() == 0,"Pos remains zero if m_Steps is zero.")

  mitk::Stepper::Pointer stepperB = mitk::Stepper::New();
  stepperA->SetSteps(4);
  //stepperA->PingPongOn();
  stepperB->SetSteps(6);
  // stepperB->PingPongOn();
  /* for (int i=0 ; i<10; i++) {
    std::cout << i << ": A: " << stepperA->GetPos() << " B:" << stepperB->GetPos() << std::endl; 
    stepperA->Next();
    stepperB->Next();
  }*/
  
  MITK_TEST_END()
}
int mitkSurfaceTest ( int  ,
char *  [] 
)

Definition at line 29 of file mitkSurfaceTest.cpp.

References EXIT_FAILURE, EXIT_SUCCESS, mitk::TimeSlicedGeometry::MSToTimeStep(), and mitk::Surface::New().

{
  mitk::Surface::Pointer surface;
  std::cout << "Testing mitk::Surface::New(): ";
  surface = mitk::Surface::New();
  if (surface.IsNull()) {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  else {
  std::cout<<"[PASSED]"<<std::endl;
  } 

  std::cout << "Testing mitk::Surface::PrintSelf() for empty surface: ";
  surface->PrintSelf(std::cout, 0);
  std::cout<<"[PASSED]"<<std::endl;

  vtkSphereSource* sphereSource = vtkSphereSource::New();
  sphereSource->SetCenter(0,0,0);
  sphereSource->SetRadius(5.0);
  sphereSource->SetThetaResolution(10);
  sphereSource->SetPhiResolution(10);
  sphereSource->Update();

  vtkPolyData* polys = sphereSource->GetOutput();
  surface->SetVtkPolyData( polys );
  sphereSource->Delete();
  std::cout << "Testing mitk::Surface::SetVtkPolyData(): ";
  if (surface->GetVtkPolyData() ==  NULL ) {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  else {
  std::cout<<"[PASSED]"<<std::endl;
  } 

  {
    vtkFloatingPointType bounds[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};

    polys->ComputeBounds();
    polys->GetBounds( bounds );

    std::cout << "Testing GetBoundingBox() ";
    surface->UpdateOutputInformation();
    surface->SetRequestedRegionToLargestPossibleRegion();
    //  mitk::BoundingBox bb = const_cast<mitk::BoundingBox*>(
    mitk::BoundingBox* bb = const_cast<mitk::BoundingBox*>(surface->GetGeometry()->GetBoundingBox());
    mitk::BoundingBox::BoundsArrayType surfBounds = bb->GetBounds();

    if ( bounds[0] != surfBounds[0] 
    || bounds[1] != surfBounds[1] 
    || bounds[2] != surfBounds[2] 
    || bounds[3] != surfBounds[3] 
    || bounds[4] != surfBounds[4] 
    || bounds[5] != surfBounds[5] 
    ) {
      std::cout<<"[FAILED]"<<std::endl;
      return EXIT_FAILURE;
    }
    else {
      std::cout<<"[PASSED]"<<std::endl;
    } 
  }


  std::cout << "Testing mitk::Surface::Expand( timesteps ): ";
  surface->Expand(5);
  surface->Update();
  surface->SetRequestedRegionToLargestPossibleRegion();
  mitk::Surface::RegionType requestedRegion = surface->GetRequestedRegion();

  if ( requestedRegion.GetSize(3) != 5 ) {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  else {
  std::cout<<"[PASSED]"<<std::endl;
  } 

  std::cout << "Testing mitk::Surface::Testing 4D surface data creation: ";

//  surface = mitk::Surface::New();
  //mitk::Geometry3D::Pointer geometry = surface->GetTimeSlicedGeometry()->GetGeometry3D(0);
  //geometry->GetVtkTransform()->Identity();
  //geometry->GetVtkTransform()->Translate(10,10,10);
  //geometry->TransferVtkToItkTransform();
  //mitk::TimeSlicedGeometry* timeSlicedGeometry = surface->GetTimeSlicedGeometry();
  //timeSlicedGeometry->InitializeEvenlyTimed(geometry, 5);

  vtkFloatingPointType bounds[5][6];

  for (int i=0;i<5;i++) {
    vtkSphereSource* sphereSource = vtkSphereSource::New();
    sphereSource->SetCenter(0,0,0);
    sphereSource->SetRadius(1.0 * (i+1.0));
    sphereSource->SetThetaResolution(10);
    sphereSource->SetPhiResolution(10);
    sphereSource->Update();
    sphereSource->GetOutput()->ComputeBounds();
    sphereSource->GetOutput()->GetBounds( bounds[i] );
    surface->SetVtkPolyData( sphereSource->GetOutput(),i );
    sphereSource->Delete();
  }

  surface->UpdateOutputInformation();
  surface->SetRequestedRegionToLargestPossibleRegion();

  bool passed = true;
  for (int i=0;i<5;i++) 
  {
    mitk::BoundingBox::BoundsArrayType surfBounds = (const_cast<mitk::BoundingBox*>(surface->GetTimeSlicedGeometry()->GetGeometry3D(i)->GetBoundingBox()))->GetBounds();

    if ( bounds[i][0] != surfBounds[0] 
    || bounds[i][1] != surfBounds[1] 
    || bounds[i][2] != surfBounds[2] 
    || bounds[i][3] != surfBounds[3] 
    || bounds[i][4] != surfBounds[4] 
    || bounds[i][5] != surfBounds[5] )
    {
      passed = false;
      break;
    }
  }

  if (!passed)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  else 
  {
    std::cout<<"[PASSED]"<<std::endl;
  }
  
  std::cout << "Testing correctness of geometry for surface->GetUpdatedTimeSlicedGeometry(): \n";
  const mitk::TimeSlicedGeometry* inputTimeGeometry = surface->GetUpdatedTimeSlicedGeometry();

  int time = 3;
  int timestep=0;
  timestep = inputTimeGeometry->MSToTimeStep( time );

  std::cout << "time: "<< time << std::endl;
  std::cout << "timestep: "<<timestep << std::endl;

  if (time != timestep)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  else 
  {
    std::cout<<"[PASSED]"<<std::endl;
  }

  std::cout << "Explicitly changing the data of timestep 3 and checking for timebounds correctness of surface's geometry again:\n";
  
  sphereSource = vtkSphereSource::New();
  sphereSource->SetCenter(0,0,0);
  sphereSource->SetRadius( 100.0 );
  sphereSource->SetThetaResolution(10);
  sphereSource->SetPhiResolution(10);
  sphereSource->Update();
  surface->SetVtkPolyData( sphereSource->GetOutput(), 3 );
  sphereSource->Delete();
  
  inputTimeGeometry = surface->GetUpdatedTimeSlicedGeometry();
  time = 3;
  timestep=0;
  timestep = inputTimeGeometry->MSToTimeStep( time );

  std::cout << "time: "<< time << std::endl;
  std::cout << "timestep: "<<timestep << std::endl;

  if (time != timestep)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  else 
  {
    std::cout<<"[PASSED]"<<std::endl;
  }

  std::cout << "Testing copying a Surface with Graft()" << std::endl;

  unsigned int numberoftimesteps = surface->GetTimeSteps();
  mitk::Surface::Pointer dummy = mitk::Surface::New();
  dummy->Graft(surface);
  std::cout << "polyData != NULL ??" << std::endl;
  if (dummy->GetVtkPolyData() == NULL)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  
  std::cout << "orig-numberofTimeSteps:" << numberoftimesteps << "  copy-numberofTimeSteps:" << dummy->GetTimeSteps() << std::endl;
  if (dummy->GetTimeSteps() != numberoftimesteps)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  
  std::cout<<"[TEST DONE]"<<std::endl;
  return EXIT_SUCCESS;
}
int mitkSurfaceToSurfaceFilterTest ( int  ,
char *  [] 
)

Definition at line 30 of file mitkSurfaceToSurfaceFilterTest.cpp.

References EXIT_FAILURE, EXIT_SUCCESS, mitk::SurfaceToSurfaceFilter::New(), and mitk::Surface::New().

{
  mitk::Surface::Pointer surface;
  surface = mitk::Surface::New();
  vtkSphereSource* sphereSource = vtkSphereSource::New();
  sphereSource->SetCenter(0,0,0);
  sphereSource->SetRadius(5.0);
  sphereSource->SetThetaResolution(10);
  sphereSource->SetPhiResolution(10);
  sphereSource->Update();

  vtkPolyData* polys = sphereSource->GetOutput();
  surface->SetVtkPolyData( polys );
  sphereSource->Delete();
  

  mitk::SurfaceToSurfaceFilter::Pointer filter = mitk::SurfaceToSurfaceFilter::New();
  std::cout << "Testing mitk::SurfaceToSurfaceFilter::SetInput() and ::GetNumberOfInputs() : " ;
  filter->SetInput( surface );
  if ( filter->GetNumberOfInputs() < 1 )
  {
    std::cout<<"[FAILED] : zero inputs set "<<std::endl;
    return EXIT_FAILURE;
  }


  std::cout << "Testing if GetInput returns the right Input : " << std::endl;
  if ( filter->GetInput() != surface )
  {
    std::cout<<"[FAILED] : GetInput does not return correct input. "<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout << "[SUCCESS] : input correct" << std::endl;


  if ( filter->GetInput(5) != NULL )
  {
    std::cout<<"[FAILED] : GetInput returns inputs that were not set. "<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout << "[SUCCESS] : Input nr.5 was not set -> is NULL" << std::endl;


  std::cout << "Testing whether Output is created correctly : " << std::endl;
  if ( filter->GetNumberOfOutputs() != filter->GetNumberOfInputs() )
  {
    std::cout <<"[FAILED] : number of outputs != number of inputs" << std::endl;
    return EXIT_FAILURE;
  }
  std::cout << "[SUCCESS] : number of inputs == number of outputs." << std::endl;


  mitk::Surface::Pointer outputSurface = filter->GetOutput(0);
  if ( outputSurface->GetVtkPolyData()->GetNumberOfPolys() != surface->GetVtkPolyData()->GetNumberOfPolys() )
  {
    std::cout << "[FAILED] : number of Polys in PolyData of output != number of Polys in PolyData of input" << std::endl;
    return EXIT_FAILURE;
  }
  std::cout << "[SUCCESS] : number of Polys in PolyData of input and output are identical." << std::endl;



  filter->Update();
  outputSurface = filter->GetOutput(0);
  if ( outputSurface->GetSizeOfPolyDataSeries() != surface->GetSizeOfPolyDataSeries() )
  {
    std::cout << "[FAILED] : number of PolyDatas in PolyDataSeries of output != number of PolyDatas of input" << std::endl;
    return EXIT_FAILURE;
  }
  std::cout << "[SUCCESS] : Size of PolyDataSeries of input and output are identical." << std::endl;


  std::cout << "Testing removeInputs() : " << std::endl;
  unsigned int numOfInputs = filter->GetNumberOfInputs();
  filter->RemoveInputs( mitk::Surface::New() );
  if ( filter->GetNumberOfInputs() != numOfInputs )
  {
    std::cout << "[FAILED] : input was removed that was not set." << std::endl;
    return EXIT_FAILURE;
  }
  std::cout << "[SUCCESS] : no iput was removed that was not set." << std::endl;
  filter->RemoveInputs( surface );
  if ( filter->GetNumberOfInputs() != 0 )
  {
    std::cout << "[FAILED] : existing input was not removed correctly." << std::endl;
    return EXIT_FAILURE; 
  }
  std::cout << "[SUCCESS] : existing input was removed correctly." << std::endl;


  
  std::cout<<"[TEST DONE]"<<std::endl;
  return EXIT_SUCCESS;
}
int mitkSurfaceVtkWriterTest ( int  ,
char *  argv[] 
)

Simple example for a test for the (non-existent) class "ClassName".

argc and argv are the command line parameters which were passed to the ADD_TEST command in the CMakeLists.txt file. For the automatic tests, argv is either empty for the simple tests or contains the filename of a test image for the image tests (see CMakeLists.txt).

Definition at line 35 of file mitkSurfaceVtkWriterTest.cpp.

References EXIT_FAILURE, MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, MITK_TEST_FOR_EXCEPTION_BEGIN, MITK_TEST_FOR_EXCEPTION_END, mitk::Surface::New(), mitk::SurfaceVtkWriter< VTKWRITER >::New(), mitk::SurfaceVtkWriter< VTKWRITER >::SetFileName(), mitk::SurfaceVtkWriter< VTKWRITER >::SetInput(), and mitk::SurfaceVtkWriter< VTKWRITER >::Update().

{
  // always start with this!
  MITK_TEST_BEGIN("SurfaceVtkWriter")

  // let's create an object of our class  
  mitk::SurfaceVtkWriter<vtkPolyDataWriter>::Pointer mySurfaceVtkWriter = mitk::SurfaceVtkWriter<vtkPolyDataWriter>::New();

  // first test: did this work?
  // using MITK_TEST_CONDITION_REQUIRED makes the test stop after failure, since
  // it makes no sense to continue without an object.
  MITK_TEST_CONDITION_REQUIRED(mySurfaceVtkWriter.IsNotNull(),"Testing instantiation") 

  // create contour
  vtkPolyDataReader* reader = vtkPolyDataReader::New();
  reader->SetFileName(argv[1]);
  reader->Update();
  if (reader->GetOutput())
  {
    mitk::Surface::Pointer surface = mitk::Surface::New();
    surface->SetVtkPolyData(reader->GetOutput());
    surface->Update();

    MITK_TEST_CONDITION_REQUIRED(surface.IsNotNull(),"Surface creation")

      try{  
        // test for exception handling
        MITK_TEST_FOR_EXCEPTION_BEGIN(itk::ExceptionObject)
        mySurfaceVtkWriter->SetInput(surface);
        mySurfaceVtkWriter->SetFileName("/usr/bin");
        mySurfaceVtkWriter->Update(); 
        MITK_TEST_FOR_EXCEPTION_END(itk::ExceptionObject)
    }
    catch(...) {
      //this means that a wrong exception (i.e. no itk:Exception) has been thrown 
      std::cout << "Wrong exception (i.e. no itk:Exception) caught during write [FAILED]" << std::endl;
      return EXIT_FAILURE;
    }

    // write your own tests here and use the macros from mitkTestingMacros.h !!!
    // do not write to std::cout and do not return from this function yourself!

    // always end with this!
  }

  //Delete reader correctly
  reader->Delete();

  MITK_TEST_END()

}
int mitkTimeSlicedGeometryTest ( int  ,
char *  [] 
)

Definition at line 29 of file mitkTimeSlicedGeometryTest.cpp.

References EXIT_FAILURE, EXIT_SUCCESS, mitk::Geometry3D::GetAxisVector(), mitk::Geometry3D::GetOrigin(), mitk::Geometry3D::GetTimeBounds(), mitk::Geometry3D::New(), mitk::TimeSlicedGeometry::New(), mitk::PlaneGeometry::New(), and mitk::Geometry3D::SetTimeBounds().

{
  mitk::PlaneGeometry::Pointer planegeometry = mitk::PlaneGeometry::New();
 
  mitk::Point3D origin;
  mitk::Vector3D right, bottom, normal;
  mitk::ScalarType width, height;
  mitk::ScalarType widthInMM, heightInMM, thicknessInMM;

  width  = 100;    widthInMM  = width*0.5;
  height = 200;    heightInMM = height*1.2;
  thicknessInMM = 1.5;
  mitk::FillVector3D(origin,       2.5,       -3.3, 17.2);
  mitk::FillVector3D(right,  widthInMM,          0, 0);
  mitk::FillVector3D(bottom,         0, heightInMM, 0);
  mitk::FillVector3D(normal,         0,          0, thicknessInMM);


  std::cout << "Creating TimeSlicedGeometry" <<std::endl;
  mitk::TimeSlicedGeometry::Pointer timeSlicedGeometry = mitk::TimeSlicedGeometry::New();
  if(timeSlicedGeometry.IsNull())
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  unsigned int numOfTimeSteps = 5;
  std::cout << "Testing TimeSlicedGeometry::Initialize(timesteps = " << numOfTimeSteps << "): " <<std::endl;
  timeSlicedGeometry->Initialize(numOfTimeSteps);
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing TimeSlicedGeometry::GetTimeSteps()==" << numOfTimeSteps << ": " <<std::endl;
  if(timeSlicedGeometry->GetTimeSteps()!=numOfTimeSteps)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing TimeSlicedGeometry::GetEvenlyTimed(): " <<std::endl;
  if(timeSlicedGeometry->GetEvenlyTimed()!=true)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;



  mitk::TimeBounds timeBounds1;
  timeBounds1[0] = 1.3;
  timeBounds1[1] = 2.4;

  std::cout << "Initializing a PlaneGeometry by InitializeStandardPlane(rightVector, downVector, spacing = NULL): "<<std::endl;
  planegeometry->InitializeStandardPlane(right.Get_vnl_vector(), bottom.Get_vnl_vector());
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Setting TimeBounds of PlaneGeometry by SetTimeBounds(): "<<std::endl;
  planegeometry->SetTimeBounds(timeBounds1);
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing PlaneGeometry::GetTimeBounds(): "<<std::endl;
  if(planegeometry->GetTimeBounds() != timeBounds1)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;


  --numOfTimeSteps;
  std::cout << "Testing TimeSlicedGeometry::InitializeEvenlyTimed(planegeometry, timesteps = " << numOfTimeSteps << "): " <<std::endl;
  mitk::TimeSlicedGeometry::Pointer timeSlicedGeometry2 = mitk::TimeSlicedGeometry::New();
  timeSlicedGeometry2->InitializeEvenlyTimed(planegeometry, numOfTimeSteps);
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing TimeSlicedGeometry::GetTimeSteps()==" << numOfTimeSteps << ": " <<std::endl;
  if(timeSlicedGeometry2->GetTimeSteps() != numOfTimeSteps)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing TimeSlicedGeometry::GetEvenlyTimed(): " <<std::endl;
  if(timeSlicedGeometry2->GetEvenlyTimed()!=true)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing TimeSlicedGeometry::TimeStepToMS(): " << std::endl;
  if(fabs(timeSlicedGeometry2->TimeStepToMS( 2 ) - 3.5) > mitk::eps)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing TimeSlicedGeometry::MSToTimeStep(): " << std::endl;
  if(timeSlicedGeometry2->MSToTimeStep( 3.6 ) != 2)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;


  std::cout << "Testing TimeSlicedGeometry::TimeStepToTimeStep(): " << std::endl;
  
  // Re-use timeSlicedGeometry with new time bounds
  mitk::TimeBounds timeBounds;
  timeBounds[0] = 0.0;
  timeBounds[1] = 1.0;
  mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New();
  geometry->Initialize();
  geometry->SetTimeBounds( timeBounds );
  timeSlicedGeometry->InitializeEvenlyTimed( geometry, numOfTimeSteps+1 ); 

  if(timeSlicedGeometry2->TimeStepToTimeStep( timeSlicedGeometry, 4 ) != 2)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing availability and type (PlaneGeometry) of first geometry in the TimeSlicedGeometry: ";
  mitk::PlaneGeometry* accessedplanegeometry = dynamic_cast<mitk::PlaneGeometry*>(timeSlicedGeometry2->GetGeometry3D(0));
  if(accessedplanegeometry==NULL)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing identity of first geometry to the planegeometry in the TimeSlicedGeometry (should not be cloned): ";
  if(accessedplanegeometry != planegeometry.GetPointer())
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing whether the spatial part of the first geometry in the TimeSlicedGeometry is identical to planegeometry by axis comparison and origin: "<<std::endl;
  if((mitk::Equal(accessedplanegeometry->GetAxisVector(0), planegeometry->GetAxisVector(0))==false) || 
     (mitk::Equal(accessedplanegeometry->GetAxisVector(1), planegeometry->GetAxisVector(1))==false) || 
     (mitk::Equal(accessedplanegeometry->GetAxisVector(2), planegeometry->GetAxisVector(2))==false) ||
     (mitk::Equal(accessedplanegeometry->GetOrigin(),      planegeometry->GetOrigin())==false))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing timebounds of first geometry: "<<std::endl;
  if( timeBounds1 != accessedplanegeometry->GetTimeBounds() )
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;



  std::cout << "Testing availability and type (PlaneGeometry) of second geometry in the TimeSlicedGeometry: ";
  mitk::PlaneGeometry* secondplanegeometry = dynamic_cast<mitk::PlaneGeometry*>(timeSlicedGeometry2->GetGeometry3D(1));
  if(secondplanegeometry==NULL)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing PlaneGeometry::GetTimeBounds(): "<<std::endl;
  const mitk::TimeBounds & secondtimebounds = secondplanegeometry->GetTimeBounds();
  if( (timeBounds1[1] != secondtimebounds[0]) || (secondtimebounds[1] != secondtimebounds[0] + timeBounds1[1]-timeBounds1[0]) )
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;


  std::cout << "Testing whether the spatial part of the second geometry in the TimeSlicedGeometry is identical to planegeometry by axis comparison and origin: "<<std::endl;
  if((mitk::Equal(secondplanegeometry->GetAxisVector(0), planegeometry->GetAxisVector(0))==false) || 
     (mitk::Equal(secondplanegeometry->GetAxisVector(1), planegeometry->GetAxisVector(1))==false) || 
     (mitk::Equal(secondplanegeometry->GetAxisVector(2), planegeometry->GetAxisVector(2))==false) ||
     (mitk::Equal(secondplanegeometry->GetOrigin(),      planegeometry->GetOrigin())==false))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  // non-evenly-timed
  std::cout << "Creating (new) TimeSlicedGeometry" <<std::endl;
  timeSlicedGeometry2 = mitk::TimeSlicedGeometry::New();
  if(timeSlicedGeometry2.IsNull())
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  numOfTimeSteps += 7;
  std::cout << "Testing TimeSlicedGeometry::InitializeEmpty(timesteps = " << numOfTimeSteps << "): " <<std::endl;
  timeSlicedGeometry2->InitializeEmpty(numOfTimeSteps);

  std::cout << "Testing TimeSlicedGeometry::GetEvenlyTimed():" <<std::endl;
  if(timeSlicedGeometry2->GetEvenlyTimed()!=false)
  {
    std::cout<<"[FAILED]"<<std::endl; 
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing TimeSlicedGeometry::SetEvenlyTimed(false):" <<std::endl;
  timeSlicedGeometry2->SetEvenlyTimed(false);
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing TimeSlicedGeometry::GetEvenlyTimed()==false:" <<std::endl;
  if(timeSlicedGeometry2->GetEvenlyTimed()!=false)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing TimeSlicedGeometry::GetTimeSteps()==" << numOfTimeSteps << ": " <<std::endl;
  if(timeSlicedGeometry2->GetTimeSteps() != numOfTimeSteps)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing availability of first geometry in the TimeSlicedGeometry (should not exist): ";
  mitk::Geometry3D* accessedgeometry = timeSlicedGeometry2->GetGeometry3D(0);
  if(accessedgeometry!=NULL)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing TimeSlicedGeometry::SetGeometry3D(planegeometry, timesteps = 0): " <<std::endl;
  timeSlicedGeometry2->SetGeometry3D(planegeometry, 0);
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing availability and type (PlaneGeometry) of first geometry in the TimeSlicedGeometry: ";
  accessedplanegeometry = dynamic_cast<mitk::PlaneGeometry*>(timeSlicedGeometry2->GetGeometry3D(0));
  if(accessedplanegeometry==NULL)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing identity of first geometry to the planegeometry in the TimeSlicedGeometry: ";
  if(accessedplanegeometry != planegeometry.GetPointer())
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;



  std::cout << "Testing availability of second geometry in the TimeSlicedGeometry (should not exist): ";
  accessedgeometry = timeSlicedGeometry2->GetGeometry3D(1);
  if(accessedgeometry!=NULL)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;


  std::cout << "Setting planegeometry2 to a cloned version of planegeometry: "<<std::endl;
  mitk::PlaneGeometry::Pointer planegeometry2;
  planegeometry2 = dynamic_cast<mitk::PlaneGeometry*>(planegeometry->Clone().GetPointer());;
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Changing timebounds of planegeometry2: "<<std::endl;
  mitk::TimeBounds timeBounds3;
  timeBounds3[0] = timeBounds[1];
  timeBounds3[1] = timeBounds3[0]+13.2334;
  planegeometry2->SetTimeBounds(timeBounds3);
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing TimeSlicedGeometry::SetGeometry3D(planegeometry2, timesteps = 1): " <<std::endl;
  timeSlicedGeometry2->SetGeometry3D(planegeometry2, 1);
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing availability and type (PlaneGeometry) of second geometry in the TimeSlicedGeometry: ";
  accessedplanegeometry = dynamic_cast<mitk::PlaneGeometry*>(timeSlicedGeometry2->GetGeometry3D(1));
  if(accessedplanegeometry==NULL)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing identity of second geometry to the planegeometry2 in the TimeSlicedGeometry: ";
  if(accessedplanegeometry != planegeometry2.GetPointer())
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout << "Testing timebounds of second geometry: "<<std::endl;
  if( timeBounds3 != accessedplanegeometry->GetTimeBounds() )
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;


  std::cout<<"[TEST DONE]"<<std::endl;
  return EXIT_SUCCESS;
}
int mitkTransferFunctionTest ( int  ,
char *  [] 
)

Unit test for class mitk::TransferFunction.

argc and argv are the command line parameters which were passed to the ADD_TEST command in the CMakeLists.txt file. For the automatic tests, argv is either empty for the simple tests or contains the filename of a test image for the image tests (see CMakeLists.txt).

Definition at line 33 of file mitkTransferFunctionTest.cpp.

References MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, mitk::TransferFunctionInitializer::New(), and mitk::TransferFunction::New().

{
  // always start with this!
  MITK_TEST_BEGIN("TransferFunction");

  // let's create an object of our class  
  mitk::TransferFunction::Pointer myTransferFunction = mitk::TransferFunction::New();

  // first test: did this work?
  // using MITK_TEST_CONDITION_REQUIRED makes the test stop after failure, since
  // it makes no sense to continue without an object.
  MITK_TEST_CONDITION_REQUIRED( myTransferFunction.IsNotNull(), "Testing instantiation" );

  /*************************************************************************/
  // Create and set control point arrays for scalar opacity transfer function
  mitk::TransferFunction::ControlPoints scalarOpacityPoints;
  scalarOpacityPoints.push_back( std::make_pair( 0.0, 0.0 ) );
  scalarOpacityPoints.push_back( std::make_pair( 5.0, 0.3 ) );
  scalarOpacityPoints.push_back( std::make_pair( 10.0, 1.0 ) );
  myTransferFunction->SetScalarOpacityPoints( scalarOpacityPoints );
  MITK_TEST_CONDITION_REQUIRED(
    myTransferFunction->GetScalarOpacityFunction()->GetSize() == 3,
    "Adding three point/value pairs to scalar opacity transfer function via VTK interface" );

  // Create and set control point arrays for gradient opacity transfer function
  mitk::TransferFunction::ControlPoints gradientOpacityPoints;
  gradientOpacityPoints.push_back( std::make_pair( 0.0, 0.2 ) );
  gradientOpacityPoints.push_back( std::make_pair( 3.0, 0.7 ) );
  gradientOpacityPoints.push_back( std::make_pair( 7.0, 0.8 ) );
  gradientOpacityPoints.push_back( std::make_pair( 15.0, 0.9 ) );
  myTransferFunction->SetGradientOpacityPoints( gradientOpacityPoints );
  MITK_TEST_CONDITION_REQUIRED(
    myTransferFunction->GetGradientOpacityFunction()->GetSize() == 4,
    "Adding four point/value pairs to gradient opacity transfer function via VTK interface" );

  // Create and set control point arrays for color transfer function
  mitk::TransferFunction::RGBControlPoints colorPoints;
  itk::RGBPixel< double > rgb0, rgb1, rgb2, rgb3;
  rgb0[0] = 0.1f; rgb0[1] = 0.3f; rgb0[2] = 0.5f;
  colorPoints.push_back( std::make_pair( 2.0, rgb0 ) );
  rgb1[0] = 0.3; rgb1[1] = 0.8; rgb1[2] = 0.9;
  colorPoints.push_back( std::make_pair( 3.0, rgb1 ) );
  rgb2[0] = 0.6; rgb2[1] = 0.5; rgb2[2] = 0.4;
  colorPoints.push_back( std::make_pair( 4.0, rgb2 ) );
  rgb3[0] = 0.7; rgb3[1] = 0.1; rgb3[2] = 0.2;
  colorPoints.push_back( std::make_pair( 5.0, rgb3 ) );

  myTransferFunction->SetRGBPoints( colorPoints );
  MITK_TEST_CONDITION_REQUIRED(
    myTransferFunction->GetColorTransferFunction()->GetSize() == 4,
    "Adding four point/value pairs to color transfer function via VTK interface" );


  /*************************************************************************/
  // Add a new point to scalar opacity transfer function
  myTransferFunction->AddScalarOpacityPoint( 3.0, 0.2 );
  MITK_TEST_CONDITION_REQUIRED(
    myTransferFunction->GetScalarOpacityFunction()->GetSize() == 4,
    "Adding new point/value to scalar opacity transfer function via MITK interface" );

  // Add a new point to gradient opacity transfer function
  myTransferFunction->AddGradientOpacityPoint( 19.0, 1.0 );
  MITK_TEST_CONDITION_REQUIRED(
    myTransferFunction->GetGradientOpacityFunction()->GetSize() == 5,
    "Adding new point/value to gradient opacity transfer function via MITK interface" );

  // Add a new point to color transfer function
  myTransferFunction->AddRGBPoint( 1.0, 0.0, 0.1, 0.2 );
  MITK_TEST_CONDITION_REQUIRED(
    myTransferFunction->GetColorTransferFunction()->GetSize() == 5,
    "Adding new point/value to color transfer function via MITK interface" );
  

  /*************************************************************************/
  // Retrieve two points from scalar opacity transfer function
  double v1, v2;
  v1 = myTransferFunction->GetScalarOpacityFunction()->GetValue( 3.0 );
  v2 = myTransferFunction->GetScalarOpacityFunction()->GetValue( 10.0 );
  MITK_TEST_CONDITION_REQUIRED(
    (fabs( v1 - 0.2 ) < 1.0e-5) && (fabs( v2 - 1.0 ) < 1.0e-5),
    "Retrieving values at two points from scalar opacity transfer function" );

  // Retrieve two points from gradient opacity transfer function
  v1 = myTransferFunction->GetGradientOpacityFunction()->GetValue( 0.0 );
  v2 = myTransferFunction->GetGradientOpacityFunction()->GetValue( 19.0 );
  MITK_TEST_CONDITION_REQUIRED(
    (fabs( v1 - 0.2 ) < 1.0e-5) && (fabs( v2 - 1.0 ) < 1.0e-5),
    "Retrieving values at two points from gradient opacity transfer function" );

  // Retrieve two points from color transfer function
  vtkFloatingPointType vrgb1[3], vrgb2[3];
  myTransferFunction->GetColorTransferFunction()->GetColor( 1.0, vrgb1 );
  myTransferFunction->GetColorTransferFunction()->GetColor( 4.0, vrgb2 );
  std::cout << vrgb2[0] << ", " << vrgb2[1] << ", " << vrgb2[2] << std::endl;
  MITK_TEST_CONDITION_REQUIRED(
       (fabs( vrgb1[0] - 0.0 ) < 1.0e-5)
    && (fabs( vrgb1[1] - 0.1 ) < 1.0e-5)
    && (fabs( vrgb1[2] - 0.2 ) < 1.0e-5)
    && (fabs( vrgb2[0] - 0.6 ) < 1.0e-5)
    && (fabs( vrgb2[1] - 0.5 ) < 1.0e-5)
    && (fabs( vrgb2[2] - 0.4 ) < 1.0e-5),
    "Retrieving values at two points from color transfer function" );


  /*************************************************************************/
  // Remove point from scalar opacity transfer function (should return new
  // number of points)
  MITK_TEST_CONDITION_REQUIRED(
    myTransferFunction->RemoveScalarOpacityPoint( 3.0 ) == 1,
    "Removing point from scalar opacity transfer function (should return point index)" );
  
  // Remove point from scalar opacity transfer function (should return new
  // number of points)
  MITK_TEST_CONDITION_REQUIRED(
    myTransferFunction->RemoveGradientOpacityPoint( 0.0 ) == 0,
    "Removing point from gradient opacity transfer function (should return point index)" );

  // Remove point from color transfer function (should return new
  // number of points)
  MITK_TEST_CONDITION_REQUIRED(
    myTransferFunction->RemoveRGBPoint( 5.0 ) == 4,
    "Removing point from color transfer function (should return point ndex)" );


  /*************************************************************************/
  // Try to remove non-existing point from scalar opacity transfer function (should return -1)
  MITK_TEST_CONDITION_REQUIRED(
    myTransferFunction->RemoveScalarOpacityPoint( 2.5 ) == -1,
    "Trying to remove non-existing point from scalar opacity transfer function (should return -1)" );

  // Try to remove non-existing point from gradient opacity transfer function (should return -1)
  MITK_TEST_CONDITION_REQUIRED(
    myTransferFunction->RemoveGradientOpacityPoint( 2.5 ) == -1,
    "Trying to remove non-existing point from gradient opacity transfer function (should return -1)" );

  // Try to remove non-existing point from color transfer function (should return -1)
  MITK_TEST_CONDITION_REQUIRED(
    myTransferFunction->RemoveRGBPoint( 2.5 ) == -1,
    "Trying to remove non-existing point from color transfer function (should return -1)" );


  /*************************************************************************/
  // Retrieve copy of scalar opacity points (check for correct content and size)
  mitk::TransferFunction::ControlPoints newScalarOpacityPoints =
    myTransferFunction->GetScalarOpacityPoints();
  MITK_TEST_CONDITION_REQUIRED(
    (newScalarOpacityPoints.size() == 3)
    && (fabs(newScalarOpacityPoints[2].first - 10.0) < 1.0e-5)
    && (fabs(newScalarOpacityPoints[2].second - 1.0) < 1.0e-5),
    "Retrieving copy of scalar opacity points (checking for correct content and size)" );

  // Retrieve copy of gradient opacity points (check for correct content and size)
  mitk::TransferFunction::ControlPoints newGradientOpacityPoints =
    myTransferFunction->GetGradientOpacityPoints();
  MITK_TEST_CONDITION_REQUIRED(
    (newGradientOpacityPoints.size() == 4)
    && (fabs(newGradientOpacityPoints[3].first - 19.0) < 1.0e-5)
    && (fabs(newGradientOpacityPoints[3].second - 1.0) < 1.0e-5),
    "Retrieving copy of gradient opacity points (checking for correct content and size)" );

  // Retrieve copy of color transfer points (check for correct content and size)
  mitk::TransferFunction::RGBControlPoints newRGBPoints =
    myTransferFunction->GetRGBPoints();
  MITK_TEST_CONDITION_REQUIRED(
    (newRGBPoints.size() == 4)
    && (fabs(newRGBPoints[3].first - 4.0) < 1.0e-5)
    && (fabs(newRGBPoints[3].second[0] - 0.6) < 1.0e-5)
    && (fabs(newRGBPoints[3].second[1] - 0.5) < 1.0e-5)
    && (fabs(newRGBPoints[3].second[2] - 0.4) < 1.0e-5),
    "Retrieving copy of color transfer function points (checking for correct content and size)" );


  /*************************************************************************/
  // Clear scalar opacity points (resulting array should be empty)
  myTransferFunction->ClearScalarOpacityPoints();
  MITK_TEST_CONDITION_REQUIRED(
    myTransferFunction->GetScalarOpacityPoints().size() == 0,
    "Clearing scalar opacity points (resulting array should be empty)" );

  myTransferFunction->ClearGradientOpacityPoints();
  MITK_TEST_CONDITION_REQUIRED(
    myTransferFunction->GetGradientOpacityPoints().size() == 0,
    "Clearing gradient opacity points (resulting array should be empty)" );

  myTransferFunction->ClearRGBPoints();
  MITK_TEST_CONDITION_REQUIRED(
    myTransferFunction->GetRGBPoints().size() == 0,
    "Clearing color transfer function points (resulting array should be empty)" );

  /******************TRANSFERFUNCTION INITIALIZER TEST***************************/
  mitk::TransferFunction::Pointer dummyTransferFunction = mitk::TransferFunction::New();
  mitk::TransferFunctionInitializer::Pointer transferInit = mitk::TransferFunctionInitializer::New(dummyTransferFunction);
  MITK_TEST_CONDITION_REQUIRED(
    transferInit->GetTransferFunction().IsNotNull(),
    "Testing if Transferfunction is set" );
  MITK_TEST_CONDITION_REQUIRED(
    transferInit->GetTransferFunction() == dummyTransferFunction,
    "Testing if Transferfunction is the correct one" );

  transferInit->SetTransferFunction(myTransferFunction);

  MITK_TEST_CONDITION_REQUIRED(
    transferInit->GetTransferFunction().IsNotNull(),
    "Testing if Set Transferfunction works" );
  MITK_TEST_CONDITION_REQUIRED(
    transferInit->GetTransferFunction() == myTransferFunction,
    "Testing if Set Transferfunction sets the correct one" );
  
  const int size = 8;
  int arPointNumbers[size][3] = {{3,1,6},
                              {2,1,2},
                              {4,1,5},
                              {3,1,5},
                              {4,1,7},
                              {4,2,7},
                              {4,1,4},
                              {6,2,6}};

  std::string names[size] = {"SetDefaultMode",
                          "SetCtBlackWhiteMode",
                          "SetCtThoraxLargeMode",
                          "SetCtThoraxSmallMode",
                          "SetCtBoneMode",
                          "SetCtBoneGradientMode",
                          "SetCtCardiacMode",
                          "SetMrGenericMode"};

  for(int i =0; i<size; i++)
  {
  transferInit->SetTransferFunctionMode(i);
  
  std::cout << "Punkte: " << myTransferFunction->GetScalarOpacityFunction()->GetSize() << std::endl;
  MITK_TEST_CONDITION_REQUIRED(
    myTransferFunction->GetScalarOpacityFunction()->GetSize() == arPointNumbers[i][0],
    "Testing if in " << names[i] << " the Scalar Opacity Function is set" );  
  MITK_TEST_CONDITION_REQUIRED(
    myTransferFunction->GetGradientOpacityFunction()->GetSize() == arPointNumbers[i][1],
    "Testing if in " << names[i] << " the Gradient Opacity Function is set" );
  MITK_TEST_CONDITION_REQUIRED(
      myTransferFunction->GetColorTransferFunction()->GetSize() == arPointNumbers[i][2],
    "Testing if in " << names[i] << " the Color Transfer Function is set" );   
  }
  // always end with this!
  MITK_TEST_END()
}
int mitkTransitionTest ( int  ,
char *  [] 
)

Definition at line 24 of file mitkTransitionTest.cpp.

References EXIT_FAILURE, EXIT_SUCCESS, int(), mitk::State::New(), and mitk::Action::New().

{
  int nextStateId = 10;
  int eventId = 100;
  
  //Create Transition
  itk::WeakPointer<mitk::Transition> transition = new mitk::Transition("transitionname", nextStateId, eventId);

  //check nextStateId
  std::cout << "Check StateId: ";
  if (transition->GetNextStateId()!=nextStateId)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  //check EventId
  std::cout << "Check EventId: ";
  if (transition->GetEventId()!=eventId || !transition->IsEvent(eventId))
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  unsigned int count = 1;
  //Create Action
  mitk::Action::Pointer firstAction = mitk::Action::New(count);
  transition->AddAction(firstAction);

  //check ActionCount
  std::cout << "Check ActionCount after first addition of an action: ";
  if (transition->GetActionCount() != count)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;
  
  ++count;

  //Create Action
  mitk::Action::Pointer secondAction = mitk::Action::New(count);
  transition->AddAction(secondAction);

  //check ActionCount
  std::cout << "check action Count after second addition of an action: ";
  if (transition->GetActionCount() != count)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  count = 1;
  
  //check ActionIterators
  std::cout << "Check ActionIterators: ";
  mitk::Transition::ActionVectorIterator iter = transition->GetActionBeginIterator();
  mitk::Transition::ActionVectorConstIterator end = transition->GetActionEndIterator();
  while (iter != end)
  {
    if((*iter)->GetActionId()!=(int)count)
    {
      std::cout<<"[FAILED]"<<std::endl;
      return EXIT_FAILURE;
    }
    ++count;
    ++iter;
  }
  std::cout<<"[PASSED]"<<std::endl;

  //check setting State
  std::cout << "Check setting a statepointer and reading it again: ";
  int stateId = 10000;
  mitk::State::Pointer state = mitk::State::New("statename", stateId);
  transition->SetNextState(state);
  if (transition->GetNextState()!=state)
  {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  //delete the instanciated transition
  delete transition;

  //well done!!! Passed!
  std::cout<<"[ALL PASSED]"<<std::endl;

  std::cout<<"[TEST DONE]"<<std::endl;
  return EXIT_SUCCESS;
}
int mitkUndoControllerTest ( int  ,
char *  [] 
)

Simple example for a test for the (non-existent) class "UndoController".

argc and argv are the command line parameters which were passed to the ADD_TEST command in the CMakeLists.txt file. For the automatic tests, argv is either empty for the simple tests or contains the filename of a test image for the image tests (see CMakeLists.txt).

Definition at line 33 of file mitkUndoControllerTest.cpp.

References mitk::UndoController::AddUndoModel(), mitk::UndoController::GetCurrentUndoModel(), mitk::UndoController::LIMITEDLINEARUNDO, MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, mitk::UndoController::RemoveUndoModel(), mitk::UndoController::SwitchUndoModel(), and mitk::UndoController::VERBOSE_LIMITEDLINEARUNDO.

{
  // always start with this!
  MITK_TEST_BEGIN("UndoController")

  // let's create an object of our class  
  mitk::UndoController* myUndoController = new mitk::UndoController();

  // first test: did this work?
  // using MITK_TEST_CONDITION_REQUIRED makes the test stop after failure, since
  // it makes no sense to continue without an object.
  MITK_TEST_CONDITION_REQUIRED(myUndoController != NULL, "Testing instantiation") 

  //check default model (verbose...)
  mitk::VerboseLimitedLinearUndo::Pointer standardModel = dynamic_cast<mitk::VerboseLimitedLinearUndo*>(myUndoController->GetCurrentUndoModel());
  MITK_TEST_CONDITION_REQUIRED(standardModel.IsNotNull(),"Testing if the standard undo model VerboseLimitedLinearUndo is returned") 

  //switch to limitedlinearundomodel
  myUndoController->AddUndoModel(mitk::UndoController::LIMITEDLINEARUNDO);
  mitk::LimitedLinearUndo::Pointer linearModel = dynamic_cast<mitk::LimitedLinearUndo*>(myUndoController->GetCurrentUndoModel());
  MITK_TEST_CONDITION_REQUIRED(linearModel.IsNotNull(),"Testing to add and then to read a LimitedLinearUndoModel") 

  //switching to verbose again
  myUndoController->SwitchUndoModel(mitk::UndoController::VERBOSE_LIMITEDLINEARUNDO);
  mitk::VerboseLimitedLinearUndo::Pointer anotherVerboseModelPointer = dynamic_cast<mitk::VerboseLimitedLinearUndo*>(myUndoController->GetCurrentUndoModel());
  MITK_TEST_CONDITION_REQUIRED(standardModel == anotherVerboseModelPointer,"Testing to switch back again and to be sure, that the poiinters are the same") 

  //removing verbose; model should be switch to limited
  myUndoController->RemoveUndoModel(mitk::UndoController::VERBOSE_LIMITEDLINEARUNDO);
  mitk::LimitedLinearUndo::Pointer anotherLinearModel = dynamic_cast<mitk::LimitedLinearUndo*>(myUndoController->GetCurrentUndoModel());
  MITK_TEST_CONDITION_REQUIRED(linearModel == anotherLinearModel,"Testing to remove the VerboseLimitedLinearUndoModel and to automatically switch to LimitedLinearUndo") 

  //switch to limitedlinearundomodel
  myUndoController->AddUndoModel(mitk::UndoController::VERBOSE_LIMITEDLINEARUNDO);
  mitk::VerboseLimitedLinearUndo::Pointer newVerboseModelPointer = dynamic_cast<mitk::VerboseLimitedLinearUndo*>(myUndoController->GetCurrentUndoModel());
  MITK_TEST_CONDITION_REQUIRED(newVerboseModelPointer != standardModel,"Testing to add verbose model and if the new model is equal to the deleted one. Should not be the case!") 

  //removing boith models 
  myUndoController->RemoveUndoModel(mitk::UndoController::VERBOSE_LIMITEDLINEARUNDO);
  //should not detele, to maintain an UndoController with at least one UndoModel
  myUndoController->RemoveUndoModel(mitk::UndoController::LIMITEDLINEARUNDO);

  mitk::LimitedLinearUndo::Pointer limited = dynamic_cast<mitk::LimitedLinearUndo*>(myUndoController->GetCurrentUndoModel());
  MITK_TEST_CONDITION_REQUIRED(limited.IsNotNull(),"Testing to erase all models. Should be impossible to maintain a working model in UndoController")

  delete myUndoController;

  // always end with this!
  MITK_TEST_END()
}
int mitkVerboseLimitedLinearUndoTest ( int  ,
char *  [] 
)

Test of the LimitedLinearUndo object.

This test was motivated by bug 3248 which had to check memory leakage while using mitkOperations within the UndoMechanism. OperationObjects are added to the UndoController and stored within two lists (m_UndoList and m_RedoList) inside LimitedLinearUndo and derived from this VerboseLimitedLinearUndo. When using Undo during runtime operations are moved from UndoList to RedoList. In case of a new interaction, causing new operations to be stored in the UndoList the RedoList needs to be cleared. For this, the operations and all connected objects need to be deleted and memory to be freed. And this what this test checks!

argc and argv are the command line parameters which were passed to the ADD_TEST command in the CMakeLists.txt file. For the automatic tests, argv is either empty for the simple tests or contains the filename of a test image for the image tests (see CMakeLists.txt).

Definition at line 70 of file mitkVerboseLimitedLinearUndoTest.cpp.

References mitk::UndoController::Clear(), mitk::UndoController::ClearRedoList(), mitk::UndoStackItem::ExecuteIncrement(), g_GlobalCounter, mitk::UndoStackItem::IncCurrObjectEventId(), MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, mitk::OpTEST, mitk::UndoController::SetOperationEvent(), mitk::UndoController::SwitchUndoModel(), mitk::UndoController::Undo(), and mitk::UndoController::VERBOSE_LIMITEDLINEARUNDO.

{
  // always start with this!
  MITK_TEST_BEGIN("VerboseLimitedLinearUndo")

  // an UndoController for the management
  mitk::UndoController* myUndoController = new mitk::UndoController();

  //set model, even if it is verboseLimitedLinearUndo by default; this already is tested by UndoControllerTest!
  myUndoController->SwitchUndoModel(mitk::UndoController::VERBOSE_LIMITEDLINEARUNDO);

  for (int i = 0; i<2; i++)
  {
    mitk::TestOperation* doOp = new mitk::TestOperation(mitk::OpTEST);
    mitk::TestOperation *undoOp = new mitk::TestOperation(mitk::OpTEST);
    mitk::OperationEvent *operationEvent = new mitk::OperationEvent(NULL, doOp, undoOp, "Test");
    myUndoController->SetOperationEvent(operationEvent);
    //increase the ID to separate the operationEvents from each other. Otherwise they would be undone all together at once.
    mitk::OperationEvent::IncCurrObjectEventId();
    mitk::UndoStackItem::ExecuteIncrement();
  }

  //now 2 * 2 operation should have been instanciated
  MITK_TEST_CONDITION_REQUIRED(g_GlobalCounter == 4,"checking initialization of mitkOperation");

  //undo one operation; 1 operationEvent element in undo list, 1 in Redo list
  myUndoController->Undo(); 

  //sending two new OperationEvents: RedoList should be deleted and memory of operations freed
  for (int i = 0; i<2; i++)
  {
    mitk::TestOperation* doOp = new mitk::TestOperation(mitk::OpTEST);
    mitk::TestOperation *undoOp = new mitk::TestOperation(mitk::OpTEST);
    mitk::OperationEvent *operationEvent = new mitk::OperationEvent(NULL, doOp, undoOp, "Test");
    myUndoController->SetOperationEvent(operationEvent);
    //increase the ID to separate the operationEvents from each other. Otherwise they would be undone all together at once.
    mitk::OperationEvent::IncCurrObjectEventId();
    mitk::UndoStackItem::ExecuteIncrement();
  }
  
  //2 operations should have been deleted, 4 should have been added
  MITK_TEST_CONDITION_REQUIRED(g_GlobalCounter == 6,"checking adding of operations");
  
  //two operations to RedoList
  myUndoController->Undo(); 
  myUndoController->ClearRedoList();

  //one operationEvent containing 2 operations should have been deleted
  MITK_TEST_CONDITION_REQUIRED(g_GlobalCounter == 4,"checking deleting RedoList");

  //clear all
  myUndoController->Clear();
  MITK_TEST_CONDITION_REQUIRED(g_GlobalCounter == 0,"checking deleting all operations in UndoModel");

  //sending two new OperationEvents
  for (int i = 0; i<2; i++)
  {
    mitk::TestOperation* doOp = new mitk::TestOperation(mitk::OpTEST);
    mitk::TestOperation *undoOp = new mitk::TestOperation(mitk::OpTEST);
    mitk::OperationEvent *operationEvent = new mitk::OperationEvent(NULL, doOp, undoOp, "Test");
    myUndoController->SetOperationEvent(operationEvent);
    //increase the ID to separate the operationEvents from each other. Otherwise they would be undone all together at once.
    mitk::OperationEvent::IncCurrObjectEventId();
    mitk::UndoStackItem::ExecuteIncrement();
  }
  MITK_TEST_CONDITION_REQUIRED(g_GlobalCounter == 4,"checking added operations in UndoModel");

  delete myUndoController;

  //after deleting UndoController g_GlobalCounter will still be 4 because m_CurrentUndoModel inside myUndoModel is a static singleton
  MITK_TEST_CONDITION_REQUIRED(g_GlobalCounter == 4,"checking singleton UndoModel");

  // always end with this!
  MITK_TEST_END()
  //operations will be deleted after terminating the application
}
int mitkVtkWidgetRenderingTest ( int  ,
char *  [] 
)

Test for class mitk::VtkWidgetRendering (for rendering vtkWidgets on the screen)

argc and argv are the command line parameters which were passed to the ADD_TEST command in the CMakeLists.txt file. For the automatic tests, argv is either empty for the simple tests or contains the filename of a test image for the image tests (see CMakeLists.txt).

Definition at line 35 of file mitkVtkWidgetRenderingTest.cpp.

References MITK_TEST_BEGIN, MITK_TEST_CONDITION, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, and mitk::VtkWidgetRendering::New().

{
  // always start with this!
  MITK_TEST_BEGIN("mitkVTKWidgetRenderingTest")

  // Test: instantiation
  mitk::VtkWidgetRendering::Pointer widgetRendering = mitk::VtkWidgetRendering::New();
  MITK_TEST_CONDITION_REQUIRED(widgetRendering.IsNotNull(),"Testing instantiation") 

  // Test: Create and set vtkRenderWindow
  vtkRenderWindow *renderWindow = vtkRenderWindow::New();
  //mitk::VtkPropRenderer::Pointer propRenderer = mitk::VtkPropRenderer::New( "the renderer", renderWindow );
  //propRenderer->SetMapperID(2);
  widgetRendering->SetRenderWindow( renderWindow );
  MITK_TEST_CONDITION_REQUIRED(widgetRendering->GetRenderWindow() == renderWindow,
    "Setting vtkRenderWindow...")

  // Test: Try to enable before widget has been set (should stay disabled)
  widgetRendering->Enable();
  MITK_TEST_CONDITION(!widgetRendering->IsEnabled(), 
    "Trying to enable widget rendering before setting widget")
  widgetRendering->Disable();

  // Test: Retrieve widget before it has been set (should return NULL)
  MITK_TEST_CONDITION(widgetRendering->GetVtkWidget() == NULL,
    "Trying to retrieve widget before it has been set")

  // Test: Create vtkWidget instance (vtkScalarWidget) and add it
  vtkScalarBarWidget *scalarBarWidget = vtkScalarBarWidget::New();
  widgetRendering->SetVtkWidget( scalarBarWidget );
  MITK_TEST_CONDITION(widgetRendering->GetVtkWidget() == scalarBarWidget,
    "Retrieving widget after it has been set")

  // Test: Try to enable widget rendering (should work now)
  widgetRendering->Enable();
  MITK_TEST_CONDITION(widgetRendering->IsEnabled(),
    "Enabling widget rendering")

  // Test: Try to disable widget rendering (should be disabled)
  widgetRendering->Disable();
  MITK_TEST_CONDITION(!widgetRendering->IsEnabled(),
    "Disabling widget rendering")




  // Clean up
  scalarBarWidget->Delete();
  renderWindow->Delete();
  

  // write your own tests here and use the macros from mitkTestingMacros.h !!!
  // do not write to std::cout and do not return from this function yourself!
  
  // always end with this!
  MITK_TEST_END()
}
int mitkWeakPointerTest ( int  ,
char *  [] 
)

Definition at line 23 of file mitkWeakPointerTest.cpp.

References mitk::WeakPointer< TObjectType >::IsNull(), MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, and MITK_TEST_END.

{

  MITK_TEST_BEGIN("WeakPointer")

  mitk::WeakPointer<itk::Object> weakPointer;
  mitk::WeakPointer<itk::Object> weakPointer2;

  // Testing constructors and reference counting
  itk::Object::Pointer smartPointer = itk::Object::New();
  mitk::WeakPointer<itk::Object> weakPointer3(smartPointer);
  mitk::WeakPointer<itk::Object> weakPointer4(weakPointer);
  {
    itk::Object::Pointer tmpSmartPointer(weakPointer);
    itk::Object::Pointer tmpSmartPointer2(weakPointer2);
    MITK_TEST_CONDITION_REQUIRED(tmpSmartPointer.GetPointer() == tmpSmartPointer2.GetPointer(), "Testing equal pointers");
  }

  weakPointer = smartPointer;
  weakPointer2 = weakPointer;

  MITK_TEST_CONDITION_REQUIRED(1 == smartPointer->GetReferenceCount(), "Testing reference count");
  smartPointer = 0;
  MITK_TEST_CONDITION_REQUIRED(weakPointer.IsNull(), "Testing expired weak pointer (smart pointer assignment)");
  MITK_TEST_CONDITION_REQUIRED(weakPointer2.IsNull(), "Testing expired weak pointer (weak pointer assignment)");
  MITK_TEST_CONDITION_REQUIRED(weakPointer3.IsNull(), "Testing expired weak pointer (smart pointer constructor)");
  MITK_TEST_CONDITION_REQUIRED(weakPointer4.IsNull(), "Testing expired weak pointer (copy constructor)")

  MITK_TEST_END()
}
int vtkMitkThickSlicesFilterTest ( int  ,
char *  [] 
)

todo

Definition at line 79 of file vtkMitkThickSlicesFilterTest.cpp.

References CheckResultImageForTSFilter(), GenerateTestImageForTSFilter(), MITK_TEST_BEGIN, MITK_TEST_END, vtkMitkThickSlicesFilter::New(), and vtkMitkThickSlicesFilter::SetThickSliceMode().

{
  MITK_TEST_BEGIN("ThickSlicesFilter")

  vtkImageData *i,*o;
  
  i = GenerateTestImageForTSFilter();

  vtkMitkThickSlicesFilter *f = vtkMitkThickSlicesFilter::New();
  f->SetThickSliceMode( 0 ); // MIP
  f->SetInput( i );
  f->Update();
  o = f->GetOutput();
  
  CheckResultImageForTSFilter(o);

  //Delete vtk variable correctly
  i->Delete();
  f->Delete();
  
  MITK_TEST_END()
}

Variable Documentation

Definition at line 75 of file MitkTestDriver.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines