Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkToFTestingCommon.h
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 #ifndef mitkToFTestingCOMMON_H
17 #define mitkToFTestingCOMMON_H
18 
19 #include <MitkToFProcessingExports.h>
20 #include "mitkNumericTypes.h"
22 #include <mitkSurface.h>
23 #include <mitkPointSet.h>
24 #include <itksys/SystemTools.hxx>
25 
26 #include <vtkSmartPointer.h>
27 #include <vtkPolyData.h>
28 
29 namespace mitk
30 {
31 class MITKTOFPROCESSING_EXPORT ToFTestingCommon
32 {
33 public:
34 
42  {
43  bool pointSetsEqual = true;
44  if (pointSet1->GetSize()==pointSet2->GetSize())
45  {
46  for (int i=0; i<pointSet1->GetSize(); i++)
47  {
48  mitk::Point3D expectedPoint = pointSet1->GetPoint(i);
49  mitk::Point3D resultPoint = pointSet2->GetPoint(i);
50  if (!mitk::Equal(expectedPoint,resultPoint))
51  {
52  std::cout << std::endl;
53  std::cout << std::setprecision(12) << "expected: " << expectedPoint;
54  std::cout << std::endl;
55  std::cout << std::setprecision(12) << "resultPoint: " << resultPoint;
56  std::cout << std::endl;
57  pointSetsEqual = false;
58  }
59  }
60  }
61  else
62  {
63  pointSetsEqual = false;
64  MITK_INFO<<"Point sets have different size: "<<pointSet1->GetSize()<<" vs. "<<pointSet2->GetSize();
65  }
66  return pointSetsEqual;
67  }
68 
75  static bool VtkPolyDatasEqual( vtkSmartPointer<vtkPolyData> poly1, vtkSmartPointer<vtkPolyData> poly2 )
76  {
77  return PointSetsEqual(VtkPolyDataToMitkPointSet(poly1), VtkPolyDataToMitkPointSet(poly2));
78  }
79 
85  static mitk::PointSet::Pointer VtkPolyDataToMitkPointSet( vtkSmartPointer<vtkPolyData> poly )
86  {
88  int numberOfPoints = poly->GetNumberOfPoints();
89  for (int i=0; i<numberOfPoints; i++)
90  {
91  double* currentPoint = poly->GetPoint(i);
92  mitk::Point3D point;
93  point[0] = currentPoint[0];
94  point[1] = currentPoint[1];
95  point[2] = currentPoint[2];
96  result->InsertPoint(i,point);
97  }
98  return result;
99  }
100 };
101 
102 }
103 #endif
#define MITK_INFO
Definition: mitkLogMacros.h:22
static Pointer New()
DataCollection - Class to facilitate loading/accessing structured data.
static bool VtkPolyDatasEqual(vtkSmartPointer< vtkPolyData > poly1, vtkSmartPointer< vtkPolyData > poly2)
VtkPolyDatasEqual Convenience method for comparing the points of two vtkPolyData (using PointSetsEqua...
static bool PointSetsEqual(mitk::PointSet::Pointer pointSet1, mitk::PointSet::Pointer pointSet2)
PointSetsEqual Method two test if two point sets contain the same points. mitk::Equal is used for com...
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
static mitk::PointSet::Pointer VtkPolyDataToMitkPointSet(vtkSmartPointer< vtkPolyData > poly)
VtkPolyDataToMitkPointSet Converts a vtkPolyData into an mitkPointSet.