TTK
Loading...
Searching...
No Matches
FastRipsPersistenceDiagram2.h
Go to the documentation of this file.
1
20
21#pragma once
22
23#ifdef TTK_ENABLE_CGAL
24
25#include <CGAL/Delaunay_triangulation_2.h>
26#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
27#include <CGAL/Fuzzy_sphere.h>
28#include <CGAL/Kd_tree.h>
29#include <CGAL/Search_traits_2.h>
30#include <CGAL/Triangulation_face_base_with_id_2.h>
31#include <CGAL/Triangulation_vertex_base_with_info_2.h>
32
33#include <PairCells.h>
35
36namespace ttk::rpd {
37
38 class FastRipsPersistenceDiagram2 : virtual public Debug {
39
40 using K = CGAL::Exact_predicates_inexact_constructions_kernel;
41 using Vb = CGAL::Triangulation_vertex_base_with_info_2<unsigned int, K>;
42 using Fb = CGAL::Triangulation_face_base_with_id_2<K>;
43 using Tds = CGAL::Triangulation_data_structure_2<Vb, Fb>;
44 using Delaunay = CGAL::Delaunay_triangulation_2<K, Tds>;
45 using Point = Delaunay::Point_2;
46 using Traits = CGAL::Search_traits_2<K>;
47 using Tree = CGAL::Kd_tree<Traits>;
48 using Fuzzy_sphere = CGAL::Fuzzy_sphere<Traits>;
49
50 public:
51 explicit FastRipsPersistenceDiagram2(const PointCloud &points);
52 explicit FastRipsPersistenceDiagram2(float *data, int n);
53
54 template <typename T>
55 void compute0Persistence(T &ph0, bool parallelSort = false);
56
57 template <typename T>
58 void computeDelaunayRips0And1Persistence(T &ph, bool parallelSort = false);
59
60 template <typename T>
61 void computeRips0And1Persistence(T &ph,
62 bool parallelSort = false,
63 bool parallelMML = false);
64
65 void exportRips1Generators(std::vector<Generator1> &generators);
66
67 private:
68 Timer tm_{};
69 const unsigned n_;
70 unsigned nFaces_;
71 std::vector<std::pair<Point, unsigned>> points_;
72 Delaunay delaunay_;
73
74 std::vector<FiltratedQuadEdge> urquhart_;
75 std::vector<FiltratedQuadEdge> rng_;
76 std::vector<FiltratedEdge> deathPoly_;
77 std::vector<double> birthPoly_;
78
79 // common to Delaunay-Rips and Rips
80 void computeDelaunay();
81 void computeUrquhart(UnionFind &UF,
82 std::vector<FiltratedEdge> &maxDelaunay,
83 bool parallelSort);
84 void compute1PH(std::vector<FiltratedQuadEdge> const &critical,
85 UnionFind &UF,
86 MultidimensionalDiagram &ph);
87
88 // specific to Rips
89 [[nodiscard]] static bool isLensEmpty(Point const &p1,
90 Point const &p2,
91 Tree const &tree,
92 double const &d);
93 [[nodiscard]] static bool
94 isRightSemiLensEmpty(Point const &p1, Point const &p2, Tree const &tree);
95 void reindexPolygons(UnionFind const &UF,
96 std::vector<FiltratedEdge> const &maxDelaunay,
97 std::vector<int> &indexPolys);
98 void computePolygonRipsDeath(bool parallel,
99 UnionFind &UF,
100 std::vector<int> const &indexPolys);
101 void pComputePolygonRipsDeath(UnionFind &UF,
102 std::vector<int> const &indexPolys);
103 void executePolygonPairCells(bool parallel,
104 UnionFind &UF,
105 std::vector<int> const &indexPolys,
106 EdgeSets4 &ph) const;
107
108 void static add0Pair(FiltratedQuadEdge const &e, Diagram &ph) {
109 ph.emplace_back(FiltratedSimplex{{-1}, 0},
110 FiltratedSimplex{{e.e.first, e.e.second}, e.d});
111 }
112
113 void static add0Pair(FiltratedQuadEdge const &e, EdgeSet &ph) {
114 ph.emplace_back(e.e);
115 }
116 };
117
118} // namespace ttk::rpd
119
120#endif
boost::tuple< double, double > Point
Definition TopoMap.cpp:56
TTK base class that computes the persistence diagram of a Rips complex of a planar point cloud using ...