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,
42 \brief Turn operation: operation
43 \details Information necessary for traversal phase (a phase
44 of the overlay process). The information is gathered during the
45 get_turns (segment intersection) phase.
46 The class is to be included in the turn_info class, either direct
47 or a derived or similar class with more (e.g. enrichment) information.
49 template <typename Point, typename SegmentRatio>
52 typedef SegmentRatio segment_ratio_type;
54 operation_type operation;
55 segment_identifier seg_id;
56 SegmentRatio fraction;
58 typedef typename coordinate_type<Point>::type comparable_distance_type;
59 comparable_distance_type remaining_distance;
61 inline turn_operation()
62 : operation(operation_none)
63 , remaining_distance(0)
69 \brief Turn information: intersection point, method, and turn information
70 \details Information necessary for traversal phase (a phase
71 of the overlay process). The information is gathered during the
72 get_turns (segment intersection) phase.
73 \tparam Point point type of intersection point
74 \tparam Operation gives classes opportunity to add additional info
75 \tparam Container gives classes opportunity to define how operations are stored
80 typename SegmentRatio = geometry::segment_ratio<typename coordinate_type<Point>::type>,
81 typename Operation = turn_operation<Point, SegmentRatio>,
82 typename Container = boost::array<Operation, 2>
86 typedef Point point_type;
87 typedef SegmentRatio segment_ratio_type;
88 typedef Operation turn_operation_type;
89 typedef Container container_type;
93 bool touch_only; // True in case of method touch(interior) and lines do not cross
94 signed_size_type cluster_id; // For multiple turns on same location, > 0. Else -1. 0 is unused.
96 bool has_colocated_both; // Colocated with a uu turn (for union) or ii (other)
101 : method(method_none)
105 , has_colocated_both(false)
108 inline bool both(operation_type type) const
110 return has12(type, type);
113 inline bool has(operation_type type) const
115 return this->operations[0].operation == type
116 || this->operations[1].operation == type;
119 inline bool combination(operation_type type1, operation_type type2) const
121 return has12(type1, type2) || has12(type2, type1);
124 inline bool blocked() const
126 return both(operation_blocked);
128 inline bool opposite() const
130 return both(operation_opposite);
132 inline bool any_blocked() const
134 return has(operation_blocked);
136 inline bool is_clustered() const
138 return cluster_id > 0;
142 inline bool has12(operation_type type1, operation_type type2) const
144 return this->operations[0].operation == type1
145 && this->operations[1].operation == type2
152 }} // namespace detail::overlay
153 #endif //DOXYGEN_NO_DETAIL
156 }} // namespace boost::geometry
159 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TURN_INFO_HPP