Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkUnstructuredGridTest.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 // mitk includes
14 #include "mitkTestingMacros.h"
15 #include "mitkUnstructuredGrid.h"
16 
17 // vtk includes
18 #include "vtkUnstructuredGrid.h"
19 
24 int mitkUnstructuredGridTest(int /* argc */, char * /*argv*/ [])
25 {
26  // always start with this!
27  MITK_TEST_BEGIN("UnstructuredGrid")
28 
29  // let's create an object of our class
31  MITK_TEST_CONDITION_REQUIRED(testObject.IsNotNull(), "Testing instantiation")
32  MITK_TEST_CONDITION_REQUIRED(testObject->VerifyRequestedRegion(),
33  "Requested region verification after initialization!");
34 
35  // create a clone object
36  mitk::UnstructuredGrid::Pointer cloneObject = testObject->Clone();
37  MITK_TEST_CONDITION_REQUIRED(cloneObject.IsNotNull(), "Testing instantiation of clone")
38  MITK_TEST_CONDITION_REQUIRED(cloneObject->VerifyRequestedRegion(),
39  "Requested region verification after initialization of clone!");
40 
41  // set some grid data to the class
42  vtkUnstructuredGrid *grid = vtkUnstructuredGrid::New();
43  testObject->SetVtkUnstructuredGrid(grid);
44  MITK_TEST_CONDITION_REQUIRED(testObject->GetVtkUnstructuredGrid() == grid, "Testing Set/Get vtkUnstructuredGrid");
45 
46  // specify a region and set it to the test object
47  auto ugRegion = new mitk::UnstructuredGrid::RegionType;
48  mitk::UnstructuredGrid::RegionType::SizeType size;
49  size.Fill(100);
50 
51  mitk::UnstructuredGrid::RegionType::IndexType index;
52  index.Fill(0);
53 
54  ugRegion->SetSize(size);
55  ugRegion->SetIndex(index);
56  testObject->SetRequestedRegion(ugRegion);
57  testObject->UpdateOutputInformation();
58  MITK_TEST_CONDITION_REQUIRED(testObject->GetRequestedRegion().GetSize() == ugRegion->GetSize(),
59  "Testing Set/Get of Requested Region by RegionType1!");
60  MITK_TEST_CONDITION_REQUIRED(testObject->GetRequestedRegion().GetIndex() == ugRegion->GetIndex(),
61  "Testing Set/Get of Requested Region by RegionType2!");
62  // VerifyRequested Region should be false due to the chosen size parameter!
63  MITK_TEST_CONDITION_REQUIRED(!testObject->VerifyRequestedRegion(), "Requested Region verification!");
64 
66  copyObject->CopyInformation(testObject);
67  copyObject->SetRequestedRegion(testObject);
68  MITK_TEST_CONDITION_REQUIRED(copyObject->GetLargestPossibleRegion() == testObject->GetLargestPossibleRegion(),
69  "Testing generation of copy object");
70  MITK_TEST_CONDITION_REQUIRED(copyObject->GetRequestedRegion().GetSize() == ugRegion->GetSize(),
71  "Testing SetRequestedRegion by DataObject1");
72  MITK_TEST_CONDITION_REQUIRED(copyObject->GetRequestedRegion().GetIndex() == ugRegion->GetIndex(),
73  "Testing SetRequestedRegion by DataObject2");
74 
75  cloneObject = testObject->Clone();
76  MITK_TEST_CONDITION_REQUIRED(cloneObject->GetRequestedRegion() == testObject->GetRequestedRegion(),
77  "Testing region cloning!");
78  MITK_TEST_CONDITION_REQUIRED(cloneObject->GetVtkUnstructuredGrid() == grid,
79  "Testing Get/Set-VtkUnstructuredGrid cloning");
80  MITK_TEST_CONDITION_REQUIRED(cloneObject->GetRequestedRegion().GetSize() == ugRegion->GetSize(),
81  "Testing Set/Get of Requested Region by RegionType1 in clone!");
82  MITK_TEST_CONDITION_REQUIRED(cloneObject->GetRequestedRegion().GetIndex() == ugRegion->GetIndex(),
83  "Testing Set/Get of Requested Region by RegionType2 in clone!");
84  // VerifyRequested Region should be false due to the chosen size parameter!
85  MITK_TEST_CONDITION_REQUIRED(!cloneObject->VerifyRequestedRegion(), "Requested Region verification!");
86 
87  // test this at the very end otherwise several other test cases need to be adapted!!
88  testObject->SetRequestedRegionToLargestPossibleRegion();
90  testObject->GetRequestedRegion().GetSize() == testObject->GetLargestPossibleRegion().GetSize(),
91  "Testing Set/Get LargestPossibleRegion!");
92 
93  // always end with this!
95 }
#define MITK_TEST_CONDITION_REQUIRED(COND, MSG)
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
int mitkUnstructuredGridTest(int, char *[])
static Pointer New()
itk::ImageRegion< 5 > RegionType
and MITK_TEST_END()