summaryrefslogtreecommitdiff
path: root/boost/geometry/algorithms/detail/overlay/get_turn_info_helpers.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/geometry/algorithms/detail/overlay/get_turn_info_helpers.hpp')
-rw-r--r--boost/geometry/algorithms/detail/overlay/get_turn_info_helpers.hpp139
1 files changed, 86 insertions, 53 deletions
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;
};