123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TURN_INFO_HPP
- #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TURN_INFO_HPP
- #include <array>
- #include <boost/geometry/core/coordinate_type.hpp>
- #include <boost/geometry/algorithms/detail/signed_size_type.hpp>
- #include <boost/geometry/algorithms/detail/overlay/segment_identifier.hpp>
- #include <boost/geometry/algorithms/detail/overlay/overlay_type.hpp>
- #include <boost/geometry/policies/robustness/segment_ratio.hpp>
- namespace boost { namespace geometry
- {
- #ifndef DOXYGEN_NO_DETAIL
- namespace detail { namespace overlay
- {
- enum method_type
- {
- method_none,
- method_disjoint,
- method_crosses,
- method_touch,
- method_touch_interior,
- method_collinear,
- method_equal,
- method_start,
- method_error
- };
- template <typename Point, typename SegmentRatio>
- struct turn_operation
- {
- typedef SegmentRatio segment_ratio_type;
- operation_type operation;
- segment_identifier seg_id;
- SegmentRatio fraction;
- typedef typename coordinate_type<Point>::type comparable_distance_type;
- comparable_distance_type remaining_distance;
- inline turn_operation()
- : operation(operation_none)
- , remaining_distance(0)
- {}
- };
- template
- <
- typename Point,
- typename SegmentRatio = geometry::segment_ratio<typename coordinate_type<Point>::type>,
- typename Operation = turn_operation<Point, SegmentRatio>,
- typename Container = std::array<Operation, 2>
- >
- struct turn_info
- {
- typedef Point point_type;
- typedef SegmentRatio segment_ratio_type;
- typedef Operation turn_operation_type;
- typedef Container container_type;
- Point point;
- method_type method;
- bool touch_only;
- signed_size_type cluster_id;
- bool discarded;
- bool has_colocated_both;
- Container operations;
- inline turn_info()
- : method(method_none)
- , touch_only(false)
- , cluster_id(-1)
- , discarded(false)
- , has_colocated_both(false)
- {}
- inline bool both(operation_type type) const
- {
- return has12(type, type);
- }
- inline bool has(operation_type type) const
- {
- return this->operations[0].operation == type
- || this->operations[1].operation == type;
- }
- inline bool combination(operation_type type1, operation_type type2) const
- {
- return has12(type1, type2) || has12(type2, type1);
- }
- inline bool blocked() const
- {
- return both(operation_blocked);
- }
- inline bool opposite() const
- {
- return both(operation_opposite);
- }
- inline bool any_blocked() const
- {
- return has(operation_blocked);
- }
- inline bool is_clustered() const
- {
- return cluster_id > 0;
- }
- inline bool is_self() const
- {
- return operations[0].seg_id.source_index
- == operations[1].seg_id.source_index;
- }
- private :
- inline bool has12(operation_type type1, operation_type type2) const
- {
- return this->operations[0].operation == type1
- && this->operations[1].operation == type2
- ;
- }
- };
- }}
- #endif
- }}
- #endif
|