1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // This file was modified by Oracle on 2018.
6 // Modifications copyright (c) 2018 Oracle and/or its affiliates.
8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
10 // Use, modification and distribution is subject to the Boost Software License,
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12 // http://www.boost.org/LICENSE_1_0.txt)
14 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CHECK_ENRICH_HPP
15 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CHECK_ENRICH_HPP
17 #ifdef BOOST_GEOMETRY_DEBUG_ENRICH
19 #endif // BOOST_GEOMETRY_DEBUG_ENRICH
24 #include <boost/range/begin.hpp>
25 #include <boost/range/end.hpp>
26 #include <boost/range/value_type.hpp>
28 #include <boost/geometry/algorithms/detail/overlay/overlay_type.hpp>
31 namespace boost { namespace geometry
34 #ifndef DOXYGEN_NO_DETAIL
35 namespace detail { namespace overlay
39 template<typename Turn>
46 inline meta_turn(int i, Turn const& t)
55 template <typename MetaTurn>
56 inline void display(MetaTurn const& meta_turn, const char* reason = "")
58 #ifdef BOOST_GEOMETRY_DEBUG_ENRICH
59 std::cout << meta_turn.index
60 << "\tMethods: " << method_char(meta_turn.turn->method)
61 << " operations: " << operation_char(meta_turn.turn->operations[0].operation)
62 << operation_char(meta_turn.turn->operations[1].operation)
63 << " travels to " << meta_turn.turn->operations[0].enriched.travels_to_ip_index
64 << " and " << meta_turn.turn->operations[1].enriched.travels_to_ip_index
65 //<< " -> " << op_index
72 template <typename MetaTurns, typename MetaTurn>
73 inline void check_detailed(MetaTurns& meta_turns, MetaTurn const& meta_turn,
74 int op_index, int cycle, int start, operation_type for_operation,
78 int const ip_index = meta_turn.turn->operations[op_index].enriched.travels_to_ip_index;
83 if (ip_index == start)
85 display(meta_turns[ip_index], " FINISH");
89 // check on continuing, or on same-operation-on-same-geometry
90 if (! meta_turns[ip_index].handled[op_index]
91 && (meta_turns[ip_index].turn->operations[op_index].operation == operation_continue
92 || meta_turns[ip_index].turn->operations[op_index].operation == for_operation)
95 meta_turns[ip_index].handled[op_index] = true;
96 check_detailed(meta_turns, meta_turns[ip_index], op_index, cycle, start, for_operation, error);
99 // check on other geometry
102 int const other_index = 1 - op_index;
103 if (! meta_turns[ip_index].handled[other_index]
104 && meta_turns[ip_index].turn->operations[other_index].operation == for_operation)
106 meta_turns[ip_index].handled[other_index] = true;
107 check_detailed(meta_turns, meta_turns[ip_index], other_index, cycle, start, for_operation, error);
114 display(meta_turns[ip_index], " STOP");
116 #ifndef BOOST_GEOMETRY_DEBUG_ENRICH
117 //std::cout << " STOP";
124 template <typename TurnPoints>
125 inline bool check_graph(TurnPoints& turn_points, operation_type for_operation)
127 typedef typename boost::range_value<TurnPoints>::type turn_point_type;
132 std::vector<meta_turn<turn_point_type> > meta_turns;
133 for (typename boost::range_iterator<TurnPoints const>::type
134 it = boost::begin(turn_points);
135 it != boost::end(turn_points);
138 meta_turns.push_back(meta_turn<turn_point_type>(index, *it));
142 for (typename boost::range_iterator<std::vector<meta_turn<turn_point_type> > > ::type
143 it = boost::begin(meta_turns);
144 it != boost::end(meta_turns);
147 if (! (it->turn->blocked() || it->turn->discarded))
149 for (int i = 0 ; i < 2; i++)
152 && it->turn->operations[i].operation == for_operation)
154 #ifdef BOOST_GEOMETRY_DEBUG_ENRICH
155 std::cout << "CYCLE " << cycle << std::endl;
157 it->handled[i] = true;
158 check_detailed(meta_turns, *it, i, cycle++, it->index, for_operation, error);
159 #ifdef BOOST_GEOMETRY_DEBUG_ENRICH
160 std::cout <<" END CYCLE " << it->index << std::endl;
171 }} // namespace detail::overlay
172 #endif //DOXYGEN_NO_DETAIL
176 }} // namespace boost::geometry
179 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CHECK_ENRICH_HPP