Medical Imaging Interaction Toolkit  2023.12.00
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 #include <nlohmann/json.hpp>
23 
24 namespace mitk
25 {
26  //##Documentation
27  //##@brief enumeration of the type a point can be
29  {
35  };
36 
37  template <class TCoordRep, unsigned int NPointDimension = 3>
38  class Point : public itk::Point<TCoordRep, NPointDimension>
39  {
40  public:
42  explicit Point<TCoordRep, NPointDimension>() : itk::Point<TCoordRep, NPointDimension>() {}
44  template <typename TPointValueType>
45  explicit Point(const Point<TPointValueType, NPointDimension> &r) : itk::Point<TCoordRep, NPointDimension>(r)
46  {
47  }
48 
49  template <typename TPointValueType>
50  explicit Point(const TPointValueType r[NPointDimension]) : itk::Point<TCoordRep, NPointDimension>(r)
51  {
52  }
53 
54  template <typename TPointValueType>
55  explicit Point(const TPointValueType &v) : itk::Point<TCoordRep, NPointDimension>(v)
56  {
57  }
58 
60  : itk::Point<TCoordRep, NPointDimension>(r)
61  {
62  }
63  Point<TCoordRep, NPointDimension>(const TCoordRep r[NPointDimension]) : itk::Point<TCoordRep, NPointDimension>(r) {}
64  Point<TCoordRep, NPointDimension>(const TCoordRep &v) : itk::Point<TCoordRep, NPointDimension>(v) {}
65  Point<TCoordRep, NPointDimension>(const itk::Point<TCoordRep, NPointDimension> &p)
66  : itk::Point<TCoordRep, NPointDimension>(p)
67  {
68  }
69 
76  template <typename ArrayType>
77  void FillPoint(const ArrayType &array)
78  {
79  itk::FixedArray<TCoordRep, NPointDimension> *thisP =
80  dynamic_cast<itk::FixedArray<TCoordRep, NPointDimension> *>(this);
81  mitk::FillArray<ArrayType, TCoordRep, NPointDimension>(*thisP, array);
82  }
83 
89  template <typename ArrayType>
90  void ToArray(ArrayType array) const
91  {
92  mitk::ToArray<ArrayType, TCoordRep, NPointDimension>(array, *this);
93  }
94  };
95 
96  template <class TCoordRep, unsigned int NPointDimension>
98  {
99  j = nlohmann::json::array();
100 
101  for (size_t i = 0; i < NPointDimension; ++i)
102  j.push_back(p[i]);
103  }
104 
105  template <class TCoordRep, unsigned int NPointDimension>
107  {
108  for (size_t i = 0; i < NPointDimension; ++i)
109  j.at(i).get_to(p[i]);
110  }
111 
115 
119 
129  template <typename TCoordRep, unsigned int NPointDimension>
130  inline bool Equal(const itk::Point<TCoordRep, NPointDimension> &point1,
131  const itk::Point<TCoordRep, NPointDimension> &point2,
132  TCoordRep eps = mitk::eps,
133  bool verbose = false)
134  {
135  bool isEqual = true;
136  typename itk::Point<TCoordRep, NPointDimension>::VectorType diff = point1 - point2;
137  for (unsigned int i = 0; i < NPointDimension; i++)
138  {
139  if (DifferenceBiggerOrEqualEps(diff[i], eps))
140  {
141  isEqual = false;
142  break;
143  }
144  }
145 
146  ConditionalOutputOfDifference(point1, point2, eps, verbose, isEqual);
147 
148  return isEqual;
149  }
150 
151 } // namespace mitk
152 
153 #endif
mitk::PTEDGE
@ PTEDGE
Definition: mitkPoint.h:33
mitk::eps
const MITKCORE_EXPORT ScalarType eps
mitk::Point4I
Point< int, 4 > Point4I
Definition: mitkPoint.h:118
mitk::Point::FillPoint
void FillPoint(const ArrayType &array)
Definition: mitkPoint.h:77
mitk::Point::Point
Point(const Point< TPointValueType, NPointDimension > &r)
Definition: mitkPoint.h:45
mitk::PTUNDEFINED
@ PTUNDEFINED
Definition: mitkPoint.h:30
mitk::to_json
void to_json(nlohmann::json &j, const GenericLookupTable< T > &t)
Definition: mitkGenericLookupTable.h:98
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.
mitk::Point::Point
Point(const TPointValueType r[NPointDimension])
Definition: mitkPoint.h:50
mitk::from_json
void from_json(const nlohmann::json &, GenericLookupTable< T > &)
Definition: mitkGenericLookupTable.h:104
mitk::Point4D
Point< ScalarType, 4 > Point4D
Definition: mitkPoint.h:114
mitk::Point2I
Point< int, 2 > Point2I
Definition: mitkPoint.h:116
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitkArray.h
mitk::Point::ToArray
void ToArray(ArrayType array) const
Definition: mitkPoint.h:90
json
nlohmann::json json
Definition: mitkModelTestFixture.h:29
mitk::Point
Definition: mitkPoint.h:38
mitk::Point::Point
Point(const TPointValueType &v)
Definition: mitkPoint.h:55
mitk::Point2D
Point< ScalarType, 2 > Point2D
Definition: mitkPoint.h:112
mitk::Point3D
Point< ScalarType, 3 > Point3D
Definition: mitkPoint.h:113
mitkNumericConstants.h
mitk::PTEND
@ PTEND
Definition: mitkPoint.h:34
mitkEqual.h
itk
SET FUNCTIONS.
Definition: itkIntelligentBinaryClosingFilter.h:30
mitk::DifferenceBiggerOrEqualEps
bool DifferenceBiggerOrEqualEps(DifferenceType diff, mitk::ScalarType epsilon=mitk::eps)
Definition: mitkEqual.h:32
mitk::PointSpecificationType
PointSpecificationType
enumeration of the type a point can be
Definition: mitkPoint.h:28
mitk::ConditionalOutputOfDifference
void ConditionalOutputOfDifference(ElementToOutput1 elem1, ElementToOutput2 elem2, mitk::ScalarType eps, bool verbose, bool isEqual)
Definition: mitkEqual.h:48
mitk::Point3I
Point< int, 3 > Point3I
Definition: mitkPoint.h:117
mitk::PTCORNER
@ PTCORNER
Definition: mitkPoint.h:32
mitk::PTSTART
@ PTSTART
Definition: mitkPoint.h:31