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

Function TestContourModelAPI

Modules/ContourModel/Testing/mitkContourModelTest.cpp:398–433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

396}
397
398static void TestContourModelAPI()
399{
400 mitk::ContourModel::Pointer contour1 = mitk::ContourModel::New();
401
402 mitk::Point3D p1;
403 p1[0] = -2;
404 p1[1] = 10;
405 p1[2] = 0;
406
407 contour1->AddVertex(p1);
408
409 // adding vertices should always copy the content and not store pointers or references.
410 MITK_TEST_CONDITION(&p1 != &(contour1->GetVertexAt(0)->Coordinates), "copied point");
411
412 mitk::Point3D p2;
413 p2[0] = -3;
414 p2[1] = 6;
415 p2[2] = -5;
416
417 contour1->AddVertex(p2);
418
419 // test use of setter and getter with const and non-const pointers
420 const mitk::ContourModel::VertexType *vertex = contour1->GetVertexAt(1);
421
422 MITK_TEST_CONDITION(contour1->GetIndex(vertex) == 1, "Get index");
423
424 auto *nonConstVertex = const_cast<mitk::ContourModel::VertexType *>(vertex);
425
426 MITK_TEST_CONDITION(contour1->GetIndex(nonConstVertex) == 1, "Get index non-const");
427
428 mitk::ContourModel::Pointer contour2 = mitk::ContourModel::New();
429
430 contour2->AddVertex(*(contour1->GetVertexAt(0)));
431
432 MITK_TEST_CONDITION(contour2->GetNumberOfVertices() == 1, "Add call with another contour");
433}
434
435static void TestClear()
436{

Callers 1

mitkContourModelTestFunction · 0.85

Calls 5

GetNumberOfVerticesMethod · 0.80
NewFunction · 0.50
AddVertexMethod · 0.45
GetVertexAtMethod · 0.45
GetIndexMethod · 0.45

Tested by

no test coverage detected