MCPcopy Create free account
hub / github.com/MITK/MITK / TestAddVertex

Function TestAddVertex

Modules/ContourModel/Testing/mitkContourModelTest.cpp:16–51  ·  view source on GitHub ↗

Add a vertex to the contour and see if size changed

Source from the content-addressed store, hash-verified

14
15// Add a vertex to the contour and see if size changed
16static void TestAddVertex()
17{
18 mitk::ContourModel::Pointer contour = mitk::ContourModel::New();
19
20 mitk::Point3D p;
21 p[0] = p[1] = p[2] = 0;
22
23 contour->AddVertex(p);
24
25 MITK_TEST_CONDITION(contour->GetNumberOfVertices() == 1, "Add a Vertex, size increased");
26 MITK_TEST_CONDITION(contour->GetVertexAt(0)->Coordinates == p, "Added vertex has the correct value.");
27
28 mitk::Point3D outOfTimeBoundPoint;
29 outOfTimeBoundPoint[0] = outOfTimeBoundPoint[1] = outOfTimeBoundPoint[2] = 1;
30
31 contour->AddVertex(outOfTimeBoundPoint, mitk::TimeStepType(1));
32
33 MITK_TEST_CONDITION(contour->GetTimeSteps() == 1, "Add a vertex to an unsupported time step has not changed geometry.");
34 MITK_TEST_CONDITION(contour->IsEmptyTimeStep(1), "Add a vertex to an unsupported time step has not added an contour element.");
35 MITK_TEST_CONDITION(contour->GetNumberOfVertices(1) == -1, "Add a vertex to an unsupported time step has not added an contour element.");
36
37 contour->Expand(3);
38
39 mitk::Point3D p2;
40 p2[0] = p2[1] = p2[2] = 2;
41 mitk::Point3D p3;
42 p3[0] = p3[1] = p3[2] = 3;
43
44 contour->AddVertex(p2, mitk::TimeStepType(1));
45 contour->AddVertex(mitk::ContourModel::VertexType(p3), mitk::TimeStepType(1));
46
47 MITK_TEST_CONDITION(!contour->IsEmptyTimeStep(1), "Add a vertex to an unsupported time step has not added an contour element.");
48 MITK_TEST_CONDITION(contour->GetVertexAt(0,1)->Coordinates == p2, "Add a vertex to the 2nd time step (as Point).");
49 MITK_TEST_CONDITION(contour->GetVertexAt(1,1)->Coordinates == p3, "Add a vertex to the 2nd time step via overload (as vertex type).");
50 MITK_TEST_CONDITION(contour->GetNumberOfVertices(1) == 2, "Add a vertex to an unsupported time step has not added an contour element.");
51}
52
53// Select a vertex by index. successful if the selected vertex member of the contour is no longer set to null
54static void TestSelectVertexAtIndex()

Callers 1

mitkContourModelTestFunction · 0.70

Calls 7

GetNumberOfVerticesMethod · 0.80
GetTimeStepsMethod · 0.80
NewFunction · 0.50
AddVertexMethod · 0.45
GetVertexAtMethod · 0.45
IsEmptyTimeStepMethod · 0.45
ExpandMethod · 0.45

Tested by

no test coverage detected