Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
MapBoxTriangulation.h
Go to the documentation of this file.
1
31#pragma once
32
33#ifdef OGDF_INCLUDE_CGAL
34
36
38
39# include <array>
40# include <vector>
41
42# include <CGAL/number_utils.h>
43
44namespace ogdf {
45namespace internal {
46namespace gcm {
47namespace geometry {
48
49template<typename Kernel>
50std::vector<unsigned int> triangulation(const geometry::Polygon_t<Kernel>& polygon) {
51 using MB_Point = std::array<double, 2>;
52
53 if (polygon.size() > 3) {
54 std::vector<std::vector<MB_Point>> mb_polygon;
55 mb_polygon.resize(1);
56 for (unsigned int i = 0; i < polygon.size(); ++i) {
57 mb_polygon[0].push_back(
58 {CGAL::to_double(polygon[i].x()), CGAL::to_double(polygon[i].y())});
59 }
60
61 return mapbox::earcut<unsigned int>(mb_polygon);
62 } else {
63 return {0, 1, 2};
64 }
65}
66
67}
68}
69}
70}
71
72#endif
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.