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

Function mitkPlaneFitTest

Modules/AlgorithmsExt/test/mitkPlaneFitTest.cpp:21–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19#include <mitkPointSet.h>
20
21int mitkPlaneFitTest(int, char *[])
22{
23 // float bounds[]={0.0f,10.0f,0.0f,10.0f,0.0f,5.0f};
24
25 mitk::PlaneFit::Pointer PlaneFit = mitk::PlaneFit::New();
26 mitk::PointSet::Pointer PointSet = mitk::PointSet::New();
27
28 mitk::Point3D Point;
29
30 // first without any point, then incrementally add points within the points there will be a plane geometry
31 std::cout << "Start PlaneFitTest " << std::endl;
32 for (int position = 0; position < 6; position++)
33 {
34 // add a point directly
35 mitk::FillVector3D(Point, (float)position, (float)position * 1.5, 2.5);
36 PointSet->GetPointSet()->GetPoints()->InsertElement(position, Point);
37 }
38
39 // Set Input
40 PlaneFit->SetInput(PointSet);
41
42 const mitk::PointSet *testPointSet = PlaneFit->GetInput();
43 std::cout << " Size test of Input Method: ";
44 if (testPointSet->GetSize() == PointSet->GetSize())
45 {
46 std::cout << "[PASSED]" << std::endl;
47 }
48 else
49 {
50 std::cout << "[FAILED]" << std::endl;
51 return EXIT_FAILURE;
52 }
53
54 // Test Centroid
55 std::cout << " Testing centroid calculaation: ";
56 PlaneFit->Update();
57 const mitk::Point3D &centroid = PlaneFit->GetCentroid();
58 mitk::Point3D expectedCentroid;
59 expectedCentroid[0] = 2.5;
60 expectedCentroid[1] = 3.75;
61 expectedCentroid[2] = 2.5;
62
63 if (centroid == expectedCentroid)
64 {
65 std::cout << "[PASSED]" << std::endl;
66 }
67 else
68 {
69 std::cout << "[FAILED]" << std::endl;
70 return EXIT_FAILURE;
71 }
72
73 // Test PlaneGeometry
74 std::cout << " Test PlaneGeometry: ";
75 auto *PlaneGeometry = dynamic_cast<mitk::PlaneGeometry *>(PlaneFit->GetOutput()->GetGeometry());
76 if (PlaneGeometry)
77 {
78 std::cout << "[PASSED]" << std::endl;

Callers

nothing calls this directly

Calls 9

FillVector3DFunction · 0.85
GetGeometryMethod · 0.80
NewFunction · 0.50
GetPointSetMethod · 0.45
SetInputMethod · 0.45
GetInputMethod · 0.45
GetSizeMethod · 0.45
UpdateMethod · 0.45
GetOutputMethod · 0.45

Tested by

no test coverage detected