From 4ee647837f4f7eba44f5eb0e63ec668f8cc2187e Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Fri, 9 Dec 2016 12:41:45 -0600 Subject: [PATCH] Always to int before abs to make sure it is using the proper abs --- include/mapbox/geometry/wagyu/active_bound_list.hpp | 4 ++-- include/mapbox/geometry/wagyu/intersect_util.hpp | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/mapbox/geometry/wagyu/active_bound_list.hpp b/include/mapbox/geometry/wagyu/active_bound_list.hpp index dbae35e..e08c568 100644 --- a/include/mapbox/geometry/wagyu/active_bound_list.hpp +++ b/include/mapbox/geometry/wagyu/active_bound_list.hpp @@ -247,7 +247,7 @@ void set_winding_count(active_bound_list_itr& bnd_itr, if ((*rev_bnd_itr)->winding_count * (*rev_bnd_itr)->winding_delta < 0) { // prev edge is 'decreasing' WindCount (WC) toward zero // so we're outside the previous polygon ... - if (std::abs((*rev_bnd_itr)->winding_count) > 1) { + if (std::abs(static_cast((*rev_bnd_itr)->winding_count)) > 1) { // outside prev poly but still inside another. // when reversing direction of prev poly use the same WC if ((*rev_bnd_itr)->winding_delta * (*bnd_itr)->winding_delta < 0) { @@ -321,7 +321,7 @@ bool is_contributing(bound const& bnd, } break; case fill_type_non_zero: - if (std::abs(bnd.winding_count) != 1) { + if (std::abs(static_cast(bnd.winding_count)) != 1) { return false; } break; diff --git a/include/mapbox/geometry/wagyu/intersect_util.hpp b/include/mapbox/geometry/wagyu/intersect_util.hpp index 77be594..2f6c40c 100644 --- a/include/mapbox/geometry/wagyu/intersect_util.hpp +++ b/include/mapbox/geometry/wagyu/intersect_util.hpp @@ -141,13 +141,13 @@ void intersect_bounds(active_bound_list_itr& b1, } } else if ((*b1)->poly_type != (*b2)->poly_type) { // toggle subj open path index on/off when std::abs(clip.WndCnt) == 1 - if (((*b1)->winding_delta == 0) && std::abs((*b2)->winding_count) == 1 && + if (((*b1)->winding_delta == 0) && std::abs(static_cast((*b2)->winding_count)) == 1 && (cliptype != clip_type_union || (*b2)->winding_count2 == 0)) { add_point(b1, active_bounds, pt, rings); if (b1Contributing) { (*b1)->ring = nullptr; } - } else if (((*b2)->winding_delta == 0) && (std::abs((*b1)->winding_count) == 1) && + } else if (((*b2)->winding_delta == 0) && (std::abs(static_cast((*b1)->winding_count)) == 1) && (cliptype != clip_type_union || (*b1)->winding_count2 == 0)) { add_point(b2, active_bounds, pt, rings); if (b2Contributing) { @@ -217,7 +217,7 @@ void intersect_bounds(active_bound_list_itr& b1, case fill_type_even_odd: case fill_type_non_zero: default: - b1Wc = std::abs((*b1)->winding_count); + b1Wc = std::abs(static_cast((*b1)->winding_count)); } switch (b2FillType) { case fill_type_positive: @@ -229,7 +229,7 @@ void intersect_bounds(active_bound_list_itr& b1, case fill_type_even_odd: case fill_type_non_zero: default: - b2Wc = std::abs((*b2)->winding_count); + b2Wc = std::abs(static_cast((*b2)->winding_count)); } if (b1Contributing && b2Contributing) { if ((b1Wc != 0 && b1Wc != 1) || (b2Wc != 0 && b2Wc != 1) || @@ -269,7 +269,7 @@ void intersect_bounds(active_bound_list_itr& b1, case fill_type_even_odd: case fill_type_non_zero: default: - b1Wc2 = std::abs((*b1)->winding_count2); + b1Wc2 = std::abs(static_cast((*b1)->winding_count2)); } switch (b2FillType2) { case fill_type_positive: @@ -281,7 +281,7 @@ void intersect_bounds(active_bound_list_itr& b1, case fill_type_even_odd: case fill_type_non_zero: default: - b2Wc2 = std::abs((*b2)->winding_count2); + b2Wc2 = std::abs(static_cast((*b2)->winding_count2)); } if ((*b1)->poly_type != (*b2)->poly_type) {