1 #pragma once
2
3 #include <algorithm>
4 #include <set>
5
6 #include <mapbox/geometry/wagyu/active_bound_list.hpp>
7 #include <mapbox/geometry/wagyu/config.hpp>
8 #include <mapbox/geometry/wagyu/intersect_util.hpp>
9 #include <mapbox/geometry/wagyu/local_minimum.hpp>
10 #include <mapbox/geometry/wagyu/local_minimum_util.hpp>
11 #include <mapbox/geometry/wagyu/process_horizontal.hpp>
12 #include <mapbox/geometry/wagyu/process_maxima.hpp>
13 #include <mapbox/geometry/wagyu/ring.hpp>
14 #include <mapbox/geometry/wagyu/ring_util.hpp>
15 #include <mapbox/geometry/wagyu/util.hpp>
16
17 namespace mapbox {
18 namespace geometry {
19 namespace wagyu {
20
21 template <typename T>
execute_vatti(local_minimum_list<T> & minima_list,ring_manager<T> & manager,clip_type cliptype,fill_type subject_fill_type,fill_type clip_fill_type)22 void execute_vatti(local_minimum_list<T>& minima_list,
23 ring_manager<T>& manager,
24 clip_type cliptype,
25 fill_type subject_fill_type,
26 fill_type clip_fill_type) {
27 active_bound_list<T> active_bounds;
28 scanbeam_list<T> scanbeam;
29 T scanline_y = std::numeric_limits<T>::max();
30
31 local_minimum_ptr_list<T> minima_sorted;
32 minima_sorted.reserve(minima_list.size());
33 for (auto& lm : minima_list) {
34 minima_sorted.push_back(&lm);
35 }
36 std::stable_sort(minima_sorted.begin(), minima_sorted.end(), local_minimum_sorter<T>());
37 local_minimum_ptr_list_itr<T> current_lm = minima_sorted.begin();
38 // std::clog << output_all_edges(minima_sorted) << std::endl;
39
40 setup_scanbeam(minima_list, scanbeam);
41 manager.current_hp_itr = manager.hot_pixels.begin();
42
43 while (pop_from_scanbeam(scanline_y, scanbeam) || current_lm != minima_sorted.end()) {
44
45 process_intersections(scanline_y, active_bounds, cliptype, subject_fill_type,
46 clip_fill_type, manager);
47
48 update_current_hp_itr(scanline_y, manager);
49
50 // First we process bounds that has already been added to the active bound list --
51 // if the active bound list is empty local minima that are at this scanline_y and
52 // have a horizontal edge at the local minima will be processed
53 process_edges_at_top_of_scanbeam(scanline_y, active_bounds, scanbeam, minima_sorted,
54 current_lm, manager, cliptype, subject_fill_type,
55 clip_fill_type);
56
57 // Next we will add local minima bounds to the active bounds list that are on the local
58 // minima queue at
59 // this current scanline_y
60 insert_local_minima_into_ABL(scanline_y, minima_sorted, current_lm, active_bounds, manager,
61 scanbeam, cliptype, subject_fill_type, clip_fill_type);
62 }
63 }
64 }
65 }
66 }
67