17 #include <vtkCellArray.h> 18 #include <vtkPolyData.h> 19 #include <vtkPolyLine.h> 20 #include <vtkPolygon.h> 21 #include <vtkSmartPointer.h> 29 CPPUNIT_TEST_SUITE(mitkSurfaceEqualTestSuite);
30 MITK_TEST(Equal_CloneAndOriginalOneTimestep_ReturnsTrue);
31 MITK_TEST(Equal_CloneAndOriginalTwoTimesteps_ReturnsTrue);
32 MITK_TEST(Equal_OneTimeStepVSTwoTimeStep_ReturnsFalse);
33 MITK_TEST(Equal_TwoTimeStepsDifferentPoints_ReturnsFalse);
34 MITK_TEST(Equal_DifferentPoints_ReturnsFalse);
35 MITK_TEST(Equal_SurfaceWithPolygonSurfaceWithPolyLine_ReturnsFalse);
36 CPPUNIT_TEST_SUITE_END();
43 vtkSmartPointer<vtkPoints> m_PointsOne;
44 vtkSmartPointer<vtkPoints> m_PointsTwo;
45 vtkSmartPointer<vtkCellArray> m_PolygonArrayTwo;
46 vtkSmartPointer<vtkPolyData> m_PolyDataOne;
56 m_PointsOne = vtkSmartPointer<vtkPoints>::New();
57 m_PointsOne->InsertNextPoint(0.0, 0.0, 0.0);
58 m_PointsOne->InsertNextPoint(1.0, 0.0, 0.0);
59 m_PointsOne->InsertNextPoint(0.0, 1.0, 0.0);
60 m_PointsOne->InsertNextPoint(1.0, 1.0, 0.0);
62 m_PointsTwo = vtkSmartPointer<vtkPoints>::New();
63 m_PointsTwo->InsertNextPoint(0.0, 0.0, 0.0);
64 m_PointsTwo->InsertNextPoint(0.0, 0.0, 2.0);
65 m_PointsTwo->InsertNextPoint(0.0, 1.0, 0.0);
66 m_PointsTwo->InsertNextPoint(0.0, 1.0, 2.0);
69 vtkSmartPointer<vtkPolygon> polygonOne = vtkSmartPointer<vtkPolygon>::New();
70 polygonOne->GetPointIds()->SetNumberOfIds(4);
71 polygonOne->GetPointIds()->SetId(0, 0);
72 polygonOne->GetPointIds()->SetId(1, 1);
73 polygonOne->GetPointIds()->SetId(2, 2);
74 polygonOne->GetPointIds()->SetId(3, 3);
76 vtkSmartPointer<vtkPolygon> polygonTwo = vtkSmartPointer<vtkPolygon>::New();
77 polygonTwo->GetPointIds()->SetNumberOfIds(4);
78 polygonTwo->GetPointIds()->SetId(0, 3);
79 polygonTwo->GetPointIds()->SetId(1, 2);
80 polygonTwo->GetPointIds()->SetId(2, 0);
81 polygonTwo->GetPointIds()->SetId(3, 1);
84 vtkSmartPointer<vtkCellArray> polygonArrayOne = vtkSmartPointer<vtkCellArray>::New();
85 polygonArrayOne->InsertNextCell(polygonOne);
87 m_PolyDataOne = vtkSmartPointer<vtkPolyData>::New();
88 m_PolyDataOne->SetPoints(m_PointsOne);
89 m_PolyDataOne->SetPolys(polygonArrayOne);
91 m_PolygonArrayTwo = vtkSmartPointer<vtkCellArray>::New();
92 m_PolygonArrayTwo->InsertNextCell(polygonTwo);
94 vtkSmartPointer<vtkPolyData> polyDataTwo = vtkSmartPointer<vtkPolyData>::New();
95 polyDataTwo->SetPoints(m_PointsOne);
96 polyDataTwo->SetPolys(m_PolygonArrayTwo);
100 m_Surface3D->SetVtkPolyData(m_PolyDataOne);
103 m_Surface3DTwoTimeSteps->SetVtkPolyData(m_PolyDataOne, 0);
104 m_Surface3DTwoTimeSteps->SetVtkPolyData(polyDataTwo, 1);
107 void tearDown()
override 109 m_Surface3D =
nullptr;
110 m_Surface3DTwoTimeSteps =
nullptr;
111 m_PolyDataOne =
nullptr;
112 m_PolygonArrayTwo =
nullptr;
113 m_PointsOne =
nullptr;
114 m_PointsTwo =
nullptr;
117 void Equal_CloneAndOriginalOneTimestep_ReturnsTrue()
119 MITK_ASSERT_EQUAL(m_Surface3D, m_Surface3D->Clone(),
"A one timestep clone should be equal to its original.");
122 void Equal_CloneAndOriginalTwoTimesteps_ReturnsTrue()
125 m_Surface3DTwoTimeSteps->Clone(),
126 "A two timestep clone should be equal to its original.");
129 void Equal_OneTimeStepVSTwoTimeStep_ReturnsFalse()
132 m_Surface3D, m_Surface3DTwoTimeSteps,
"A one timestep and two timestep surface should not be equal.");
135 void Equal_TwoTimeStepsDifferentPoints_ReturnsFalse()
137 vtkSmartPointer<vtkPolyData> polyDataDifferentPoints = vtkSmartPointer<vtkPolyData>::New();
138 polyDataDifferentPoints->SetPoints(m_PointsTwo);
139 polyDataDifferentPoints->SetPolys(m_PolygonArrayTwo);
142 surface3DTwoTimeStepsDifferentPoints->SetVtkPolyData(m_PolyDataOne, 0);
143 surface3DTwoTimeStepsDifferentPoints->SetVtkPolyData(polyDataDifferentPoints, 1);
147 m_Surface3DTwoTimeSteps,
148 "A surface with the same timesteps and different points should not be equal.");
151 void Equal_SurfaceWithPolygonSurfaceWithPolyLine_ReturnsFalse()
154 vtkSmartPointer<vtkPolyLine> polyLineOne = vtkSmartPointer<vtkPolyLine>::New();
155 polyLineOne->GetPointIds()->SetNumberOfIds(2);
156 polyLineOne->GetPointIds()->SetId(0, 0);
157 polyLineOne->GetPointIds()->SetId(1, 1);
159 vtkSmartPointer<vtkCellArray> polyLineArrayOne = vtkSmartPointer<vtkCellArray>::New();
160 polyLineArrayOne->InsertNextCell(polyLineOne);
162 vtkSmartPointer<vtkPolyData> polyDataLine = vtkSmartPointer<vtkPolyData>::New();
163 polyDataLine->SetPoints(m_PointsOne);
164 polyDataLine->SetLines(polyLineArrayOne);
167 surface3DLine->SetVtkPolyData(polyDataLine);
171 "A surface with the same timesteps and points and the same " 172 "number of cells, but different types of cells should not be " 176 void Equal_DifferentPoints_ReturnsFalse()
180 surfaceWithADifferentPoint->GetVtkPolyData()->SetPoints(m_PointsTwo);
183 surfaceWithADifferentPoint,
184 "A surface with a single timestep and different points should not be equal.");
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
#define MITK_ASSERT_NOT_EQUAL(OBJ1, OBJ2, MSG)
Testing macro to test if two objects are not equal.
Test fixture for parameterized tests.
#define MITK_ASSERT_EQUAL(EXPECTED, ACTUAL, MSG)
Testing macro to test if two objects are equal.