Skip to content

Commit

Permalink
メンテナーのパッチ(レビュー中)に置き換え
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitsuhiko-Matsukawa committed Nov 15, 2022
1 parent ff4dca3 commit 56332e9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,9 @@ struct get_distance_measure<CalculationType, cartesian_tag>
// Get the distance measure / side value
// It is not a real distance and purpose is
// to detect small differences in collinearity

auto const line = detail::make::make_infinite_line<CalculationType>(p1, p2);
result_type result;
if (equals(p, p1) || equals(p, p2)) {
result.measure = 0;
}
else {
result.measure = arithmetic::side_value(line, p);
}
result.measure = arithmetic::side_value(line, p);
return result;
}
};
Expand All @@ -122,17 +116,32 @@ namespace detail
// 0 (absolutely 0, not even an epsilon) means collinear. Like side,
// a negative means that p is to the right of p1-p2. And a positive value
// means that p is to the left of p1-p2.

template <typename SegmentPoint, typename Point, typename Strategies>
inline auto get_distance_measure(SegmentPoint const& p1, SegmentPoint const& p2, Point const& p,
Strategies const&)
{
return detail_dispatch::get_distance_measure
<
typename select_coordinate_type<SegmentPoint, Point>::type,
typename Strategies::cs_tag
>::apply(p1, p2, p);
using calc_t = typename select_coordinate_type<SegmentPoint, Point>::type;

// Verify equality, without using a tolerance
// (so don't use equals or equals_point_point)
// because it is about very tiny differences.
auto identical = [](const auto& point1, const auto& point2)
{
return geometry::get<0>(point1) == geometry::get<0>(point2)
&& geometry::get<1>(point1) == geometry::get<1>(point2);
};

if (identical(p1, p) || identical(p2, p))
{
detail::distance_measure<calc_t> const result;
return result;
}

return detail_dispatch::get_distance_measure
<
calc_t,
typename Strategies::cs_tag
>::apply(p1, p2, p);
}

} // namespace detail
Expand Down
19 changes: 8 additions & 11 deletions include/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,12 +587,14 @@ struct touch : public base_turn_handler
// >----->P qj is LEFT of P1 and pi is LEFT of Q2
// (the other way round is also possible)

auto const dm_qj_p1 = get_distance_measure(range_p.at(0), range_p.at(1), range_q.at(1),
umbrella_strategy);
auto const dm_pi_q2 = get_distance_measure(range_q.at(1), range_q.at(2), range_p.at(0),
umbrella_strategy);
auto has_distance = [&](const auto& r1, const auto& r2) -> bool
{
auto const d1 = get_distance_measure(r1.at(0), r1.at(1), r2.at(1), umbrella_strategy);
auto const d2 = get_distance_measure(r2.at(1), r2.at(2), r1.at(0), umbrella_strategy);
return d1.measure > 0 && d2.measure > 0;
};

if (dm_qj_p1.measure > 0 && dm_pi_q2.measure > 0)
if (has_distance(range_p, range_q))
{
// Even though there is a touch, Q(j) is left of P1
// and P(i) is still left from Q2.
Expand All @@ -605,12 +607,7 @@ struct touch : public base_turn_handler
return true;
}

auto const dm_pj_q1 = get_distance_measure(range_q.at(0), range_q.at(1), range_p.at(1),
umbrella_strategy);
auto const dm_qi_p2 = get_distance_measure(range_p.at(1), range_p.at(2), range_q.at(0),
umbrella_strategy);

if (dm_pj_q1.measure > 0 && dm_qi_p2.measure > 0)
if (has_distance(range_q, range_p))
{
// Even though there is a touch, Q(j) is left of P1
// and P(i) is still left from Q2.
Expand Down

0 comments on commit 56332e9

Please sign in to comment.