diff --git a/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp b/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp index 3e691f4d7..eb76b94f2 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp @@ -43,7 +43,6 @@ struct buffer_range { typedef typename point_type::type output_point_type; typedef typename coordinate_type::type coordinate_type; - typedef model::referring_segment segment_type; template @@ -103,11 +102,9 @@ struct buffer_range RobustPolicy const& ) { - segment_type previous_segment(prev_perp1, prev_perp2); - segment_type segment(perp1, perp2); output_point_type intersection_point; - if (line_line_intersection::apply( - segment, previous_segment, intersection_point)) + if (line_line_intersection::apply( + perp1, perp2, prev_perp1, prev_perp2, intersection_point)) { std::vector range_out; if (join_strategy.apply(intersection_point, @@ -247,7 +244,6 @@ struct buffer_point { typedef typename point_type::type output_point_type; typedef typename coordinate_type::type coordinate_type; - typedef model::referring_segment segment_type; typedef typename geometry::select_most_precise < diff --git a/include/boost/geometry/algorithms/detail/buffer/line_line_intersection.hpp b/include/boost/geometry/algorithms/detail/buffer/line_line_intersection.hpp index bdcb2b585..68608b33b 100644 --- a/include/boost/geometry/algorithms/detail/buffer/line_line_intersection.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/line_line_intersection.hpp @@ -24,7 +24,6 @@ namespace detail { namespace buffer // TODO: once change this to proper strategy // It is different from current segment intersection because these are not segments but lines // If we have the Line concept, we can create a strategy -template struct line_line_intersection { template @@ -42,16 +41,14 @@ struct line_line_intersection && math::sign(dy1) == math::sign(dy2); } - static inline bool apply(Line1 const& line1, Line2 const& line2, Point& ip) + template + static inline bool apply(Point const& pi, Point const& pj, + Point const& qi, Point const& qj, Point& ip) { // See http://mathworld.wolfram.com/Line-LineIntersection.html typedef typename coordinate_type::type coordinate_type; - coordinate_type x1 = get<0,0>(line1), y1 = get<0,1>(line1); - coordinate_type x2 = get<1,0>(line1), y2 = get<1,1>(line1); - coordinate_type x3 = get<0,0>(line2), y3 = get<0,1>(line2); - coordinate_type x4 = get<1,0>(line2), y4 = get<1,1>(line2); - coordinate_type denominator = det(x1 - x2, y1 - y2, x3 - x4, y3 - y4); + coordinate_type denominator = det(get<0>(pi) - get<0>(pj), get<1>(pi) - get<1>(pj), get<0>(qi) - get<0>(qj), get<1>(qi) - get<1>(qj)); // TODO: maybe use something else then denominator (sides?) to determine this. @@ -74,7 +71,10 @@ struct line_line_intersection // +---------------/ x3,y4 // x4,y4 // We then calculate the IP from one of the segments up to a certain distance - if (parallel_continue(x4 - x3, y4 - y3, x2 - x1, y2 - y1)) + if (parallel_continue(get<0>(qj) - get<0>(qi), + get<1>(qj) - get<1>(qi), + get<0>(pj) - get<0>(pi), + get<1>(pj) - get<1>(pi))) { return false; } @@ -82,13 +82,11 @@ struct line_line_intersection denominator = limit; } - coordinate_type d1 = det(x1, y1, x2, y2); - coordinate_type d2 = det(x3, y3, x4, y4); - coordinate_type px = det(d1, x1 - x2, d2, x3 - x4) / denominator; - coordinate_type py = det(d1, y1 - y2, d2, y3 - y4) / denominator; + coordinate_type d1 = det(get<0>(pi), get<1>(pi), get<0>(pj), get<1>(pj)); + coordinate_type d2 = det(get<0>(qi), get<1>(qi), get<0>(qj), get<1>(qj)); - set<0>(ip, px); - set<1>(ip, py); + set<0>(ip, det(d1, get<0>(pi) - get<0>(pj), d2, get<0>(qi) - get<0>(qj)) / denominator); + set<1>(ip, det(d1, get<1>(pi) - get<1>(pj), d2, get<1>(qi) - get<1>(qj)) / denominator); return true; }