diff --git a/include/boost/geometry/algorithms/detail/rescale.hpp b/include/boost/geometry/algorithms/detail/rescale.hpp index 6fdbcb3cd..ce4ab6d56 100644 --- a/include/boost/geometry/algorithms/detail/rescale.hpp +++ b/include/boost/geometry/algorithms/detail/rescale.hpp @@ -25,8 +25,6 @@ namespace detail struct no_rescale_policy { - // TODO the type should be passed - typedef segment_ratio segment_ratio_type; // We don't rescale but return the reference. zero cost. template @@ -47,6 +45,15 @@ struct robust_point_type typedef Point type; }; +// Meta-function to access segment-ratio +// By default, the segment ratio is derived from corresponding point-type +// A policy can specialize this. +template +struct segment_ratio_type +{ + // TODO set to coordinate type + typedef segment_ratio type; +}; #endif diff --git a/include/boost/geometry/algorithms/detail/zoom_to_robust.hpp b/include/boost/geometry/algorithms/detail/zoom_to_robust.hpp index b22c85f92..8338af031 100644 --- a/include/boost/geometry/algorithms/detail/zoom_to_robust.hpp +++ b/include/boost/geometry/algorithms/detail/zoom_to_robust.hpp @@ -56,8 +56,6 @@ struct get_max_size template struct rescale_strategy { - typedef segment_ratio segment_ratio_type; - typedef typename geometry::coordinate_type::type output_ct; rescale_strategy(FpPoint const& fp_min, IntPoint const& int_min, CalculationType const& the_factor) @@ -93,6 +91,14 @@ struct robust_point_type +struct segment_ratio_type > +{ + typedef segment_ratio type; +}; + + template inline typename coordinate_type::type get_max_size(Box const& box) @@ -316,7 +322,6 @@ template > struct rescale_policy_type { - typedef Point robust_point_type; typedef no_rescale_policy type; }; @@ -327,13 +332,14 @@ template > struct rescale_policy_type { +private: typedef model::point < typename geometry::robust_type::type>::type, geometry::dimension::value, typename geometry::coordinate_system::type > robust_point_type; - +public: typedef detail::zoom_to_robust::rescale_strategy type; }; diff --git a/include/boost/geometry/strategies/cartesian/cart_intersect.hpp b/include/boost/geometry/strategies/cartesian/cart_intersect.hpp index 13dad3cdb..38cd2bab9 100644 --- a/include/boost/geometry/strategies/cartesian/cart_intersect.hpp +++ b/include/boost/geometry/strategies/cartesian/cart_intersect.hpp @@ -108,6 +108,8 @@ struct relate_cartesian_segments BOOST_CONCEPT_ASSERT( (concept::ConstSegment) ); BOOST_CONCEPT_ASSERT( (concept::ConstSegment) ); + boost::ignore_unused_variable_warning(robust_policy); + typedef typename select_calculation_type ::type coordinate_type; @@ -163,11 +165,17 @@ struct relate_cartesian_segments RobustPoint >::type robust_coordinate_type; + typedef typename segment_ratio_type + < + typename geometry::point_type::type, // TODO: most precise point? + RobustPolicy + >::type ratio_type; + segment_intersection_info < coordinate_type, promoted_type, - typename RobustPolicy::segment_ratio_type + ratio_type > sinfo; sinfo.dx_a = get<1, 0>(a) - get<0, 0>(a); // distance in x-dir @@ -269,12 +277,12 @@ struct relate_cartesian_segments >= geometry::math::abs(robust_dy_a) + geometry::math::abs(robust_dy_b); if (collinear_use_first) { - return relate_collinear<0>(a, b, robust_policy, robust_a1, robust_a2, robust_b1, robust_b2); + return relate_collinear<0, ratio_type>(a, b, robust_a1, robust_a2, robust_b1, robust_b2); } else { // Y direction contains larger segments (maybe dx is zero) - return relate_collinear<1>(a, b, robust_policy, robust_a1, robust_a2, robust_b1, robust_b2); + return relate_collinear<1, ratio_type>(a, b, robust_a1, robust_a2, robust_b1, robust_b2); } } @@ -314,14 +322,20 @@ private : } private: - template + template + < + std::size_t Dimension, + typename RatioType, + typename Segment1, + typename Segment2, + typename RobustPoint + > static inline return_type relate_collinear(Segment1 const& a, Segment2 const& b, - RobustPolicy const& robust_policy, RobustPoint const& robust_a1, RobustPoint const& robust_a2, RobustPoint const& robust_b1, RobustPoint const& robust_b2) { - return relate_collinear(a, b, robust_policy, + return relate_collinear(a, b, get(robust_a1), get(robust_a2), get(robust_b1), @@ -329,10 +343,15 @@ private: } /// Relate segments known collinear - template + template + < + typename RatioType, + typename Segment1, + typename Segment2, + typename RobustType + > static inline return_type relate_collinear(Segment1 const& a , Segment2 const& b - , RobustPolicy const& robust_policy , RobustType oa_1, RobustType oa_2 , RobustType ob_1, RobustType ob_2 ) @@ -370,12 +389,10 @@ private: RobustType const length_a = oa_2 - oa_1; // no abs, see above RobustType const length_b = ob_2 - ob_1; - boost::ignore_unused_variable_warning(robust_policy); - typedef typename RobustPolicy::segment_ratio_type ratio_type; - ratio_type const ra_from(oa_1 - ob_1, length_b); - ratio_type const ra_to(oa_2 - ob_1, length_b); - ratio_type const rb_from(ob_1 - oa_1, length_a); - ratio_type const rb_to(ob_2 - oa_1, length_a); + RatioType const ra_from(oa_1 - ob_1, length_b); + RatioType const ra_to(oa_2 - ob_1, length_b); + RatioType const rb_from(ob_1 - oa_1, length_a); + RatioType const rb_to(ob_2 - oa_1, length_a); if ((ra_from.left() && ra_to.left()) || (ra_from.right() && ra_to.right())) {