1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
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)
9 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TURN_INFO_HPP
10 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TURN_INFO_HPP
13 #include <boost/array.hpp>
15 #include <boost/geometry/core/coordinate_type.hpp>
16 #include <boost/geometry/algorithms/detail/signed_size_type.hpp>
17 #include <boost/geometry/algorithms/detail/overlay/segment_identifier.hpp>
18 #include <boost/geometry/algorithms/detail/overlay/overlay_type.hpp>
19 #include <boost/geometry/policies/robustness/segment_ratio.hpp>
21 namespace boost { namespace geometry
24 #ifndef DOXYGEN_NO_DETAIL
25 namespace detail { namespace overlay
34 method_touch_interior,
43 \brief Turn operation: operation
44 \details Information necessary for traversal phase (a phase
45 of the overlay process). The information is gathered during the
46 get_turns (segment intersection) phase.
47 The class is to be included in the turn_info class, either direct
48 or a derived or similar class with more (e.g. enrichment) information.
50 template <typename Point, typename SegmentRatio>
53 typedef SegmentRatio segment_ratio_type;
55 operation_type operation;
56 segment_identifier seg_id;
57 SegmentRatio fraction;
59 typedef typename coordinate_type<Point>::type comparable_distance_type;
60 comparable_distance_type remaining_distance;
62 inline turn_operation()
63 : operation(operation_none)
64 , remaining_distance(0)
70 \brief Turn information: intersection point, method, and turn information
71 \details Information necessary for traversal phase (a phase
72 of the overlay process). The information is gathered during the
73 get_turns (segment intersection) phase.
74 \tparam Point point type of intersection point
75 \tparam Operation gives classes opportunity to add additional info
76 \tparam Container gives classes opportunity to define how operations are stored
81 typename SegmentRatio = geometry::segment_ratio<typename coordinate_type<Point>::type>,
82 typename Operation = turn_operation<Point, SegmentRatio>,
83 typename Container = boost::array<Operation, 2>
87 typedef Point point_type;
88 typedef SegmentRatio segment_ratio_type;
89 typedef Operation turn_operation_type;
90 typedef Container container_type;
94 bool touch_only; // True in case of method touch(interior) and lines do not cross
95 signed_size_type cluster_id; // For multiple turns on same location, > 0. Else -1. 0 is unused.
97 bool has_colocated_both; // Colocated with a uu turn (for union) or ii (other)
102 : method(method_none)
106 , has_colocated_both(false)
109 inline bool both(operation_type type) const
111 return has12(type, type);
114 inline bool has(operation_type type) const
116 return this->operations[0].operation == type
117 || this->operations[1].operation == type;
120 inline bool combination(operation_type type1, operation_type type2) const
122 return has12(type1, type2) || has12(type2, type1);
125 inline bool blocked() const
127 return both(operation_blocked);
129 inline bool opposite() const
131 return both(operation_opposite);
133 inline bool any_blocked() const
135 return has(operation_blocked);
137 inline bool is_clustered() const
139 return cluster_id > 0;
143 inline bool has12(operation_type type1, operation_type type2) const
145 return this->operations[0].operation == type1
146 && this->operations[1].operation == type2
153 }} // namespace detail::overlay
154 #endif //DOXYGEN_NO_DETAIL
157 }} // namespace boost::geometry
160 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TURN_INFO_HPP