Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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 
44 namespace ogdf {
45 namespace internal {
46 namespace gcm {
47 namespace geometry {
48 
49 template<typename Kernel>
50 std::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
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
Polygon.h
mapbox_earcut.h