// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2014-2017 Adam Wulkiewicz, Lodz, Poland.
-// This file was modified by Oracle on 2014-2020.
-// Modifications copyright (c) 2014-2020 Oracle and/or its affiliates.
+// This file was modified by Oracle on 2014-2021.
+// Modifications copyright (c) 2014-2021 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
#include <boost/geometry/util/math.hpp>
#include <boost/geometry/util/type_traits.hpp>
-#include <boost/geometry/views/closeable_view.hpp>
-#include <boost/geometry/views/reversible_view.hpp>
-#include <boost/geometry/views/detail/range_type.hpp>
+#include <boost/geometry/views/detail/closed_clockwise_view.hpp>
#ifdef BOOST_GEOMETRY_DEBUG_INTERSECTION
typename Section,
typename Point,
typename CircularIterator,
- typename IntersectionStrategy,
+ typename Strategy,
typename RobustPolicy
>
struct unique_sub_range_from_section
unique_sub_range_from_section(Section const& section, signed_size_type index,
CircularIterator circular_iterator,
Point const& previous, Point const& current,
+ Strategy const& strategy,
RobustPolicy const& robust_policy)
- : m_section(section)
- , m_index(index)
- , m_previous_point(previous)
- , m_current_point(current)
- , m_circular_iterator(circular_iterator)
- , m_point_retrieved(false)
- , m_robust_policy(robust_policy)
- {
- }
+ : m_section(section)
+ , m_index(index)
+ , m_previous_point(previous)
+ , m_current_point(current)
+ , m_circular_iterator(circular_iterator)
+ , m_point_retrieved(false)
+ , m_strategy(strategy)
+ , m_robust_policy(robust_policy)
+ {}
inline bool is_first_segment() const
{
inline void advance_to_non_duplicate_next(Point const& current, CircularIterator& circular_iterator) const
{
- typedef typename IntersectionStrategy::point_in_point_strategy_type disjoint_strategy_type;
typedef typename robust_point_type<Point, RobustPolicy>::type robust_point_type;
robust_point_type current_robust_point;
robust_point_type next_robust_point;
// So advance to the "non duplicate next"
// (the check is defensive, to avoid endless loops)
std::size_t check = 0;
- while(! detail::disjoint::disjoint_point_point
- (
- current_robust_point, next_robust_point,
- disjoint_strategy_type()
- )
- && check++ < m_section.range_count)
+ while (! detail::disjoint::disjoint_point_point(
+ current_robust_point, next_robust_point, m_strategy)
+ && check++ < m_section.range_count)
{
circular_iterator++;
geometry::recalculate(next_robust_point, *circular_iterator, m_robust_policy);
mutable CircularIterator m_circular_iterator;
mutable Point m_point;
mutable bool m_point_retrieved;
+ Strategy m_strategy;
RobustPolicy m_robust_policy;
};
>
class get_turns_in_sections
{
- typedef typename closeable_view
+ using range1_view = detail::closed_clockwise_view
<
- typename range_type<Geometry1>::type const,
- closure<Geometry1>::value
- >::type cview_type1;
- typedef typename closeable_view
+ typename ring_type<Geometry1>::type const,
+ geometry::closure<Geometry1>::value,
+ Reverse1 ? counterclockwise : clockwise
+ >;
+ using range2_view = detail::closed_clockwise_view
<
- typename range_type<Geometry2>::type const,
- closure<Geometry2>::value
- >::type cview_type2;
+ typename ring_type<Geometry2>::type const,
+ geometry::closure<Geometry2>::value,
+ Reverse2 ? counterclockwise : clockwise
+ >;
- typedef typename reversible_view
- <
- cview_type1 const,
- Reverse1 ? iterate_reverse : iterate_forward
- >::type view_type1;
- typedef typename reversible_view
- <
- cview_type2 const,
- Reverse2 ? iterate_reverse : iterate_forward
- >::type view_type2;
+ using range1_iterator = typename boost::range_iterator<range1_view const>::type;
+ using range2_iterator = typename boost::range_iterator<range2_view const>::type;
- typedef typename boost::range_iterator
- <
- view_type1 const
- >::type range1_iterator;
-
- typedef typename boost::range_iterator
- <
- view_type2 const
- >::type range2_iterator;
-
- typedef ever_circling_iterator<range1_iterator> circular1_iterator;
- typedef ever_circling_iterator<range2_iterator> circular2_iterator;
+ using circular1_iterator = ever_circling_iterator<range1_iterator>;
+ using circular2_iterator = ever_circling_iterator<range2_iterator>;
template <typename Geometry, typename Section>
static inline bool adjacent(Section const& section,
public :
// Returns true if terminated, false if interrupted
- template <typename IntersectionStrategy, typename RobustPolicy, typename Turns, typename InterruptPolicy>
+ template <typename Strategy, 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, bool skip_adjacent,
- IntersectionStrategy const& intersection_strategy,
+ Strategy const& strategy,
RobustPolicy const& robust_policy,
Turns& turns,
InterruptPolicy& interrupt_policy)
return true;
}
- cview_type1 cview1(range_by_section(geometry1, sec1));
- cview_type2 cview2(range_by_section(geometry2, sec2));
- view_type1 view1(cview1);
- view_type2 view2(cview2);
+ range1_view const view1(range_by_section(geometry1, sec1));
+ range2_view const view2(range_by_section(geometry2, sec2));
range1_iterator begin_range_1 = boost::begin(view1);
range1_iterator end_range_1 = boost::end(view1);
// We need a circular iterator because it might run through the closing point.
// One circle is actually enough but this one is just convenient.
- ever_circling_iterator<range1_iterator> next1(begin_range_1, end_range_1, it1, true);
+ circular1_iterator next1(begin_range_1, end_range_1, it1, true);
next1++;
// Walk through section and stop if we exceed the other box
unique_sub_range_from_section
<
areal1, Section1, point1_type, circular1_iterator,
- IntersectionStrategy, RobustPolicy
+ Strategy, RobustPolicy
> unique_sub_range1(sec1, index1,
circular1_iterator(begin_range_1, end_range_1, next1, true),
*prev1, *it1,
- robust_policy);
+ strategy, robust_policy);
signed_size_type index2 = sec2.begin_index;
signed_size_type ndi2 = sec2.non_duplicate_index;
get_start_point_iterator(sec2, view2, prev2, it2, end2,
index2, ndi2, dir2, sec1.bounding_box, robust_policy);
- ever_circling_iterator<range2_iterator> next2(begin_range_2, end_range_2, it2, true);
+ circular2_iterator next2(begin_range_2, end_range_2, it2, true);
next2++;
for (prev2 = it2++, next2++;
unique_sub_range_from_section
<
areal2, Section2, point2_type, circular2_iterator,
- IntersectionStrategy, RobustPolicy
+ Strategy, RobustPolicy
> unique_sub_range2(sec2, index2,
circular2_iterator(begin_range_2, end_range_2, next2),
*prev2, *it2,
- robust_policy);
+ strategy, robust_policy);
typedef typename boost::range_value<Turns>::type turn_info;
std::size_t const size_before = boost::size(turns);
TurnPolicy::apply(unique_sub_range1, unique_sub_range2,
- ti, intersection_strategy, robust_policy,
+ ti, strategy, robust_policy,
std::back_inserter(turns));
if (InterruptPolicy::enabled)
typename Geometry1, typename Geometry2,
bool Reverse1, bool Reverse2,
typename TurnPolicy,
- typename IntersectionStrategy,
+ typename Strategy,
typename RobustPolicy,
typename Turns,
typename InterruptPolicy
Geometry1 const& m_geometry1;
int m_source_id2;
Geometry2 const& m_geometry2;
- IntersectionStrategy const& m_intersection_strategy;
+ Strategy const& m_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,
- IntersectionStrategy const& intersection_strategy,
+ Strategy const& 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_strategy(strategy)
, m_rescale_policy(robust_policy)
, m_turns(turns)
, m_interrupt_policy(ip)
{
if (! detail::disjoint::disjoint_box_box(sec1.bounding_box,
sec2.bounding_box,
- m_intersection_strategy.get_disjoint_box_box_strategy()))
+ m_strategy) )
{
// false if interrupted
return get_turns_in_sections
>::apply(m_source_id1, m_geometry1, sec1,
m_source_id2, m_geometry2, sec2,
false, false,
- m_intersection_strategy,
+ m_strategy,
m_rescale_policy,
m_turns, m_interrupt_policy);
}
{
public:
- template <typename IntersectionStrategy, typename RobustPolicy, typename Turns, typename InterruptPolicy>
+ template <typename Strategy, 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,
+ Strategy const& strategy,
RobustPolicy const& robust_policy,
Turns& turns,
InterruptPolicy& interrupt_policy)
sections_type sec1, sec2;
typedef std::integer_sequence<std::size_t, 0, 1> dimensions;
- typename IntersectionStrategy::envelope_strategy_type const
- envelope_strategy = intersection_strategy.get_envelope_strategy();
- typename IntersectionStrategy::expand_strategy_type const
- expand_strategy = intersection_strategy.get_expand_strategy();
-
geometry::sectionalize<Reverse1, dimensions>(geometry1, robust_policy,
- sec1, envelope_strategy, expand_strategy, 0);
+ sec1, strategy, 0);
geometry::sectionalize<Reverse2, dimensions>(geometry2, robust_policy,
- sec2, envelope_strategy, expand_strategy, 1);
+ sec2, strategy, 1);
// ... and then partition them, intersecting overlapping sections in visitor method
section_visitor
Geometry1, Geometry2,
Reverse1, Reverse2,
TurnPolicy,
- IntersectionStrategy, RobustPolicy,
+ Strategy, RobustPolicy,
Turns, InterruptPolicy
> visitor(source_id1, geometry1, source_id2, geometry2,
- intersection_strategy, robust_policy,
- turns, interrupt_policy);
-
- typedef detail::section::get_section_box
- <
- typename IntersectionStrategy::expand_box_strategy_type
- > get_section_box_type;
- typedef detail::section::overlaps_section_box
- <
- typename IntersectionStrategy::disjoint_box_box_strategy_type
- > overlaps_section_box_type;
+ strategy, robust_policy, turns, interrupt_policy);
geometry::partition
<
box_type
>::apply(sec1, sec2, visitor,
- get_section_box_type(),
- overlaps_section_box_type());
+ detail::section::get_section_box<Strategy>(strategy),
+ detail::section::overlaps_section_box<Strategy>(strategy));
}
};
typedef typename geometry::point_type<Box>::type box_point_type;
typedef boost::array<box_point_type, 4> box_array;
- typedef typename closeable_view
+ using view_type = detail::closed_clockwise_view
<
Range const,
- closure<Range>::value
- >::type cview_type;
+ geometry::closure<Range>::value,
+ ReverseRange ? counterclockwise : clockwise
+ >;
- typedef typename reversible_view
- <
- cview_type const,
- ReverseRange ? iterate_reverse : iterate_forward
- >::type view_type;
-
- typedef typename boost::range_iterator
- <
- view_type const
- >::type iterator_type;
+ using iterator_type = typename boost::range_iterator<view_type const>::type;
struct unique_sub_range_from_box_policy
{
box_array box_points;
assign_box_corners_oriented<ReverseBox>(box, box_points);
- cview_type cview(range);
- view_type view(cview);
+ view_type const view(range);
// TODO: in this code, possible duplicate points are not yet taken
// into account (not in the iterator, nor in the retrieve policy)
>
struct get_turns_reversed
{
- template <typename IntersectionStrategy, typename RobustPolicy, typename Turns, typename InterruptPolicy>
+ template <typename Strategy, 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,
+ Strategy const& strategy,
RobustPolicy const& robust_policy,
Turns& turns,
InterruptPolicy& interrupt_policy)
Reverse2, Reverse1,
TurnPolicy
>::apply(source_id2, g2, source_id1, g1,
- intersection_strategy, robust_policy,
+ strategy, robust_policy,
turns, interrupt_policy);
}
};
typename AssignPolicy,
typename Geometry1,
typename Geometry2,
- typename IntersectionStrategy,
+ typename Strategy,
typename RobustPolicy,
typename Turns,
typename InterruptPolicy
>
inline void get_turns(Geometry1 const& geometry1,
Geometry2 const& geometry2,
- IntersectionStrategy const& intersection_strategy,
+ Strategy const& strategy,
RobustPolicy const& robust_policy,
Turns& turns,
InterruptPolicy& interrupt_policy)
>
>::apply(0, geometry1,
1, geometry2,
- intersection_strategy,
+ strategy,
robust_policy,
turns, interrupt_policy);
}