Medical Imaging Interaction Toolkit  2016.11.0
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,
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 #ifndef MITKPOINT_H_
18 #define MITKPOINT_H_
19 
20 #include <itkPoint.h>
21 
22 #include "mitkArray.h"
23 #include "mitkEqual.h"
24 #include "mitkNumericConstants.h"
25 
26 namespace mitk
27 {
28  //##Documentation
29  //##@brief enumeration of the type a point can be
31  {
37  };
38 
39  template <class TCoordRep, unsigned int NPointDimension = 3>
40  class Point : public itk::Point<TCoordRep, NPointDimension>
41  {
42  public:
44  explicit Point<TCoordRep, NPointDimension>() : itk::Point<TCoordRep, NPointDimension>() {}
46  template <typename TPointValueType>
47  explicit Point(const Point<TPointValueType, NPointDimension> &r) : itk::Point<TCoordRep, NPointDimension>(r)
48  {
49  }
50 
51  template <typename TPointValueType>
52  explicit Point(const TPointValueType r[NPointDimension]) : itk::Point<TCoordRep, NPointDimension>(r)
53  {
54  }
55 
56  template <typename TPointValueType>
57  Point(const TPointValueType &v) : itk::Point<TCoordRep, NPointDimension>(v)
58  {
59  }
60 
62  : itk::Point<TCoordRep, NPointDimension>(r)
63  {
64  }
65  Point<TCoordRep, NPointDimension>(const TCoordRep r[NPointDimension]) : itk::Point<TCoordRep, NPointDimension>(r) {}
66  Point<TCoordRep, NPointDimension>(const TCoordRep &v) : itk::Point<TCoordRep, NPointDimension>(v) {}
67  Point<TCoordRep, NPointDimension>(const itk::Point<TCoordRep, NPointDimension> &p)
68  : itk::Point<TCoordRep, NPointDimension>(p)
69  {
70  }
71 
78  template <typename ArrayType>
79  void FillPoint(const ArrayType &array)
80  {
81  itk::FixedArray<TCoordRep, NPointDimension> *thisP =
82  dynamic_cast<itk::FixedArray<TCoordRep, NPointDimension> *>(this);
83  mitk::FillArray<ArrayType, TCoordRep, NPointDimension>(*thisP, array);
84  }
85 
91  template <typename ArrayType>
92  void ToArray(ArrayType array) const
93  {
94  mitk::ToArray<ArrayType, TCoordRep, NPointDimension>(array, *this);
95  }
96  };
97 
101 
105 
115  template <typename TCoordRep, unsigned int NPointDimension>
116  inline bool Equal(const itk::Point<TCoordRep, NPointDimension> &point1,
117  const itk::Point<TCoordRep, NPointDimension> &point2,
118  TCoordRep eps = mitk::eps,
119  bool verbose = false)
120  {
121  bool isEqual = true;
122  typename itk::Point<TCoordRep, NPointDimension>::VectorType diff = point1 - point2;
123  for (unsigned int i = 0; i < NPointDimension; i++)
124  {
125  if (DifferenceBiggerOrEqualEps(diff[i], eps))
126  {
127  isEqual = false;
128  break;
129  }
130  }
131 
132  ConditionalOutputOfDifference(point1, point2, eps, verbose, isEqual);
133 
134  return isEqual;
135  }
136 
137 } // namespace mitk
138 
139 #endif /* MITKPOINT_H_ */
Point< ScalarType, 2 > Point2D
Definition: mitkPoint.h:98
Point< int, 3 > Point3I
Definition: mitkPoint.h:103
void ConditionalOutputOfDifference(ElementToOutput1 elem1, ElementToOutput2 elem2, mitk::ScalarType eps, bool verbose, bool isEqual)
Definition: mitkEqual.h:42
Point< ScalarType, 4 > Point4D
Definition: mitkPoint.h:100
DataCollection - Class to facilitate loading/accessing structured data.
itk::Vector< float, 3 > VectorType
Point< int, 2 > Point2I
Definition: mitkPoint.h:102
Point< ScalarType, 3 > Point3D
Definition: mitkPoint.h:99
Point(const Point< TPointValueType, NPointDimension > &r)
Definition: mitkPoint.h:47
Point(const TPointValueType r[NPointDimension])
Definition: mitkPoint.h:52
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:104
MITKCORE_EXPORT const ScalarType eps
Point(const TPointValueType &v)
Definition: mitkPoint.h:57
bool DifferenceBiggerOrEqualEps(DifferenceType diff, mitk::ScalarType epsilon=mitk::eps)
Definition: mitkEqual.h:26
void ToArray(ArrayType array) const
Definition: mitkPoint.h:92
void FillPoint(const ArrayType &array)
Definition: mitkPoint.h:79
PointSpecificationType
enumeration of the type a point can be
Definition: mitkPoint.h:30