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
mitkImageToUnstructuredGridFilterTest.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"
19 #include <mitkTestFixture.h>
20 
21 #include <mitkIOUtil.h>
22 
23 class mitkImageToUnstructuredGridFilterTestSuite : public mitk::TestFixture
24 {
25  CPPUNIT_TEST_SUITE(mitkImageToUnstructuredGridFilterTestSuite);
26  MITK_TEST(testImageToUnstructuredGridFilterInitialization);
27  MITK_TEST(testInput);
28  MITK_TEST(testUnstructuredGridGeneration);
29  MITK_TEST(testThreshold);
30  CPPUNIT_TEST_SUITE_END();
31 
32 private:
34  mitk::Image::Pointer m_BallImage;
35 
36 public:
41  void setUp() override { m_BallImage = mitk::IOUtil::LoadImage(GetTestDataFilePath("BallBinary30x30x30.nrrd")); }
42  void testImageToUnstructuredGridFilterInitialization()
43  {
45  CPPUNIT_ASSERT_MESSAGE("Testing instantiation of test object", testFilter.IsNotNull());
46  CPPUNIT_ASSERT_MESSAGE("Testing initialization of threshold member variable", testFilter->GetThreshold() == -0.1);
47  }
48 
49  void testInput()
50  {
52  testFilter->SetInput(m_BallImage);
53  CPPUNIT_ASSERT_MESSAGE("Testing set / get input!", testFilter->GetInput() == m_BallImage);
54  }
55 
56  void testUnstructuredGridGeneration()
57  {
59  testFilter->SetInput(m_BallImage);
60  testFilter->Update();
61  CPPUNIT_ASSERT_MESSAGE("Testing UnstructuredGrid generation!", testFilter->GetOutput() != NULL);
62  }
63 
64  void testThreshold()
65  {
67  testFilter1->SetInput(m_BallImage);
68  testFilter1->Update();
69 
70  int numberOfPoints1 = testFilter1->GetNumberOfExtractedPoints();
71 
73  testFilter2->SetInput(m_BallImage);
74  testFilter2->SetThreshold(1.0);
75  testFilter2->Update();
76 
77  int numberOfPoints2 = testFilter2->GetNumberOfExtractedPoints();
78 
79  CPPUNIT_ASSERT_MESSAGE("Testing Threshold", numberOfPoints1 > numberOfPoints2);
80  }
81 };
82 
83 MITK_TEST_SUITE_REGISTRATION(mitkImageToUnstructuredGridFilter)
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
static std::string GetTestDataFilePath(const std::string &testData)
Get the absolute path for test data.
Test fixture for parameterized tests.
static Pointer New()
static mitk::Image::Pointer LoadImage(const std::string &path)
LoadImage Convenience method to load an arbitrary mitkImage.
Definition: mitkIOUtil.cpp:597