Skip to content

Commit

Permalink
Always to int before abs to make sure it is using the proper abs
Browse files Browse the repository at this point in the history
  • Loading branch information
flippmoke committed Dec 9, 2016
1 parent 94ce406 commit 4ee6478
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions include/mapbox/geometry/wagyu/active_bound_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ void set_winding_count(active_bound_list_itr<T>& 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<int>((*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) {
Expand Down Expand Up @@ -321,7 +321,7 @@ bool is_contributing(bound<T> const& bnd,
}
break;
case fill_type_non_zero:
if (std::abs(bnd.winding_count) != 1) {
if (std::abs(static_cast<int>(bnd.winding_count)) != 1) {
return false;
}
break;
Expand Down
12 changes: 6 additions & 6 deletions include/mapbox/geometry/wagyu/intersect_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,13 @@ void intersect_bounds(active_bound_list_itr<T>& 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<int>((*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<int>((*b1)->winding_count)) == 1) &&
(cliptype != clip_type_union || (*b1)->winding_count2 == 0)) {
add_point(b2, active_bounds, pt, rings);
if (b2Contributing) {
Expand Down Expand Up @@ -217,7 +217,7 @@ void intersect_bounds(active_bound_list_itr<T>& b1,
case fill_type_even_odd:
case fill_type_non_zero:
default:
b1Wc = std::abs((*b1)->winding_count);
b1Wc = std::abs(static_cast<int>((*b1)->winding_count));
}
switch (b2FillType) {
case fill_type_positive:
Expand All @@ -229,7 +229,7 @@ void intersect_bounds(active_bound_list_itr<T>& b1,
case fill_type_even_odd:
case fill_type_non_zero:
default:
b2Wc = std::abs((*b2)->winding_count);
b2Wc = std::abs(static_cast<int>((*b2)->winding_count));
}
if (b1Contributing && b2Contributing) {
if ((b1Wc != 0 && b1Wc != 1) || (b2Wc != 0 && b2Wc != 1) ||
Expand Down Expand Up @@ -269,7 +269,7 @@ void intersect_bounds(active_bound_list_itr<T>& b1,
case fill_type_even_odd:
case fill_type_non_zero:
default:
b1Wc2 = std::abs((*b1)->winding_count2);
b1Wc2 = std::abs(static_cast<int>((*b1)->winding_count2));
}
switch (b2FillType2) {
case fill_type_positive:
Expand All @@ -281,7 +281,7 @@ void intersect_bounds(active_bound_list_itr<T>& b1,
case fill_type_even_odd:
case fill_type_non_zero:
default:
b2Wc2 = std::abs((*b2)->winding_count2);
b2Wc2 = std::abs(static_cast<int>((*b2)->winding_count2));
}

if ((*b1)->poly_type != (*b2)->poly_type) {
Expand Down

0 comments on commit 4ee6478

Please sign in to comment.