Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include <fstream>
18 #include <mitkGeometry3D.h>
19 #include <mitkGeometryData.h>
20 #include <mitkNumericTypes.h>
21 #include <mitkPlaneFit.h>
22 #include <mitkPlaneGeometry.h>
23 #include <mitkPointSet.h>
24 
25 int mitkPlaneFitTest(int, char *[])
26 {
27  // float bounds[]={0.0f,10.0f,0.0f,10.0f,0.0f,5.0f};
28 
31 
32  mitk::Point3D Point;
33 
34  // first without any point, then incrementally add points within thre points there will be a plane geometry
35  std::cout << "Start PlaneFitTest " << std::endl;
36  for (int position = 0; position < 6; position++)
37  {
38  // add a point directly
39  mitk::FillVector3D(Point, (float)position, (float)position * 1.5, 2.5);
40  PointSet->GetPointSet()->GetPoints()->InsertElement(position, Point);
41  }
42 
43  // Set Input
44  PlaneFit->SetInput(PointSet);
45 
46  const mitk::PointSet *testPointSet = PlaneFit->GetInput();
47  std::cout << " Size test of Input Method: ";
48  if (testPointSet->GetSize() == PointSet->GetSize())
49  {
50  std::cout << "[PASSED]" << std::endl;
51  }
52  else
53  {
54  std::cout << "[FAILED]" << std::endl;
55  return EXIT_FAILURE;
56  }
57 
58  // Test Centroid
59  std::cout << " Testing centroid calculaation: ";
60  PlaneFit->Update();
61  const mitk::Point3D &centroid = PlaneFit->GetCentroid();
62  mitk::Point3D expectedCentroid;
63  expectedCentroid[0] = 2.5;
64  expectedCentroid[1] = 3.75;
65  expectedCentroid[2] = 2.5;
66 
67  if (centroid == expectedCentroid)
68  {
69  std::cout << "[PASSED]" << std::endl;
70  }
71  else
72  {
73  std::cout << "[FAILED]" << std::endl;
74  return EXIT_FAILURE;
75  }
76 
77  // Test PlaneGeometry
78  std::cout << " Test PlaneGeometry: ";
79  mitk::PlaneGeometry *PlaneGeometry = dynamic_cast<mitk::PlaneGeometry *>(PlaneFit->GetOutput()->GetGeometry());
80  if (PlaneGeometry)
81  {
82  std::cout << "[PASSED]" << std::endl;
83  }
84  else
85  {
86  std::cout << "[FAILED]" << std::endl;
87  return EXIT_FAILURE;
88  }
89 
90  std::cout << "[TEST DONE]" << std::endl;
91  return EXIT_SUCCESS;
92 }
virtual int GetSize(unsigned int t=0) const
returns the current size of the point-list
int mitkPlaneFitTest(int, char *[])
static Pointer New()
void FillVector3D(Tout &out, mitk::ScalarType x, mitk::ScalarType y, mitk::ScalarType z)
Definition: mitkArray.h:110
Data structure which stores a set of points. Superclass of mitk::Mesh.
Definition: mitkPointSet.h:79
static Pointer New()
Describes a two-dimensional, rectangular plane.