• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
4 
5 // Use, modification and distribution is subject to the Boost Software License,
6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 
9 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TRAVERSE_HPP
10 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TRAVERSE_HPP
11 
12 #include <cstddef>
13 
14 #include <boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp>
15 #include <boost/geometry/algorithms/detail/overlay/traversal_ring_creator.hpp>
16 #include <boost/geometry/algorithms/detail/overlay/traversal_switch_detector.hpp>
17 
18 
19 namespace boost { namespace geometry
20 {
21 
22 #ifndef DOXYGEN_NO_DETAIL
23 namespace detail { namespace overlay
24 {
25 
26 
27 /*!
28     \brief Traverses through intersection points / geometries
29     \ingroup overlay
30  */
31 template
32 <
33     bool Reverse1, bool Reverse2,
34     typename Geometry1,
35     typename Geometry2,
36     overlay_type OverlayType,
37     typename Backtrack = backtrack_check_self_intersections<Geometry1, Geometry2>
38 >
39 class traverse
40 {
41 
42     template <typename Turns>
reset_visits(Turns & turns)43     static void reset_visits(Turns& turns)
44     {
45         for (typename boost::range_iterator<Turns>::type
46             it = boost::begin(turns);
47             it != boost::end(turns);
48             ++it)
49         {
50             for (int i = 0; i < 2; i++)
51             {
52                 it->operations[i].visited.reset();
53             }
54         }
55     }
56 
57 
58 public :
59     template
60     <
61         typename IntersectionStrategy,
62         typename RobustPolicy,
63         typename Turns,
64         typename Rings,
65         typename TurnInfoMap,
66         typename Clusters,
67         typename Visitor
68     >
apply(Geometry1 const & geometry1,Geometry2 const & geometry2,IntersectionStrategy const & intersection_strategy,RobustPolicy const & robust_policy,Turns & turns,Rings & rings,TurnInfoMap & turn_info_map,Clusters & clusters,Visitor & visitor)69     static inline void apply(Geometry1 const& geometry1,
70                 Geometry2 const& geometry2,
71                 IntersectionStrategy const& intersection_strategy,
72                 RobustPolicy const& robust_policy,
73                 Turns& turns, Rings& rings,
74                 TurnInfoMap& turn_info_map,
75                 Clusters& clusters,
76                 Visitor& visitor)
77     {
78         traversal_switch_detector
79             <
80                 Reverse1, Reverse2, OverlayType,
81                 Geometry1, Geometry2,
82                 Turns, Clusters,
83                 RobustPolicy, Visitor
84             > switch_detector(geometry1, geometry2, turns, clusters,
85                    robust_policy, visitor);
86 
87         switch_detector.iterate();
88         reset_visits(turns);
89 
90         traversal_ring_creator
91             <
92                 Reverse1, Reverse2, OverlayType,
93                 Geometry1, Geometry2,
94                 Turns, TurnInfoMap, Clusters,
95                 IntersectionStrategy,
96                 RobustPolicy, Visitor,
97                 Backtrack
98             > trav(geometry1, geometry2, turns, turn_info_map, clusters,
99                    intersection_strategy, robust_policy, visitor);
100 
101         std::size_t finalized_ring_size = boost::size(rings);
102 
103         typename Backtrack::state_type state;
104 
105         trav.iterate(rings, finalized_ring_size, state);
106     }
107 };
108 
109 }} // namespace detail::overlay
110 #endif // DOXYGEN_NO_DETAIL
111 
112 }} // namespace boost::geometry
113 
114 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TRAVERSE_HPP
115