21 #include <vtkCellArray.h>
22 #include <vtkPolyData.h>
23 #include <vtkPolyLine.h>
24 #include <vtkPolygon.h>
25 #include <vtkSmartPointer.h>
33 CPPUNIT_TEST_SUITE(mitkSurfaceEqualTestSuite);
34 MITK_TEST(Equal_CloneAndOriginalOneTimestep_ReturnsTrue);
35 MITK_TEST(Equal_CloneAndOriginalTwoTimesteps_ReturnsTrue);
36 MITK_TEST(Equal_OneTimeStepVSTwoTimeStep_ReturnsFalse);
37 MITK_TEST(Equal_TwoTimeStepsDifferentPoints_ReturnsFalse);
38 MITK_TEST(Equal_DifferentPoints_ReturnsFalse);
39 MITK_TEST(Equal_SurfaceWithPolygonSurfaceWithPolyLine_ReturnsFalse);
40 CPPUNIT_TEST_SUITE_END();
47 vtkSmartPointer<vtkPoints> m_PointsOne;
48 vtkSmartPointer<vtkPoints> m_PointsTwo;
49 vtkSmartPointer<vtkCellArray> m_PolygonArrayTwo;
50 vtkSmartPointer<vtkPolyData> m_PolyDataOne;
61 m_PointsOne->InsertNextPoint(0.0, 0.0, 0.0);
62 m_PointsOne->InsertNextPoint(1.0, 0.0, 0.0);
63 m_PointsOne->InsertNextPoint(0.0, 1.0, 0.0);
64 m_PointsOne->InsertNextPoint(1.0, 1.0, 0.0);
67 m_PointsTwo->InsertNextPoint(0.0, 0.0, 0.0);
68 m_PointsTwo->InsertNextPoint(0.0, 0.0, 2.0);
69 m_PointsTwo->InsertNextPoint(0.0, 1.0, 0.0);
70 m_PointsTwo->InsertNextPoint(0.0, 1.0, 2.0);
74 polygonOne->GetPointIds()->SetNumberOfIds(4);
75 polygonOne->GetPointIds()->SetId(0, 0);
76 polygonOne->GetPointIds()->SetId(1, 1);
77 polygonOne->GetPointIds()->SetId(2, 2);
78 polygonOne->GetPointIds()->SetId(3, 3);
81 polygonTwo->GetPointIds()->SetNumberOfIds(4);
82 polygonTwo->GetPointIds()->SetId(0, 3);
83 polygonTwo->GetPointIds()->SetId(1, 2);
84 polygonTwo->GetPointIds()->SetId(2, 0);
85 polygonTwo->GetPointIds()->SetId(3, 1);
89 polygonArrayOne->InsertNextCell(polygonOne);
92 m_PolyDataOne->SetPoints(m_PointsOne);
93 m_PolyDataOne->SetPolys(polygonArrayOne);
96 m_PolygonArrayTwo->InsertNextCell(polygonTwo);
99 polyDataTwo->SetPoints(m_PointsOne);
100 polyDataTwo->SetPolys(m_PolygonArrayTwo);
104 m_Surface3D->SetVtkPolyData(m_PolyDataOne);
107 m_Surface3DTwoTimeSteps->SetVtkPolyData(m_PolyDataOne, 0);
108 m_Surface3DTwoTimeSteps->SetVtkPolyData(polyDataTwo, 1);
111 void tearDown()
override
113 m_Surface3D =
nullptr;
114 m_Surface3DTwoTimeSteps =
nullptr;
115 m_PolyDataOne =
nullptr;
116 m_PolygonArrayTwo =
nullptr;
117 m_PointsOne =
nullptr;
118 m_PointsTwo =
nullptr;
121 void Equal_CloneAndOriginalOneTimestep_ReturnsTrue()
123 MITK_ASSERT_EQUAL(m_Surface3D, m_Surface3D->Clone(),
"A one timestep clone should be equal to its original.");
126 void Equal_CloneAndOriginalTwoTimesteps_ReturnsTrue()
129 m_Surface3DTwoTimeSteps->Clone(),
130 "A two timestep clone should be equal to its original.");
133 void Equal_OneTimeStepVSTwoTimeStep_ReturnsFalse()
136 m_Surface3D, m_Surface3DTwoTimeSteps,
"A one timestep and two timestep surface should not be equal.");
139 void Equal_TwoTimeStepsDifferentPoints_ReturnsFalse()
142 polyDataDifferentPoints->SetPoints(m_PointsTwo);
143 polyDataDifferentPoints->SetPolys(m_PolygonArrayTwo);
146 surface3DTwoTimeStepsDifferentPoints->SetVtkPolyData(m_PolyDataOne, 0);
147 surface3DTwoTimeStepsDifferentPoints->SetVtkPolyData(polyDataDifferentPoints, 1);
151 m_Surface3DTwoTimeSteps,
152 "A surface with the same timesteps and different points should not be equal.");
155 void Equal_SurfaceWithPolygonSurfaceWithPolyLine_ReturnsFalse()
159 polyLineOne->GetPointIds()->SetNumberOfIds(2);
160 polyLineOne->GetPointIds()->SetId(0, 0);
161 polyLineOne->GetPointIds()->SetId(1, 1);
164 polyLineArrayOne->InsertNextCell(polyLineOne);
167 polyDataLine->SetPoints(m_PointsOne);
168 polyDataLine->SetLines(polyLineArrayOne);
171 surface3DLine->SetVtkPolyData(polyDataLine);
175 "A surface with the same timesteps and points and the same "
176 "number of cells, but different types of cells should not be "
180 void Equal_DifferentPoints_ReturnsFalse()
184 surfaceWithADifferentPoint->GetVtkPolyData()->SetPoints(m_PointsTwo);
187 surfaceWithADifferentPoint,
188 "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.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.