23#ifndef VCL_ALGORITHMS_CORE_POLYGON_EAR_CUT_H
24#define VCL_ALGORITHMS_CORE_POLYGON_EAR_CUT_H
26#include "projection.h"
28#include <vclib/space/core.h>
30#if __has_include(<mapbox/earcut.hpp>)
31#include <mapbox/earcut.hpp>
35#include "../../../../../external/earcut.hpp-2.2.3/include/mapbox/earcut.hpp"
40namespace mapbox::util {
42template<
typename Scalar>
43struct nth<0, vcl::
Point2<Scalar>>
48template<
typename Scalar>
49struct nth<1, vcl::
Point2<Scalar>>
89template<Po
int2IteratorConcept Iterator>
90std::vector<uint>
earCut(Iterator begin, Iterator end)
92 using PointT = Iterator::value_type;
93 using Scalar = PointT::ScalarType;
100 std::vector<std::vector<Point2<Scalar>>>
poly;
101 poly.emplace_back(begin, end);
105 return mapbox::earcut<uint>(
poly);
143template<Po
int3IteratorConcept Iterator>
144std::vector<uint>
earCut(Iterator begin, Iterator end)
147 auto poly2D =
project(begin, end);
151 return earCut(poly2D.begin(), poly2D.end());
A class representing a box in N-dimensional space.
Definition box.h:46
auto project(Iterator begin, Iterator end)
Project a 3D polygon onto a plane, and return the 2D polygon.
Definition projection.h:41
std::vector< uint > earCut(Iterator begin, Iterator end)
Triangulates a simple polygon with no holes using the ear-cutting algorithm.
Definition ear_cut.h:90
Point< Scalar, 2 > Point2
A convenience alias for a 2-dimensional Point.
Definition point.h:695