diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-09-13 11:08:07 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-09-13 11:09:00 +0900 |
commit | b5c87084afaef42b2d058f68091be31988a6a874 (patch) | |
tree | adef9a65870a41181687e11d57fdf98e7629de3c /boost/geometry/algorithms/detail/overlay | |
parent | 34bd32e225e2a8a94104489b31c42e5801cc1f4a (diff) | |
download | boost-b5c87084afaef42b2d058f68091be31988a6a874.tar.gz boost-b5c87084afaef42b2d058f68091be31988a6a874.tar.bz2 boost-b5c87084afaef42b2d058f68091be31988a6a874.zip |
Imported Upstream version 1.64.0upstream/1.64.0
Change-Id: Id9212edd016dd55f21172c427aa7894d1d24148b
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/geometry/algorithms/detail/overlay')
18 files changed, 440 insertions, 265 deletions
diff --git a/boost/geometry/algorithms/detail/overlay/assign_parents.hpp b/boost/geometry/algorithms/detail/overlay/assign_parents.hpp index 047eb4993e..2408b4b68e 100644 --- a/boost/geometry/algorithms/detail/overlay/assign_parents.hpp +++ b/boost/geometry/algorithms/detail/overlay/assign_parents.hpp @@ -2,6 +2,10 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// This file was modified by Oracle on 2017. +// Modifications copyright (c) 2017 Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + // 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) @@ -258,8 +262,9 @@ inline void assign_parents(Geometry1 const& geometry1, geometry::partition < - box_type, ring_info_helper_get_box, ring_info_helper_ovelaps_box - >::apply(vector, visitor); + box_type + >::apply(vector, visitor, ring_info_helper_get_box(), + ring_info_helper_ovelaps_box()); } if (check_for_orientation) diff --git a/boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp b/boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp index a8171e1482..9beb8ad64f 100644 --- a/boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp +++ b/boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp @@ -2,6 +2,10 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// This file was modified by Oracle on 2017. +// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + // 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) @@ -106,19 +110,27 @@ class backtrack_check_self_intersections public : typedef state state_type; - template <typename Operation, typename Rings, typename Ring, typename Turns, typename RobustPolicy, typename Visitor> + template + < + typename Operation, + typename Rings, typename Ring, typename Turns, + typename Strategy, + typename RobustPolicy, + typename Visitor + > static inline void apply(std::size_t size_at_start, - Rings& rings, Ring& ring, - Turns& turns, - typename boost::range_value<Turns>::type const& turn, - Operation& operation, - traverse_error_type traverse_error, - Geometry1 const& geometry1, - Geometry2 const& geometry2, - RobustPolicy const& robust_policy, - state_type& state, - Visitor& visitor - ) + Rings& rings, + Ring& ring, + Turns& turns, + typename boost::range_value<Turns>::type const& turn, + Operation& operation, + traverse_error_type traverse_error, + Geometry1 const& geometry1, + Geometry2 const& geometry2, + Strategy const& strategy, + RobustPolicy const& robust_policy, + state_type& state, + Visitor& visitor) { visitor.visit_traverse_reject(turns, turn, operation, traverse_error); @@ -128,8 +140,8 @@ public : if (! state.m_checked) { state.m_checked = true; - has_self_intersections(geometry1, robust_policy); - has_self_intersections(geometry2, robust_policy); + has_self_intersections(geometry1, strategy, robust_policy); + has_self_intersections(geometry2, strategy, robust_policy); } // Make bad output clean diff --git a/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp b/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp index b9e48cdbfc..c249ff57ff 100644 --- a/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp +++ b/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp @@ -1,5 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) +// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. + // Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. @@ -15,6 +17,7 @@ #include <iterator> #include <boost/range.hpp> +#include <boost/throw_exception.hpp> #include <boost/geometry/core/assert.hpp> #include <boost/geometry/core/tag.hpp> @@ -307,7 +310,7 @@ public: #if ! defined(BOOST_GEOMETRY_OVERLAY_NO_THROW) if (enter_count != 0) { - throw inconsistent_turns_exception(); + BOOST_THROW_EXCEPTION(inconsistent_turns_exception()); } #else BOOST_GEOMETRY_ASSERT(enter_count == 0); diff --git a/boost/geometry/algorithms/detail/overlay/get_intersection_points.hpp b/boost/geometry/algorithms/detail/overlay/get_intersection_points.hpp index 99281eaecb..94667d0ed0 100644 --- a/boost/geometry/algorithms/detail/overlay/get_intersection_points.hpp +++ b/boost/geometry/algorithms/detail/overlay/get_intersection_points.hpp @@ -2,6 +2,11 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// This file was modified by Oracle on 2017. +// Modifications copyright (c) 2017 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + // 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) @@ -39,29 +44,33 @@ template > struct get_turn_without_info { - template <typename RobustPolicy, typename OutputIterator> + template <typename Strategy, typename RobustPolicy, typename OutputIterator> static inline OutputIterator apply( Point1 const& pi, Point1 const& pj, Point1 const& /*pk*/, Point2 const& qi, Point2 const& qj, Point2 const& /*qk*/, bool /*is_p_first*/, bool /*is_p_last*/, bool /*is_q_first*/, bool /*is_q_last*/, TurnInfo const& , + Strategy const& strategy, RobustPolicy const& robust_policy, OutputIterator out) { - typedef intersection_strategies - < - typename cs_tag<typename TurnInfo::point_type>::type, - Point1, - Point2, - typename TurnInfo::point_type, - RobustPolicy - > si; + typedef typename TurnInfo::point_type turn_point_type; - typedef typename si::segment_intersection_strategy_type strategy; + typedef policies::relate::segments_intersection_points + < + segment_intersection_points + < + turn_point_type, + typename geometry::segment_ratio_type + < + turn_point_type, RobustPolicy + >::type + > + > policy_type; typedef model::referring_segment<Point1 const> segment_type1; - typedef model::referring_segment<Point1 const> segment_type2; + typedef model::referring_segment<Point2 const> segment_type2; segment_type1 p1(pi, pj); segment_type2 q1(qi, qj); @@ -75,15 +84,14 @@ struct get_turn_without_info geometry::recalculate(pj_rob, pj, robust_policy); geometry::recalculate(qi_rob, qi, robust_policy); geometry::recalculate(qj_rob, qj, robust_policy); - typename strategy::return_type result - = strategy::apply(p1, q1, robust_policy, - pi_rob, pj_rob, qi_rob, qj_rob); + typename policy_type::return_type result + = strategy.apply(p1, q1, policy_type(), robust_policy, + pi_rob, pj_rob, qi_rob, qj_rob); - for (std::size_t i = 0; i < result.template get<0>().count; i++) + for (std::size_t i = 0; i < result.count; i++) { - TurnInfo tp; - geometry::convert(result.template get<0>().intersections[i], tp.point); + geometry::convert(result.intersections[i], tp.point); *out++ = tp; } @@ -102,12 +110,14 @@ template typename Geometry1, typename Geometry2, typename RobustPolicy, - typename Turns + typename Turns, + typename Strategy > inline void get_intersection_points(Geometry1 const& geometry1, Geometry2 const& geometry2, RobustPolicy const& robust_policy, - Turns& turns) + Turns& turns, + Strategy const& strategy) { concepts::check_concepts_and_equal_dimensions<Geometry1 const, Geometry2 const>(); @@ -142,6 +152,7 @@ inline void get_intersection_points(Geometry1 const& geometry1, >::type::apply( 0, geometry1, 1, geometry2, + strategy, robust_policy, turns, interrupt_policy); } diff --git a/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp b/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp index a4cce3fd32..08bc342186 100644 --- a/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp +++ b/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp @@ -1,9 +1,10 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2015. -// Modifications copyright (c) 2015 Oracle and/or its affiliates. +// This file was modified by Oracle on 2015, 2017. +// Modifications copyright (c) 2015-2017 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -16,10 +17,10 @@ #include <boost/core/ignore_unused.hpp> +#include <boost/throw_exception.hpp> #include <boost/geometry/core/access.hpp> #include <boost/geometry/core/assert.hpp> -#include <boost/geometry/strategies/intersection_strategies.hpp> #include <boost/geometry/algorithms/convert.hpp> #include <boost/geometry/algorithms/detail/overlay/turn_info.hpp> @@ -644,7 +645,7 @@ struct collinear : public base_turn_handler // causes currently cycling include problems typedef typename geometry::coordinate_type<Point1>::type ctype; ctype const dx = get<0>(a) - get<0>(b); - ctype const dy = get<1>(b) - get<1>(b); + ctype const dy = get<1>(a) - get<1>(b); return dx * dx + dy * dy; } }; @@ -930,6 +931,7 @@ struct get_turn_info typename Point1, typename Point2, typename TurnInfo, + typename IntersectionStrategy, typename RobustPolicy, typename OutputIterator > @@ -939,13 +941,19 @@ struct get_turn_info bool /*is_p_first*/, bool /*is_p_last*/, bool /*is_q_first*/, bool /*is_q_last*/, TurnInfo const& tp_model, + IntersectionStrategy const& intersection_strategy, RobustPolicy const& robust_policy, OutputIterator out) { - typedef intersection_info<Point1, Point2, typename TurnInfo::point_type, RobustPolicy> - inters_info; + typedef intersection_info + < + Point1, Point2, + typename TurnInfo::point_type, + IntersectionStrategy, + RobustPolicy + > inters_info; - inters_info inters(pi, pj, pk, qi, qj, qk, robust_policy); + inters_info inters(pi, pj, pk, qi, qj, qk, intersection_strategy, robust_policy); char const method = inters.d_info().how; @@ -991,9 +999,12 @@ struct get_turn_info < typename inters_info::cs_tag, typename inters_info::robust_point2_type, - typename inters_info::robust_point1_type + typename inters_info::robust_point1_type, + typename inters_info::side_strategy_type > swapped_side_calc(inters.rqi(), inters.rqj(), inters.rqk(), - inters.rpi(), inters.rpj(), inters.rpk()); + inters.rpi(), inters.rpj(), inters.rpk(), + inters.get_side_strategy()); + policy::template apply<1>(qi, qj, qk, pi, pj, pk, tp, inters.i_info(), inters.d_info(), swapped_side_calc); @@ -1093,7 +1104,7 @@ struct get_turn_info std::cout << "TURN: Unknown method: " << method << std::endl; #endif #if ! defined(BOOST_GEOMETRY_OVERLAY_NO_THROW) - throw turn_info_exception(method); + BOOST_THROW_EXCEPTION(turn_info_exception(method)); #endif } break; diff --git a/boost/geometry/algorithms/detail/overlay/get_turn_info_for_endpoint.hpp b/boost/geometry/algorithms/detail/overlay/get_turn_info_for_endpoint.hpp index 85cdfbc02d..48716634c5 100644 --- a/boost/geometry/algorithms/detail/overlay/get_turn_info_for_endpoint.hpp +++ b/boost/geometry/algorithms/detail/overlay/get_turn_info_for_endpoint.hpp @@ -2,15 +2,15 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2013, 2014. -// Modifications copyright (c) 2013-2014 Oracle and/or its affiliates. +// This file was modified by Oracle on 2013, 2014, 2017. +// Modifications copyright (c) 2013-2017 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // 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) -// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle - #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_TURN_INFO_FOR_ENDPOINT_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_TURN_INFO_FOR_ENDPOINT_HPP @@ -427,8 +427,11 @@ struct get_turn_info_for_endpoint } else if ( ip_j2 ) { - side_calculator<cs_tag, RobustPoint1, RobustPoint2, RobustPoint2> - side_calc(ri2, ri1, rj1, ri2, rj2, rk2); + side_calculator<cs_tag, + RobustPoint1, RobustPoint2, + typename IntersectionInfo::side_strategy_type, + RobustPoint2> + side_calc(ri2, ri1, rj1, ri2, rj2, rk2, inters.get_side_strategy()); std::pair<operation_type, operation_type> operations = operations_of_equal(side_calc); @@ -478,8 +481,10 @@ struct get_turn_info_for_endpoint } else if ( ip_j2 ) { - side_calculator<cs_tag, RobustPoint1, RobustPoint2, RobustPoint2> - side_calc(ri2, rj1, ri1, ri2, rj2, rk2); + side_calculator<cs_tag, RobustPoint1, RobustPoint2, + typename IntersectionInfo::side_strategy_type, + RobustPoint2> + side_calc(ri2, rj1, ri1, ri2, rj2, rk2, inters.get_side_strategy()); std::pair<operation_type, operation_type> operations = operations_of_equal(side_calc); diff --git a/boost/geometry/algorithms/detail/overlay/get_turn_info_helpers.hpp b/boost/geometry/algorithms/detail/overlay/get_turn_info_helpers.hpp index 3e7da1d797..5f2cb07faf 100644 --- a/boost/geometry/algorithms/detail/overlay/get_turn_info_helpers.hpp +++ b/boost/geometry/algorithms/detail/overlay/get_turn_info_helpers.hpp @@ -2,15 +2,15 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2013, 2014, 2015. -// Modifications copyright (c) 2013-2015 Oracle and/or its affiliates. +// This file was modified by Oracle on 2013, 2014, 2015, 2017. +// Modifications copyright (c) 2013-2017 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // 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) -// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle - #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_TURN_INFO_HELPERS_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_TURN_INFO_HELPERS_HPP @@ -37,32 +37,27 @@ struct turn_operation_linear }; template <typename TurnPointCSTag, typename PointP, typename PointQ, + typename SideStrategy, typename Pi = PointP, typename Pj = PointP, typename Pk = PointP, typename Qi = PointQ, typename Qj = PointQ, typename Qk = PointQ > struct side_calculator { - // This strategy should be the same as side strategy defined in - // intersection_strategies<> which is used in various places - // of the library - typedef typename strategy::side::services::default_strategy - < - TurnPointCSTag - >::type side; - inline side_calculator(Pi const& pi, Pj const& pj, Pk const& pk, - Qi const& qi, Qj const& qj, Qk const& qk) + Qi const& qi, Qj const& qj, Qk const& qk, + SideStrategy const& side_strategy) : m_pi(pi), m_pj(pj), m_pk(pk) , m_qi(qi), m_qj(qj), m_qk(qk) + , m_side_strategy(side_strategy) {} - inline int pk_wrt_p1() const { return side::apply(m_pi, m_pj, m_pk); } - inline int pk_wrt_q1() const { return side::apply(m_qi, m_qj, m_pk); } - inline int qk_wrt_p1() const { return side::apply(m_pi, m_pj, m_qk); } - inline int qk_wrt_q1() const { return side::apply(m_qi, m_qj, m_qk); } + inline int pk_wrt_p1() const { return m_side_strategy.apply(m_pi, m_pj, m_pk); } + inline int pk_wrt_q1() const { return m_side_strategy.apply(m_qi, m_qj, m_pk); } + inline int qk_wrt_p1() const { return m_side_strategy.apply(m_pi, m_pj, m_qk); } + inline int qk_wrt_q1() const { return m_side_strategy.apply(m_qi, m_qj, m_qk); } - inline int pk_wrt_q2() const { return side::apply(m_qj, m_qk, m_pk); } - inline int qk_wrt_p2() const { return side::apply(m_pj, m_pk, m_qk); } + inline int pk_wrt_q2() const { return m_side_strategy.apply(m_qj, m_qk, m_pk); } + inline int qk_wrt_p2() const { return m_side_strategy.apply(m_pj, m_pk, m_qk); } Pi const& m_pi; Pj const& m_pj; @@ -70,6 +65,8 @@ struct side_calculator Qi const& m_qi; Qj const& m_qj; Qk const& m_qk; + + SideStrategy const& m_side_strategy; }; template <typename Point1, typename Point2, typename RobustPolicy> @@ -99,7 +96,7 @@ struct robust_points robust_point2_type m_rqi, m_rqj, m_rqk; }; -template <typename Point1, typename Point2, typename TurnPoint, typename RobustPolicy> +template <typename Point1, typename Point2, typename TurnPoint, typename IntersectionStrategy, typename RobustPolicy> class intersection_info_base : private robust_points<Point1, Point2, RobustPolicy> { @@ -114,14 +111,17 @@ public: typedef typename cs_tag<TurnPoint>::type cs_tag; - typedef side_calculator<cs_tag, robust_point1_type, robust_point2_type> side_calculator_type; + typedef typename IntersectionStrategy::side_strategy_type side_strategy_type; + typedef side_calculator<cs_tag, robust_point1_type, robust_point2_type, side_strategy_type> side_calculator_type; intersection_info_base(Point1 const& pi, Point1 const& pj, Point1 const& pk, Point2 const& qi, Point2 const& qj, Point2 const& qk, + IntersectionStrategy const& intersection_strategy, RobustPolicy const& robust_policy) : base(pi, pj, pk, qi, qj, qk, robust_policy) , m_side_calc(base::m_rpi, base::m_rpj, base::m_rpk, - base::m_rqi, base::m_rqj, base::m_rqk) + base::m_rqi, base::m_rqj, base::m_rqk, + intersection_strategy.get_side_strategy()) , m_pi(pi), m_pj(pj), m_pk(pk) , m_qi(qi), m_qj(qj), m_qk(qk) {} @@ -155,8 +155,8 @@ private: point2_type const& m_qk; }; -template <typename Point1, typename Point2, typename TurnPoint> -class intersection_info_base<Point1, Point2, TurnPoint, detail::no_rescale_policy> +template <typename Point1, typename Point2, typename TurnPoint, typename IntersectionStrategy> +class intersection_info_base<Point1, Point2, TurnPoint, IntersectionStrategy, detail::no_rescale_policy> { public: typedef Point1 point1_type; @@ -167,12 +167,15 @@ public: typedef typename cs_tag<TurnPoint>::type cs_tag; - typedef side_calculator<cs_tag, Point1, Point2> side_calculator_type; + typedef typename IntersectionStrategy::side_strategy_type side_strategy_type; + typedef side_calculator<cs_tag, Point1, Point2, side_strategy_type> side_calculator_type; intersection_info_base(Point1 const& pi, Point1 const& pj, Point1 const& pk, Point2 const& qi, Point2 const& qj, Point2 const& qk, + IntersectionStrategy const& intersection_strategy, no_rescale_policy const& /*robust_policy*/) - : m_side_calc(pi, pj, pk, qi, qj, qk) + : m_side_calc(pi, pj, pk, qi, qj, qk, + intersection_strategy.get_side_strategy()) {} inline Point1 const& pi() const { return m_side_calc.m_pi; } @@ -203,40 +206,58 @@ template typename Point1, typename Point2, typename TurnPoint, + typename IntersectionStrategy, typename RobustPolicy > class intersection_info - : public intersection_info_base<Point1, Point2, TurnPoint, RobustPolicy> + : public intersection_info_base<Point1, Point2, TurnPoint, IntersectionStrategy, RobustPolicy> { - typedef intersection_info_base<Point1, Point2, TurnPoint, RobustPolicy> base; + typedef intersection_info_base<Point1, Point2, TurnPoint, IntersectionStrategy, RobustPolicy> base; + +public: + typedef segment_intersection_points + < + TurnPoint, + typename geometry::segment_ratio_type + < + TurnPoint, RobustPolicy + >::type + > intersection_point_type; - typedef typename intersection_strategies + // NOTE: formerly defined in intersection_strategies + typedef policies::relate::segments_tupled < - typename base::cs_tag, - Point1, - Point2, - TurnPoint, - RobustPolicy - >::segment_intersection_strategy_type strategy; + policies::relate::segments_intersection_points + < + intersection_point_type + >, + policies::relate::segments_direction + > intersection_policy_type; + + typedef IntersectionStrategy intersection_strategy_type; + typedef typename IntersectionStrategy::side_strategy_type side_strategy_type; -public: typedef model::referring_segment<Point1 const> segment_type1; typedef model::referring_segment<Point2 const> segment_type2; typedef typename base::side_calculator_type side_calculator_type; - typedef typename strategy::return_type result_type; + typedef typename intersection_policy_type::return_type result_type; typedef typename boost::tuples::element<0, result_type>::type i_info_type; // intersection_info typedef typename boost::tuples::element<1, result_type>::type d_info_type; // dir_info intersection_info(Point1 const& pi, Point1 const& pj, Point1 const& pk, Point2 const& qi, Point2 const& qj, Point2 const& qk, + IntersectionStrategy const& intersection_strategy, RobustPolicy const& robust_policy) - : base(pi, pj, pk, qi, qj, qk, robust_policy) - , m_result(strategy::apply(segment_type1(pi, pj), - segment_type2(qi, qj), - robust_policy, - base::rpi(), base::rpj(), - base::rqi(), base::rqj())) + : base(pi, pj, pk, qi, qj, qk, intersection_strategy, robust_policy) + , m_result(intersection_strategy.apply( + segment_type1(pi, pj), + segment_type2(qi, qj), + intersection_policy_type(), + robust_policy, + base::rpi(), base::rpj(), + base::rqi(), base::rqj())) + , m_intersection_strategy(intersection_strategy) , m_robust_policy(robust_policy) {} @@ -244,6 +265,16 @@ public: inline i_info_type const& i_info() const { return m_result.template get<0>(); } inline d_info_type const& d_info() const { return m_result.template get<1>(); } + inline intersection_strategy_type const& get_intersection_strategy() const + { + return m_intersection_strategy; + } + + inline side_strategy_type get_side_strategy() const + { + return m_intersection_strategy.get_side_strategy(); + } + // TODO: it's more like is_spike_ip_p inline bool is_spike_p() const { @@ -307,17 +338,18 @@ private: { typedef model::referring_segment<Point const> seg; - typedef intersection_strategies - < - typename base::cs_tag, Point, Point, Point, RobustPolicy - > si; - - typedef typename si::segment_intersection_strategy_type strategy; - - typename strategy::return_type result - = strategy::apply(seg(i, j), seg(j, k), m_robust_policy); + // no need to calcualte direction info + typedef policies::relate::segments_intersection_points + < + intersection_point_type + > policy_type; + + typename policy_type::return_type const result + = m_intersection_strategy.apply(seg(i, j), seg(j, k), + policy_type(), + m_robust_policy); - return result.template get<0>().count == 2; + return result.count == 2; } template <std::size_t OpId> @@ -344,6 +376,7 @@ private: } result_type m_result; + IntersectionStrategy const& m_intersection_strategy; RobustPolicy const& m_robust_policy; }; diff --git a/boost/geometry/algorithms/detail/overlay/get_turn_info_la.hpp b/boost/geometry/algorithms/detail/overlay/get_turn_info_la.hpp index 121728d822..46c1305cd7 100644 --- a/boost/geometry/algorithms/detail/overlay/get_turn_info_la.hpp +++ b/boost/geometry/algorithms/detail/overlay/get_turn_info_la.hpp @@ -1,9 +1,10 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2013, 2014, 2015. -// Modifications copyright (c) 2013-2015 Oracle and/or its affiliates. +// This file was modified by Oracle on 2013, 2014, 2015, 2017. +// Modifications copyright (c) 2013-2017 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -14,6 +15,8 @@ #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_TURN_INFO_LA_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_TURN_INFO_LA_HPP +#include <boost/throw_exception.hpp> + #include <boost/geometry/core/assert.hpp> #include <boost/geometry/util/condition.hpp> @@ -41,6 +44,7 @@ struct get_turn_info_linear_areal typename Point1, typename Point2, typename TurnInfo, + typename IntersectionStrategy, typename RobustPolicy, typename OutputIterator > @@ -50,13 +54,19 @@ struct get_turn_info_linear_areal bool is_p_first, bool is_p_last, bool is_q_first, bool is_q_last, TurnInfo const& tp_model, + IntersectionStrategy const& intersection_strategy, RobustPolicy const& robust_policy, OutputIterator out) { - typedef intersection_info<Point1, Point2, typename TurnInfo::point_type, RobustPolicy> - inters_info; + typedef intersection_info + < + Point1, Point2, + typename TurnInfo::point_type, + IntersectionStrategy, + RobustPolicy + > inters_info; - inters_info inters(pi, pj, pk, qi, qj, qk, robust_policy); + inters_info inters(pi, pj, pk, qi, qj, qk, intersection_strategy, robust_policy); char const method = inters.d_info().how; @@ -108,9 +118,11 @@ struct get_turn_info_linear_areal < typename inters_info::cs_tag, typename inters_info::robust_point2_type, - typename inters_info::robust_point1_type + typename inters_info::robust_point1_type, + typename inters_info::side_strategy_type > swapped_side_calc(inters.rqi(), inters.rqj(), inters.rqk(), - inters.rpi(), inters.rpj(), inters.rpk()); + inters.rpi(), inters.rpj(), inters.rpk(), + inters.get_side_strategy()); policy::template apply<1>(qi, qj, qk, pi, pj, pk, tp, inters.i_info(), inters.d_info(), swapped_side_calc); @@ -395,7 +407,7 @@ struct get_turn_info_linear_areal std::cout << "TURN: Unknown method: " << method << std::endl; #endif #if ! defined(BOOST_GEOMETRY_OVERLAY_NO_THROW) - throw turn_info_exception(method); + BOOST_THROW_EXCEPTION(turn_info_exception(method)); #endif } break; @@ -747,6 +759,9 @@ struct get_turn_info_linear_areal } else { + typedef typename IntersectionInfo::robust_point1_type rp1_type; + typedef typename IntersectionInfo::robust_point2_type rp2_type; + method_type replaced_method = method_touch_interior; if ( ip0.is_qj ) @@ -754,11 +769,12 @@ struct get_turn_info_linear_areal side_calculator < typename IntersectionInfo::cs_tag, - typename IntersectionInfo::robust_point1_type, - typename IntersectionInfo::robust_point2_type, - typename IntersectionInfo::robust_point2_type + rp1_type, rp2_type, + typename IntersectionInfo::side_strategy_type, + rp2_type > side_calc(inters.rqi(), inters.rpi(), inters.rpj(), - inters.rqi(), inters.rqj(), inters.rqk()); + inters.rqi(), inters.rqj(), inters.rqk(), + inters.get_side_strategy()); std::pair<operation_type, operation_type> operations = get_info_e::operations_of_equal(side_calc); @@ -773,16 +789,13 @@ struct get_turn_info_linear_areal side_calculator < typename IntersectionInfo::cs_tag, - typename IntersectionInfo::robust_point1_type, - typename IntersectionInfo::robust_point2_type, - typename IntersectionInfo::robust_point2_type, - typename IntersectionInfo::robust_point1_type, - typename IntersectionInfo::robust_point1_type, - typename IntersectionInfo::robust_point2_type, - typename IntersectionInfo::robust_point1_type, - typename IntersectionInfo::robust_point2_type + rp1_type, rp2_type, + typename IntersectionInfo::side_strategy_type, + rp2_type, rp1_type, rp1_type, + rp2_type, rp1_type, rp2_type > side_calc(inters.rqi(), inters.rpi(), inters.rpj(), - inters.rqi(), inters.rpi(), inters.rqj()); + inters.rqi(), inters.rpi(), inters.rqj(), + inters.get_side_strategy()); std::pair<operation_type, operation_type> operations = get_info_e::operations_of_equal(side_calc); @@ -832,9 +845,11 @@ struct get_turn_info_linear_areal typename IntersectionInfo::cs_tag, typename IntersectionInfo::robust_point1_type, typename IntersectionInfo::robust_point2_type, + typename IntersectionInfo::side_strategy_type, typename IntersectionInfo::robust_point2_type > side_calc(inters.rqi(), inters.rpj(), inters.rpi(), - inters.rqi(), inters.rqj(), inters.rqk()); + inters.rqi(), inters.rqj(), inters.rqk(), + inters.get_side_strategy()); std::pair<operation_type, operation_type> operations = get_info_e::operations_of_equal(side_calc); diff --git a/boost/geometry/algorithms/detail/overlay/get_turn_info_ll.hpp b/boost/geometry/algorithms/detail/overlay/get_turn_info_ll.hpp index 6bb3a74bb8..58fd4bb5c7 100644 --- a/boost/geometry/algorithms/detail/overlay/get_turn_info_ll.hpp +++ b/boost/geometry/algorithms/detail/overlay/get_turn_info_ll.hpp @@ -1,19 +1,22 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2013, 2014, 2015. -// Modifications copyright (c) 2013-2015 Oracle and/or its affiliates. +// This file was modified by Oracle on 2013, 2014, 2015, 2017. +// Modifications copyright (c) 2013-2017 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // 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) -// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle - #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_TURN_INFO_LL_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_TURN_INFO_LL_HPP +#include <boost/throw_exception.hpp> + #include <boost/geometry/core/assert.hpp> #include <boost/geometry/algorithms/detail/overlay/get_turn_info.hpp> @@ -36,6 +39,7 @@ struct get_turn_info_linear_linear typename Point1, typename Point2, typename TurnInfo, + typename IntersectionStrategy, typename RobustPolicy, typename OutputIterator > @@ -45,13 +49,19 @@ struct get_turn_info_linear_linear bool is_p_first, bool is_p_last, bool is_q_first, bool is_q_last, TurnInfo const& tp_model, + IntersectionStrategy const& strategy, RobustPolicy const& robust_policy, OutputIterator out) { - typedef intersection_info<Point1, Point2, typename TurnInfo::point_type, RobustPolicy> - inters_info; + typedef intersection_info + < + Point1, Point2, + typename TurnInfo::point_type, + IntersectionStrategy, + RobustPolicy + > inters_info; - inters_info inters(pi, pj, pk, qi, qj, qk, robust_policy); + inters_info inters(pi, pj, pk, qi, qj, qk, strategy, robust_policy); char const method = inters.d_info().how; @@ -103,9 +113,11 @@ struct get_turn_info_linear_linear < typename inters_info::cs_tag, typename inters_info::robust_point2_type, - typename inters_info::robust_point1_type + typename inters_info::robust_point1_type, + typename inters_info::side_strategy_type > swapped_side_calc(inters.rqi(), inters.rqj(), inters.rqk(), - inters.rpi(), inters.rpj(), inters.rpk()); + inters.rpi(), inters.rpj(), inters.rpk(), + inters.get_side_strategy()); policy::template apply<1>(qi, qj, qk, pi, pj, pk, tp, inters.i_info(), inters.d_info(), @@ -463,7 +475,7 @@ struct get_turn_info_linear_linear std::cout << "TURN: Unknown method: " << method << std::endl; #endif #if ! defined(BOOST_GEOMETRY_OVERLAY_NO_THROW) - throw turn_info_exception(method); + BOOST_THROW_EXCEPTION(turn_info_exception(method)); #endif } break; diff --git a/boost/geometry/algorithms/detail/overlay/get_turns.hpp b/boost/geometry/algorithms/detail/overlay/get_turns.hpp index 1eb18b74d4..4e97a84a37 100644 --- a/boost/geometry/algorithms/detail/overlay/get_turns.hpp +++ b/boost/geometry/algorithms/detail/overlay/get_turns.hpp @@ -3,15 +3,15 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014, 2016. -// Modifications copyright (c) 2014, 2016 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2016, 2017. +// Modifications copyright (c) 2014-2017 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // 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) -// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle - #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_TURNS_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_TURNS_HPP @@ -45,7 +45,6 @@ #include <boost/geometry/iterators/ever_circling_iterator.hpp> -#include <boost/geometry/strategies/cartesian/cart_intersect.hpp> #include <boost/geometry/strategies/intersection_strategies.hpp> #include <boost/geometry/strategies/intersection_result.hpp> @@ -174,11 +173,12 @@ class get_turns_in_sections public : // Returns true if terminated, false if interrupted - template <typename Turns, typename RobustPolicy, typename InterruptPolicy> + template <typename IntersectionStrategy, typename RobustPolicy, typename Turns, typename InterruptPolicy> static inline bool apply( int source_id1, Geometry1 const& geometry1, Section1 const& sec1, int source_id2, Geometry2 const& geometry2, Section2 const& sec2, bool skip_larger, + IntersectionStrategy const& intersection_strategy, RobustPolicy const& robust_policy, Turns& turns, InterruptPolicy& interrupt_policy) @@ -295,7 +295,8 @@ public : TurnPolicy::apply(*prev1, *it1, *nd_next1, *prev2, *it2, *nd_next2, is_1_first, is_1_last, is_2_first, is_2_last, - ti, robust_policy, std::back_inserter(turns)); + ti, intersection_strategy, robust_policy, + std::back_inserter(turns)); if (InterruptPolicy::enabled) { @@ -381,9 +382,10 @@ template < typename Geometry1, typename Geometry2, bool Reverse1, bool Reverse2, - typename Turns, typename TurnPolicy, + typename IntersectionStrategy, typename RobustPolicy, + typename Turns, typename InterruptPolicy > struct section_visitor @@ -392,16 +394,20 @@ struct section_visitor Geometry1 const& m_geometry1; int m_source_id2; Geometry2 const& m_geometry2; + IntersectionStrategy const& m_intersection_strategy; RobustPolicy const& m_rescale_policy; Turns& m_turns; InterruptPolicy& m_interrupt_policy; section_visitor(int id1, Geometry1 const& g1, - int id2, Geometry2 const& g2, - RobustPolicy const& robust_policy, - Turns& turns, InterruptPolicy& ip) + int id2, Geometry2 const& g2, + IntersectionStrategy const& intersection_strategy, + RobustPolicy const& robust_policy, + Turns& turns, + InterruptPolicy& ip) : m_source_id1(id1), m_geometry1(g1) , m_source_id2(id2), m_geometry2(g2) + , m_intersection_strategy(intersection_strategy) , m_rescale_policy(robust_policy) , m_turns(turns) , m_interrupt_policy(ip) @@ -423,6 +429,7 @@ struct section_visitor m_source_id1, m_geometry1, sec1, m_source_id2, m_geometry2, sec2, false, + m_intersection_strategy, m_rescale_policy, m_turns, m_interrupt_policy); } @@ -441,10 +448,11 @@ class get_turns_generic { public: - template <typename RobustPolicy, typename Turns, typename InterruptPolicy> + template <typename IntersectionStrategy, typename RobustPolicy, typename Turns, typename InterruptPolicy> static inline void apply( int source_id1, Geometry1 const& geometry1, int source_id2, Geometry2 const& geometry2, + IntersectionStrategy const& intersection_strategy, RobustPolicy const& robust_policy, Turns& turns, InterruptPolicy& interrupt_policy) @@ -475,15 +483,19 @@ public: < Geometry1, Geometry2, Reverse1, Reverse2, - Turns, TurnPolicy, RobustPolicy, InterruptPolicy - > visitor(source_id1, geometry1, source_id2, geometry2, robust_policy, turns, interrupt_policy); + TurnPolicy, + IntersectionStrategy, RobustPolicy, + Turns, InterruptPolicy + > visitor(source_id1, geometry1, source_id2, geometry2, + intersection_strategy, robust_policy, + turns, interrupt_policy); geometry::partition < - box_type, - detail::section::get_section_box, - detail::section::overlaps_section_box - >::apply(sec1, sec2, visitor); + box_type + >::apply(sec1, sec2, visitor, + detail::section::get_section_box(), + detail::section::overlaps_section_box()); } }; @@ -518,10 +530,11 @@ struct get_turns_cs >::type iterator_type; - template <typename RobustPolicy, typename Turns, typename InterruptPolicy> + template <typename IntersectionStrategy, typename RobustPolicy, typename Turns, typename InterruptPolicy> static inline void apply( int source_id1, Range const& range, int source_id2, Box const& box, + IntersectionStrategy const& intersection_strategy, RobustPolicy const& robust_policy, Turns& turns, InterruptPolicy& interrupt_policy, @@ -593,8 +606,10 @@ struct get_turns_cs // NOTE: some dummy values could be passed below since this would be called only for Polygons and Boxes index == 0, size_type(index) == segments_count1, + intersection_strategy, robust_policy, - turns, interrupt_policy); + turns, + interrupt_policy); // Future performance enhancement: // return if told by the interrupt policy } @@ -622,7 +637,7 @@ private: else return 0; } - template <typename RobustPolicy, typename Turns, typename InterruptPolicy> + template <typename IntersectionStrategy, typename RobustPolicy, typename Turns, typename InterruptPolicy> static inline void get_turns_with_box(segment_identifier const& seg_id, int source_id2, // Points from a range: point_type const& rp0, @@ -635,6 +650,7 @@ private: box_point_type const& bp3, bool const is_range_first, bool const is_range_last, + IntersectionStrategy const& intersection_strategy, RobustPolicy const& robust_policy, // Output Turns& turns, @@ -653,25 +669,29 @@ private: TurnPolicy::apply(rp0, rp1, rp2, bp0, bp1, bp2, is_range_first, is_range_last, true, false, - ti, robust_policy, std::back_inserter(turns)); + ti, intersection_strategy, robust_policy, + std::back_inserter(turns)); ti.operations[1].seg_id = segment_identifier(source_id2, -1, -1, 1); TurnPolicy::apply(rp0, rp1, rp2, bp1, bp2, bp3, is_range_first, is_range_last, false, false, - ti, robust_policy, std::back_inserter(turns)); + ti, intersection_strategy, robust_policy, + std::back_inserter(turns)); ti.operations[1].seg_id = segment_identifier(source_id2, -1, -1, 2); TurnPolicy::apply(rp0, rp1, rp2, bp2, bp3, bp0, is_range_first, is_range_last, false, false, - ti, robust_policy, std::back_inserter(turns)); + ti, intersection_strategy, robust_policy, + std::back_inserter(turns)); ti.operations[1].seg_id = segment_identifier(source_id2, -1, -1, 3); TurnPolicy::apply(rp0, rp1, rp2, bp3, bp0, bp1, is_range_first, is_range_last, false, true, - ti, robust_policy, std::back_inserter(turns)); + ti, intersection_strategy, robust_policy, + std::back_inserter(turns)); if (InterruptPolicy::enabled) { @@ -691,12 +711,14 @@ template > struct get_turns_polygon_cs { - template <typename RobustPolicy, typename Turns, typename InterruptPolicy> + template <typename IntersectionStrategy, typename RobustPolicy, typename Turns, typename InterruptPolicy> static inline void apply( int source_id1, Polygon const& polygon, int source_id2, Box const& box, + IntersectionStrategy const& intersection_strategy, RobustPolicy const& robust_policy, - Turns& turns, InterruptPolicy& interrupt_policy, + Turns& turns, + InterruptPolicy& interrupt_policy, signed_size_type multi_index = -1) { typedef typename geometry::ring_type<Polygon>::type ring_type; @@ -711,8 +733,10 @@ struct get_turns_polygon_cs intersector_type::apply( source_id1, geometry::exterior_ring(polygon), source_id2, box, + intersection_strategy, robust_policy, - turns, interrupt_policy, + turns, + interrupt_policy, multi_index, -1); signed_size_type i = 0; @@ -725,6 +749,7 @@ struct get_turns_polygon_cs intersector_type::apply( source_id1, *it, source_id2, box, + intersection_strategy, robust_policy, turns, interrupt_policy, multi_index, i); @@ -742,12 +767,14 @@ template > struct get_turns_multi_polygon_cs { - template <typename RobustPolicy, typename Turns, typename InterruptPolicy> + template <typename IntersectionStrategy, typename RobustPolicy, typename Turns, typename InterruptPolicy> static inline void apply( int source_id1, Multi const& multi, int source_id2, Box const& box, + IntersectionStrategy const& intersection_strategy, RobustPolicy const& robust_policy, - Turns& turns, InterruptPolicy& interrupt_policy) + Turns& turns, + InterruptPolicy& interrupt_policy) { typedef typename boost::range_iterator < @@ -766,7 +793,8 @@ struct get_turns_multi_polygon_cs Reverse, ReverseBox, TurnPolicy >::apply(source_id1, *it, source_id2, box, - robust_policy, turns, interrupt_policy, i); + intersection_strategy, robust_policy, + turns, interrupt_policy, i); } } }; @@ -918,13 +946,13 @@ template > struct get_turns_reversed { - template <typename RobustPolicy, typename Turns, typename InterruptPolicy> - static inline void apply( - int source_id1, Geometry1 const& g1, - int source_id2, Geometry2 const& g2, - RobustPolicy const& robust_policy, - Turns& turns, - InterruptPolicy& interrupt_policy) + template <typename IntersectionStrategy, typename RobustPolicy, typename Turns, typename InterruptPolicy> + static inline void apply(int source_id1, Geometry1 const& g1, + int source_id2, Geometry2 const& g2, + IntersectionStrategy const& intersection_strategy, + RobustPolicy const& robust_policy, + Turns& turns, + InterruptPolicy& interrupt_policy) { get_turns < @@ -932,8 +960,9 @@ struct get_turns_reversed Geometry2, Geometry1, Reverse2, Reverse1, TurnPolicy - >::apply(source_id2, g2, source_id1, g1, robust_policy, - turns, interrupt_policy); + >::apply(source_id2, g2, source_id1, g1, + intersection_strategy, robust_policy, + turns, interrupt_policy); } }; @@ -951,6 +980,7 @@ struct get_turns_reversed \tparam Turns type of turn-container (e.g. vector of "intersection/turn point"'s) \param geometry1 \param_geometry \param geometry2 \param_geometry +\param intersection_strategy segments intersection strategy \param robust_policy policy to handle robustness issues \param turns container which will contain turn points \param interrupt_policy policy determining if process is stopped @@ -962,15 +992,17 @@ template typename AssignPolicy, typename Geometry1, typename Geometry2, + typename IntersectionStrategy, typename RobustPolicy, typename Turns, typename InterruptPolicy > inline void get_turns(Geometry1 const& geometry1, - Geometry2 const& geometry2, - RobustPolicy const& robust_policy, - Turns& turns, - InterruptPolicy& interrupt_policy) + Geometry2 const& geometry2, + IntersectionStrategy const& intersection_strategy, + RobustPolicy const& robust_policy, + Turns& turns, + InterruptPolicy& interrupt_policy) { concepts::check_concepts_and_equal_dimensions<Geometry1 const, Geometry2 const>(); @@ -996,11 +1028,11 @@ inline void get_turns(Geometry1 const& geometry1, Reverse1, Reverse2, TurnPolicy > - >::type::apply( - 0, geometry1, - 1, geometry2, - robust_policy, - turns, interrupt_policy); + >::type::apply(0, geometry1, + 1, geometry2, + intersection_strategy, + robust_policy, + turns, interrupt_policy); } #if defined(_MSC_VER) diff --git a/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp b/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp index bb82003a23..3244480f48 100644 --- a/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp +++ b/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp @@ -2,10 +2,11 @@ // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2014, 2015. -// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015, 2017. +// Modifications copyright (c) 2014-2017 Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -71,7 +72,7 @@ struct intersection_segment_segment_point Segment2 const& segment2, RobustPolicy const& robust_policy, OutputIterator out, - Strategy const& ) + Strategy const& strategy) { typedef typename point_type<PointOut>::type point_type; @@ -106,16 +107,15 @@ struct intersection_segment_segment_point >::type > intersection_return_type; - typedef strategy::intersection::relate_cartesian_segments + typedef policies::relate::segments_intersection_points < - policies::relate::segments_intersection_points - < - intersection_return_type - > - > policy; + intersection_return_type + > policy_type; - intersection_return_type is = policy::apply(segment1, segment2, - robust_policy, pi_rob, pj_rob, qi_rob, qj_rob); + intersection_return_type + is = strategy.apply(segment1, segment2, + policy_type(), robust_policy, + pi_rob, pj_rob, qi_rob, qj_rob); for (std::size_t i = 0; i < is.count; i++) { @@ -134,13 +134,14 @@ struct intersection_linestring_linestring_point < typename Linestring1, typename Linestring2, typename RobustPolicy, - typename OutputIterator, typename Strategy + typename OutputIterator, + typename Strategy > static inline OutputIterator apply(Linestring1 const& linestring1, Linestring2 const& linestring2, RobustPolicy const& robust_policy, OutputIterator out, - Strategy const& ) + Strategy const& strategy) { typedef typename point_type<PointOut>::type point_type; @@ -151,7 +152,8 @@ struct intersection_linestring_linestring_point > turn_info; std::deque<turn_info> turns; - geometry::get_intersection_points(linestring1, linestring2, robust_policy, turns); + geometry::get_intersection_points(linestring1, linestring2, + robust_policy, turns, strategy); for (typename boost::range_iterator<std::deque<turn_info> const>::type it = boost::begin(turns); it != boost::end(turns); ++it) @@ -295,7 +297,7 @@ struct intersection_of_linestring_with_areal static inline OutputIterator apply(LineString const& linestring, Areal const& areal, RobustPolicy const& robust_policy, OutputIterator out, - Strategy const& ) + Strategy const& strategy) { if (boost::size(linestring) == 0) { @@ -325,7 +327,7 @@ struct intersection_of_linestring_with_areal false, (OverlayType == overlay_intersection ? ReverseAreal : !ReverseAreal), detail::overlay::assign_null_policy - >(linestring, areal, robust_policy, turns, policy); + >(linestring, areal, strategy, robust_policy, turns, policy); if (no_crossing_turns_or_empty(turns)) { @@ -621,7 +623,7 @@ struct intersection_insert static inline OutputIterator apply(Geometry1 const& geometry1, Geometry2 const& geometry2, RobustPolicy const& robust_policy, - OutputIterator out, Strategy const& ) + OutputIterator out, Strategy const& strategy) { typedef detail::overlay::turn_info @@ -635,7 +637,7 @@ struct intersection_insert geometry::get_turns < false, false, detail::overlay::assign_null_policy - >(geometry1, geometry2, robust_policy, turns, policy); + >(geometry1, geometry2, strategy, robust_policy, turns, policy); for (typename std::vector<turn_info>::const_iterator it = turns.begin(); it != turns.end(); ++it) { @@ -996,7 +998,11 @@ inline OutputIterator intersection_insert(Geometry1 const& geometry1, concepts::check<Geometry1 const>(); concepts::check<Geometry2 const>(); - typedef typename Strategy::rescale_policy_type rescale_policy_type; + typedef typename geometry::rescale_policy_type + < + typename geometry::point_type<Geometry1>::type // TODO from both + >::type rescale_policy_type; + rescale_policy_type robust_policy = geometry::get_rescale_policy<rescale_policy_type>(geometry1, geometry2); @@ -1037,22 +1043,13 @@ inline OutputIterator intersection_insert(Geometry1 const& geometry1, concepts::check<Geometry1 const>(); concepts::check<Geometry2 const>(); - typedef typename geometry::rescale_policy_type - < - typename geometry::point_type<Geometry1>::type // TODO from both - >::type rescale_policy_type; - - typedef intersection_strategies + typedef typename strategy::intersection::services::default_strategy < - typename cs_tag<GeometryOut>::type, - Geometry1, - Geometry2, - typename geometry::point_type<GeometryOut>::type, - rescale_policy_type - > strategy; - + typename cs_tag<GeometryOut>::type + >::type strategy_type; + return intersection_insert<GeometryOut>(geometry1, geometry2, out, - strategy()); + strategy_type()); } }} // namespace detail::intersection diff --git a/boost/geometry/algorithms/detail/overlay/linear_linear.hpp b/boost/geometry/algorithms/detail/overlay/linear_linear.hpp index 34517f6590..a74bb33ba1 100644 --- a/boost/geometry/algorithms/detail/overlay/linear_linear.hpp +++ b/boost/geometry/algorithms/detail/overlay/linear_linear.hpp @@ -1,11 +1,12 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014-2015, Oracle and/or its affiliates. +// Copyright (c) 2014-2017, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_LINEAR_LINEAR_HPP @@ -158,11 +159,13 @@ protected: typename Turns, typename LinearGeometry1, typename LinearGeometry2, + typename IntersectionStrategy, typename RobustPolicy > static inline void compute_turns(Turns& turns, LinearGeometry1 const& linear1, LinearGeometry2 const& linear2, + IntersectionStrategy const& strategy, RobustPolicy const& robust_policy) { turns.clear(); @@ -180,7 +183,7 @@ protected: assign_policy >, RobustPolicy - >::apply(turns, linear1, linear2, interrupt_policy, robust_policy); + >::apply(turns, linear1, linear2, interrupt_policy, strategy, robust_policy); } @@ -237,7 +240,7 @@ public: Linear2 const& linear2, RobustPolicy const& robust_policy, OutputIterator oit, - Strategy const& ) + Strategy const& strategy) { typedef typename detail::relate::turns::get_turns < @@ -255,7 +258,7 @@ public: typedef std::vector<turn_info> turns_container; turns_container turns; - compute_turns(turns, linear1, linear2, robust_policy); + compute_turns(turns, linear1, linear2, strategy, robust_policy); if ( turns.empty() ) { diff --git a/boost/geometry/algorithms/detail/overlay/overlay.hpp b/boost/geometry/algorithms/detail/overlay/overlay.hpp index 09c80025a0..f1af2f1949 100644 --- a/boost/geometry/algorithms/detail/overlay/overlay.hpp +++ b/boost/geometry/algorithms/detail/overlay/overlay.hpp @@ -3,10 +3,11 @@ // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland -// This file was modified by Oracle on 2015. -// Modifications copyright (c) 2015, Oracle and/or its affiliates. +// This file was modified by Oracle on 2015, 2017. +// Modifications copyright (c) 2015-2017, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -184,7 +185,7 @@ struct overlay Geometry1 const& geometry1, Geometry2 const& geometry2, RobustPolicy const& robust_policy, OutputIterator out, - Strategy const& , + Strategy const& strategy, Visitor& visitor) { bool const is_empty1 = geometry::is_empty(geometry1); @@ -233,7 +234,7 @@ std::cout << "get turns" << std::endl; < Reverse1, Reverse2, detail::overlay::assign_null_policy - >(geometry1, geometry2, robust_policy, turns, policy); + >(geometry1, geometry2, strategy, robust_policy, turns, policy); visitor.visit_turns(1, turns); @@ -262,6 +263,7 @@ std::cout << "traverse" << std::endl; traverse<Reverse1, Reverse2, Geometry1, Geometry2, OverlayType>::apply ( geometry1, geometry2, + strategy, robust_policy, turns, rings, clusters, diff --git a/boost/geometry/algorithms/detail/overlay/pointlike_linear.hpp b/boost/geometry/algorithms/detail/overlay/pointlike_linear.hpp index 156cb54867..a26f54e008 100644 --- a/boost/geometry/algorithms/detail/overlay/pointlike_linear.hpp +++ b/boost/geometry/algorithms/detail/overlay/pointlike_linear.hpp @@ -1,12 +1,13 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2015, Oracle and/or its affiliates. +// Copyright (c) 2015-2017, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html -// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle - #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_POINTLIKE_LINEAR_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_POINTLIKE_LINEAR_HPP @@ -69,12 +70,12 @@ struct point_linear_point Linear const& linear, RobustPolicy const&, OutputIterator oit, - Strategy const&) + Strategy const& strategy) { action_selector_pl_l < PointOut, OverlayType - >::apply(point, Policy::apply(point, linear), oit); + >::apply(point, Policy::apply(point, linear, strategy), oit); return oit; } }; @@ -95,7 +96,7 @@ struct multipoint_segment_point Segment const& segment, RobustPolicy const&, OutputIterator oit, - Strategy const&) + Strategy const& strategy) { for (typename boost::range_iterator<MultiPoint const>::type it = boost::begin(multipoint); @@ -105,7 +106,7 @@ struct multipoint_segment_point action_selector_pl_l < PointOut, OverlayType - >::apply(*it, Policy::apply(*it, segment), oit); + >::apply(*it, Policy::apply(*it, segment, strategy), oit); } return oit; @@ -145,11 +146,14 @@ private: } }; - template <typename OutputIterator> + template <typename OutputIterator, typename Strategy> class item_visitor_type { public: - item_visitor_type(OutputIterator& oit) : m_oit(oit) {} + item_visitor_type(OutputIterator& oit, Strategy const& strategy) + : m_oit(oit) + , m_strategy(strategy) + {} template <typename Item1, typename Item2> inline void apply(Item1 const& item1, Item2 const& item2) @@ -157,11 +161,12 @@ private: action_selector_pl_l < PointOut, overlay_intersection - >::apply(item1, Policy::apply(item1, item2), m_oit); + >::apply(item1, Policy::apply(item1, item2, m_strategy), m_oit); } private: OutputIterator& m_oit; + Strategy const& m_strategy; }; // structs for partition -- end @@ -189,12 +194,13 @@ private: Linear const& m_linear; }; - template <typename OutputIterator> + template <typename OutputIterator, typename Strategy> static inline OutputIterator get_common_points(MultiPoint const& multipoint, Linear const& linear, - OutputIterator oit) + OutputIterator oit, + Strategy const& strategy) { - item_visitor_type<OutputIterator> item_visitor(oit); + item_visitor_type<OutputIterator, Strategy> item_visitor(oit, strategy); segment_range rng(linear); @@ -203,10 +209,9 @@ private: geometry::model::box < typename boost::range_value<MultiPoint>::type - >, - expand_box, - overlaps_box - >::apply(multipoint, rng, item_visitor); + > + >::apply(multipoint, rng, item_visitor, + expand_box(), overlaps_box()); return oit; } @@ -228,7 +233,8 @@ public: // compute the common points get_common_points(multipoint, linear, - std::back_inserter(common_points)); + std::back_inserter(common_points), + strategy); return multipoint_multipoint_point < diff --git a/boost/geometry/algorithms/detail/overlay/self_turn_points.hpp b/boost/geometry/algorithms/detail/overlay/self_turn_points.hpp index aedf22e1fb..8540ef98a0 100644 --- a/boost/geometry/algorithms/detail/overlay/self_turn_points.hpp +++ b/boost/geometry/algorithms/detail/overlay/self_turn_points.hpp @@ -2,6 +2,11 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// This file was modified by Oracle on 2017. +// Modifications copyright (c) 2017 Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + // 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) @@ -61,20 +66,25 @@ template typename Geometry, typename Turns, typename TurnPolicy, + typename IntersectionStrategy, typename RobustPolicy, typename InterruptPolicy > struct self_section_visitor { Geometry const& m_geometry; + IntersectionStrategy const& m_intersection_strategy; RobustPolicy const& m_rescale_policy; Turns& m_turns; InterruptPolicy& m_interrupt_policy; inline self_section_visitor(Geometry const& g, - RobustPolicy const& rp, - Turns& turns, InterruptPolicy& ip) + IntersectionStrategy const& is, + RobustPolicy const& rp, + Turns& turns, + InterruptPolicy& ip) : m_geometry(g) + , m_intersection_strategy(is) , m_rescale_policy(rp) , m_turns(turns) , m_interrupt_policy(ip) @@ -97,6 +107,7 @@ struct self_section_visitor 0, m_geometry, sec1, 0, m_geometry, sec2, false, + m_intersection_strategy, m_rescale_policy, m_turns, m_interrupt_policy); } @@ -116,9 +127,10 @@ struct self_section_visitor template<typename TurnPolicy> struct get_turns { - template <typename Geometry, typename RobustPolicy, typename Turns, typename InterruptPolicy> + template <typename Geometry, typename IntersectionStrategy, typename RobustPolicy, typename Turns, typename InterruptPolicy> static inline bool apply( Geometry const& geometry, + IntersectionStrategy const& intersection_strategy, RobustPolicy const& robust_policy, Turns& turns, InterruptPolicy& interrupt_policy) @@ -142,17 +154,17 @@ struct get_turns self_section_visitor < Geometry, - Turns, TurnPolicy, RobustPolicy, InterruptPolicy - > visitor(geometry, robust_policy, turns, interrupt_policy); + Turns, TurnPolicy, IntersectionStrategy, RobustPolicy, InterruptPolicy + > visitor(geometry, intersection_strategy, robust_policy, turns, interrupt_policy); try { geometry::partition < - box_type, - detail::section::get_section_box, - detail::section::overlaps_section_box - >::apply(sec, visitor); + box_type + >::apply(sec, visitor, + detail::section::get_section_box(), + detail::section::overlaps_section_box()); } catch(self_ip_exception const& ) { @@ -208,9 +220,10 @@ struct self_get_turn_points TurnPolicy > { - template <typename RobustPolicy, typename Turns, typename InterruptPolicy> + template <typename Strategy, typename RobustPolicy, typename Turns, typename InterruptPolicy> static inline bool apply( Box const& , + Strategy const& , RobustPolicy const& , Turns& , InterruptPolicy& ) @@ -259,6 +272,7 @@ struct self_get_turn_points \tparam Turns type of intersection container (e.g. vector of "intersection/turn point"'s) \param geometry geometry + \param strategy strategy to be used \param robust_policy policy to handle robustness issues \param turns container which will contain intersection points \param interrupt_policy policy determining if process is stopped @@ -268,13 +282,15 @@ template < typename AssignPolicy, typename Geometry, + typename IntersectionStrategy, typename RobustPolicy, typename Turns, typename InterruptPolicy > inline void self_turns(Geometry const& geometry, - RobustPolicy const& robust_policy, - Turns& turns, InterruptPolicy& interrupt_policy) + IntersectionStrategy const& strategy, + RobustPolicy const& robust_policy, + Turns& turns, InterruptPolicy& interrupt_policy) { concepts::check<Geometry const>(); @@ -285,7 +301,7 @@ inline void self_turns(Geometry const& geometry, typename tag<Geometry>::type, Geometry, turn_policy - >::apply(geometry, robust_policy, turns, interrupt_policy); + >::apply(geometry, strategy, robust_policy, turns, interrupt_policy); } diff --git a/boost/geometry/algorithms/detail/overlay/traversal.hpp b/boost/geometry/algorithms/detail/overlay/traversal.hpp index 5adc0fcf69..bc828920e9 100644 --- a/boost/geometry/algorithms/detail/overlay/traversal.hpp +++ b/boost/geometry/algorithms/detail/overlay/traversal.hpp @@ -140,10 +140,10 @@ struct traversal { for (int i = 0; i < 2; i++) { - turn_operation_type& op = turn.operations[i]; - if (op.visited.none()) + turn_operation_type& turn_op = turn.operations[i]; + if (turn_op.visited.none()) { - op.visited.set_visited(); + turn_op.visited.set_visited(); } } } diff --git a/boost/geometry/algorithms/detail/overlay/traversal_ring_creator.hpp b/boost/geometry/algorithms/detail/overlay/traversal_ring_creator.hpp index e0dfee19a8..9ab82a77c1 100644 --- a/boost/geometry/algorithms/detail/overlay/traversal_ring_creator.hpp +++ b/boost/geometry/algorithms/detail/overlay/traversal_ring_creator.hpp @@ -2,6 +2,10 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// This file was modified by Oracle on 2017. +// Modifications copyright (c) 2017, Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + // 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) @@ -38,6 +42,7 @@ template typename Geometry2, typename Turns, typename Clusters, + typename IntersectionStrategy, typename RobustPolicy, typename Visitor, typename Backtrack @@ -56,12 +61,14 @@ struct traversal_ring_creator inline traversal_ring_creator(Geometry1 const& geometry1, Geometry2 const& geometry2, Turns& turns, Clusters const& clusters, + IntersectionStrategy const& intersection_strategy, RobustPolicy const& robust_policy, Visitor& visitor) : m_trav(geometry1, geometry2, turns, clusters, robust_policy,visitor) , m_geometry1(geometry1) , m_geometry2(geometry2) , m_turns(turns) , m_clusters(clusters) + , m_intersection_strategy(intersection_strategy) , m_robust_policy(robust_policy) , m_visitor(visitor) { @@ -280,7 +287,8 @@ struct traversal_ring_creator rings, ring, m_turns, start_turn, m_turns[turn_index].operations[op_index], traverse_error, - m_geometry1, m_geometry2, m_robust_policy, + m_geometry1, m_geometry2, + m_intersection_strategy, m_robust_policy, state, m_visitor); } } @@ -314,6 +322,7 @@ private: Geometry2 const& m_geometry2; Turns& m_turns; Clusters const& m_clusters; + IntersectionStrategy const& m_intersection_strategy; RobustPolicy const& m_robust_policy; Visitor& m_visitor; }; diff --git a/boost/geometry/algorithms/detail/overlay/traverse.hpp b/boost/geometry/algorithms/detail/overlay/traverse.hpp index f01e50eb03..058f6c9458 100644 --- a/boost/geometry/algorithms/detail/overlay/traverse.hpp +++ b/boost/geometry/algorithms/detail/overlay/traverse.hpp @@ -58,6 +58,7 @@ class traverse public : template < + typename IntersectionStrategy, typename RobustPolicy, typename Turns, typename Rings, @@ -66,6 +67,7 @@ public : > static inline void apply(Geometry1 const& geometry1, Geometry2 const& geometry2, + IntersectionStrategy const& intersection_strategy, RobustPolicy const& robust_policy, Turns& turns, Rings& rings, Clusters& clusters, @@ -88,10 +90,11 @@ public : Reverse1, Reverse2, OverlayType, Geometry1, Geometry2, Turns, Clusters, + IntersectionStrategy, RobustPolicy, Visitor, Backtrack > trav(geometry1, geometry2, turns, clusters, - robust_policy, visitor); + intersection_strategy, robust_policy, visitor); std::size_t finalized_ring_size = boost::size(rings); |