1 | #pragma once |
---|---|
2 | |
3 | #include <mapbox/geometry/wagyu/config.hpp> |
4 | #include <mapbox/geometry/wagyu/local_minimum.hpp> |
5 | |
6 | #include <algorithm> |
7 | |
8 | namespace mapbox { |
9 | namespace geometry { |
10 | namespace wagyu { |
11 | |
12 | template <typename T> |
13 | using scanbeam_list = std::vector<T>; |
14 | |
15 | template <typename T> |
16 | bool pop_from_scanbeam(T& Y, scanbeam_list<T>& scanbeam) { |
17 | if (scanbeam.empty()) { |
18 | return false; |
19 | } |
20 | std::sort(scanbeam.begin(), scanbeam.end()); |
21 | scanbeam.erase(std::unique(scanbeam.begin(), scanbeam.end()), scanbeam.end()); |
22 | Y = scanbeam.back(); |
23 | scanbeam.pop_back(); |
24 | return true; |
25 | } |
26 | |
27 | template <typename T> |
28 | void setup_scanbeam(local_minimum_list<T>& minima_list, scanbeam_list<T>& scanbeam) { |
29 | |
30 | for (auto lm = minima_list.begin(); lm != minima_list.end(); ++lm) { |
31 | scanbeam.push_back(lm->y); |
32 | } |
33 | } |
34 | } |
35 | } |
36 | } |
37 |