Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 09:50:19

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
0004 // Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland.
0005 
0006 // Use, modification and distribution is subject to the Boost Software License,
0007 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0008 // http://www.boost.org/LICENSE_1_0.txt)
0009 
0010 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TURN_INFO_HPP
0011 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TURN_INFO_HPP
0012 
0013 
0014 #include <array>
0015 
0016 #include <boost/geometry/core/coordinate_type.hpp>
0017 #include <boost/geometry/algorithms/detail/signed_size_type.hpp>
0018 #include <boost/geometry/algorithms/detail/overlay/segment_identifier.hpp>
0019 #include <boost/geometry/algorithms/detail/overlay/overlay_type.hpp>
0020 #include <boost/geometry/policies/robustness/segment_ratio.hpp>
0021 
0022 namespace boost { namespace geometry
0023 {
0024 
0025 #ifndef DOXYGEN_NO_DETAIL
0026 namespace detail { namespace overlay
0027 {
0028 
0029 enum method_type
0030 {
0031     method_none,
0032     method_disjoint,
0033     method_crosses,
0034     method_touch,
0035     method_touch_interior,
0036     method_collinear,
0037     method_equal,
0038     method_start,
0039     method_error
0040 };
0041 
0042 
0043 /*!
0044     \brief Turn operation: operation
0045     \details Information necessary for traversal phase (a phase
0046         of the overlay process). The information is gathered during the
0047         get_turns (segment intersection) phase.
0048         The class is to be included in the turn_info class, either direct
0049         or a derived or similar class with more (e.g. enrichment) information.
0050  */
0051 template <typename Point, typename SegmentRatio>
0052 struct turn_operation
0053 {
0054     using segment_ratio_type = SegmentRatio;
0055 
0056     operation_type operation;
0057     segment_identifier seg_id;
0058     segment_ratio_type fraction;
0059 
0060     using comparable_distance_type = coordinate_type_t<Point>;
0061     comparable_distance_type remaining_distance;
0062 
0063     inline turn_operation()
0064         : operation(operation_none)
0065         , remaining_distance(0)
0066     {}
0067 };
0068 
0069 
0070 /*!
0071     \brief Turn information: intersection point, method, and turn information
0072     \details Information necessary for traversal phase (a phase
0073         of the overlay process). The information is gathered during the
0074         get_turns (segment intersection) phase.
0075     \tparam Point point type of intersection point
0076     \tparam Operation gives classes opportunity to add additional info
0077     \tparam Container gives classes opportunity to define how operations are stored
0078  */
0079 template
0080 <
0081     typename Point,
0082     typename SegmentRatio = geometry::segment_ratio<coordinate_type_t<Point>>,
0083     typename Operation = turn_operation<Point, SegmentRatio>,
0084     typename Container = std::array<Operation, 2>
0085 >
0086 struct turn_info
0087 {
0088     using point_type = Point;
0089     using segment_ratio_type = SegmentRatio;
0090     using turn_operation_type = Operation;
0091     using container_type = Container;
0092 
0093     Point point;
0094     method_type method;
0095     bool touch_only; // True in case of method touch(interior) and lines do not cross
0096     signed_size_type cluster_id; // For multiple turns on same location, > 0. Else -1. 0 is unused.
0097     bool discarded;
0098     bool has_colocated_both; // Colocated with a uu turn (for union) or ii (other)
0099 
0100     Container operations;
0101 
0102     inline turn_info()
0103         : method(method_none)
0104         , touch_only(false)
0105         , cluster_id(-1)
0106         , discarded(false)
0107         , has_colocated_both(false)
0108     {}
0109 
0110     inline bool both(operation_type type) const
0111     {
0112         return has12(type, type);
0113     }
0114 
0115     inline bool has(operation_type type) const
0116     {
0117         return this->operations[0].operation == type
0118             || this->operations[1].operation == type;
0119     }
0120 
0121     inline bool combination(operation_type type1, operation_type type2) const
0122     {
0123         return has12(type1, type2) || has12(type2, type1);
0124     }
0125 
0126     inline bool blocked() const
0127     {
0128         return both(operation_blocked);
0129     }
0130     inline bool opposite() const
0131     {
0132         return both(operation_opposite);
0133     }
0134     inline bool any_blocked() const
0135     {
0136         return has(operation_blocked);
0137     }
0138     inline bool is_clustered() const
0139     {
0140         return cluster_id > 0;
0141     }
0142     inline bool is_self() const
0143     {
0144         return operations[0].seg_id.source_index
0145                 == operations[1].seg_id.source_index;
0146     }
0147 
0148 private :
0149     inline bool has12(operation_type type1, operation_type type2) const
0150     {
0151         return this->operations[0].operation == type1
0152             && this->operations[1].operation == type2
0153             ;
0154     }
0155 
0156 };
0157 
0158 
0159 }} // namespace detail::overlay
0160 #endif //DOXYGEN_NO_DETAIL
0161 
0162 
0163 }} // namespace boost::geometry
0164 
0165 
0166 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TURN_INFO_HPP