Upgrade Wagyu to version 0.5.0

This commit is contained in:
Eric Fischer
2020-08-25 17:00:50 -07:00
parent ddb79937d9
commit e0c7f1b91a
55 changed files with 794 additions and 576 deletions
+29 -41
View File
@@ -32,8 +32,7 @@ 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))) {
(hp_itr->y > scanline_y || (hp_itr->y == scanline_y && hp_itr->x < (*horz_bound)->current_edge->bot.x))) {
++hp_itr;
}
@@ -48,15 +47,14 @@ active_bound_list_itr<T> process_horizontal_left_to_right(T scanline_y,
// 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) {
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)) {
if (greater_than((*bnd)->current_x, static_cast<double>((*horz_bound)->current_edge->top.x))) {
break;
}
@@ -70,17 +68,16 @@ active_bound_list_itr<T> process_horizontal_left_to_right(T scanline_y,
// 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),
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);
if ((*horz_bound)->ring && (*bound_max_pair)->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;
@@ -90,8 +87,7 @@ active_bound_list_itr<T> process_horizontal_left_to_right(T scanline_y,
return horizontal_itr_behind;
}
intersect_bounds(*(*horz_bound), *(*bnd),
mapbox::geometry::point<T>(wround<T>((*bnd)->current_x), scanline_y),
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;
@@ -135,15 +131,13 @@ active_bound_list_itr<T> process_horizontal_right_to_left(T scanline_y,
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 = 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))) {
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);
@@ -158,15 +152,14 @@ active_bound_list_itr<T> process_horizontal_right_to_left(T scanline_y,
// 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) {
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)) {
if (less_than((*bnd)->current_x, static_cast<double>((*horz_bound)->current_edge->top.x))) {
break;
}
@@ -180,25 +173,23 @@ active_bound_list_itr<T> process_horizontal_right_to_left(T scanline_y,
// 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),
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);
if ((*horz_bound)->ring && (*bound_max_pair)->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),
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;
@@ -234,13 +225,11 @@ active_bound_list_itr<T> process_horizontal(T scanline_y,
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);
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);
return process_horizontal_right_to_left(scanline_y, horz_bound, active_bounds, rings, scanbeam, cliptype,
subject_fill_type, clip_fill_type);
}
}
@@ -254,15 +243,14 @@ void process_horizontals(T scanline_y,
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);
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());
}
}
}
active_bounds.erase(std::remove(active_bounds.begin(), active_bounds.end(), nullptr), active_bounds.end());
}
} // namespace wagyu
} // namespace geometry
} // namespace mapbox