From c4af782c0cc2f18a6fc8d6f7b30f3f215ea990e1 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Fri, 23 May 2014 00:35:44 +0300 Subject: [PATCH] [distance] eliminate more useless code in segment-box computation --- .../detail/distance/segment_to_box.hpp | 57 ++++--------------- 1 file changed, 10 insertions(+), 47 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp b/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp index 8a3abd950..c6185d570 100644 --- a/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp +++ b/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp @@ -235,7 +235,7 @@ private: }; template - struct compare_equal + struct compare_less_equal { template inline bool operator()(T1 const& t1, T2 const& t2) const @@ -246,11 +246,11 @@ private: }; template - struct less_equal : compare_equal > + struct less_equal : compare_less_equal > {}; template - struct greater_equal : compare_equal > + struct greater_equal : compare_less_equal > {}; template @@ -315,26 +315,6 @@ private: }; - // it is assumed here that p1 lies to the left of the box (so the - // entire segment lies to the left of the box) - template - struct left_of_box - { - static inline ReturnType apply(SegmentPoint const& p0, - SegmentPoint const& p1, - BoxPoint const& bottom_left, - BoxPoint const& top_left, - PPStrategy const& pp_strategy, - PSStrategy const& ps_strategy) - { - return right_of_box - < - typename other_compare::type - >::apply(p1, p0, top_left, bottom_left, - pp_strategy, ps_strategy); - } - }; - // it is assumed here that p0 lies above the box (so the // entire segment lies above the box) template @@ -368,23 +348,6 @@ private: }; - // it is assumed here that p1 lies below the box (so the - // entire segment lies below the box) - template - struct below_of_box - { - static inline ReturnType apply(SegmentPoint const& p0, - SegmentPoint const& p1, - BoxPoint const& bottom_right, - PSStrategy const& ps_strategy) - { - return above_of_box - < - typename other_compare::type - >::apply(p1, p0, bottom_right, ps_strategy); - } - }; - template struct check_right_left_of_box { @@ -412,10 +375,10 @@ private: // p1 lies to the left of the box if ( get<0>(p1) <= geometry::get<0>(bottom_left) ) { - result = left_of_box + result = right_of_box < - LessEqual - >::apply(p0, p1, bottom_left, top_left, + typename other_compare::type + >::apply(p1, p0, top_left, bottom_left, pp_strategy, ps_strategy); return true; } @@ -441,14 +404,14 @@ private: // the segment lies below the box if ( geometry::get<1>(p1) < geometry::get<1>(bottom_left) ) { - result = below_of_box + result = above_of_box < - LessEqual - >::apply(p0, p1, bottom_right, ps_strategy); + typename other_compare::type + >::apply(p1, p0, bottom_right, ps_strategy); return true; } - + // the segment lies above the box if ( geometry::get<1>(p0) > geometry::get<1>(top_right) ) { result = above_of_box