Medical Imaging Interaction Toolkit  2018.4.99-1bab67a2
Medical Imaging Interaction Toolkit
mitkPoint.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 
13 #ifndef MITKPOINT_H_
14 #define MITKPOINT_H_
15 
16 #include <itkPoint.h>
17 
18 #include "mitkArray.h"
19 #include "mitkEqual.h"
20 #include "mitkNumericConstants.h"
21 
22 namespace mitk
23 {
24  //##Documentation
25  //##@brief enumeration of the type a point can be
27  {
33  };
34 
35  template <class TCoordRep, unsigned int NPointDimension = 3>
36  class Point : public itk::Point<TCoordRep, NPointDimension>
37  {
38  public:
40  explicit Point<TCoordRep, NPointDimension>() : itk::Point<TCoordRep, NPointDimension>() {}
42  template <typename TPointValueType>
43  explicit Point(const Point<TPointValueType, NPointDimension> &r) : itk::Point<TCoordRep, NPointDimension>(r)
44  {
45  }
46 
47  template <typename TPointValueType>
48  explicit Point(const TPointValueType r[NPointDimension]) : itk::Point<TCoordRep, NPointDimension>(r)
49  {
50  }
51 
52  template <typename TPointValueType>
53  Point(const TPointValueType &v) : itk::Point<TCoordRep, NPointDimension>(v)
54  {
55  }
56 
58  : itk::Point<TCoordRep, NPointDimension>(r)
59  {
60  }
61  Point<TCoordRep, NPointDimension>(const TCoordRep r[NPointDimension]) : itk::Point<TCoordRep, NPointDimension>(r) {}
62  Point<TCoordRep, NPointDimension>(const TCoordRep &v) : itk::Point<TCoordRep, NPointDimension>(v) {}
63  Point<TCoordRep, NPointDimension>(const itk::Point<TCoordRep, NPointDimension> &p)
64  : itk::Point<TCoordRep, NPointDimension>(p)
65  {
66  }
67 
74  template <typename ArrayType>
75  void FillPoint(const ArrayType &array)
76  {
77  itk::FixedArray<TCoordRep, NPointDimension> *thisP =
78  dynamic_cast<itk::FixedArray<TCoordRep, NPointDimension> *>(this);
79  mitk::FillArray<ArrayType, TCoordRep, NPointDimension>(*thisP, array);
80  }
81 
87  template <typename ArrayType>
88  void ToArray(ArrayType array) const
89  {
90  mitk::ToArray<ArrayType, TCoordRep, NPointDimension>(array, *this);
91  }
92  };
93 
97 
101 
111  template <typename TCoordRep, unsigned int NPointDimension>
112  inline bool Equal(const itk::Point<TCoordRep, NPointDimension> &point1,
113  const itk::Point<TCoordRep, NPointDimension> &point2,
114  TCoordRep eps = mitk::eps,
115  bool verbose = false)
116  {
117  bool isEqual = true;
118  typename itk::Point<TCoordRep, NPointDimension>::VectorType diff = point1 - point2;
119  for (unsigned int i = 0; i < NPointDimension; i++)
120  {
121  if (DifferenceBiggerOrEqualEps(diff[i], eps))
122  {
123  isEqual = false;
124  break;
125  }
126  }
127 
128  ConditionalOutputOfDifference(point1, point2, eps, verbose, isEqual);
129 
130  return isEqual;
131  }
132 
133 } // namespace mitk
134 
135 #endif /* MITKPOINT_H_ */
Point< ScalarType, 2 > Point2D
Definition: mitkPoint.h:94
Point< int, 3 > Point3I
Definition: mitkPoint.h:99
void ConditionalOutputOfDifference(ElementToOutput1 elem1, ElementToOutput2 elem2, mitk::ScalarType eps, bool verbose, bool isEqual)
Definition: mitkEqual.h:54
Point< ScalarType, 4 > Point4D
Definition: mitkPoint.h:96
DataCollection - Class to facilitate loading/accessing structured data.
void ToArray(ArrayType array) const
Definition: mitkPoint.h:88
bool verbose(false)
Point< int, 2 > Point2I
Definition: mitkPoint.h:98
Point< ScalarType, 3 > Point3D
Definition: mitkPoint.h:95
Point(const Point< TPointValueType, NPointDimension > &r)
Definition: mitkPoint.h:43
Point(const TPointValueType r[NPointDimension])
Definition: mitkPoint.h:48
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.
Point< int, 4 > Point4I
Definition: mitkPoint.h:100
MITKCORE_EXPORT const ScalarType eps
Point(const TPointValueType &v)
Definition: mitkPoint.h:53
bool DifferenceBiggerOrEqualEps(DifferenceType diff, mitk::ScalarType epsilon=mitk::eps)
Definition: mitkEqual.h:38
void FillPoint(const ArrayType &array)
Definition: mitkPoint.h:75
PointSpecificationType
enumeration of the type a point can be
Definition: mitkPoint.h:26