Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkUnstructuredGridToUnstructuredGridFilterTest.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 #include "mitkTestingMacros.h"
18 #include <mitkTestFixture.h>
19 #include <mitkUnstructuredGrid.h>
21 
22 #include <mitkIOUtil.h>
23 
24 #include <vtkDebugLeaks.h>
25 #include <vtkPoints.h>
26 #include <vtkSmartPointer.h>
27 #include <vtkUnstructuredGrid.h>
28 
29 class mitkUnstructuredGridToUnstructuredGridFilterTestSuite : public mitk::TestFixture
30 {
31  CPPUNIT_TEST_SUITE(mitkUnstructuredGridToUnstructuredGridFilterTestSuite);
32 
33  vtkDebugLeaks::SetExitError(0);
34 
35  MITK_TEST(testUnstructuredGridToUnstructuredGridFilterInitialization);
36  MITK_TEST(testInput);
37  MITK_TEST(testMultipleInputs);
38  MITK_TEST(testUnstructuredGridGeneration);
39  CPPUNIT_TEST_SUITE_END();
40 
41 private:
42  mitk::UnstructuredGrid::Pointer m_UnstructuredGrid;
43  mitk::UnstructuredGrid::Pointer m_2ndUnstructuredGrid;
44 
45 public:
46  void setUp() override
47  {
48  m_UnstructuredGrid = mitk::UnstructuredGrid::New();
49  m_2ndUnstructuredGrid = mitk::UnstructuredGrid::New();
50  vtkSmartPointer<vtkUnstructuredGrid> vtkGrid = vtkSmartPointer<vtkUnstructuredGrid>::New();
51  vtkSmartPointer<vtkUnstructuredGrid> vtkGrid2 = vtkSmartPointer<vtkUnstructuredGrid>::New();
52  vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
53  vtkSmartPointer<vtkPoints> points2 = vtkSmartPointer<vtkPoints>::New();
54 
55  for (int i = 0; i < 3; i++)
56  {
57  for (int j = 0; j < 3; j++)
58  {
59  for (int k = 0; k < 3; k++)
60  {
61  mitk::Point3D point;
62  point[0] = i;
63  point[1] = j;
64  point[2] = k;
65 
66  points->InsertNextPoint(point[0], point[1], point[2]);
67  points2->InsertNextPoint(point[0] + 5, point[1] + 5, point[2] + 5);
68  }
69  }
70  }
71 
72  vtkGrid->SetPoints(points);
73  vtkGrid2->SetPoints(points2);
74  m_UnstructuredGrid->SetVtkUnstructuredGrid(vtkGrid);
75  m_2ndUnstructuredGrid->SetVtkUnstructuredGrid(vtkGrid2);
76  }
77 
78  void testUnstructuredGridToUnstructuredGridFilterInitialization()
79  {
82  CPPUNIT_ASSERT_MESSAGE("Testing instantiation of test object", testFilter.IsNotNull());
83  }
84 
85  void testInput()
86  {
89  testFilter->SetInput(m_UnstructuredGrid);
90  CPPUNIT_ASSERT_MESSAGE("Testing set / get input!", testFilter->GetInput() == m_UnstructuredGrid);
91  }
92 
93  void testMultipleInputs()
94  {
97  testFilter->SetInput(0, m_UnstructuredGrid);
98  testFilter->SetInput(1, m_2ndUnstructuredGrid);
99  CPPUNIT_ASSERT_MESSAGE("Testing first input!", testFilter->GetInput(0) == m_UnstructuredGrid);
100  CPPUNIT_ASSERT_MESSAGE("Testing second input!", testFilter->GetInput(1) == m_2ndUnstructuredGrid);
101  }
102 
103  void testUnstructuredGridGeneration()
104  {
107  testFilter->SetInput(m_UnstructuredGrid);
108  testFilter->Update();
109  CPPUNIT_ASSERT_MESSAGE("Testing unstructured grid generation!", testFilter->GetOutput() != NULL);
110  }
111 };
112 
113 MITK_TEST_SUITE_REGISTRATION(mitkUnstructuredGridToUnstructuredGridFilter)
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
static Pointer New()
Test fixture for parameterized tests.
static Pointer New()
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.