Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 // mitk includes
18 #include "mitkTestingMacros.h"
19 #include "mitkUnstructuredGrid.h"
20 
21 // vtk includes
22 #include "vtkUnstructuredGrid.h"
23 
28 int mitkUnstructuredGridTest(int /* argc */, char * /*argv*/ [])
29 {
30  // always start with this!
31  MITK_TEST_BEGIN("UnstructuredGrid")
32 
33  // let's create an object of our class
35  MITK_TEST_CONDITION_REQUIRED(testObject.IsNotNull(), "Testing instantiation")
36  MITK_TEST_CONDITION_REQUIRED(testObject->VerifyRequestedRegion(),
37  "Requested region verification after initialization!");
38 
39  // create a clone object
40  mitk::UnstructuredGrid::Pointer cloneObject = testObject->Clone();
41  MITK_TEST_CONDITION_REQUIRED(cloneObject.IsNotNull(), "Testing instantiation of clone")
42  MITK_TEST_CONDITION_REQUIRED(cloneObject->VerifyRequestedRegion(),
43  "Requested region verification after initialization of clone!");
44 
45  // set some grid data to the class
46  vtkUnstructuredGrid *grid = vtkUnstructuredGrid::New();
47  testObject->SetVtkUnstructuredGrid(grid);
48  MITK_TEST_CONDITION_REQUIRED(testObject->GetVtkUnstructuredGrid() == grid, "Testing Set/Get vtkUnstructuredGrid");
49 
50  // specify a region and set it to the test object
51  auto ugRegion = new mitk::UnstructuredGrid::RegionType;
52  mitk::UnstructuredGrid::RegionType::SizeType size;
53  size.Fill(100);
54 
55  mitk::UnstructuredGrid::RegionType::IndexType index;
56  index.Fill(0);
57 
58  ugRegion->SetSize(size);
59  ugRegion->SetIndex(index);
60  testObject->SetRequestedRegion(ugRegion);
61  testObject->UpdateOutputInformation();
62  MITK_TEST_CONDITION_REQUIRED(testObject->GetRequestedRegion().GetSize() == ugRegion->GetSize(),
63  "Testing Set/Get of Requested Region by RegionType1!");
64  MITK_TEST_CONDITION_REQUIRED(testObject->GetRequestedRegion().GetIndex() == ugRegion->GetIndex(),
65  "Testing Set/Get of Requested Region by RegionType2!");
66  // VerifyRequested Region should be false due to the chosen size parameter!
67  MITK_TEST_CONDITION_REQUIRED(!testObject->VerifyRequestedRegion(), "Requested Region verification!");
68 
70  copyObject->CopyInformation(testObject);
71  copyObject->SetRequestedRegion(testObject);
72  MITK_TEST_CONDITION_REQUIRED(copyObject->GetLargestPossibleRegion() == testObject->GetLargestPossibleRegion(),
73  "Testing generation of copy object");
74  MITK_TEST_CONDITION_REQUIRED(copyObject->GetRequestedRegion().GetSize() == ugRegion->GetSize(),
75  "Testing SetRequestedRegion by DataObject1");
76  MITK_TEST_CONDITION_REQUIRED(copyObject->GetRequestedRegion().GetIndex() == ugRegion->GetIndex(),
77  "Testing SetRequestedRegion by DataObject2");
78 
79  cloneObject = testObject->Clone();
80  MITK_TEST_CONDITION_REQUIRED(cloneObject->GetRequestedRegion() == testObject->GetRequestedRegion(),
81  "Testing region cloning!");
82  MITK_TEST_CONDITION_REQUIRED(cloneObject->GetVtkUnstructuredGrid() == grid,
83  "Testing Get/Set-VtkUnstructuredGrid cloning");
84  MITK_TEST_CONDITION_REQUIRED(cloneObject->GetRequestedRegion().GetSize() == ugRegion->GetSize(),
85  "Testing Set/Get of Requested Region by RegionType1 in clone!");
86  MITK_TEST_CONDITION_REQUIRED(cloneObject->GetRequestedRegion().GetIndex() == ugRegion->GetIndex(),
87  "Testing Set/Get of Requested Region by RegionType2 in clone!");
88  // VerifyRequested Region should be false due to the chosen size parameter!
89  MITK_TEST_CONDITION_REQUIRED(!cloneObject->VerifyRequestedRegion(), "Requested Region verification!");
90 
91  // test this at the very end otherwise several other test cases need to be adapted!!
92  testObject->SetRequestedRegionToLargestPossibleRegion();
94  testObject->GetRequestedRegion().GetSize() == testObject->GetLargestPossibleRegion().GetSize(),
95  "Testing Set/Get LargestPossibleRegion!");
96 
97  // always end with this!
99 }
#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()
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.