File indexing completed on 2025-07-01 08:15:22
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_INTERSECTION_POLICY_HPP
0014 #define BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_INTERSECTION_POLICY_HPP
0015
0016
0017 #include <string>
0018 #include <tuple>
0019
0020 #include <boost/geometry/policies/relate/direction.hpp>
0021 #include <boost/geometry/policies/relate/intersection_points.hpp>
0022
0023 #include <boost/geometry/strategies/side_info.hpp>
0024
0025 namespace boost { namespace geometry
0026 {
0027
0028 namespace policies { namespace relate
0029 {
0030
0031
0032 template <typename IntersectionPointsReturnType>
0033 struct segments_intersection_policy
0034 {
0035 private:
0036 typedef policies::relate::segments_intersection_points
0037 <
0038 IntersectionPointsReturnType
0039 > pts_policy;
0040 typedef policies::relate::segments_direction dir_policy;
0041
0042 public:
0043 struct return_type
0044 {
0045 typedef typename pts_policy::return_type intersection_points_type;
0046 typedef typename dir_policy::return_type direction_type;
0047
0048 return_type(intersection_points_type const& pts_result,
0049 direction_type const& dir_result)
0050 : intersection_points(pts_result)
0051 , direction(dir_result)
0052 {}
0053
0054 intersection_points_type intersection_points;
0055 direction_type direction;
0056 };
0057
0058 template <typename Segment1, typename Segment2, typename SegmentIntersectionInfo>
0059 static inline return_type segments_crosses(side_info const& sides,
0060 SegmentIntersectionInfo const& sinfo,
0061 Segment1 const& s1, Segment2 const& s2)
0062 {
0063 return return_type
0064 (
0065 pts_policy::segments_crosses(sides, sinfo, s1, s2),
0066 dir_policy::segments_crosses(sides, sinfo, s1, s2)
0067 );
0068 }
0069
0070 template <typename SegmentIntersectionInfo, typename Point>
0071 static inline return_type
0072 segments_share_common_point(side_info const& sides,
0073 SegmentIntersectionInfo const& sinfo,
0074 Point const& p)
0075 {
0076 return return_type
0077 (
0078 pts_policy::segments_share_common_point(sides, sinfo, p),
0079 dir_policy::segments_share_common_point(sides, sinfo, p)
0080 );
0081 }
0082
0083 template <typename Segment1, typename Segment2, typename Ratio>
0084 static inline return_type segments_collinear(
0085 Segment1 const& segment1,
0086 Segment2 const& segment2,
0087 bool opposite,
0088 int pa1, int pa2, int pb1, int pb2,
0089 Ratio const& ra1, Ratio const& ra2,
0090 Ratio const& rb1, Ratio const& rb2)
0091 {
0092 return return_type
0093 (
0094 pts_policy::segments_collinear(segment1, segment2,
0095 opposite,
0096 pa1, pa2, pb1, pb2,
0097 ra1, ra2, rb1, rb2),
0098 dir_policy::segments_collinear(segment1, segment2,
0099 opposite,
0100 pa1, pa2, pb1, pb2,
0101 ra1, ra2, rb1, rb2)
0102 );
0103 }
0104
0105 template <typename Segment>
0106 static inline return_type degenerate(Segment const& segment,
0107 bool a_degenerate)
0108 {
0109 return return_type
0110 (
0111 pts_policy::degenerate(segment, a_degenerate),
0112 dir_policy::degenerate(segment, a_degenerate)
0113 );
0114 }
0115
0116 template <typename Segment, typename Ratio>
0117 static inline return_type one_degenerate(Segment const& segment,
0118 Ratio const& ratio,
0119 bool a_degenerate)
0120 {
0121 return return_type
0122 (
0123 pts_policy::one_degenerate(segment, ratio, a_degenerate),
0124 dir_policy::one_degenerate(segment, ratio, a_degenerate)
0125 );
0126 }
0127
0128 static inline return_type disjoint()
0129 {
0130 return return_type
0131 (
0132 pts_policy::disjoint(),
0133 dir_policy::disjoint()
0134 );
0135 }
0136
0137 static inline return_type error(std::string const& msg)
0138 {
0139 return return_type
0140 (
0141 pts_policy::error(msg),
0142 dir_policy::error(msg)
0143 );
0144 }
0145 };
0146
0147
0148 }}
0149
0150 }}
0151
0152 #endif