Medical Imaging Interaction Toolkit  2018.4.99-4c24e3cb
Medical Imaging Interaction Toolkit
mitkPlaneFitTest.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include <fstream>
14 #include <mitkGeometry3D.h>
15 #include <mitkGeometryData.h>
16 #include <mitkNumericTypes.h>
17 #include <mitkPlaneFit.h>
18 #include <mitkPlaneGeometry.h>
19 #include <mitkPointSet.h>
20 
21 int mitkPlaneFitTest(int, char *[])
22 {
23  // float bounds[]={0.0f,10.0f,0.0f,10.0f,0.0f,5.0f};
24 
27 
28  mitk::Point3D Point;
29 
30  // first without any point, then incrementally add points within thre 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;
79  }
80  else
81  {
82  std::cout << "[FAILED]" << std::endl;
83  return EXIT_FAILURE;
84  }
85 
86  std::cout << "[TEST DONE]" << std::endl;
87  return EXIT_SUCCESS;
88 }
int mitkPlaneFitTest(int, char *[])
static Pointer New()
void FillVector3D(Tout &out, mitk::ScalarType x, mitk::ScalarType y, mitk::ScalarType z)
Definition: mitkArray.h:106
virtual int GetSize(unsigned int t=0) const
returns the current size of the point-list
Data structure which stores a set of points. Superclass of mitk::Mesh.
Definition: mitkPointSet.h:75
static Pointer New()
Describes a two-dimensional, rectangular plane.