This file is indexed.

/usr/include/mapbox/geometry/wagyu/process_horizontal.hpp is in libmapbox-wagyu-dev 0.4.3-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
#pragma once

#include <mapbox/geometry/line_string.hpp>
#include <mapbox/geometry/point.hpp>
#include <mapbox/geometry/polygon.hpp>

#include <mapbox/geometry/wagyu/config.hpp>
#include <mapbox/geometry/wagyu/edge.hpp>
#include <mapbox/geometry/wagyu/local_minimum.hpp>
#include <mapbox/geometry/wagyu/util.hpp>

namespace mapbox {
namespace geometry {
namespace wagyu {

template <typename T>
active_bound_list_itr<T> process_horizontal_left_to_right(T scanline_y,
                                                          active_bound_list_itr<T>& horz_bound,
                                                          active_bound_list<T>& active_bounds,
                                                          ring_manager<T>& rings,
                                                          scanbeam_list<T>& scanbeam,
                                                          clip_type cliptype,
                                                          fill_type subject_fill_type,
                                                          fill_type clip_fill_type) {
    auto horizontal_itr_behind = horz_bound;
    bool shifted = false;
    bool is_maxima_edge = is_maxima(horz_bound, scanline_y);
    auto bound_max_pair = active_bounds.end();
    if (is_maxima_edge) {
        bound_max_pair = get_maxima_pair<T>(horz_bound, active_bounds);
    }

    auto hp_itr = rings.current_hp_itr;
    while (hp_itr != rings.hot_pixels.end() &&
           (hp_itr->y > scanline_y ||
            (hp_itr->y == scanline_y && hp_itr->x < (*horz_bound)->current_edge->bot.x))) {
        ++hp_itr;
    }

    auto bnd = std::next(horz_bound);

    while (bnd != active_bounds.end()) {
        if (*bnd == nullptr) {
            ++bnd;
            continue;
        }
        // this code block inserts extra coords into horizontal edges (in output
        // polygons) wherever hot pixels touch these horizontal edges. This helps
        //'simplifying' polygons (ie if the Simplify property is set).
        while (hp_itr != rings.hot_pixels.end() && hp_itr->y == scanline_y &&
               hp_itr->x < wround<T>((*bnd)->current_x) &&
               hp_itr->x < (*horz_bound)->current_edge->top.x) {
            if ((*horz_bound)->ring) {
                add_point_to_ring(*(*horz_bound), *hp_itr, rings);
            }
            ++hp_itr;
        }

        if ((*bnd)->current_x > static_cast<double>((*horz_bound)->current_edge->top.x)) {
            break;
        }

        // Also break if we've got to the end of an intermediate horizontal edge ...
        // nb: Smaller Dx's are to the right of larger Dx's ABOVE the horizontal.
        if (wround<T>((*bnd)->current_x) == (*horz_bound)->current_edge->top.x &&
            (*horz_bound)->next_edge != (*horz_bound)->edges.end() &&
            (*horz_bound)->current_edge->dx < (*horz_bound)->next_edge->dx) {
            break;
        }

        // note: may be done multiple times
        if ((*horz_bound)->ring) {
            add_point_to_ring(*(*horz_bound),
                              mapbox::geometry::point<T>(wround<T>((*bnd)->current_x), scanline_y),
                              rings);
        }

        // OK, so far we're still in range of the horizontal Edge  but make sure
        // we're at the last of consec. horizontals when matching with eMaxPair
        if (is_maxima_edge && bnd == bound_max_pair) {
            if ((*horz_bound)->ring) {
                add_local_maximum_point(*(*horz_bound), *(*bound_max_pair),
                                        (*horz_bound)->current_edge->top, rings, active_bounds);
            }
            *bound_max_pair = nullptr;
            *horz_bound = nullptr;
            if (!shifted) {
                ++horizontal_itr_behind;
            }
            return horizontal_itr_behind;
        }

        intersect_bounds(*(*horz_bound), *(*bnd),
                         mapbox::geometry::point<T>(wround<T>((*bnd)->current_x), scanline_y),
                         cliptype, subject_fill_type, clip_fill_type, rings, active_bounds);
        std::iter_swap(horz_bound, bnd);
        horz_bound = bnd;
        ++bnd;
        shifted = true;
    } // end while (bnd != active_bounds.end())

    if ((*horz_bound)->ring) {
        while (hp_itr != rings.hot_pixels.end() && hp_itr->y == scanline_y &&
               hp_itr->x < (*horz_bound)->current_edge->top.x) {
            add_point_to_ring(*(*horz_bound), *hp_itr, rings);
            ++hp_itr;
        }
    }

    if ((*horz_bound)->ring) {
        add_point_to_ring(*(*horz_bound), (*horz_bound)->current_edge->top, rings);
    }

    if ((*horz_bound)->next_edge != (*horz_bound)->edges.end()) {
        next_edge_in_bound(*(*horz_bound), scanbeam);
    } else {
        *horz_bound = nullptr;
    }
    if (!shifted) {
        ++horizontal_itr_behind;
    }
    return horizontal_itr_behind;
}

template <typename T>
active_bound_list_itr<T> process_horizontal_right_to_left(T scanline_y,
                                                          active_bound_list_itr<T>& horz_bound_fwd,
                                                          active_bound_list<T>& active_bounds,
                                                          ring_manager<T>& rings,
                                                          scanbeam_list<T>& scanbeam,
                                                          clip_type cliptype,
                                                          fill_type subject_fill_type,
                                                          fill_type clip_fill_type) {
    auto next_bnd_itr = std::next(horz_bound_fwd);
    bool is_maxima_edge = is_maxima(horz_bound_fwd, scanline_y);
    auto bound_max_pair = active_bounds.rend();
    if (is_maxima_edge) {
        bound_max_pair =
            active_bound_list_rev_itr<T>(get_maxima_pair<T>(horz_bound_fwd, active_bounds));
        --bound_max_pair;
    }
    auto hp_itr_fwd = rings.current_hp_itr;
    while (
        hp_itr_fwd != rings.hot_pixels.end() &&
        (hp_itr_fwd->y < scanline_y ||
         (hp_itr_fwd->y == scanline_y && hp_itr_fwd->x < (*horz_bound_fwd)->current_edge->top.x))) {
        ++hp_itr_fwd;
    }
    auto hp_itr = hot_pixel_rev_itr<T>(hp_itr_fwd);

    auto bnd = active_bound_list_rev_itr<T>(horz_bound_fwd);
    auto horz_bound = std::prev(bnd);
    while (bnd != active_bounds.rend()) {
        if (*bnd == nullptr) {
            ++bnd;
            continue;
        }
        // this code block inserts extra coords into horizontal edges (in output
        // polygons) wherever hot pixels touch these horizontal edges.
        while (hp_itr != rings.hot_pixels.rend() && hp_itr->y == scanline_y &&
               hp_itr->x > wround<T>((*bnd)->current_x) &&
               hp_itr->x > (*horz_bound)->current_edge->top.x) {
            if ((*horz_bound)->ring) {
                add_point_to_ring(*(*horz_bound), *hp_itr, rings);
            }
            ++hp_itr;
        }

        if ((*bnd)->current_x < static_cast<double>((*horz_bound)->current_edge->top.x)) {
            break;
        }

        // Also break if we've got to the end of an intermediate horizontal edge ...
        // nb: Smaller Dx's are to the right of larger Dx's ABOVE the horizontal.
        if (wround<T>((*bnd)->current_x) == (*horz_bound)->current_edge->top.x &&
            (*horz_bound)->next_edge != (*horz_bound)->edges.end() &&
            (*horz_bound)->current_edge->dx < (*horz_bound)->next_edge->dx) {
            break;
        }

        // note: may be done multiple times
        if ((*horz_bound)->ring) {
            add_point_to_ring(*(*horz_bound),
                              mapbox::geometry::point<T>(wround<T>((*bnd)->current_x), scanline_y),
                              rings);
        }

        // OK, so far we're still in range of the horizontal Edge  but make sure
        // we're at the last of consec. horizontals when matching with eMaxPair
        if (is_maxima_edge && bnd == bound_max_pair) {
            if ((*horz_bound)->ring) {
                add_local_maximum_point(*(*horz_bound), *(*bound_max_pair),
                                        (*horz_bound)->current_edge->top, rings, active_bounds);
            }
            *bound_max_pair = nullptr;
            *horz_bound = nullptr;
            return next_bnd_itr;
        }

        intersect_bounds(*(*bnd), *(*horz_bound),
                         mapbox::geometry::point<T>(wround<T>((*bnd)->current_x), scanline_y),
                         cliptype, subject_fill_type, clip_fill_type, rings, active_bounds);
        std::iter_swap(horz_bound, bnd);
        horz_bound = bnd;
        ++bnd;
    } // end while (bnd != active_bounds.rend())

    if ((*horz_bound)->ring) {
        while (hp_itr != rings.hot_pixels.rend() && hp_itr->y == scanline_y &&
               hp_itr->x > (*horz_bound)->current_edge->top.x) {
            add_point_to_ring(*(*horz_bound), *hp_itr, rings);
            ++hp_itr;
        }
    }
    if ((*horz_bound)->ring) {
        add_point_to_ring(*(*horz_bound), (*horz_bound)->current_edge->top, rings);
    }

    if ((*horz_bound)->next_edge != (*horz_bound)->edges.end()) {
        next_edge_in_bound(*(*horz_bound), scanbeam);
    } else {
        *horz_bound = nullptr;
    }
    return next_bnd_itr;
}

template <typename T>
active_bound_list_itr<T> process_horizontal(T scanline_y,
                                            active_bound_list_itr<T>& horz_bound,
                                            active_bound_list<T>& active_bounds,
                                            ring_manager<T>& rings,
                                            scanbeam_list<T>& scanbeam,
                                            clip_type cliptype,
                                            fill_type subject_fill_type,
                                            fill_type clip_fill_type) {
    if ((*horz_bound)->current_edge->bot.x < (*horz_bound)->current_edge->top.x) {
        return process_horizontal_left_to_right(scanline_y, horz_bound, active_bounds, rings,
                                                scanbeam, cliptype, subject_fill_type,
                                                clip_fill_type);
    } else {
        return process_horizontal_right_to_left(scanline_y, horz_bound, active_bounds, rings,
                                                scanbeam, cliptype, subject_fill_type,
                                                clip_fill_type);
    }
}

template <typename T>
void process_horizontals(T scanline_y,
                         active_bound_list<T>& active_bounds,
                         ring_manager<T>& rings,
                         scanbeam_list<T>& scanbeam,
                         clip_type cliptype,
                         fill_type subject_fill_type,
                         fill_type clip_fill_type) {
    for (auto bnd_itr = active_bounds.begin(); bnd_itr != active_bounds.end();) {
        if (*bnd_itr != nullptr && current_edge_is_horizontal<T>(bnd_itr)) {
            bnd_itr = process_horizontal(scanline_y, bnd_itr, active_bounds, rings, scanbeam,
                                         cliptype, subject_fill_type, clip_fill_type);
        } else {
            ++bnd_itr;
        }
    }
    active_bounds.erase(std::remove(active_bounds.begin(), active_bounds.end(), nullptr),
                        active_bounds.end());
}
}
}
}