diff --git a/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp b/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp index 9c984f0b8..b00faadac 100644 --- a/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #ifdef BOOST_GEOMETRY_DEBUG_ENRICH # include @@ -77,6 +76,7 @@ template typename TurnPoints, typename Indexed, typename Geometry1, typename Geometry2, + typename RobustPolicy, bool Reverse1, bool Reverse2, typename Strategy > @@ -85,11 +85,13 @@ struct sort_on_segment_and_ratio inline sort_on_segment_and_ratio(TurnPoints const& turn_points , Geometry1 const& geometry1 , Geometry2 const& geometry2 + , RobustPolicy const& robust_policy , Strategy const& strategy , bool* clustered) : m_turn_points(turn_points) , m_geometry1(geometry1) , m_geometry2(geometry2) + , m_robust_policy(robust_policy) , m_strategy(strategy) , m_clustered(clustered) { @@ -100,25 +102,26 @@ private : TurnPoints const& m_turn_points; Geometry1 const& m_geometry1; Geometry2 const& m_geometry2; + RobustPolicy const& m_robust_policy; Strategy const& m_strategy; mutable bool* m_clustered; - typedef model::point - < - typename detail::robust_type - < - typename select_coordinate_type::type - >::type, - geometry::dimension::value, - typename geometry::coordinate_system::type - > robust_point_type; + typedef typename geometry::point_type::type point_type; + typedef typename geometry::robust_point_type + < + point_type, + RobustPolicy + >::type robust_point_type; + // TODO: this function is shared with handle_tangencies + // The one in handle_tangencies will go as soon as we have + // reliable "cluster_info" (using occupation_map, get_left_turns) inline void get_situation_map(Indexed const& left, Indexed const& right, robust_point_type& pi_rob, robust_point_type& pj_rob, robust_point_type& ri_rob, robust_point_type& rj_rob, robust_point_type& si_rob, robust_point_type& sj_rob) const { - typename geometry::point_type::type pi, pj, ri, rj, si, sj; + point_type pi, pj, ri, rj, si, sj; geometry::copy_segment_points(m_geometry1, m_geometry2, left.subject.seg_id, @@ -129,8 +132,13 @@ private : geometry::copy_segment_points(m_geometry1, m_geometry2, right.subject.other_id, si, sj); - detail::zoom_to_robust(pi, pj, ri, rj, si, sj, - pi_rob, pj_rob, ri_rob, rj_rob, si_rob, sj_rob); + + geometry::recalculate(pi_rob, pi, m_robust_policy); + geometry::recalculate(pj_rob, pj, m_robust_policy); + geometry::recalculate(ri_rob, ri, m_robust_policy); + geometry::recalculate(rj_rob, rj, m_robust_policy); + geometry::recalculate(si_rob, si, m_robust_policy); + geometry::recalculate(sj_rob, sj, m_robust_policy); } inline bool consider_relative_order(Indexed const& left, @@ -235,9 +243,10 @@ inline void enrich_sort(Container& operations, TurnPoints, IndexType, Geometry1, Geometry2, + RobustPolicy, Reverse1, Reverse2, Strategy - >(turn_points, geometry1, geometry2, strategy, &clustered)); + >(turn_points, geometry1, geometry2, robust_policy, strategy, &clustered)); // DONT'T discard xx / (for union) ix / ii / (for intersection) ux / uu here // It would give way to "lonely" ui turn points, traveling all diff --git a/include/boost/geometry/algorithms/detail/overlay/handle_tangencies.hpp b/include/boost/geometry/algorithms/detail/overlay/handle_tangencies.hpp index 92d162032..9bb828498 100644 --- a/include/boost/geometry/algorithms/detail/overlay/handle_tangencies.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/handle_tangencies.hpp @@ -19,7 +19,6 @@ #include #include #include -#include #if defined(BOOST_GEOMETRY_DEBUG_HANDLE_TANGENCIES) #include @@ -71,16 +70,13 @@ private : typedef typename Indexed::type turn_operation_type; typedef typename geometry::point_type::type point_type; - typedef model::point + typedef typename geometry::robust_point_type < - typename detail::robust_type - < - typename select_coordinate_type::type - >::type, - geometry::dimension::value, - typename geometry::coordinate_system::type - > robust_point_type; + point_type, + RobustPolicy + >::type robust_point_type; + // TODO: this function is shared with enrich_intersection_points // Still called by #case_102_multi, #case_107_multi // #case_recursive_boxes_3 inline void get_situation_map(Indexed const& left, Indexed const& right, @@ -88,7 +84,6 @@ private : robust_point_type& ri_rob, robust_point_type& rj_rob, robust_point_type& si_rob, robust_point_type& sj_rob) const { - typedef typename geometry::point_type::type point_type; point_type pi, pj, ri, rj, si, sj; geometry::copy_segment_points(m_geometry1, m_geometry2, diff --git a/include/boost/geometry/algorithms/detail/zoom_to_robust.hpp b/include/boost/geometry/algorithms/detail/zoom_to_robust.hpp deleted file mode 100644 index ac78a200b..000000000 --- a/include/boost/geometry/algorithms/detail/zoom_to_robust.hpp +++ /dev/null @@ -1,180 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) - -// Copyright (c) 2013 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2013 Bruno Lalande, Paris, France. -// Copyright (c) 2013 Mateusz Loskot, London, UK. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. - -// Use, modification and distribution is subject to the Boost Software License, -// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ZOOM_TO_ROBUST_HPP -#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ZOOM_TO_ROBUST_HPP - - -#include - -#include - -#include -#include -#include -#include - -#include -#include - -#include - -namespace boost { namespace geometry -{ - - -#ifndef DOXYGEN_NO_DISPATCH -namespace dispatch -{ - - - -template -struct zoom_to_robust -{ - template - < - typename Geometry1, typename Geometry2, typename Geometry3, - typename Geometry4, typename Geometry5, typename Geometry6, - typename GeometryOut - > - static inline void apply(Geometry1 const& g1, Geometry2 const& g2, Geometry3 const& g3, - Geometry4 const& g4, Geometry5 const& g5, Geometry6 const& g6, - GeometryOut& og1, GeometryOut& og2, GeometryOut& og3, - GeometryOut& og4, GeometryOut& og5, GeometryOut& og6) - { - // By default, just convert these geometries (until now: points or maybe segments) - geometry::convert(g1, og1); - geometry::convert(g2, og2); - geometry::convert(g3, og3); - geometry::convert(g4, og4); - geometry::convert(g5, og5); - geometry::convert(g6, og6); - } -}; - -template <> -struct zoom_to_robust -{ - template - < - typename Geometry1, typename Geometry2, typename Geometry3, - typename Geometry4, typename Geometry5, typename Geometry6, - typename GeometryOut - > - static inline void apply(Geometry1 const& g1, Geometry2 const& g2, Geometry3 const& g3, - Geometry4 const& g4, Geometry5 const& g5, Geometry6 const& g6, - GeometryOut& og1, GeometryOut& og2, GeometryOut& og3, - GeometryOut& og4, GeometryOut& og5, GeometryOut& og6) - { - typedef typename point_type::type point1_type; - - // Get the envelop of inputs - model::box env; - geometry::assign_inverse(env); - geometry::expand(env, g1); - geometry::expand(env, g2); - geometry::expand(env, g3); - geometry::expand(env, g4); - geometry::expand(env, g5); - geometry::expand(env, g6); - - // Scale this to integer-range - typename geometry::coordinate_type::type diff = detail::get_max_size(env); - double range = 1000000000.0; // Define a large range to get precise integer coordinates - double factor = double(boost::long_long_type(range / double(diff))); - - // Assign input/output minimal points - point1_type min_point1; - detail::assign_point_from_index<0>(env, min_point1); - - typedef typename point_type::type point2_type; - point2_type min_point2; - assign_values(min_point2, boost::long_long_type(-range/2.0), boost::long_long_type(-range/2.0)); - - detail::robust_policy strategy(min_point1, min_point2, factor); - - geometry::recalculate(og1, g1, strategy); - geometry::recalculate(og2, g2, strategy); - geometry::recalculate(og3, g3, strategy); - geometry::recalculate(og4, g4, strategy); - geometry::recalculate(og5, g5, strategy); - geometry::recalculate(og6, g6, strategy); - } -}; - - -} // namespace dispatch -#endif // DOXYGEN_NO_DISPATCH - -#ifndef DOXYGEN_NO_DETAIL -namespace detail -{ - - -template -inline void zoom_to_robust(Geometry1 const& g1a, Geometry1 const& g1b, Geometry2& g2a, Geometry2& g2b) -{ - typedef typename point_type::type point1_type; - typedef typename point_type::type point2_type; - - point1_type min_point1; - point2_type min_point2; - - // Get the envelop of inputs - model::box env; - geometry::envelope(g1a, env); - geometry::expand(env, g1b); - - // Scale this to integer-range - typename coordinate_type::type diff = detail::get_max_size(env); - double range = 1000000000.0; // Define a large range to get precise integer coordinates - double factor = range / diff; - - // Assign input/output minimal points - detail::assign_point_from_index<0>(env, min_point1); - assign_values(min_point2, boost::long_long_type(-range/2.0), boost::long_long_type(-range/2.0)); - - detail::robust_policy strategy(min_point1, min_point2, factor); - geometry::recalculate(g2a, g1a, strategy); - geometry::recalculate(g2b, g1b, strategy); -} - -template -< - typename Geometry1, typename Geometry2, typename Geometry3, - typename Geometry4, typename Geometry5, typename Geometry6, - typename GeometryOut -> -void zoom_to_robust(Geometry1 const& g1, Geometry2 const& g2, Geometry3 const& g3, - Geometry4 const& g4, Geometry5 const& g5, Geometry6 const& g6, - GeometryOut& og1, GeometryOut& og2, GeometryOut& og3, - GeometryOut& og4, GeometryOut& og5, GeometryOut& og6) -{ - // Make FP robust (so dispatch to true), so float and double - // Other types as int, boost::rational, or ttmath are considered to be already robust - dispatch::zoom_to_robust - < - typename boost::is_floating_point - < - typename geometry::coordinate_type::type - >::type - >::apply(g1, g2, g3, g4, g5, g6, og1, og2, og3, og4, og5, og6); -} - -} // namespace detail -#endif // DOXYGEN_NO_DETAIL - - -}} // namespace boost::geometry - - -#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ZOOM_TO_ROBUST_HPP diff --git a/include/boost/geometry/policies/robustness/robust_point_type.hpp b/include/boost/geometry/policies/robustness/robust_point_type.hpp index 35f719865..25639227f 100644 --- a/include/boost/geometry/policies/robustness/robust_point_type.hpp +++ b/include/boost/geometry/policies/robustness/robust_point_type.hpp @@ -12,14 +12,16 @@ #ifndef BOOST_GEOMETRY_POLICIES_ROBUSTNESS_ROBUST_POINT_TYPE_HPP #define BOOST_GEOMETRY_POLICIES_ROBUSTNESS_ROBUST_POINT_TYPE_HPP -#include - namespace boost { namespace geometry { // Meta-function to typedef a robust point type for a policy template -struct robust_point_type {}; //: not_implemented<> {}; +struct robust_point_type +{ + // By default, the point itself is the robust type + typedef Point type; +}; }} // namespace boost::geometry diff --git a/test/algorithms/buffer/multi_polygon_buffer.cpp b/test/algorithms/buffer/multi_polygon_buffer.cpp index fc9511969..7afd55b82 100644 --- a/test/algorithms/buffer/multi_polygon_buffer.cpp +++ b/test/algorithms/buffer/multi_polygon_buffer.cpp @@ -311,9 +311,7 @@ void test_all() test_one("rt_p6", rt_p6, 18.4853, 1.0); test_one("rt_p7", rt_p7, 26.2279, 1.0); test_one("rt_p8", rt_p8, 29.0563, 1.0); -#if !defined(_MSC_VER) test_one("rt_p9", rt_p9, 26.1421, 1.0); -#endif test_one("rt_p10", rt_p10, 23.3995, 1.0); test_one("rt_p11", rt_p11, 28.7426, 1.0);