Medical Imaging Interaction Toolkit  2023.04.00
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 (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 #ifndef mitkToFTestingCommon_h
13 #define mitkToFTestingCommon_h
14 
15 #include <MitkToFProcessingExports.h>
16 #include "mitkNumericTypes.h"
18 #include <mitkSurface.h>
19 #include <mitkPointSet.h>
20 #include <itksys/SystemTools.hxx>
21 
22 #include <vtkSmartPointer.h>
23 #include <vtkPolyData.h>
24 
25 namespace mitk
26 {
27 class MITKTOFPROCESSING_EXPORT ToFTestingCommon
28 {
29 public:
30 
38  {
39  bool pointSetsEqual = true;
40  if (pointSet1->GetSize()==pointSet2->GetSize())
41  {
42  for (int i=0; i<pointSet1->GetSize(); i++)
43  {
44  mitk::Point3D expectedPoint = pointSet1->GetPoint(i);
45  mitk::Point3D resultPoint = pointSet2->GetPoint(i);
46  if (!mitk::Equal(expectedPoint,resultPoint))
47  {
48  std::cout << std::endl;
49  std::cout << std::setprecision(12) << "expected: " << expectedPoint;
50  std::cout << std::endl;
51  std::cout << std::setprecision(12) << "resultPoint: " << resultPoint;
52  std::cout << std::endl;
53  pointSetsEqual = false;
54  }
55  }
56  }
57  else
58  {
59  pointSetsEqual = false;
60  MITK_INFO<<"Point sets have different size: "<<pointSet1->GetSize()<<" vs. "<<pointSet2->GetSize();
61  }
62  return pointSetsEqual;
63  }
64 
71  static bool VtkPolyDatasEqual( vtkSmartPointer<vtkPolyData> poly1, vtkSmartPointer<vtkPolyData> poly2 )
72  {
73  return PointSetsEqual(VtkPolyDataToMitkPointSet(poly1), VtkPolyDataToMitkPointSet(poly2));
74  }
75 
81  static mitk::PointSet::Pointer VtkPolyDataToMitkPointSet( vtkSmartPointer<vtkPolyData> poly )
82  {
84  int numberOfPoints = poly->GetNumberOfPoints();
85  for (int i=0; i<numberOfPoints; i++)
86  {
87  double* currentPoint = poly->GetPoint(i);
88  mitk::Point3D point;
89  point[0] = currentPoint[0];
90  point[1] = currentPoint[1];
91  point[2] = currentPoint[2];
92  result->InsertPoint(i,point);
93  }
94  return result;
95  }
96 };
97 
98 }
99 #endif
MITK_INFO
#define MITK_INFO
Definition: mitkLogMacros.h:18
mitk::ToFTestingCommon::PointSetsEqual
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...
Definition: mitkToFTestingCommon.h:37
mitk::ToFTestingCommon::VtkPolyDatasEqual
static bool VtkPolyDatasEqual(vtkSmartPointer< vtkPolyData > poly1, vtkSmartPointer< vtkPolyData > poly2)
VtkPolyDatasEqual Convenience method for comparing the points of two vtkPolyData (using PointSetsEqua...
Definition: mitkToFTestingCommon.h:71
mitk::Equal
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.
itk::SmartPointer< Self >
mitk::PointSet::New
static Pointer New()
mitk::ToFTestingCommon::VtkPolyDataToMitkPointSet
static mitk::PointSet::Pointer VtkPolyDataToMitkPointSet(vtkSmartPointer< vtkPolyData > poly)
VtkPolyDataToMitkPointSet Converts a vtkPolyData into an mitkPointSet.
Definition: mitkToFTestingCommon.h:81
mitkPointSet.h
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitkSurface.h
mitk::Point< ScalarType, 3 >
mitkNumericTypes.h
mitkToFProcessingCommon.h
mitk::ToFTestingCommon
Definition: mitkToFTestingCommon.h:27