Internal_point.h
1/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
2 * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
3 * Author: Francois Godi
4 *
5 * Copyright (C) 2015 Inria
6 *
7 * Modification(s):
8 * - YYYY/MM Author: Description of the modification
9 */
10
11#ifndef INTERNAL_POINT_H_
12#define INTERNAL_POINT_H_
13
14namespace Gudhi {
15
16namespace persistence_diagram {
17
19int null_point_index();
20
22struct Internal_point {
23 double vec[2];
24 int point_index;
25
26 Internal_point() { }
27
28 Internal_point(double x, double y, int p_i) {
29 vec[0] = x;
30 vec[1] = y;
31 point_index = p_i;
32 }
33
34 double x() const {
35 return vec[ 0 ];
36 }
37
38 double y() const {
39 return vec[ 1 ];
40 }
41
42 double& x() {
43 return vec[ 0 ];
44 }
45
46 double& y() {
47 return vec[ 1 ];
48 }
49
50 bool operator==(const Internal_point& p) const {
51 return point_index == p.point_index;
52 }
53
54 bool operator!=(const Internal_point& p) const {
55 return !(*this == p);
56 }
57};
58
59inline int null_point_index() {
60 return -1;
61}
62
63struct Construct_coord_iterator {
64 typedef const double* result_type;
65
66 const double* operator()(const Internal_point& p) const {
67 return p.vec;
68 }
69
70 const double* operator()(const Internal_point& p, int) const {
71 return p.vec + 2;
72 }
73};
74
75} // namespace persistence_diagram
76
77} // namespace Gudhi
78
79#endif // INTERNAL_POINT_H_