Upgrade Wagyu to bfbf2893

This commit is contained in:
Eric Fischer
2017-01-04 16:33:43 -08:00
parent e53c8ed7e6
commit bdac4d4e80
37 changed files with 678 additions and 953 deletions
+27 -39
View File
@@ -6,7 +6,6 @@
#include <mapbox/geometry/wagyu/config.hpp>
#include <mapbox/geometry/wagyu/edge.hpp>
#include <mapbox/geometry/wagyu/exceptions.hpp>
#include <mapbox/geometry/wagyu/local_minimum.hpp>
#include <mapbox/geometry/wagyu/util.hpp>
@@ -24,7 +23,6 @@ active_bound_list_itr<T> process_horizontal_left_to_right(T scanline_y,
fill_type subject_fill_type,
fill_type clip_fill_type) {
auto horizontal_itr_behind = horz_bound;
bool is_open = (*horz_bound)->winding_delta == 0;
bool is_maxima_edge = is_maxima(horz_bound, scanline_y);
auto bound_max_pair = active_bounds.end();
if (is_maxima_edge) {
@@ -32,19 +30,22 @@ active_bound_list_itr<T> process_horizontal_left_to_right(T scanline_y,
}
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))) {
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()) {
// 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 < std::llround((*bnd)->current_x) &&
while (hp_itr != rings.hot_pixels.end() && hp_itr->y == scanline_y &&
hp_itr->x < std::llround((*bnd)->current_x) &&
hp_itr->x < (*horz_bound)->current_edge->top.x) {
if ((*horz_bound)->ring && !is_open) {
if ((*horz_bound)->ring) {
add_point_to_ring(*(*horz_bound), *hp_itr, rings);
}
++hp_itr;
@@ -63,11 +64,10 @@ active_bound_list_itr<T> process_horizontal_left_to_right(T scanline_y,
}
// note: may be done multiple times
if ((*horz_bound)->ring && !is_open) {
add_point_to_ring(*(*horz_bound),
mapbox::geometry::point<T>(std::llround((*bnd)->current_x),
scanline_y),
rings);
if ((*horz_bound)->ring) {
add_point_to_ring(
*(*horz_bound),
mapbox::geometry::point<T>(std::llround((*bnd)->current_x), scanline_y), rings);
}
// OK, so far we're still in range of the horizontal Edge but make sure
@@ -87,8 +87,7 @@ active_bound_list_itr<T> process_horizontal_left_to_right(T scanline_y,
}
intersect_bounds(horz_bound, bnd,
mapbox::geometry::point<T>(std::llround((*bnd)->current_x),
scanline_y),
mapbox::geometry::point<T>(std::llround((*bnd)->current_x), scanline_y),
cliptype, subject_fill_type, clip_fill_type, rings, active_bounds);
auto next_bnd = std::next(bnd);
swap_positions_in_ABL(horz_bound, bnd, active_bounds);
@@ -98,7 +97,7 @@ active_bound_list_itr<T> process_horizontal_left_to_right(T scanline_y,
bnd = next_bnd;
} // end while (bnd != active_bounds.end())
if ((*horz_bound)->ring && !is_open) {
if ((*horz_bound)->ring) {
while (hp_itr != rings.hot_pixels.end() && hp_itr->y == scanline_y &&
hp_itr->x < std::llround((*horz_bound)->current_edge->top.x)) {
add_point_to_ring(*(*horz_bound), *hp_itr, rings);
@@ -110,14 +109,6 @@ active_bound_list_itr<T> process_horizontal_left_to_right(T scanline_y,
if ((*horz_bound)->ring) {
add_point_to_ring(*(*horz_bound), (*horz_bound)->current_edge->top, rings);
next_edge_in_bound(horz_bound, scanbeam);
if ((*horz_bound)->winding_delta == 0) {
if (horizontal_itr_behind != horz_bound) {
return horizontal_itr_behind;
} else {
return std::next(horz_bound);
}
}
} else {
next_edge_in_bound(horz_bound, scanbeam);
}
@@ -148,14 +139,15 @@ active_bound_list_itr<T> process_horizontal_right_to_left(T scanline_y,
clip_type cliptype,
fill_type subject_fill_type,
fill_type clip_fill_type) {
bool is_open = (*horz_bound)->winding_delta == 0;
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_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)->current_edge->top.x))) {
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)->current_edge->top.x))) {
++hp_itr_fwd;
}
auto hp_itr = hot_pixel_rev_itr<T>(hp_itr_fwd);
@@ -164,9 +156,10 @@ active_bound_list_itr<T> process_horizontal_right_to_left(T scanline_y,
while (bnd != active_bounds.rend()) {
// 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 > std::llround((*bnd)->current_x) &&
while (hp_itr != rings.hot_pixels.rend() && hp_itr->y == scanline_y &&
hp_itr->x > std::llround((*bnd)->current_x) &&
hp_itr->x > (*horz_bound)->current_edge->top.x) {
if ((*horz_bound)->ring && !is_open) {
if ((*horz_bound)->ring) {
add_point_to_ring(*(*horz_bound), *hp_itr, rings);
}
++hp_itr;
@@ -185,11 +178,10 @@ active_bound_list_itr<T> process_horizontal_right_to_left(T scanline_y,
}
// note: may be done multiple times
if ((*horz_bound)->ring && !is_open) {
add_point_to_ring(*(*horz_bound),
mapbox::geometry::point<T>(std::llround((*bnd)->current_x),
scanline_y),
rings);
if ((*horz_bound)->ring) {
add_point_to_ring(
*(*horz_bound),
mapbox::geometry::point<T>(std::llround((*bnd)->current_x), scanline_y), rings);
}
auto bnd_forward = --(bnd.base());
@@ -205,8 +197,7 @@ active_bound_list_itr<T> process_horizontal_right_to_left(T scanline_y,
}
intersect_bounds(bnd_forward, horz_bound,
mapbox::geometry::point<T>(std::llround((*bnd)->current_x),
scanline_y),
mapbox::geometry::point<T>(std::llround((*bnd)->current_x), scanline_y),
cliptype, subject_fill_type, clip_fill_type, rings, active_bounds);
swap_positions_in_ABL(horz_bound, bnd_forward, active_bounds);
// Why are we not incrementing the bnd iterator here:
@@ -216,8 +207,9 @@ active_bound_list_itr<T> process_horizontal_right_to_left(T scanline_y,
// so what the reverse bound points to will have changed.
} // end while (bnd != active_bounds.rend())
if ((*horz_bound)->ring && !is_open) {
while (hp_itr != rings.hot_pixels.rend() && hp_itr->y == scanline_y && hp_itr->x > (*horz_bound)->current_edge->top.x) {
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;
}
@@ -227,10 +219,6 @@ active_bound_list_itr<T> process_horizontal_right_to_left(T scanline_y,
if ((*horz_bound)->ring) {
add_point_to_ring(*(*horz_bound), (*horz_bound)->current_edge->top, rings);
next_edge_in_bound(horz_bound, scanbeam);
if ((*horz_bound)->winding_delta == 0) {
return std::next(horz_bound);
}
} else {
next_edge_in_bound(horz_bound, scanbeam);
}