This file is indexed.

/usr/include/mapbox/geometry/wagyu/snap_rounding.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
#pragma once

#include <mapbox/geometry/wagyu/active_bound_list.hpp>
#include <mapbox/geometry/wagyu/bound.hpp>
#include <mapbox/geometry/wagyu/bubble_sort.hpp>
#include <mapbox/geometry/wagyu/config.hpp>
#include <mapbox/geometry/wagyu/edge.hpp>
#include <mapbox/geometry/wagyu/intersect.hpp>
#include <mapbox/geometry/wagyu/intersect_util.hpp>
#include <mapbox/geometry/wagyu/ring.hpp>
#include <mapbox/geometry/wagyu/ring_util.hpp>
#include <mapbox/geometry/wagyu/util.hpp>

namespace mapbox {
namespace geometry {
namespace wagyu {

template <typename T>
struct hp_intersection_swap {

    ring_manager<T>& manager;

    hp_intersection_swap(ring_manager<T>& m) : manager(m) {
    }

    void operator()(bound_ptr<T> const& b1, bound_ptr<T> const& b2) {
        mapbox::geometry::point<double> pt;
        if (!get_edge_intersection<T, double>(*(b1->current_edge), *(b2->current_edge), pt)) {
            // LCOV_EXCL_START
            throw std::runtime_error("Trying to find intersection of lines that do not intersect");
            // LCOV_EXCL_END
        }
        add_to_hot_pixels(round_point<T>(pt), manager);
    }
};

template <typename T>
void process_hot_pixel_intersections(T top_y,
                                     active_bound_list<T>& active_bounds,
                                     ring_manager<T>& manager) {
    if (active_bounds.empty()) {
        return;
    }
    update_current_x(active_bounds, top_y);
    bubble_sort(active_bounds.begin(), active_bounds.end(), intersection_compare<T>(),
                hp_intersection_swap<T>(manager));
}

template <typename T>
bool horizontals_at_top_scanbeam(T top_y,
                                 active_bound_list_itr<T>& bnd_curr,
                                 active_bound_list<T>& active_bounds,
                                 ring_manager<T>& manager) {
    bool shifted = false;
    auto& current_edge = (*bnd_curr)->current_edge;
    (*bnd_curr)->current_x = static_cast<double>(current_edge->top.x);
    if (current_edge->bot.x < current_edge->top.x) {
        // left to right
        auto bnd_next = std::next(bnd_curr);
        while (bnd_next != active_bounds.end() &&
               (*bnd_next == nullptr || (*bnd_next)->current_x < (*bnd_curr)->current_x)) {
            if (*bnd_next != nullptr && (*bnd_next)->current_edge->top.y != top_y &&
                (*bnd_next)->current_edge->bot.y != top_y) {
                mapbox::geometry::point<T> pt(wround<T>((*bnd_next)->current_x), top_y);
                add_to_hot_pixels(pt, manager);
            }
            std::iter_swap(bnd_curr, bnd_next);
            ++bnd_curr;
            ++bnd_next;
            shifted = true;
        }
    } else {
        // right to left
        if (bnd_curr != active_bounds.begin()) {
            auto bnd_prev = std::prev(bnd_curr);
            while (bnd_curr != active_bounds.begin() &&
                   (*bnd_prev == nullptr || (*bnd_prev)->current_x > (*bnd_curr)->current_x)) {
                if (*bnd_prev != nullptr && (*bnd_prev)->current_edge->top.y != top_y &&
                    (*bnd_prev)->current_edge->bot.y != top_y) {
                    mapbox::geometry::point<T> pt(wround<T>((*bnd_prev)->current_x), top_y);
                    add_to_hot_pixels(pt, manager);
                }
                std::iter_swap(bnd_curr, bnd_prev);
                --bnd_curr;
                if (bnd_curr != active_bounds.begin()) {
                    --bnd_prev;
                }
            }
        }
    }
    return shifted;
}

template <typename T>
void process_hot_pixel_edges_at_top_of_scanbeam(T top_y,
                                                scanbeam_list<T>& scanbeam,
                                                active_bound_list<T>& active_bounds,
                                                ring_manager<T>& manager) {
    for (auto bnd = active_bounds.begin(); bnd != active_bounds.end();) {
        if (*bnd == nullptr) {
            ++bnd;
            continue;
        }
        bound<T>& current_bound = *(*bnd);
        auto bnd_curr = bnd;
        bool shifted = false;
        auto& current_edge = current_bound.current_edge;
        while (current_edge != current_bound.edges.end() && current_edge->top.y == top_y) {
            add_to_hot_pixels(current_edge->top, manager);
            if (is_horizontal(*current_edge)) {
                if (horizontals_at_top_scanbeam(top_y, bnd_curr, active_bounds, manager)) {
                    shifted = true;
                }
            }
            next_edge_in_bound(current_bound, scanbeam);
        }
        if (current_edge == current_bound.edges.end()) {
            *bnd_curr = nullptr;
        }
        if (!shifted) {
            ++bnd;
        }
    }
    active_bounds.erase(std::remove(active_bounds.begin(), active_bounds.end(), nullptr),
                        active_bounds.end());
}

template <typename T>
void insert_local_minima_into_ABL_hot_pixel(T top_y,
                                            local_minimum_ptr_list<T>& minima_sorted,
                                            local_minimum_ptr_list_itr<T>& lm,
                                            active_bound_list<T>& active_bounds,
                                            ring_manager<T>& manager,
                                            scanbeam_list<T>& scanbeam) {
    while (lm != minima_sorted.end() && (*lm)->y == top_y) {
        add_to_hot_pixels((*lm)->left_bound.edges.front().bot, manager);
        auto& left_bound = (*lm)->left_bound;
        auto& right_bound = (*lm)->right_bound;
        left_bound.current_edge = left_bound.edges.begin();
        left_bound.next_edge = std::next(left_bound.current_edge);
        left_bound.current_x = static_cast<double>(left_bound.current_edge->bot.x);
        right_bound.current_edge = right_bound.edges.begin();
        right_bound.next_edge = std::next(right_bound.current_edge);
        right_bound.current_x = static_cast<double>(right_bound.current_edge->bot.x);
        auto lb_abl_itr = insert_bound_into_ABL(left_bound, right_bound, active_bounds);
        if (!current_edge_is_horizontal<T>(lb_abl_itr)) {
            scanbeam.push_back((*lb_abl_itr)->current_edge->top.y);
        }
        auto rb_abl_itr = std::next(lb_abl_itr);
        if (!current_edge_is_horizontal<T>(rb_abl_itr)) {
            scanbeam.push_back((*rb_abl_itr)->current_edge->top.y);
        }
        ++lm;
    }
}

template <typename T>
void build_hot_pixels(local_minimum_list<T>& minima_list, ring_manager<T>& manager) {
    active_bound_list<T> active_bounds;
    scanbeam_list<T> scanbeam;
    T scanline_y = std::numeric_limits<T>::max();

    local_minimum_ptr_list<T> minima_sorted;
    minima_sorted.reserve(minima_list.size());
    for (auto& lm : minima_list) {
        minima_sorted.push_back(&lm);
    }
    std::stable_sort(minima_sorted.begin(), minima_sorted.end(), local_minimum_sorter<T>());
    local_minimum_ptr_list_itr<T> current_lm = minima_sorted.begin();

    setup_scanbeam(minima_list, scanbeam);

    // Estimate size for reserving hot pixels
    std::size_t reserve = 0;
    for (auto& lm : minima_list) {
        reserve += lm.left_bound.edges.size() + 2;
        reserve += lm.right_bound.edges.size() + 2;
    }
    manager.hot_pixels.reserve(reserve);

    while (pop_from_scanbeam(scanline_y, scanbeam) || current_lm != minima_sorted.end()) {

        process_hot_pixel_intersections(scanline_y, active_bounds, manager);

        insert_local_minima_into_ABL_hot_pixel(scanline_y, minima_sorted, current_lm, active_bounds,
                                               manager, scanbeam);

        process_hot_pixel_edges_at_top_of_scanbeam(scanline_y, scanbeam, active_bounds, manager);
    }
    preallocate_point_memory(manager, manager.hot_pixels.size());
    sort_hot_pixels(manager);
}
}
}
}